]> code.delx.au - gnu-emacs/commitdiff
Merge from mainline.
authorEli Zaretskii <eliz@gnu.org>
Mon, 18 Nov 2013 16:45:48 +0000 (18:45 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 18 Nov 2013 16:45:48 +0000 (18:45 +0200)
447 files changed:
ChangeLog
GNUmakefile
Makefile.in
admin/ChangeLog
admin/FOR-RELEASE
admin/unidata/BidiMirroring.txt
admin/unidata/Makefile.in
admin/unidata/UnicodeData.txt
admin/unidata/copyright.html
admin/unidata/unidata-gen.el
admin/update_autogen [moved from autogen/update_autogen with 76% similarity]
autogen.sh
autogen/README [deleted file]
autogen/aclocal.m4 [deleted file]
autogen/compile [deleted file]
autogen/config.guess [deleted file]
autogen/config.sub [deleted file]
autogen/configure [deleted file]
autogen/copy_autogen [deleted file]
autogen/depcomp [deleted file]
autogen/install-sh [deleted file]
autogen/missing [deleted file]
build-aux/update-subdirs
config.bat
configure.ac
doc/emacs/ChangeLog
doc/emacs/Makefile.in
doc/emacs/cmdargs.texi
doc/emacs/custom.texi
doc/emacs/files.texi
doc/emacs/glossary.texi
doc/emacs/killing.texi
doc/emacs/search.texi
doc/emacs/sending.texi
doc/lispintro/ChangeLog
doc/lispintro/Makefile.in
doc/lispref/ChangeLog
doc/lispref/Makefile.in
doc/lispref/display.texi
doc/lispref/eval.texi
doc/lispref/files.texi
doc/lispref/intro.texi
doc/lispref/keymaps.texi
doc/lispref/lists.texi
doc/lispref/loading.texi
doc/lispref/nonascii.texi
doc/lispref/objects.texi
doc/lispref/os.texi
doc/lispref/searching.texi
doc/misc/ChangeLog
doc/misc/Makefile.in
doc/misc/calc.texi
doc/misc/dired-x.texi
doc/misc/ebrowse.texi
doc/misc/ede.texi
doc/misc/eieio.texi
doc/misc/epa.texi
doc/misc/ert.texi
doc/misc/eshell.texi
doc/misc/org.texi
doc/misc/pcl-cvs.texi
doc/misc/sc.texi
doc/misc/srecode.texi
doc/misc/vip.texi
doc/misc/viper.texi
doc/misc/widget.texi
etc/ChangeLog
etc/NEWS
etc/ORG-NEWS
etc/TODO
etc/refcards/orgcard.tex
leim/ChangeLog
leim/Makefile.in
lib-src/ChangeLog
lib-src/Makefile.in
lib-src/ebrowse.c
lib-src/etags.c
lib/fpending.h
lib/intprops.h
lisp/ChangeLog
lisp/Makefile.in
lisp/allout-widgets.el
lisp/arc-mode.el
lisp/battery.el
lisp/bindings.el
lisp/buff-menu.el
lisp/calc/calc.el
lisp/cedet/ChangeLog
lisp/cedet/ede/proj-elisp.el
lisp/cedet/pulse.el
lisp/cedet/semantic/db-mode.el
lisp/cedet/semantic/fw.el
lisp/cedet/semantic/grammar.el
lisp/cedet/semantic/idle.el
lisp/cedet/semantic/lex.el
lisp/comint.el
lisp/composite.el
lisp/custom.el
lisp/delsel.el
lisp/dos-w32.el
lisp/electric.el
lisp/emacs-lisp/autoload.el
lisp/emacs-lisp/byte-run.el
lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/cconv.el
lisp/emacs-lisp/cl-indent.el
lisp/emacs-lisp/cl-macs.el
lisp/emacs-lisp/ert.el
lisp/emacs-lisp/gv.el
lisp/emacs-lisp/helpers.el [new file with mode: 0644]
lisp/emacs-lisp/lisp-mode.el
lisp/emacs-lisp/nadvice.el
lisp/emacs-lisp/package.el
lisp/emacs-lisp/smie.el
lisp/epa-file.el
lisp/erc/ChangeLog
lisp/erc/erc-pcomplete.el
lisp/eshell/em-ls.el
lisp/faces.el
lisp/files.el
lisp/frame.el
lisp/gnus/ChangeLog
lisp/gnus/gnus-cite.el
lisp/gnus/gnus-group.el
lisp/gnus/gnus-icalendar.el
lisp/gnus/gnus-int.el
lisp/gnus/mm-decode.el
lisp/gnus/nnimap.el
lisp/hfy-cmap.el
lisp/htmlfontify.el
lisp/ido.el
lisp/image.el
lisp/international/README
lisp/international/characters.el
lisp/international/charprop.el
lisp/international/quail.el
lisp/international/uni-bidi.el
lisp/international/uni-category.el
lisp/international/uni-combining.el
lisp/international/uni-comment.el
lisp/international/uni-decimal.el
lisp/international/uni-decomposition.el
lisp/international/uni-digit.el
lisp/international/uni-lowercase.el
lisp/international/uni-mirrored.el
lisp/international/uni-name.el
lisp/international/uni-numeric.el
lisp/international/uni-old-name.el
lisp/international/uni-titlecase.el
lisp/international/uni-uppercase.el
lisp/iswitchb.el
lisp/ldefs-boot.el
lisp/linum.el
lisp/loadhist.el
lisp/loadup.el
lisp/lpr.el
lisp/man.el
lisp/menu-bar.el
lisp/mh-e/ChangeLog
lisp/mh-e/mh-print.el
lisp/net/rcirc.el
lisp/net/tramp-cmds.el
lisp/net/tramp-compat.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp.el
lisp/obsolete/assoc.el
lisp/org/ChangeLog
lisp/org/ob-C.el
lisp/org/ob-R.el
lisp/org/ob-awk.el
lisp/org/ob-calc.el
lisp/org/ob-clojure.el
lisp/org/ob-comint.el
lisp/org/ob-core.el [new file with mode: 0644]
lisp/org/ob-ditaa.el
lisp/org/ob-dot.el
lisp/org/ob-emacs-lisp.el
lisp/org/ob-eval.el
lisp/org/ob-exp.el
lisp/org/ob-fortran.el
lisp/org/ob-gnuplot.el
lisp/org/ob-haskell.el
lisp/org/ob-io.el
lisp/org/ob-java.el
lisp/org/ob-js.el
lisp/org/ob-keys.el
lisp/org/ob-latex.el
lisp/org/ob-lilypond.el
lisp/org/ob-lisp.el
lisp/org/ob-lob.el
lisp/org/ob-makefile.el [new file with mode: 0644]
lisp/org/ob-maxima.el
lisp/org/ob-mscgen.el
lisp/org/ob-ocaml.el
lisp/org/ob-octave.el
lisp/org/ob-org.el
lisp/org/ob-perl.el
lisp/org/ob-picolisp.el
lisp/org/ob-plantuml.el
lisp/org/ob-python.el
lisp/org/ob-ref.el
lisp/org/ob-ruby.el
lisp/org/ob-sass.el
lisp/org/ob-scala.el
lisp/org/ob-scheme.el
lisp/org/ob-screen.el
lisp/org/ob-sh.el
lisp/org/ob-shen.el
lisp/org/ob-sql.el
lisp/org/ob-sqlite.el
lisp/org/ob-table.el
lisp/org/ob-tangle.el
lisp/org/ob.el
lisp/org/org-agenda.el
lisp/org/org-archive.el
lisp/org/org-ascii.el [deleted file]
lisp/org/org-attach.el
lisp/org/org-bbdb.el
lisp/org/org-beamer.el [deleted file]
lisp/org/org-bibtex.el
lisp/org/org-capture.el
lisp/org/org-clock.el
lisp/org/org-colview.el
lisp/org/org-compat.el
lisp/org/org-crypt.el
lisp/org/org-ctags.el
lisp/org/org-datetree.el
lisp/org/org-docbook.el [deleted file]
lisp/org/org-docview.el
lisp/org/org-element.el
lisp/org/org-entities.el
lisp/org/org-exp-blocks.el [deleted file]
lisp/org/org-exp.el [deleted file]
lisp/org/org-faces.el
lisp/org/org-footnote.el
lisp/org/org-freemind.el [deleted file]
lisp/org/org-gnus.el
lisp/org/org-habit.el
lisp/org/org-html.el [deleted file]
lisp/org/org-icalendar.el [deleted file]
lisp/org/org-id.el
lisp/org/org-indent.el
lisp/org/org-inlinetask.el
lisp/org/org-jsinfo.el [deleted file]
lisp/org/org-latex.el [deleted file]
lisp/org/org-list.el
lisp/org/org-lparse.el [deleted file]
lisp/org/org-mac-message.el [deleted file]
lisp/org/org-macro.el [new file with mode: 0644]
lisp/org/org-macs.el
lisp/org/org-mew.el [deleted file]
lisp/org/org-mhe.el
lisp/org/org-mks.el [deleted file]
lisp/org/org-mobile.el
lisp/org/org-mouse.el
lisp/org/org-odt.el [deleted file]
lisp/org/org-pcomplete.el
lisp/org/org-plot.el
lisp/org/org-protocol.el
lisp/org/org-publish.el [deleted file]
lisp/org/org-remember.el [deleted file]
lisp/org/org-special-blocks.el [deleted file]
lisp/org/org-src.el
lisp/org/org-table.el
lisp/org/org-taskjuggler.el [deleted file]
lisp/org/org-timer.el
lisp/org/org-version.el
lisp/org/org-vm.el [deleted file]
lisp/org/org-w3m.el
lisp/org/org-wl.el [deleted file]
lisp/org/org-xoxo.el [deleted file]
lisp/org/org.el
lisp/org/ox-ascii.el [new file with mode: 0644]
lisp/org/ox-beamer.el [new file with mode: 0644]
lisp/org/ox-html.el [new file with mode: 0644]
lisp/org/ox-icalendar.el [new file with mode: 0644]
lisp/org/ox-latex.el [new file with mode: 0644]
lisp/org/ox-man.el [new file with mode: 0644]
lisp/org/ox-md.el [new file with mode: 0644]
lisp/org/ox-odt.el [new file with mode: 0644]
lisp/org/ox-org.el [new file with mode: 0644]
lisp/org/ox-publish.el [new file with mode: 0644]
lisp/org/ox-texinfo.el [new file with mode: 0644]
lisp/org/ox.el [new file with mode: 0644]
lisp/progmodes/autoconf.el
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-fonts.el
lisp/progmodes/cfengine.el
lisp/progmodes/compile.el
lisp/progmodes/cperl-mode.el
lisp/progmodes/ebnf2ps.el
lisp/progmodes/gdb-mi.el
lisp/progmodes/gud.el
lisp/progmodes/inf-lisp.el
lisp/progmodes/octave.el
lisp/progmodes/prolog.el
lisp/progmodes/python.el
lisp/progmodes/ruby-mode.el
lisp/progmodes/scheme.el
lisp/progmodes/sh-script.el
lisp/progmodes/verilog-mode.el
lisp/ps-print.el
lisp/rect.el
lisp/replace.el
lisp/simple.el
lisp/startup.el
lisp/subr.el
lisp/term/ns-win.el
lisp/term/w32-win.el
lisp/textmodes/fill.el
lisp/textmodes/ispell.el
lisp/textmodes/reftex-parse.el
lisp/textmodes/remember.el
lisp/textmodes/text-mode.el
lisp/thingatpt.el
lisp/vc/pcvs.el
lisp/vc/vc-rcs.el
lisp/vc/vc.el
lisp/widget.el
lisp/window.el
lwlib/ChangeLog
lwlib/Makefile.in
lwlib/lwlib.c
m4/acl.m4
m4/extern-inline.m4
m4/fpending.m4
make-dist
msdos/ChangeLog
msdos/autogen/Makefile.in [moved from autogen/Makefile.in with 100% similarity]
msdos/autogen/config.in [moved from autogen/config.in with 99% similarity]
msdos/mainmake.v2
nextstep/ChangeLog
nextstep/Makefile.in
nt/ChangeLog
nt/INSTALL
nt/Makefile.in
nt/config.nt
nt/mingw-cfg.site
nt/msysconfig.sh [deleted file]
oldXMenu/ChangeLog
oldXMenu/Makefile.in
src/ChangeLog
src/ChangeLog.12
src/Makefile.in
src/alloc.c
src/buffer.c
src/buffer.h
src/bytecode.c
src/callproc.c
src/casefiddle.c
src/category.c
src/category.h
src/ccl.c
src/character.h
src/chartab.c
src/coding.c
src/commands.h
src/composite.c
src/composite.h
src/conf_post.h
src/data.c
src/dispextern.h
src/dispnew.c
src/disptab.h
src/doc.c
src/dosfns.c
src/editfns.c
src/emacs.c
src/eval.c
src/fileio.c
src/floatfns.c
src/fns.c
src/font.c
src/font.h
src/fontset.c
src/frame.c
src/fringe.c
src/ftfont.c
src/ftxfont.c
src/gmalloc.c
src/gnutls.c
src/gtkutil.c
src/image.c
src/indent.c
src/insdel.c
src/keyboard.c
src/keymap.c
src/lisp.h
src/lread.c
src/macfont.h
src/macfont.m
src/macros.c
src/menu.h
src/minibuf.c
src/msdos.c
src/nsfns.m
src/nsfont.m
src/nsterm.h
src/nsterm.m
src/print.c
src/process.c
src/regex.c
src/regex.h
src/search.c
src/term.c
src/w32.c
src/w32fns.c
src/w32font.c
src/w32font.h
src/w32inevt.c
src/w32menu.c
src/w32term.c
src/w32term.h
src/w32uniscribe.c
src/window.c
src/window.h
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xfont.c
src/xftfont.c
src/xmenu.c
src/xrdb.c
src/xselect.c
src/xsettings.c
src/xterm.c
src/xterm.h
test/ChangeLog
test/automated/Makefile.in
test/automated/eieio-tests.el
test/automated/ert-tests.el
test/automated/ert-x-tests.el
test/automated/file-notify-tests.el
test/automated/files.el
test/automated/flymake-tests.el
test/automated/info-xref.el
test/automated/process-tests.el [new file with mode: 0644]
test/automated/ruby-mode-tests.el
test/automated/tramp-tests.el [new file with mode: 0644]
test/automated/vc-bzr.el
test/automated/zlib-tests.el
test/indent/css-mode.css
test/indent/prolog.prolog
test/indent/ruby.rb
test/indent/shell.sh

index c1700c017a3902c53bc6d62dc437d65a98e22220..30c87c3e61363bf04a92c50c30cf00296e776d08 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,135 @@
+2013-11-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * configure.ac (DEBUGGER_SEES_C_MACROS): Remove.
+       It apparently doesn't work for GCC 3, and I suppose it's more
+       trouble than it's worth to worry about this.
+
+2013-11-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * configure.ac (DEBUGGER_SEES_C_MACROS): New macro.
+
+2013-11-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify, port and tune bool vector implementation.
+       * configure.ac (BITSIZEOF_SIZE_T, SIZEOF_SIZE_T): Remove.
+
+2013-11-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * Makefile.in (ACLOCAL_INPUTS): Add configure.ac.
+
+2013-11-12  Dani Moncayo  <dmoncayo@gmail.com>
+
+       * configure.ac [MINGW32]: Source nt/mingw-cfg.site.
+       * make-dist: Don't distribute nt/msysconfig.sh.
+
+       * Makefile.in (epaths-force-w32): Simplify w32srcdir computation.
+
+2013-11-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Merge from gnulib, incorporating:
+       2013-11-08 extern-inline: port better to OS X 10.9
+       2013-11-08 fpending: fix regression on DragonFly BSD
+       * lib/fpending.h, m4/extern-inline.m4, m4/fpending.m4:
+       Update from gnulib.
+
+2013-11-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to C11 aligned_alloc.
+       * configure.ac (GMALLOC_OBJ): Initialize to empty if !system_malloc
+       and doug_lea_malloc.
+       (aligned_alloc): Test for existence if !GMALLOC_OBJ and not darwin.
+       (posix_memalign): Test for existence only if !GMALLOC_OBJ and
+       not darwin and !aligned_alloc.
+
+2013-11-05  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac (abs_srcdir) [MINGW32]: No point setting it here,
+       config.status computes it.
+       * Makefile.in (epaths-force-w32): Move srcdir tweak here.
+
+       * autogen: Remove directory.  Move update_autogen to admin/.
+       * autogen.sh: Remove reference to copy_autogen.
+       * GNUmakefile (configure):
+       * Makefile.in (bootstrap): Do not try to run copy_autogen.
+       * config.bat: Use msdos/autogen rather than autogen.
+
+2013-11-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify and port recent bool vector changes.
+       * configure.ac (BITSIZEOF_SIZE_T, SIZEOF_SIZE_T):
+       New symbols to configure.
+
+2013-11-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * configure.ac: Don't disallow builds in non-ASCII directories.
+       (Bug#15260)
+
+2013-11-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to stricter C99 platforms.
+       Merge from gnulib, incorporating:
+       2013-11-03 intprops: port to Oracle Studio c99
+       * lib/intprops.h: Update from gnulib.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (check): Depend on all.
+
+2013-10-31  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac: Use [!...] rather than [^...], for ksh.  (Bug#15769)
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (distclean, bootstrap-clean, maintainer-clean):
+       Also clean admin/unidata, if present.
+
+2013-10-27  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac: It seems installing in non-ASCII is not, in fact, ok.
+
+2013-10-25  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac: It seems _installing_ in non-ASCII is ok, not building.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac:
+       * Makefile.in (install-arch-indep, install-etcdoc, install-info):
+       Avoid non-portable "`\" nesting.
+
+       * configure.ac (CPPFLAGS) [mingw32]: Use abs_top_srcdir.
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * configure.ac: Explicit error for non-ASCII directories.  (Bug#15260)
+
+       Progress towards allowing installation in directories with whitespace.
+       * Makefile.in (COPYDESTS, write_subdir, install-arch-dep)
+       (install-arch-indep, install-etcdoc, install-info, install-man)
+       (install-etc, uninstall, install-nt, uninstall-nt):
+       Quote entities that might contain whitespace.
+       * build-aux/update-subdirs: Handle whitespace in argument.
+       Check cd return value.
+
+       Make building in directories with whitespace possible.  (Bug#15675)
+       * configure.ac (srcdir): Don't make it absolute - abs_srcdir exists.
+       (src/.gdbinit): Use ac_abs_top_srcdir.
+       * Makefile.in (abs_srcdir): New, set by configure.
+       (buildlisppath, epaths-force-w32): Use abs_srcdir.
+       (install-arch-indep, install-etcdoc, install-info, install-man)
+       (install-etc): Quote entities that might contain whitespace.
+
+2013-10-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Merge from gnulib, incorporating:
+       2013-10-14 acl: allow cross-compilation to Gentoo
+       2013-10-18 extern-inline: make safe for -Wundef usage
+       2013-09-30 fpending: use pure+const function attrs
+       * lib/fpending.h, m4/acl.m4, m4/extern-inline.m4: Update from gnulib.
+
 2013-10-13  Glenn Morris  <rgm@gnu.org>
 
        * configure.ac [alpha]: Explicit error in non-ELF case.  (Bug#15601)
index a2a630ba9d573c6e3f39d2a4f281bda90521ec69..25c586d8356d6b5597928f5a42868f07b41d41e9 100644 (file)
@@ -68,8 +68,8 @@ default $(filter-out configure Makefile,$(MAKECMDGOALS)): Makefile
 
 configure:
        @echo >&2 'There seems to be no "configure" file in this directory.'
-       @echo >&2 'Running ./autogen.sh || autogen/copy_autogen ...'
-       ./autogen.sh || autogen/copy_autogen
+       @echo >&2 'Running ./autogen.sh ...'
+       ./autogen.sh
        @echo >&2 '"configure" file built.'
 
 Makefile: configure
index c6254fd6098969aa98318dda3b68ca3e62a690ce..e00eb790d66e4d6afe717665f053c9fd2e4cff78 100644 (file)
@@ -163,6 +163,9 @@ bitmapdir=@bitmapdir@
 
 # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
 srcdir=@srcdir@
+abs_srcdir=@abs_srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 
 # Where the manpage source files are kept.
 mansrcdir=$(srcdir)/doc/man
@@ -216,7 +219,7 @@ lisppath=@lisppath@
 # before they've been installed in their final location.
 # This should be a colon-separated list of directories.
 # Normally it points to the lisp/ directory in the sources.
-buildlisppath=${srcdir}/lisp
+buildlisppath=${abs_srcdir}/lisp
 
 # Where to install the other architecture-independent
 # data files distributed with Emacs (like the tutorial,
@@ -283,7 +286,7 @@ SUBDIR_MAKEFILES = `echo $(SUBDIR_MAKEFILES_IN:.in=) | sed 's|$(srcdir)/||g'`
 # separately.  quail appears twice because in out-of-tree builds, it
 # exists twice.
 COPYDIR = ${srcdir}/etc ${srcdir}/lisp ${srcdir}/leim/ja-dic ${srcdir}/leim/quail leim/quail
-COPYDESTS = $(DESTDIR)${etcdir} $(DESTDIR)${lispdir} $(DESTDIR)${leimdir}/ja-dic $(DESTDIR)${leimdir}/quail $(DESTDIR)${leimdir}/quail
+COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}" "$(DESTDIR)${leimdir}/ja-dic" "$(DESTDIR)${leimdir}/quail" "$(DESTDIR)${leimdir}/quail"
 
 all: ${SUBDIR}
 
@@ -339,8 +342,16 @@ msys_sed_sh_escape=sed -e 's/[];$$*.^[]/\\\\&/g'
 # nt/epaths.nt as the template.
 # Use the value of ${locallisppath} supplied by `configure',
 # to support the --enable-locallisppath argument.
+#
+# When building with MinGW inside the MSYS tree, 'pwd' produces directories
+# relative to the root of the MSYS tree, e.g. '/home/user/foo' instead of
+# '/d/MSYS/home/user/foo'.  If such a value of srcdir is written to
+# src/epaths.h, that causes temacs to fail, because, being a MinGW
+# program that knows nothing of MSYS root substitution, it cannot find
+# the data directory.  "pwd -W" produces Windows-style 'd:/foo/bar'
+# absolute directory names, so we use it here to countermand that lossage.
 epaths-force-w32: FRC
-       @(w32srcdir=`echo "${srcdir}" | ${msys_to_w32}` ;       \
+       @(w32srcdir=`cd "${srcdir}" && pwd -W` ; \
          prefixpattern=`echo '${prefix}' | ${msys_to_w32} | ${msys_sed_sh_escape}` ; \
          locallisppath=`echo '${locallisppath}' | ${msys_lisppath_to_w32} | ${msys_prefix_subst}` ; \
          sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$          \
@@ -424,7 +435,7 @@ AUTOCONF_INPUTS = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
 $(srcdir)/configure: $(AUTOCONF_INPUTS)
        cd ${srcdir} && autoconf
 
-ACLOCAL_INPUTS = $(srcdir)/m4/gnulib-comp.m4
+ACLOCAL_INPUTS = $(srcdir)/configure.ac $(srcdir)/m4/gnulib-comp.m4
 $(srcdir)/aclocal.m4: $(ACLOCAL_INPUTS)
        cd $(srcdir) && aclocal -I m4
 
@@ -468,32 +479,32 @@ install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR)
 ## world-readable.
 ## TODO it might be good to warn about non-standard permissions of
 ## pre-existing directories, but that does not seem easy.
-write_subdir=if [ -f $${subdir}/subdirs.el ]; \
+write_subdir=if [ -f "$${subdir}/subdirs.el" ]; \
        then true; \
        else \
          umask 022; \
-         ${MKDIR_P} $${subdir}; \
+         ${MKDIR_P} "$${subdir}"; \
          (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
           echo "    (normal-top-level-add-subdirs-to-load-path))") \
-           > $${subdir}/subdirs.el; \
+           > "$${subdir}/subdirs.el"; \
        fi
 
 ### Install the executables that were compiled specifically for this machine.
 ### We do install-arch-indep first because the executable needs the
 ### Lisp files and DOC file to work properly.
 install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR)
-       umask 022; ${MKDIR_P} $(DESTDIR)${bindir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
        cd lib-src && \
-         $(MAKE) install $(MFLAGS) prefix=${prefix} \
-           exec_prefix=${exec_prefix} bindir=${bindir} \
-           libexecdir=${libexecdir} archlibdir=${archlibdir} \
+         $(MAKE) install $(MFLAGS) prefix="${prefix}" \
+           exec_prefix="${exec_prefix}" bindir="${bindir}" \
+           libexecdir="${libexecdir}" archlibdir="${archlibdir}" \
            INSTALL_STRIP=${INSTALL_STRIP}
        if test "${ns_self_contained}" = "no"; then \
-         ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} $(DESTDIR)${bindir}/$(EMACSFULL) || exit 1 ; \
-         chmod 1755 $(DESTDIR)${bindir}/$(EMACSFULL) || true; \
+         ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)" || exit 1 ; \
+         chmod 1755 "$(DESTDIR)${bindir}/$(EMACSFULL)" || true; \
          if test "x${NO_BIN_LINK}" = x; then \
-           rm -f $(DESTDIR)${bindir}/$(EMACS) ; \
-           cd $(DESTDIR)${bindir} && $(LN_S_FILEONLY) $(EMACSFULL) $(EMACS); \
+           rm -f "$(DESTDIR)${bindir}/$(EMACS)" ; \
+           cd "$(DESTDIR)${bindir}" && $(LN_S_FILEONLY) $(EMACSFULL) $(EMACS); \
          fi; \
        else \
          subdir=${ns_appresdir}/site-lisp; \
@@ -506,9 +517,9 @@ install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR)
 install-:
 install-nt:
        cd $(NTDIR) && \
-         $(MAKE) install $(MFLAGS) prefix=${prefix} \
-           exec_prefix=${exec_prefix} bindir=${bindir} \
-           libexecdir=${libexecdir} archlibdir=${archlibdir} \
+         $(MAKE) install $(MFLAGS) prefix="${prefix}" \
+           exec_prefix="${exec_prefix}" bindir="${bindir}" \
+           libexecdir="${libexecdir}" archlibdir="${archlibdir}" \
            INSTALL_STRIP=${INSTALL_STRIP}
 
 ## In the share directory, we are deleting:
@@ -567,62 +578,66 @@ install-arch-indep: lisp leim install-info install-man ${INSTALL_ARCH_INDEP_EXTR
        $(set_installuser); \
        for dir in ${COPYDIR} ; do \
          [ -d $${dir} ] || exit 1 ; \
-         dest=$$1 ; shift ; \
-         [ -d $${dest} ] && \
-           [ `cd $${dest} && /bin/pwd` = `cd $${dir} && /bin/pwd` ] && \
-           continue ; \
+         dest="$$1" ; shift ; \
+         if [ -d "$${dest}" ]; then \
+           exp_dest=`cd "$${dest}" && /bin/pwd`; \
+           [ "$$exp_dest" = "`cd $${dir} && /bin/pwd`" ] && continue ; \
+         else true; \
+         fi; \
          if [ "$${dir}" = "leim/quail" ]; then \
-           [ `cd $${dir} && /bin/pwd` = `cd ${srcdir}/leim/quail && /bin/pwd` ] && \
+           [ "`cd $${dir} && /bin/pwd`" = "`cd ${srcdir}/leim/quail && /bin/pwd`" ] && \
              continue ; \
          else \
-           rm -rf $${dest} ; \
-           umask 022; ${MKDIR_P} $${dest} ; \
+           rm -rf "$${dest}" ; \
+           umask 022; ${MKDIR_P} "$${dest}" ; \
          fi ; \
          echo "Copying $${dir} to $${dest}..." ; \
          (cd $${dir}; tar -chf - . ) \
-           | (cd $${dest}; umask 022; \
+           | (cd "$${dest}"; umask 022; \
               tar -xvf - && cat > /dev/null) || exit 1; \
          if [ "$${dir}" = "${srcdir}/etc" ]; then \
-             rm -f $${dest}/DOC* ; \
-             rm -f $${dest}/refcards/*.aux $${dest}/refcards/*.dvi; \
-             rm -f $${dest}/refcards/*.log; \
+             rm -f "$${dest}/DOC"* ; \
+             rm -f "$${dest}/refcards"/*.aux "$${dest}/refcards"/*.dvi; \
+             rm -f "$${dest}/refcards"/*.log; \
          else true; \
          fi; \
-         for subdir in `find $${dest} -type d -print` ; do \
-           chmod a+rx $${subdir} ; \
-           rm -f $${subdir}/.gitignore ; \
-           rm -f $${subdir}/.arch-inventory ; \
-           rm -f $${subdir}/.DS_Store ; \
-           rm -f $${subdir}/\#* ; \
-           rm -f $${subdir}/.\#* ; \
-           rm -f $${subdir}/*~ ; \
-           rm -f $${subdir}/*.orig ; \
-           rm -f $${subdir}/ChangeLog* ; \
-           [ "$${dir}" != "${srcdir}/etc" ] && \
-             rm -f $${subdir}/[mM]akefile*[.-]in $${subdir}/[mM]akefile ; \
-         done ; \
-         find $${dest} -exec chown $${installuser} {} ';' ;\
+         (cd "$${dest}" || exit 1; \
+           for subdir in `find . -type d -print` ; do \
+             chmod a+rx $${subdir} ; \
+             rm -f $${subdir}/.gitignore ; \
+             rm -f $${subdir}/.arch-inventory ; \
+             rm -f $${subdir}/.DS_Store ; \
+             rm -f $${subdir}/\#* ; \
+             rm -f $${subdir}/.\#* ; \
+             rm -f $${subdir}/*~ ; \
+             rm -f $${subdir}/*.orig ; \
+             rm -f $${subdir}/ChangeLog* ; \
+             [ "$${dir}" != "${srcdir}/etc" ] && \
+               rm -f $${subdir}/[mM]akefile*[.-]in $${subdir}/[mM]akefile ; \
+           done ); \
+         find "$${dest}" -exec chown $${installuser} {} ';' ;\
        done
-       -rm -f $(DESTDIR)${leimdir}/leim-list.el
-       ${INSTALL_DATA} leim/leim-list.el $(DESTDIR)${leimdir}/leim-list.el
-       -rm -f $(DESTDIR)${lispdir}/subdirs.el
-       umask 022; $(srcdir)/build-aux/update-subdirs $(DESTDIR)${lispdir}
-       subdir=$(DESTDIR)${datadir}/emacs/${version}/site-lisp ; \
+       -rm -f "$(DESTDIR)${leimdir}/leim-list.el"
+       ${INSTALL_DATA} leim/leim-list.el "$(DESTDIR)${leimdir}/leim-list.el"
+       -rm -f "$(DESTDIR)${lispdir}/subdirs.el"
+       umask 022; $(srcdir)/build-aux/update-subdirs "$(DESTDIR)${lispdir}"
+       subdir="$(DESTDIR)${datadir}/emacs/${version}/site-lisp" ; \
          ${write_subdir}
-       subdir=$(DESTDIR)${datadir}/emacs/site-lisp ; \
+       subdir="$(DESTDIR)${datadir}/emacs/site-lisp" ; \
          ${write_subdir} || true
        [ -z "${GZIP_PROG}" ] || \
          ( echo "Compressing *.el ..." ; \
            unset CDPATH; \
            thisdir=`/bin/pwd`; \
-           for dir in $(DESTDIR)${lispdir} $(DESTDIR)${leimdir}; do \
-             cd $${thisdir} ; \
-             cd $${dir} || exit 1 ; \
+           for dir in "$(DESTDIR)${lispdir}" "$(DESTDIR)${leimdir}"; do \
+             cd "$${thisdir}" ; \
+             cd "$${dir}" || exit 1 ; \
              for f in `find . -name "*.elc" -print`; do \
-               ${GZIP_PROG} -9n `echo $$f|sed 's/.elc$$/.el/'` ; \
+               f_el=`echo "$$f" | sed 's/.elc$$/.el/'`; \
+               ${GZIP_PROG} -9n "$$f_el" ; \
              done ; \
            done )
-       -chmod -R a+r $(DESTDIR)${datadir}/emacs/${version} ${COPYDESTS}
+       -chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS}
 
 ## The above chmods are needed because "umask 022; tar ..." is not
 ## guaranteed to do the right thing; eg if we are root and tar is
@@ -632,41 +647,44 @@ install-arch-indep: lisp leim install-info install-man ${INSTALL_ARCH_INDEP_EXTR
 ## installed etc/ directory, so we need it to run before this does.
 install-etcdoc: src install-arch-indep
        -unset CDPATH; \
-       umask 022; ${MKDIR_P} $(DESTDIR)${etcdocdir} ; \
-       if [ `cd ./etc; /bin/pwd` != `cd $(DESTDIR)${etcdocdir}; /bin/pwd` ]; \
+       umask 022; ${MKDIR_P} "$(DESTDIR)${etcdocdir}" ; \
+       exp_etcdocdir=`cd "$(DESTDIR)${etcdocdir}"; /bin/pwd`; \
+       if [ "`cd ./etc; /bin/pwd`" != "$$exp_etcdocdir" ]; \
        then \
           docfile="DOC"; \
           echo "Copying etc/$${docfile} to $(DESTDIR)${etcdocdir} ..." ; \
-          ${INSTALL_DATA} etc/$${docfile} $(DESTDIR)${etcdocdir}/$${docfile}; \
+          ${INSTALL_DATA} etc/$${docfile} "$(DESTDIR)${etcdocdir}/$${docfile}"; \
           $(set_installuser); \
-            chown $${installuser} $(DESTDIR)${etcdocdir}/$${docfile} || true ; \
+            chown $${installuser} "$(DESTDIR)${etcdocdir}/$${docfile}" || true ; \
        else true; fi
 
 install-info: info
-       umask 022; ${MKDIR_P} $(DESTDIR)${infodir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${infodir}"
        -unset CDPATH; \
        thisdir=`/bin/pwd`; \
-       [ `cd ${srcdir}/info && /bin/pwd` = `cd $(DESTDIR)${infodir} && /bin/pwd` ] || \
-         (cd $(DESTDIR)${infodir};  \
+       exp_infodir=`cd "$(DESTDIR)${infodir}" && /bin/pwd`; \
+       if [ "`cd ${srcdir}/info && /bin/pwd`" = "$$exp_infodir" ]; then \
+         true; \
+       else \
+         (cd "$(DESTDIR)${infodir}"; \
           [ -f dir ] || \
-            (cd $${thisdir}; \
-             ${INSTALL_DATA} ${srcdir}/info/dir $(DESTDIR)${infodir}/dir) ; \
-          info_misc=`cd $${thisdir}/doc/misc && \
-               $(QUIET_SUBMAKE) $(MAKE) -s echo-info \
-          `; \
+            (cd "$${thisdir}"; \
+             ${INSTALL_DATA} ${srcdir}/info/dir "$(DESTDIR)${infodir}/dir") ); \
+          info_misc=`cd doc/misc && $(QUIET_SUBMAKE) $(MAKE) -s echo-info`; \
           cd ${srcdir}/info ; \
           for elt in ${INFO_NONMISC} $${info_misc}; do \
              test "$(HAVE_MAKEINFO)" = "no" && test ! -f $$elt && continue; \
              for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
-              (cd $${thisdir}; \
-               ${INSTALL_DATA} ${srcdir}/info/$$f $(DESTDIR)${infodir}/$$f); \
+              (cd "$${thisdir}"; \
+               ${INSTALL_DATA} ${srcdir}/info/$$f "$(DESTDIR)${infodir}/$$f"); \
                [ -n "${GZIP_PROG}" ] || continue ; \
-               rm -f $(DESTDIR)${infodir}/$$f.gz; \
-               ${GZIP_PROG} -9n $(DESTDIR)${infodir}/$$f; \
+               rm -f "$(DESTDIR)${infodir}/$$f.gz"; \
+               ${GZIP_PROG} -9n "$(DESTDIR)${infodir}/$$f"; \
              done; \
-            (cd $${thisdir}; \
-             ${INSTALL_INFO} --info-dir=$(DESTDIR)${infodir} $(DESTDIR)${infodir}/$$elt); \
-          done)
+            (cd "$${thisdir}"; \
+             ${INSTALL_INFO} --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
+          done; \
+       fi
 
 ## "gzip || true" is because some gzips exit with non-zero status
 ## if compression would not reduce the file size.  Eg, the gzip in
@@ -675,16 +693,16 @@ install-info: info
 ## ctags.1 is compressed or not.  "gzip -f" is another option here,
 ## but not sure if portable.
 install-man:
-       umask 022; ${MKDIR_P} $(DESTDIR)${man1dir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${man1dir}"
        thisdir=`/bin/pwd`; \
        cd ${mansrcdir}; \
        for page in *.1; do \
          dest=`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1; \
-         (cd $${thisdir}; \
-          ${INSTALL_DATA} ${mansrcdir}/$${page} $(DESTDIR)${man1dir}/$${dest}); \
+         (cd "$${thisdir}"; \
+          ${INSTALL_DATA} ${mansrcdir}/$${page} "$(DESTDIR)${man1dir}/$${dest}"); \
          [ -n "${GZIP_PROG}" ] || continue ; \
-         rm -f $(DESTDIR)${man1dir}/$${dest}.gz; \
-         ${GZIP_PROG} -9n $(DESTDIR)${man1dir}/$${dest} || true; \
+         rm -f "$(DESTDIR)${man1dir}/$${dest}.gz"; \
+         ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \
        done
 
 ## Install those items from etc/ that need to end up elsewhere.
@@ -694,25 +712,25 @@ install-man:
 EMACS_ICON=emacs
 
 install-etc:
-       umask 022; ${MKDIR_P} $(DESTDIR)${desktopdir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${desktopdir}"
        tmp=etc/emacs.tmpdesktop; rm -f $${tmp}; \
        emacs_name=`echo emacs | sed '$(TRANSFORM)'`; \
        sed -e "/^Exec=emacs/ s/emacs/$${emacs_name}/" \
          -e "/^Icon=emacs/ s/emacs/$${emacs_name}/" \
          ${srcdir}/etc/emacs.desktop > $${tmp}; \
-       ${INSTALL_DATA} $${tmp} $(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop; \
+       ${INSTALL_DATA} $${tmp} "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"; \
        rm -f $${tmp}
        thisdir=`/bin/pwd`; \
        cd ${iconsrcdir} || exit 1; umask 022 ; \
        for dir in */*/apps */*/mimetypes; do \
          [ -d $${dir} ] || continue ; \
-         ( cd $${thisdir}; ${MKDIR_P} $(DESTDIR)${icondir}/$${dir} ) ; \
+         ( cd "$${thisdir}"; ${MKDIR_P} "$(DESTDIR)${icondir}/$${dir}" ) ; \
          for icon in $${dir}/${EMACS_ICON}[.-]*; do \
            [ -r $${icon} ] || continue ; \
            ext=`echo "$${icon}" | sed -e 's|.*\.||'`; \
            dest=`echo "$${icon}" | sed -e 's|.*/||' -e "s|\.$${ext}$$||" -e 's/$(EMACS_ICON)/emacs/' -e '$(TRANSFORM)'`.$${ext} ; \
-           ( cd $${thisdir}; \
-             ${INSTALL_DATA} ${iconsrcdir}/$${icon} $(DESTDIR)${icondir}/$${dir}/$${dest} ) \
+           ( cd "$${thisdir}"; \
+             ${INSTALL_DATA} ${iconsrcdir}/$${icon} "$(DESTDIR)${icondir}/$${dir}/$${dest}" ) \
            || exit 1; \
          done ; \
        done
@@ -728,30 +746,31 @@ install-strip:
 uninstall: uninstall-$(NTDIR) uninstall-doc
        cd lib-src &&                                   \
         $(MAKE) $(MFLAGS) uninstall                    \
-           prefix=${prefix} exec_prefix=${exec_prefix} \
-           bindir=${bindir} libexecdir=${libexecdir} archlibdir=${archlibdir}
+           prefix="${prefix}" exec_prefix="${exec_prefix}" \
+           bindir="${bindir}" libexecdir="${libexecdir}" \
+           archlibdir="${archlibdir}"
 
        -unset CDPATH; \
-       for dir in $(DESTDIR)${lispdir} $(DESTDIR)${etcdir} ; do        \
-         if [ -d $${dir} ]; then                       \
-           case `cd $${dir} ; /bin/pwd` in             \
-             `cd ${srcdir} ; /bin/pwd`* ) ;;           \
-             * ) rm -rf $${dir} ;;                     \
+       for dir in "$(DESTDIR)${lispdir}" "$(DESTDIR)${etcdir}" ; do    \
+         if [ -d "$${dir}" ]; then                     \
+           case `cd "$${dir}" ; /bin/pwd` in           \
+             "`cd ${srcdir} ; /bin/pwd`"* ) ;;         \
+             * ) rm -rf "$${dir}" ;;                   \
            esac ;                                      \
-           case $${dir} in                             \
-             $(DESTDIR)${datadir}/emacs/${version}/* )         \
-               rm -rf $(DESTDIR)${datadir}/emacs/${version}    \
+           case "$${dir}" in                           \
+             "$(DESTDIR)${datadir}/emacs/${version}"/* )               \
+               rm -rf "$(DESTDIR)${datadir}/emacs/${version}"  \
              ;;                                        \
            esac ;                                      \
          fi ;                                          \
        done
-       -rm -rf $(DESTDIR)${libexecdir}/emacs/${version}
+       -rm -rf "$(DESTDIR)${libexecdir}/emacs/${version}"
        thisdir=`/bin/pwd`; \
        (info_misc=`cd doc/misc && $(QUIET_SUBMAKE) $(MAKE) -s echo-info`; \
-        if cd $(DESTDIR)${infodir}; then \
+        if cd "$(DESTDIR)${infodir}"; then \
           for elt in ${INFO_NONMISC} $${info_misc}; do \
-            (cd $${thisdir}; \
-             $(INSTALL_INFO) --remove --info-dir=$(DESTDIR)${infodir} $(DESTDIR)${infodir}/$$elt); \
+            (cd "$${thisdir}"; \
+             $(INSTALL_INFO) --remove --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
             if [ -n "${GZIP_PROG}" ]; then \
                ext=.gz; else ext=; fi; \
             rm -f $$elt$$ext $$elt-[1-9]$$ext $$elt-[1-9][0-9]$$ext; \
@@ -761,18 +780,18 @@ uninstall: uninstall-$(NTDIR) uninstall-doc
            ext=.gz; else ext=; fi; \
         if cd ${mansrcdir}; then \
           for page in *.1; do \
-            rm -f $(DESTDIR)${man1dir}/`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1$$ext; done; \
+            rm -f "$(DESTDIR)${man1dir}"/`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1$$ext; done; \
         fi)
-       (cd $(DESTDIR)${bindir} && rm -f $(EMACSFULL) $(EMACS) || true)
-       (if cd $(DESTDIR)${icondir}; then \
+       (cd "$(DESTDIR)${bindir}" && rm -f $(EMACSFULL) $(EMACS) || true)
+       (if cd "$(DESTDIR)${icondir}"; then \
           rm -f hicolor/*x*/apps/${EMACS_NAME}.png \
             hicolor/scalable/apps/${EMACS_NAME}.svg \
             hicolor/scalable/mimetypes/`echo emacs-document | sed '$(TRANSFORM)'`.svg; \
        fi)
-       -rm -f $(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop
+       -rm -f "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"
        for file in snake-scores tetris-scores; do \
-         file=$(DESTDIR)${gamedir}/$${file}; \
-         [ -s $${file} ] || rm -f $$file; \
+         file="$(DESTDIR)${gamedir}/$${file}"; \
+         [ -s "$${file}" ] || rm -f "$$file"; \
        done
 
 ### Windows-specific uninstall target for removing programs produced
@@ -781,8 +800,9 @@ uninstall-:
 uninstall-nt:
        cd $(NTDIR) &&                                  \
         $(MAKE) $(MFLAGS) uninstall                    \
-           prefix=${prefix} exec_prefix=${exec_prefix} \
-           bindir=${bindir} libexecdir=${libexecdir} archlibdir=${archlibdir}
+           prefix="${prefix}" exec_prefix="${exec_prefix}" \
+           bindir="${bindir}" libexecdir="${libexecdir}" \
+           archlibdir="${archlibdir}"
 
 FRC:
 
@@ -858,9 +878,9 @@ distclean: FRC
        cd leim     && $(MAKE) $(MFLAGS) distclean
        cd lisp     && $(MAKE) $(MFLAGS) distclean
        cd nextstep && $(MAKE) $(MFLAGS) distclean
-       [ ! -d test/automated ] || { \
-         cd test/automated && $(MAKE) $(MFLAGS) distclean; \
-       }
+       for dir in test/automated admin/unidata; do \
+         [ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) distclean); \
+       done
        ${top_distclean}
 
 ### `bootstrap-clean'
@@ -880,9 +900,9 @@ bootstrap-clean: FRC
        cd leim     && $(MAKE) $(MFLAGS) maintainer-clean
        cd lisp     && $(MAKE) $(MFLAGS) bootstrap-clean
        cd nextstep && $(MAKE) $(MFLAGS) maintainer-clean
-       [ ! -d test/automated ] || { \
-         cd test/automated && $(MAKE) $(MFLAGS) bootstrap-clean; \
-       }
+       for dir in test/automated admin/unidata; do \
+         [ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) bootstrap-clean); \
+       done
        [ ! -f config.log ] || mv -f config.log config.log~
        ${top_bootclean}
 
@@ -903,9 +923,9 @@ top_maintainer_clean=\
 maintainer-clean: bootstrap-clean FRC
        cd src  && $(MAKE) $(MFLAGS) maintainer-clean
        cd lisp && $(MAKE) $(MFLAGS) maintainer-clean
-       [ ! -d test/automated ] || { \
-         cd test/automated && $(MAKE) $(MFLAGS) maintainer-clean; \
-       }
+       for dir in test/automated admin/unidata; do \
+         [ ! -d $$dir ] || (cd $$dir && $(MAKE) $(MFLAGS) maintainer-clean); \
+       done
        ${top_maintainer_clean}
 
 ### This doesn't actually appear in the coding standards, but Karl
@@ -924,7 +944,7 @@ extraclean:
 TAGS tags: lib lib-src src
        cd src; $(MAKE) $(MFLAGS) tags
 
-check:
+check: all
        @if test ! -d test/automated; then \
          echo "You do not seem to have the test/ directory."; \
          echo "Maybe you are using a release tarfile, rather than a repository checkout."; \
@@ -1053,11 +1073,11 @@ check-info-dir: info
 
 # Bootstrapping does the following:
 #  * Remove files to start from a bootstrap-clean slate.
-#  * Run autogen.sh, falling back on copy_autogen if autogen.sh fails.
+#  * Run autogen.sh.
 #  * Rebuild Makefile, to update the build procedure itself.
 #  * Do the actual build.
 bootstrap: bootstrap-clean FRC
-       cd $(srcdir) && { ./autogen.sh || autogen/copy_autogen; }
+       cd $(srcdir) && ./autogen.sh
        $(MAKE) $(MFLAGS) MAKEFILE_NAME=force-Makefile force-Makefile
        $(MAKE) $(MFLAGS) info all
 
index 31247765a26dc6bc7864b366ae09870dc9f8bf52..b8fdf09ddff64341ff7fa807d6efe15d277d0204 100644 (file)
@@ -1,3 +1,57 @@
+2013-11-11  Glenn Morris  <rgm@gnu.org>
+
+       * unidata/BidiMirroring.txt, unidata/UnicodeData.txt: Update to 6.3.0.
+
+       * unidata/unidata-gen.el (unidata-gen-files):
+       Tweak whitespace in generated files.
+
+2013-11-09  Glenn Morris  <rgm@gnu.org>
+
+       * unidata/unidata-gen.el (unidata-gen-files):
+       Fix deletion of existing output files after 2013-10-30 changes.
+
+2013-11-07  Glenn Morris  <rgm@gnu.org>
+
+       * unidata/unidata-gen.el (unidata-gen-files):
+       Disable version-control in generated files.
+       Update Unicode Inc. copyright years.
+
+2013-11-05  Glenn Morris  <rgm@gnu.org>
+
+       * update_autogen: Move here from ../autogen.
+       (usage): Update.  Remove -l, add -A.
+       (autogendir): New variable.
+       (ldefs_flag): Default to set.
+       (genfiles): Reduce to only ms-dos relevant files.
+       (main): Make checking autogen sources optional.
+       Make copying of autogen files optional.
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * unidata/unidata-gen.el (unidata-gen-files): Use pop.
+       Also take the output directory as an argument.
+       * unidata/Makefile.in: Simplify now that unidata-gen-files takes
+       the output directory as an argument (no need to cd, etc).
+       (abs_srcdir, abs_builddir): Remove.
+       (abs_top_builddir): Replace by top_builddir.
+       (${DSTDIR}/charprop.el): No need to cd.  Pass dest as argument.
+       (${DSTDIR}/charprop.el, charprop.el):
+       No need to pass unidata.txt as argument.
+
+       * unidata/unidata-gen.el (unidata--ensure-compiled): New function.
+       (unidata-gen-table-name, unidata-gen-table-decomposition)
+       (unidata-gen-files): Use unidata--ensure-compiled.
+
+       * unidata/Makefile.in (abs_srcdir): New, set by configure.
+       (${DSTDIR}/charprop.el, charprop.el): Update for srcdir not absolute.
+       (clean): Delete all .elc files.
+       (bootstrap-clean): New rule.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * unidata/Makefile.in (emacs, ${DSTDIR}/charprop.el):
+       Quote entities that might contain whitespace.
+
 2013-10-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        Improve support for popcount and counting trailing zeros (Bug#15550).
index ea496e16cf02a6f902a0334b27ccca5d39c2edc0..8470e7151c923b19fea571ea86e9e9fab6d65d2e 100644 (file)
@@ -2,6 +2,8 @@ Tasks needed before the next release.
 
 * TO BE DONE SHORTLY BEFORE RELEASE
 
+** Either update, test, and support the old w32 build method, or remove it.
+
 ** Manuals
 Check for node names using problematic characters:
   find doc -name '*.texi' -exec grep '^@node[^,]*[:.()]' {} +
index ec41b769375ff23bdc373fc6d5bdba65bcb6881f..d97c0dd9617687b2ff565ce11f4c1ffa9ec2f48c 100644 (file)
@@ -1,19 +1,19 @@
-# BidiMirroring-6.2.0.txt
-# Date: 2012-05-15, 24:19:00 GMT [KW, LI]
+# BidiMirroring-6.3.0.txt
+# Date: 2013-02-12, 08:20:00 GMT [KW, LI]
 #
 # Bidi_Mirroring_Glyph Property
 # 
 # This file is an informative contributory data file in the
 # Unicode Character Database.
 #
-# Copyright (c) 1991-2012 Unicode, Inc.
+# Copyright (c) 1991-2013 Unicode, Inc.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
 # This data file lists characters that have the Bidi_Mirrored=Yes property
 # value, for which there is another Unicode character that typically has a glyph
 # that is the mirror image of the original character's glyph.
 #
-# The repertoire covered by the file is Unicode 6.2.0.
+# The repertoire covered by the file is Unicode 6.3.0.
 # 
 # The file contains a list of lines with mappings from one code point
 # to another one for character-based mirroring.
@@ -42,7 +42,7 @@
 # 
 # This file was originally created by Markus Scherer.
 # Extended for Unicode 3.2, 4.0, 4.1, 5.0, 5.1, 5.2, and 6.0 by Ken Whistler,
-# and for Unicode 6.1 and 6.2 by Ken Whistler and Laurentiu Iancu.
+# and for Unicode 6.1, 6.2, and 6.3 by Ken Whistler and Laurentiu Iancu.
 # 
 # ############################################################
 #
 276F; 276E # HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT
 2770; 2771 # HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT
 2771; 2770 # HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT
-2772; 2773 # LIGHT LEFT TORTOISE SHELL BRACKET
-2773; 2772 # LIGHT RIGHT TORTOISE SHELL BRACKET
+2772; 2773 # LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT
+2773; 2772 # LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT
 2774; 2775 # MEDIUM LEFT CURLY BRACKET ORNAMENT
 2775; 2774 # MEDIUM RIGHT CURLY BRACKET ORNAMENT
 27C3; 27C4 # OPEN SUBSET
index df225cc8cbfb63d85cba5990ee3b2e7470165438..4d9473635143cb2c514d6983695aa188428f38c4 100644 (file)
 SHELL = @SHELL@
 
 srcdir = @srcdir@
-abs_builddir = @abs_builddir@
 top_srcdir = @top_srcdir@
-abs_top_builddir = @abs_top_builddir@
+top_builddir = @top_builddir@
 
-EMACS = ${abs_top_builddir}/src/emacs
+EMACS = ${top_builddir}/src/emacs
 DSTDIR = ${top_srcdir}/lisp/international
-emacs = ${EMACS} -batch --no-site-file --no-site-lisp
+emacs = "${EMACS}" -batch --no-site-file --no-site-lisp
 
 all: ${DSTDIR}/charprop.el
 
@@ -41,13 +40,13 @@ unidata.txt: ${srcdir}/UnicodeData.txt
        sed -e 's/\([^;]*\);\(.*\)/(#x\1 "\2")/' -e 's/;/" "/g' < ${srcdir}/UnicodeData.txt > $@
 
 ${DSTDIR}/charprop.el: ${srcdir}/unidata-gen.elc unidata.txt
-       cd ${DSTDIR} && ${emacs} -l ${srcdir}/unidata-gen \
-         -f unidata-gen-files ${srcdir} ${abs_builddir}/unidata.txt
+       ${emacs} -L ${srcdir} -l unidata-gen -f unidata-gen-files \
+         ${srcdir} "${DSTDIR}"
 
 ## Like the above, but generate in PWD rather than lisp/international.
 charprop.el: ${srcdir}/unidata-gen.elc unidata.txt
-       ${emacs} -l ${srcdir}/unidata-gen \
-         -f unidata-gen-files ${srcdir} unidata.txt
+       ${emacs} -L ${srcdir} -l unidata-gen -f unidata-gen-files \
+         ${srcdir}
 
 install: charprop.el
        cp charprop.el ${DSTDIR}
@@ -57,7 +56,9 @@ clean:
        if test -f charprop.el; then \
          rm -f `sed -n 's/^;; FILE: //p' < charprop.el`; \
        fi
-       rm -f charprop.el ${srcdir}/unidata-gen.elc unidata.txt
+       rm -f charprop.el ${srcdir}/*.elc unidata.txt
+
+bootstrap-clean: clean
 
 distclean: clean
        -rm -f ./Makefile
index 086379eb4f34526f18ac207c7b640d60b5c66416..9fffa71a1e92246e804b608fe7c30384d29d13b5 100644 (file)
 0619;ARABIC SMALL DAMMA;Mn;31;NSM;;;;;N;;;;;
 061A;ARABIC SMALL KASRA;Mn;32;NSM;;;;;N;;;;;
 061B;ARABIC SEMICOLON;Po;0;AL;;;;;N;;;;;
+061C;ARABIC LETTER MARK;Cf;0;AL;;;;;N;;;;;
 061E;ARABIC TRIPLE DOT PUNCTUATION MARK;Po;0;AL;;;;;N;;;;;
 061F;ARABIC QUESTION MARK;Po;0;AL;;;;;N;;;;;
 0620;ARABIC LETTER KASHMIRI YEH;Lo;0;AL;;;;;N;;;;;
 180B;MONGOLIAN FREE VARIATION SELECTOR ONE;Mn;0;NSM;;;;;N;;;;;
 180C;MONGOLIAN FREE VARIATION SELECTOR TWO;Mn;0;NSM;;;;;N;;;;;
 180D;MONGOLIAN FREE VARIATION SELECTOR THREE;Mn;0;NSM;;;;;N;;;;;
-180E;MONGOLIAN VOWEL SEPARATOR;Zs;0;WS;;;;;N;;;;;
+180E;MONGOLIAN VOWEL SEPARATOR;Cf;0;BN;;;;;N;;;;;
 1810;MONGOLIAN DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
 1811;MONGOLIAN DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
 1812;MONGOLIAN DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
 1A18;BUGINESE VOWEL SIGN U;Mn;220;NSM;;;;;N;;;;;
 1A19;BUGINESE VOWEL SIGN E;Mc;0;L;;;;;N;;;;;
 1A1A;BUGINESE VOWEL SIGN O;Mc;0;L;;;;;N;;;;;
-1A1B;BUGINESE VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;
+1A1B;BUGINESE VOWEL SIGN AE;Mn;0;NSM;;;;;N;;;;;
 1A1E;BUGINESE PALLAWA;Po;0;L;;;;;N;;;;;
 1A1F;BUGINESE END OF SECTION;Po;0;L;;;;;N;;;;;
 1A20;TAI THAM LETTER HIGH KA;Lo;0;L;;;;;N;;;;;
 2062;INVISIBLE TIMES;Cf;0;BN;;;;;N;;;;;
 2063;INVISIBLE SEPARATOR;Cf;0;BN;;;;;N;;;;;
 2064;INVISIBLE PLUS;Cf;0;BN;;;;;N;;;;;
+2066;LEFT-TO-RIGHT ISOLATE;Cf;0;LRI;;;;;N;;;;;
+2067;RIGHT-TO-LEFT ISOLATE;Cf;0;RLI;;;;;N;;;;;
+2068;FIRST STRONG ISOLATE;Cf;0;FSI;;;;;N;;;;;
+2069;POP DIRECTIONAL ISOLATE;Cf;0;PDI;;;;;N;;;;;
 206A;INHIBIT SYMMETRIC SWAPPING;Cf;0;BN;;;;;N;;;;;
 206B;ACTIVATE SYMMETRIC SWAPPING;Cf;0;BN;;;;;N;;;;;
 206C;INHIBIT ARABIC FORM SHAPING;Cf;0;BN;;;;;N;;;;;
 2305;PROJECTIVE;So;0;ON;;;;;N;;;;;
 2306;PERSPECTIVE;So;0;ON;;;;;N;;;;;
 2307;WAVY LINE;So;0;ON;;;;;N;;;;;
-2308;LEFT CEILING;Sm;0;ON;;;;;Y;;;;;
-2309;RIGHT CEILING;Sm;0;ON;;;;;Y;;;;;
-230A;LEFT FLOOR;Sm;0;ON;;;;;Y;;;;;
-230B;RIGHT FLOOR;Sm;0;ON;;;;;Y;;;;;
+2308;LEFT CEILING;Ps;0;ON;;;;;Y;;;;;
+2309;RIGHT CEILING;Pe;0;ON;;;;;Y;;;;;
+230A;LEFT FLOOR;Ps;0;ON;;;;;Y;;;;;
+230B;RIGHT FLOOR;Pe;0;ON;;;;;Y;;;;;
 230C;BOTTOM RIGHT CROP;So;0;ON;;;;;N;;;;;
 230D;BOTTOM LEFT CROP;So;0;ON;;;;;N;;;;;
 230E;TOP RIGHT CROP;So;0;ON;;;;;N;;;;;
@@ -18740,8 +18745,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 12453;CUNEIFORM NUMERIC SIGN FOUR BAN2 VARIANT FORM;Nl;0;L;;;;4;N;;;;;
 12454;CUNEIFORM NUMERIC SIGN FIVE BAN2;Nl;0;L;;;;5;N;;;;;
 12455;CUNEIFORM NUMERIC SIGN FIVE BAN2 VARIANT FORM;Nl;0;L;;;;5;N;;;;;
-12456;CUNEIFORM NUMERIC SIGN NIGIDAMIN;Nl;0;L;;;;-1;N;;;;;
-12457;CUNEIFORM NUMERIC SIGN NIGIDAESH;Nl;0;L;;;;-1;N;;;;;
+12456;CUNEIFORM NUMERIC SIGN NIGIDAMIN;Nl;0;L;;;;2;N;;;;;
+12457;CUNEIFORM NUMERIC SIGN NIGIDAESH;Nl;0;L;;;;3;N;;;;;
 12458;CUNEIFORM NUMERIC SIGN ONE ESHE3;Nl;0;L;;;;1;N;;;;;
 12459;CUNEIFORM NUMERIC SIGN TWO ESHE3;Nl;0;L;;;;2;N;;;;;
 1245A;CUNEIFORM NUMERIC SIGN ONE THIRD DISH;Nl;0;L;;;;1/3;N;;;;;
index 90cd895d9848230ccc4c313fc127cf233db75a52..81722bd091f2eba19b31fb11e4be5f29604f2138 100644 (file)
@@ -10,7 +10,7 @@
 
 <meta name="VI60_defaultClientScript" content="JavaScript">
 
-<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
+<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
 
 <meta name="keywords" content="Unicode Standard, copyright">
 
@@ -136,7 +136,7 @@ href="http://www.unicode.org/webscripts/standard_styles.css">
             <ol type="A">
               <li><u><a name="1"></a>Unicode Copyright.</u>
               <ol>
-                <li>Copyright © 1991-2012 Unicode, Inc. All rights reserved.</li>
+                <li>Copyright © 1991-2013 Unicode, Inc. All rights reserved.</li>
                 <li>Certain documents and files on this website contain a legend 
                 indicating that &quot;Modification is permitted.&quot; Any person is 
                 hereby authorized, without fee, to modify such documents and 
@@ -268,7 +268,7 @@ http://www.unicode.org/cldr/data/</a>.</p>
 <p>NOTICE TO USER: Carefully read the following legal agreement. BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.</p>
 <p>COPYRIGHT AND PERMISSION NOTICE</p>
 
-<p>Copyright © 1991-2012 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in 
+<p>Copyright © 1991-2013 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in 
 <a href="http://www.unicode.org/copyright.html">http://www.unicode.org/copyright.html</a>.</p>
 
 <p>Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and 
index d9277217f0e30688b98c96c411b3f1d856c15d2c..dd667f9571d97c02b8697de5ad3659b89743a2fb 100644 (file)
@@ -1,4 +1,7 @@
 ;; unidata-gen.el -- Create files containing character property data.
+
+;; Copyright 2008-2013 (C) Free Software Foundation, Inc.
+
 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H13PRO009
 ;; SPECIAL NOTICE
 ;;
 ;;   This file must be byte-compilable/loadable by `temacs' and also
-;;   the entry function `unidata-gen-files' must be runnable by
-;;   `temacs'.
+;;   the entry function `unidata-gen-files' must be runnable by `temacs'.
 
 ;; FILES TO BE GENERATED
 ;;
 ;;   The entry function `unidata-gen-files' generates these files in
-;;   the current directory.
+;;   in directory specified by its dest-dir argument.
 ;;
 ;;   charprop.el
 ;;     It contains a series of forms of this format:
@@ -88,9 +90,9 @@
 
 (defvar unidata-list nil)
 
-;; Name of the directory containing files of Unicode Character
-;; Database.
+;; Name of the directory containing files of Unicode Character Database.
 
+;; Dynamically bound in unidata-gen-files.
 (defvar unidata-dir nil)
 
 (defun unidata-setup-list (unidata-text-file)
@@ -975,11 +977,15 @@ is the character itself.")))
                      idx (1+ i)))))
        (nreverse (cons (intern (substring str idx)) l))))))
 
+(defun unidata--ensure-compiled (&rest funcs)
+  (dolist (fun funcs)
+    (or (byte-code-function-p (symbol-function fun))
+       (byte-compile fun))))
+
 (defun unidata-gen-table-name (prop &rest ignore)
   (let* ((table (unidata-gen-table-word-list prop 'unidata-split-name))
         (word-tables (char-table-extra-slot table 4)))
-    (byte-compile 'unidata-get-name)
-    (byte-compile 'unidata-put-name)
+    (unidata--ensure-compiled 'unidata-get-name 'unidata-put-name)
     (set-char-table-extra-slot table 1 (symbol-function 'unidata-get-name))
     (set-char-table-extra-slot table 2 (symbol-function 'unidata-put-name))
 
@@ -1017,8 +1023,8 @@ is the character itself.")))
 (defun unidata-gen-table-decomposition (prop &rest ignore)
   (let* ((table (unidata-gen-table-word-list prop 'unidata-split-decomposition))
         (word-tables (char-table-extra-slot table 4)))
-    (byte-compile 'unidata-get-decomposition)
-    (byte-compile 'unidata-put-decomposition)
+    (unidata--ensure-compiled 'unidata-get-decomposition
+                             'unidata-put-decomposition)
     (set-char-table-extra-slot table 1
                               (symbol-function 'unidata-get-decomposition))
     (set-char-table-extra-slot table 2
@@ -1176,18 +1182,21 @@ is the character itself.")))
 ;; The entry function.  It generates files described in the header
 ;; comment of this file.
 
-(defun unidata-gen-files (&optional data-dir unidata-text-file)
+;; Write files (charprop.el, uni-*.el) to dest-dir (default PWD),
+;; using as input files from data-dir, and
+;; unidata-text-file (default "unidata.txt" in PWD).
+(defun unidata-gen-files (&optional data-dir dest-dir unidata-text-file)
   (or data-dir
-      (setq data-dir (car command-line-args-left)
-           command-line-args-left (cdr command-line-args-left)
-           unidata-text-file (car command-line-args-left)
-           command-line-args-left (cdr command-line-args-left)))
+      (setq data-dir (pop command-line-args-left)
+           dest-dir (or (pop command-line-args-left) default-directory)
+           unidata-text-file (or (pop command-line-args-left)
+                                 (expand-file-name "unidata.txt"))))
   (let ((coding-system-for-write 'utf-8-unix)
-       (charprop-file "charprop.el")
+       (charprop-file (expand-file-name "charprop.el" dest-dir))
        (unidata-dir data-dir))
     (dolist (elt unidata-prop-alist)
       (let* ((prop (car elt))
-            (file (unidata-prop-file prop)))
+            (file (expand-file-name (unidata-prop-file prop) dest-dir)))
        (if (file-exists-p file)
            (delete-file file))))
     (unidata-setup-list unidata-text-file)
@@ -1196,7 +1205,8 @@ is the character itself.")))
       (dolist (elt unidata-prop-alist)
        (let* ((prop (car elt))
               (generator (unidata-prop-generator prop))
-              (file (unidata-prop-file prop))
+              (file (expand-file-name (unidata-prop-file prop) dest-dir))
+              (basename (file-name-nondirectory file))
               (docstring (unidata-prop-docstring prop))
               (describer (unidata-prop-describer prop))
               (default-value (unidata-prop-default prop))
@@ -1204,9 +1214,9 @@ is the character itself.")))
               table)
          ;; Filename in this comment line is extracted by sed in
          ;; Makefile.
-         (insert (format ";; FILE: %s\n" file))
+         (insert (format ";; FILE: %s\n" basename))
          (insert (format "(define-char-code-property '%S %S\n  %S)\n"
-                         prop file docstring))
+                         prop basename docstring))
          (with-temp-buffer
            (message "Generating %s..." file)
            (when (file-exists-p file)
@@ -1216,30 +1226,33 @@ is the character itself.")))
            (setq table (funcall generator prop default-value val-list))
            (when describer
              (unless (subrp (symbol-function describer))
-               (byte-compile describer)
+               (unidata--ensure-compiled describer)
                (setq describer (symbol-function describer)))
              (set-char-table-extra-slot table 3 describer))
            (if (bobp)
-               (insert ";; Copyright (C) 1991-2009 Unicode, Inc.
+               (insert ";; Copyright (C) 1991-2013 Unicode, Inc.
 ;; This file was generated from the Unicode data files at
 ;; http://www.unicode.org/Public/UNIDATA/.
 ;; See lisp/international/README for the copyright and permission notice.\n"))
-           (insert (format "(define-char-code-property '%S %S %S)\n"
+           (insert (format "(define-char-code-property '%S\n  %S\n  %S)\n"
                            prop table docstring))
            (if (eobp)
                (insert ";; Local Variables:\n"
                        ";; coding: utf-8\n"
+                       ";; version-control: never\n"
                        ";; no-byte-compile: t\n"
                        ";; End:\n\n"
-                       (format ";; %s ends here\n" file)))
+                       (format ";; %s ends here\n" basename)))
            (write-file file)
            (message "Generating %s...done" file))))
       (message "Writing %s..." charprop-file)
       (insert ";; Local Variables:\n"
              ";; coding: utf-8\n"
+             ";; version-control: never\n"
              ";; no-byte-compile: t\n"
              ";; End:\n\n"
-             (format ";; %s ends here\n" charprop-file)))))
+             (format ";; %s ends here\n"
+                     (file-name-nondirectory charprop-file))))))
 
 \f
 
similarity index 76%
rename from autogen/update_autogen
rename to admin/update_autogen
index 264d8d83d6d011fd7f7cf967d85fd9ab5d888436..316c9330b629ac54a00c7e29c0b7a2b639ad0e23 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-### update_autogen - update the generated files in Emacs autogen/ directory
+### update_autogen - update some auto-generated files in the Emacs tree
 
 ## Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
 
 ### Commentary:
 
-## This is a helper script to update the pre-built generated files in
-## the autogen/ directory.  This is suitable for running from cron.
+## This is a helper script to update some generated files in the Emacs
+## repository.  This is suitable for running from cron.
 ## Only Emacs maintainers need use this, so it uses bash features.
 ##
-## With the -l option, it also updates the versioned loaddefs-like
-## files in lisp/.  These include ldefs-boot, cl-loaddefs, rmail, etc.
+## By default, it updates the versioned loaddefs-like files in lisp,
+## except ldefs-boot.el.
 
 ### Code:
 
@@ -42,24 +42,25 @@ PD=${0%/*}
 
 [ "$PD" = "$0" ] && PD=.        # if PATH includes PWD
 
-## This should be the autogen directory.
+## This should be the admin directory.
 cd $PD
 cd ../
-[ -d autogen ] || die "Could not locate autogen directory"
+[ -d admin ] || die "Could not locate admin directory"
 
 
 usage ()
 {
     cat 1>&2 <<EOF
-Usage: ${PN} [-f] [-c] [-q] [-l [-L]] [-C] [-- make-flags]
-Update the generated files in the Emacs autogen/ directory.
+Usage: ${PN} [-f] [-c] [-q] [-A dir] [-L] [-C] [-- make-flags]
+Update some auto-generated files in the Emacs tree.
+By default, only does the versioned loaddefs-like files in lisp/.
+This requires a build.  Passes any non-option args to make (eg -- -j2).
 Options:
 -f: force an update even if the source files are locally modified.
 -c: if the update succeeds and the generated files are modified,
     commit them (caution).
 -q: be quiet; only give error messages, not status messages.
--l: also update the versioned loaddefs-like files in lisp/.
-This requires a build.  Passes any non-option args to make (eg -- -j2).
+-A: only update autotools files, copying into specified dir.
 -L: also update ldefs-boot.el.
 -C: start from a clean state.  Slower, but more correct.
 EOF
@@ -73,18 +74,23 @@ force=
 commit=
 quiet=
 clean=
-ldefs_flag=
+autogendir=                     # was "autogen"
+ldefs_flag=1
 lboot_flag=
 
 ## Parameters.
 ldefs_in=lisp/loaddefs.el
 ldefs_out=lisp/ldefs-boot.el
 sources="configure.ac lib/Makefile.am"
+## Files to copy into autogendir.
+## Everything:
 genfiles="
   configure aclocal.m4 src/config.in lib/Makefile.in
   build-aux/compile build-aux/config.guess build-aux/config.sub
   build-aux/depcomp build-aux/install-sh build-aux/missing
 "
+## msdos-only:
+genfiles="src/config.in lib/Makefile.in"
 
 for g in $genfiles; do
     basegen="$basegen ${g##*/}"
@@ -97,7 +103,7 @@ tempfile=/tmp/$PN.$$
 trap "rm -f $tempfile 2> /dev/null" EXIT
 
 
-while getopts ":hcflqCL" option ; do
+while getopts ":hcfqA:CL" option ; do
     case $option in
         (h) usage ;;
 
@@ -105,10 +111,12 @@ while getopts ":hcflqCL" option ; do
 
         (f) force=1 ;;
 
-        (l) ldefs_flag=1 ;;
-
         (q) quiet=1 ;;
 
+        (A) autogendir=$OPTARG
+            [ -d "$autogendir" ] || die "No autogen directory: $autogendir"
+            ;;
+
         (C) clean=1 ;;
 
         (L) lboot_flag=1 ;;
@@ -130,8 +138,8 @@ OPTIND=1
 
 echo "Running bzr status..."
 
-bzr status -S $sources ${ldefs_flag:+lisp} >| $tempfile || \
-    die "bzr status error for sources"
+bzr status -S ${autogendir:+$sources} ${ldefs_flag:+lisp} >| $tempfile || \
+    die "bzr status error for input files"
 
 ## The lisp portion could be more permissive, eg only care about .el files.
 while read stat file; do
@@ -175,31 +183,6 @@ fi
 [ $retval -ne 0 ] && die "autoreconf error"
 
 
-cp $genfiles autogen/
-
-
-cd autogen
-
-echo "Checking status of generated files..."
-
-bzr status -S $basegen >| $tempfile || \
-    die "bzr status error for generated files"
-
-
-modified=
-
-while read stat file; do
-
-    [ "$stat" != "M" ] && die "Unexpected status ($stat) for generated $file"
-
-    modified="$modified $file"
-
-done < $tempfile
-
-
-cd ../
-
-
 ## Uses global $commit.
 commit ()
 {
@@ -224,7 +207,36 @@ commit ()
 }                               # function commit
 
 
-commit "generated" $modified || die "bzr commit error"
+[ "$autogendir" ] && {
+
+    oldpwd=$PWD
+
+    cp $genfiles $autogendir/
+
+    cd $autogendir || die "cd error for $autogendir"
+
+    echo "Checking status of generated files..."
+
+    bzr status -S $basegen >| $tempfile || \
+        die "bzr status error for generated files"
+
+    modified=
+
+    while read stat file; do
+
+        [ "$stat" != "M" ] && \
+            die "Unexpected status ($stat) for generated $file"
+
+        modified="$modified $file"
+
+    done < $tempfile
+
+    cd $oldpwd
+
+    commit "generated" $modified || die "bzr commit error"
+
+    exit 0
+}                               # $autogendir
 
 
 [ "$ldefs_flag" ] || exit 0
index e7c28c16d94e15a3a811fdb1e3d49ceeef2c1bb5..2cb7410a07ee2e8e37f0058e7e08b2a7d0808a83 100755 (executable)
@@ -191,13 +191,6 @@ autoreconf -i -I m4
 
 instead of this script.
 
-If all else fails, you can try using the pre-built versions of the
-generated files by doing:
-
-./autogen/copy_autogen
-
-This is not recommended - see the comments in \`copy_autogen'.
-
 Please report any problems with this script to bug-gnu-emacs@gnu.org .
 EOF
 
diff --git a/autogen/README b/autogen/README
deleted file mode 100644 (file)
index d4c2236..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-This directory contains some pre-built generated files.
-Most people do not need to use these files - instead you should
-generate them yourself using eg `autogen.sh'.
-
-File:        Destination:  Created by:
-configure    ../           autoconf
-config.in    ../src        autoheader      * also used by MSDOS bzr build
-aclocal.m4   ../           aclocal
-Makefile.in  ../lib        automake
-compile      ../build-aux  automake
-config.guess ../build-aux  automake
-config.sub   ../build-aux  automake
-depcomp      ../build-aux  automake
-install-sh   ../build-aux  automake
-missing      ../build-aux  automake
-
-There are also some scripts:
-
-copy_autogen    - copy pre-built generated files into place
-update_autogen  - regenerate generated files (for maintainers)
diff --git a/autogen/aclocal.m4 b/autogen/aclocal.m4
deleted file mode 100644 (file)
index e61c008..0000000
+++ /dev/null
@@ -1,1083 +0,0 @@
-# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-m4_ifndef([AC_AUTOCONF_VERSION],
-  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
-[m4_warning([this file was generated for autoconf 2.65.
-You have another version of autoconf.  It may work, but is not guaranteed to.
-If you have problems, you may need to regenerate the build system entirely.
-To do so, use the procedure documented by the package, typically `autoreconf'.])])
-
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-# (This private macro should not be called outside this file.)
-AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.11'
-dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
-dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11.1], [],
-      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
-])
-
-# _AM_AUTOCONF_VERSION(VERSION)
-# -----------------------------
-# aclocal traces this macro to find the Autoconf version.
-# This is a private macro too.  Using m4_define simplifies
-# the logic in aclocal, which can simply ignore this definition.
-m4_define([_AM_AUTOCONF_VERSION], [])
-
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
-# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.1])dnl
-m4_ifndef([AC_AUTOCONF_VERSION],
-  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
-
-# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
-
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
-#
-# Of course, Automake must honor this variable whenever it calls a
-# tool from the auxiliary directory.  The problem is that $srcdir (and
-# therefore $ac_aux_dir as well) can be either absolute or relative,
-# depending on how configure is run.  This is pretty annoying, since
-# it makes $ac_aux_dir quite unusable in subdirectories: in the top
-# source directory, any form will work fine, but in subdirectories a
-# relative path needs to be adjusted first.
-#
-# $ac_aux_dir/missing
-#    fails when called from a subdirectory if $ac_aux_dir is relative
-# $top_srcdir/$ac_aux_dir/missing
-#    fails if $ac_aux_dir is absolute,
-#    fails when called from a subdirectory in a VPATH build with
-#          a relative $ac_aux_dir
-#
-# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
-# are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
-# start a VPATH build or use an absolute $srcdir.
-#
-# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
-# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
-#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
-# and then we would define $MISSING as
-#   MISSING="\${SHELL} $am_aux_dir/missing"
-# This will work as long as MISSING is not called from configure, because
-# unfortunately $(top_srcdir) has no meaning in configure.
-# However there are other variables, like CC, which are often used in
-# configure, and could therefore not use this "fixed" $ac_aux_dir.
-#
-# Another solution, used here, is to always expand $ac_aux_dir to an
-# absolute PATH.  The drawback is that using absolute paths prevent a
-# configured tree to be moved without reconfiguration.
-
-AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-])
-
-# AM_CONDITIONAL                                            -*- Autoconf -*-
-
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 9
-
-# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-# -------------------------------------
-# Define a conditional.
-AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])dnl
-AC_SUBST([$1_FALSE])dnl
-_AM_SUBST_NOTMAKE([$1_TRUE])dnl
-_AM_SUBST_NOTMAKE([$1_FALSE])dnl
-m4_define([_AM_COND_VALUE_$1], [$2])dnl
-if $2; then
-  $1_TRUE=
-  $1_FALSE='#'
-else
-  $1_TRUE='#'
-  $1_FALSE=
-fi
-AC_CONFIG_COMMANDS_PRE(
-[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-  AC_MSG_ERROR([[conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.]])
-fi])])
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 10
-
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery.  Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
-
-
-# _AM_DEPENDENCIES(NAME)
-# ----------------------
-# See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
-# We try a few techniques and use that to set a single cache variable.
-#
-# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
-# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
-# dependency, and given that the user is not expected to run this macro,
-# just rely on AC_PROG_CC.
-AC_DEFUN([_AM_DEPENDENCIES],
-[AC_REQUIRE([AM_SET_DEPDIR])dnl
-AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
-AC_REQUIRE([AM_MAKE_INCLUDE])dnl
-AC_REQUIRE([AM_DEP_TRACK])dnl
-
-ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
-       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
-       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
-       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                   [depcc="$$1"   am_compiler_list=])
-
-AC_CACHE_CHECK([dependency style of $depcc],
-               [am_cv_$1_dependencies_compiler_type],
-[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
-
-  am_cv_$1_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
-  fi
-  am__universal=false
-  m4_case([$1], [CC],
-    [case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac],
-    [CXX],
-    [case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac])
-
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
-    am__obj=sub/conftest.${OBJEXT-o}
-    am__minus_obj="-o $am__obj"
-    case $depmode in
-    gcc)
-      # This depmode causes a compiler race in universal mode.
-      test "$am__universal" = false || continue
-      ;;
-    nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
-      if test "x$enable_dependency_tracking" = xyes; then
-       continue
-      else
-       break
-      fi
-      ;;
-    msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
-      # not run yet.  These depmodes are late enough in the game, and
-      # so weak that their functioning should not be impacted.
-      am__obj=conftest.${OBJEXT-o}
-      am__minus_obj=
-      ;;
-    none) break ;;
-    esac
-    if depmode=$depmode \
-       source=sub/conftest.c object=$am__obj \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_$1_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
-
-  cd ..
-  rm -rf conftest.dir
-else
-  am_cv_$1_dependencies_compiler_type=none
-fi
-])
-AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
-AM_CONDITIONAL([am__fastdep$1], [
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
-])
-
-
-# AM_SET_DEPDIR
-# -------------
-# Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
-AC_DEFUN([AM_SET_DEPDIR],
-[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
-])
-
-
-# AM_DEP_TRACK
-# ------------
-AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors])
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-fi
-AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])dnl
-_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
-])
-
-# Generate code to set up dependency tracking.              -*- Autoconf -*-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-#serial 5
-
-# _AM_OUTPUT_DEPENDENCY_COMMANDS
-# ------------------------------
-AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[{
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
-  # are listed without --file.  Let's play safe and only enable the eval
-  # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
-  shift
-  for mf
-  do
-    # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
-    # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`AS_DIRNAME("$mf")`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`AS_DIRNAME(["$file"])`
-      AS_MKDIR_P([$dirpart/$fdir])
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
-  done
-}
-])# _AM_OUTPUT_DEPENDENCY_COMMANDS
-
-
-# AM_OUTPUT_DEPENDENCY_COMMANDS
-# -----------------------------
-# This macro should only be invoked once -- use via AC_REQUIRE.
-#
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
-# need in order to bootstrap the dependency handling code.
-AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
-[AC_CONFIG_COMMANDS([depfiles],
-     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
-
-# Do all the work for Automake.                             -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 16
-
-# This macro actually does too much.  Some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
-
-# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
-# AM_INIT_AUTOMAKE([OPTIONS])
-# -----------------------------------------------
-# The call with PACKAGE and VERSION arguments is the old style
-# call (pre autoconf-2.50), which is being phased out.  PACKAGE
-# and VERSION should now be passed to AC_INIT and removed from
-# the call to AM_INIT_AUTOMAKE.
-# We support both call styles for the transition.  After
-# the next Automake release, Autoconf can make the AC_INIT
-# arguments mandatory, and then we can depend on a new Autoconf
-# release and drop the old call support.
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.62])dnl
-dnl Autoconf wants to disallow AM_ names.  We explicitly allow
-dnl the ones we care about.
-m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
-AC_REQUIRE([AC_PROG_INSTALL])dnl
-if test "`cd $srcdir && pwd`" != "`pwd`"; then
-  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
-  # is not polluted with repeated "-I."
-  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
-  # test to see if srcdir already configured
-  if test -f $srcdir/config.status; then
-    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-  fi
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
-  if (cygpath --version) >/dev/null 2>/dev/null; then
-    CYGPATH_W='cygpath -w'
-  else
-    CYGPATH_W=echo
-  fi
-fi
-AC_SUBST([CYGPATH_W])
-
-# Define the identity of the package.
-dnl Distinguish between old-style and new-style calls.
-m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
- AC_SUBST([PACKAGE], [$1])dnl
- AC_SUBST([VERSION], [$2])],
-[_AM_SET_OPTIONS([$1])dnl
-dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
-m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
-  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
- AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
- AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
-
-_AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
-
-# Some tools Automake needs.
-AC_REQUIRE([AM_SANITY_CHECK])dnl
-AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
-AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([AC_PROG_MAKE_SET])dnl
-AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
-             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
-                            [_AM_PROG_TAR([v7])])])
-_AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_CC],
-                 [_AM_DEPENDENCIES(CC)],
-                 [define([AC_PROG_CC],
-                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_CXX],
-                 [_AM_DEPENDENCIES(CXX)],
-                 [define([AC_PROG_CXX],
-                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-                 [_AM_DEPENDENCIES(OBJC)],
-                 [define([AC_PROG_OBJC],
-                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
-])
-_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
-dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
-dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
-dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
-AC_CONFIG_COMMANDS_PRE(dnl
-[m4_provide_if([_AM_COMPILER_EXEEXT],
-  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-])
-
-dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
-dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
-dnl mangled by Autoconf and run in a shell conditional statement.
-m4_define([_AC_COMPILER_EXEEXT],
-m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
-
-
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated.  The stamp files are numbered to have different names.
-
-# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
-# loop where config.status creates the headers, so we can generate
-# our stamp files there.
-AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
-[# Compute $1's index in $config_headers.
-_am_arg=$1
-_am_stamp_count=1
-for _am_header in $config_headers :; do
-  case $_am_header in
-    $_am_arg | $_am_arg:* )
-      break ;;
-    * )
-      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
-  esac
-done
-echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
-
-# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_SH
-# ------------------
-# Define $install_sh.
-AC_DEFUN([AM_PROG_INSTALL_SH],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\    *)
-    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
-  *)
-    install_sh="\${SHELL} $am_aux_dir/install-sh"
-  esac
-fi
-AC_SUBST(install_sh)])
-
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# Check whether the underlying file-system supports filenames
-# with a leading dot.  For instance MS-DOS doesn't.
-AC_DEFUN([AM_SET_LEADING_DOT],
-[rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
-  am__leading_dot=.
-else
-  am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-AC_SUBST([am__leading_dot])])
-
-# Check to see how 'make' treats includes.                 -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# AM_MAKE_INCLUDE()
-# -----------------
-# Check to see how make treats includes.
-AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
-       @echo this is the am__doit target
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
-
-# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 6
-
-# AM_PROG_CC_C_O
-# --------------
-# Like AC_PROG_CC_C_O, but changed for automake.
-AC_DEFUN([AM_PROG_CC_C_O],
-[AC_REQUIRE([AC_PROG_CC_C_O])dnl
-AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([compile])dnl
-# FIXME: we rely on the cache variable name because
-# there is no other way.
-set dummy $CC
-am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
-eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
-if test "$am_t" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-dnl Make sure AC_PROG_CC is never called again, or it will override our
-dnl setting of CC.
-m4_define([AC_PROG_CC],
-          [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
-])
-
-# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
-
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 6
-
-# AM_MISSING_PROG(NAME, PROGRAM)
-# ------------------------------
-AC_DEFUN([AM_MISSING_PROG],
-[AC_REQUIRE([AM_MISSING_HAS_RUN])
-$1=${$1-"${am_missing_run}$2"}
-AC_SUBST($1)])
-
-
-# AM_MISSING_HAS_RUN
-# ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
-AC_DEFUN([AM_MISSING_HAS_RUN],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([missing])dnl
-if test x"${MISSING+set}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\    *)
-    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
-  *)
-    MISSING="\${SHELL} $am_aux_dir/missing" ;;
-  esac
-fi
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
-else
-  am_missing_run=
-  AC_MSG_WARN([`missing' script is too old or missing])
-fi
-])
-
-# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check for `mkdir -p'.
-AC_DEFUN([AM_PROG_MKDIR_P],
-[AC_PREREQ([2.60])dnl
-AC_REQUIRE([AC_PROG_MKDIR_P])dnl
-dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
-dnl while keeping a definition of mkdir_p for backward compatibility.
-dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
-dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
-dnl Makefile.ins that do not define MKDIR_P, so we do our own
-dnl adjustment using top_builddir (which is defined more often than
-dnl MKDIR_P).
-AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
-case $mkdir_p in
-  [[\\/$]]* | ?:[[\\/]]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-])
-
-# Helper functions for option handling.                     -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# _AM_MANGLE_OPTION(NAME)
-# -----------------------
-AC_DEFUN([_AM_MANGLE_OPTION],
-[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
-
-# _AM_SET_OPTION(NAME)
-# ------------------------------
-# Set option NAME.  Presently that only means defining a flag for this option.
-AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
-
-# _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
-# OPTIONS is a space-separated list of Automake options.
-AC_DEFUN([_AM_SET_OPTIONS],
-[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
-
-# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
-# -------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-AC_DEFUN([_AM_IF_OPTION],
-[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
-
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 5
-
-# AM_SANITY_CHECK
-# ---------------
-AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Reject unsafe characters in $srcdir or the absolute working directory
-# name.  Accept space and tab only in the latter.
-am_lf='
-'
-case `pwd` in
-  *[[\\\"\#\$\&\'\`$am_lf]]*)
-    AC_MSG_ERROR([unsafe absolute working directory name]);;
-esac
-case $srcdir in
-  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
-    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
-esac
-
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments.  Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$[*]" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$[*]" != "X $srcdir/configure conftest.file" \
-      && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-alias in your environment])
-   fi
-
-   test "$[2]" = conftest.file
-   )
-then
-   # Ok.
-   :
-else
-   AC_MSG_ERROR([newly created file is older than distributed files!
-Check your system clock])
-fi
-AC_MSG_RESULT(yes)])
-
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_STRIP
-# ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
-# specify the program used to strip binaries.  This is especially
-# annoying in cross-compiling environments, where the build's strip
-# is unlikely to handle the host's binaries.
-# Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
-# STRIPPROG with the value of the STRIP variable (set by the user).
-AC_DEFUN([AM_PROG_INSTALL_STRIP],
-[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
-if test "$cross_compiling" != no; then
-  AC_CHECK_TOOL([STRIP], [strip], :)
-fi
-INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
-AC_SUBST([INSTALL_STRIP_PROGRAM])])
-
-# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# _AM_SUBST_NOTMAKE(VARIABLE)
-# ---------------------------
-# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
-# This macro is traced by Automake.
-AC_DEFUN([_AM_SUBST_NOTMAKE])
-
-# AM_SUBST_NOTMAKE(VARIABLE)
-# ---------------------------
-# Public sister of _AM_SUBST_NOTMAKE.
-AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
-
-# Check how to create a tarball.                            -*- Autoconf -*-
-
-# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# _AM_PROG_TAR(FORMAT)
-# --------------------
-# Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
-#
-# Substitute a variable $(am__tar) that is a command
-# writing to stdout a FORMAT-tarball containing the directory
-# $tardir.
-#     tardir=directory && $(am__tar) > result.tar
-#
-# Substitute a variable $(am__untar) that extract such
-# a tarball read from stdin.
-#     $(am__untar) < result.tar
-AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.
-AM_MISSING_PROG([AMTAR], [tar])
-m4_if([$1], [v7],
-     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
-     [m4_case([$1], [ustar],, [pax],,
-              [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
-_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
-for _am_tool in $_am_tools
-do
-  case $_am_tool in
-  gnutar)
-    for _am_tar in tar gnutar gtar;
-    do
-      AM_RUN_LOG([$_am_tar --version]) && break
-    done
-    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
-    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
-    am__untar="$_am_tar -xf -"
-    ;;
-  plaintar)
-    # Must skip GNU tar: if it does not support --format= it doesn't create
-    # ustar tarball either.
-    (tar --version) >/dev/null 2>&1 && continue
-    am__tar='tar chf - "$$tardir"'
-    am__tar_='tar chf - "$tardir"'
-    am__untar='tar xf -'
-    ;;
-  pax)
-    am__tar='pax -L -x $1 -w "$$tardir"'
-    am__tar_='pax -L -x $1 -w "$tardir"'
-    am__untar='pax -r'
-    ;;
-  cpio)
-    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
-    am__untar='cpio -i -H $1 -d'
-    ;;
-  none)
-    am__tar=false
-    am__tar_=false
-    am__untar=false
-    ;;
-  esac
-
-  # If the value was cached, stop now.  We just wanted to have am__tar
-  # and am__untar set.
-  test -n "${am_cv_prog_tar_$1}" && break
-
-  # tar/untar a dummy directory, and stop if the command works
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  echo GrepMe > conftest.dir/file
-  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
-  rm -rf conftest.dir
-  if test -s conftest.tar; then
-    AM_RUN_LOG([$am__untar <conftest.tar])
-    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
-  fi
-done
-rm -rf conftest.dir
-
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
-AC_SUBST([am__tar])
-AC_SUBST([am__untar])
-]) # _AM_PROG_TAR
-
-m4_include([m4/00gnulib.m4])
-m4_include([m4/acl.m4])
-m4_include([m4/alloca.m4])
-m4_include([m4/byteswap.m4])
-m4_include([m4/c-strtod.m4])
-m4_include([m4/clock_time.m4])
-m4_include([m4/close-stream.m4])
-m4_include([m4/count-one-bits.m4])
-m4_include([m4/count-trailing-zeros.m4])
-m4_include([m4/dirent_h.m4])
-m4_include([m4/dup2.m4])
-m4_include([m4/environ.m4])
-m4_include([m4/errno_h.m4])
-m4_include([m4/euidaccess.m4])
-m4_include([m4/execinfo.m4])
-m4_include([m4/extensions.m4])
-m4_include([m4/extern-inline.m4])
-m4_include([m4/faccessat.m4])
-m4_include([m4/fcntl.m4])
-m4_include([m4/fcntl_h.m4])
-m4_include([m4/fdatasync.m4])
-m4_include([m4/fdopendir.m4])
-m4_include([m4/filemode.m4])
-m4_include([m4/fpending.m4])
-m4_include([m4/fstatat.m4])
-m4_include([m4/fsync.m4])
-m4_include([m4/getdtablesize.m4])
-m4_include([m4/getgroups.m4])
-m4_include([m4/getloadavg.m4])
-m4_include([m4/getopt.m4])
-m4_include([m4/gettime.m4])
-m4_include([m4/gettimeofday.m4])
-m4_include([m4/gnulib-common.m4])
-m4_include([m4/gnulib-comp.m4])
-m4_include([m4/group-member.m4])
-m4_include([m4/include_next.m4])
-m4_include([m4/inttypes.m4])
-m4_include([m4/largefile.m4])
-m4_include([m4/longlong.m4])
-m4_include([m4/lstat.m4])
-m4_include([m4/manywarnings.m4])
-m4_include([m4/md5.m4])
-m4_include([m4/memrchr.m4])
-m4_include([m4/mkostemp.m4])
-m4_include([m4/mktime.m4])
-m4_include([m4/multiarch.m4])
-m4_include([m4/nocrash.m4])
-m4_include([m4/off_t.m4])
-m4_include([m4/pathmax.m4])
-m4_include([m4/pipe2.m4])
-m4_include([m4/pselect.m4])
-m4_include([m4/pthread_sigmask.m4])
-m4_include([m4/putenv.m4])
-m4_include([m4/readlink.m4])
-m4_include([m4/readlinkat.m4])
-m4_include([m4/secure_getenv.m4])
-m4_include([m4/setenv.m4])
-m4_include([m4/sha1.m4])
-m4_include([m4/sha256.m4])
-m4_include([m4/sha512.m4])
-m4_include([m4/sig2str.m4])
-m4_include([m4/signal_h.m4])
-m4_include([m4/socklen.m4])
-m4_include([m4/ssize_t.m4])
-m4_include([m4/st_dm_mode.m4])
-m4_include([m4/stat-time.m4])
-m4_include([m4/stat.m4])
-m4_include([m4/stdalign.m4])
-m4_include([m4/stdarg.m4])
-m4_include([m4/stdbool.m4])
-m4_include([m4/stddef_h.m4])
-m4_include([m4/stdint.m4])
-m4_include([m4/stdio_h.m4])
-m4_include([m4/stdlib_h.m4])
-m4_include([m4/strftime.m4])
-m4_include([m4/string_h.m4])
-m4_include([m4/strtoimax.m4])
-m4_include([m4/strtoll.m4])
-m4_include([m4/strtoull.m4])
-m4_include([m4/strtoumax.m4])
-m4_include([m4/symlink.m4])
-m4_include([m4/sys_select_h.m4])
-m4_include([m4/sys_socket_h.m4])
-m4_include([m4/sys_stat_h.m4])
-m4_include([m4/sys_time_h.m4])
-m4_include([m4/tempname.m4])
-m4_include([m4/time_h.m4])
-m4_include([m4/time_r.m4])
-m4_include([m4/timer_time.m4])
-m4_include([m4/timespec.m4])
-m4_include([m4/tm_gmtoff.m4])
-m4_include([m4/unistd_h.m4])
-m4_include([m4/utimbuf.m4])
-m4_include([m4/utimens.m4])
-m4_include([m4/utimes.m4])
-m4_include([m4/warnings.m4])
-m4_include([m4/wchar_t.m4])
diff --git a/autogen/compile b/autogen/compile
deleted file mode 100755 (executable)
index c0096a7..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand `-c -o'.
-
-scriptversion=2009-10-06.20; # UTC
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009  Free Software
-# Foundation, Inc.
-# Written by Tom Tromey <tromey@cygnus.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-case $1 in
-  '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
-     exit 1;
-     ;;
-  -h | --h*)
-    cat <<\EOF
-Usage: compile [--help] [--version] PROGRAM [ARGS]
-
-Wrapper for compilers which do not understand `-c -o'.
-Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
-arguments, and rename the output as expected.
-
-If you are trying to build a whole package this is not the
-right script to run: please start by reading the file `INSTALL'.
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
-    exit $?
-    ;;
-  -v | --v*)
-    echo "compile $scriptversion"
-    exit $?
-    ;;
-esac
-
-ofile=
-cfile=
-eat=
-
-for arg
-do
-  if test -n "$eat"; then
-    eat=
-  else
-    case $1 in
-      -o)
-       # configure might choose to run compile as `compile cc -o foo foo.c'.
-       # So we strip `-o arg' only if arg is an object.
-       eat=1
-       case $2 in
-         *.o | *.obj)
-           ofile=$2
-           ;;
-         *)
-           set x "$@" -o "$2"
-           shift
-           ;;
-       esac
-       ;;
-      *.c)
-       cfile=$1
-       set x "$@" "$1"
-       shift
-       ;;
-      *)
-       set x "$@" "$1"
-       shift
-       ;;
-    esac
-  fi
-  shift
-done
-
-if test -z "$ofile" || test -z "$cfile"; then
-  # If no `-o' option was seen then we might have been invoked from a
-  # pattern rule where we don't need one.  That is ok -- this is a
-  # normal compilation that the losing compiler can handle.  If no
-  # `.c' file was seen then we are probably linking.  That is also
-  # ok.
-  exec "$@"
-fi
-
-# Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
-
-# Create the lock directory.
-# Note: use `[/\\:.-]' here to ensure that we don't use the same name
-# that we are using for the .o file.  Also, base the name on the expected
-# object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
-while true; do
-  if mkdir "$lockdir" >/dev/null 2>&1; then
-    break
-  fi
-  sleep 1
-done
-# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
-
-# Run the compile.
-"$@"
-ret=$?
-
-if test -f "$cofile"; then
-  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
-elif test -f "${cofile}bj"; then
-  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
-fi
-
-rmdir "$lockdir"
-exit $ret
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
diff --git a/autogen/config.guess b/autogen/config.guess
deleted file mode 100755 (executable)
index e3a2116..0000000
+++ /dev/null
@@ -1,1533 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-#   Free Software Foundation, Inc.
-
-timestamp='2009-06-10'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )        # Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help" >&2
-       exit 1 ;;
-    * )
-       break ;;
-  esac
-done
-
-if test $# != 0; then
-  echo "$me: too many arguments$help" >&2
-  exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
-       for c in cc gcc c89 c99 ; do
-         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
-            CC_FOR_BUILD="$c"; break ;
-         fi ;
-       done ;
-       if test x"$CC_FOR_BUILD" = x ; then
-         CC_FOR_BUILD=no_compiler_found ;
-       fi
-       ;;
- ,,*)   CC_FOR_BUILD=$CC ;;
- ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
-       PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
-    *:NetBSD:*:*)
-       # NetBSD (nbsd) targets should (where applicable) match one or
-       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
-       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
-       # switched to ELF, *-*-netbsd* would select the old
-       # object file format.  This provides both forward
-       # compatibility and a consistent mechanism for selecting the
-       # object file format.
-       #
-       # Note: NetBSD doesn't particularly care about the vendor
-       # portion of the name.  We always set it to "unknown".
-       sysctl="sysctl -n hw.machine_arch"
-       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-       case "${UNAME_MACHINE_ARCH}" in
-           armeb) machine=armeb-unknown ;;
-           arm*) machine=arm-unknown ;;
-           sh3el) machine=shl-unknown ;;
-           sh3eb) machine=sh-unknown ;;
-           sh5el) machine=sh5le-unknown ;;
-           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
-       esac
-       # The Operating System including object format, if it has switched
-       # to ELF recently, or will in the future.
-       case "${UNAME_MACHINE_ARCH}" in
-           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-               eval $set_cc_for_build
-               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-                       | grep -q __ELF__
-               then
-                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
-                   # Return netbsd for either.  FIX?
-                   os=netbsd
-               else
-                   os=netbsdelf
-               fi
-               ;;
-           *)
-               os=netbsd
-               ;;
-       esac
-       # The OS release
-       # Debian GNU/NetBSD machines have a different userland, and
-       # thus, need a distinct triplet. However, they do not need
-       # kernel version information, so it can be replaced with a
-       # suitable tag, in the style of linux-gnu.
-       case "${UNAME_VERSION}" in
-           Debian*)
-               release='-gnu'
-               ;;
-           *)
-               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-               ;;
-       esac
-       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
-       # contains redundant information, the shorter form:
-       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-       echo "${machine}-${os}${release}"
-       exit ;;
-    *:OpenBSD:*:*)
-       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
-       exit ;;
-    *:ekkoBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
-       exit ;;
-    *:SolidBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
-       exit ;;
-    macppc:MirBSD:*:*)
-       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
-       exit ;;
-    *:MirBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
-       exit ;;
-    alpha:OSF1:*:*)
-       case $UNAME_RELEASE in
-       *4.0)
-               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-               ;;
-       *5.*)
-               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
-               ;;
-       esac
-       # According to Compaq, /usr/sbin/psrinfo has been available on
-       # OSF/1 and Tru64 systems produced since 1995.  I hope that
-       # covers most systems running today.  This code pipes the CPU
-       # types through head -n 1, so we only detect the type of CPU 0.
-       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-       case "$ALPHA_CPU_TYPE" in
-           "EV4 (21064)")
-               UNAME_MACHINE="alpha" ;;
-           "EV4.5 (21064)")
-               UNAME_MACHINE="alpha" ;;
-           "LCA4 (21066/21068)")
-               UNAME_MACHINE="alpha" ;;
-           "EV5 (21164)")
-               UNAME_MACHINE="alphaev5" ;;
-           "EV5.6 (21164A)")
-               UNAME_MACHINE="alphaev56" ;;
-           "EV5.6 (21164PC)")
-               UNAME_MACHINE="alphapca56" ;;
-           "EV5.7 (21164PC)")
-               UNAME_MACHINE="alphapca57" ;;
-           "EV6 (21264)")
-               UNAME_MACHINE="alphaev6" ;;
-           "EV6.7 (21264A)")
-               UNAME_MACHINE="alphaev67" ;;
-           "EV6.8CB (21264C)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.8AL (21264B)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.8CX (21264D)")
-               UNAME_MACHINE="alphaev68" ;;
-           "EV6.9A (21264/EV69A)")
-               UNAME_MACHINE="alphaev69" ;;
-           "EV7 (21364)")
-               UNAME_MACHINE="alphaev7" ;;
-           "EV7.9 (21364A)")
-               UNAME_MACHINE="alphaev79" ;;
-       esac
-       # A Pn.n version is a patched version.
-       # A Vn.n version is a released version.
-       # A Tn.n version is a released field test version.
-       # A Xn.n version is an unreleased experimental baselevel.
-       # 1.2 uses "1.2" for uname -r.
-       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-       exit ;;
-    Alpha\ *:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # Should we change UNAME_MACHINE based on the output of uname instead
-       # of the specific Alpha model?
-       echo alpha-pc-interix
-       exit ;;
-    21064:Windows_NT:50:3)
-       echo alpha-dec-winnt3.5
-       exit ;;
-    Amiga*:UNIX_System_V:4.0:*)
-       echo m68k-unknown-sysv4
-       exit ;;
-    *:[Aa]miga[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-amigaos
-       exit ;;
-    *:[Mm]orph[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-morphos
-       exit ;;
-    *:OS/390:*:*)
-       echo i370-ibm-openedition
-       exit ;;
-    *:z/VM:*:*)
-       echo s390-ibm-zvmoe
-       exit ;;
-    *:OS400:*:*)
-        echo powerpc-ibm-os400
-       exit ;;
-    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-       echo arm-acorn-riscix${UNAME_RELEASE}
-       exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
-       echo arm-unknown-riscos
-       exit ;;
-    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-       echo hppa1.1-hitachi-hiuxmpp
-       exit ;;
-    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
-       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-       if test "`(/bin/universe) 2>/dev/null`" = att ; then
-               echo pyramid-pyramid-sysv3
-       else
-               echo pyramid-pyramid-bsd
-       fi
-       exit ;;
-    NILE*:*:*:dcosx)
-       echo pyramid-pyramid-svr4
-       exit ;;
-    DRS?6000:unix:4.0:6*)
-       echo sparc-icl-nx6
-       exit ;;
-    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
-       case `/usr/bin/uname -p` in
-           sparc) echo sparc-icl-nx7; exit ;;
-       esac ;;
-    s390x:SunOS:*:*)
-       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4H:SunOS:5.*:*)
-       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       eval $set_cc_for_build
-       SUN_ARCH="i386"
-       # If there is a compiler, see if it is configured for 64-bit objects.
-       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-       # This test works for both compilers.
-       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-               grep IS_64BIT_ARCH >/dev/null
-           then
-               SUN_ARCH="x86_64"
-           fi
-       fi
-       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:6*:*)
-       # According to config.sub, this is the proper way to canonicalize
-       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
-       # it's likely to be more like Solaris than SunOS4.
-       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    sun4*:SunOS:*:*)
-       case "`/usr/bin/arch -k`" in
-           Series*|S4*)
-               UNAME_RELEASE=`uname -v`
-               ;;
-       esac
-       # Japanese Language versions have a version number like `4.1.3-JL'.
-       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-       exit ;;
-    sun3*:SunOS:*:*)
-       echo m68k-sun-sunos${UNAME_RELEASE}
-       exit ;;
-    sun*:*:4.2BSD:*)
-       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
-       case "`/bin/arch`" in
-           sun3)
-               echo m68k-sun-sunos${UNAME_RELEASE}
-               ;;
-           sun4)
-               echo sparc-sun-sunos${UNAME_RELEASE}
-               ;;
-       esac
-       exit ;;
-    aushp:SunOS:*:*)
-       echo sparc-auspex-sunos${UNAME_RELEASE}
-       exit ;;
-    # The situation for MiNT is a little confusing.  The machine name
-    # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor
-    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
-    # to the lowercase version "mint" (or "freemint").  Finally
-    # the system name "TOS" denotes a system which is actually not
-    # MiNT.  But MiNT is downward compatible to TOS, so this should
-    # be no problem.
-    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit ;;
-    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
-    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-       exit ;;
-    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
-    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
-    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
-    m68k:machten:*:*)
-       echo m68k-apple-machten${UNAME_RELEASE}
-       exit ;;
-    powerpc:machten:*:*)
-       echo powerpc-apple-machten${UNAME_RELEASE}
-       exit ;;
-    RISC*:Mach:*:*)
-       echo mips-dec-mach_bsd4.3
-       exit ;;
-    RISC*:ULTRIX:*:*)
-       echo mips-dec-ultrix${UNAME_RELEASE}
-       exit ;;
-    VAX*:ULTRIX*:*:*)
-       echo vax-dec-ultrix${UNAME_RELEASE}
-       exit ;;
-    2020:CLIX:*:* | 2430:CLIX:*:*)
-       echo clipper-intergraph-clix${UNAME_RELEASE}
-       exit ;;
-    mips:*:*:UMIPS | mips:*:*:RISCos)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-       int main (int argc, char *argv[]) {
-#else
-       int main (argc, argv) int argc; char *argv[]; {
-#endif
-       #if defined (host_mips) && defined (MIPSEB)
-       #if defined (SYSTYPE_SYSV)
-         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
-       #endif
-       #if defined (SYSTYPE_SVR4)
-         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
-       #endif
-       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
-       #endif
-       #endif
-         exit (-1);
-       }
-EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c &&
-         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-         SYSTEM_NAME=`$dummy $dummyarg` &&
-           { echo "$SYSTEM_NAME"; exit; }
-       echo mips-mips-riscos${UNAME_RELEASE}
-       exit ;;
-    Motorola:PowerMAX_OS:*:*)
-       echo powerpc-motorola-powermax
-       exit ;;
-    Motorola:*:4.3:PL8-*)
-       echo powerpc-harris-powermax
-       exit ;;
-    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-       echo powerpc-harris-powermax
-       exit ;;
-    Night_Hawk:Power_UNIX:*:*)
-       echo powerpc-harris-powerunix
-       exit ;;
-    m88k:CX/UX:7*:*)
-       echo m88k-harris-cxux7
-       exit ;;
-    m88k:*:4*:R4*)
-       echo m88k-motorola-sysv4
-       exit ;;
-    m88k:*:3*:R3*)
-       echo m88k-motorola-sysv3
-       exit ;;
-    AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
-       then
-           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-              [ ${TARGET_BINARY_INTERFACE}x = x ]
-           then
-               echo m88k-dg-dgux${UNAME_RELEASE}
-           else
-               echo m88k-dg-dguxbcs${UNAME_RELEASE}
-           fi
-       else
-           echo i586-dg-dgux${UNAME_RELEASE}
-       fi
-       exit ;;
-    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
-       echo m88k-dolphin-sysv3
-       exit ;;
-    M88*:*:R3*:*)
-       # Delta 88k system running SVR3
-       echo m88k-motorola-sysv3
-       exit ;;
-    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-       echo m88k-tektronix-sysv3
-       exit ;;
-    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-       echo m68k-tektronix-bsd
-       exit ;;
-    *:IRIX*:*:*)
-       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-       exit ;;
-    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
-    i*86:AIX:*:*)
-       echo i386-ibm-aix
-       exit ;;
-    ia64:AIX:*:*)
-       if [ -x /usr/bin/oslevel ] ; then
-               IBM_REV=`/usr/bin/oslevel`
-       else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-       fi
-       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-       exit ;;
-    *:AIX:2:3)
-       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-               eval $set_cc_for_build
-               sed 's/^                //' << EOF >$dummy.c
-               #include <sys/systemcfg.h>
-
-               main()
-                       {
-                       if (!__power_pc())
-                               exit(1);
-                       puts("powerpc-ibm-aix3.2.5");
-                       exit(0);
-                       }
-EOF
-               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
-               then
-                       echo "$SYSTEM_NAME"
-               else
-                       echo rs6000-ibm-aix3.2.5
-               fi
-       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-               echo rs6000-ibm-aix3.2.4
-       else
-               echo rs6000-ibm-aix3.2
-       fi
-       exit ;;
-    *:AIX:*:[456])
-       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
-               IBM_ARCH=rs6000
-       else
-               IBM_ARCH=powerpc
-       fi
-       if [ -x /usr/bin/oslevel ] ; then
-               IBM_REV=`/usr/bin/oslevel`
-       else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-       fi
-       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-       exit ;;
-    *:AIX:*:*)
-       echo rs6000-ibm-aix
-       exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
-       echo romp-ibm-bsd4.4
-       exit ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-       exit ;;                             # report: romp-ibm BSD 4.3
-    *:BOSX:*:*)
-       echo rs6000-bull-bosx
-       exit ;;
-    DPX/2?00:B.O.S.:*:*)
-       echo m68k-bull-sysv3
-       exit ;;
-    9000/[34]??:4.3bsd:1.*:*)
-       echo m68k-hp-bsd
-       exit ;;
-    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-       echo m68k-hp-bsd4.4
-       exit ;;
-    9000/[34678]??:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       case "${UNAME_MACHINE}" in
-           9000/31? )            HP_ARCH=m68000 ;;
-           9000/[34]?? )         HP_ARCH=m68k ;;
-           9000/[678][0-9][0-9])
-               if [ -x /usr/bin/getconf ]; then
-                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
-                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
-               fi
-               if [ "${HP_ARCH}" = "" ]; then
-                   eval $set_cc_for_build
-                   sed 's/^              //' << EOF >$dummy.c
-
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
-
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
-
-                  switch (cpu)
-               {
-               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-               case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-                   switch (bits)
-                       {
-                       case 64: puts ("hppa2.0w"); break;
-                       case 32: puts ("hppa2.0n"); break;
-                       default: puts ("hppa2.0"); break;
-                       } break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-                   puts ("hppa2.0"); break;
-              #endif
-               default: puts ("hppa1.0"); break;
-               }
-                  exit (0);
-              }
-EOF
-                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
-                   test -z "$HP_ARCH" && HP_ARCH=hppa
-               fi ;;
-       esac
-       if [ ${HP_ARCH} = "hppa2.0w" ]
-       then
-           eval $set_cc_for_build
-
-           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
-           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
-           # generating 64-bit code.  GNU and HP use different nomenclature:
-           #
-           # $ CC_FOR_BUILD=cc ./config.guess
-           # => hppa2.0w-hp-hpux11.23
-           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
-           # => hppa64-hp-hpux11.23
-
-           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-               grep -q __LP64__
-           then
-               HP_ARCH="hppa2.0w"
-           else
-               HP_ARCH="hppa64"
-           fi
-       fi
-       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-       exit ;;
-    ia64:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       echo ia64-hp-hpux${HPUX_REV}
-       exit ;;
-    3050*:HI-UX:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <unistd.h>
-       int
-       main ()
-       {
-         long cpu = sysconf (_SC_CPU_VERSION);
-         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
-            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
-            results, however.  */
-         if (CPU_IS_PA_RISC (cpu))
-           {
-             switch (cpu)
-               {
-                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
-                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
-                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
-                 default: puts ("hppa-hitachi-hiuxwe2"); break;
-               }
-           }
-         else if (CPU_IS_HP_MC68K (cpu))
-           puts ("m68k-hitachi-hiuxwe2");
-         else puts ("unknown-hitachi-hiuxwe2");
-         exit (0);
-       }
-EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
-               { echo "$SYSTEM_NAME"; exit; }
-       echo unknown-hitachi-hiuxwe2
-       exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
-       echo hppa1.1-hp-bsd
-       exit ;;
-    9000/8??:4.3bsd:*:*)
-       echo hppa1.0-hp-bsd
-       exit ;;
-    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-       echo hppa1.0-hp-mpeix
-       exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
-       echo hppa1.1-hp-osf
-       exit ;;
-    hp8??:OSF1:*:*)
-       echo hppa1.0-hp-osf
-       exit ;;
-    i*86:OSF1:*:*)
-       if [ -x /usr/sbin/sysversion ] ; then
-           echo ${UNAME_MACHINE}-unknown-osf1mk
-       else
-           echo ${UNAME_MACHINE}-unknown-osf1
-       fi
-       exit ;;
-    parisc*:Lites*:*:*)
-       echo hppa1.1-hp-lites
-       exit ;;
-    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-       echo c1-convex-bsd
-        exit ;;
-    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
-       if getsysinfo -f scalar_acc
-       then echo c32-convex-bsd
-       else echo c2-convex-bsd
-       fi
-        exit ;;
-    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-       echo c34-convex-bsd
-        exit ;;
-    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-       echo c38-convex-bsd
-        exit ;;
-    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-       echo c4-convex-bsd
-        exit ;;
-    CRAY*Y-MP:*:*:*)
-       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*[A-Z]90:*:*:*)
-       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
-       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-             -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*TS:*:*:*)
-       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*T3E:*:*:*)
-       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    CRAY*SV1:*:*:*)
-       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    *:UNICOS/mp:*:*)
-       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-       exit ;;
-    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
-    5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-       exit ;;
-    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-       exit ;;
-    sparc*:BSD/OS:*:*)
-       echo sparc-unknown-bsdi${UNAME_RELEASE}
-       exit ;;
-    *:BSD/OS:*:*)
-       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-       exit ;;
-    *:FreeBSD:*:*)
-       case ${UNAME_MACHINE} in
-           pc98)
-               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           amd64)
-               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           *)
-               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-       esac
-       exit ;;
-    i*:CYGWIN*:*)
-       echo ${UNAME_MACHINE}-pc-cygwin
-       exit ;;
-    *:MINGW*:*)
-       echo ${UNAME_MACHINE}-pc-mingw32
-       exit ;;
-    i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
-       exit ;;
-    i*:PW*:*)
-       echo ${UNAME_MACHINE}-pc-pw32
-       exit ;;
-    *:Interix*:[3456]*)
-       case ${UNAME_MACHINE} in
-           x86)
-               echo i586-pc-interix${UNAME_RELEASE}
-               exit ;;
-           EM64T | authenticamd | genuineintel)
-               echo x86_64-unknown-interix${UNAME_RELEASE}
-               exit ;;
-           IA64)
-               echo ia64-unknown-interix${UNAME_RELEASE}
-               exit ;;
-       esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-       echo i${UNAME_MACHINE}-pc-mks
-       exit ;;
-    8664:Windows_NT:*)
-       echo x86_64-pc-mks
-       exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-       # UNAME_MACHINE based on the output of uname instead of i386?
-       echo i586-pc-interix
-       exit ;;
-    i*:UWIN*:*)
-       echo ${UNAME_MACHINE}-pc-uwin
-       exit ;;
-    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-       echo x86_64-unknown-cygwin
-       exit ;;
-    p*:CYGWIN*:*)
-       echo powerpcle-unknown-cygwin
-       exit ;;
-    prep*:SunOS:5.*:*)
-       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-       exit ;;
-    *:GNU:*:*)
-       # the GNU system
-       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-       exit ;;
-    *:GNU/*:*:*)
-       # other systems with GNU libc and userland
-       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
-       exit ;;
-    i*86:Minix:*:*)
-       echo ${UNAME_MACHINE}-pc-minix
-       exit ;;
-    arm*:Linux:*:*)
-       eval $set_cc_for_build
-       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
-           | grep -q __ARM_EABI__
-       then
-           echo ${UNAME_MACHINE}-unknown-linux-gnu
-       else
-           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
-       fi
-       exit ;;
-    avr32*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    cris:Linux:*:*)
-       echo cris-axis-linux-gnu
-       exit ;;
-    crisv32:Linux:*:*)
-       echo crisv32-axis-linux-gnu
-       exit ;;
-    frv:Linux:*:*)
-       echo frv-unknown-linux-gnu
-       exit ;;
-    ia64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    m32r*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    m68*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    mips:Linux:*:* | mips64:Linux:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #undef CPU
-       #undef ${UNAME_MACHINE}
-       #undef ${UNAME_MACHINE}el
-       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-       CPU=${UNAME_MACHINE}el
-       #else
-       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-       CPU=${UNAME_MACHINE}
-       #else
-       CPU=
-       #endif
-       #endif
-EOF
-       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-           /^CPU/{
-               s: ::g
-               p
-           }'`"
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-       ;;
-    or32:Linux:*:*)
-       echo or32-unknown-linux-gnu
-       exit ;;
-    ppc:Linux:*:*)
-       echo powerpc-unknown-linux-gnu
-       exit ;;
-    ppc64:Linux:*:*)
-       echo powerpc64-unknown-linux-gnu
-       exit ;;
-    alpha:Linux:*:*)
-       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-         EV5)   UNAME_MACHINE=alphaev5 ;;
-         EV56)  UNAME_MACHINE=alphaev56 ;;
-         PCA56) UNAME_MACHINE=alphapca56 ;;
-         PCA57) UNAME_MACHINE=alphapca56 ;;
-         EV6)   UNAME_MACHINE=alphaev6 ;;
-         EV67)  UNAME_MACHINE=alphaev67 ;;
-         EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-       objdump --private-headers /bin/sh | grep -q ld.so.1
-       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-       exit ;;
-    padre:Linux:*:*)
-       echo sparc-unknown-linux-gnu
-       exit ;;
-    parisc:Linux:*:* | hppa:Linux:*:*)
-       # Look for CPU level
-       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-         PA7*) echo hppa1.1-unknown-linux-gnu ;;
-         PA8*) echo hppa2.0-unknown-linux-gnu ;;
-         *)    echo hppa-unknown-linux-gnu ;;
-       esac
-       exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-       echo hppa64-unknown-linux-gnu
-       exit ;;
-    s390:Linux:*:* | s390x:Linux:*:*)
-       echo ${UNAME_MACHINE}-ibm-linux
-       exit ;;
-    sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    sh*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    sparc:Linux:*:* | sparc64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    vax:Linux:*:*)
-       echo ${UNAME_MACHINE}-dec-linux-gnu
-       exit ;;
-    x86_64:Linux:*:*)
-       echo x86_64-unknown-linux-gnu
-       exit ;;
-    xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
-       exit ;;
-    i*86:Linux:*:*)
-       # The BFD linker knows what the default object file format is, so
-       # first see if it will tell us. cd to the root directory to prevent
-       # problems with other programs or directories called `ld' in the path.
-       # Set LC_ALL=C to ensure ld outputs messages in English.
-       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-                        | sed -ne '/supported targets:/!d
-                                   s/[         ][      ]*/ /g
-                                   s/.*supported targets: *//
-                                   s/ .*//
-                                   p'`
-        case "$ld_supported_targets" in
-         elf32-i386)
-               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-               ;;
-       esac
-       # Determine whether the default compiler is a.out or elf
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
-       #include <features.h>
-       #ifdef __ELF__
-       # ifdef __GLIBC__
-       #  if __GLIBC__ >= 2
-       LIBC=gnu
-       #  else
-       LIBC=gnulibc1
-       #  endif
-       # else
-       LIBC=gnulibc1
-       # endif
-       #else
-       #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
-       LIBC=gnu
-       #else
-       LIBC=gnuaout
-       #endif
-       #endif
-       #ifdef __dietlibc__
-       LIBC=dietlibc
-       #endif
-EOF
-       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
-           /^LIBC/{
-               s: ::g
-               p
-           }'`"
-       test x"${LIBC}" != x && {
-               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-               exit
-       }
-       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
-       ;;
-    i*86:DYNIX/ptx:4*:*)
-       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
-       # earlier versions are messed up and put the nodename in both
-       # sysname and nodename.
-       echo i386-sequent-sysv4
-       exit ;;
-    i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
-       # I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
-       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-       exit ;;
-    i*86:OS/2:*:*)
-       # If we were able to find `uname', then EMX Unix compatibility
-       # is probably installed.
-       echo ${UNAME_MACHINE}-pc-os2-emx
-       exit ;;
-    i*86:XTS-300:*:STOP)
-       echo ${UNAME_MACHINE}-unknown-stop
-       exit ;;
-    i*86:atheos:*:*)
-       echo ${UNAME_MACHINE}-unknown-atheos
-       exit ;;
-    i*86:syllable:*:*)
-       echo ${UNAME_MACHINE}-pc-syllable
-       exit ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-       echo i386-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    i*86:*DOS:*:*)
-       echo ${UNAME_MACHINE}-pc-msdosdjgpp
-       exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
-       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
-       else
-               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
-       fi
-       exit ;;
-    i*86:*:5:[678]*)
-       # UnixWare 7.x, OpenUNIX and OpenServer 6.
-       case `/bin/uname -X | grep "^Machine"` in
-           *486*)           UNAME_MACHINE=i486 ;;
-           *Pentium)        UNAME_MACHINE=i586 ;;
-           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
-       esac
-       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-       exit ;;
-    i*86:*:3.2:*)
-       if test -f /usr/options/cb.name; then
-               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
-       elif /bin/uname -X 2>/dev/null >/dev/null ; then
-               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
-               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
-               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
-                       && UNAME_MACHINE=i586
-               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
-                       && UNAME_MACHINE=i686
-               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
-                       && UNAME_MACHINE=i686
-               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
-       else
-               echo ${UNAME_MACHINE}-pc-sysv32
-       fi
-       exit ;;
-    pc:*:*:*)
-       # Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i586.
-       # Note: whatever this is, it MUST be the same as what config.sub
-       # prints for the "djgpp" host, or else GDB configury will decide that
-       # this is a cross-build.
-       echo i586-pc-msdosdjgpp
-        exit ;;
-    Intel:Mach:3*:*)
-       echo i386-pc-mach3
-       exit ;;
-    paragon:*:*:*)
-       echo i860-intel-osf1
-       exit ;;
-    i860:*:4.*:*) # i860-SVR4
-       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
-       else # Add other i860-SVR4 vendors below as they are discovered.
-         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
-       fi
-       exit ;;
-    mini*:CTIX:SYS*5:*)
-       # "miniframe"
-       echo m68010-convergent-sysv
-       exit ;;
-    mc68k:UNIX:SYSTEM5:3.51m)
-       echo m68k-convergent-sysv
-       exit ;;
-    M680?0:D-NIX:5.3:*)
-       echo m68k-diab-dnix
-       exit ;;
-    M68*:*:R3V[5678]*:*)
-       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
-       OS_REL=''
-       test -r /etc/.relid \
-       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
-    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
-       OS_REL='.3'
-       test -r /etc/.relid \
-           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
-       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-       echo m68k-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    mc68030:UNIX_System_V:4.*:*)
-       echo m68k-atari-sysv4
-       exit ;;
-    TSUNAMI:LynxOS:2.*:*)
-       echo sparc-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    rs6000:LynxOS:2.*:*)
-       echo rs6000-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-       echo powerpc-unknown-lynxos${UNAME_RELEASE}
-       exit ;;
-    SM[BE]S:UNIX_SV:*:*)
-       echo mips-dde-sysv${UNAME_RELEASE}
-       exit ;;
-    RM*:ReliantUNIX-*:*:*)
-       echo mips-sni-sysv4
-       exit ;;
-    RM*:SINIX-*:*:*)
-       echo mips-sni-sysv4
-       exit ;;
-    *:SINIX-*:*:*)
-       if uname -p 2>/dev/null >/dev/null ; then
-               UNAME_MACHINE=`(uname -p) 2>/dev/null`
-               echo ${UNAME_MACHINE}-sni-sysv4
-       else
-               echo ns32k-sni-sysv
-       fi
-       exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
-    *:UNIX_System_V:4*:FTX*)
-       # From Gerald Hewes <hewes@openmarket.com>.
-       # How about differentiating between stratus architectures? -djm
-       echo hppa1.1-stratus-sysv4
-       exit ;;
-    *:*:*:FTX*)
-       # From seanf@swdc.stratus.com.
-       echo i860-stratus-sysv4
-       exit ;;
-    i*86:VOS:*:*)
-       # From Paul.Green@stratus.com.
-       echo ${UNAME_MACHINE}-stratus-vos
-       exit ;;
-    *:VOS:*:*)
-       # From Paul.Green@stratus.com.
-       echo hppa1.1-stratus-vos
-       exit ;;
-    mc68*:A/UX:*:*)
-       echo m68k-apple-aux${UNAME_RELEASE}
-       exit ;;
-    news*:NEWS-OS:6*:*)
-       echo mips-sony-newsos6
-       exit ;;
-    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-       if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
-       else
-               echo mips-unknown-sysv${UNAME_RELEASE}
-       fi
-        exit ;;
-    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
-       echo powerpc-be-beos
-       exit ;;
-    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
-       echo powerpc-apple-beos
-       exit ;;
-    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
-       echo i586-pc-beos
-       exit ;;
-    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
-       echo i586-pc-haiku
-       exit ;;
-    SX-4:SUPER-UX:*:*)
-       echo sx4-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-5:SUPER-UX:*:*)
-       echo sx5-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-6:SUPER-UX:*:*)
-       echo sx6-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-7:SUPER-UX:*:*)
-       echo sx7-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-8:SUPER-UX:*:*)
-       echo sx8-nec-superux${UNAME_RELEASE}
-       exit ;;
-    SX-8R:SUPER-UX:*:*)
-       echo sx8r-nec-superux${UNAME_RELEASE}
-       exit ;;
-    Power*:Rhapsody:*:*)
-       echo powerpc-apple-rhapsody${UNAME_RELEASE}
-       exit ;;
-    *:Rhapsody:*:*)
-       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-       exit ;;
-    *:Darwin:*:*)
-       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-       case $UNAME_PROCESSOR in
-           unknown) UNAME_PROCESSOR=powerpc ;;
-       esac
-       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-       exit ;;
-    *:procnto*:*:* | *:QNX:[0123456789]*:*)
-       UNAME_PROCESSOR=`uname -p`
-       if test "$UNAME_PROCESSOR" = "x86"; then
-               UNAME_PROCESSOR=i386
-               UNAME_MACHINE=pc
-       fi
-       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-       exit ;;
-    *:QNX:*:4*)
-       echo i386-pc-qnx
-       exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
-       echo nse-tandem-nsk${UNAME_RELEASE}
-       exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-       echo nsr-tandem-nsk${UNAME_RELEASE}
-       exit ;;
-    *:NonStop-UX:*:*)
-       echo mips-compaq-nonstopux
-       exit ;;
-    BS2000:POSIX*:*:*)
-       echo bs2000-siemens-sysv
-       exit ;;
-    DS/*:UNIX_System_V:*:*)
-       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-       exit ;;
-    *:Plan9:*:*)
-       # "uname -m" is not consistent, so use $cputype instead. 386
-       # is converted to i386 for consistency with other x86
-       # operating systems.
-       if test "$cputype" = "386"; then
-           UNAME_MACHINE=i386
-       else
-           UNAME_MACHINE="$cputype"
-       fi
-       echo ${UNAME_MACHINE}-unknown-plan9
-       exit ;;
-    *:TOPS-10:*:*)
-       echo pdp10-unknown-tops10
-       exit ;;
-    *:TENEX:*:*)
-       echo pdp10-unknown-tenex
-       exit ;;
-    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-       echo pdp10-dec-tops20
-       exit ;;
-    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-       echo pdp10-xkl-tops20
-       exit ;;
-    *:TOPS-20:*:*)
-       echo pdp10-unknown-tops20
-       exit ;;
-    *:ITS:*:*)
-       echo pdp10-unknown-its
-       exit ;;
-    SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
-       exit ;;
-    *:DragonFly:*:*)
-       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-       exit ;;
-    *:*VMS:*:*)
-       UNAME_MACHINE=`(uname -p) 2>/dev/null`
-       case "${UNAME_MACHINE}" in
-           A*) echo alpha-dec-vms ; exit ;;
-           I*) echo ia64-dec-vms ; exit ;;
-           V*) echo vax-dec-vms ; exit ;;
-       esac ;;
-    *:XENIX:*:SysV)
-       echo i386-pc-xenix
-       exit ;;
-    i*86:skyos:*:*)
-       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
-       exit ;;
-    i*86:rdos:*:*)
-       echo ${UNAME_MACHINE}-pc-rdos
-       exit ;;
-    i*86:AROS:*:*)
-       echo ${UNAME_MACHINE}-pc-aros
-       exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-          "4"
-#else
-         ""
-#endif
-         ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-       printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-       printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-       { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-       echo c1-convex-bsd
-       exit ;;
-    c2*)
-       if getsysinfo -f scalar_acc
-       then echo c32-convex-bsd
-       else echo c2-convex-bsd
-       fi
-       exit ;;
-    c34*)
-       echo c34-convex-bsd
-       exit ;;
-    c38*)
-       echo c38-convex-bsd
-       exit ;;
-    c4*)
-       echo c4-convex-bsd
-       exit ;;
-    esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
-and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo               = `(hostinfo) 2>/dev/null`
-/bin/universe          = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch              = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/autogen/config.sub b/autogen/config.sub
deleted file mode 100755 (executable)
index eb0389a..0000000
+++ /dev/null
@@ -1,1693 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-#   Free Software Foundation, Inc.
-
-timestamp='2009-06-11'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support.  The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )        # Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help"
-       exit 1 ;;
-
-    *local*)
-       # First pass through any local machine types.
-       echo $1
-       exit ;;
-
-    * )
-       break ;;
-  esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
-    exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
-    exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
-  kopensolaris*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-    os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
-    else os=; fi
-    ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work.  We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
-       -sun*os*)
-               # Prevent following clause from handling this invalid input.
-               ;;
-       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-       -apple | -axis | -knuth | -cray)
-               os=
-               basic_machine=$1
-               ;;
-        -bluegene*)
-               os=-cnk
-               ;;
-       -sim | -cisco | -oki | -wec | -winbond)
-               os=
-               basic_machine=$1
-               ;;
-       -scout)
-               ;;
-       -wrs)
-               os=-vxworks
-               basic_machine=$1
-               ;;
-       -chorusos*)
-               os=-chorusos
-               basic_machine=$1
-               ;;
-       -chorusrdb)
-               os=-chorusrdb
-               basic_machine=$1
-               ;;
-       -hiux*)
-               os=-hiuxwe2
-               ;;
-       -sco6)
-               os=-sco5v6
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5)
-               os=-sco3.2v5
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco4)
-               os=-sco3.2v4
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2.[4-9]*)
-               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2v[4-9]*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5v6*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco*)
-               os=-sco3.2v2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -udk*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -isc)
-               os=-isc2.2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -clix*)
-               basic_machine=clipper-intergraph
-               ;;
-       -isc*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -lynx*)
-               os=-lynxos
-               ;;
-       -ptx*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-               ;;
-       -windowsnt*)
-               os=`echo $os | sed -e 's/windowsnt/winnt/'`
-               ;;
-       -psos*)
-               os=-psos
-               ;;
-       -mint | -mint[0-9]*)
-               basic_machine=m68k-atari
-               os=-mint
-               ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
-       # Recognize the basic CPU types without company name.
-       # Some are omitted here because they have special meanings below.
-       1750a | 580 \
-       | a29k \
-       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-       | am33_2.0 \
-       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-       | bfin \
-       | c4x | clipper \
-       | d10v | d30v | dlx | dsp16xx \
-       | fido | fr30 | frv \
-       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-       | i370 | i860 | i960 | ia64 \
-       | ip2k | iq2000 \
-       | lm32 \
-       | m32c | m32r | m32rle | m68000 | m68k | m88k \
-       | maxq | mb | microblaze | mcore | mep | metag \
-       | mips | mipsbe | mipseb | mipsel | mipsle \
-       | mips16 \
-       | mips64 | mips64el \
-       | mips64octeon | mips64octeonel \
-       | mips64orion | mips64orionel \
-       | mips64r5900 | mips64r5900el \
-       | mips64vr | mips64vrel \
-       | mips64vr4100 | mips64vr4100el \
-       | mips64vr4300 | mips64vr4300el \
-       | mips64vr5000 | mips64vr5000el \
-       | mips64vr5900 | mips64vr5900el \
-       | mipsisa32 | mipsisa32el \
-       | mipsisa32r2 | mipsisa32r2el \
-       | mipsisa64 | mipsisa64el \
-       | mipsisa64r2 | mipsisa64r2el \
-       | mipsisa64sb1 | mipsisa64sb1el \
-       | mipsisa64sr71k | mipsisa64sr71kel \
-       | mipstx39 | mipstx39el \
-       | mn10200 | mn10300 \
-       | moxie \
-       | mt \
-       | msp430 \
-       | nios | nios2 \
-       | ns16k | ns32k \
-       | or32 \
-       | pdp10 | pdp11 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
-       | pyramid \
-       | score \
-       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
-       | sh64 | sh64le \
-       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
-       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-       | spu | strongarm \
-       | tahoe | thumb | tic4x | tic80 | tron \
-       | v850 | v850e \
-       | we32k \
-       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
-       | z8k | z80)
-               basic_machine=$basic_machine-unknown
-               ;;
-       m6811 | m68hc11 | m6812 | m68hc12)
-               # Motorola 68HC11/12.
-               basic_machine=$basic_machine-unknown
-               os=-none
-               ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
-               ;;
-       ms1)
-               basic_machine=mt-unknown
-               ;;
-
-       # We use `pc' rather than `unknown'
-       # because (1) that's what they normally are, and
-       # (2) the word "unknown" tends to confuse beginning users.
-       i*86 | x86_64)
-         basic_machine=$basic_machine-pc
-         ;;
-       # Object if more than one company name word.
-       *-*-*)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-               exit 1
-               ;;
-       # Recognize the basic CPU types with company name.
-       580-* \
-       | a29k-* \
-       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
-       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-       | avr-* | avr32-* \
-       | bfin-* | bs2000-* \
-       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-       | clipper-* | craynv-* | cydra-* \
-       | d10v-* | d30v-* | dlx-* \
-       | elxsi-* \
-       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
-       | h8300-* | h8500-* \
-       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-       | i*86-* | i860-* | i960-* | ia64-* \
-       | ip2k-* | iq2000-* \
-       | lm32-* \
-       | m32c-* | m32r-* | m32rle-* \
-       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
-       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
-       | mips16-* \
-       | mips64-* | mips64el-* \
-       | mips64octeon-* | mips64octeonel-* \
-       | mips64orion-* | mips64orionel-* \
-       | mips64r5900-* | mips64r5900el-* \
-       | mips64vr-* | mips64vrel-* \
-       | mips64vr4100-* | mips64vr4100el-* \
-       | mips64vr4300-* | mips64vr4300el-* \
-       | mips64vr5000-* | mips64vr5000el-* \
-       | mips64vr5900-* | mips64vr5900el-* \
-       | mipsisa32-* | mipsisa32el-* \
-       | mipsisa32r2-* | mipsisa32r2el-* \
-       | mipsisa64-* | mipsisa64el-* \
-       | mipsisa64r2-* | mipsisa64r2el-* \
-       | mipsisa64sb1-* | mipsisa64sb1el-* \
-       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
-       | mipstx39-* | mipstx39el-* \
-       | mmix-* \
-       | mt-* \
-       | msp430-* \
-       | nios-* | nios2-* \
-       | none-* | np1-* | ns16k-* | ns32k-* \
-       | orion-* \
-       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
-       | pyramid-* \
-       | romp-* | rs6000-* \
-       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
-       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
-       | sparclite-* \
-       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
-       | tahoe-* | thumb-* \
-       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
-       | tron-* \
-       | v850-* | v850e-* | vax-* \
-       | we32k-* \
-       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
-       | xstormy16-* | xtensa*-* \
-       | ymp-* \
-       | z8k-* | z80-*)
-               ;;
-       # Recognize the basic CPU types without company name, with glob match.
-       xtensa*)
-               basic_machine=$basic_machine-unknown
-               ;;
-       # Recognize the various machine names and aliases which stand
-       # for a CPU type and a company and sometimes even an OS.
-       386bsd)
-               basic_machine=i386-unknown
-               os=-bsd
-               ;;
-       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
-               basic_machine=m68000-att
-               ;;
-       3b*)
-               basic_machine=we32k-att
-               ;;
-       a29khif)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       abacus)
-               basic_machine=abacus-unknown
-               ;;
-       adobe68k)
-               basic_machine=m68010-adobe
-               os=-scout
-               ;;
-       alliant | fx80)
-               basic_machine=fx80-alliant
-               ;;
-       altos | altos3068)
-               basic_machine=m68k-altos
-               ;;
-       am29k)
-               basic_machine=a29k-none
-               os=-bsd
-               ;;
-       amd64)
-               basic_machine=x86_64-pc
-               ;;
-       amd64-*)
-               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       amdahl)
-               basic_machine=580-amdahl
-               os=-sysv
-               ;;
-       amiga | amiga-*)
-               basic_machine=m68k-unknown
-               ;;
-       amigaos | amigados)
-               basic_machine=m68k-unknown
-               os=-amigaos
-               ;;
-       amigaunix | amix)
-               basic_machine=m68k-unknown
-               os=-sysv4
-               ;;
-       apollo68)
-               basic_machine=m68k-apollo
-               os=-sysv
-               ;;
-       apollo68bsd)
-               basic_machine=m68k-apollo
-               os=-bsd
-               ;;
-       aros)
-               basic_machine=i386-pc
-               os=-aros
-               ;;
-       aux)
-               basic_machine=m68k-apple
-               os=-aux
-               ;;
-       balance)
-               basic_machine=ns32k-sequent
-               os=-dynix
-               ;;
-       blackfin)
-               basic_machine=bfin-unknown
-               os=-linux
-               ;;
-       blackfin-*)
-               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       bluegene*)
-               basic_machine=powerpc-ibm
-               os=-cnk
-               ;;
-       c90)
-               basic_machine=c90-cray
-               os=-unicos
-               ;;
-        cegcc)
-               basic_machine=arm-unknown
-               os=-cegcc
-               ;;
-       convex-c1)
-               basic_machine=c1-convex
-               os=-bsd
-               ;;
-       convex-c2)
-               basic_machine=c2-convex
-               os=-bsd
-               ;;
-       convex-c32)
-               basic_machine=c32-convex
-               os=-bsd
-               ;;
-       convex-c34)
-               basic_machine=c34-convex
-               os=-bsd
-               ;;
-       convex-c38)
-               basic_machine=c38-convex
-               os=-bsd
-               ;;
-       cray | j90)
-               basic_machine=j90-cray
-               os=-unicos
-               ;;
-       craynv)
-               basic_machine=craynv-cray
-               os=-unicosmp
-               ;;
-       cr16)
-               basic_machine=cr16-unknown
-               os=-elf
-               ;;
-       crds | unos)
-               basic_machine=m68k-crds
-               ;;
-       crisv32 | crisv32-* | etraxfs*)
-               basic_machine=crisv32-axis
-               ;;
-       cris | cris-* | etrax*)
-               basic_machine=cris-axis
-               ;;
-       crx)
-               basic_machine=crx-unknown
-               os=-elf
-               ;;
-       da30 | da30-*)
-               basic_machine=m68k-da30
-               ;;
-       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
-               basic_machine=mips-dec
-               ;;
-       decsystem10* | dec10*)
-               basic_machine=pdp10-dec
-               os=-tops10
-               ;;
-       decsystem20* | dec20*)
-               basic_machine=pdp10-dec
-               os=-tops20
-               ;;
-       delta | 3300 | motorola-3300 | motorola-delta \
-             | 3300-motorola | delta-motorola)
-               basic_machine=m68k-motorola
-               ;;
-       delta88)
-               basic_machine=m88k-motorola
-               os=-sysv3
-               ;;
-       dicos)
-               basic_machine=i686-pc
-               os=-dicos
-               ;;
-       djgpp)
-               basic_machine=i586-pc
-               os=-msdosdjgpp
-               ;;
-       dpx20 | dpx20-*)
-               basic_machine=rs6000-bull
-               os=-bosx
-               ;;
-       dpx2* | dpx2*-bull)
-               basic_machine=m68k-bull
-               os=-sysv3
-               ;;
-       ebmon29k)
-               basic_machine=a29k-amd
-               os=-ebmon
-               ;;
-       elxsi)
-               basic_machine=elxsi-elxsi
-               os=-bsd
-               ;;
-       encore | umax | mmax)
-               basic_machine=ns32k-encore
-               ;;
-       es1800 | OSE68k | ose68k | ose | OSE)
-               basic_machine=m68k-ericsson
-               os=-ose
-               ;;
-       fx2800)
-               basic_machine=i860-alliant
-               ;;
-       genix)
-               basic_machine=ns32k-ns
-               ;;
-       gmicro)
-               basic_machine=tron-gmicro
-               os=-sysv
-               ;;
-       go32)
-               basic_machine=i386-pc
-               os=-go32
-               ;;
-       h3050r* | hiux*)
-               basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       h8300hms)
-               basic_machine=h8300-hitachi
-               os=-hms
-               ;;
-       h8300xray)
-               basic_machine=h8300-hitachi
-               os=-xray
-               ;;
-       h8500hms)
-               basic_machine=h8500-hitachi
-               os=-hms
-               ;;
-       harris)
-               basic_machine=m88k-harris
-               os=-sysv3
-               ;;
-       hp300-*)
-               basic_machine=m68k-hp
-               ;;
-       hp300bsd)
-               basic_machine=m68k-hp
-               os=-bsd
-               ;;
-       hp300hpux)
-               basic_machine=m68k-hp
-               os=-hpux
-               ;;
-       hp3k9[0-9][0-9] | hp9[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hp9k2[0-9][0-9] | hp9k31[0-9])
-               basic_machine=m68000-hp
-               ;;
-       hp9k3[2-9][0-9])
-               basic_machine=m68k-hp
-               ;;
-       hp9k6[0-9][0-9] | hp6[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hp9k7[0-79][0-9] | hp7[0-79][0-9])
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k78[0-9] | hp78[0-9])
-               # FIXME: really hppa2.0-hp
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
-               # FIXME: really hppa2.0-hp
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[0-9][13679] | hp8[0-9][13679])
-               basic_machine=hppa1.1-hp
-               ;;
-       hp9k8[0-9][0-9] | hp8[0-9][0-9])
-               basic_machine=hppa1.0-hp
-               ;;
-       hppa-next)
-               os=-nextstep3
-               ;;
-       hppaosf)
-               basic_machine=hppa1.1-hp
-               os=-osf
-               ;;
-       hppro)
-               basic_machine=hppa1.1-hp
-               os=-proelf
-               ;;
-       i370-ibm* | ibm*)
-               basic_machine=i370-ibm
-               ;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-       i*86v32)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv32
-               ;;
-       i*86v4*)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv4
-               ;;
-       i*86v)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv
-               ;;
-       i*86sol2)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-solaris2
-               ;;
-       i386mach)
-               basic_machine=i386-mach
-               os=-mach
-               ;;
-       i386-vsta | vsta)
-               basic_machine=i386-unknown
-               os=-vsta
-               ;;
-       iris | iris4d)
-               basic_machine=mips-sgi
-               case $os in
-                   -irix*)
-                       ;;
-                   *)
-                       os=-irix4
-                       ;;
-               esac
-               ;;
-       isi68 | isi)
-               basic_machine=m68k-isi
-               os=-sysv
-               ;;
-       m68knommu)
-               basic_machine=m68k-unknown
-               os=-linux
-               ;;
-       m68knommu-*)
-               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       m88k-omron*)
-               basic_machine=m88k-omron
-               ;;
-       magnum | m3230)
-               basic_machine=mips-mips
-               os=-sysv
-               ;;
-       merlin)
-               basic_machine=ns32k-utek
-               os=-sysv
-               ;;
-       mingw32)
-               basic_machine=i386-pc
-               os=-mingw32
-               ;;
-       mingw32ce)
-               basic_machine=arm-unknown
-               os=-mingw32ce
-               ;;
-       miniframe)
-               basic_machine=m68000-convergent
-               ;;
-       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
-               basic_machine=m68k-atari
-               os=-mint
-               ;;
-       mips3*-*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
-               ;;
-       mips3*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-               ;;
-       monitor)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
-       morphos)
-               basic_machine=powerpc-unknown
-               os=-morphos
-               ;;
-       msdos)
-               basic_machine=i386-pc
-               os=-msdos
-               ;;
-       ms1-*)
-               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-               ;;
-       mvs)
-               basic_machine=i370-ibm
-               os=-mvs
-               ;;
-       ncr3000)
-               basic_machine=i486-ncr
-               os=-sysv4
-               ;;
-       netbsd386)
-               basic_machine=i386-unknown
-               os=-netbsd
-               ;;
-       netwinder)
-               basic_machine=armv4l-rebel
-               os=-linux
-               ;;
-       news | news700 | news800 | news900)
-               basic_machine=m68k-sony
-               os=-newsos
-               ;;
-       news1000)
-               basic_machine=m68030-sony
-               os=-newsos
-               ;;
-       news-3600 | risc-news)
-               basic_machine=mips-sony
-               os=-newsos
-               ;;
-       necv70)
-               basic_machine=v70-nec
-               os=-sysv
-               ;;
-       next | m*-next )
-               basic_machine=m68k-next
-               case $os in
-                   -nextstep* )
-                       ;;
-                   -ns2*)
-                     os=-nextstep2
-                       ;;
-                   *)
-                     os=-nextstep3
-                       ;;
-               esac
-               ;;
-       nh3000)
-               basic_machine=m68k-harris
-               os=-cxux
-               ;;
-       nh[45]000)
-               basic_machine=m88k-harris
-               os=-cxux
-               ;;
-       nindy960)
-               basic_machine=i960-intel
-               os=-nindy
-               ;;
-       mon960)
-               basic_machine=i960-intel
-               os=-mon960
-               ;;
-       nonstopux)
-               basic_machine=mips-compaq
-               os=-nonstopux
-               ;;
-       np1)
-               basic_machine=np1-gould
-               ;;
-       nsr-tandem)
-               basic_machine=nsr-tandem
-               ;;
-       op50n-* | op60c-*)
-               basic_machine=hppa1.1-oki
-               os=-proelf
-               ;;
-       openrisc | openrisc-*)
-               basic_machine=or32-unknown
-               ;;
-       os400)
-               basic_machine=powerpc-ibm
-               os=-os400
-               ;;
-       OSE68000 | ose68000)
-               basic_machine=m68000-ericsson
-               os=-ose
-               ;;
-       os68k)
-               basic_machine=m68k-none
-               os=-os68k
-               ;;
-       pa-hitachi)
-               basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       paragon)
-               basic_machine=i860-intel
-               os=-osf
-               ;;
-       parisc)
-               basic_machine=hppa-unknown
-               os=-linux
-               ;;
-       parisc-*)
-               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       pbd)
-               basic_machine=sparc-tti
-               ;;
-       pbb)
-               basic_machine=m68k-tti
-               ;;
-       pc532 | pc532-*)
-               basic_machine=ns32k-pc532
-               ;;
-       pc98)
-               basic_machine=i386-pc
-               ;;
-       pc98-*)
-               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentium | p5 | k5 | k6 | nexgen | viac3)
-               basic_machine=i586-pc
-               ;;
-       pentiumpro | p6 | 6x86 | athlon | athlon_*)
-               basic_machine=i686-pc
-               ;;
-       pentiumii | pentium2 | pentiumiii | pentium3)
-               basic_machine=i686-pc
-               ;;
-       pentium4)
-               basic_machine=i786-pc
-               ;;
-       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentiumpro-* | p6-* | 6x86-* | athlon-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pentium4-*)
-               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       pn)
-               basic_machine=pn-gould
-               ;;
-       power)  basic_machine=power-ibm
-               ;;
-       ppc)    basic_machine=powerpc-unknown
-               ;;
-       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
-               basic_machine=powerpcle-unknown
-               ;;
-       ppcle-* | powerpclittle-*)
-               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppc64)  basic_machine=powerpc64-unknown
-               ;;
-       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-               basic_machine=powerpc64le-unknown
-               ;;
-       ppc64le-* | powerpc64little-*)
-               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ps2)
-               basic_machine=i386-ibm
-               ;;
-       pw32)
-               basic_machine=i586-unknown
-               os=-pw32
-               ;;
-       rdos)
-               basic_machine=i386-pc
-               os=-rdos
-               ;;
-       rom68k)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
-       rm[46]00)
-               basic_machine=mips-siemens
-               ;;
-       rtpc | rtpc-*)
-               basic_machine=romp-ibm
-               ;;
-       s390 | s390-*)
-               basic_machine=s390-ibm
-               ;;
-       s390x | s390x-*)
-               basic_machine=s390x-ibm
-               ;;
-       sa29200)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       sb1)
-               basic_machine=mipsisa64sb1-unknown
-               ;;
-       sb1el)
-               basic_machine=mipsisa64sb1el-unknown
-               ;;
-       sde)
-               basic_machine=mipsisa32-sde
-               os=-elf
-               ;;
-       sei)
-               basic_machine=mips-sei
-               os=-seiux
-               ;;
-       sequent)
-               basic_machine=i386-sequent
-               ;;
-       sh)
-               basic_machine=sh-hitachi
-               os=-hms
-               ;;
-       sh5el)
-               basic_machine=sh5le-unknown
-               ;;
-       sh64)
-               basic_machine=sh64-unknown
-               ;;
-       sparclite-wrs | simso-wrs)
-               basic_machine=sparclite-wrs
-               os=-vxworks
-               ;;
-       sps7)
-               basic_machine=m68k-bull
-               os=-sysv2
-               ;;
-       spur)
-               basic_machine=spur-unknown
-               ;;
-       st2000)
-               basic_machine=m68k-tandem
-               ;;
-       stratus)
-               basic_machine=i860-stratus
-               os=-sysv4
-               ;;
-       sun2)
-               basic_machine=m68000-sun
-               ;;
-       sun2os3)
-               basic_machine=m68000-sun
-               os=-sunos3
-               ;;
-       sun2os4)
-               basic_machine=m68000-sun
-               os=-sunos4
-               ;;
-       sun3os3)
-               basic_machine=m68k-sun
-               os=-sunos3
-               ;;
-       sun3os4)
-               basic_machine=m68k-sun
-               os=-sunos4
-               ;;
-       sun4os3)
-               basic_machine=sparc-sun
-               os=-sunos3
-               ;;
-       sun4os4)
-               basic_machine=sparc-sun
-               os=-sunos4
-               ;;
-       sun4sol2)
-               basic_machine=sparc-sun
-               os=-solaris2
-               ;;
-       sun3 | sun3-*)
-               basic_machine=m68k-sun
-               ;;
-       sun4)
-               basic_machine=sparc-sun
-               ;;
-       sun386 | sun386i | roadrunner)
-               basic_machine=i386-sun
-               ;;
-       sv1)
-               basic_machine=sv1-cray
-               os=-unicos
-               ;;
-       symmetry)
-               basic_machine=i386-sequent
-               os=-dynix
-               ;;
-       t3e)
-               basic_machine=alphaev5-cray
-               os=-unicos
-               ;;
-       t90)
-               basic_machine=t90-cray
-               os=-unicos
-               ;;
-       tic54x | c54x*)
-               basic_machine=tic54x-unknown
-               os=-coff
-               ;;
-       tic55x | c55x*)
-               basic_machine=tic55x-unknown
-               os=-coff
-               ;;
-       tic6x | c6x*)
-               basic_machine=tic6x-unknown
-               os=-coff
-               ;;
-       tile*)
-               basic_machine=tile-unknown
-               os=-linux-gnu
-               ;;
-       tx39)
-               basic_machine=mipstx39-unknown
-               ;;
-       tx39el)
-               basic_machine=mipstx39el-unknown
-               ;;
-       toad1)
-               basic_machine=pdp10-xkl
-               os=-tops20
-               ;;
-       tower | tower-32)
-               basic_machine=m68k-ncr
-               ;;
-       tpf)
-               basic_machine=s390x-ibm
-               os=-tpf
-               ;;
-       udi29k)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       ultra3)
-               basic_machine=a29k-nyu
-               os=-sym1
-               ;;
-       v810 | necv810)
-               basic_machine=v810-nec
-               os=-none
-               ;;
-       vaxv)
-               basic_machine=vax-dec
-               os=-sysv
-               ;;
-       vms)
-               basic_machine=vax-dec
-               os=-vms
-               ;;
-       vpp*|vx|vx-*)
-               basic_machine=f301-fujitsu
-               ;;
-       vxworks960)
-               basic_machine=i960-wrs
-               os=-vxworks
-               ;;
-       vxworks68)
-               basic_machine=m68k-wrs
-               os=-vxworks
-               ;;
-       vxworks29k)
-               basic_machine=a29k-wrs
-               os=-vxworks
-               ;;
-       w65*)
-               basic_machine=w65-wdc
-               os=-none
-               ;;
-       w89k-*)
-               basic_machine=hppa1.1-winbond
-               os=-proelf
-               ;;
-       xbox)
-               basic_machine=i686-pc
-               os=-mingw32
-               ;;
-       xps | xps100)
-               basic_machine=xps100-honeywell
-               ;;
-       ymp)
-               basic_machine=ymp-cray
-               os=-unicos
-               ;;
-       z8k-*-coff)
-               basic_machine=z8k-unknown
-               os=-sim
-               ;;
-       z80-*-coff)
-               basic_machine=z80-unknown
-               os=-sim
-               ;;
-       none)
-               basic_machine=none-none
-               os=-none
-               ;;
-
-# Here we handle the default manufacturer of certain CPU types.  It is in
-# some cases the only manufacturer, in others, it is the most popular.
-       w89k)
-               basic_machine=hppa1.1-winbond
-               ;;
-       op50n)
-               basic_machine=hppa1.1-oki
-               ;;
-       op60c)
-               basic_machine=hppa1.1-oki
-               ;;
-       romp)
-               basic_machine=romp-ibm
-               ;;
-       mmix)
-               basic_machine=mmix-knuth
-               ;;
-       rs6000)
-               basic_machine=rs6000-ibm
-               ;;
-       vax)
-               basic_machine=vax-dec
-               ;;
-       pdp10)
-               # there are many clones, so DEC is not a safe bet
-               basic_machine=pdp10-unknown
-               ;;
-       pdp11)
-               basic_machine=pdp11-dec
-               ;;
-       we32k)
-               basic_machine=we32k-att
-               ;;
-       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
-               basic_machine=sh-unknown
-               ;;
-       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-               basic_machine=sparc-sun
-               ;;
-       cydra)
-               basic_machine=cydra-cydrome
-               ;;
-       orion)
-               basic_machine=orion-highlevel
-               ;;
-       orion105)
-               basic_machine=clipper-highlevel
-               ;;
-       mac | mpw | mac-mpw)
-               basic_machine=m68k-apple
-               ;;
-       pmac | pmac-mpw)
-               basic_machine=powerpc-apple
-               ;;
-       *-unknown)
-               # Make sure to match an already-canonicalized machine name.
-               ;;
-       *)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-               exit 1
-               ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
-       *-digital*)
-               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
-               ;;
-       *-commodore*)
-               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
-               ;;
-       *)
-               ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
-       # -solaris* is a basic system type, with this one exception.
-       -solaris1 | -solaris1.*)
-               os=`echo $os | sed -e 's|solaris1|sunos4|'`
-               ;;
-       -solaris)
-               os=-solaris2
-               ;;
-       -svr4*)
-               os=-sysv4
-               ;;
-       -unixware*)
-               os=-sysv4.2uw
-               ;;
-       -gnu/linux*)
-               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-               ;;
-       # First accept the basic system types.
-       # The portable systems comes first.
-       # Each alternative MUST END IN A *, to match a version number.
-       # -sysv* is not here because it comes later, after sysvr4.
-       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
-             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
-             | -kopensolaris* \
-             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-             | -aos* | -aros* \
-             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-             | -openbsd* | -solidbsd* \
-             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* | -cegcc* \
-             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
-             | -uxpv* | -beos* | -mpeix* | -udk* \
-             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
-       # Remember, each alternative MUST END IN *, to match a version number.
-               ;;
-       -qnx*)
-               case $basic_machine in
-                   x86-* | i*86-*)
-                       ;;
-                   *)
-                       os=-nto$os
-                       ;;
-               esac
-               ;;
-       -nto-qnx*)
-               ;;
-       -nto*)
-               os=`echo $os | sed -e 's|nto|nto-qnx|'`
-               ;;
-       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
-               ;;
-       -mac*)
-               os=`echo $os | sed -e 's|mac|macos|'`
-               ;;
-       -linux-dietlibc)
-               os=-linux-dietlibc
-               ;;
-       -linux*)
-               os=`echo $os | sed -e 's|linux|linux-gnu|'`
-               ;;
-       -sunos5*)
-               os=`echo $os | sed -e 's|sunos5|solaris2|'`
-               ;;
-       -sunos6*)
-               os=`echo $os | sed -e 's|sunos6|solaris3|'`
-               ;;
-       -opened*)
-               os=-openedition
-               ;;
-        -os400*)
-               os=-os400
-               ;;
-       -wince*)
-               os=-wince
-               ;;
-       -osfrose*)
-               os=-osfrose
-               ;;
-       -osf*)
-               os=-osf
-               ;;
-       -utek*)
-               os=-bsd
-               ;;
-       -dynix*)
-               os=-bsd
-               ;;
-       -acis*)
-               os=-aos
-               ;;
-       -atheos*)
-               os=-atheos
-               ;;
-       -syllable*)
-               os=-syllable
-               ;;
-       -386bsd)
-               os=-bsd
-               ;;
-       -ctix* | -uts*)
-               os=-sysv
-               ;;
-       -nova*)
-               os=-rtmk-nova
-               ;;
-       -ns2 )
-               os=-nextstep2
-               ;;
-       -nsk*)
-               os=-nsk
-               ;;
-       # Preserve the version number of sinix5.
-       -sinix5.*)
-               os=`echo $os | sed -e 's|sinix|sysv|'`
-               ;;
-       -sinix*)
-               os=-sysv4
-               ;;
-        -tpf*)
-               os=-tpf
-               ;;
-       -triton*)
-               os=-sysv3
-               ;;
-       -oss*)
-               os=-sysv3
-               ;;
-       -svr4)
-               os=-sysv4
-               ;;
-       -svr3)
-               os=-sysv3
-               ;;
-       -sysvr4)
-               os=-sysv4
-               ;;
-       # This must come after -sysvr4.
-       -sysv*)
-               ;;
-       -ose*)
-               os=-ose
-               ;;
-       -es1800*)
-               os=-ose
-               ;;
-       -xenix)
-               os=-xenix
-               ;;
-       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-               os=-mint
-               ;;
-       -aros*)
-               os=-aros
-               ;;
-       -kaos*)
-               os=-kaos
-               ;;
-       -zvmoe)
-               os=-zvmoe
-               ;;
-       -dicos*)
-               os=-dicos
-               ;;
-       -none)
-               ;;
-       *)
-               # Get rid of the `-' at the beginning of $os.
-               os=`echo $os | sed 's/[^-]*-//'`
-               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
-               exit 1
-               ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system.  Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
-        score-*)
-               os=-elf
-               ;;
-        spu-*)
-               os=-elf
-               ;;
-       *-acorn)
-               os=-riscix1.2
-               ;;
-       arm*-rebel)
-               os=-linux
-               ;;
-       arm*-semi)
-               os=-aout
-               ;;
-        c4x-* | tic4x-*)
-               os=-coff
-               ;;
-       # This must come before the *-dec entry.
-       pdp10-*)
-               os=-tops20
-               ;;
-       pdp11-*)
-               os=-none
-               ;;
-       *-dec | vax-*)
-               os=-ultrix4.2
-               ;;
-       m68*-apollo)
-               os=-domain
-               ;;
-       i386-sun)
-               os=-sunos4.0.2
-               ;;
-       m68000-sun)
-               os=-sunos3
-               # This also exists in the configure program, but was not the
-               # default.
-               # os=-sunos4
-               ;;
-       m68*-cisco)
-               os=-aout
-               ;;
-        mep-*)
-               os=-elf
-               ;;
-       mips*-cisco)
-               os=-elf
-               ;;
-       mips*-*)
-               os=-elf
-               ;;
-       or32-*)
-               os=-coff
-               ;;
-       *-tti)  # must be before sparc entry or we get the wrong os.
-               os=-sysv3
-               ;;
-       sparc-* | *-sun)
-               os=-sunos4.1.1
-               ;;
-       *-be)
-               os=-beos
-               ;;
-       *-haiku)
-               os=-haiku
-               ;;
-       *-ibm)
-               os=-aix
-               ;;
-       *-knuth)
-               os=-mmixware
-               ;;
-       *-wec)
-               os=-proelf
-               ;;
-       *-winbond)
-               os=-proelf
-               ;;
-       *-oki)
-               os=-proelf
-               ;;
-       *-hp)
-               os=-hpux
-               ;;
-       *-hitachi)
-               os=-hiux
-               ;;
-       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-               os=-sysv
-               ;;
-       *-cbm)
-               os=-amigaos
-               ;;
-       *-dg)
-               os=-dgux
-               ;;
-       *-dolphin)
-               os=-sysv3
-               ;;
-       m68k-ccur)
-               os=-rtu
-               ;;
-       m88k-omron*)
-               os=-luna
-               ;;
-       *-next )
-               os=-nextstep
-               ;;
-       *-sequent)
-               os=-ptx
-               ;;
-       *-crds)
-               os=-unos
-               ;;
-       *-ns)
-               os=-genix
-               ;;
-       i370-*)
-               os=-mvs
-               ;;
-       *-next)
-               os=-nextstep3
-               ;;
-       *-gould)
-               os=-sysv
-               ;;
-       *-highlevel)
-               os=-bsd
-               ;;
-       *-encore)
-               os=-bsd
-               ;;
-       *-sgi)
-               os=-irix
-               ;;
-       *-siemens)
-               os=-sysv4
-               ;;
-       *-masscomp)
-               os=-rtu
-               ;;
-       f30[01]-fujitsu | f700-fujitsu)
-               os=-uxpv
-               ;;
-       *-rom68k)
-               os=-coff
-               ;;
-       *-*bug)
-               os=-coff
-               ;;
-       *-apple)
-               os=-macos
-               ;;
-       *-atari*)
-               os=-mint
-               ;;
-       *)
-               os=-none
-               ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer.  We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
-       *-unknown)
-               case $os in
-                       -riscix*)
-                               vendor=acorn
-                               ;;
-                       -sunos*)
-                               vendor=sun
-                               ;;
-                       -cnk*|-aix*)
-                               vendor=ibm
-                               ;;
-                       -beos*)
-                               vendor=be
-                               ;;
-                       -hpux*)
-                               vendor=hp
-                               ;;
-                       -mpeix*)
-                               vendor=hp
-                               ;;
-                       -hiux*)
-                               vendor=hitachi
-                               ;;
-                       -unos*)
-                               vendor=crds
-                               ;;
-                       -dgux*)
-                               vendor=dg
-                               ;;
-                       -luna*)
-                               vendor=omron
-                               ;;
-                       -genix*)
-                               vendor=ns
-                               ;;
-                       -mvs* | -opened*)
-                               vendor=ibm
-                               ;;
-                       -os400*)
-                               vendor=ibm
-                               ;;
-                       -ptx*)
-                               vendor=sequent
-                               ;;
-                       -tpf*)
-                               vendor=ibm
-                               ;;
-                       -vxsim* | -vxworks* | -windiss*)
-                               vendor=wrs
-                               ;;
-                       -aux*)
-                               vendor=apple
-                               ;;
-                       -hms*)
-                               vendor=hitachi
-                               ;;
-                       -mpw* | -macos*)
-                               vendor=apple
-                               ;;
-                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-                               vendor=atari
-                               ;;
-                       -vos*)
-                               vendor=stratus
-                               ;;
-               esac
-               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
-               ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/autogen/configure b/autogen/configure
deleted file mode 100755 (executable)
index 5f379dc..0000000
+++ /dev/null
@@ -1,31210 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.65 for emacs 24.3.50.
-#
-#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-       expr "X$arg" : "X\\(.*\\)$as_nl";
-       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""       $as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
-else
-  case \`(set -o) 2>/dev/null\` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-"
-  as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
-  exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1"
-  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
-test \$(( 1 + 1 )) = 2 || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
-  as_have_required=yes
-else
-  as_have_required=no
-fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  as_found=:
-  case $as_dir in #(
-        /*)
-          for as_base in sh bash ksh sh5; do
-            # Try only shells that exist, to save several forks.
-            as_shell=$as_dir/$as_base
-            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  CONFIG_SHELL=$as_shell as_have_required=yes
-                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  break 2
-fi
-fi
-          done;;
-       esac
-  as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-  CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
-      if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-       # neutralization value for shells without unset; and this also
-       # works around shells that cannot unset nonexistent variables.
-       BASH_ENV=/dev/null
-       ENV=/dev/null
-       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-       export CONFIG_SHELL
-       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
-fi
-
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-  else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
-$0: including any error possibly output before this
-$0: message. Then install a modern shell, or manually run
-$0: the script under such a shell if you do have one."
-  fi
-  exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$as_dir" : 'X\(//\)[^/]' \| \
-        X"$as_dir" : 'X\(//\)$' \| \
-        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-  fi
-  $as_echo "$as_me: error: $1" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-        X"$0" : 'X\(//\)$' \| \
-        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-           s//\1/
-           q
-         }
-         /^X\/\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\/\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
-  as_lineno_1=$LINENO as_lineno_1a=$LINENO
-  as_lineno_2=$LINENO as_lineno_2a=$LINENO
-  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
-  sed -n '
-    p
-    /[$]LINENO/=
-  ' <$as_myself |
-    sed '
-      s/[$]LINENO.*/&-/
-      t lineno
-      b
-      :lineno
-      N
-      :loop
-      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-      t loop
-      s/-\n.*//
-    ' >$as_me.lineno &&
-  chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensitive to this).
-  . "./$as_me.lineno"
-  # Exit status is that of the last command.
-  exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='        ';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -p'
-  fi
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-       test -d "$1/.";
-      else
-       case $1 in #(
-       -*)set "./$1";;
-       esac;
-       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-       ???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME='emacs'
-PACKAGE_TARNAME='emacs'
-PACKAGE_VERSION='24.3.50'
-PACKAGE_STRING='emacs 24.3.50'
-PACKAGE_BUGREPORT=''
-PACKAGE_URL=''
-
-ac_unique_file="src/lisp.h"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_header_list=
-ac_func_list=
-gl_getopt_required=POSIX
-gl_getopt_required=POSIX
-ac_subst_vars='gltests_LTLIBOBJS
-gltests_LIBOBJS
-gl_LTLIBOBJS
-gl_LIBOBJS
-am__EXEEXT_FALSE
-am__EXEEXT_TRUE
-LTLIBOBJS
-LIBOBJS
-SUBDIR_MAKEFILES_IN
-ns_check_file
-WINDOW_SYSTEM_OBJ
-EMACS_HEAPSIZE
-TEMACS_POST_LINK
-ADDSECTION
-LD_SWITCH_SYSTEM_TEMACS
-LIBGNU_LTLIBDEPS
-LIBGNU_LIBDEPS
-gltests_WITNESS
-gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE
-gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE
-gl_GNULIB_ENABLED_tempname_FALSE
-gl_GNULIB_ENABLED_tempname_TRUE
-gl_GNULIB_ENABLED_strtoull_FALSE
-gl_GNULIB_ENABLED_strtoull_TRUE
-gl_GNULIB_ENABLED_strtoll_FALSE
-gl_GNULIB_ENABLED_strtoll_TRUE
-gl_GNULIB_ENABLED_stat_FALSE
-gl_GNULIB_ENABLED_stat_TRUE
-gl_GNULIB_ENABLED_secure_getenv_FALSE
-gl_GNULIB_ENABLED_secure_getenv_TRUE
-gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_FALSE
-gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_TRUE
-gl_GNULIB_ENABLED_pathmax_FALSE
-gl_GNULIB_ENABLED_pathmax_TRUE
-gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_FALSE
-gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_TRUE
-gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_FALSE
-gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_TRUE
-gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE
-gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE
-gl_GNULIB_ENABLED_getgroups_FALSE
-gl_GNULIB_ENABLED_getgroups_TRUE
-gl_GNULIB_ENABLED_getdtablesize_FALSE
-gl_GNULIB_ENABLED_getdtablesize_TRUE
-gl_GNULIB_ENABLED_euidaccess_FALSE
-gl_GNULIB_ENABLED_euidaccess_TRUE
-gl_GNULIB_ENABLED_dosname_FALSE
-gl_GNULIB_ENABLED_dosname_TRUE
-gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_FALSE
-gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE
-LTLIBINTL
-LIBINTL
-LIB_EACCESS
-WINDOWS_64_BIT_OFF_T
-HAVE_UNISTD_H
-NEXT_AS_FIRST_DIRECTIVE_UNISTD_H
-NEXT_UNISTD_H
-LIB_TIMER_TIME
-PTHREAD_H_DEFINES_STRUCT_TIMESPEC
-SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
-TIME_H_DEFINES_STRUCT_TIMESPEC
-NEXT_AS_FIRST_DIRECTIVE_TIME_H
-NEXT_TIME_H
-WINDOWS_64_BIT_ST_SIZE
-NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H
-NEXT_SYS_STAT_H
-NEXT_AS_FIRST_DIRECTIVE_STRING_H
-NEXT_STRING_H
-NEXT_AS_FIRST_DIRECTIVE_STDLIB_H
-NEXT_STDLIB_H
-NEXT_AS_FIRST_DIRECTIVE_STDIO_H
-NEXT_STDIO_H
-REPLACE_VSPRINTF
-REPLACE_VSNPRINTF
-REPLACE_VPRINTF
-REPLACE_VFPRINTF
-REPLACE_VDPRINTF
-REPLACE_VASPRINTF
-REPLACE_TMPFILE
-REPLACE_STDIO_WRITE_FUNCS
-REPLACE_STDIO_READ_FUNCS
-REPLACE_SPRINTF
-REPLACE_SNPRINTF
-REPLACE_RENAMEAT
-REPLACE_RENAME
-REPLACE_REMOVE
-REPLACE_PRINTF
-REPLACE_POPEN
-REPLACE_PERROR
-REPLACE_OBSTACK_PRINTF
-REPLACE_GETLINE
-REPLACE_GETDELIM
-REPLACE_FTELLO
-REPLACE_FTELL
-REPLACE_FSEEKO
-REPLACE_FSEEK
-REPLACE_FREOPEN
-REPLACE_FPURGE
-REPLACE_FPRINTF
-REPLACE_FOPEN
-REPLACE_FFLUSH
-REPLACE_FDOPEN
-REPLACE_FCLOSE
-REPLACE_DPRINTF
-HAVE_VDPRINTF
-HAVE_VASPRINTF
-HAVE_RENAMEAT
-HAVE_POPEN
-HAVE_PCLOSE
-HAVE_FTELLO
-HAVE_FSEEKO
-HAVE_DPRINTF
-HAVE_DECL_VSNPRINTF
-HAVE_DECL_SNPRINTF
-HAVE_DECL_OBSTACK_PRINTF
-HAVE_DECL_GETLINE
-HAVE_DECL_GETDELIM
-HAVE_DECL_FTELLO
-HAVE_DECL_FSEEKO
-HAVE_DECL_FPURGE
-GNULIB_VSPRINTF_POSIX
-GNULIB_VSNPRINTF
-GNULIB_VPRINTF_POSIX
-GNULIB_VPRINTF
-GNULIB_VFPRINTF_POSIX
-GNULIB_VFPRINTF
-GNULIB_VDPRINTF
-GNULIB_VSCANF
-GNULIB_VFSCANF
-GNULIB_VASPRINTF
-GNULIB_TMPFILE
-GNULIB_STDIO_H_SIGPIPE
-GNULIB_STDIO_H_NONBLOCKING
-GNULIB_SPRINTF_POSIX
-GNULIB_SNPRINTF
-GNULIB_SCANF
-GNULIB_RENAMEAT
-GNULIB_RENAME
-GNULIB_REMOVE
-GNULIB_PUTS
-GNULIB_PUTCHAR
-GNULIB_PUTC
-GNULIB_PRINTF_POSIX
-GNULIB_PRINTF
-GNULIB_POPEN
-GNULIB_PERROR
-GNULIB_PCLOSE
-GNULIB_OBSTACK_PRINTF_POSIX
-GNULIB_OBSTACK_PRINTF
-GNULIB_GETLINE
-GNULIB_GETDELIM
-GNULIB_GETCHAR
-GNULIB_GETC
-GNULIB_FWRITE
-GNULIB_FTELLO
-GNULIB_FTELL
-GNULIB_FSEEKO
-GNULIB_FSEEK
-GNULIB_FSCANF
-GNULIB_FREOPEN
-GNULIB_FREAD
-GNULIB_FPUTS
-GNULIB_FPUTC
-GNULIB_FPURGE
-GNULIB_FPRINTF_POSIX
-GNULIB_FPRINTF
-GNULIB_FOPEN
-GNULIB_FGETS
-GNULIB_FGETC
-GNULIB_FFLUSH
-GNULIB_FDOPEN
-GNULIB_FCLOSE
-GNULIB_DPRINTF
-NEXT_AS_FIRST_DIRECTIVE_STDDEF_H
-NEXT_STDDEF_H
-GL_GENERATE_STDDEF_H_FALSE
-GL_GENERATE_STDDEF_H_TRUE
-STDDEF_H
-HAVE_WCHAR_T
-REPLACE_NULL
-HAVE__BOOL
-GL_GENERATE_STDBOOL_H_FALSE
-GL_GENERATE_STDBOOL_H_TRUE
-STDBOOL_H
-GL_GENERATE_STDARG_H_FALSE
-GL_GENERATE_STDARG_H_TRUE
-STDARG_H
-NEXT_AS_FIRST_DIRECTIVE_STDARG_H
-NEXT_STDARG_H
-GL_GENERATE_STDALIGN_H_FALSE
-GL_GENERATE_STDALIGN_H_TRUE
-STDALIGN_H
-NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H
-NEXT_SIGNAL_H
-USE_ACL
-LIB_ACL
-LIB_PTHREAD_SIGMASK
-REPLACE_RAISE
-REPLACE_PTHREAD_SIGMASK
-HAVE_SIGHANDLER_T
-HAVE_TYPE_VOLATILE_SIG_ATOMIC_T
-HAVE_STRUCT_SIGACTION_SA_SIGACTION
-HAVE_SIGACTION
-HAVE_SIGINFO_T
-HAVE_SIGSET_T
-HAVE_RAISE
-HAVE_PTHREAD_SIGMASK
-HAVE_POSIX_SIGNALBLOCKING
-GNULIB_SIGACTION
-GNULIB_SIGPROCMASK
-GNULIB_SIGNAL_H_SIGPIPE
-GNULIB_RAISE
-GNULIB_PTHREAD_SIGMASK
-HAVE_SYS_SELECT_H
-NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H
-NEXT_SYS_SELECT_H
-REPLACE_SELECT
-REPLACE_PSELECT
-HAVE_PSELECT
-GNULIB_SELECT
-GNULIB_PSELECT
-REPLACE_TIMEGM
-REPLACE_NANOSLEEP
-REPLACE_MKTIME
-REPLACE_LOCALTIME_R
-HAVE_TIMEGM
-HAVE_STRPTIME
-HAVE_NANOSLEEP
-HAVE_DECL_LOCALTIME_R
-GNULIB_TIME_R
-GNULIB_TIMEGM
-GNULIB_STRPTIME
-GNULIB_NANOSLEEP
-GNULIB_MKTIME
-UNDEFINE_STRTOK_R
-REPLACE_STRTOK_R
-REPLACE_STRSIGNAL
-REPLACE_STRNLEN
-REPLACE_STRNDUP
-REPLACE_STRNCAT
-REPLACE_STRERROR_R
-REPLACE_STRERROR
-REPLACE_STRCHRNUL
-REPLACE_STRCASESTR
-REPLACE_STRSTR
-REPLACE_STRDUP
-REPLACE_STPNCPY
-REPLACE_MEMMEM
-REPLACE_MEMCHR
-HAVE_STRVERSCMP
-HAVE_DECL_STRSIGNAL
-HAVE_DECL_STRERROR_R
-HAVE_DECL_STRTOK_R
-HAVE_STRCASESTR
-HAVE_STRSEP
-HAVE_STRPBRK
-HAVE_DECL_STRNLEN
-HAVE_DECL_STRNDUP
-HAVE_DECL_STRDUP
-HAVE_STRCHRNUL
-HAVE_STPNCPY
-HAVE_STPCPY
-HAVE_RAWMEMCHR
-HAVE_DECL_MEMRCHR
-HAVE_MEMPCPY
-HAVE_DECL_MEMMEM
-HAVE_MEMCHR
-HAVE_FFSLL
-HAVE_FFSL
-HAVE_MBSLEN
-GNULIB_STRVERSCMP
-GNULIB_STRSIGNAL
-GNULIB_STRERROR_R
-GNULIB_STRERROR
-GNULIB_MBSTOK_R
-GNULIB_MBSSEP
-GNULIB_MBSSPN
-GNULIB_MBSPBRK
-GNULIB_MBSCSPN
-GNULIB_MBSCASESTR
-GNULIB_MBSPCASECMP
-GNULIB_MBSNCASECMP
-GNULIB_MBSCASECMP
-GNULIB_MBSSTR
-GNULIB_MBSRCHR
-GNULIB_MBSCHR
-GNULIB_MBSNLEN
-GNULIB_MBSLEN
-GNULIB_STRTOK_R
-GNULIB_STRCASESTR
-GNULIB_STRSTR
-GNULIB_STRSEP
-GNULIB_STRPBRK
-GNULIB_STRNLEN
-GNULIB_STRNDUP
-GNULIB_STRNCAT
-GNULIB_STRDUP
-GNULIB_STRCHRNUL
-GNULIB_STPNCPY
-GNULIB_STPCPY
-GNULIB_RAWMEMCHR
-GNULIB_MEMRCHR
-GNULIB_MEMPCPY
-GNULIB_MEMMEM
-GNULIB_MEMCHR
-GNULIB_FFSLL
-GNULIB_FFSL
-NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H
-NEXT_INTTYPES_H
-UINT64_MAX_EQ_ULONG_MAX
-UINT32_MAX_LT_UINTMAX_MAX
-PRIPTR_PREFIX
-PRI_MACROS_BROKEN
-INT64_MAX_EQ_LONG_MAX
-INT32_MAX_LT_INTMAX_MAX
-REPLACE_STRTOUMAX
-REPLACE_STRTOIMAX
-HAVE_DECL_STRTOUMAX
-HAVE_DECL_STRTOIMAX
-HAVE_DECL_IMAXDIV
-HAVE_DECL_IMAXABS
-GNULIB_STRTOUMAX
-GNULIB_STRTOIMAX
-GNULIB_IMAXDIV
-GNULIB_IMAXABS
-GL_GENERATE_STDINT_H_FALSE
-GL_GENERATE_STDINT_H_TRUE
-STDINT_H
-WINT_T_SUFFIX
-WCHAR_T_SUFFIX
-SIG_ATOMIC_T_SUFFIX
-SIZE_T_SUFFIX
-PTRDIFF_T_SUFFIX
-HAVE_SIGNED_WINT_T
-HAVE_SIGNED_WCHAR_T
-HAVE_SIGNED_SIG_ATOMIC_T
-BITSIZEOF_WINT_T
-BITSIZEOF_WCHAR_T
-BITSIZEOF_SIG_ATOMIC_T
-BITSIZEOF_SIZE_T
-BITSIZEOF_PTRDIFF_T
-APPLE_UNIVERSAL_BUILD
-HAVE_SYS_BITYPES_H
-HAVE_SYS_INTTYPES_H
-HAVE_STDINT_H
-NEXT_AS_FIRST_DIRECTIVE_STDINT_H
-NEXT_STDINT_H
-HAVE_SYS_TYPES_H
-HAVE_INTTYPES_H
-HAVE_WCHAR_H
-HAVE_UNSIGNED_LONG_LONG_INT
-HAVE_LONG_LONG_INT
-HAVE_WINSOCK2_H
-NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H
-NEXT_SYS_TIME_H
-REPLACE_STRUCT_TIMEVAL
-REPLACE_GETTIMEOFDAY
-HAVE_SYS_TIME_H
-HAVE_STRUCT_TIMEVAL
-HAVE_GETTIMEOFDAY
-GNULIB_GETTIMEOFDAY
-GNULIB_GL_UNISTD_H_GETOPT
-GETOPT_H
-HAVE_GETOPT_H
-NEXT_AS_FIRST_DIRECTIVE_GETOPT_H
-NEXT_GETOPT_H
-GETLOADAVG_LIBS
-REPLACE_WCTOMB
-REPLACE_UNSETENV
-REPLACE_STRTOD
-REPLACE_SETENV
-REPLACE_REALPATH
-REPLACE_REALLOC
-REPLACE_RANDOM_R
-REPLACE_PUTENV
-REPLACE_PTSNAME_R
-REPLACE_PTSNAME
-REPLACE_MKSTEMP
-REPLACE_MBTOWC
-REPLACE_MALLOC
-REPLACE_CANONICALIZE_FILE_NAME
-REPLACE_CALLOC
-HAVE_DECL_UNSETENV
-HAVE_UNLOCKPT
-HAVE_SYS_LOADAVG_H
-HAVE_STRUCT_RANDOM_DATA
-HAVE_STRTOULL
-HAVE_STRTOLL
-HAVE_STRTOD
-HAVE_DECL_SETENV
-HAVE_SETENV
-HAVE_SECURE_GETENV
-HAVE_RPMATCH
-HAVE_REALPATH
-HAVE_RANDOM_R
-HAVE_RANDOM_H
-HAVE_RANDOM
-HAVE_PTSNAME_R
-HAVE_PTSNAME
-HAVE_POSIX_OPENPT
-HAVE_MKSTEMPS
-HAVE_MKSTEMP
-HAVE_MKOSTEMPS
-HAVE_MKOSTEMP
-HAVE_MKDTEMP
-HAVE_GRANTPT
-HAVE_GETSUBOPT
-HAVE_DECL_GETLOADAVG
-HAVE_CANONICALIZE_FILE_NAME
-HAVE_ATOLL
-HAVE__EXIT
-GNULIB_WCTOMB
-GNULIB_UNSETENV
-GNULIB_UNLOCKPT
-GNULIB_SYSTEM_POSIX
-GNULIB_STRTOULL
-GNULIB_STRTOLL
-GNULIB_STRTOD
-GNULIB_SETENV
-GNULIB_SECURE_GETENV
-GNULIB_RPMATCH
-GNULIB_REALPATH
-GNULIB_REALLOC_POSIX
-GNULIB_RANDOM_R
-GNULIB_RANDOM
-GNULIB_PUTENV
-GNULIB_PTSNAME_R
-GNULIB_PTSNAME
-GNULIB_POSIX_OPENPT
-GNULIB_MKSTEMPS
-GNULIB_MKSTEMP
-GNULIB_MKOSTEMPS
-GNULIB_MKOSTEMP
-GNULIB_MKDTEMP
-GNULIB_MBTOWC
-GNULIB_MALLOC_POSIX
-GNULIB_GRANTPT
-GNULIB_GETSUBOPT
-GNULIB_GETLOADAVG
-GNULIB_CANONICALIZE_FILE_NAME
-GNULIB_CALLOC_POSIX
-GNULIB_ATOLL
-GNULIB__EXIT
-REPLACE_UTIMENSAT
-REPLACE_STAT
-REPLACE_MKNOD
-REPLACE_MKFIFO
-REPLACE_MKDIR
-REPLACE_LSTAT
-REPLACE_FUTIMENS
-REPLACE_FSTATAT
-REPLACE_FSTAT
-HAVE_UTIMENSAT
-HAVE_MKNODAT
-HAVE_MKNOD
-HAVE_MKFIFOAT
-HAVE_MKFIFO
-HAVE_MKDIRAT
-HAVE_LSTAT
-HAVE_LCHMOD
-HAVE_FUTIMENS
-HAVE_FSTATAT
-HAVE_FCHMODAT
-GNULIB_UTIMENSAT
-GNULIB_STAT
-GNULIB_MKNODAT
-GNULIB_MKNOD
-GNULIB_MKFIFOAT
-GNULIB_MKFIFO
-GNULIB_MKDIRAT
-GNULIB_LSTAT
-GNULIB_LCHMOD
-GNULIB_FUTIMENS
-GNULIB_FSTATAT
-GNULIB_FSTAT
-GNULIB_FCHMODAT
-LIB_FDATASYNC
-NEXT_AS_FIRST_DIRECTIVE_FCNTL_H
-NEXT_FCNTL_H
-REPLACE_OPENAT
-REPLACE_OPEN
-REPLACE_FCNTL
-HAVE_OPENAT
-HAVE_FCNTL
-GNULIB_OPENAT
-GNULIB_OPEN
-GNULIB_NONBLOCKING
-GNULIB_FCNTL
-GL_GENERATE_EXECINFO_H_FALSE
-GL_GENERATE_EXECINFO_H_TRUE
-LIB_EXECINFO
-EXECINFO_H
-EOVERFLOW_VALUE
-EOVERFLOW_HIDDEN
-ENOLINK_VALUE
-ENOLINK_HIDDEN
-EMULTIHOP_VALUE
-EMULTIHOP_HIDDEN
-GL_GENERATE_ERRNO_H_FALSE
-GL_GENERATE_ERRNO_H_TRUE
-ERRNO_H
-NEXT_AS_FIRST_DIRECTIVE_ERRNO_H
-NEXT_ERRNO_H
-HAVE_DIRENT_H
-NEXT_AS_FIRST_DIRECTIVE_DIRENT_H
-NEXT_DIRENT_H
-PRAGMA_COLUMNS
-PRAGMA_SYSTEM_HEADER
-INCLUDE_NEXT_AS_FIRST_DIRECTIVE
-INCLUDE_NEXT
-REPLACE_FDOPENDIR
-REPLACE_DIRFD
-REPLACE_CLOSEDIR
-REPLACE_OPENDIR
-HAVE_ALPHASORT
-HAVE_SCANDIR
-HAVE_FDOPENDIR
-HAVE_DECL_FDOPENDIR
-HAVE_DECL_DIRFD
-HAVE_CLOSEDIR
-HAVE_REWINDDIR
-HAVE_READDIR
-HAVE_OPENDIR
-GNULIB_ALPHASORT
-GNULIB_SCANDIR
-GNULIB_FDOPENDIR
-GNULIB_DIRFD
-GNULIB_CLOSEDIR
-GNULIB_REWINDDIR
-GNULIB_READDIR
-GNULIB_OPENDIR
-UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS
-UNISTD_H_HAVE_WINSOCK2_H
-REPLACE_WRITE
-REPLACE_USLEEP
-REPLACE_UNLINKAT
-REPLACE_UNLINK
-REPLACE_TTYNAME_R
-REPLACE_SYMLINK
-REPLACE_SLEEP
-REPLACE_RMDIR
-REPLACE_READLINK
-REPLACE_READ
-REPLACE_PWRITE
-REPLACE_PREAD
-REPLACE_LSEEK
-REPLACE_LINKAT
-REPLACE_LINK
-REPLACE_LCHOWN
-REPLACE_ISATTY
-REPLACE_GETPAGESIZE
-REPLACE_GETGROUPS
-REPLACE_GETLOGIN_R
-REPLACE_GETDTABLESIZE
-REPLACE_GETDOMAINNAME
-REPLACE_GETCWD
-REPLACE_FTRUNCATE
-REPLACE_FCHOWNAT
-REPLACE_DUP2
-REPLACE_DUP
-REPLACE_CLOSE
-REPLACE_CHOWN
-HAVE_SYS_PARAM_H
-HAVE_OS_H
-HAVE_DECL_TTYNAME_R
-HAVE_DECL_SETHOSTNAME
-HAVE_DECL_GETUSERSHELL
-HAVE_DECL_GETPAGESIZE
-HAVE_DECL_GETLOGIN_R
-HAVE_DECL_GETDOMAINNAME
-HAVE_DECL_FDATASYNC
-HAVE_DECL_FCHDIR
-HAVE_DECL_ENVIRON
-HAVE_USLEEP
-HAVE_UNLINKAT
-HAVE_SYMLINKAT
-HAVE_SYMLINK
-HAVE_SLEEP
-HAVE_SETHOSTNAME
-HAVE_READLINKAT
-HAVE_READLINK
-HAVE_PWRITE
-HAVE_PREAD
-HAVE_PIPE2
-HAVE_PIPE
-HAVE_LINKAT
-HAVE_LINK
-HAVE_LCHOWN
-HAVE_GROUP_MEMBER
-HAVE_GETPAGESIZE
-HAVE_GETLOGIN
-HAVE_GETHOSTNAME
-HAVE_GETGROUPS
-HAVE_GETDTABLESIZE
-HAVE_FTRUNCATE
-HAVE_FSYNC
-HAVE_FDATASYNC
-HAVE_FCHOWNAT
-HAVE_FCHDIR
-HAVE_FACCESSAT
-HAVE_EUIDACCESS
-HAVE_DUP3
-HAVE_DUP2
-HAVE_CHOWN
-GNULIB_WRITE
-GNULIB_USLEEP
-GNULIB_UNLINKAT
-GNULIB_UNLINK
-GNULIB_UNISTD_H_SIGPIPE
-GNULIB_UNISTD_H_NONBLOCKING
-GNULIB_TTYNAME_R
-GNULIB_SYMLINKAT
-GNULIB_SYMLINK
-GNULIB_SLEEP
-GNULIB_SETHOSTNAME
-GNULIB_RMDIR
-GNULIB_READLINKAT
-GNULIB_READLINK
-GNULIB_READ
-GNULIB_PWRITE
-GNULIB_PREAD
-GNULIB_PIPE2
-GNULIB_PIPE
-GNULIB_LSEEK
-GNULIB_LINKAT
-GNULIB_LINK
-GNULIB_LCHOWN
-GNULIB_ISATTY
-GNULIB_GROUP_MEMBER
-GNULIB_GETUSERSHELL
-GNULIB_GETPAGESIZE
-GNULIB_GETLOGIN_R
-GNULIB_GETLOGIN
-GNULIB_GETHOSTNAME
-GNULIB_GETGROUPS
-GNULIB_GETDTABLESIZE
-GNULIB_GETDOMAINNAME
-GNULIB_GETCWD
-GNULIB_FTRUNCATE
-GNULIB_FSYNC
-GNULIB_FDATASYNC
-GNULIB_FCHOWNAT
-GNULIB_FCHDIR
-GNULIB_FACCESSAT
-GNULIB_EUIDACCESS
-GNULIB_ENVIRON
-GNULIB_DUP3
-GNULIB_DUP2
-GNULIB_DUP
-GNULIB_CLOSE
-GNULIB_CHOWN
-GNULIB_CHDIR
-LIB_CLOCK_GETTIME
-GL_GENERATE_BYTESWAP_H_FALSE
-GL_GENERATE_BYTESWAP_H_TRUE
-BYTESWAP_H
-GL_GENERATE_ALLOCA_H_FALSE
-GL_GENERATE_ALLOCA_H_TRUE
-ALLOCA_H
-ALLOCA
-GL_COND_LIBTOOL_FALSE
-GL_COND_LIBTOOL_TRUE
-POST_ALLOC_OBJ
-PRE_ALLOC_OBJ
-CYGWIN_OBJ
-RALLOC_OBJ
-OLDXMENU_DEPS
-LIBX_OTHER
-LIBXMENU
-OLDXMENU
-OLDXMENU_TARGET
-LIBXT_OTHER
-TOOLKIT_LIBW
-WIDGET_OBJ
-XOBJ
-XMENU_OBJ
-FONT_OBJ
-OTHER_FILES
-GNU_OBJC_CFLAGS
-ns_appsrc
-ns_appresdir
-ns_appbindir
-ns_appdir
-X_TOOLKIT_TYPE
-GNUSTEP_CFLAGS
-C_SWITCH_X_SITE
-LD_SWITCH_X_SITE
-gameuser
-gamedir
-bitmapdir
-etcdocdir
-archlibdir
-etcdir
-x_default_search_path
-lisppath
-locallisppath
-standardlisppath
-leimdir
-lispdir
-srcdir
-canonical
-configuration
-version
-copyright
-XGSELOBJ
-KRB4LIB
-DESLIB
-KRB5LIB
-CRYPTOLIB
-COM_ERRLIB
-LIBRESOLV
-LIBHESIOD
-TERMCAP_OBJ
-LIBS_TERMCAP
-BLESSMAIL_TARGET
-LIBS_MAIL
-liblockfile
-LIBXML2_LIBS
-LIBXML2_CFLAGS
-XINERAMA_LIBS
-XINERAMA_CFLAGS
-XRANDR_LIBS
-XRANDR_CFLAGS
-LIBXSM
-LIBGPM
-LIBGIF
-LIBTIFF
-LIBZ
-LIBPNG
-LIBJPEG
-LIBXPM
-M17N_FLT_LIBS
-M17N_FLT_CFLAGS
-LIBOTF_LIBS
-LIBOTF_CFLAGS
-FREETYPE_LIBS
-FREETYPE_CFLAGS
-XFT_LIBS
-XFT_CFLAGS
-FONTCONFIG_LIBS
-FONTCONFIG_CFLAGS
-LIBXMU
-LIBXTR6
-NOTIFY_OBJ
-GFILENOTIFY_LIBS
-GFILENOTIFY_CFLAGS
-LIBGNUTLS_LIBS
-LIBGNUTLS_CFLAGS
-LIBSELINUX_LIBS
-SETTINGS_LIBS
-SETTINGS_CFLAGS
-GOBJECT_LIBS
-GOBJECT_CFLAGS
-GCONF_LIBS
-GCONF_CFLAGS
-GSETTINGS_LIBS
-GSETTINGS_CFLAGS
-DBUS_OBJ
-DBUS_LIBS
-DBUS_CFLAGS
-GTK_OBJ
-GTK_LIBS
-GTK_CFLAGS
-IMAGEMAGICK_LIBS
-IMAGEMAGICK_CFLAGS
-RSVG_LIBS
-RSVG_CFLAGS
-LIB_PTHREAD
-VMLIMIT_OBJ
-GMALLOC_OBJ
-HAVE_XSERVER
-XARGS_LIMIT
-NTLIB
-LIB_WSOCK32
-LIBS_ECLIENT
-CM_OBJ
-NTDIR
-FIRSTFILE_OBJ
-W32_RES_LINK
-CLIENTW
-CLIENTRES
-UPDATE_MANIFEST
-EMACS_MANIFEST
-EMACSRES
-W32_LIBS
-W32_OBJ
-WINDRES
-NS_OBJC_OBJ
-NS_OBJ
-ns_self_contained
-INSTALL_ARCH_INDEP_EXTRA
-LIBS_GNUSTEP
-LD_SWITCH_X_SITE_RPATH
-XMKMF
-DEPFLAGS
-MKDEPDIR
-CFLAGS_SOUND
-ALSA_LIBS
-ALSA_CFLAGS
-LIBSOUND
-PKG_CONFIG
-LIB_MATH
-LIBS_SYSTEM
-C_SWITCH_SYSTEM
-UNEXEC_OBJ
-C_SWITCH_MACHINE
-LD_SWITCH_SYSTEM
-CANNOT_DUMP
-DOCMISC_W32
-INFO_OPTS
-INFO_EXT
-HAVE_MAKEINFO
-PAXCTL
-GZIP_PROG
-INSTALL_INFO
-LN_S_FILEONLY
-GNULIB_WARN_CFLAGS
-WERROR_CFLAGS
-WARN_CFLAGS
-RANLIB
-ARFLAGS
-AR
-EGREP
-GREP
-CPP
-BUILDING_FOR_WINDOWSNT_FALSE
-BUILDING_FOR_WINDOWSNT_TRUE
-am__fastdepCC_FALSE
-am__fastdepCC_TRUE
-CCDEPMODE
-AMDEPBACKSLASH
-AMDEP_FALSE
-AMDEP_TRUE
-am__quote
-am__include
-DEPDIR
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
-PROFILING_CFLAGS
-cache_file
-am__untar
-am__tar
-AMTAR
-am__leading_dot
-SET_MAKE
-AWK
-mkdir_p
-MKDIR_P
-INSTALL_STRIP_PROGRAM
-STRIP
-install_sh
-MAKEINFO
-AUTOHEADER
-AUTOMAKE
-AUTOCONF
-ACLOCAL
-VERSION
-PACKAGE
-CYGPATH_W
-am__isrc
-INSTALL_DATA
-INSTALL_SCRIPT
-INSTALL_PROGRAM
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files='deps_frag
-lisp_frag'
-ac_user_opts='
-enable_option_checking
-with_all
-with_pop
-with_kerberos
-with_kerberos5
-with_hesiod
-with_mmdf
-with_mail_unlink
-with_mailhost
-with_sound
-with_x_toolkit
-with_wide_int
-with_xpm
-with_jpeg
-with_tiff
-with_gif
-with_png
-with_rsvg
-with_xml2
-with_imagemagick
-with_xft
-with_libotf
-with_m17n_flt
-with_toolkit_scroll_bars
-with_xaw3d
-with_xim
-with_ns
-with_w32
-with_gpm
-with_dbus
-with_gconf
-with_gsettings
-with_selinux
-with_gnutls
-with_zlib
-with_file_notification
-with_makeinfo
-with_compress_install
-with_pkg_config_prog
-with_gameuser
-with_gnustep_conf
-enable_ns_self_contained
-enable_locallisppath
-enable_checking
-enable_check_lisp_object_type
-enable_profiling
-enable_autodepend
-enable_gtk_deprecation_warnings
-enable_dependency_tracking
-enable_largefile
-enable_gcc_warnings
-enable_link_time_optimization
-with_x
-enable_acl
-'
-      ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS
-CPP
-XMKMF'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval $ac_prev=\$ac_option
-    ac_prev=
-    continue
-  fi
-
-  case $ac_option in
-  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *)   ac_optarg=yes ;;
-  esac
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case $ac_dashdash$ac_option in
-  --)
-    ac_dashdash=yes ;;
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir=$ac_optarg ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build_alias ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build_alias=$ac_optarg ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file=$ac_optarg ;;
-
-  --config-cache | -C)
-    cache_file=config.cache ;;
-
-  -datadir | --datadir | --datadi | --datad)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=*)
-    datadir=$ac_optarg ;;
-
-  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
-  | --dataroo | --dataro | --datar)
-    ac_prev=datarootdir ;;
-  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
-  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
-    datarootdir=$ac_optarg ;;
-
-  -disable-* | --disable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
-        ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=no ;;
-
-  -docdir | --docdir | --docdi | --doc | --do)
-    ac_prev=docdir ;;
-  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
-    docdir=$ac_optarg ;;
-
-  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
-    ac_prev=dvidir ;;
-  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
-    dvidir=$ac_optarg ;;
-
-  -enable-* | --enable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
-        ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=\$ac_optarg ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix=$ac_optarg ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he | -h)
-    ac_init_help=long ;;
-  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
-    ac_init_help=recursive ;;
-  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
-    ac_init_help=short ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host_alias ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host_alias=$ac_optarg ;;
-
-  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
-    ac_prev=htmldir ;;
-  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
-  | --ht=*)
-    htmldir=$ac_optarg ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir=$ac_optarg ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir=$ac_optarg ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir=$ac_optarg ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir=$ac_optarg ;;
-
-  -localedir | --localedir | --localedi | --localed | --locale)
-    ac_prev=localedir ;;
-  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
-    localedir=$ac_optarg ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst | --locals)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
-    localstatedir=$ac_optarg ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir=$ac_optarg ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c | -n)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir=$ac_optarg ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix=$ac_optarg ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix=$ac_optarg ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix=$ac_optarg ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name=$ac_optarg ;;
-
-  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
-    ac_prev=pdfdir ;;
-  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
-    pdfdir=$ac_optarg ;;
-
-  -psdir | --psdir | --psdi | --psd | --ps)
-    ac_prev=psdir ;;
-  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
-    psdir=$ac_optarg ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir=$ac_optarg ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir=$ac_optarg ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site=$ac_optarg ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir=$ac_optarg ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir=$ac_optarg ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target_alias ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target_alias=$ac_optarg ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers | -V)
-    ac_init_version=: ;;
-
-  -with-* | --with-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
-        ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=\$ac_optarg ;;
-
-  -without-* | --without-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
-        ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=no ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes=$ac_optarg ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries=$ac_optarg ;;
-
-  -*) as_fn_error "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information."
-    ;;
-
-  *=*)
-    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
-    # Reject names that are not valid shell variable names.
-    case $ac_envvar in #(
-      '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
-    esac
-    eval $ac_envvar=\$ac_optarg
-    export $ac_envvar ;;
-
-  *)
-    # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
-  case $enable_option_checking in
-    no) ;;
-    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
-  esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
-               datadir sysconfdir sharedstatedir localstatedir includedir \
-               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
-do
-  eval ac_val=\$$ac_var
-  # Remove trailing slashes.
-  case $ac_val in
-    */ )
-      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
-      eval $ac_var=\$ac_val;;
-  esac
-  # Be sure to have absolute directory names.
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* )  continue;;
-    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
-  esac
-  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
-  if test "x$build_alias" = x; then
-    cross_compiling=maybe
-    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used." >&2
-  elif test "x$build_alias" != "x$host_alias"; then
-    cross_compiling=yes
-  fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error "pwd does not report name of working directory"
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then the parent directory.
-  ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$as_myself" : 'X\(//\)[^/]' \| \
-        X"$as_myself" : 'X\(//\)$' \| \
-        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-  srcdir=$ac_confdir
-  if test ! -r "$srcdir/$ac_unique_file"; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
-  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
-       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
-       pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
-  srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
-  eval ac_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_env_${ac_var}_value=\$${ac_var}
-  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
-  # Omit some internal or obsolete options to make the list less imposing.
-  # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<_ACEOF
-\`configure' configures emacs 24.3.50 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE.  See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
-  -h, --help              display this help and exit
-      --help=short        display options specific to this package
-      --help=recursive    display the short help of all the included packages
-  -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking...' messages
-      --cache-file=FILE   cache test results in FILE [disabled]
-  -C, --config-cache      alias for \`--cache-file=config.cache'
-  -n, --no-create         do not create output files
-      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
-
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR            user executables [EPREFIX/bin]
-  --sbindir=DIR           system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR        program executables [EPREFIX/libexec]
-  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --libdir=DIR            object code libraries [EPREFIX/lib]
-  --includedir=DIR        C header files [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
-  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR           info documentation [DATAROOTDIR/info]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
-  --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/emacs]
-  --htmldir=DIR           html documentation [DOCDIR]
-  --dvidir=DIR            dvi documentation [DOCDIR]
-  --pdfdir=DIR            pdf documentation [DOCDIR]
-  --psdir=DIR             ps documentation [DOCDIR]
-_ACEOF
-
-  cat <<\_ACEOF
-
-Program names:
-  --program-prefix=PREFIX            prepend PREFIX to installed program names
-  --program-suffix=SUFFIX            append SUFFIX to installed program names
-  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
-
-X features:
-  --x-includes=DIR    X include files are in DIR
-  --x-libraries=DIR   X library files are in DIR
-
-System types:
-  --build=BUILD     configure for building on BUILD [guessed]
-  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-  case $ac_init_help in
-     short | recursive ) echo "Configuration of emacs 24.3.50:";;
-   esac
-  cat <<\_ACEOF
-
-Optional Features:
-  --disable-option-checking  ignore unrecognized --enable/--with options
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --disable-ns-self-contained
-                          disable self contained build under NeXTstep
-  --enable-locallisppath=PATH
-                          directories Emacs should search for lisp files
-                          specific to this site
-  --enable-checking[=LIST]
-                          enable expensive run-time checks. With LIST, enable
-                          only specific categories of checks. Categories are:
-                          all,yes,no. Flags are: stringbytes, stringoverrun,
-                          stringfreelist, xmallocoverrun, conslist, glyphs
-  --enable-check-lisp-object-type
-                          enable compile time checks for the Lisp_Object data
-                          type. This is useful for development for catching
-                          certain types of bugs.
-  --enable-profiling      build emacs with low-level, gprof profiling support.
-                          Mainly useful for debugging Emacs itself. May not
-                          work on all platforms. Stops profiler.el working.
-  --enable-autodepend     automatically generate dependencies to .h-files.
-                          Requires GNU Make and Gcc. Enabled if GNU Make and
-                          Gcc is found
-  --enable-gtk-deprecation-warnings
-                          Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0
-  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors
-  --disable-largefile     omit support for large files
-  --enable-gcc-warnings   turn on lots of GCC warnings/errors. This is
-                          intended for developers, and may generate false
-                          alarms when used with older or non-GNU development
-                          tools.
-  --enable-link-time-optimization
-                          build emacs with link-time optimization. This is
-                          supported only for GCC since 4.5.0.
-  --disable-acl           do not support ACLs
-
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --without-all           omit almost all features and build small executable
-                          with minimal dependencies
-  --without-pop           don't support POP mail retrieval with movemail
-  --with-kerberos         support Kerberos-authenticated POP
-  --with-kerberos5        support Kerberos version 5 authenticated POP
-  --with-hesiod           support Hesiod to get the POP server host
-  --with-mmdf             support MMDF mailboxes
-  --with-mail-unlink      unlink, rather than empty, mail spool after reading
-  --with-mailhost=HOSTNAME
-                          string giving default POP mail host
-  --with-sound=VALUE      compile with sound support (VALUE one of: yes, alsa,
-                          oss, bsd-ossaudio, no; default yes). Only for
-                          GNU/Linux, FreeBSD, NetBSD, MinGW.
-  --with-x-toolkit=KIT    use an X toolkit (KIT one of: yes or gtk, gtk2,
-                          gtk3, lucid or athena, motif, no)
-  --with-wide-int         prefer wide Emacs integers (typically 62-bit)
-  --without-xpm           don't compile with XPM image support
-  --without-jpeg          don't compile with JPEG image support
-  --without-tiff          don't compile with TIFF image support
-  --without-gif           don't compile with GIF image support
-  --without-png           don't compile with PNG image support
-  --without-rsvg          don't compile with SVG image support
-  --without-xml2          don't compile with XML parsing support
-  --without-imagemagick   don't compile with ImageMagick image support
-  --without-xft           don't use XFT for anti aliased fonts
-  --without-libotf        don't use libotf for OpenType font support
-  --without-m17n-flt      don't use m17n-flt for text shaping
-  --without-toolkit-scroll-bars
-                          don't use Motif or Xaw3d scroll bars
-  --without-xaw3d         don't use Xaw3d
-  --without-xim           don't use X11 XIM
-  --with-ns               use NeXTstep (Cocoa or GNUstep) windowing system
-  --with-w32              use native MS Windows GUI in a Cygwin build
-  --without-gpm           don't use -lgpm for mouse support on a GNU/Linux
-                          console
-  --without-dbus          don't compile with D-Bus support
-  --without-gconf         don't compile with GConf support
-  --without-gsettings     don't compile with GSettings support
-  --without-selinux       don't compile with SELinux support
-  --without-gnutls        don't use -lgnutls for SSL/TLS support
-  --without-zlib          don't compile with zlib decompression support
-  --with-file-notification=LIB
-                          use a file notification library (LIB one of: yes,
-                          gfile, inotify, w32, no)
-  --without-makeinfo      don't require makeinfo for building manuals
-  --without-compress-install
-                          don't compress some files (.el, .info, etc.) when
-                          installing. Equivalent to: make GZIP_PROG= install
-  --with-pkg-config-prog=FILENAME
-                          file name of pkg-config for finding GTK and librsvg
-  --with-gameuser=USER    user for shared game score files
-  --with-gnustep-conf=FILENAME
-                          name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE,
-                          or /etc/GNUstep/GNUstep.conf
-  --with-x                use the X Window System
-
-Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
-  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-              nonstandard directory <lib dir>
-  LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-              you have headers in a nonstandard directory <include dir>
-  CPP         C preprocessor
-  XMKMF       Path to xmkmf, Makefile generator for X Window System
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to the package provider.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
-  # If there are subdirs, report their specific --help.
-  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d "$ac_dir" ||
-      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
-      continue
-    ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-    cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
-    if test -f "$ac_srcdir/configure.gnu"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
-    elif test -f "$ac_srcdir/configure"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure" --help=recursive
-    else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi || ac_status=$?
-    cd "$ac_pwd" || { ac_status=$?; break; }
-  done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
-  cat <<\_ACEOF
-emacs configure 24.3.50
-generated by GNU Autoconf 2.65
-
-Copyright (C) 2009 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
-  exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=1
-fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-
-# ac_fn_c_try_cpp LINENO
-# ----------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } >/dev/null && {
-        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_cpp
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
-  # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_header_compiler=yes
-else
-  ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  ac_header_preproc=yes
-else
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
-  yes:no: )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-  no:yes:* )
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-    ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_header_mongrel
-
-# ac_fn_c_try_run LINENO
-# ----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_c_try_run ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: program exited with status $ac_status" >&5
-       $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=$ac_status
-fi
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_run
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_header_compile
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-        test "$cross_compiling" = yes ||
-        $as_test_x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR
-# ------------------------------------
-# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
-$as_echo_n "checking whether $2 is declared... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $2
-  (void) $2;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_decl
-
-# ac_fn_c_check_header_preproc LINENO HEADER VAR
-# ----------------------------------------------
-# Tests whether HEADER is present, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_preproc ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f conftest.err conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_header_preproc
-
-# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
-# ----------------------------------------------------
-# Tries to find if the field MEMBER exists in type AGGR, after including
-# INCLUDES, setting cache variable VAR accordingly.
-ac_fn_c_check_member ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
-$as_echo_n "checking for $2.$3... " >&6; }
-if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$5
-int
-main ()
-{
-static $2 ac_aggr;
-if (ac_aggr.$3)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$4=yes"
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$5
-int
-main ()
-{
-static $2 ac_aggr;
-if (sizeof ac_aggr.$3)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$4=yes"
-else
-  eval "$4=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$4
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_member
-
-# ac_fn_c_check_func LINENO FUNC VAR
-# ----------------------------------
-# Tests whether FUNC exists, setting the cache variable VAR accordingly
-ac_fn_c_check_func ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $2 innocuous_$2
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $2 (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $2
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $2 ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_$2 || defined __stub___$2
-choke me
-#endif
-
-int
-main ()
-{
-return $2 ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_func
-
-# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
-# -------------------------------------------
-# Tests whether TYPE exists after having included INCLUDES, setting cache
-# variable VAR accordingly.
-ac_fn_c_check_type ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$3=no"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-if (sizeof ($2))
-        return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-if (sizeof (($2)))
-           return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  eval "$3=yes"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_type
-
-# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
-# --------------------------------------------
-# Tries to find the compile-time value of EXPR in a program that includes
-# INCLUDES, setting VAR accordingly. Returns whether the value could be
-# computed
-ac_fn_c_compute_int ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if test "$cross_compiling" = yes; then
-    # Depending upon the size, compute the lo and hi bounds.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=$ac_mid; break
-else
-  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
-                       if test $ac_lo -le $ac_mid; then
-                         ac_lo= ac_hi=
-                         break
-                       fi
-                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_lo=$ac_mid; break
-else
-  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
-                       if test $ac_mid -le $ac_hi; then
-                         ac_lo= ac_hi=
-                         break
-                       fi
-                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  ac_lo= ac_hi=
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=$ac_mid
-else
-  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in #((
-?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
-'') ac_retval=1 ;;
-esac
-  else
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-static long int longval () { return $2; }
-static unsigned long int ulongval () { return $2; }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    return 1;
-  if (($2) < 0)
-    {
-      long int i = longval ();
-      if (i != ($2))
-       return 1;
-      fprintf (f, "%ld", i);
-    }
-  else
-    {
-      unsigned long int i = ulongval ();
-      if (i != ($2))
-       return 1;
-      fprintf (f, "%lu", i);
-    }
-  /* Do not output a trailing newline, as this causes \r\n confusion
-     on some platforms.  */
-  return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
-else
-  ac_retval=1
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-rm -f conftest.val
-
-  fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_compute_int
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by emacs $as_me 24.3.50, which was
-generated by GNU Autoconf 2.65.  Invocation command line was
-
-  $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
-  done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
-  for ac_arg
-  do
-    case $ac_arg in
-    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-    | -silent | --silent | --silen | --sile | --sil)
-      continue ;;
-    *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    case $ac_pass in
-    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
-    2)
-      as_fn_append ac_configure_args1 " '$ac_arg'"
-      if test $ac_must_keep_next = true; then
-       ac_must_keep_next=false # Got value, back to normal.
-      else
-       case $ac_arg in
-         *=* | --config-cache | -C | -disable-* | --disable-* \
-         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
-         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
-         | -with-* | --with-* | -without-* | --without-* | --x)
-           case "$ac_configure_args0 " in
-             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
-           esac
-           ;;
-         -* ) ac_must_keep_next=true ;;
-       esac
-      fi
-      as_fn_append ac_configure_args " '$ac_arg'"
-      ;;
-    esac
-  done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log.  We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
-  # Save into config.log some information that might help in debugging.
-  {
-    echo
-
-    cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
-    echo
-    # The following way of writing the cache mishandles newlines in values,
-(
-  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-  (set) 2>&1 |
-    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      sed -n \
-       "s/'\''/'\''\\\\'\'''\''/g;
-         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
-      ;; #(
-    *)
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-)
-    echo
-
-    cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
-    echo
-    for ac_var in $ac_subst_vars
-    do
-      eval ac_val=\$$ac_var
-      case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-      esac
-      $as_echo "$ac_var='\''$ac_val'\''"
-    done | sort
-    echo
-
-    if test -n "$ac_subst_files"; then
-      cat <<\_ASBOX
-## ------------------- ##
-## File substitutions. ##
-## ------------------- ##
-_ASBOX
-      echo
-      for ac_var in $ac_subst_files
-      do
-       eval ac_val=\$$ac_var
-       case $ac_val in
-       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-       esac
-       $as_echo "$ac_var='\''$ac_val'\''"
-      done | sort
-      echo
-    fi
-
-    if test -s confdefs.h; then
-      cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
-      echo
-      cat confdefs.h
-      echo
-    fi
-    test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
-  } >&5
-  rm -f core *.core core.conftest.* &&
-    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
-    exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
-  ac_site_file1=$CONFIG_SITE
-elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
-else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
-    sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file"
-  fi
-done
-
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special files
-  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
-  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . "$cache_file";;
-      *)                      . "./$cache_file";;
-    esac
-  fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
-
-as_fn_append ac_header_list " sys/systeminfo.h"
-as_fn_append ac_header_list " coff.h"
-as_fn_append ac_header_list " pty.h"
-as_fn_append ac_header_list " sys/resource.h"
-as_fn_append ac_header_list " sys/utsname.h"
-as_fn_append ac_header_list " pwd.h"
-as_fn_append ac_header_list " utmp.h"
-as_fn_append ac_header_list " util.h"
-as_fn_append ac_header_list " sys/socket.h"
-as_fn_append ac_header_list " stdlib.h"
-as_fn_append ac_header_list " unistd.h"
-as_fn_append ac_header_list " sys/param.h"
-as_fn_append ac_header_list " pthread.h"
-as_fn_append ac_header_list " malloc/malloc.h"
-as_fn_append ac_header_list " maillock.h"
-as_fn_append ac_header_list " sys/un.h"
-as_fn_append ac_func_list " tzset"
-as_fn_append ac_func_list " readlinkat"
-as_fn_append ac_header_list " dirent.h"
-as_fn_append ac_header_list " execinfo.h"
-as_fn_append ac_func_list " faccessat"
-as_fn_append ac_func_list " fcntl"
-as_fn_append ac_func_list " fdopendir"
-as_fn_append ac_header_list " stdio_ext.h"
-as_fn_append ac_func_list " fstatat"
-as_fn_append ac_func_list " fsync"
-gl_getopt_required=GNU
-as_fn_append ac_header_list " getopt.h"
-as_fn_append ac_func_list " gettimeofday"
-as_fn_append ac_func_list " nanotime"
-as_fn_append ac_header_list " sys/time.h"
-as_fn_append ac_header_list " wchar.h"
-as_fn_append ac_header_list " stdint.h"
-as_fn_append ac_header_list " inttypes.h"
-as_fn_append ac_func_list " lstat"
-as_fn_append ac_func_list " mkostemp"
-as_fn_append ac_func_list " pipe2"
-as_fn_append ac_header_list " sys/select.h"
-as_fn_append ac_func_list " pselect"
-as_fn_append ac_func_list " pthread_sigmask"
-as_fn_append ac_func_list " readlink"
-as_fn_append ac_func_list " strtoimax"
-as_fn_append ac_func_list " strtoumax"
-as_fn_append ac_func_list " symlink"
-as_fn_append ac_header_list " sys/stat.h"
-as_fn_append ac_func_list " localtime_r"
-as_fn_append ac_header_list " utime.h"
-as_fn_append ac_func_list " futimes"
-as_fn_append ac_func_list " futimesat"
-as_fn_append ac_func_list " futimens"
-as_fn_append ac_func_list " utimensat"
-as_fn_append ac_func_list " lutimes"
-as_fn_append ac_func_list " getdtablesize"
-as_fn_append ac_func_list " secure_getenv"
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
-  eval ac_old_set=\$ac_cv_env_${ac_var}_set
-  eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val=\$ac_cv_env_${ac_var}_value
-  eval ac_new_val=\$ac_env_${ac_var}_value
-  case $ac_old_set,$ac_new_set in
-    set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,);;
-    *)
-      if test "x$ac_old_val" != "x$ac_new_val"; then
-       # differences in whitespace do not lead to failure.
-       ac_old_val_w=`echo x $ac_old_val`
-       ac_new_val_w=`echo x $ac_new_val`
-       if test "$ac_old_val_w" != "$ac_new_val_w"; then
-         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-         ac_cache_corrupted=:
-       else
-         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
-         eval $ac_var=\$ac_old_val
-       fi
-       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
-      fi;;
-  esac
-  # Pass precious variables to config.status.
-  if test "$ac_new_set" = set; then
-    case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
-    *) ac_arg=$ac_var=$ac_new_val ;;
-    esac
-    case " $ac_configure_args " in
-      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
-    esac
-  fi
-done
-if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-emacs_config_options=
-optsep=
-for opt in ${1+"$@"} CFLAGS CPPFLAGS LDFLAGS; do
-  case $opt in
-    -n | --no-create | --no-recursion)
-      continue ;;
-    CFLAGS | CPPFLAGS | LDFLAGS)
-      eval 'test "${'$opt'+set}" = set' || continue
-      case " $*" in
-       *" $opt="*) continue ;;
-      esac
-      eval opt=$opt=\$$opt ;;
-  esac
-
-  emacs_shell_specials=$IFS\''"#$&()*;<>?[\\`{|~'
-  case $opt in
-    *["$emacs_shell_specials"]*)
-      case $opt in
-       *\'*)
-         emacs_quote_apostrophes="s/'/'\\\\''/g"
-         opt=`$as_echo "$opt" | sed "$emacs_quote_apostrophes"` ;;
-      esac
-      opt="'$opt'"
-      case $opt in
-       *['"\\']*)
-         emacs_quote_for_c='s/["\\]/\\&/g; $!s/$/\\n\\/'
-         opt=`$as_echo "$opt" | sed "$emacs_quote_for_c"` ;;
-      esac ;;
-  esac
-  as_fn_append emacs_config_options "$optsep$opt"
-  optsep=' '
-done
-
-ac_config_headers="$ac_config_headers src/config.h:src/config.in"
-
-
-ac_aux_dir=
-for ac_dir in build-aux "$srcdir"/build-aux; do
-  for ac_t in install-sh install.sh shtool; do
-    if test -f "$ac_dir/$ac_t"; then
-      ac_aux_dir=$ac_dir
-      ac_install_sh="$ac_aux_dir/$ac_t -c"
-      break 2
-    fi
-  done
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-
-
-am__api_version='1.11'
-
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
-  ./ | .// | /[cC]/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # by default.
-    for ac_prog in ginstall scoinst install; do
-      for ac_exec_ext in '' $ac_executable_extensions; do
-       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
-         if test $ac_prog = install &&
-           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-           # AIX install.  It has an incompatible calling convention.
-           :
-         elif test $ac_prog = install &&
-           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-           # program-specific install script used by HP pwplus--don't use.
-           :
-         else
-           rm -rf conftest.one conftest.two conftest.dir
-           echo one > conftest.one
-           echo two > conftest.two
-           mkdir conftest.dir
-           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
-             test -s conftest.one && test -s conftest.two &&
-             test -s conftest.dir/conftest.one &&
-             test -s conftest.dir/conftest.two
-           then
-             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-             break 3
-           fi
-         fi
-       fi
-      done
-    done
-    ;;
-esac
-
-  done
-IFS=$as_save_IFS
-
-rm -rf conftest.one conftest.two conftest.dir
-
-fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    INSTALL=$ac_install_sh
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
-$as_echo_n "checking whether build environment is sane... " >&6; }
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Reject unsafe characters in $srcdir or the absolute working directory
-# name.  Accept space and tab only in the latter.
-am_lf='
-'
-case `pwd` in
-  *[\\\"\#\$\&\'\`$am_lf]*)
-    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
-esac
-case $srcdir in
-  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
-    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
-esac
-
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments.  Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$*" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$*" != "X $srcdir/configure conftest.file" \
-      && test "$*" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
-alias in your environment" "$LINENO" 5
-   fi
-
-   test "$2" = conftest.file
-   )
-then
-   # Ok.
-   :
-else
-   as_fn_error "newly created file is older than distributed files!
-Check your system clock" "$LINENO" 5
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-test "$program_prefix" != NONE &&
-  program_transform_name="s&^&$program_prefix&;$program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
-  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
-# Double any \ or $.
-# By default was `s,x,x', remove it if useless.
-ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
-program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
-
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-
-if test x"${MISSING+set}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\    *)
-    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
-  *)
-    MISSING="\${SHELL} $am_aux_dir/missing" ;;
-  esac
-fi
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
-else
-  am_missing_run=
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
-$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
-fi
-
-if test x"${install_sh}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\    *)
-    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
-  *)
-    install_sh="\${SHELL} $am_aux_dir/install-sh"
-  esac
-fi
-
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-if test "$cross_compiling" != no; then
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_STRIP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
-$as_echo "$STRIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
-$as_echo "$ac_ct_STRIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_STRIP" = x; then
-    STRIP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    STRIP=$ac_ct_STRIP
-  fi
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
-
-fi
-INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
-$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
-if test -z "$MKDIR_P"; then
-  if test "${ac_cv_path_mkdir+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in mkdir gmkdir; do
-        for ac_exec_ext in '' $ac_executable_extensions; do
-          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
-          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
-            'mkdir (GNU coreutils) '* | \
-            'mkdir (coreutils) '* | \
-            'mkdir (fileutils) '4.1*)
-              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
-              break 3;;
-          esac
-        done
-       done
-  done
-IFS=$as_save_IFS
-
-fi
-
-  test -d ./--version && rmdir ./--version
-  if test "${ac_cv_path_mkdir+set}" = set; then
-    MKDIR_P="$ac_cv_path_mkdir -p"
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for MKDIR_P within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    MKDIR_P="$ac_install_sh -d"
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
-$as_echo "$MKDIR_P" >&6; }
-
-mkdir_p="$MKDIR_P"
-case $mkdir_p in
-  [\\/$]* | ?:[\\/]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-
-for ac_prog in gawk mawk nawk awk
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_AWK+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AWK"; then
-  ac_cv_prog_AWK="$AWK" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AWK="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-AWK=$ac_cv_prog_AWK
-if test -n "$AWK"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
-$as_echo "$AWK" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$AWK" && break
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
-set x ${MAKE-make}
-ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.make <<\_ACEOF
-SHELL = /bin/sh
-all:
-       @echo '@@@%%%=$(MAKE)=@@@%%%'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-case `${MAKE-make} -f conftest.make 2>/dev/null` in
-  *@@@%%%=?*=@@@%%%*)
-    eval ac_cv_prog_make_${ac_make}_set=yes;;
-  *)
-    eval ac_cv_prog_make_${ac_make}_set=no;;
-esac
-rm -f conftest.make
-fi
-if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-  SET_MAKE=
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-  SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
-  am__leading_dot=.
-else
-  am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-
-if test "`cd $srcdir && pwd`" != "`pwd`"; then
-  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
-  # is not polluted with repeated "-I."
-  am__isrc=' -I$(srcdir)'
-  # test to see if srcdir already configured
-  if test -f $srcdir/config.status; then
-    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
-  fi
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
-  if (cygpath --version) >/dev/null 2>/dev/null; then
-    CYGPATH_W='cygpath -w'
-  else
-    CYGPATH_W=echo
-  fi
-fi
-
-
-# Define the identity of the package.
- PACKAGE='emacs'
- VERSION='24.3.50'
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
-
-# Some tools Automake needs.
-
-ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
-
-
-AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
-
-
-AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
-
-
-AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
-
-
-MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
-
-# We need awk for the "check" target.  The system "awk" is bad on
-# some platforms.
-# Always define AMTAR for backward compatibility.
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
-
-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
-
-
-
-
-
-
-
-
-lispdir='${datadir}/emacs/${version}/lisp'
-leimdir='${datadir}/emacs/${version}/leim'
-standardlisppath='${lispdir}:${leimdir}'
-locallisppath='${datadir}/emacs/${version}/site-lisp:'\
-'${datadir}/emacs/site-lisp'
-lisppath='${locallisppath}:${standardlisppath}'
-etcdir='${datadir}/emacs/${version}/etc'
-archlibdir='${libexecdir}/emacs/${version}/${configuration}'
-etcdocdir='${datadir}/emacs/${version}/etc'
-gamedir='${localstatedir}/games/emacs'
-
-
-# Check whether --with-all was given.
-if test "${with_all+set}" = set; then :
-  withval=$with_all; with_features=$withval
-else
-  with_features=yes
-fi
-
-
-
-
-
-# Check whether --with-pop was given.
-if test "${with_pop+set}" = set; then :
-  withval=$with_pop;
-else
-     with_pop=$with_features
-fi
-
-if test "$with_pop" = yes; then
-   $as_echo "#define MAIL_USE_POP 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-kerberos was given.
-if test "${with_kerberos+set}" = set; then :
-  withval=$with_kerberos;
-else
-      with_kerberos=no
-fi
-
-if test "$with_kerberos" != no; then
-   $as_echo "#define KERBEROS 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-kerberos5 was given.
-if test "${with_kerberos5+set}" = set; then :
-  withval=$with_kerberos5;
-else
-      with_kerberos5=no
-fi
-
-if test "${with_kerberos5}" != no; then
-  if test "${with_kerberos}" = no; then
-    with_kerberos=yes
-    $as_echo "#define KERBEROS 1" >>confdefs.h
-
-  fi
-
-$as_echo "#define KERBEROS5 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-hesiod was given.
-if test "${with_hesiod+set}" = set; then :
-  withval=$with_hesiod;
-else
-      with_hesiod=no
-fi
-
-if test "$with_hesiod" != no; then
-
-$as_echo "#define HESIOD 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-mmdf was given.
-if test "${with_mmdf+set}" = set; then :
-  withval=$with_mmdf;
-else
-      with_mmdf=no
-fi
-
-if test "$with_mmdf" != no; then
-
-$as_echo "#define MAIL_USE_MMDF 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-mail-unlink was given.
-if test "${with_mail_unlink+set}" = set; then :
-  withval=$with_mail_unlink;
-else
-      with_mail_unlink=no
-fi
-
-if test "$with_mail_unlink" != no; then
-
-$as_echo "#define MAIL_UNLINK_SPOOL 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-mailhost was given.
-if test "${with_mailhost+set}" = set; then :
-  withval=$with_mailhost;
-cat >>confdefs.h <<_ACEOF
-#define MAILHOST "$withval"
-_ACEOF
-
-fi
-
-
-
-# Check whether --with-sound was given.
-if test "${with_sound+set}" = set; then :
-  withval=$with_sound;  case "${withval}" in
-      yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
-      *) as_fn_error "\`--with-sound=$withval' is invalid;
-this option's value should be \`yes', \`no', \`alsa', \`oss', or \`bsd-ossaudio'." "$LINENO" 5
-      ;;
-    esac
-    with_sound=$val
-
-else
-  with_sound=$with_features
-fi
-
-
-
-# Check whether --with-x-toolkit was given.
-if test "${with_x_toolkit+set}" = set; then :
-  withval=$with_x_toolkit;       case "${withval}" in
-           y | ye | yes )      val=gtk ;;
-           n | no )            val=no  ;;
-           l | lu | luc | luci | lucid )       val=lucid ;;
-           a | at | ath | athe | athen | athena )      val=athena ;;
-           m | mo | mot | moti | motif )       val=motif ;;
-           g | gt | gtk  )     val=gtk ;;
-           gtk2  )     val=gtk2 ;;
-           gtk3  )     val=gtk3 ;;
-           * )
-as_fn_error "\`--with-x-toolkit=$withval' is invalid;
-this option's value should be \`yes', \`no', \`lucid', \`athena', \`motif', \`gtk',
-\`gtk2' or \`gtk3'.  \`yes' and \`gtk' are synonyms.
-\`athena' and \`lucid' are synonyms." "$LINENO" 5
-           ;;
-         esac
-         with_x_toolkit=$val
-
-fi
-
-
-
-# Check whether --with-wide-int was given.
-if test "${with_wide_int+set}" = set; then :
-  withval=$with_wide_int;
-else
-      with_wide_int=no
-fi
-
-if test "$with_wide_int" = yes; then
-
-$as_echo "#define WIDE_EMACS_INT 1" >>confdefs.h
-
-fi
-
-
-# Check whether --with-xpm was given.
-if test "${with_xpm+set}" = set; then :
-  withval=$with_xpm;
-else
-     with_xpm=$with_features
-fi
-
-
-# Check whether --with-jpeg was given.
-if test "${with_jpeg+set}" = set; then :
-  withval=$with_jpeg;
-else
-     with_jpeg=$with_features
-fi
-
-
-# Check whether --with-tiff was given.
-if test "${with_tiff+set}" = set; then :
-  withval=$with_tiff;
-else
-     with_tiff=$with_features
-fi
-
-
-# Check whether --with-gif was given.
-if test "${with_gif+set}" = set; then :
-  withval=$with_gif;
-else
-     with_gif=$with_features
-fi
-
-
-# Check whether --with-png was given.
-if test "${with_png+set}" = set; then :
-  withval=$with_png;
-else
-     with_png=$with_features
-fi
-
-
-# Check whether --with-rsvg was given.
-if test "${with_rsvg+set}" = set; then :
-  withval=$with_rsvg;
-else
-     with_rsvg=$with_features
-fi
-
-
-# Check whether --with-xml2 was given.
-if test "${with_xml2+set}" = set; then :
-  withval=$with_xml2;
-else
-     with_xml2=$with_features
-fi
-
-
-# Check whether --with-imagemagick was given.
-if test "${with_imagemagick+set}" = set; then :
-  withval=$with_imagemagick;
-else
-     with_imagemagick=$with_features
-fi
-
-
-
-# Check whether --with-xft was given.
-if test "${with_xft+set}" = set; then :
-  withval=$with_xft;
-else
-     with_xft=$with_features
-fi
-
-
-# Check whether --with-libotf was given.
-if test "${with_libotf+set}" = set; then :
-  withval=$with_libotf;
-else
-     with_libotf=$with_features
-fi
-
-
-# Check whether --with-m17n-flt was given.
-if test "${with_m17n_flt+set}" = set; then :
-  withval=$with_m17n_flt;
-else
-     with_m17n_flt=$with_features
-fi
-
-
-
-# Check whether --with-toolkit-scroll-bars was given.
-if test "${with_toolkit_scroll_bars+set}" = set; then :
-  withval=$with_toolkit_scroll_bars;
-else
-     with_toolkit_scroll_bars=$with_features
-fi
-
-
-# Check whether --with-xaw3d was given.
-if test "${with_xaw3d+set}" = set; then :
-  withval=$with_xaw3d;
-else
-     with_xaw3d=$with_features
-fi
-
-
-# Check whether --with-xim was given.
-if test "${with_xim+set}" = set; then :
-  withval=$with_xim;
-else
-     with_xim=$with_features
-fi
-
-
-# Check whether --with-ns was given.
-if test "${with_ns+set}" = set; then :
-  withval=$with_ns;
-else
-      with_ns=no
-fi
-
-
-# Check whether --with-w32 was given.
-if test "${with_w32+set}" = set; then :
-  withval=$with_w32;
-else
-      with_w32=no
-fi
-
-
-
-# Check whether --with-gpm was given.
-if test "${with_gpm+set}" = set; then :
-  withval=$with_gpm;
-else
-     with_gpm=$with_features
-fi
-
-
-# Check whether --with-dbus was given.
-if test "${with_dbus+set}" = set; then :
-  withval=$with_dbus;
-else
-     with_dbus=$with_features
-fi
-
-
-# Check whether --with-gconf was given.
-if test "${with_gconf+set}" = set; then :
-  withval=$with_gconf;
-else
-     with_gconf=$with_features
-fi
-
-
-# Check whether --with-gsettings was given.
-if test "${with_gsettings+set}" = set; then :
-  withval=$with_gsettings;
-else
-     with_gsettings=$with_features
-fi
-
-
-# Check whether --with-selinux was given.
-if test "${with_selinux+set}" = set; then :
-  withval=$with_selinux;
-else
-     with_selinux=$with_features
-fi
-
-
-# Check whether --with-gnutls was given.
-if test "${with_gnutls+set}" = set; then :
-  withval=$with_gnutls;
-else
-     with_gnutls=$with_features
-fi
-
-
-# Check whether --with-zlib was given.
-if test "${with_zlib+set}" = set; then :
-  withval=$with_zlib;
-else
-     with_zlib=$with_features
-fi
-
-
-
-# Check whether --with-file-notification was given.
-if test "${with_file_notification+set}" = set; then :
-  withval=$with_file_notification;  case "${withval}" in
-    y | ye | yes )     val=yes ;;
-    n | no )           val=no  ;;
-    g | gf | gfi | gfil | gfile )      val=gfile ;;
-    i | in | ino | inot | inoti | inotif | inotify )   val=inotify ;;
-    w | w3 | w32 )     val=w32 ;;
-    * ) as_fn_error "\`--with-file-notification=$withval' is invalid;
-this option's value should be \`yes', \`no', \`gfile', \`inotify' or \`w32'.
-\`yes' is a synonym for \`w32' on MS-Windows, for \`no' on Nextstep,
-otherwise for the first of \`gfile' or \`inotify' that is usable." "$LINENO" 5
-    ;;
-   esac
-   with_file_notification=$val
-
-else
-  with_file_notification=$with_features
-fi
-
-
-## For the times when you want to build Emacs but don't have
-## a suitable makeinfo, and can live without the manuals.
-
-# Check whether --with-makeinfo was given.
-if test "${with_makeinfo+set}" = set; then :
-  withval=$with_makeinfo;
-else
-     with_makeinfo=$with_features
-fi
-
-
-## Makefile.in needs the cache file name.
-
-
-## This is an option because I do not know if all info/man support
-## compressed files, nor how to test if they do so.
-
-# Check whether --with-compress-install was given.
-if test "${with_compress_install+set}" = set; then :
-  withval=$with_compress_install;
-else
-     with_compress_install=$with_features
-fi
-
-
-
-# Check whether --with-pkg-config-prog was given.
-if test "${with_pkg_config_prog+set}" = set; then :
-  withval=$with_pkg_config_prog;
-fi
-
-if test "X${with_pkg_config_prog}" != X; then
-   if test "${with_pkg_config_prog}" != yes; then
-      PKG_CONFIG="${with_pkg_config_prog}"
-   fi
-fi
-
-
-# Check whether --with-gameuser was given.
-if test "${with_gameuser+set}" = set; then :
-  withval=$with_gameuser;
-fi
-
-test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
-  && gameuser="${with_gameuser}"
-test "X$gameuser" = X && gameuser=games
-
-
-# Check whether --with-gnustep-conf was given.
-if test "${with_gnustep_conf+set}" = set; then :
-  withval=$with_gnustep_conf;
-fi
-
-test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
-  GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
-test "X$GNUSTEP_CONFIG_FILE" = "X" && \
-     GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
-
-# Check whether --enable-ns-self-contained was given.
-if test "${enable_ns_self_contained+set}" = set; then :
-  enableval=$enable_ns_self_contained; EN_NS_SELF_CONTAINED=$enableval
-else
-  EN_NS_SELF_CONTAINED=yes
-fi
-
-
-# Check whether --enable-locallisppath was given.
-if test "${enable_locallisppath+set}" = set; then :
-  enableval=$enable_locallisppath; if test "${enableval}" = "no"; then
-  locallisppath=
-elif test "${enableval}" != "yes"; then
-  locallisppath=${enableval}
-fi
-fi
-
-
-# Check whether --enable-checking was given.
-if test "${enable_checking+set}" = set; then :
-  enableval=$enable_checking; ac_checking_flags="${enableval}"
-fi
-
-IFS="${IFS=    }"; ac_save_IFS="$IFS"; IFS="$IFS,"
-for check in $ac_checking_flags
-do
-       case $check in
-       # these set all the flags to specific states
-       yes)            ac_enable_checking=1 ;;
-       no)             ac_enable_checking= ;
-                       ac_gc_check_stringbytes= ;
-                       ac_gc_check_string_overrun= ;
-                       ac_gc_check_string_free_list= ;
-                       ac_xmalloc_overrun= ;
-                       ac_gc_check_cons_list= ;
-                       ac_glyphs_debug= ;;
-       all)            ac_enable_checking=1 ;
-                       ac_gc_check_stringbytes=1 ;
-                       ac_gc_check_string_overrun=1 ;
-                       ac_gc_check_string_free_list=1 ;
-                       ac_xmalloc_overrun=1 ;
-                       ac_gc_check_cons_list=1 ;
-                       ac_glyphs_debug=1 ;;
-       # these enable particular checks
-       stringbytes)    ac_gc_check_stringbytes=1 ;;
-       stringoverrun)  ac_gc_check_string_overrun=1 ;;
-       stringfreelist) ac_gc_check_string_free_list=1 ;;
-       xmallocoverrun) ac_xmalloc_overrun=1 ;;
-       conslist)       ac_gc_check_cons_list=1 ;;
-       glyphs)         ac_glyphs_debug=1 ;;
-       *)      as_fn_error "unknown check category $check" "$LINENO" 5 ;;
-       esac
-done
-IFS="$ac_save_IFS"
-
-if test x$ac_enable_checking != x ; then
-
-$as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
-
-fi
-if test x$ac_gc_check_stringbytes != x ; then
-
-$as_echo "#define GC_CHECK_STRING_BYTES 1" >>confdefs.h
-
-fi
-if test x$ac_gc_check_string_overrun != x ; then
-
-$as_echo "#define GC_CHECK_STRING_OVERRUN 1" >>confdefs.h
-
-fi
-if test x$ac_gc_check_string_free_list != x ; then
-
-$as_echo "#define GC_CHECK_STRING_FREE_LIST 1" >>confdefs.h
-
-fi
-if test x$ac_xmalloc_overrun != x ; then
-
-$as_echo "#define XMALLOC_OVERRUN_CHECK 1" >>confdefs.h
-
-fi
-if test x$ac_gc_check_cons_list != x ; then
-
-$as_echo "#define GC_CHECK_CONS_LIST 1" >>confdefs.h
-
-fi
-if test x$ac_glyphs_debug != x ; then
-
-$as_echo "#define GLYPH_DEBUG 1" >>confdefs.h
-
-fi
-
-# Check whether --enable-check-lisp-object-type was given.
-if test "${enable_check_lisp_object_type+set}" = set; then :
-  enableval=$enable_check_lisp_object_type; if test "${enableval}" != "no"; then
-
-$as_echo "#define CHECK_LISP_OBJECT_TYPE 1" >>confdefs.h
-
-fi
-fi
-
-
-
-# Check whether --enable-profiling was given.
-if test "${enable_profiling+set}" = set; then :
-  enableval=$enable_profiling; ac_enable_profiling="${enableval}"
-fi
-
-if test x$ac_enable_profiling != x ; then
-   PROFILING_CFLAGS="-DPROFILING=1 -pg"
-else
-   PROFILING_CFLAGS=
-fi
-
-
-# Check whether --enable-autodepend was given.
-if test "${enable_autodepend+set}" = set; then :
-  enableval=$enable_autodepend; ac_enable_autodepend="${enableval}"
-else
-  ac_enable_autodepend=yes
-fi
-
-
-# Check whether --enable-gtk-deprecation-warnings was given.
-if test "${enable_gtk_deprecation_warnings+set}" = set; then :
-  enableval=$enable_gtk_deprecation_warnings; ac_enable_gtk_deprecation_warnings="${enableval}"
-fi
-
-
-#### Make srcdir absolute, if it isn't already.  It's important to
-#### avoid running the file name through pwd unnecessarily, since pwd can
-#### give you automounter prefixes, which can go away.  We do all this
-#### so Emacs can find its files when run uninstalled.
-## Make sure CDPATH doesn't affect cd (in case PWD is relative).
-unset CDPATH
-case "${srcdir}" in
-  [\\/]* | ?:[\\/]*) ;;
-  . )
-    ## We may be able to use the $PWD environment variable to make this
-    ## absolute.  But sometimes PWD is inaccurate.
-    ## Note: we used to use $PWD at the end instead of `pwd`,
-    ## but that tested only for a well-formed and valid PWD,
-    ## it did not object when PWD was well-formed and valid but just wrong.
-    if test ".$PWD" != "." && test ".`(cd "$PWD" ; sh -c pwd)`" = ".`pwd`"  ;
-    then
-      srcdir="$PWD"
-    else
-      srcdir=`(cd "$srcdir"; pwd)`
-    fi
-  ;;
-  *  ) srcdir=`(cd "$srcdir"; pwd)` ;;
-esac
-
-#### When building with MinGW inside the MSYS tree, 'pwd' produces
-#### directories relative to the root of the MSYS tree,
-#### e.g. '/home/user/foo' instead of '/d/MSYS/home/user/foo'.  When
-#### such a value of srcdir is written to the top-level Makefile, it
-#### gets propagated to src/epaths.h, and that causes temacs to fail,
-#### because, being a MinGW program that knows nothing of MSYS root
-#### substitution, it cannot find the data directory.  "pwd -W"
-#### produces Windows-style 'd:/foo/bar' absolute directory names, so
-#### we use it here to countermand that lossage.
-test "$MSYSTEM" = "MINGW32" && srcdir=`(cd "$srcdir"; pwd -W | sed -e 's,^\([A-Za-z]\):,/\1,')`
-
-### Canonicalize the configuration name.
-
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if test "${ac_cv_build+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if test "${ac_cv_host+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
-else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-canonical=$host
-configuration=${host_alias-${build_alias-$host}}
-
-
-
-### If you add support for a new configuration, add code to this
-### switch statement to recognize your configuration name and select
-### the appropriate operating system file.
-
-### You would hope that you could choose an s/*.h
-### file based on the operating system portion.  However, it turns out
-### that each s/*.h file is pretty manufacturer-specific.
-### So we basically have to have a special case for each
-### configuration name.
-###
-### As far as handling version numbers on operating systems is
-### concerned, make sure things will fail in a fixable way.  If
-### /etc/MACHINES doesn't say anything about version numbers, be
-### prepared to handle anything reasonably.  If version numbers
-### matter, be sure /etc/MACHINES says something about it.
-
-opsys='' unported=no
-case "${canonical}" in
-
-  ## GNU/Linux and similar ports
-  *-*-linux* )
-    opsys=gnu-linux
-  ;;
-
-  ## FreeBSD ports
-  *-*-freebsd* )
-    opsys=freebsd
-  ;;
-
-  ## DragonFly ports
-  *-*-dragonfly* )
-    opsys=dragonfly
-  ;;
-
-  ## FreeBSD kernel + glibc based userland
-  *-*-kfreebsd*gnu* )
-    opsys=gnu-kfreebsd
-  ;;
-
-  ## NetBSD ports
-  *-*-netbsd* )
-    opsys=netbsd
-  ;;
-
-  ## OpenBSD ports
-  *-*-openbsd* )
-    opsys=openbsd
-  ;;
-
-  ## Apple Darwin / Mac OS X
-  *-apple-darwin* )
-    case "${canonical}" in
-      i[3456]86-* )  ;;
-      powerpc-* )    ;;
-      x86_64-* )     ;;
-      * )            unported=yes ;;
-    esac
-    opsys=darwin
-    ## Use fink packages if available.
-    ## FIXME find a better way to do this: http://debbugs.gnu.org/11507
-##    if test -d /sw/include && test -d /sw/lib; then
-##      GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
-##      NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
-##    fi
-  ;;
-
-  ## Cygwin ports
-  *-*-cygwin )
-    opsys=cygwin
-  ;;
-
-  ## HP 9000 series 700 and 800, running HP/UX
-  hppa*-hp-hpux10.2* )
-    opsys=hpux10-20
-  ;;
-  hppa*-hp-hpux1[1-9]* )
-    opsys=hpux11
-    CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
-  ;;
-
-  ## IBM machines
-  rs6000-ibm-aix4.[23]* )
-    opsys=aix4-2
-  ;;
-  powerpc-ibm-aix4.[23]*  )
-    opsys=aix4-2
-  ;;
-  rs6000-ibm-aix[56]* )
-    opsys=aix4-2
-  ;;
-  powerpc-ibm-aix[56]*  )
-    opsys=aix4-2
-  ;;
-
-  ## Silicon Graphics machines
-  ## Iris 4D
-  mips-sgi-irix6.5 )
-    opsys=irix6-5
-    # Without defining _LANGUAGE_C, things get masked out in the headers
-    # so that, for instance, grepping for `free' in stdlib.h fails and
-    # AC_HEADER_STD_C fails.   (MIPSPro 7.2.1.2m compilers, Irix 6.5.3m).
-    NON_GCC_TEST_OPTIONS="-D_LANGUAGE_C"
-  ;;
-
-  ## Suns
-  *-sun-solaris* \
-    | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
-    | x86_64-*-solaris2*    | x86_64-*-sunos5*)
-    case "${canonical}" in
-      i[3456]86-*-* )   ;;
-      amd64-*-*|x86_64-*-*) ;;
-      sparc* )         ;;
-      * )              unported=yes ;;
-    esac
-    case "${canonical}" in
-      *-sunos5.6* | *-solaris2.6* )
-               opsys=sol2-6
-               RANLIB="ar -ts"
-               ;;
-      *-sunos5.[7-9]* | *-solaris2.[7-9]* )
-               opsys=sol2-6
-               emacs_check_sunpro_c=yes
-               ;;
-      *-sunos5* | *-solaris* )
-               opsys=sol2-10
-               emacs_check_sunpro_c=yes
-               ;;
-    esac
-    ## Watch out for a compiler that we know will not work.
-    case "${canonical}" in
-     *-solaris* | *-sunos5* )
-               if [ "x$CC" = x/usr/ucb/cc ]; then
-                 ## /usr/ucb/cc doesn't work;
-                 ## we should find some other compiler that does work.
-                 unset CC
-               fi
-               ;;
-      *) ;;
-    esac
-  ;;
-
-  ## Intel 386 machines where we don't care about the manufacturer.
-  i[3456]86-*-* )
-    case "${canonical}" in
-      *-darwin* )               opsys=darwin ;;
-      *-mingw32 )
-               opsys=mingw32
-               # MinGW overrides and adds some system headers in nt/inc.
-               GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
-               ;;
-      *-sysv4.2uw* )           opsys=unixware ;;
-      *-sysv5uw* )             opsys=unixware ;;
-      *-sysv5OpenUNIX* )       opsys=unixware ;;
-      ## Otherwise, we'll fall through to the generic opsys code at the bottom.
-    esac
-  ;;
-
-  * )
-    unported=yes
-  ;;
-esac
-
-### If the code above didn't choose an operating system, just choose
-### an operating system based on the configuration name.  You really
-### only want to use this when you have no idea what the right
-### operating system is; if you know what operating systems a machine
-### runs, it's cleaner to make it explicit in the case statement
-### above.
-if test x"${opsys}" = x; then
-  case "${canonical}" in
-    *-gnu* )                           opsys=gnu ;;
-    * )
-      unported=yes
-    ;;
-  esac
-fi
-
-
-
-if test $unported = yes; then
-  as_fn_error "Emacs hasn't been ported to \`${canonical}' systems.
-Check \`etc/MACHINES' for recognized configuration names." "$LINENO" 5
-fi
-
-
-#### Choose a compiler.
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
-          if test -n "$ac_tool_prefix"; then
-    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  fi
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl.exe
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$CC" && break
-  done
-fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl.exe
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_CC" && break
-done
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "no acceptable C compiler found in \$PATH
-See \`config.log' for more details." "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
-  esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link_default") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile.  We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
-       ;;
-    [ab].out )
-       # We found the default executable, but exeext='' is most
-       # certainly right.
-       break;;
-    *.* )
-       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-       then :; else
-          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-       fi
-       # We set ac_cv_exeext here because the later test for it is not
-       # safe: cross compilers may not add the suffix if given an `-o'
-       # argument, so we may need to know it at that point already.
-       # Even if this section looks crufty: it has the advantage of
-       # actually working.
-       break;;
-    * )
-       break;;
-  esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
-  ac_file=''
-fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ as_fn_set_status 77
-as_fn_error "C compiler cannot create executables
-See \`config.log' for more details." "$LINENO" 5; }; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-         break;;
-    * ) break;;
-  esac
-done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-       cross_compiling=yes
-    else
-       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if test "${ac_cv_objext+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  for ac_file in conftest.o conftest.obj conftest.*; do
-  test -f "$ac_file" || continue;
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
-done
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GCC=yes
-else
-  GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
-        CFLAGS="-g"
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-DEPDIR="${am__leading_dot}deps"
-
-ac_config_commands="$ac_config_commands depfiles"
-
-
-am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
-       @echo this is the am__doit target
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
-$as_echo_n "checking for style of include used by $am_make... " >&6; }
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
-$as_echo "$_am_result" >&6; }
-rm -f confinc confmf
-
-# Check whether --enable-dependency-tracking was given.
-if test "${enable_dependency_tracking+set}" = set; then :
-  enableval=$enable_dependency_tracking;
-fi
-
-if test "x$enable_dependency_tracking" != xno; then
-  am_depcomp="$ac_aux_dir/depcomp"
-  AMDEPBACKSLASH='\'
-fi
- if test "x$enable_dependency_tracking" != xno; then
-  AMDEP_TRUE=
-  AMDEP_FALSE='#'
-else
-  AMDEP_TRUE='#'
-  AMDEP_FALSE=
-fi
-
-
-
-depcc="$CC"   am_compiler_list=
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
-$as_echo_n "checking dependency style of $depcc... " >&6; }
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
-
-  am_cv_CC_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
-  fi
-  am__universal=false
-  case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac
-
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
-    am__obj=sub/conftest.${OBJEXT-o}
-    am__minus_obj="-o $am__obj"
-    case $depmode in
-    gcc)
-      # This depmode causes a compiler race in universal mode.
-      test "$am__universal" = false || continue
-      ;;
-    nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
-      if test "x$enable_dependency_tracking" = xyes; then
-       continue
-      else
-       break
-      fi
-      ;;
-    msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
-      # not run yet.  These depmodes are late enough in the game, and
-      # so weak that their functioning should not be impacted.
-      am__obj=conftest.${OBJEXT-o}
-      am__minus_obj=
-      ;;
-    none) break ;;
-    esac
-    if depmode=$depmode \
-       source=sub/conftest.c object=$am__obj \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_CC_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
-
-  cd ..
-  rm -rf conftest.dir
-else
-  am_cv_CC_dependencies_compiler_type=none
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
-$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-
- if
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
-  am__fastdepCC_TRUE=
-  am__fastdepCC_FALSE='#'
-else
-  am__fastdepCC_TRUE='#'
-  am__fastdepCC_FALSE=
-fi
-
-
-if test "x$CC" != xcc; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
-$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
-$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
-fi
-set dummy $CC; ac_cc=`$as_echo "$2" |
-                     sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-# Make sure it works both with $CC and with simple cc.
-# We do the test twice because some compilers refuse to overwrite an
-# existing .o file with -o, though they will create one.
-ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-rm -f conftest2.*
-if { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } &&
-   test -f conftest2.$ac_objext && { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; };
-then
-  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
-  if test "x$CC" != xcc; then
-    # Test first that cc exists at all.
-    if { ac_try='cc -c conftest.$ac_ext >&5'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
-      rm -f conftest2.*
-      if { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } &&
-        test -f conftest2.$ac_objext && { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; };
-      then
-       # cc works too.
-       :
-      else
-       # cc exists but doesn't like -o.
-       eval ac_cv_prog_cc_${ac_cc}_c_o=no
-      fi
-    fi
-  fi
-else
-  eval ac_cv_prog_cc_${ac_cc}_c_o=no
-fi
-rm -f core conftest*
-
-fi
-if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
-
-fi
-
-# FIXME: we rely on the cache variable name because
-# there is no other way.
-set dummy $CC
-am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
-eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
-if test "$am_t" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-
-
-
-if test x$GCC = xyes; then
-  test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
-else
-  test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
-fi
-
- if test "x$opsys" = "xmingw32"; then
-  BUILDING_FOR_WINDOWSNT_TRUE=
-  BUILDING_FOR_WINDOWSNT_FALSE='#'
-else
-  BUILDING_FOR_WINDOWSNT_TRUE='#'
-  BUILDING_FOR_WINDOWSNT_FALSE=
-fi
-
-
-# Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
-# as we don't use them.
-
-# Avoid gnulib's threadlib module, as we do threads our own way.
-
-
-# Initialize gnulib right after choosing the compiler.
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-                    Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-                    Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." "$LINENO" 5; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_GREP=$GREP
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
-
-   fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Minix Amsterdam compiler" >&5
-$as_echo_n "checking for Minix Amsterdam compiler... " >&6; }
-if test "${gl_cv_c_amsterdam_compiler+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifdef __ACK__
-Amsterdam
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "Amsterdam" >/dev/null 2>&1; then :
-  gl_cv_c_amsterdam_compiler=yes
-else
-  gl_cv_c_amsterdam_compiler=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_c_amsterdam_compiler" >&5
-$as_echo "$gl_cv_c_amsterdam_compiler" >&6; }
-  if test -z "$AR"; then
-    if test $gl_cv_c_amsterdam_compiler = yes; then
-      AR='cc -c.a'
-      if test -z "$ARFLAGS"; then
-        ARFLAGS='-o'
-      fi
-    else
-                  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_AR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AR="${ac_tool_prefix}ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_AR"; then
-  ac_ct_AR=$AR
-  # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_AR="ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_AR" = x; then
-    AR="ar"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    AR=$ac_ct_AR
-  fi
-else
-  AR="$ac_cv_prog_AR"
-fi
-
-      if test -z "$ARFLAGS"; then
-        ARFLAGS='cru'
-      fi
-    fi
-  else
-    if test -z "$ARFLAGS"; then
-      ARFLAGS='cru'
-    fi
-  fi
-
-
-  if test -z "$RANLIB"; then
-    if test $gl_cv_c_amsterdam_compiler = yes; then
-      RANLIB=':'
-    else
-            if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_RANLIB+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-    fi
-  fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-                  (('a' <= (c) && (c) <= 'i') \
-                    || ('j' <= (c) && (c) <= 'r') \
-                    || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-       || toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-                 inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-  ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
-if test "x$ac_cv_header_minix_config_h" = x""yes; then :
-  MINIX=yes
-else
-  MINIX=
-fi
-
-
-  if test "$MINIX" = yes; then
-
-$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
-
-
-$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h
-
-
-$as_echo "#define _MINIX 1" >>confdefs.h
-
-
-$as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h
-
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
-$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
-if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#         define __EXTENSIONS__ 1
-          $ac_includes_default
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_safe_to_define___extensions__=yes
-else
-  ac_cv_safe_to_define___extensions__=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5
-$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
-  test $ac_cv_safe_to_define___extensions__ = yes &&
-    $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
-
-  $as_echo "#define _ALL_SOURCE 1" >>confdefs.h
-
-  $as_echo "#define _DARWIN_C_SOURCE 1" >>confdefs.h
-
-  $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
-
-  $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
-
-  $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5
-$as_echo_n "checking whether _XOPEN_SOURCE should be defined... " >&6; }
-if test "${ac_cv_should_define__xopen_source+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_should_define__xopen_source=no
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-          #include <wchar.h>
-          mbstate_t x;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-             #define _XOPEN_SOURCE 500
-             #include <wchar.h>
-             mbstate_t x;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_should_define__xopen_source=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5
-$as_echo "$ac_cv_should_define__xopen_source" >&6; }
-  test $ac_cv_should_define__xopen_source = yes &&
-    $as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h
-
-
-
-
-
-
-
-
-# Check whether --enable-largefile was given.
-if test "${enable_largefile+set}" = set; then :
-  enableval=$enable_largefile;
-fi
-
-if test "$enable_largefile" != no; then
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
-$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_CC+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_sys_largefile_CC=no
-     if test "$GCC" != yes; then
-       ac_save_CC=$CC
-       while :; do
-         # IRIX 6.2 and later do not support large files by default,
-         # so use the C compiler's -n32 option if that helps.
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-                       && LARGE_OFF_T % 2147483647 == 1)
-                      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-         if ac_fn_c_try_compile "$LINENO"; then :
-  break
-fi
-rm -f core conftest.err conftest.$ac_objext
-         CC="$CC -n32"
-         if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_largefile_CC=' -n32'; break
-fi
-rm -f core conftest.err conftest.$ac_objext
-         break
-       done
-       CC=$ac_save_CC
-       rm -f conftest.$ac_ext
-    fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5
-$as_echo "$ac_cv_sys_largefile_CC" >&6; }
-  if test "$ac_cv_sys_largefile_CC" != no; then
-    CC=$CC$ac_cv_sys_largefile_CC
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
-$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if test "${ac_cv_sys_file_offset_bits+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-                       && LARGE_OFF_T % 2147483647 == 1)
-                      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_file_offset_bits=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-                       && LARGE_OFF_T % 2147483647 == 1)
-                      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_file_offset_bits=64; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_file_offset_bits=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5
-$as_echo "$ac_cv_sys_file_offset_bits" >&6; }
-case $ac_cv_sys_file_offset_bits in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
-_ACEOF
-;;
-esac
-rm -rf conftest*
-  if test $ac_cv_sys_file_offset_bits = unknown; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
-$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if test "${ac_cv_sys_large_files+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-                       && LARGE_OFF_T % 2147483647 == 1)
-                      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_large_files=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _LARGE_FILES 1
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
-    We can't simply define LARGE_OFF_T to be 9223372036854775807,
-    since some C++ compilers masquerading as C compilers
-    incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-                       && LARGE_OFF_T % 2147483647 == 1)
-                      ? 1 : -1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_sys_large_files=1; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  ac_cv_sys_large_files=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5
-$as_echo "$ac_cv_sys_large_files" >&6; }
-case $ac_cv_sys_large_files in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGE_FILES $ac_cv_sys_large_files
-_ACEOF
-;;
-esac
-rm -rf conftest*
-  fi
-
-
-$as_echo "#define _DARWIN_USE_64_BIT_INODE 1" >>confdefs.h
-
-fi
-
-   case $ac_cv_prog_cc_stdc in #(
-  no) :
-    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
-  *) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
-$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
-if test "${ac_cv_prog_cc_c99+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c99=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
-
-// Check varargs macros.  These examples are taken from C99 6.10.3.5.
-#define debug(...) fprintf (stderr, __VA_ARGS__)
-#define showlist(...) puts (#__VA_ARGS__)
-#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
-static void
-test_varargs_macros (void)
-{
-  int x = 1234;
-  int y = 5678;
-  debug ("Flag");
-  debug ("X = %d\n", x);
-  showlist (The first, second, and third items.);
-  report (x>y, "x is %d but y is %d", x, y);
-}
-
-// Check long long types.
-#define BIG64 18446744073709551615ull
-#define BIG32 4294967295ul
-#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
-#if !BIG_OK
-  your preprocessor is broken;
-#endif
-#if BIG_OK
-#else
-  your preprocessor is broken;
-#endif
-static long long int bignum = -9223372036854775807LL;
-static unsigned long long int ubignum = BIG64;
-
-struct incomplete_array
-{
-  int datasize;
-  double data[];
-};
-
-struct named_init {
-  int number;
-  const wchar_t *name;
-  double average;
-};
-
-typedef const char *ccp;
-
-static inline int
-test_restrict (ccp restrict text)
-{
-  // See if C++-style comments work.
-  // Iterate through items via the restricted pointer.
-  // Also check for declarations in for loops.
-  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
-    continue;
-  return 0;
-}
-
-// Check varargs and va_copy.
-static void
-test_varargs (const char *format, ...)
-{
-  va_list args;
-  va_start (args, format);
-  va_list args_copy;
-  va_copy (args_copy, args);
-
-  const char *str;
-  int number;
-  float fnumber;
-
-  while (*format)
-    {
-      switch (*format++)
-       {
-       case 's': // string
-         str = va_arg (args_copy, const char *);
-         break;
-       case 'd': // int
-         number = va_arg (args_copy, int);
-         break;
-       case 'f': // float
-         fnumber = va_arg (args_copy, double);
-         break;
-       default:
-         break;
-       }
-    }
-  va_end (args_copy);
-  va_end (args);
-}
-
-int
-main ()
-{
-
-  // Check bool.
-  _Bool success = false;
-
-  // Check restrict.
-  if (test_restrict ("String literal") == 0)
-    success = true;
-  char *restrict newvar = "Another string";
-
-  // Check varargs.
-  test_varargs ("s, d' f .", "string", 65, 34.234);
-  test_varargs_macros ();
-
-  // Check flexible array members.
-  struct incomplete_array *ia =
-    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
-  ia->datasize = 10;
-  for (int i = 0; i < ia->datasize; ++i)
-    ia->data[i] = i * 1.234;
-
-  // Check named initializers.
-  struct named_init ni = {
-    .number = 34,
-    .name = L"Test wide string",
-    .average = 543.34343,
-  };
-
-  ni.number = 58;
-
-  int dynamic_array[ni.number];
-  dynamic_array[ni.number - 1] = 543;
-
-  // work around unused variable warnings
-  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
-         || dynamic_array[ni.number - 1] != 543);
-
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c99=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c99" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c99" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c99"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
-$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c99" != xno; then :
-  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
-else
-  ac_cv_prog_cc_stdc=no
-fi
-
-fi
- ;;
-esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
-$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
-  if test "${ac_cv_prog_cc_stdc+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-fi
-
-  case $ac_cv_prog_cc_stdc in #(
-  no) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;; #(
-  '') :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;; #(
-  *) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
-$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
-esac
-
-
-
-  # Code from module alloca-opt:
-  # Code from module allocator:
-  # Code from module at-internal:
-  # Code from module binary-io:
-  # Code from module byteswap:
-  # Code from module c-ctype:
-  # Code from module c-strcase:
-  # Code from module careadlinkat:
-  # Code from module clock-time:
-  # Code from module close-stream:
-  # Code from module count-one-bits:
-  # Code from module count-trailing-zeros:
-  # Code from module crypto/md5:
-  # Code from module crypto/sha1:
-  # Code from module crypto/sha256:
-  # Code from module crypto/sha512:
-  # Code from module dirent:
-  # Code from module dosname:
-  # Code from module dtoastr:
-  # Code from module dtotimespec:
-  # Code from module dup2:
-  # Code from module environ:
-  # Code from module errno:
-  # Code from module euidaccess:
-  # Code from module execinfo:
-  # Code from module extensions:
-
-  # Code from module extern-inline:
-  # Code from module faccessat:
-  # Code from module fcntl:
-  # Code from module fcntl-h:
-  # Code from module fdatasync:
-  # Code from module fdopendir:
-  # Code from module filemode:
-  # Code from module fpending:
-  # Code from module fstatat:
-  # Code from module fsync:
-  # Code from module getdtablesize:
-  # Code from module getgroups:
-  # Code from module getloadavg:
-  # Code from module getopt-gnu:
-  # Code from module getopt-posix:
-  # Code from module gettext-h:
-  # Code from module gettime:
-  # Code from module gettimeofday:
-  # Code from module group-member:
-  # Code from module include_next:
-  # Code from module intprops:
-  # Code from module inttypes-incomplete:
-  # Code from module largefile:
-
-  # Code from module lstat:
-  # Code from module manywarnings:
-  # Code from module memrchr:
-  # Code from module mkostemp:
-  # Code from module mktime:
-  # Code from module multiarch:
-  # Code from module nocrash:
-  # Code from module openat-h:
-  # Code from module pathmax:
-  # Code from module pipe2:
-  # Code from module pselect:
-  # Code from module pthread_sigmask:
-  # Code from module putenv:
-  # Code from module qacl:
-  # Code from module readlink:
-  # Code from module readlinkat:
-  # Code from module root-uid:
-  # Code from module secure_getenv:
-  # Code from module sig2str:
-  # Code from module signal-h:
-  # Code from module snippet/_Noreturn:
-  # Code from module snippet/arg-nonnull:
-  # Code from module snippet/c++defs:
-  # Code from module snippet/warn-on-use:
-  # Code from module socklen:
-  # Code from module ssize_t:
-  # Code from module stat:
-  # Code from module stat-time:
-  # Code from module stdalign:
-  # Code from module stdarg:
-
-
-
-  # Code from module stdbool:
-  # Code from module stddef:
-  # Code from module stdint:
-  # Code from module stdio:
-  # Code from module stdlib:
-  # Code from module strftime:
-  # Code from module string:
-  # Code from module strtoimax:
-  # Code from module strtoll:
-  # Code from module strtoull:
-  # Code from module strtoumax:
-  # Code from module symlink:
-  # Code from module sys_select:
-  # Code from module sys_stat:
-  # Code from module sys_time:
-  # Code from module tempname:
-  # Code from module time:
-  # Code from module time_r:
-  # Code from module timer-time:
-  # Code from module timespec:
-  # Code from module timespec-add:
-  # Code from module timespec-sub:
-  # Code from module u64:
-  # Code from module unistd:
-  # Code from module unsetenv:
-  # Code from module utimens:
-  # Code from module verify:
-  # Code from module warnings:
-  # Code from module xalloc-oversized:
-
-
-if test "$ac_test_CFLAGS" != set; then
-  # It's helpful to have C macros available to GDB, so prefer -g3 to -g
-  # if -g3 works and the user does not specify CFLAGS.
-  # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
-  case $CFLAGS in
-    '-g')
-      emacs_g3_CFLAGS='-g3';;
-    '-g -O2')
-      emacs_g3_CFLAGS='-g3 -O2';;
-    *)
-      emacs_g3_CFLAGS='';;
-  esac
-  if test -n "$emacs_g3_CFLAGS"; then
-    emacs_save_CFLAGS=$CFLAGS
-    CFLAGS=$emacs_g3_CFLAGS
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts $emacs_g3_CFLAGS" >&5
-$as_echo_n "checking whether $CC accepts $emacs_g3_CFLAGS... " >&6; }
-if test "${emacs_cv_prog_cc_g3+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_prog_cc_g3=yes
-else
-  emacs_cv_prog_cc_g3=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_prog_cc_g3" >&5
-$as_echo "$emacs_cv_prog_cc_g3" >&6; }
-    if test $emacs_cv_prog_cc_g3 != yes; then
-      CFLAGS=$emacs_save_CFLAGS
-    fi
-    if test $opsys = mingw32; then
-      CFLAGS="$CFLAGS -gdwarf-2"
-    fi
-  fi
-
-  case $CFLAGS in
-    *-O*) ;;
-    *)
-      # No optimization flag was inferred for this non-GCC compiler.
-      # Try -O.  This is needed for xlc on AIX; see Bug#14258.
-      emacs_save_CFLAGS=$CFLAGS
-      test -z "$CFLAGS" || CFLAGS="$CFLAGS "
-      CFLAGS=${CFLAGS}-O
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -O" >&5
-$as_echo_n "checking whether $CC accepts -O... " >&6; }
-if test "${emacs_cv_prog_cc_o+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_prog_cc_o=yes
-else
-  emacs_cv_prog_cc_o=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_prog_cc_o" >&5
-$as_echo "$emacs_cv_prog_cc_o" >&6; }
-      if test $emacs_cv_prog_cc_o != yes; then
-       CFLAGS=$emacs_save_CFLAGS
-      fi ;;
-  esac
-fi
-
-# Check whether --enable-gcc-warnings was given.
-if test "${enable_gcc_warnings+set}" = set; then :
-  enableval=$enable_gcc_warnings; case $enableval in
-     yes|no) ;;
-     *)      as_fn_error "bad value $enableval for gcc-warnings option" "$LINENO" 5 ;;
-   esac
-   gl_gcc_warnings=$enableval
-else
-  gl_gcc_warnings=no
-
-fi
-
-
-# Check whether --enable-link-time-optimization was given.
-if test "${enable_link_time_optimization+set}" = set; then :
-  enableval=$enable_link_time_optimization; if test "${enableval}" != "no"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether link-time optimization is supported" >&5
-$as_echo_n "checking whether link-time optimization is supported... " >&6; }
-   ac_lto_supported=no
-   if test x$GCC = xyes; then
-      CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
-      if test x$CPUS != x; then
-        LTO="-flto=$CPUS"
-      else
-        LTO="-flto"
-      fi
-      old_CFLAGS=$CFLAGS
-      CFLAGS="$CFLAGS $LTO"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_lto_supported=yes
-else
-  ac_lto_supported=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      CFLAGS="$old_CFLAGS"
-   fi
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_lto_supported" >&5
-$as_echo "$ac_lto_supported" >&6; }
-   if test "$ac_lto_supported" = "yes"; then
-      CFLAGS="$CFLAGS $LTO"
-   fi
-fi
-fi
-
-
-# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
-# ------------------------------------------------
-# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
-# Otherwise, run RUN-IF-NOT-FOUND.
-
-
-# clang is unduly picky about some things.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler is clang" >&5
-$as_echo_n "checking whether the compiler is clang... " >&6; }
-if test "${emacs_cv_clang+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-         #ifndef __clang__
-           #error "not clang"
-         #endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_clang=yes
-else
-  emacs_cv_clang=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_clang" >&5
-$as_echo "$emacs_cv_clang" >&6; }
-
-# When compiling with GCC, prefer -isystem to -I when including system
-# include files, to avoid generating useless diagnostics for the files.
-if test "$gl_gcc_warnings" != yes; then
-  isystem='-I'
-  if test "$emacs_cv_clang" = yes
-  then
-     # Turn off some warnings if supported.
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Werror -Wunknown-warning-option" >&5
-$as_echo_n "checking whether C compiler handles -Werror -Wunknown-warning-option... " >&6; }
-if test "${gl_cv_warn_c__Werror__Wunknown_warning_option+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Werror -Wunknown-warning-option"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Werror__Wunknown_warning_option=yes
-else
-  gl_cv_warn_c__Werror__Wunknown_warning_option=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Werror__Wunknown_warning_option" >&5
-$as_echo "$gl_cv_warn_c__Werror__Wunknown_warning_option" >&6; }
-if test "x$gl_cv_warn_c__Werror__Wunknown_warning_option" = x""yes; then :
-  gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'
-else
-  gl_unknown_warnings_are_errors=
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-switch" >&5
-$as_echo_n "checking whether C compiler handles -Wno-switch... " >&6; }
-if test "${gl_cv_warn_c__Wno_switch+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wswitch"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_switch=yes
-else
-  gl_cv_warn_c__Wno_switch=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_switch" >&5
-$as_echo "$gl_cv_warn_c__Wno_switch" >&6; }
-if test "x$gl_cv_warn_c__Wno_switch" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-switch"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-tautological-constant-out-of-range-compare" >&5
-$as_echo_n "checking whether C compiler handles -Wno-tautological-constant-out-of-range-compare... " >&6; }
-if test "${gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wtautological-constant-out-of-range-compare"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare=yes
-else
-  gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" >&5
-$as_echo "$gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" >&6; }
-if test "x$gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-tautological-constant-out-of-range-compare"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-pointer-sign" >&5
-$as_echo_n "checking whether C compiler handles -Wno-pointer-sign... " >&6; }
-if test "${gl_cv_warn_c__Wno_pointer_sign+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wpointer-sign"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_pointer_sign=yes
-else
-  gl_cv_warn_c__Wno_pointer_sign=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_pointer_sign" >&5
-$as_echo "$gl_cv_warn_c__Wno_pointer_sign" >&6; }
-if test "x$gl_cv_warn_c__Wno_pointer_sign" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-pointer-sign"
-fi
-
-
-  fi
-else
-  isystem='-isystem '
-
-  # This, $nw, is the list of warnings we disable.
-  nw=
-
-  case $with_x_toolkit in
-    lucid | athena | motif)
-       # Old toolkits mishandle 'const'.
-       nw="$nw -Wwrite-strings"
-       ;;
-    *)
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Werror" >&5
-$as_echo_n "checking whether C compiler handles -Werror... " >&6; }
-if test "${gl_cv_warn_c__Werror+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Werror"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Werror=yes
-else
-  gl_cv_warn_c__Werror=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Werror" >&5
-$as_echo "$gl_cv_warn_c__Werror" >&6; }
-if test "x$gl_cv_warn_c__Werror" = x""yes; then :
-  as_fn_append WERROR_CFLAGS " -Werror"
-fi
-
-
-       ;;
-  esac
-
-
-  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
-  nw="$nw -Woverlength-strings"     # Not a problem these days
-  nw="$nw -Wlogical-op"             # any use of fwrite provokes this
-  nw="$nw -Wformat-nonliteral"      # we do this a lot
-  nw="$nw -Wvla"                    # warnings in gettext.h
-  nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
-  nw="$nw -Wswitch-default"         # Too many warnings for now
-  nw="$nw -Winline"                 # OK to ignore 'inline'
-  nw="$nw -Wjump-misses-init"       # We sometimes safely jump over init.
-  nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
-                                    # signed overflow has undefined behavior
-  nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
-  nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
-  nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
-
-  # Emacs doesn't care about shadowing; see
-  # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
-  nw="$nw -Wshadow"
-
-  # Emacs's use of alloca inhibits protecting the stack.
-  nw="$nw -Wstack-protector"
-
-  # The following line should be removable at some point.
-  nw="$nw -Wsuggest-attribute=pure"
-
-  # This part is merely for shortening the command line,
-  # since -Wno-FOO needs to be added below regardless.
-  nw="$nw -Wmissing-field-initializers"
-  nw="$nw -Wswitch"
-  nw="$nw -Wtype-limits"
-  nw="$nw -Wunused-parameter"
-
-  if test $emacs_cv_clang = yes; then
-    nw="$nw -Wcast-align"
-  fi
-
-
-
-  if test -n "$GCC"; then
-
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wno-missing-field-initializers is supported" >&5
-$as_echo_n "checking whether -Wno-missing-field-initializers is supported... " >&6; }
-    if test "${gl_cv_cc_nomfi_supported+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      gl_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_cc_nomfi_supported=yes
-else
-  gl_cv_cc_nomfi_supported=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      CFLAGS="$gl_save_CFLAGS"
-fi
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_nomfi_supported" >&5
-$as_echo "$gl_cv_cc_nomfi_supported" >&6; }
-
-    if test "$gl_cv_cc_nomfi_supported" = yes; then
-                  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wno-missing-field-initializers is needed" >&5
-$as_echo_n "checking whether -Wno-missing-field-initializers is needed... " >&6; }
-      if test "${gl_cv_cc_nomfi_needed+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-        gl_save_CFLAGS="$CFLAGS"
-        CFLAGS="$CFLAGS -W -Werror"
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-void f (void)
-               {
-                 typedef struct { int a; int b; } s_t;
-                 s_t s1 = { 0, };
-               }
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_cc_nomfi_needed=no
-else
-  gl_cv_cc_nomfi_needed=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-        CFLAGS="$gl_save_CFLAGS"
-
-fi
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_nomfi_needed" >&5
-$as_echo "$gl_cv_cc_nomfi_needed" >&6; }
-    fi
-
-                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wuninitialized is supported" >&5
-$as_echo_n "checking whether -Wuninitialized is supported... " >&6; }
-    if test "${gl_cv_cc_uninitialized_supported+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      gl_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -Werror -Wuninitialized"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_cc_uninitialized_supported=yes
-else
-  gl_cv_cc_uninitialized_supported=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      CFLAGS="$gl_save_CFLAGS"
-fi
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_uninitialized_supported" >&5
-$as_echo "$gl_cv_cc_uninitialized_supported" >&6; }
-
-  fi
-
-  # List all gcc warning categories.
-  gl_manywarn_set=
-  for gl_manywarn_item in \
-    -W \
-    -Wabi \
-    -Waddress \
-    -Waggressive-loop-optimizations \
-    -Wall \
-    -Warray-bounds \
-    -Wattributes \
-    -Wbad-function-cast \
-    -Wbuiltin-macro-redefined \
-    -Wcast-align \
-    -Wchar-subscripts \
-    -Wclobbered \
-    -Wcomment \
-    -Wcomments \
-    -Wcoverage-mismatch \
-    -Wcpp \
-    -Wdeprecated \
-    -Wdeprecated-declarations \
-    -Wdisabled-optimization \
-    -Wdiv-by-zero \
-    -Wdouble-promotion \
-    -Wempty-body \
-    -Wendif-labels \
-    -Wenum-compare \
-    -Wextra \
-    -Wformat-contains-nul \
-    -Wformat-extra-args \
-    -Wformat-nonliteral \
-    -Wformat-security \
-    -Wformat-y2k \
-    -Wformat-zero-length \
-    -Wfree-nonheap-object \
-    -Wignored-qualifiers \
-    -Wimplicit \
-    -Wimplicit-function-declaration \
-    -Wimplicit-int \
-    -Winit-self \
-    -Winline \
-    -Wint-to-pointer-cast \
-    -Winvalid-memory-model \
-    -Winvalid-pch \
-    -Wjump-misses-init \
-    -Wlogical-op \
-    -Wmain \
-    -Wmaybe-uninitialized \
-    -Wmissing-braces \
-    -Wmissing-declarations \
-    -Wmissing-field-initializers \
-    -Wmissing-include-dirs \
-    -Wmissing-parameter-type \
-    -Wmissing-prototypes \
-    -Wmudflap \
-    -Wmultichar \
-    -Wnarrowing \
-    -Wnested-externs \
-    -Wnonnull \
-    -Wnormalized=nfc \
-    -Wold-style-declaration \
-    -Wold-style-definition \
-    -Woverflow \
-    -Woverlength-strings \
-    -Woverride-init \
-    -Wpacked \
-    -Wpacked-bitfield-compat \
-    -Wparentheses \
-    -Wpointer-arith \
-    -Wpointer-sign \
-    -Wpointer-to-int-cast \
-    -Wpragmas \
-    -Wreturn-local-addr \
-    -Wreturn-type \
-    -Wsequence-point \
-    -Wshadow \
-    -Wsizeof-pointer-memaccess \
-    -Wstack-protector \
-    -Wstrict-aliasing \
-    -Wstrict-overflow \
-    -Wstrict-prototypes \
-    -Wsuggest-attribute=const \
-    -Wsuggest-attribute=format \
-    -Wsuggest-attribute=noreturn \
-    -Wsuggest-attribute=pure \
-    -Wswitch \
-    -Wswitch-default \
-    -Wsync-nand \
-    -Wsystem-headers \
-    -Wtrampolines \
-    -Wtrigraphs \
-    -Wtype-limits \
-    -Wuninitialized \
-    -Wunknown-pragmas \
-    -Wunsafe-loop-optimizations \
-    -Wunused \
-    -Wunused-but-set-parameter \
-    -Wunused-but-set-variable \
-    -Wunused-function \
-    -Wunused-label \
-    -Wunused-local-typedefs \
-    -Wunused-macros \
-    -Wunused-parameter \
-    -Wunused-result \
-    -Wunused-value \
-    -Wunused-variable \
-    -Wvarargs \
-    -Wvariadic-macros \
-    -Wvector-operation-performance \
-    -Wvla \
-    -Wvolatile-register-var \
-    -Wwrite-strings \
-    -fdiagnostics-show-option \
-    -funit-at-a-time \
-    \
-    ; do
-    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
-  done
-
-  # Disable specific options as needed.
-  if test "$gl_cv_cc_nomfi_needed" = yes; then
-    gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
-  fi
-
-  if test "$gl_cv_cc_uninitialized_supported" = no; then
-    gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
-  fi
-
-  ws=$gl_manywarn_set
-
-
-  gl_warn_set=
-  set x $ws; shift
-  for gl_warn_item
-  do
-    case " $nw " in
-      *" $gl_warn_item "*)
-        ;;
-      *)
-        gl_warn_set="$gl_warn_set $gl_warn_item"
-        ;;
-    esac
-  done
-  ws=$gl_warn_set
-
-  for w in $ws; do
-
-as_gl_Warn=`$as_echo "gl_cv_warn_c_$w" | $as_tr_sh`
-gl_positive="$w"
-case $gl_positive in
-  -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;;
-esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles $w" >&5
-$as_echo_n "checking whether C compiler handles $w... " >&6; }
-if { as_var=$as_gl_Warn; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors $gl_positive"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$as_gl_Warn=yes"
-else
-  eval "$as_gl_Warn=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-eval ac_res=\$$as_gl_Warn
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-eval as_val=\$$as_gl_Warn
-   if test "x$as_val" = x""yes; then :
-  as_fn_append WARN_CFLAGS " $w"
-fi
-
-
-  done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-missing-field-initializers" >&5
-$as_echo_n "checking whether C compiler handles -Wno-missing-field-initializers... " >&6; }
-if test "${gl_cv_warn_c__Wno_missing_field_initializers+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wmissing-field-initializers"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_missing_field_initializers=yes
-else
-  gl_cv_warn_c__Wno_missing_field_initializers=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_missing_field_initializers" >&5
-$as_echo "$gl_cv_warn_c__Wno_missing_field_initializers" >&6; }
-if test "x$gl_cv_warn_c__Wno_missing_field_initializers" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-missing-field-initializers"
-fi
-
- # We need this one
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-sign-compare" >&5
-$as_echo_n "checking whether C compiler handles -Wno-sign-compare... " >&6; }
-if test "${gl_cv_warn_c__Wno_sign_compare+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wsign-compare"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_sign_compare=yes
-else
-  gl_cv_warn_c__Wno_sign_compare=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_sign_compare" >&5
-$as_echo "$gl_cv_warn_c__Wno_sign_compare" >&6; }
-if test "x$gl_cv_warn_c__Wno_sign_compare" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-sign-compare"
-fi
-
-     # Too many warnings for now
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-type-limits" >&5
-$as_echo_n "checking whether C compiler handles -Wno-type-limits... " >&6; }
-if test "${gl_cv_warn_c__Wno_type_limits+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wtype-limits"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_type_limits=yes
-else
-  gl_cv_warn_c__Wno_type_limits=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_type_limits" >&5
-$as_echo "$gl_cv_warn_c__Wno_type_limits" >&6; }
-if test "x$gl_cv_warn_c__Wno_type_limits" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-type-limits"
-fi
-
-      # Too many warnings for now
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-switch" >&5
-$as_echo_n "checking whether C compiler handles -Wno-switch... " >&6; }
-if test "${gl_cv_warn_c__Wno_switch+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wswitch"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_switch=yes
-else
-  gl_cv_warn_c__Wno_switch=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_switch" >&5
-$as_echo "$gl_cv_warn_c__Wno_switch" >&6; }
-if test "x$gl_cv_warn_c__Wno_switch" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-switch"
-fi
-
-           # Too many warnings for now
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-parameter" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-parameter... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_parameter+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-parameter"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_parameter=yes
-else
-  gl_cv_warn_c__Wno_unused_parameter=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_parameter" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_parameter" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_parameter" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-parameter"
-fi
-
- # Too many warnings for now
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-format-nonliteral" >&5
-$as_echo_n "checking whether C compiler handles -Wno-format-nonliteral... " >&6; }
-if test "${gl_cv_warn_c__Wno_format_nonliteral+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wformat-nonliteral"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_format_nonliteral=yes
-else
-  gl_cv_warn_c__Wno_format_nonliteral=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_format_nonliteral" >&5
-$as_echo "$gl_cv_warn_c__Wno_format_nonliteral" >&6; }
-if test "x$gl_cv_warn_c__Wno_format_nonliteral" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-format-nonliteral"
-fi
-
-
-
-  # In spite of excluding -Wlogical-op above, it is enabled, as of
-  # gcc 4.5.0 20090517.
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-logical-op" >&5
-$as_echo_n "checking whether C compiler handles -Wno-logical-op... " >&6; }
-if test "${gl_cv_warn_c__Wno_logical_op+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wlogical-op"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_logical_op=yes
-else
-  gl_cv_warn_c__Wno_logical_op=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_logical_op" >&5
-$as_echo "$gl_cv_warn_c__Wno_logical_op" >&6; }
-if test "x$gl_cv_warn_c__Wno_logical_op" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-logical-op"
-fi
-
-
-
-  # More things that clang is unduly picky about.
-  if test $emacs_cv_clang = yes; then
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-format-extra-args" >&5
-$as_echo_n "checking whether C compiler handles -Wno-format-extra-args... " >&6; }
-if test "${gl_cv_warn_c__Wno_format_extra_args+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wformat-extra-args"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_format_extra_args=yes
-else
-  gl_cv_warn_c__Wno_format_extra_args=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_format_extra_args" >&5
-$as_echo "$gl_cv_warn_c__Wno_format_extra_args" >&6; }
-if test "x$gl_cv_warn_c__Wno_format_extra_args" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-format-extra-args"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-tautological-constant-out-of-range-compare" >&5
-$as_echo_n "checking whether C compiler handles -Wno-tautological-constant-out-of-range-compare... " >&6; }
-if test "${gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wtautological-constant-out-of-range-compare"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare=yes
-else
-  gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" >&5
-$as_echo "$gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" >&6; }
-if test "x$gl_cv_warn_c__Wno_tautological_constant_out_of_range_compare" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-tautological-constant-out-of-range-compare"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-command-line-argument" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-command-line-argument... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_command_line_argument+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-command-line-argument"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_command_line_argument=yes
-else
-  gl_cv_warn_c__Wno_unused_command_line_argument=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_command_line_argument" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_command_line_argument" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_command_line_argument" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-command-line-argument"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-value" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-value... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_value+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-value"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_value=yes
-else
-  gl_cv_warn_c__Wno_unused_value=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_value" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_value" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_value" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-value"
-fi
-
-
-  fi
-
-
-$as_echo "#define lint 1" >>confdefs.h
-
-
-
-$as_echo "#define GNULIB_PORTCHECK 1" >>confdefs.h
-
-
-  # We use a slightly smaller set of warning options for lib/.
-  # Remove the following and save the result in GNULIB_WARN_CFLAGS.
-  nw=
-  nw="$nw -Wunused-macros"
-
-
-  gl_warn_set=
-  set x $WARN_CFLAGS; shift
-  for gl_warn_item
-  do
-    case " $nw " in
-      *" $gl_warn_item "*)
-        ;;
-      *)
-        gl_warn_set="$gl_warn_set $gl_warn_item"
-        ;;
-    esac
-  done
-  GNULIB_WARN_CFLAGS=$gl_warn_set
-
-
-fi
-
-
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works for files in the same directory" >&5
-$as_echo_n "checking whether ln -s works for files in the same directory... " >&6; }
-rm -f conf$$ conf$$.file
-
-LN_S_FILEONLY='cp -p'
-
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    LN_S_FILEONLY='ln -s'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    LN_S_FILEONLY=ln
-  fi
-fi
-
-rm -f conf$$ conf$$.file
-
-if test "$LN_S_FILEONLY" = "ln -s"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S_FILEONLY" >&5
-$as_echo "no, using $LN_S_FILEONLY" >&6; }
-fi
-
-
-
-
-if test "$opsys" = "mingw32"; then
-  LN_S="ln"
-fi
-
-# Extract the first word of "install-info", so it can be a program name with args.
-set dummy install-info; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_INSTALL_INFO+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $INSTALL_INFO in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_INSTALL_INFO="$INSTALL_INFO" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_INSTALL_INFO="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_INSTALL_INFO" && ac_cv_path_INSTALL_INFO=":"
-  ;;
-esac
-fi
-INSTALL_INFO=$ac_cv_path_INSTALL_INFO
-if test -n "$INSTALL_INFO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_INFO" >&5
-$as_echo "$INSTALL_INFO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-# Extract the first word of "gzip", so it can be a program name with args.
-set dummy gzip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GZIP_PROG+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $GZIP_PROG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_GZIP_PROG="$GZIP_PROG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_GZIP_PROG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-GZIP_PROG=$ac_cv_path_GZIP_PROG
-if test -n "$GZIP_PROG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP_PROG" >&5
-$as_echo "$GZIP_PROG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-test $with_compress_install != yes && test -n "$GZIP_PROG" && \
-   GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
-
-if test $opsys = gnu-linux; then
-  # Extract the first word of "paxctl", so it can be a program name with args.
-set dummy paxctl; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PAXCTL+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PAXCTL in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PAXCTL="$PAXCTL" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_PAXCTL="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-PAXCTL=$ac_cv_path_PAXCTL
-if test -n "$PAXCTL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PAXCTL" >&5
-$as_echo "$PAXCTL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  if test "X$PAXCTL" != X; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether binaries have a PT_PAX_FLAGS header" >&5
-$as_echo_n "checking whether binaries have a PT_PAX_FLAGS header... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-      else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }; PAXCTL=""; fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  fi
-fi
-
-## Need makeinfo >= 4.7 (?) to build the manuals.
-# Extract the first word of "makeinfo", so it can be a program name with args.
-set dummy makeinfo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MAKEINFO+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $MAKEINFO in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MAKEINFO="$MAKEINFO" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_MAKEINFO="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_MAKEINFO" && ac_cv_path_MAKEINFO="no"
-  ;;
-esac
-fi
-MAKEINFO=$ac_cv_path_MAKEINFO
-if test -n "$MAKEINFO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEINFO" >&5
-$as_echo "$MAKEINFO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test "$MAKEINFO" != "no"; then
-  case `
-    $MAKEINFO --version 2> /dev/null |
-    $EGREP 'texinfo[^0-9]*([1-4][0-9]+|[5-9]|4\.[7-9]|4\.[1-6][0-9]+)'
-  ` in
-    '') MAKEINFO=no;;
-  esac
-fi
-
-## Makeinfo is unusual.  For a released Emacs, the manuals are
-## pre-built, and not deleted by the normal clean rules.  makeinfo is
-## therefore in the category of "special tools" not normally required, which
-## configure does not have to check for (eg autoconf itself).
-## In a Bazaar checkout on the other hand, the manuals are not included.
-## So makeinfo is a requirement to build from Bazaar, and configure
-## should test for it as it does for any other build requirement.
-## We use the presence of $srcdir/info/emacs to distinguish a release,
-## with pre-built manuals, from a Bazaar checkout.
-HAVE_MAKEINFO=yes
-
-if test "$MAKEINFO" = "no"; then
-  MAKEINFO=makeinfo
-  if test "x${with_makeinfo}" = "xno"; then
-    HAVE_MAKEINFO=no
-  elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
-    as_fn_error "You do not seem to have makeinfo >= 4.7, and your
-source tree does not seem to have pre-built manuals in the \`info' directory.
-Either install a suitable version of makeinfo, or re-run configure
-with the \`--without-makeinfo' option to build without the manuals. " "$LINENO" 5
-  fi
-fi
-
-
-INFO_EXT=.info
-INFO_OPTS=--no-split
-
-
-
-if test $opsys = mingw32; then
-   DOCMISC_W32=efaq-w32
-else
-   DOCMISC_W32=
-fi
-
-
-
-if test x$GCC = xyes; then
-  test "x$GCC_LINK_TEST_OPTIONS" != x && \
-    ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
-else
-  test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
-    ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
-fi
-
-
-late_LDFLAGS="$LDFLAGS"
-if test x$GCC = xyes; then
-  LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
-else
-  LDFLAGS_NOCOMBRELOC="-znocombreloc"
-fi
-
-LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -znocombreloc" >&5
-$as_echo_n "checking for -znocombreloc... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  LDFLAGS_NOCOMBRELOC=
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-LDFLAGS="$late_LDFLAGS"
-
-test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
-case "$opsys" in
-  your-opsys-here) CANNOT_DUMP=yes ;;
-esac
-
-test "$CANNOT_DUMP" = "yes" && \
-
-$as_echo "#define CANNOT_DUMP 1" >>confdefs.h
-
-
-
-
-
-UNEXEC_OBJ=unexelf.o
-case "$opsys" in
-  # MSDOS uses unexcoff.o
-  aix4-2)
-   UNEXEC_OBJ=unexaix.o
-   ;;
-  cygwin)
-   UNEXEC_OBJ=unexcw.o
-   ;;
-  darwin)
-   UNEXEC_OBJ=unexmacosx.o
-   ;;
-  hpux10-20 | hpux11)
-   UNEXEC_OBJ=unexhp9k800.o
-   ;;
-  mingw32)
-   UNEXEC_OBJ=unexw32.o
-   ;;
-  sol2-10)
-   # Use the Solaris dldump() function, called from unexsol.c, to dump
-   # emacs, instead of the generic ELF dump code found in unexelf.c.
-   # The resulting binary has a complete symbol table, and is better
-   # for debugging and other observability tools (debuggers, pstack, etc).
-   #
-   # If you encounter a problem using dldump(), please consider sending
-   # a message to the OpenSolaris tools-linking mailing list:
-   #      http://mail.opensolaris.org/mailman/listinfo/tools-linking
-   #
-   # It is likely that dldump() works with older Solaris too, but this has
-   # not been tested, so for now this change is for Solaris 10 or newer.
-   UNEXEC_OBJ=unexsol.o
-   ;;
-esac
-
-LD_SWITCH_SYSTEM=
-case "$opsys" in
-  freebsd|dragonfly)
-   ## Let `ld' find image libs and similar things in /usr/local/lib.
-   ## The system compiler, GCC, has apparently been modified to not
-   ## look there, contrary to what a stock GCC would do.
-### It's not our place to do this.  See bug#10313#17.
-###   LD_SWITCH_SYSTEM=-L/usr/local/lib
-      :
-   ;;
-
-  gnu-linux)
-   ## cpp test was "ifdef __mips__", but presumably this is equivalent...
-   case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
-   ;;
-
-  netbsd)
-### It's not our place to do this.  See bug#10313#17.
-###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
-      :
-   ;;
-
-  openbsd)
-   ## Han Boetes <han@boetes.org> says this is necessary,
-   ## otherwise Emacs dumps core on elf systems.
-   LD_SWITCH_SYSTEM="-Z"
-   ;;
-esac
-
-
-ac_link="$ac_link $LD_SWITCH_SYSTEM"
-
-## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
-## which has not been defined yet.  When this was handled with cpp,
-## it was expanded to null when configure sourced the s/*.h file.
-## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
-## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
-## (or somesuch), but because it is supposed to go at the _front_
-## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
-## Compare with the gnu-linux case below, which added to the end
-## of LD_SWITCH_SYSTEM, and so can instead go at the front of
-## LD_SWITCH_SYSTEM_TEMACS.
-case "$opsys" in
-  netbsd|openbsd)
-   LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
-esac
-
-
-C_SWITCH_MACHINE=
-case $canonical in
- alpha*)
-  ac_fn_c_check_decl "$LINENO" "__ELF__" "ac_cv_have_decl___ELF__" "$ac_includes_default"
-if test "x$ac_cv_have_decl___ELF__" = x""yes; then :
-
-fi
-
-  if test "$ac_cv_have_decl___ELF__" = "yes"; then
-    ## With ELF, make sure that all common symbols get allocated to in the
-    ## data section.  Otherwise, the dump of temacs may miss variables in
-    ## the shared library that have been initialized.  For example, with
-    ## GNU libc, __malloc_initialized would normally be resolved to the
-    ## shared library's .bss section, which is fatal.
-    if test "x$GCC" = "xyes"; then
-      C_SWITCH_MACHINE="-fno-common"
-    else
-      as_fn_error "Non-GCC compilers are not supported." "$LINENO" 5
-    fi
-  else
-                        as_fn_error "Non-ELF systems are not supported since Emacs 24.1." "$LINENO" 5
-  fi
-  ;;
-esac
-
-
-
-
-C_SWITCH_SYSTEM=
-## Some programs in src produce warnings saying certain subprograms
-## are too complex and need a MAXMEM value greater than 2000 for
-## additional optimization.  --nils@exp-math.uni-essen.de
-test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
-  C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
-test "$opsys" = "mingw32" && C_SWITCH_SYSTEM="-mtune=pentium4"
-## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
-## It is redundant in glibc2, since we define _GNU_SOURCE.
-
-
-
-LIBS_SYSTEM=
-case "$opsys" in
-  ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
-  aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
-
-  freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
-
-  hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
-
-  sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
-
-  ## Motif needs -lgen.
-  unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
-esac
-
-
-
-### Make sure subsequent tests use flags consistent with the build flags.
-
-if test x"${OVERRIDE_CPPFLAGS}" != x; then
-  CPPFLAGS="${OVERRIDE_CPPFLAGS}"
-else
-  CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
-fi
-
-# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
-
-# Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
-
-
-
-LIB_MATH=-lm
-SYSTEM_TYPE=`echo $opsys | sed -e 's/[0-9].*//' -e 's|-|/|'`
-
-case $opsys in
-  cygwin )
-    LIB_MATH=
-    ;;
-  darwin )
-    ## Adding -lm confuses the dynamic linker, so omit it.
-    LIB_MATH=
-    ;;
-  freebsd | dragonfly )
-    SYSTEM_TYPE=berkeley-unix
-    ;;
-  gnu-linux | gnu-kfreebsd )
-    ;;
-  hpux10-20 | hpux11 )
-    ;;
-  mingw32 )
-    LIB_MATH=
-    SYSTEM_TYPE=windows-nt
-    ;;
-    netbsd | openbsd )
-    SYSTEM_TYPE=berkeley-unix
-    ;;
-
-  sol2* | unixware )
-    SYSTEM_TYPE=usg-unix-v
-    ;;
-
-esac
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define SYSTEM_TYPE "$SYSTEM_TYPE"
-_ACEOF
-
-
-
-pre_PKG_CONFIG_CFLAGS=$CFLAGS
-pre_PKG_CONFIG_LIBS=$LIBS
-
-# Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $PKG_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
-  ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-
-
-
-HAVE_SOUND=no
-if test "${with_sound}" != "no"; then
-  # Sound support for GNU/Linux, the free BSDs, and MinGW.
-  for ac_header in machine/soundcard.h sys/soundcard.h soundcard.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
-    #ifdef __MINGW32__
-    #define WIN32_LEAN_AND_MEAN
-    #include <windows.h>
-    #endif
-
-"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- have_sound_header=yes
-fi
-
-done
-
-  test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
-    as_fn_error "OSS sound support requested but not found." "$LINENO" 5
-
-  if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
-    # Emulation library used on NetBSD.
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _oss_ioctl in -lossaudio" >&5
-$as_echo_n "checking for _oss_ioctl in -lossaudio... " >&6; }
-if test "${ac_cv_lib_ossaudio__oss_ioctl+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lossaudio  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char _oss_ioctl ();
-int
-main ()
-{
-return _oss_ioctl ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ossaudio__oss_ioctl=yes
-else
-  ac_cv_lib_ossaudio__oss_ioctl=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ossaudio__oss_ioctl" >&5
-$as_echo "$ac_cv_lib_ossaudio__oss_ioctl" >&6; }
-if test "x$ac_cv_lib_ossaudio__oss_ioctl" = x""yes; then :
-  LIBSOUND=-lossaudio
-else
-  LIBSOUND=
-fi
-
-    test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
-      as_fn_error "bsd-ossaudio sound support requested but not found." "$LINENO" 5
-          fi
-
-
-  if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
-    ALSA_REQUIRED=1.0.0
-    ALSA_MODULES="alsa >= $ALSA_REQUIRED"
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_ALSA=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ALSA_MODULES" >&5
-$as_echo_n "checking for $ALSA_MODULES... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$ALSA_MODULES" 2>&5 &&
-          ALSA_CFLAGS=`"$PKG_CONFIG" --cflags "$ALSA_MODULES" 2>&5` &&
-          ALSA_LIBS=`"$PKG_CONFIG" --libs "$ALSA_MODULES" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           ALSA_CFLAGS=`$as_echo "$ALSA_CFLAGS" | sed -e "$edit_cflags"`
-           ALSA_LIBS=`$as_echo "$ALSA_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$ALSA_CFLAGS' LIBS='$ALSA_LIBS'" >&5
-$as_echo "yes CFLAGS='$ALSA_CFLAGS' LIBS='$ALSA_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            ALSA_CFLAGS=""
-            ALSA_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           ALSA_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$ALSA_MODULES") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_ALSA=yes
-  else
-     HAVE_ALSA=no
-  fi
-
-    if test $HAVE_ALSA = yes; then
-      SAVE_CFLAGS="$CFLAGS"
-      SAVE_LIBS="$LIBS"
-      CFLAGS="$ALSA_CFLAGS $CFLAGS"
-      LIBS="$ALSA_LIBS $LIBS"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <asoundlib.h>
-int
-main ()
-{
-snd_lib_error_set_handler (0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_alsa_normal=yes
-else
-  emacs_alsa_normal=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      if test "$emacs_alsa_normal" != yes; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <alsa/asoundlib.h>
-int
-main ()
-{
-snd_lib_error_set_handler (0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_alsa_subdir=yes
-else
-  emacs_alsa_subdir=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-        if test "$emacs_alsa_subdir" != yes; then
-          as_fn_error "pkg-config found alsa, but it does not compile.  See config.log for error messages." "$LINENO" 5
-        fi
-        ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
-      fi
-
-      CFLAGS="$SAVE_CFLAGS"
-      LIBS="$SAVE_LIBS"
-      LIBSOUND="$LIBSOUND $ALSA_LIBS"
-      CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
-
-$as_echo "#define HAVE_ALSA 1" >>confdefs.h
-
-    elif test "${with_sound}" = "alsa"; then
-      as_fn_error "ALSA sound support requested but not found." "$LINENO" 5
-    fi
-  fi
-            if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
-     case "$opsys" in
-                     gnu-linux|freebsd|netbsd|mingw32)
-
-$as_echo "#define HAVE_SOUND 1" >>confdefs.h
-
-         HAVE_SOUND=yes
-         ;;
-     esac
-  fi
-
-
-fi
-
-
-
-
-  for ac_header in $ac_header_list
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if personality LINUX32 can be set" >&5
-$as_echo_n "checking if personality LINUX32 can be set... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/personality.h>
-int
-main ()
-{
-personality (PER_LINUX32)
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_personality_linux32=yes
-else
-  emacs_cv_personality_linux32=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_personality_linux32" >&5
-$as_echo "$emacs_cv_personality_linux32" >&6; }
-
-if test $emacs_cv_personality_linux32 = yes; then
-
-$as_echo "#define HAVE_PERSONALITY_LINUX32 1" >>confdefs.h
-
-fi
-
-for ac_header in term.h
-do :
-  ac_fn_c_check_header_preproc "$LINENO" "term.h" "ac_cv_header_term_h"
-if test "x$ac_cv_header_term_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_TERM_H 1
-_ACEOF
-
-fi
-
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
-$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
-if test "${ac_cv_header_time+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_time=yes
-else
-  ac_cv_header_time=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
-$as_echo "$ac_cv_header_time" >&6; }
-if test $ac_cv_header_time = yes; then
-
-$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
-
-fi
-
-ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h>
-
-"
-if test "x$ac_cv_have_decl_sys_siglist" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_SYS_SIGLIST $ac_have_decl
-_ACEOF
-
-if test $ac_cv_have_decl_sys_siglist != yes; then
-  # For Tru64, at least:
-  ac_fn_c_check_decl "$LINENO" "__sys_siglist" "ac_cv_have_decl___sys_siglist" "#include <signal.h>
-
-"
-if test "x$ac_cv_have_decl___sys_siglist" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL___SYS_SIGLIST $ac_have_decl
-_ACEOF
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
-$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
-if test "${ac_cv_header_sys_wait_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-
-int
-main ()
-{
-  int s;
-  wait (&s);
-  s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_sys_wait_h=yes
-else
-  ac_cv_header_sys_wait_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5
-$as_echo "$ac_cv_header_sys_wait_h" >&6; }
-if test $ac_cv_header_sys_wait_h = yes; then
-
-$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
-
-fi
-
-
-
-
-
-for ac_header in net/if.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-"
-if test "x$ac_cv_header_net_if_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NET_IF_H 1
-_ACEOF
-
-fi
-
-done
-
-for ac_header in ifaddrs.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "ifaddrs.h" "ac_cv_header_ifaddrs_h" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-"
-if test "x$ac_cv_header_ifaddrs_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_IFADDRS_H 1
-_ACEOF
-
-fi
-
-done
-
-for ac_header in net/if_dl.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "net/if_dl.h" "ac_cv_header_net_if_dl_h" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-"
-if test "x$ac_cv_header_net_if_dl_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NET_IF_DL_H 1
-_ACEOF
-
-fi
-
-done
-
-
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_flags" "ac_cv_member_struct_ifreq_ifr_flags" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_flags" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_FLAGS 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_hwaddr" "ac_cv_member_struct_ifreq_ifr_hwaddr" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_hwaddr" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_HWADDR 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_netmask" "ac_cv_member_struct_ifreq_ifr_netmask" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_netmask" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_NETMASK 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_broadaddr" "ac_cv_member_struct_ifreq_ifr_broadaddr" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_broadaddr" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_BROADADDR 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_addr" "ac_cv_member_struct_ifreq_ifr_addr" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_addr" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_ADDR 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "struct ifreq" "ifr_addr.sa_len" "ac_cv_member_struct_ifreq_ifr_addr_sa_len" "$ac_includes_default
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-#include <net/if.h>
-#endif
-"
-if test "x$ac_cv_member_struct_ifreq_ifr_addr_sa_len" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN 1
-_ACEOF
-
-
-fi
-
-
-
-
-DEPFLAGS=
-MKDEPDIR=":"
-deps_frag=deps.mk
-if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using GNU Make" >&5
-$as_echo_n "checking whether we are using GNU Make... " >&6; }
-   HAVE_GNU_MAKE=no
-   testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'`
-   if test "x$testval" != x; then
-      HAVE_GNU_MAKE=yes
-   else
-      ac_enable_autodepend=no
-   fi
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_GNU_MAKE" >&5
-$as_echo "$HAVE_GNU_MAKE" >&6; }
-   if test $HAVE_GNU_MAKE = yes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc understands -MMD -MF" >&5
-$as_echo_n "checking whether gcc understands -MMD -MF... " >&6; }
-      SAVE_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  ac_enable_autodepend=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      CFLAGS="$SAVE_CFLAGS"
-      test -f deps.d || ac_enable_autodepend=no
-      rm -rf deps.d
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_enable_autodepend" >&5
-$as_echo "$ac_enable_autodepend" >&6; }
-   fi
-   if test $ac_enable_autodepend = yes; then
-      DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP'
-      ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe.
-      MKDEPDIR='${MKDIR_P} ${DEPDIR}'
-      deps_frag=autodeps.mk
-   fi
-fi
-deps_frag=$srcdir/src/$deps_frag
-
-
-
-
-
-lisp_frag=$srcdir/src/lisp.mk
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for long file names" >&5
-$as_echo_n "checking for long file names... " >&6; }
-if test "${ac_cv_sys_long_file_names+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_sys_long_file_names=yes
-# Test for long file names in all the places we know might matter:
-#      .               the current directory, where building will happen
-#      $prefix/lib     where we will be installing things
-#      $exec_prefix/lib        likewise
-#      $TMPDIR         if set, where it might want to write temporary files
-#      /tmp            where it might want to write temporary files
-#      /var/tmp                likewise
-#      /usr/tmp                likewise
-for ac_dir in . "$TMPDIR" /tmp /var/tmp /usr/tmp "$prefix/lib" "$exec_prefix/lib"; do
-  # Skip $TMPDIR if it is empty or bogus, and skip $exec_prefix/lib
-  # in the usual case where exec_prefix is '${prefix}'.
-  case $ac_dir in #(
-    . | /* | ?:[\\/]*) ;; #(
-    *) continue;;
-  esac
-  test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
-  ac_xdir=$ac_dir/cf$$
-  (umask 077 && mkdir "$ac_xdir" 2>/dev/null) || continue
-  ac_tf1=$ac_xdir/conftest9012345
-  ac_tf2=$ac_xdir/conftest9012346
-  touch "$ac_tf1" 2>/dev/null && test -f "$ac_tf1" && test ! -f "$ac_tf2" ||
-    ac_cv_sys_long_file_names=no
-  rm -f -r "$ac_xdir" 2>/dev/null
-  test $ac_cv_sys_long_file_names = no && break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_long_file_names" >&5
-$as_echo "$ac_cv_sys_long_file_names" >&6; }
-if test $ac_cv_sys_long_file_names = yes; then
-
-$as_echo "#define HAVE_LONG_FILE_NAMES 1" >>confdefs.h
-
-fi
-
-
-#### Choose a window system.
-
-## We leave window_system equal to none if
-## we end up building without one.  Any new window system should
-## set window_system to an appropriate value and add objects to
-## window-system-specific substs.
-
-window_system=none
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5
-$as_echo_n "checking for X... " >&6; }
-
-
-# Check whether --with-x was given.
-if test "${with_x+set}" = set; then :
-  withval=$with_x;
-fi
-
-# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
-if test "x$with_x" = xno; then
-  # The user explicitly disabled X.
-  have_x=disabled
-else
-  case $x_includes,$x_libraries in #(
-    *\'*) as_fn_error "cannot use X directory names containing '" "$LINENO" 5;; #(
-    *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # One or both of the vars are not set, and there is no cached value.
-ac_x_includes=no ac_x_libraries=no
-rm -f -r conftest.dir
-if mkdir conftest.dir; then
-  cd conftest.dir
-  cat >Imakefile <<'_ACEOF'
-incroot:
-       @echo incroot='${INCROOT}'
-usrlibdir:
-       @echo usrlibdir='${USRLIBDIR}'
-libdir:
-       @echo libdir='${LIBDIR}'
-_ACEOF
-  if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
-    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-    for ac_var in incroot usrlibdir libdir; do
-      eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
-    done
-    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
-    for ac_extension in a so sl dylib la dll; do
-      if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
-        test -f "$ac_im_libdir/libX11.$ac_extension"; then
-       ac_im_usrlibdir=$ac_im_libdir; break
-      fi
-    done
-    # Screen out bogus values from the imake configuration.  They are
-    # bogus both because they are the default anyway, and because
-    # using them would break gcc on systems where it needs fixed includes.
-    case $ac_im_incroot in
-       /usr/include) ac_x_includes= ;;
-       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
-    esac
-    case $ac_im_usrlibdir in
-       /usr/lib | /usr/lib64 | /lib | /lib64) ;;
-       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
-    esac
-  fi
-  cd ..
-  rm -f -r conftest.dir
-fi
-
-# Standard set of common directories for X headers.
-# Check X11 before X11Rn because it is often a symlink to the current release.
-ac_x_header_dirs='
-/usr/X11/include
-/usr/X11R7/include
-/usr/X11R6/include
-/usr/X11R5/include
-/usr/X11R4/include
-
-/usr/include/X11
-/usr/include/X11R7
-/usr/include/X11R6
-/usr/include/X11R5
-/usr/include/X11R4
-
-/usr/local/X11/include
-/usr/local/X11R7/include
-/usr/local/X11R6/include
-/usr/local/X11R5/include
-/usr/local/X11R4/include
-
-/usr/local/include/X11
-/usr/local/include/X11R7
-/usr/local/include/X11R6
-/usr/local/include/X11R5
-/usr/local/include/X11R4
-
-/usr/X386/include
-/usr/x386/include
-/usr/XFree86/include/X11
-
-/usr/include
-/usr/local/include
-/usr/unsupported/include
-/usr/athena/include
-/usr/local/x11r5/include
-/usr/lpp/Xamples/include
-
-/usr/openwin/include
-/usr/openwin/share/include'
-
-if test "$ac_x_includes" = no; then
-  # Guess where to find include files, by looking for Xlib.h.
-  # First, try using that file with no special directory specified.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # We can compile using X headers with no special include directory.
-ac_x_includes=
-else
-  for ac_dir in $ac_x_header_dirs; do
-  if test -r "$ac_dir/X11/Xlib.h"; then
-    ac_x_includes=$ac_dir
-    break
-  fi
-done
-fi
-rm -f conftest.err conftest.$ac_ext
-fi # $ac_x_includes = no
-
-if test "$ac_x_libraries" = no; then
-  # Check for the libraries.
-  # See if we find them without any special options.
-  # Don't add to $LIBS permanently.
-  ac_save_LIBS=$LIBS
-  LIBS="-lX11 $LIBS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-XrmInitialize ()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  LIBS=$ac_save_LIBS
-# We can link X programs with no special library path.
-ac_x_libraries=
-else
-  LIBS=$ac_save_LIBS
-for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
-do
-  # Don't even attempt the hair of trying to link an X program!
-  for ac_extension in a so sl dylib la dll; do
-    if test -r "$ac_dir/libX11.$ac_extension"; then
-      ac_x_libraries=$ac_dir
-      break 2
-    fi
-  done
-done
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi # $ac_x_libraries = no
-
-case $ac_x_includes,$ac_x_libraries in #(
-  no,* | *,no | *\'*)
-    # Didn't find X, or a directory has "'" in its name.
-    ac_cv_have_x="have_x=no";; #(
-  *)
-    # Record where we found X for the cache.
-    ac_cv_have_x="have_x=yes\
-       ac_x_includes='$ac_x_includes'\
-       ac_x_libraries='$ac_x_libraries'"
-esac
-fi
-;; #(
-    *) have_x=yes;;
-  esac
-  eval "$ac_cv_have_x"
-fi # $with_x != no
-
-if test "$have_x" != yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5
-$as_echo "$have_x" >&6; }
-  no_x=yes
-else
-  # If each of the values was on the command line, it overrides each guess.
-  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
-  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
-  # Update the cache value to reflect the command line values.
-  ac_cv_have_x="have_x=yes\
-       ac_x_includes='$x_includes'\
-       ac_x_libraries='$x_libraries'"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5
-$as_echo "libraries $x_libraries, headers $x_includes" >&6; }
-fi
-
-if test "$no_x" != yes; then
-  window_system=x11
-fi
-
-LD_SWITCH_X_SITE_RPATH=
-if test "${x_libraries}" != NONE; then
-  if test -n "${x_libraries}"; then
-    LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
-    LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"`
-  fi
-  x_default_search_path=""
-  x_search_path=${x_libraries}
-  if test -z "${x_search_path}"; then
-    x_search_path=/usr/lib
-  fi
-  for x_library in `echo ${x_search_path}: | \
-                   sed -e "s/:/ /g" -e p -e "s:/lib[^ /]* :/share :g"`; do
-    x_search_path="\
-${x_library}/X11/%L/%T/%N%C%S:\
-${x_library}/X11/%l/%T/%N%C%S:\
-${x_library}/X11/%T/%N%C%S:\
-${x_library}/X11/%L/%T/%N%S:\
-${x_library}/X11/%l/%T/%N%S:\
-${x_library}/X11/%T/%N%S"
-    if test x"${x_default_search_path}" = x; then
-      x_default_search_path=${x_search_path}
-    else
-      x_default_search_path="${x_search_path}:${x_default_search_path}"
-    fi
-  done
-fi
-
-
-if test "${x_includes}" != NONE && test -n "${x_includes}"; then
-  C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
-fi
-
-if test x"${x_includes}" = x; then
-  bitmapdir=/usr/include/X11/bitmaps
-else
-  # accumulate include directories that have X11 bitmap subdirectories
-  bmd_acc="dummyval"
-  for bmd in `echo ${x_includes} | sed -e "s/:/ /g"`; do
-    if test -d "${bmd}/X11/bitmaps"; then
-      bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
-    fi
-    if test -d "${bmd}/bitmaps"; then
-      bmd_acc="${bmd_acc}:${bmd}/bitmaps"
-    fi
-  done
-  if test ${bmd_acc} != "dummyval"; then
-    bitmapdir=`echo ${bmd_acc} | sed -e "s/^dummyval://"`
-  fi
-fi
-
-HAVE_NS=no
-NS_IMPL_COCOA=no
-NS_IMPL_GNUSTEP=no
-tmp_CPPFLAGS="$CPPFLAGS"
-tmp_CFLAGS="$CFLAGS"
-CPPFLAGS="$CPPFLAGS -x objective-c"
-CFLAGS="$CFLAGS -x objective-c"
-GNU_OBJC_CFLAGS=
-LIBS_GNUSTEP=
-if test "${with_ns}" != no; then
-  if test "${opsys}" = darwin; then
-     NS_IMPL_COCOA=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app
-     ns_appbindir=${ns_appdir}/Contents/MacOS
-     ns_appresdir=${ns_appdir}/Contents/Resources
-     ns_appsrc=Cocoa/Emacs.base
-  elif test -f $GNUSTEP_CONFIG_FILE; then
-     NS_IMPL_GNUSTEP=yes
-     ns_appdir=`pwd`/nextstep/Emacs.app
-     ns_appbindir=${ns_appdir}
-     ns_appresdir=${ns_appdir}/Resources
-     ns_appsrc=GNUstep/Emacs.base
-          GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
-     GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
-          GNUSTEP_LOCAL_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_HEADERS)"
-     GNUSTEP_LOCAL_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_LIBRARIES)"
-     test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
-       GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
-     test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
-       GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
-     CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
-     CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
-     LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
-     LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS" >&5
-$as_echo_n "checking if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS... " >&6; }
-if test "${emacs_cv_objc_exceptions+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <GNUstepBase/GSConfig.h>
-int
-main ()
-{
-#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
-1;
-#else
-fail;
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_objc_exceptions=yes
-else
-  emacs_cv_objc_exceptions=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_objc_exceptions" >&5
-$as_echo "$emacs_cv_objc_exceptions" >&6; }
-     if test $emacs_cv_objc_exceptions = yes; then
-
-$as_echo "#define _NATIVE_OBJC_EXCEPTIONS 1" >>confdefs.h
-
-       GNU_OBJC_CFLAGS="-fobjc-exceptions"
-     fi
-  fi
-
-    CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
-
-  ac_fn_c_check_header_mongrel "$LINENO" "AppKit/AppKit.h" "ac_cv_header_AppKit_AppKit_h" "$ac_includes_default"
-if test "x$ac_cv_header_AppKit_AppKit_h" = x""yes; then :
-  HAVE_NS=yes
-else
-  as_fn_error "\`--with-ns' was specified, but the include
-  files are missing or cannot be compiled." "$LINENO" 5
-fi
-
-
-
-  macfont_file=""
-  if test "${NS_IMPL_COCOA}" = "yes"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OSX 10.4 or newer" >&5
-$as_echo_n "checking for OSX 10.4 or newer... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <AppKit/AppKit.h>
-int
-main ()
-{
-
-#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
- ; /* OK */
-#else
-#error "OSX 10.4 or newer required"
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ns_osx_have_104=yes
-else
-  ns_osx_have_104=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ns_osx_have_104" >&5
-$as_echo "$ns_osx_have_104" >&6; }
-
-    if test $ns_osx_have_104 = no; then
-       as_fn_error "\`OSX 10.4 or newer is required'" "$LINENO" 5;
-    fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OSX 10.5 or newer" >&5
-$as_echo_n "checking for OSX 10.5 or newer... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <AppKit/AppKit.h>
-int
-main ()
-{
-
-#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
- ; /* OK */
-#else
-#error "OSX 10.5 not found"
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ns_osx_have_105=yes
-else
-  ns_osx_have_105=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ns_osx_have_105" >&5
-$as_echo "$ns_osx_have_105" >&6; }
-    if test $ns_osx_have_105 = yes; then
-      macfont_file="macfont.o"
-    fi
-  fi
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <Foundation/NSObjCRuntime.h>
-int
-main ()
-{
-NSInteger i;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ns_have_nsinteger=yes
-else
-  ns_have_nsinteger=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  if test $ns_have_nsinteger = yes; then
-
-$as_echo "#define NS_HAVE_NSINTEGER 1" >>confdefs.h
-
-  fi
-fi
-
-
-
-INSTALL_ARCH_INDEP_EXTRA=install-etc
-ns_self_contained=no
-NS_OBJ=
-NS_OBJC_OBJ=
-if test "${HAVE_NS}" = yes; then
-  if test "$with_toolkit_scroll_bars" = "no"; then
-    as_fn_error "Non-toolkit scroll bars are not implemented for Nextstep." "$LINENO" 5
-  fi
-
-  window_system=nextstep
-  # set up packaging dirs
-  if test "${EN_NS_SELF_CONTAINED}" = yes; then
-     ns_self_contained=yes
-     prefix=${ns_appresdir}
-     exec_prefix=${ns_appbindir}
-          libexecdir="\${ns_appbindir}/libexec"
-     archlibdir="\${ns_appbindir}/libexec"
-     etcdocdir="\${ns_appresdir}/etc"
-     etcdir="\${ns_appresdir}/etc"
-               infodir="\${ns_appresdir}/info"
-     mandir="\${ns_appresdir}/man"
-     lispdir="\${ns_appresdir}/lisp"
-     leimdir="\${ns_appresdir}/leim"
-     INSTALL_ARCH_INDEP_EXTRA=
-  fi
-
-  NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o $macfont_file"
-fi
-CFLAGS="$tmp_CFLAGS"
-CPPFLAGS="$tmp_CPPFLAGS"
-
-
-
-
-
-HAVE_W32=no
-W32_OBJ=
-W32_LIBS=
-EMACSRES=
-CLIENTRES=
-CLIENTW=
-W32_RES_LINK=
-EMACS_MANIFEST=
-UPDATE_MANIFEST=
-if test "${with_w32}" != no; then
-  case "${opsys}" in
-    cygwin)
-      ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
-if test "x$ac_cv_header_windows_h" = x""yes; then :
-  HAVE_W32=yes
-else
-  as_fn_error "\`--with-w32' was specified, but windows.h
-                   cannot be found." "$LINENO" 5
-fi
-
-
-    ;;
-    mingw32)
-    ## Using --with-w32 with MinGW is a no-op, but we allow it.
-    ;;
-    *)
-      as_fn_error "Using w32 with an autotools build is only supported for Cygwin and MinGW32." "$LINENO" 5
-    ;;
-  esac
-fi
-
-if test "${opsys}" = "mingw32"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether Windows API headers are recent enough" >&5
-$as_echo_n "checking whether Windows API headers are recent enough... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-     #include <windows.h>
-     #include <usp10.h>
-int
-main ()
-{
-PIMAGE_NT_HEADERS pHeader;
-     PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_w32api=yes
-    HAVE_W32=yes
-else
-  emacs_cv_w32api=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_w32api" >&5
-$as_echo "$emacs_cv_w32api" >&6; }
-  if test "${emacs_cv_w32api}" = "no"; then
-    as_fn_error "the Windows API headers are too old to support this build." "$LINENO" 5
-  fi
-fi
-
-FIRSTFILE_OBJ=
-NTDIR=
-LIBS_ECLIENT=
-LIB_WSOCK32=
-NTLIB=
-CM_OBJ="cm.o"
-XARGS_LIMIT=
-if test "${HAVE_W32}" = "yes"; then
-
-$as_echo "#define HAVE_NTGUI 1" >>confdefs.h
-
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
-set dummy ${ac_tool_prefix}windres; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_WINDRES+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$WINDRES"; then
-  ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_WINDRES="${ac_tool_prefix}windres"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-WINDRES=$ac_cv_prog_WINDRES
-if test -n "$WINDRES"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5
-$as_echo "$WINDRES" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_WINDRES"; then
-  ac_ct_WINDRES=$WINDRES
-  # Extract the first word of "windres", so it can be a program name with args.
-set dummy windres; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_WINDRES+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_WINDRES"; then
-  ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_WINDRES="windres"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES
-if test -n "$ac_ct_WINDRES"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_WINDRES" >&5
-$as_echo "$ac_ct_WINDRES" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_WINDRES" = x; then
-    WINDRES="as_fn_error "No resource compiler found." "$LINENO" 5"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    WINDRES=$ac_ct_WINDRES
-  fi
-else
-  WINDRES="$ac_cv_prog_WINDRES"
-fi
-
-  W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
-  W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
-  EMACSRES="emacs.res"
-  case "$canonical" in
-    x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
-    *) EMACS_MANIFEST="emacs-x86.manifest" ;;
-  esac
-  UPDATE_MANIFEST=update-game-score.exe.manifest
-  if test "${opsys}" = "cygwin"; then
-    W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
-    W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
-    # Tell the linker that emacs.res is an object (which we compile from
-    # the rc file), not a linker script.
-    W32_RES_LINK="-Wl,emacs.res"
-  else
-    W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
-    W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
-    W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
-    W32_RES_LINK="\$(EMACSRES)"
-    CLIENTRES="emacsclient.res"
-    CLIENTW="emacsclientw\$(EXEEXT)"
-    FIRSTFILE_OBJ=firstfile.o
-    NTDIR=nt
-    CM_OBJ=
-    LIBS_ECLIENT="-lcomctl32"
-    LIB_WSOCK32="-lwsock32"
-    NTLIB="ntlib.$ac_objext"
-    XARGS_LIMIT="-s 10000"
-  fi
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-if test "${HAVE_W32}" = "yes"; then
-  window_system=w32
-  with_xft=no
-fi
-
-## $window_system is now set to the window system we will
-## ultimately use.
-
-if test "$window_system" = none && test "$gl_gcc_warnings" = yes; then
-   # Too many warnings for now.
-   nw=
-   nw="$nw -Wsuggest-attribute=const"
-   nw="$nw -Wsuggest-attribute=noreturn"
-
-  gl_warn_set=
-  set x $WARN_CFLAGS; shift
-  for gl_warn_item
-  do
-    case " $nw " in
-      *" $gl_warn_item "*)
-        ;;
-      *)
-        gl_warn_set="$gl_warn_set $gl_warn_item"
-        ;;
-    esac
-  done
-  WARN_CFLAGS=$gl_warn_set
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-variable" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-variable... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_variable+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-variable"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_variable=yes
-else
-  gl_cv_warn_c__Wno_unused_variable=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_variable" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_variable" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_variable" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-variable"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-but-set-variable" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-but-set-variable... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_but_set_variable+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-but-set-variable"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_but_set_variable=yes
-else
-  gl_cv_warn_c__Wno_unused_but_set_variable=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_but_set_variable" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_but_set_variable" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_but_set_variable" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-but-set-variable"
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler handles -Wno-unused-but-set-parameter" >&5
-$as_echo_n "checking whether C compiler handles -Wno-unused-but-set-parameter... " >&6; }
-if test "${gl_cv_warn_c__Wno_unused_but_set_parameter+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  gl_save_compiler_FLAGS="$CFLAGS"
-  as_fn_append CFLAGS " $gl_unknown_warnings_are_errors -Wunused-but-set-parameter"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_warn_c__Wno_unused_but_set_parameter=yes
-else
-  gl_cv_warn_c__Wno_unused_but_set_parameter=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  CFLAGS="$gl_save_compiler_FLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn_c__Wno_unused_but_set_parameter" >&5
-$as_echo "$gl_cv_warn_c__Wno_unused_but_set_parameter" >&6; }
-if test "x$gl_cv_warn_c__Wno_unused_but_set_parameter" = x""yes; then :
-  as_fn_append WARN_CFLAGS " -Wno-unused-but-set-parameter"
-fi
-
-
-fi
-
-term_header=
-HAVE_X_WINDOWS=no
-HAVE_X11=no
-USE_X_TOOLKIT=none
-
-case "${window_system}" in
-  x11 )
-    HAVE_X_WINDOWS=yes
-    HAVE_X11=yes
-    term_header=xterm.h
-    case "${with_x_toolkit}" in
-      athena | lucid ) USE_X_TOOLKIT=LUCID ;;
-      motif ) USE_X_TOOLKIT=MOTIF ;;
-      gtk ) with_gtk=yes
-            term_header=gtkutil.h
-            USE_X_TOOLKIT=none ;;
-      gtk2 ) with_gtk2=yes
-             term_header=gtkutil.h
-             USE_X_TOOLKIT=none ;;
-      gtk3 ) with_gtk3=yes
-             term_header=gtkutil.h
-             USE_X_TOOLKIT=none ;;
-      no ) USE_X_TOOLKIT=none ;;
-      * ) USE_X_TOOLKIT=maybe ;;
-    esac
-  ;;
-  nextstep )
-    term_header=nsterm.h
-  ;;
-  w32 )
-    term_header=w32term.h
-  ;;
-esac
-
-if test "$window_system" = none && test "X$with_x" != "Xno"; then
-   # Extract the first word of "X", so it can be a program name with args.
-set dummy X; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_HAVE_XSERVER+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$HAVE_XSERVER"; then
-  ac_cv_prog_HAVE_XSERVER="$HAVE_XSERVER" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_HAVE_XSERVER="true"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_prog_HAVE_XSERVER" && ac_cv_prog_HAVE_XSERVER="false"
-fi
-fi
-HAVE_XSERVER=$ac_cv_prog_HAVE_XSERVER
-if test -n "$HAVE_XSERVER"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_XSERVER" >&5
-$as_echo "$HAVE_XSERVER" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-   if test "$HAVE_XSERVER" = true ||
-      test -n "$DISPLAY" ||
-      test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
-        as_fn_error "You seem to be running X, but no X development libraries
-were found.  You should install the relevant development files for X
-and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
-sure you have development files for image handling, i.e.
-tiff, gif, jpeg, png and xpm.
-If you are sure you want Emacs compiled without X window support, pass
-  --without-x
-to configure." "$LINENO" 5
-   fi
-fi
-
-### We always support menus.
-HAVE_MENUS=yes
-
-# Does the opsystem file prohibit the use of the GNU malloc?
-# Assume not, until told otherwise.
-GNU_MALLOC=yes
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether malloc is Doug Lea style" >&5
-$as_echo_n "checking whether malloc is Doug Lea style... " >&6; }
-if test "${emacs_cv_var_doug_lea_malloc+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <malloc.h>
-         static void hook (void) {}
-int
-main ()
-{
-malloc_set_state (malloc_get_state ());
-         __after_morecore_hook = hook;
-         __malloc_initialize_hook = hook;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_var_doug_lea_malloc=yes
-else
-  emacs_cv_var_doug_lea_malloc=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_var_doug_lea_malloc" >&5
-$as_echo "$emacs_cv_var_doug_lea_malloc" >&6; }
-doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
-
-
-system_malloc=no
-case "$opsys" in
-  ## darwin ld insists on the use of malloc routines in the System framework.
-  darwin|sol2-10) system_malloc=yes ;;
-esac
-
-if test "${system_malloc}" = "yes"; then
-
-$as_echo "#define SYSTEM_MALLOC 1" >>confdefs.h
-
-  GNU_MALLOC=no
-  GNU_MALLOC_reason="
-    (The GNU allocators don't work with this system configuration.)"
-  GMALLOC_OBJ=
-  VMLIMIT_OBJ=
-else
-  test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
-  VMLIMIT_OBJ=vm-limit.o
-
-  for ac_header in sys/vlimit.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/vlimit.h" "ac_cv_header_sys_vlimit_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_vlimit_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_VLIMIT_H 1
-_ACEOF
-
-fi
-
-done
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for data_start" >&5
-$as_echo_n "checking for data_start... " >&6; }
-if test "${emacs_cv_data_start+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char data_start[]; char ch;
-int
-main ()
-{
-return data_start < &ch;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_data_start=yes
-else
-  emacs_cv_data_start=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_data_start" >&5
-$as_echo "$emacs_cv_data_start" >&6; }
-  if test $emacs_cv_data_start = yes; then
-
-$as_echo "#define HAVE_DATA_START 1" >>confdefs.h
-
-  fi
-fi
-
-
-
-if test "$doug_lea_malloc" = "yes" ; then
-  if test "$GNU_MALLOC" = yes ; then
-    GNU_MALLOC_reason="
-      (Using Doug Lea's new malloc from the GNU C Library.)"
-  fi
-
-$as_echo "#define DOUG_LEA_MALLOC 1" >>confdefs.h
-
-
-  ## Use mmap directly for allocating larger buffers.
-  ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
-  ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
-  ## Does the AC_FUNC_MMAP test below make this check unnecessary?
-  case "$opsys" in
-    gnu*) REL_ALLOC=no ;;
-  esac
-fi
-
-if test x"${REL_ALLOC}" = x; then
-  REL_ALLOC=${GNU_MALLOC}
-fi
-
-use_mmap_for_buffers=no
-case "$opsys" in
-  cygwin|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
-esac
-
-
-
-
-
-
-
-
-for ac_func in getpagesize
-do :
-  ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize"
-if test "x$ac_cv_func_getpagesize" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GETPAGESIZE 1
-_ACEOF
-
-fi
-done
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5
-$as_echo_n "checking for working mmap... " >&6; }
-if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  ac_cv_func_mmap_fixed_mapped=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-/* malloc might have been renamed as rpl_malloc. */
-#undef malloc
-
-/* Thanks to Mike Haertel and Jim Avera for this test.
-   Here is a matrix of mmap possibilities:
-       mmap private not fixed
-       mmap private fixed at somewhere currently unmapped
-       mmap private fixed at somewhere already mapped
-       mmap shared not fixed
-       mmap shared fixed at somewhere currently unmapped
-       mmap shared fixed at somewhere already mapped
-   For private mappings, we should verify that changes cannot be read()
-   back from the file, nor mmap's back from the file at a different
-   address.  (There have been systems where private was not correctly
-   implemented like the infamous i386 svr4.0, and systems where the
-   VM page cache was not coherent with the file system buffer cache
-   like early versions of FreeBSD and possibly contemporary NetBSD.)
-   For shared mappings, we should conversely verify that changes get
-   propagated back to all the places they're supposed to be.
-
-   Grep wants private fixed already mapped.
-   The main things grep needs to know about mmap are:
-   * does it exist and is it safe to write into the mmap'd area
-   * how to use it (BSD variants)  */
-
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
-char *malloc ();
-#endif
-
-/* This mess was copied from the GNU getpagesize.h.  */
-#ifndef HAVE_GETPAGESIZE
-# ifdef _SC_PAGESIZE
-#  define getpagesize() sysconf(_SC_PAGESIZE)
-# else /* no _SC_PAGESIZE */
-#  ifdef HAVE_SYS_PARAM_H
-#   include <sys/param.h>
-#   ifdef EXEC_PAGESIZE
-#    define getpagesize() EXEC_PAGESIZE
-#   else /* no EXEC_PAGESIZE */
-#    ifdef NBPG
-#     define getpagesize() NBPG * CLSIZE
-#     ifndef CLSIZE
-#      define CLSIZE 1
-#     endif /* no CLSIZE */
-#    else /* no NBPG */
-#     ifdef NBPC
-#      define getpagesize() NBPC
-#     else /* no NBPC */
-#      ifdef PAGESIZE
-#       define getpagesize() PAGESIZE
-#      endif /* PAGESIZE */
-#     endif /* no NBPC */
-#    endif /* no NBPG */
-#   endif /* no EXEC_PAGESIZE */
-#  else /* no HAVE_SYS_PARAM_H */
-#   define getpagesize() 8192  /* punt totally */
-#  endif /* no HAVE_SYS_PARAM_H */
-# endif /* no _SC_PAGESIZE */
-
-#endif /* no HAVE_GETPAGESIZE */
-
-int
-main ()
-{
-  char *data, *data2, *data3;
-  const char *cdata2;
-  int i, pagesize;
-  int fd, fd2;
-
-  pagesize = getpagesize ();
-
-  /* First, make a file with some known garbage in it. */
-  data = (char *) malloc (pagesize);
-  if (!data)
-    return 1;
-  for (i = 0; i < pagesize; ++i)
-    *(data + i) = rand ();
-  umask (0);
-  fd = creat ("conftest.mmap", 0600);
-  if (fd < 0)
-    return 2;
-  if (write (fd, data, pagesize) != pagesize)
-    return 3;
-  close (fd);
-
-  /* Next, check that the tail of a page is zero-filled.  File must have
-     non-zero length, otherwise we risk SIGBUS for entire page.  */
-  fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600);
-  if (fd2 < 0)
-    return 4;
-  cdata2 = "";
-  if (write (fd2, cdata2, 1) != 1)
-    return 5;
-  data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L);
-  if (data2 == MAP_FAILED)
-    return 6;
-  for (i = 0; i < pagesize; ++i)
-    if (*(data2 + i))
-      return 7;
-  close (fd2);
-  if (munmap (data2, pagesize))
-    return 8;
-
-  /* Next, try to mmap the file at a fixed address which already has
-     something else allocated at it.  If we can, also make sure that
-     we see the same garbage.  */
-  fd = open ("conftest.mmap", O_RDWR);
-  if (fd < 0)
-    return 9;
-  if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
-                    MAP_PRIVATE | MAP_FIXED, fd, 0L))
-    return 10;
-  for (i = 0; i < pagesize; ++i)
-    if (*(data + i) != *(data2 + i))
-      return 11;
-
-  /* Finally, make sure that changes to the mapped area do not
-     percolate back to the file as seen by read().  (This is a bug on
-     some variants of i386 svr4.0.)  */
-  for (i = 0; i < pagesize; ++i)
-    *(data2 + i) = *(data2 + i) + 1;
-  data3 = (char *) malloc (pagesize);
-  if (!data3)
-    return 12;
-  if (read (fd, data3, pagesize) != pagesize)
-    return 13;
-  for (i = 0; i < pagesize; ++i)
-    if (*(data + i) != *(data3 + i))
-      return 14;
-  close (fd);
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_func_mmap_fixed_mapped=yes
-else
-  ac_cv_func_mmap_fixed_mapped=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5
-$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; }
-if test $ac_cv_func_mmap_fixed_mapped = yes; then
-
-$as_echo "#define HAVE_MMAP 1" >>confdefs.h
-
-fi
-rm -f conftest.mmap conftest.txt
-
-if test $use_mmap_for_buffers = yes; then
-
-$as_echo "#define USE_MMAP_FOR_BUFFERS 1" >>confdefs.h
-
-  REL_ALLOC=no
-fi
-
-LIBS="$LIBS_SYSTEM $LIBS"
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5
-$as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; }
-if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_ntoa ();
-int
-main ()
-{
-return dnet_ntoa ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dnet_dnet_ntoa=yes
-else
-  ac_cv_lib_dnet_dnet_ntoa=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
-$as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
-if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDNET 1
-_ACEOF
-
-  LIBS="-ldnet $LIBS"
-
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lXbsd" >&5
-$as_echo_n "checking for main in -lXbsd... " >&6; }
-if test "${ac_cv_lib_Xbsd_main+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-int
-main ()
-{
-return main ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xbsd_main=yes
-else
-  ac_cv_lib_Xbsd_main=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xbsd_main" >&5
-$as_echo "$ac_cv_lib_Xbsd_main" >&6; }
-if test "x$ac_cv_lib_Xbsd_main" = x""yes; then :
-  LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd"
-fi
-
-
-LIB_PTHREAD=
-
-
-
-if test "$ac_cv_header_pthread_h"; then
-        if test "$GMALLOC_OBJ" = gmalloc.o; then
-    emacs_pthread_function=pthread_atfork
-  else
-    emacs_pthread_function=pthread_self
-  fi
-  as_ac_Lib=`$as_echo "ac_cv_lib_pthread_$emacs_pthread_function" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $emacs_pthread_function in -lpthread" >&5
-$as_echo_n "checking for $emacs_pthread_function in -lpthread... " >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthread  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $emacs_pthread_function ();
-int
-main ()
-{
-return $emacs_pthread_function ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  eval "$as_ac_Lib=yes"
-else
-  eval "$as_ac_Lib=no"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-eval ac_res=\$$as_ac_Lib
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-eval as_val=\$$as_ac_Lib
-   if test "x$as_val" = x""yes; then :
-  HAVE_PTHREAD=yes
-fi
-
-fi
-if test "$HAVE_PTHREAD" = yes; then
-  case "${canonical}" in
-    *-hpux*) ;;
-    *) LIB_PTHREAD="-lpthread"
-       LIBS="$LIB_PTHREAD $LIBS" ;;
-  esac
-
-$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
-
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cma_open in -lpthreads" >&5
-$as_echo_n "checking for cma_open in -lpthreads... " >&6; }
-if test "${ac_cv_lib_pthreads_cma_open+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpthreads  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char cma_open ();
-int
-main ()
-{
-return cma_open ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_pthreads_cma_open=yes
-else
-  ac_cv_lib_pthreads_cma_open=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_cma_open" >&5
-$as_echo "$ac_cv_lib_pthreads_cma_open" >&6; }
-if test "x$ac_cv_lib_pthreads_cma_open" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPTHREADS 1
-_ACEOF
-
-  LIBS="-lpthreads $LIBS"
-
-fi
-
-
-## Note: when using cpp in s/aix4.2.h, this definition depended on
-## HAVE_LIBPTHREADS.  That was not defined earlier in configure when
-## the system file was sourced.  Hence the value of LIBS_SYSTEM
-## added to LIBS in configure would never contain the pthreads part,
-## but the value used in Makefiles might.  FIXME?
-##
-## -lpthreads seems to be necessary for Xlib in X11R6, and should
-## be harmless on older versions of X where it happens to exist.
-test "$opsys" = "aix4-2" && \
-  test $ac_cv_lib_pthreads_cma_open = yes && \
-  LIBS_SYSTEM="$LIBS_SYSTEM -lpthreads"
-
-
-case ${host_os} in
-aix*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -bbigtoc option" >&5
-$as_echo_n "checking for -bbigtoc option... " >&6; }
-if test "${gdb_cv_bigtoc+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    case $GCC in
-    yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
-    *) gdb_cv_bigtoc=-bbigtoc ;;
-    esac
-
-    LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-int i;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  gdb_cv_bigtoc=
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_bigtoc" >&5
-$as_echo "$gdb_cv_bigtoc" >&6; }
-  ;;
-esac
-
-# Change CFLAGS and CPPFLAGS temporarily so that C_SWITCH_X_SITE gets
-# used for the tests that follow.  We set them back to REAL_CFLAGS and
-# REAL_CPPFLAGS later on.
-
-REAL_CFLAGS="$CFLAGS"
-REAL_CPPFLAGS="$CPPFLAGS"
-
-if test "${HAVE_X11}" = "yes"; then
-  DEFS="$C_SWITCH_X_SITE $DEFS"
-  LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
-  LIBS="-lX11 $LIBS"
-  CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
-  CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
-
-  # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
-  # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
-  # but it's more convenient here to set LD_RUN_PATH since this
-  # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
-  if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
-    LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
-    export LD_RUN_PATH
-  fi
-
-  if test "${opsys}" = "gnu-linux"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether X on GNU/Linux needs -b to link" >&5
-$as_echo_n "checking whether X on GNU/Linux needs -b to link... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-XOpenDisplay ("foo");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  xgnu_linux_first_failure=no
-else
-  xgnu_linux_first_failure=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    if test "${xgnu_linux_first_failure}" = "yes"; then
-      OLD_LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE"
-      OLD_C_SWITCH_X_SITE="$C_SWITCH_X_SITE"
-      OLD_CPPFLAGS="$CPPFLAGS"
-      OLD_LIBS="$LIBS"
-      LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
-      C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
-      CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
-      LIBS="$LIBS -b i486-linuxaout"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-XOpenDisplay ("foo");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  xgnu_linux_second_failure=no
-else
-  xgnu_linux_second_failure=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-      if test "${xgnu_linux_second_failure}" = "yes"; then
-       # If we get the same failure with -b, there is no use adding -b.
-       # So take it out.  This plays safe.
-       LD_SWITCH_X_SITE="$OLD_LD_SWITCH_X_SITE"
-       C_SWITCH_X_SITE="$OLD_C_SWITCH_X_SITE"
-       CPPFLAGS="$OLD_CPPFLAGS"
-       LIBS="$OLD_LIBS"
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-      else
-        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-      fi
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    fi
-  fi
-
-  # Reportedly, some broken Solaris systems have XKBlib.h but are missing
-  # header files included from there.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Xkb" >&5
-$as_echo_n "checking for Xkb... " >&6; }
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-#include <X11/XKBlib.h>
-int
-main ()
-{
-XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_xkb=yes
-else
-  emacs_xkb=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_xkb" >&5
-$as_echo "$emacs_xkb" >&6; }
-  if test $emacs_xkb = yes; then
-
-$as_echo "#define HAVE_XKB 1" >>confdefs.h
-
-  fi
-
-  for ac_func in XrmSetDatabase XScreenResourceString \
-XScreenNumberOfScreen
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-fi
-
-if test "${window_system}" = "x11"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking X11 version 6" >&5
-$as_echo_n "checking X11 version 6... " >&6; }
-  if test "${emacs_cv_x11_version_6+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Xlib.h>
-int
-main ()
-{
-#if XlibSpecificationRelease < 6
-fail;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_x11_version_6=yes
-else
-  emacs_cv_x11_version_6=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-
-  if test $emacs_cv_x11_version_6 = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: 6 or newer" >&5
-$as_echo "6 or newer" >&6; }
-
-$as_echo "#define HAVE_X11R6 1" >>confdefs.h
-
-
-$as_echo "#define HAVE_X_I18N 1" >>confdefs.h
-
-    ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
-    ## XIM support.
-    case "$opsys" in
-      sol2-*) : ;;
-      *)
-$as_echo "#define HAVE_X11R6_XIM 1" >>confdefs.h
-
-         ;;
-    esac
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: before 6" >&5
-$as_echo "before 6" >&6; }
-  fi
-fi
-
-
-### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
-HAVE_RSVG=no
-if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
-  if test "${with_rsvg}" != "no"; then
-    RSVG_REQUIRED=2.11.0
-    RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
-
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     :
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $RSVG_MODULE" >&5
-$as_echo_n "checking for $RSVG_MODULE... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$RSVG_MODULE" 2>&5 &&
-          RSVG_CFLAGS=`"$PKG_CONFIG" --cflags "$RSVG_MODULE" 2>&5` &&
-          RSVG_LIBS=`"$PKG_CONFIG" --libs "$RSVG_MODULE" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           RSVG_CFLAGS=`$as_echo "$RSVG_CFLAGS" | sed -e "$edit_cflags"`
-           RSVG_LIBS=`$as_echo "$RSVG_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$RSVG_CFLAGS' LIBS='$RSVG_LIBS'" >&5
-$as_echo "yes CFLAGS='$RSVG_CFLAGS' LIBS='$RSVG_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            RSVG_CFLAGS=""
-            RSVG_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           RSVG_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$RSVG_MODULE") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_RSVG=yes
-  else
-     :
-  fi
-
-
-
-
-    if test $HAVE_RSVG = yes; then
-
-$as_echo "#define HAVE_RSVG 1" >>confdefs.h
-
-      CFLAGS="$CFLAGS $RSVG_CFLAGS"
-      LIBS="$RSVG_LIBS $LIBS"
-    fi
-  fi
-fi
-
-HAVE_IMAGEMAGICK=no
-if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
-  if test "${with_imagemagick}" != "no"; then
-    ## 6.2.8 is the earliest version known to work, but earlier versions
-    ## might work - let us know if you find one.
-    ## 6.0.7 does not work.  See bug#7955.
-    ## 6.8.2 makes Emacs crash; see Bug#13867.
-    IMAGEMAGICK_MODULE="Wand >= 6.2.8 Wand != 6.8.2"
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     :
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $IMAGEMAGICK_MODULE" >&5
-$as_echo_n "checking for $IMAGEMAGICK_MODULE... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$IMAGEMAGICK_MODULE" 2>&5 &&
-          IMAGEMAGICK_CFLAGS=`"$PKG_CONFIG" --cflags "$IMAGEMAGICK_MODULE" 2>&5` &&
-          IMAGEMAGICK_LIBS=`"$PKG_CONFIG" --libs "$IMAGEMAGICK_MODULE" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           IMAGEMAGICK_CFLAGS=`$as_echo "$IMAGEMAGICK_CFLAGS" | sed -e "$edit_cflags"`
-           IMAGEMAGICK_LIBS=`$as_echo "$IMAGEMAGICK_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$IMAGEMAGICK_CFLAGS' LIBS='$IMAGEMAGICK_LIBS'" >&5
-$as_echo "yes CFLAGS='$IMAGEMAGICK_CFLAGS' LIBS='$IMAGEMAGICK_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            IMAGEMAGICK_CFLAGS=""
-            IMAGEMAGICK_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           IMAGEMAGICK_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$IMAGEMAGICK_MODULE") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_IMAGEMAGICK=yes
-  else
-     :
-  fi
-
-
-
-
-    if test $HAVE_IMAGEMAGICK = yes; then
-
-$as_echo "#define HAVE_IMAGEMAGICK 1" >>confdefs.h
-
-      CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
-      LIBS="$IMAGEMAGICK_LIBS $LIBS"
-      for ac_func in MagickExportImagePixels MagickMergeImageLayers
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-    fi
-  fi
-fi
-
-
-HAVE_GTK=no
-GTK_OBJ=
-gtk_term_header=$term_header
-check_gtk2=no
-gtk3_pkg_errors=
-if test "${opsys}" != "mingw32"; then
-  if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
-    GLIB_REQUIRED=2.28
-    GTK_REQUIRED=3.0
-    GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
-
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     pkg_check_gtk=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $GTK_MODULES" >&5
-$as_echo_n "checking for $GTK_MODULES... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$GTK_MODULES" 2>&5 &&
-          GTK_CFLAGS=`"$PKG_CONFIG" --cflags "$GTK_MODULES" 2>&5` &&
-          GTK_LIBS=`"$PKG_CONFIG" --libs "$GTK_MODULES" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GTK_CFLAGS=`$as_echo "$GTK_CFLAGS" | sed -e "$edit_cflags"`
-           GTK_LIBS=`$as_echo "$GTK_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GTK_CFLAGS' LIBS='$GTK_LIBS'" >&5
-$as_echo "yes CFLAGS='$GTK_CFLAGS' LIBS='$GTK_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GTK_CFLAGS=""
-            GTK_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GTK_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$GTK_MODULES") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     pkg_check_gtk=yes
-  else
-     pkg_check_gtk=no
-  fi
-
-    if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
-       as_fn_error "$GTK_PKG_ERRORS" "$LINENO" 5
-    fi
-    if test "$pkg_check_gtk" = "yes"; then
-
-$as_echo "#define HAVE_GTK3 1" >>confdefs.h
-
-       GTK_OBJ=emacsgtkfixed.o
-       gtk_term_header=gtkutil.h
-       USE_GTK_TOOLKIT="GTK3"
-       if test "x$ac_enable_gtk_deprecation_warnings" = x; then
-                 GTK_CFLAGS="$GTK_CFLAGS -DGDK_DISABLE_DEPRECATION_WARNINGS"
-                 GTK_CFLAGS="$GTK_CFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS"
-       fi
-    else
-       check_gtk2=yes
-       gtk3_pkg_errors="$GTK_PKG_ERRORS "
-    fi
-  fi
-
-  if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
-    GLIB_REQUIRED=2.10
-    GTK_REQUIRED=2.10
-    GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
-
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     pkg_check_gtk=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $GTK_MODULES" >&5
-$as_echo_n "checking for $GTK_MODULES... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$GTK_MODULES" 2>&5 &&
-          GTK_CFLAGS=`"$PKG_CONFIG" --cflags "$GTK_MODULES" 2>&5` &&
-          GTK_LIBS=`"$PKG_CONFIG" --libs "$GTK_MODULES" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GTK_CFLAGS=`$as_echo "$GTK_CFLAGS" | sed -e "$edit_cflags"`
-           GTK_LIBS=`$as_echo "$GTK_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GTK_CFLAGS' LIBS='$GTK_LIBS'" >&5
-$as_echo "yes CFLAGS='$GTK_CFLAGS' LIBS='$GTK_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GTK_CFLAGS=""
-            GTK_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GTK_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$GTK_MODULES") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     pkg_check_gtk=yes
-  else
-     pkg_check_gtk=no
-  fi
-
-    if test "$pkg_check_gtk" = "no" &&
-       { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
-    then
-      as_fn_error "$gtk3_pkg_errors$GTK_PKG_ERRORS" "$LINENO" 5
-    fi
-    test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
-  fi
-fi
-
-if test x"$pkg_check_gtk" = xyes; then
-
-
-
-  C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
-  CFLAGS="$CFLAGS $GTK_CFLAGS"
-  LIBS="$GTK_LIBS $LIBS"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GTK compiles" >&5
-$as_echo_n "checking whether GTK compiles... " >&6; }
-  GTK_COMPILES=no
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Check the Gtk and Glib APIs.  */
-        #include <gtk/gtk.h>
-        #include <glib-object.h>
-        static void
-        callback (GObject *go, GParamSpec *spec, gpointer user_data)
-        {}
-
-int
-main ()
-{
-
-        GtkSettings *gs = 0;
-        /* Use G_CALLBACK to make sure function pointers can be cast to void *;
-           strict C prohibits this.  Use gtk_main_iteration to test that the
-           libraries are there.  */
-        if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
-                                   0, 0, 0, G_CALLBACK (callback), 0))
-          gtk_main_iteration ();
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  GTK_COMPILES=yes
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GTK_COMPILES" >&5
-$as_echo "$GTK_COMPILES" >&6; }
-  if test "${GTK_COMPILES}" != "yes"; then
-    GTK_OBJ=
-    if test "$USE_X_TOOLKIT" != "maybe"; then
-      as_fn_error "Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?" "$LINENO" 5;
-    fi
-  else
-    HAVE_GTK=yes
-
-$as_echo "#define USE_GTK 1" >>confdefs.h
-
-    GTK_OBJ="gtkutil.o $GTK_OBJ"
-    term_header=$gtk_term_header
-    USE_X_TOOLKIT=none
-    if "$PKG_CONFIG" --atleast-version=2.10 gtk+-2.0; then
-      :
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of Gtk+ will have problems with
-       closing open displays.  This is no problem if you just use
-       one display, but if you use more than one and close one of them
-       Emacs may crash." >&5
-$as_echo "$as_me: WARNING: Your version of Gtk+ will have problems with
-       closing open displays.  This is no problem if you just use
-       one display, but if you use more than one and close one of them
-       Emacs may crash." >&2;}
-      sleep 3
-    fi
-  fi
-
-fi
-
-
-
-if test "${HAVE_GTK}" = "yes"; then
-
-      if test "$with_toolkit_scroll_bars" != no; then
-    with_toolkit_scroll_bars=yes
-  fi
-
-          HAVE_GTK_FILE_SELECTION=no
-  ac_fn_c_check_decl "$LINENO" "GTK_TYPE_FILE_SELECTION" "ac_cv_have_decl_GTK_TYPE_FILE_SELECTION" "$ac_includes_default
-#include <gtk/gtk.h>
-"
-if test "x$ac_cv_have_decl_GTK_TYPE_FILE_SELECTION" = x""yes; then :
-  HAVE_GTK_FILE_SELECTION=yes
-else
-  HAVE_GTK_FILE_SELECTION=no
-fi
-
-  if test "$HAVE_GTK_FILE_SELECTION" = yes; then
-    for ac_func in gtk_file_selection_new
-do :
-  ac_fn_c_check_func "$LINENO" "gtk_file_selection_new" "ac_cv_func_gtk_file_selection_new"
-if test "x$ac_cv_func_gtk_file_selection_new" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GTK_FILE_SELECTION_NEW 1
-_ACEOF
-
-fi
-done
-
-  fi
-
-    HAVE_GTK_HANDLE_BOX=no
-  ac_fn_c_check_decl "$LINENO" "GTK_TYPE_HANDLE_BOX" "ac_cv_have_decl_GTK_TYPE_HANDLE_BOX" "$ac_includes_default
-#include <gtk/gtk.h>
-"
-if test "x$ac_cv_have_decl_GTK_TYPE_HANDLE_BOX" = x""yes; then :
-  HAVE_GTK_HANDLE_BOX=yes
-else
-  HAVE_GTK_HANDLE_BOX=no
-fi
-
-  if test "$HAVE_GTK_HANDLE_BOX" = yes; then
-    for ac_func in gtk_handle_box_new
-do :
-  ac_fn_c_check_func "$LINENO" "gtk_handle_box_new" "ac_cv_func_gtk_handle_box_new"
-if test "x$ac_cv_func_gtk_handle_box_new" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GTK_HANDLE_BOX_NEW 1
-_ACEOF
-
-fi
-done
-
-  fi
-
-    HAVE_GTK_TEAROFF_MENU_ITEM=no
-  ac_fn_c_check_decl "$LINENO" "GTK_TYPE_TEAROFF_MENU_ITEM" "ac_cv_have_decl_GTK_TYPE_TEAROFF_MENU_ITEM" "$ac_includes_default
-#include <gtk/gtk.h>
-"
-if test "x$ac_cv_have_decl_GTK_TYPE_TEAROFF_MENU_ITEM" = x""yes; then :
-  HAVE_GTK_TEAROFF_MENU_ITEM=yes
-else
-  HAVE_GTK_TEAROFF_MENU_ITEM=no
-fi
-
-  if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
-    for ac_func in gtk_tearoff_menu_item_new
-do :
-  ac_fn_c_check_func "$LINENO" "gtk_tearoff_menu_item_new" "ac_cv_func_gtk_tearoff_menu_item_new"
-if test "x$ac_cv_func_gtk_tearoff_menu_item_new" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GTK_TEAROFF_MENU_ITEM_NEW 1
-_ACEOF
-
-fi
-done
-
-  fi
-
-    for ac_func in gtk_widget_get_window gtk_widget_set_has_window \
-                 gtk_dialog_get_action_area gtk_widget_get_sensitive \
-                 gtk_widget_get_mapped gtk_adjustment_get_page_size \
-                 gtk_orientable_set_orientation \
-                gtk_window_set_has_resize_grip
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
- term_header=gtkutil.h
-fi
-
-HAVE_DBUS=no
-DBUS_OBJ=
-if test "${with_dbus}" = "yes"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_DBUS=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus-1 >= 1.0" >&5
-$as_echo_n "checking for dbus-1 >= 1.0... " >&6; }
-
-        if "$PKG_CONFIG" --exists "dbus-1 >= 1.0" 2>&5 &&
-          DBUS_CFLAGS=`"$PKG_CONFIG" --cflags "dbus-1 >= 1.0" 2>&5` &&
-          DBUS_LIBS=`"$PKG_CONFIG" --libs "dbus-1 >= 1.0" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           DBUS_CFLAGS=`$as_echo "$DBUS_CFLAGS" | sed -e "$edit_cflags"`
-           DBUS_LIBS=`$as_echo "$DBUS_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$DBUS_CFLAGS' LIBS='$DBUS_LIBS'" >&5
-$as_echo "yes CFLAGS='$DBUS_CFLAGS' LIBS='$DBUS_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            DBUS_CFLAGS=""
-            DBUS_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           DBUS_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "dbus-1 >= 1.0") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_DBUS=yes
-  else
-     HAVE_DBUS=no
-  fi
-
-   if test "$HAVE_DBUS" = yes; then
-     LIBS="$LIBS $DBUS_LIBS"
-
-$as_echo "#define HAVE_DBUS 1" >>confdefs.h
-
-                    for ac_func in dbus_watch_get_unix_fd \
-                   dbus_type_is_valid \
-                   dbus_validate_bus_name \
-                    dbus_validate_path \
-                   dbus_validate_interface \
-                   dbus_validate_member
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-     DBUS_OBJ=dbusbind.o
-   fi
-fi
-
-
-HAVE_GSETTINGS=no
-if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GSETTINGS=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gio-2.0 >= 2.26" >&5
-$as_echo_n "checking for gio-2.0 >= 2.26... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gio-2.0 >= 2.26" 2>&5 &&
-          GSETTINGS_CFLAGS=`"$PKG_CONFIG" --cflags "gio-2.0 >= 2.26" 2>&5` &&
-          GSETTINGS_LIBS=`"$PKG_CONFIG" --libs "gio-2.0 >= 2.26" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GSETTINGS_CFLAGS=`$as_echo "$GSETTINGS_CFLAGS" | sed -e "$edit_cflags"`
-           GSETTINGS_LIBS=`$as_echo "$GSETTINGS_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GSETTINGS_CFLAGS' LIBS='$GSETTINGS_LIBS'" >&5
-$as_echo "yes CFLAGS='$GSETTINGS_CFLAGS' LIBS='$GSETTINGS_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GSETTINGS_CFLAGS=""
-            GSETTINGS_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GSETTINGS_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gio-2.0 >= 2.26") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GSETTINGS=yes
-  else
-     HAVE_GSETTINGS=no
-  fi
-
-   if test "$HAVE_GSETTINGS" = "yes"; then
-
-$as_echo "#define HAVE_GSETTINGS 1" >>confdefs.h
-
-      SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
-      SETTINGS_LIBS="$GSETTINGS_LIBS"
-   fi
-fi
-
-HAVE_GCONF=no
-if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GCONF=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gconf-2.0 >= 2.13" >&5
-$as_echo_n "checking for gconf-2.0 >= 2.13... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gconf-2.0 >= 2.13" 2>&5 &&
-          GCONF_CFLAGS=`"$PKG_CONFIG" --cflags "gconf-2.0 >= 2.13" 2>&5` &&
-          GCONF_LIBS=`"$PKG_CONFIG" --libs "gconf-2.0 >= 2.13" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GCONF_CFLAGS=`$as_echo "$GCONF_CFLAGS" | sed -e "$edit_cflags"`
-           GCONF_LIBS=`$as_echo "$GCONF_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GCONF_CFLAGS' LIBS='$GCONF_LIBS'" >&5
-$as_echo "yes CFLAGS='$GCONF_CFLAGS' LIBS='$GCONF_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GCONF_CFLAGS=""
-            GCONF_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GCONF_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gconf-2.0 >= 2.13") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GCONF=yes
-  else
-     HAVE_GCONF=no
-  fi
-
-   if test "$HAVE_GCONF" = yes; then
-
-$as_echo "#define HAVE_GCONF 1" >>confdefs.h
-
-            SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
-      SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
-   fi
-fi
-
-if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GOBJECT=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gobject-2.0 >= 2.0" >&5
-$as_echo_n "checking for gobject-2.0 >= 2.0... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gobject-2.0 >= 2.0" 2>&5 &&
-          GOBJECT_CFLAGS=`"$PKG_CONFIG" --cflags "gobject-2.0 >= 2.0" 2>&5` &&
-          GOBJECT_LIBS=`"$PKG_CONFIG" --libs "gobject-2.0 >= 2.0" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GOBJECT_CFLAGS=`$as_echo "$GOBJECT_CFLAGS" | sed -e "$edit_cflags"`
-           GOBJECT_LIBS=`$as_echo "$GOBJECT_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GOBJECT_CFLAGS' LIBS='$GOBJECT_LIBS'" >&5
-$as_echo "yes CFLAGS='$GOBJECT_CFLAGS' LIBS='$GOBJECT_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GOBJECT_CFLAGS=""
-            GOBJECT_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GOBJECT_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gobject-2.0 >= 2.0") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GOBJECT=yes
-  else
-     HAVE_GOBJECT=no
-  fi
-
-    if test "$HAVE_GOBJECT" = "yes"; then
-       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
-       SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
-    fi
-    SAVE_CFLAGS="$CFLAGS"
-    SAVE_LIBS="$LIBS"
-    CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
-    LIBS="$SETTINGS_LIBS $LIBS"
-    CFLAGS="$SAVE_CFLAGS"
-    LIBS="$SAVE_LIBS"
-fi
-
-
-
-
-HAVE_LIBSELINUX=no
-LIBSELINUX_LIBS=
-if test "${with_selinux}" = "yes"; then
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lgetfilecon in -lselinux" >&5
-$as_echo_n "checking for lgetfilecon in -lselinux... " >&6; }
-if test "${ac_cv_lib_selinux_lgetfilecon+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lselinux  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char lgetfilecon ();
-int
-main ()
-{
-return lgetfilecon ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_selinux_lgetfilecon=yes
-else
-  ac_cv_lib_selinux_lgetfilecon=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_lgetfilecon" >&5
-$as_echo "$ac_cv_lib_selinux_lgetfilecon" >&6; }
-if test "x$ac_cv_lib_selinux_lgetfilecon" = x""yes; then :
-  HAVE_LIBSELINUX=yes
-else
-  HAVE_LIBSELINUX=no
-fi
-
-   if test "$HAVE_LIBSELINUX" = yes; then
-
-$as_echo "#define HAVE_LIBSELINUX 1" >>confdefs.h
-
-      LIBSELINUX_LIBS=-lselinux
-   fi
-fi
-
-
-HAVE_GNUTLS=no
-HAVE_GNUTLS3=no
-if test "${with_gnutls}" = "yes" ; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GNUTLS3=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls >= 3.0.0" >&5
-$as_echo_n "checking for gnutls >= 3.0.0... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gnutls >= 3.0.0" 2>&5 &&
-          LIBGNUTLS_CFLAGS=`"$PKG_CONFIG" --cflags "gnutls >= 3.0.0" 2>&5` &&
-          LIBGNUTLS_LIBS=`"$PKG_CONFIG" --libs "gnutls >= 3.0.0" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           LIBGNUTLS_CFLAGS=`$as_echo "$LIBGNUTLS_CFLAGS" | sed -e "$edit_cflags"`
-           LIBGNUTLS_LIBS=`$as_echo "$LIBGNUTLS_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS'" >&5
-$as_echo "yes CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            LIBGNUTLS_CFLAGS=""
-            LIBGNUTLS_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           LIBGNUTLS_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gnutls >= 3.0.0") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GNUTLS3=yes
-  else
-     HAVE_GNUTLS3=no
-  fi
-
-  if test "${HAVE_GNUTLS3}" = "yes"; then
-
-$as_echo "#define HAVE_GNUTLS3 1" >>confdefs.h
-
-    HAVE_GNUTLS="yes"
-  else
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GNUTLS=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls >= 2.6.6" >&5
-$as_echo_n "checking for gnutls >= 2.6.6... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gnutls >= 2.6.6" 2>&5 &&
-          LIBGNUTLS_CFLAGS=`"$PKG_CONFIG" --cflags "gnutls >= 2.6.6" 2>&5` &&
-          LIBGNUTLS_LIBS=`"$PKG_CONFIG" --libs "gnutls >= 2.6.6" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           LIBGNUTLS_CFLAGS=`$as_echo "$LIBGNUTLS_CFLAGS" | sed -e "$edit_cflags"`
-           LIBGNUTLS_LIBS=`$as_echo "$LIBGNUTLS_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS'" >&5
-$as_echo "yes CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            LIBGNUTLS_CFLAGS=""
-            LIBGNUTLS_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           LIBGNUTLS_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gnutls >= 2.6.6") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GNUTLS=yes
-  else
-     HAVE_GNUTLS=no
-  fi
-
-  fi
-  if test "${HAVE_GNUTLS}" = "yes"; then
-
-$as_echo "#define HAVE_GNUTLS 1" >>confdefs.h
-
-  fi
-
-  # Windows loads GnuTLS dynamically
-  if test "${opsys}" = "mingw32"; then
-    LIBGNUTLS_LIBS=
-  else
-    CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
-    LIBS="$LIBGNUTLS_LIBS $LIBS"
-  fi
-fi
-
-
-
-
-NOTIFY_OBJ=
-NOTIFY_SUMMARY=no
-
-if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
-  with_file_notification=no
-fi
-
-case $with_file_notification,$opsys in
-  w32,* | yes,mingw32)
-    ac_fn_c_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default"
-if test "x$ac_cv_header_windows_h" = x""yes; then :
-
-fi
-
-
-    if test "$ac_cv_header_windows_h" = yes ; then
-
-$as_echo "#define HAVE_W32NOTIFY 1" >>confdefs.h
-
-       NOTIFY_OBJ=w32notify.o
-       NOTIFY_SUMMARY="yes (w32)"
-    fi ;;
-esac
-
-case $with_file_notification,$NOTIFY_OBJ in
-  gfile, | yes,)
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_GFILENOTIFY=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gio-2.0 >= 2.24" >&5
-$as_echo_n "checking for gio-2.0 >= 2.24... " >&6; }
-
-        if "$PKG_CONFIG" --exists "gio-2.0 >= 2.24" 2>&5 &&
-          GFILENOTIFY_CFLAGS=`"$PKG_CONFIG" --cflags "gio-2.0 >= 2.24" 2>&5` &&
-          GFILENOTIFY_LIBS=`"$PKG_CONFIG" --libs "gio-2.0 >= 2.24" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           GFILENOTIFY_CFLAGS=`$as_echo "$GFILENOTIFY_CFLAGS" | sed -e "$edit_cflags"`
-           GFILENOTIFY_LIBS=`$as_echo "$GFILENOTIFY_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$GFILENOTIFY_CFLAGS' LIBS='$GFILENOTIFY_LIBS'" >&5
-$as_echo "yes CFLAGS='$GFILENOTIFY_CFLAGS' LIBS='$GFILENOTIFY_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            GFILENOTIFY_CFLAGS=""
-            GFILENOTIFY_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           GFILENOTIFY_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "gio-2.0 >= 2.24") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_GFILENOTIFY=yes
-  else
-     HAVE_GFILENOTIFY=no
-  fi
-
-    if test "$HAVE_GFILENOTIFY" = "yes"; then
-
-$as_echo "#define HAVE_GFILENOTIFY 1" >>confdefs.h
-
-       NOTIFY_OBJ=gfilenotify.o
-       NOTIFY_SUMMARY="yes -lgio (gfile)"
-    fi ;;
-esac
-
-case $with_file_notification,$NOTIFY_OBJ in
-  inotify, | yes,)
-    ac_fn_c_check_header_mongrel "$LINENO" "sys/inotify.h" "ac_cv_header_sys_inotify_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_inotify_h" = x""yes; then :
-
-fi
-
-
-    if test "$ac_cv_header_sys_inotify_h" = yes ; then
-       ac_fn_c_check_func "$LINENO" "inotify_init1" "ac_cv_func_inotify_init1"
-if test "x$ac_cv_func_inotify_init1" = x""yes; then :
-
-fi
-
-       if test "$ac_cv_func_inotify_init1" = yes; then
-
-$as_echo "#define HAVE_INOTIFY 1" >>confdefs.h
-
-         NOTIFY_OBJ=inotify.o
-         NOTIFY_SUMMARY="yes -lglibc (inotify)"
-       fi
-    fi ;;
-esac
-
-case $with_file_notification,$NOTIFY_OBJ in
-  yes,* | no,* | *,?*) ;;
-  *) as_fn_error "File notification \`$with_file_notification' requested but requirements not found." "$LINENO" 5 ;;
-esac
-
-if test -n "$NOTIFY_OBJ"; then
-
-$as_echo "#define USE_FILE_NOTIFY 1" >>confdefs.h
-
-fi
-
-
-
-
-HAVE_XAW3D=no
-LUCID_LIBW=
-if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
-  if test "$with_xaw3d" != no; then
-    if test "${emacs_cv_xaw3d+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <X11/Intrinsic.h>
-#include <X11/Xaw3d/Simple.h>
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XawScrollbarSetThumb in -lXaw3d" >&5
-$as_echo_n "checking for XawScrollbarSetThumb in -lXaw3d... " >&6; }
-if test "${ac_cv_lib_Xaw3d_XawScrollbarSetThumb+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXaw3d  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XawScrollbarSetThumb ();
-int
-main ()
-{
-return XawScrollbarSetThumb ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xaw3d_XawScrollbarSetThumb=yes
-else
-  ac_cv_lib_Xaw3d_XawScrollbarSetThumb=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&5
-$as_echo "$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&6; }
-if test "x$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" = x""yes; then :
-  emacs_cv_xaw3d=yes
-else
-  emacs_cv_xaw3d=no
-fi
-
-else
-  emacs_cv_xaw3d=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-
-  else
-    emacs_cv_xaw3d=no
-  fi
-  if test $emacs_cv_xaw3d = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xaw3d" >&5
-$as_echo_n "checking for xaw3d... " >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes; using Lucid toolkit" >&5
-$as_echo "yes; using Lucid toolkit" >&6; }
-    USE_X_TOOLKIT=LUCID
-    HAVE_XAW3D=yes
-    LUCID_LIBW=-lXaw3d
-
-$as_echo "#define HAVE_XAW3D 1" >>confdefs.h
-
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xaw3d" >&5
-$as_echo_n "checking for xaw3d... " >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libXaw" >&5
-$as_echo_n "checking for libXaw... " >&6; }
-    if test "${emacs_cv_xaw+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <X11/Intrinsic.h>
-#include <X11/Xaw/Simple.h>
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_xaw=yes
-else
-  emacs_cv_xaw=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-
-    if test $emacs_cv_xaw = yes; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes; using Lucid toolkit" >&5
-$as_echo "yes; using Lucid toolkit" >&6; }
-      USE_X_TOOLKIT=LUCID
-      LUCID_LIBW=-lXaw
-    elif test x"${USE_X_TOOLKIT}" = xLUCID; then
-      as_fn_error "Lucid toolkit requires X11/Xaw include files" "$LINENO" 5
-    else
-      as_fn_error "No X toolkit could be found.
-If you are sure you want Emacs compiled without an X toolkit, pass
-  --with-x-toolkit=no
-to configure.  Otherwise, install the development libraries for the toolkit
-that you want to use (e.g. Gtk+) and re-run configure." "$LINENO" 5
-    fi
-  fi
-fi
-
-X_TOOLKIT_TYPE=$USE_X_TOOLKIT
-
-LIBXTR6=
-if test "${USE_X_TOOLKIT}" != "none"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking X11 toolkit version" >&5
-$as_echo_n "checking X11 toolkit version... " >&6; }
-  if test "${emacs_cv_x11_toolkit_version_6+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <X11/Intrinsic.h>
-int
-main ()
-{
-#if XtSpecificationRelease < 6
-fail;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_x11_toolkit_version_6=yes
-else
-  emacs_cv_x11_toolkit_version_6=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-
-  HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
-  if test $emacs_cv_x11_toolkit_version_6 = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: 6 or newer" >&5
-$as_echo "6 or newer" >&6; }
-
-$as_echo "#define HAVE_X11XTR6 1" >>confdefs.h
-
-    LIBXTR6="-lSM -lICE"
-    case "$opsys" in
-      ## Use libw.a along with X11R6 Xt.
-      unixware) LIBXTR6="$LIBXTR6 -lw" ;;
-    esac
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: before 6" >&5
-$as_echo "before 6" >&6; }
-  fi
-
-  OLDLIBS="$LIBS"
-  if test x$HAVE_X11XTR6 = xyes; then
-    LIBS="-lXt -lSM -lICE $LIBS"
-  else
-    LIBS="-lXt $LIBS"
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XmuConvertStandardSelection in -lXmu" >&5
-$as_echo_n "checking for XmuConvertStandardSelection in -lXmu... " >&6; }
-if test "${ac_cv_lib_Xmu_XmuConvertStandardSelection+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXmu  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XmuConvertStandardSelection ();
-int
-main ()
-{
-return XmuConvertStandardSelection ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xmu_XmuConvertStandardSelection=yes
-else
-  ac_cv_lib_Xmu_XmuConvertStandardSelection=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xmu_XmuConvertStandardSelection" >&5
-$as_echo "$ac_cv_lib_Xmu_XmuConvertStandardSelection" >&6; }
-if test "x$ac_cv_lib_Xmu_XmuConvertStandardSelection" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBXMU 1
-_ACEOF
-
-  LIBS="-lXmu $LIBS"
-
-fi
-
-  test $ac_cv_lib_Xmu_XmuConvertStandardSelection = no && LIBS="$OLDLIBS"
-  fi
-
-
-LIBXMU=-lXmu
-case $opsys in
-  ## These systems don't supply Xmu.
-  hpux* | aix4-2 )
-    test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
-    ;;
-  mingw32 )
-    LIBXMU=
-    ;;
-esac
-
-
-# On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
-if test "${HAVE_X11}" = "yes"; then
-  if test "${USE_X_TOOLKIT}" != "none"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XShapeQueryExtension in -lXext" >&5
-$as_echo_n "checking for XShapeQueryExtension in -lXext... " >&6; }
-if test "${ac_cv_lib_Xext_XShapeQueryExtension+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXext  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XShapeQueryExtension ();
-int
-main ()
-{
-return XShapeQueryExtension ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xext_XShapeQueryExtension=yes
-else
-  ac_cv_lib_Xext_XShapeQueryExtension=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xext_XShapeQueryExtension" >&5
-$as_echo "$ac_cv_lib_Xext_XShapeQueryExtension" >&6; }
-if test "x$ac_cv_lib_Xext_XShapeQueryExtension" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBXEXT 1
-_ACEOF
-
-  LIBS="-lXext $LIBS"
-
-fi
-
-  fi
-fi
-
-LIBXP=
-if test "${USE_X_TOOLKIT}" = "MOTIF"; then
-  # OpenMotif may be installed in such a way on some GNU/Linux systems.
-  if test -d /usr/include/openmotif; then
-    CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
-    emacs_cv_openmotif=yes
-    case "$canonical" in
-      x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
-      test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
-      ;;
-      *)
-      test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
-    esac
-  else
-    emacs_cv_openmotif=no
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for (Open)Motif version 2.1" >&5
-$as_echo_n "checking for (Open)Motif version 2.1... " >&6; }
-if test "${emacs_cv_motif_version_2_1+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <Xm/Xm.h>
-int
-main ()
-{
-#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
-int x = 5;
-#else
-Motif version prior to 2.1.
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_motif_version_2_1=yes
-else
-  emacs_cv_motif_version_2_1=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_motif_version_2_1" >&5
-$as_echo "$emacs_cv_motif_version_2_1" >&6; }
-  if test $emacs_cv_motif_version_2_1 = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpCreateContext in -lXp" >&5
-$as_echo_n "checking for XpCreateContext in -lXp... " >&6; }
-if test "${ac_cv_lib_Xp_XpCreateContext+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXp  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XpCreateContext ();
-int
-main ()
-{
-return XpCreateContext ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xp_XpCreateContext=yes
-else
-  ac_cv_lib_Xp_XpCreateContext=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xp_XpCreateContext" >&5
-$as_echo "$ac_cv_lib_Xp_XpCreateContext" >&6; }
-if test "x$ac_cv_lib_Xp_XpCreateContext" = x""yes; then :
-  LIBXP=-lXp
-fi
-
-    if test x$emacs_cv_openmotif = xyes; then
-      REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
-    fi
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LessTif where some systems put it" >&5
-$as_echo_n "checking for LessTif where some systems put it... " >&6; }
-if test "${emacs_cv_lesstif+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # We put this in CFLAGS temporarily to precede other -I options
-    # that might be in CFLAGS temporarily.
-    # We put this in CPPFLAGS where it precedes the other -I options.
-    OLD_CPPFLAGS=$CPPFLAGS
-    OLD_CFLAGS=$CFLAGS
-    CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
-    CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>
-int
-main ()
-{
-int x = 5;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_lesstif=yes
-else
-  emacs_cv_lesstif=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_lesstif" >&5
-$as_echo "$emacs_cv_lesstif" >&6; }
-    if test $emacs_cv_lesstif = yes; then
-      # Make sure this -I option remains in CPPFLAGS after it is set
-      # back to REAL_CPPFLAGS.
-      # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
-      # have those other -I options anyway.  Ultimately, having this
-      # directory ultimately in CPPFLAGS will be enough.
-      REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
-      LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
-    else
-      CFLAGS=$OLD_CFLAGS
-      CPPFLAGS=$OLD_CPPFLAGS
-    fi
-  fi
-  ac_fn_c_check_header_mongrel "$LINENO" "Xm/BulletinB.h" "ac_cv_header_Xm_BulletinB_h" "$ac_includes_default"
-if test "x$ac_cv_header_Xm_BulletinB_h" = x""yes; then :
-
-else
-  as_fn_error "Motif toolkit requested but requirements not found." "$LINENO" 5
-fi
-
-
-fi
-
-
-USE_TOOLKIT_SCROLL_BARS=no
-if test "${with_toolkit_scroll_bars}" != "no"; then
-  if test "${USE_X_TOOLKIT}" != "none"; then
-    if test "${USE_X_TOOLKIT}" = "MOTIF"; then
-      $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
-
-      HAVE_XAW3D=no
-      USE_TOOLKIT_SCROLL_BARS=yes
-    elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
-      $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
-
-      USE_TOOLKIT_SCROLL_BARS=yes
-    fi
-  elif test "${HAVE_GTK}" = "yes"; then
-    $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
-
-    USE_TOOLKIT_SCROLL_BARS=yes
-  elif test "${HAVE_NS}" = "yes"; then
-    $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
-
-    USE_TOOLKIT_SCROLL_BARS=yes
-  elif test "${HAVE_W32}" = "yes"; then
-    $as_echo "#define USE_TOOLKIT_SCROLL_BARS 1" >>confdefs.h
-
-    USE_TOOLKIT_SCROLL_BARS=yes
-  fi
-fi
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-         #include <X11/Xlib.h>
-         #include <X11/Xresource.h>
-int
-main ()
-{
-XIMProc  callback;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  HAVE_XIM=yes
-
-$as_echo "#define HAVE_XIM 1" >>confdefs.h
-
-else
-  HAVE_XIM=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-
-if test "${with_xim}" != "no"; then
-
-$as_echo "#define USE_XIM 1" >>confdefs.h
-
-fi
-
-
-if test "${HAVE_XIM}" != "no"; then
-  late_CFLAGS=$CFLAGS
-  if test "$GCC" = yes; then
-    CFLAGS="$CFLAGS --pedantic-errors"
-  fi
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-int
-main ()
-{
-Display *display;
-XrmDatabase db;
-char *res_name;
-char *res_class;
-XIMProc  callback;
-XPointer *client_data;
-#ifndef __GNUC__
-/* If we're not using GCC, it's probably not XFree86, and this is
-   probably right, but we can't use something like --pedantic-errors.  */
-extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
-                                           char*, XIMProc, XPointer*);
-#endif
-(void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
-   client_data);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_arg6_star=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    if test "$emacs_cv_arg6_star" = yes; then
-    $as_echo "#define XRegisterIMInstantiateCallback_arg6 XPointer*" >>confdefs.h
-
-  else
-    $as_echo "#define XRegisterIMInstantiateCallback_arg6 XPointer" >>confdefs.h
-
-  fi
-  CFLAGS=$late_CFLAGS
-fi
-
-### Start of font-backend (under any platform) section.
-# (nothing here yet -- this is a placeholder)
-### End of font-backend (under any platform) section.
-
-### Start of font-backend (under X11) section.
-if test "${HAVE_X11}" = "yes"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_FC=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fontconfig >= 2.2.0" >&5
-$as_echo_n "checking for fontconfig >= 2.2.0... " >&6; }
-
-        if "$PKG_CONFIG" --exists "fontconfig >= 2.2.0" 2>&5 &&
-          FONTCONFIG_CFLAGS=`"$PKG_CONFIG" --cflags "fontconfig >= 2.2.0" 2>&5` &&
-          FONTCONFIG_LIBS=`"$PKG_CONFIG" --libs "fontconfig >= 2.2.0" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           FONTCONFIG_CFLAGS=`$as_echo "$FONTCONFIG_CFLAGS" | sed -e "$edit_cflags"`
-           FONTCONFIG_LIBS=`$as_echo "$FONTCONFIG_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$FONTCONFIG_CFLAGS' LIBS='$FONTCONFIG_LIBS'" >&5
-$as_echo "yes CFLAGS='$FONTCONFIG_CFLAGS' LIBS='$FONTCONFIG_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            FONTCONFIG_CFLAGS=""
-            FONTCONFIG_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           FONTCONFIG_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "fontconfig >= 2.2.0") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_FC=yes
-  else
-     HAVE_FC=no
-  fi
-
-
-   ## Use -lXft if available, unless `--with-xft=no'.
-   HAVE_XFT=maybe
-    if test "${HAVE_FC}" = "no" || test "x${with_x}" = "xno"; then
-      with_xft="no";
-    fi
-    if test "x${with_xft}" != "xno"; then
-
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_XFT=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xft >= 0.13.0" >&5
-$as_echo_n "checking for xft >= 0.13.0... " >&6; }
-
-        if "$PKG_CONFIG" --exists "xft >= 0.13.0" 2>&5 &&
-          XFT_CFLAGS=`"$PKG_CONFIG" --cflags "xft >= 0.13.0" 2>&5` &&
-          XFT_LIBS=`"$PKG_CONFIG" --libs "xft >= 0.13.0" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           XFT_CFLAGS=`$as_echo "$XFT_CFLAGS" | sed -e "$edit_cflags"`
-           XFT_LIBS=`$as_echo "$XFT_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$XFT_CFLAGS' LIBS='$XFT_LIBS'" >&5
-$as_echo "yes CFLAGS='$XFT_CFLAGS' LIBS='$XFT_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            XFT_CFLAGS=""
-            XFT_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           XFT_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "xft >= 0.13.0") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     :
-  else
-     HAVE_XFT=no
-  fi
-
-      ## Because xftfont.c uses XRenderQueryExtension, we also
-      ## need to link to -lXrender.
-      HAVE_XRENDER=no
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XRenderQueryExtension in -lXrender" >&5
-$as_echo_n "checking for XRenderQueryExtension in -lXrender... " >&6; }
-if test "${ac_cv_lib_Xrender_XRenderQueryExtension+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXrender  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XRenderQueryExtension ();
-int
-main ()
-{
-return XRenderQueryExtension ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xrender_XRenderQueryExtension=yes
-else
-  ac_cv_lib_Xrender_XRenderQueryExtension=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xrender_XRenderQueryExtension" >&5
-$as_echo "$ac_cv_lib_Xrender_XRenderQueryExtension" >&6; }
-if test "x$ac_cv_lib_Xrender_XRenderQueryExtension" = x""yes; then :
-  HAVE_XRENDER=yes
-fi
-
-      if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
-       OLD_CPPFLAGS="$CPPFLAGS"
-       OLD_CFLAGS="$CFLAGS"
-       OLD_LIBS="$LIBS"
-       CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
-       CFLAGS="$CFLAGS $XFT_CFLAGS"
-       XFT_LIBS="-lXrender $XFT_LIBS"
-       LIBS="$XFT_LIBS $LIBS"
-       ac_fn_c_check_header_compile "$LINENO" "X11/Xft/Xft.h" "ac_cv_header_X11_Xft_Xft_h" "#include <X11/X.h>
-"
-if test "x$ac_cv_header_X11_Xft_Xft_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XftFontOpen in -lXft" >&5
-$as_echo_n "checking for XftFontOpen in -lXft... " >&6; }
-if test "${ac_cv_lib_Xft_XftFontOpen+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXft $XFT_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XftFontOpen ();
-int
-main ()
-{
-return XftFontOpen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xft_XftFontOpen=yes
-else
-  ac_cv_lib_Xft_XftFontOpen=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xft_XftFontOpen" >&5
-$as_echo "$ac_cv_lib_Xft_XftFontOpen" >&6; }
-if test "x$ac_cv_lib_Xft_XftFontOpen" = x""yes; then :
-  HAVE_XFT=yes
-fi
-
-fi
-
-
-
-       if test "${HAVE_XFT}" = "yes"; then
-
-$as_echo "#define HAVE_XFT 1" >>confdefs.h
-
-
-         C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
-       else
-         CPPFLAGS="$OLD_CPPFLAGS"
-         CFLAGS="$OLD_CFLAGS"
-         LIBS="$OLD_LIBS"
-       fi                        # "${HAVE_XFT}" = "yes"
-      fi                          # "$HAVE_XFT" != no
-    fi                            # "x${with_xft}" != "xno"
-
-    ## We used to allow building with FreeType and without Xft.
-    ## However, the ftx font backend driver is not in good shape.
-    if test "$HAVE_XFT" != "yes"; then
-              HAVE_XFT=no
-       HAVE_FREETYPE=no
-    else
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_FREETYPE=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2" >&5
-$as_echo_n "checking for freetype2... " >&6; }
-
-        if "$PKG_CONFIG" --exists "freetype2" 2>&5 &&
-          FREETYPE_CFLAGS=`"$PKG_CONFIG" --cflags "freetype2" 2>&5` &&
-          FREETYPE_LIBS=`"$PKG_CONFIG" --libs "freetype2" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           FREETYPE_CFLAGS=`$as_echo "$FREETYPE_CFLAGS" | sed -e "$edit_cflags"`
-           FREETYPE_LIBS=`$as_echo "$FREETYPE_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$FREETYPE_CFLAGS' LIBS='$FREETYPE_LIBS'" >&5
-$as_echo "yes CFLAGS='$FREETYPE_CFLAGS' LIBS='$FREETYPE_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            FREETYPE_CFLAGS=""
-            FREETYPE_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           FREETYPE_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "freetype2") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_FREETYPE=yes
-  else
-     HAVE_FREETYPE=no
-  fi
-
-
-       test "$HAVE_FREETYPE" = "no" && as_fn_error "libxft requires libfreetype" "$LINENO" 5
-    fi
-
-    HAVE_LIBOTF=no
-    if test "${HAVE_FREETYPE}" = "yes"; then
-
-$as_echo "#define HAVE_FREETYPE 1" >>confdefs.h
-
-      if test "${with_libotf}" != "no"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_LIBOTF=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libotf" >&5
-$as_echo_n "checking for libotf... " >&6; }
-
-        if "$PKG_CONFIG" --exists "libotf" 2>&5 &&
-          LIBOTF_CFLAGS=`"$PKG_CONFIG" --cflags "libotf" 2>&5` &&
-          LIBOTF_LIBS=`"$PKG_CONFIG" --libs "libotf" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           LIBOTF_CFLAGS=`$as_echo "$LIBOTF_CFLAGS" | sed -e "$edit_cflags"`
-           LIBOTF_LIBS=`$as_echo "$LIBOTF_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$LIBOTF_CFLAGS' LIBS='$LIBOTF_LIBS'" >&5
-$as_echo "yes CFLAGS='$LIBOTF_CFLAGS' LIBS='$LIBOTF_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            LIBOTF_CFLAGS=""
-            LIBOTF_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           LIBOTF_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "libotf") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_LIBOTF=yes
-  else
-     HAVE_LIBOTF=no
-  fi
-
-       if test "$HAVE_LIBOTF" = "yes"; then
-
-$as_echo "#define HAVE_LIBOTF 1" >>confdefs.h
-
-         { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTF_get_variation_glyphs in -lotf" >&5
-$as_echo_n "checking for OTF_get_variation_glyphs in -lotf... " >&6; }
-if test "${ac_cv_lib_otf_OTF_get_variation_glyphs+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lotf  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char OTF_get_variation_glyphs ();
-int
-main ()
-{
-return OTF_get_variation_glyphs ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_otf_OTF_get_variation_glyphs=yes
-else
-  ac_cv_lib_otf_OTF_get_variation_glyphs=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_otf_OTF_get_variation_glyphs" >&5
-$as_echo "$ac_cv_lib_otf_OTF_get_variation_glyphs" >&6; }
-if test "x$ac_cv_lib_otf_OTF_get_variation_glyphs" = x""yes; then :
-  HAVE_OTF_GET_VARIATION_GLYPHS=yes
-else
-  HAVE_OTF_GET_VARIATION_GLYPHS=no
-fi
-
-         if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
-
-$as_echo "#define HAVE_OTF_GET_VARIATION_GLYPHS 1" >>confdefs.h
-
-         fi
-       fi
-      fi
-            fi
-
-    HAVE_M17N_FLT=no
-    if test "${HAVE_LIBOTF}" = yes; then
-      if test "${with_m17n_flt}" != "no"; then
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_M17N_FLT=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for m17n-flt" >&5
-$as_echo_n "checking for m17n-flt... " >&6; }
-
-        if "$PKG_CONFIG" --exists "m17n-flt" 2>&5 &&
-          M17N_FLT_CFLAGS=`"$PKG_CONFIG" --cflags "m17n-flt" 2>&5` &&
-          M17N_FLT_LIBS=`"$PKG_CONFIG" --libs "m17n-flt" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           M17N_FLT_CFLAGS=`$as_echo "$M17N_FLT_CFLAGS" | sed -e "$edit_cflags"`
-           M17N_FLT_LIBS=`$as_echo "$M17N_FLT_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$M17N_FLT_CFLAGS' LIBS='$M17N_FLT_LIBS'" >&5
-$as_echo "yes CFLAGS='$M17N_FLT_CFLAGS' LIBS='$M17N_FLT_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            M17N_FLT_CFLAGS=""
-            M17N_FLT_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           M17N_FLT_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "m17n-flt") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_M17N_FLT=yes
-  else
-     HAVE_M17N_FLT=no
-  fi
-
-       if test "$HAVE_M17N_FLT" = "yes"; then
-
-$as_echo "#define HAVE_M17N_FLT 1" >>confdefs.h
-
-       fi
-      fi
-    fi
-else
-    HAVE_XFT=no
-    HAVE_FREETYPE=no
-    HAVE_LIBOTF=no
-    HAVE_M17N_FLT=no
-fi
-
-### End of font-backend (under X11) section.
-
-
-
-
-
-
-
-
-
-
-### Use -lXpm if available, unless `--with-xpm=no'.
-### mingw32 doesn't use -lXpm, since it loads the library dynamically.
-HAVE_XPM=no
-LIBXPM=
-if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
-  if test "${with_xpm}" != "no"; then
-    SAVE_CPPFLAGS="$CPPFLAGS"
-    SAVE_LDFLAGS="$LDFLAGS"
-    CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
-    LDFLAGS="$LDFLAGS -L/usr/lib/noX"
-    ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_xpm_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReadFileToImage in -lXpm" >&5
-$as_echo_n "checking for XpmReadFileToImage in -lXpm... " >&6; }
-if test "${ac_cv_lib_Xpm_XpmReadFileToImage+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXpm  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XpmReadFileToImage ();
-int
-main ()
-{
-return XpmReadFileToImage ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xpm_XpmReadFileToImage=yes
-else
-  ac_cv_lib_Xpm_XpmReadFileToImage=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xpm_XpmReadFileToImage" >&5
-$as_echo "$ac_cv_lib_Xpm_XpmReadFileToImage" >&6; }
-if test "x$ac_cv_lib_Xpm_XpmReadFileToImage" = x""yes; then :
-  HAVE_XPM=yes
-fi
-
-fi
-
-
-    if test "${HAVE_XPM}" = "yes"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReturnAllocPixels preprocessor define" >&5
-$as_echo_n "checking for XpmReturnAllocPixels preprocessor define... " >&6; }
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "X11/xpm.h"
-#ifndef XpmReturnAllocPixels
-no_return_alloc_pixels
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "no_return_alloc_pixels" >/dev/null 2>&1; then :
-  HAVE_XPM=no
-else
-  HAVE_XPM=yes
-fi
-rm -f conftest*
-
-
-      if test "${HAVE_XPM}" = "yes"; then
-        REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-      else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-        CPPFLAGS="$SAVE_CPPFLAGS"
-        LDFLAGS="$SAVE_LDFLAGS"
-      fi
-    fi
-  fi
-
-  if test "${HAVE_XPM}" = "yes"; then
-
-$as_echo "#define HAVE_XPM 1" >>confdefs.h
-
-    LIBXPM=-lXpm
-  fi
-fi
-
-if test "${HAVE_X11}" = "yes"; then
-  if test "${with_xpm}" != "no"; then
-    ac_fn_c_check_header_mongrel "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_xpm_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReadFileToPixmap in -lXpm" >&5
-$as_echo_n "checking for XpmReadFileToPixmap in -lXpm... " >&6; }
-if test "${ac_cv_lib_Xpm_XpmReadFileToPixmap+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXpm -lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XpmReadFileToPixmap ();
-int
-main ()
-{
-return XpmReadFileToPixmap ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xpm_XpmReadFileToPixmap=yes
-else
-  ac_cv_lib_Xpm_XpmReadFileToPixmap=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xpm_XpmReadFileToPixmap" >&5
-$as_echo "$ac_cv_lib_Xpm_XpmReadFileToPixmap" >&6; }
-if test "x$ac_cv_lib_Xpm_XpmReadFileToPixmap" = x""yes; then :
-  HAVE_XPM=yes
-fi
-
-fi
-
-
-    if test "${HAVE_XPM}" = "yes"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XpmReturnAllocPixels preprocessor define" >&5
-$as_echo_n "checking for XpmReturnAllocPixels preprocessor define... " >&6; }
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include "X11/xpm.h"
-#ifndef XpmReturnAllocPixels
-no_return_alloc_pixels
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "no_return_alloc_pixels" >/dev/null 2>&1; then :
-  HAVE_XPM=no
-else
-  HAVE_XPM=yes
-fi
-rm -f conftest*
-
-
-      if test "${HAVE_XPM}" = "yes"; then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-      else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-      fi
-    fi
-  fi
-
-  if test "${HAVE_XPM}" = "yes"; then
-
-$as_echo "#define HAVE_XPM 1" >>confdefs.h
-
-    LIBXPM=-lXpm
-  fi
-fi
-
-### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
-### slightly different requirements wrt image libraries (it doesn't
-### use -lXpm because it loads the xpm shared library dynamically at
-### run time).
-if test "${opsys}" = "mingw32"; then
-  if test "${with_xpm}" != "no"; then
-    ac_fn_c_check_header_compile "$LINENO" "X11/xpm.h" "ac_cv_header_X11_xpm_h" "
-#define FOR_MSW 1
-"
-if test "x$ac_cv_header_X11_xpm_h" = x""yes; then :
-  HAVE_XPM=yes
-else
-  HAVE_XPM=no
-fi
-
-
-  fi
-
-  if test "${HAVE_XPM}" = "yes"; then
-
-$as_echo "#define HAVE_XPM 1" >>confdefs.h
-
-  fi
-fi
-
-
-
-### Use -ljpeg if available, unless `--with-jpeg=no'.
-### mingw32 doesn't use -ljpeg, since it loads the library dynamically.
-HAVE_JPEG=no
-LIBJPEG=
-if test "${opsys}" = "mingw32"; then
-  if test "${with_jpeg}" != "no"; then
-            ac_fn_c_check_header_mongrel "$LINENO" "jerror.h" "ac_cv_header_jerror_h" "$ac_includes_default"
-if test "x$ac_cv_header_jerror_h" = x""yes; then :
-  HAVE_JPEG=yes
-else
-  HAVE_JPEG=no
-fi
-
-
-  fi
-    if test "${HAVE_JPEG}" = "yes"; then
-    $as_echo "#define HAVE_JPEG 1" >>confdefs.h
-
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <jpeglib.h>
-        version=JPEG_LIB_VERSION
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "version= *(6[2-9]|[7-9][0-9])" >/dev/null 2>&1; then :
-  $as_echo "#define HAVE_JPEG 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libjpeg found, but not version 6b or later" >&5
-$as_echo "$as_me: WARNING: libjpeg found, but not version 6b or later" >&2;}
-        HAVE_JPEG=no
-fi
-rm -f conftest*
-
-  fi
-elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
-  if test "${with_jpeg}" != "no"; then
-            ac_fn_c_check_header_mongrel "$LINENO" "jerror.h" "ac_cv_header_jerror_h" "$ac_includes_default"
-if test "x$ac_cv_header_jerror_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_destroy_compress in -ljpeg" >&5
-$as_echo_n "checking for jpeg_destroy_compress in -ljpeg... " >&6; }
-if test "${ac_cv_lib_jpeg_jpeg_destroy_compress+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ljpeg  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char jpeg_destroy_compress ();
-int
-main ()
-{
-return jpeg_destroy_compress ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_jpeg_jpeg_destroy_compress=yes
-else
-  ac_cv_lib_jpeg_jpeg_destroy_compress=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_destroy_compress" >&5
-$as_echo "$ac_cv_lib_jpeg_jpeg_destroy_compress" >&6; }
-if test "x$ac_cv_lib_jpeg_jpeg_destroy_compress" = x""yes; then :
-  HAVE_JPEG=yes
-fi
-
-fi
-
-
-  fi
-
-    if test "${HAVE_JPEG}" = "yes"; then
-    $as_echo "#define HAVE_JPEG 1" >>confdefs.h
-
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <jpeglib.h>
-        version=JPEG_LIB_VERSION
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "version= *(6[2-9]|[7-9][0-9])" >/dev/null 2>&1; then :
-  $as_echo "#define HAVE_JPEG 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libjpeg found, but not version 6b or later" >&5
-$as_echo "$as_me: WARNING: libjpeg found, but not version 6b or later" >&2;}
-       HAVE_JPEG=no
-fi
-rm -f conftest*
-
-  fi
-  if test "${HAVE_JPEG}" = "yes"; then
-    LIBJPEG=-ljpeg
-  fi
-fi
-
-
-### Use -lpng if available, unless `--with-png=no'.
-### mingw32 doesn't use -lpng, since it loads the library dynamically.
-HAVE_PNG=no
-LIBPNG=
-if test "${opsys}" = "mingw32"; then
-  if test "${with_png}" != "no"; then
-    ac_fn_c_check_header_mongrel "$LINENO" "png.h" "ac_cv_header_png_h" "$ac_includes_default"
-if test "x$ac_cv_header_png_h" = x""yes; then :
-  HAVE_PNG=yes
-else
-  HAVE_PNG=no
-fi
-
-
-  fi
-  if test "${HAVE_PNG}" = "yes"; then
-
-$as_echo "#define HAVE_PNG 1" >>confdefs.h
-
-
-    ac_fn_c_check_decl "$LINENO" "png_longjmp" "ac_cv_have_decl_png_longjmp" "#ifdef HAVE_LIBPNG_PNG_H
-       # include <libpng/png.h>
-       #else
-       # include <png.h>
-       #endif
-
-"
-if test "x$ac_cv_have_decl_png_longjmp" = x""yes; then :
-
-else
-
-$as_echo "#define PNG_DEPSTRUCT /**/" >>confdefs.h
-
-fi
-
-  fi
-elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
-  if test "${with_png}" != "no"; then
-    # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
-    # in /usr/include/libpng.
-    for ac_header in png.h libpng/png.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
- break
-fi
-
-done
-
-    if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_get_channels in -lpng" >&5
-$as_echo_n "checking for png_get_channels in -lpng... " >&6; }
-if test "${ac_cv_lib_png_png_get_channels+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpng -lz -lm $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char png_get_channels ();
-int
-main ()
-{
-return png_get_channels ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_png_png_get_channels=yes
-else
-  ac_cv_lib_png_png_get_channels=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_get_channels" >&5
-$as_echo "$ac_cv_lib_png_png_get_channels" >&6; }
-if test "x$ac_cv_lib_png_png_get_channels" = x""yes; then :
-  HAVE_PNG=yes
-fi
-
-    fi
-  fi
-
-  if test "${HAVE_PNG}" = "yes"; then
-
-$as_echo "#define HAVE_PNG 1" >>confdefs.h
-
-    LIBPNG="-lpng -lz -lm"
-
-    ac_fn_c_check_decl "$LINENO" "png_longjmp" "ac_cv_have_decl_png_longjmp" "#ifdef HAVE_LIBPNG_PNG_H
-       # include <libpng/png.h>
-       #else
-       # include <png.h>
-       #endif
-
-"
-if test "x$ac_cv_have_decl_png_longjmp" = x""yes; then :
-
-else
-
-$as_echo "#define PNG_DEPSTRUCT /**/" >>confdefs.h
-
-fi
-
-  fi
-fi
-
-
-HAVE_ZLIB=no
-LIBZ=
-if test "${with_zlib}" != "no"; then
-  OLIBS=$LIBS
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inflateEnd" >&5
-$as_echo_n "checking for library containing inflateEnd... " >&6; }
-if test "${ac_cv_search_inflateEnd+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char inflateEnd ();
-int
-main ()
-{
-return inflateEnd ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_inflateEnd=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_inflateEnd+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_inflateEnd+set}" = set; then :
-
-else
-  ac_cv_search_inflateEnd=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inflateEnd" >&5
-$as_echo "$ac_cv_search_inflateEnd" >&6; }
-ac_res=$ac_cv_search_inflateEnd
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  HAVE_ZLIB=yes
-fi
-
-  LIBS=$OLIBS
-  case $ac_cv_search_inflateEnd in
-    -*) LIBZ=$ac_cv_search_inflateEnd ;;
-  esac
-fi
-if test "${HAVE_ZLIB}" = "yes"; then
-
-$as_echo "#define HAVE_ZLIB 1" >>confdefs.h
-
-  ### mingw32 doesn't use -lz, since it loads the library dynamically.
-  if test "${opsys}" = "mingw32"; then
-     LIBZ=
-  fi
-fi
-
-
-
-### Use -ltiff if available, unless `--with-tiff=no'.
-### mingw32 doesn't use -ltiff, since it loads the library dynamically.
-HAVE_TIFF=no
-LIBTIFF=
-if test "${opsys}" = "mingw32"; then
-  if test "${with_tiff}" != "no"; then
-    ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default"
-if test "x$ac_cv_header_tiffio_h" = x""yes; then :
-  HAVE_TIFF=yes
-else
-  HAVE_TIFF=no
-fi
-
-
-  fi
-  if test "${HAVE_TIFF}" = "yes"; then
-
-$as_echo "#define HAVE_TIFF 1" >>confdefs.h
-
-  fi
-elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
-  if test "${with_tiff}" != "no"; then
-    ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default"
-if test "x$ac_cv_header_tiffio_h" = x""yes; then :
-  tifflibs="-lz -lm"
-      # At least one tiff package requires the jpeg library.
-      if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIFFGetVersion in -ltiff" >&5
-$as_echo_n "checking for TIFFGetVersion in -ltiff... " >&6; }
-if test "${ac_cv_lib_tiff_TIFFGetVersion+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltiff $tifflibs $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char TIFFGetVersion ();
-int
-main ()
-{
-return TIFFGetVersion ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_tiff_TIFFGetVersion=yes
-else
-  ac_cv_lib_tiff_TIFFGetVersion=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tiff_TIFFGetVersion" >&5
-$as_echo "$ac_cv_lib_tiff_TIFFGetVersion" >&6; }
-if test "x$ac_cv_lib_tiff_TIFFGetVersion" = x""yes; then :
-  HAVE_TIFF=yes
-fi
-
-fi
-
-
-  fi
-
-  if test "${HAVE_TIFF}" = "yes"; then
-
-$as_echo "#define HAVE_TIFF 1" >>confdefs.h
-
-        LIBTIFF=-ltiff
-  fi
-fi
-
-
-### Use -lgif or -lungif if available, unless `--with-gif=no'.
-### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
-HAVE_GIF=no
-LIBGIF=
-if test "${opsys}" = "mingw32"; then
-  if test "${with_gif}" != "no"; then
-    ac_fn_c_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default"
-if test "x$ac_cv_header_gif_lib_h" = x""yes; then :
-  HAVE_GIF=yes
-else
-  HAVE_GIF=no
-fi
-
-
-  fi
-  if test "${HAVE_GIF}" = "yes"; then
-
-$as_echo "#define HAVE_GIF 1" >>confdefs.h
-
-  fi
-elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
-        || test "${HAVE_W32}" = "yes"; then
-  ac_fn_c_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default"
-if test "x$ac_cv_header_gif_lib_h" = x""yes; then :
-  # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
-# Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GifMakeMapObject in -lgif" >&5
-$as_echo_n "checking for GifMakeMapObject in -lgif... " >&6; }
-if test "${ac_cv_lib_gif_GifMakeMapObject+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgif  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char GifMakeMapObject ();
-int
-main ()
-{
-return GifMakeMapObject ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gif_GifMakeMapObject=yes
-else
-  ac_cv_lib_gif_GifMakeMapObject=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_GifMakeMapObject" >&5
-$as_echo "$ac_cv_lib_gif_GifMakeMapObject" >&6; }
-if test "x$ac_cv_lib_gif_GifMakeMapObject" = x""yes; then :
-  HAVE_GIF=yes
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGifPutExtensionLast in -lgif" >&5
-$as_echo_n "checking for EGifPutExtensionLast in -lgif... " >&6; }
-if test "${ac_cv_lib_gif_EGifPutExtensionLast+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgif  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char EGifPutExtensionLast ();
-int
-main ()
-{
-return EGifPutExtensionLast ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gif_EGifPutExtensionLast=yes
-else
-  ac_cv_lib_gif_EGifPutExtensionLast=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_EGifPutExtensionLast" >&5
-$as_echo "$ac_cv_lib_gif_EGifPutExtensionLast" >&6; }
-if test "x$ac_cv_lib_gif_EGifPutExtensionLast" = x""yes; then :
-  HAVE_GIF=yes
-else
-  HAVE_GIF=maybe
-fi
-
-fi
-
-fi
-
-
-
-  if test "$HAVE_GIF" = yes; then
-    LIBGIF=-lgif
-  elif test "$HAVE_GIF" = maybe; then
-# If gif_lib.h but no libgif, try libungif.
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGifPutExtensionLast in -lungif" >&5
-$as_echo_n "checking for EGifPutExtensionLast in -lungif... " >&6; }
-if test "${ac_cv_lib_ungif_EGifPutExtensionLast+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lungif  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char EGifPutExtensionLast ();
-int
-main ()
-{
-return EGifPutExtensionLast ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_ungif_EGifPutExtensionLast=yes
-else
-  ac_cv_lib_ungif_EGifPutExtensionLast=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ungif_EGifPutExtensionLast" >&5
-$as_echo "$ac_cv_lib_ungif_EGifPutExtensionLast" >&6; }
-if test "x$ac_cv_lib_ungif_EGifPutExtensionLast" = x""yes; then :
-  HAVE_GIF=yes
-else
-  HAVE_GIF=no
-fi
-
-    test "$HAVE_GIF" = yes && LIBGIF=-lungif
-  fi
-
-  if test "${HAVE_GIF}" = "yes"; then
-
-$as_echo "#define HAVE_GIF 1" >>confdefs.h
-
-  fi
-fi
-
-
-if test "${HAVE_X11}" = "yes"; then
-  MISSING=""
-  WITH_NO=""
-  test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
-    MISSING="libXpm" && WITH_NO="--with-xpm=no"
-  test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
-    MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
-  test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
-    MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
-  test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
-    MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
-  test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
-    MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
-
-  if test "X${MISSING}" != X; then
-    as_fn_error "The following required libraries were not found:
-    $MISSING
-Maybe some development libraries/packages are missing?
-If you don't want to link with them give
-    $WITH_NO
-as options to configure" "$LINENO" 5
-  fi
-fi
-
-### Use -lgpm if available, unless `--with-gpm=no'.
-HAVE_GPM=no
-LIBGPM=
-if test "${with_gpm}" != "no"; then
-  ac_fn_c_check_header_mongrel "$LINENO" "gpm.h" "ac_cv_header_gpm_h" "$ac_includes_default"
-if test "x$ac_cv_header_gpm_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Gpm_Open in -lgpm" >&5
-$as_echo_n "checking for Gpm_Open in -lgpm... " >&6; }
-if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgpm  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char Gpm_Open ();
-int
-main ()
-{
-return Gpm_Open ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gpm_Gpm_Open=yes
-else
-  ac_cv_lib_gpm_Gpm_Open=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gpm_Gpm_Open" >&5
-$as_echo "$ac_cv_lib_gpm_Gpm_Open" >&6; }
-if test "x$ac_cv_lib_gpm_Gpm_Open" = x""yes; then :
-  HAVE_GPM=yes
-fi
-
-fi
-
-
-
-  if test "${HAVE_GPM}" = "yes"; then
-
-$as_echo "#define HAVE_GPM 1" >>confdefs.h
-
-    LIBGPM=-lgpm
-  fi
-fi
-
-
-
-
-
-
-GNUSTEP_CFLAGS=
-### Use NeXTstep API to implement GUI.
-if test "${HAVE_NS}" = "yes"; then
-
-$as_echo "#define HAVE_NS 1" >>confdefs.h
-
-  if test "${NS_IMPL_COCOA}" = "yes"; then
-
-$as_echo "#define NS_IMPL_COCOA 1" >>confdefs.h
-
-  fi
-  if test "${NS_IMPL_GNUSTEP}" = "yes"; then
-
-$as_echo "#define NS_IMPL_GNUSTEP 1" >>confdefs.h
-
-    # See also .m.o rule in Makefile.in */
-    # FIXME: are all these flags really needed?  Document here why.  */
-    GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
-    ## Extra CFLAGS applied to src/*.m files.
-    GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"
-  fi
-  OTHER_FILES=ns-app
-fi
-
-### Use session management (-lSM -lICE) if available
-HAVE_X_SM=no
-LIBXSM=
-if test "${HAVE_X11}" = "yes"; then
-  ac_fn_c_check_header_mongrel "$LINENO" "X11/SM/SMlib.h" "ac_cv_header_X11_SM_SMlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_SM_SMlib_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SmcOpenConnection in -lSM" >&5
-$as_echo_n "checking for SmcOpenConnection in -lSM... " >&6; }
-if test "${ac_cv_lib_SM_SmcOpenConnection+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lSM -lICE $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char SmcOpenConnection ();
-int
-main ()
-{
-return SmcOpenConnection ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_SM_SmcOpenConnection=yes
-else
-  ac_cv_lib_SM_SmcOpenConnection=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_SM_SmcOpenConnection" >&5
-$as_echo "$ac_cv_lib_SM_SmcOpenConnection" >&6; }
-if test "x$ac_cv_lib_SM_SmcOpenConnection" = x""yes; then :
-  HAVE_X_SM=yes
-fi
-
-fi
-
-
-
-  if test "${HAVE_X_SM}" = "yes"; then
-
-$as_echo "#define HAVE_X_SM 1" >>confdefs.h
-
-    LIBXSM="-lSM -lICE"
-    case "$LIBS" in
-      *-lSM*) ;;
-      *)      LIBS="$LIBXSM $LIBS" ;;
-    esac
-  fi
-fi
-
-
-### Use XRandr (-lXrandr) if available
-HAVE_XRANDR=no
-if test "${HAVE_X11}" = "yes"; then
-  XRANDR_REQUIRED=1.2.2
-  XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_XRANDR=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $XRANDR_MODULES" >&5
-$as_echo_n "checking for $XRANDR_MODULES... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$XRANDR_MODULES" 2>&5 &&
-          XRANDR_CFLAGS=`"$PKG_CONFIG" --cflags "$XRANDR_MODULES" 2>&5` &&
-          XRANDR_LIBS=`"$PKG_CONFIG" --libs "$XRANDR_MODULES" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           XRANDR_CFLAGS=`$as_echo "$XRANDR_CFLAGS" | sed -e "$edit_cflags"`
-           XRANDR_LIBS=`$as_echo "$XRANDR_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$XRANDR_CFLAGS' LIBS='$XRANDR_LIBS'" >&5
-$as_echo "yes CFLAGS='$XRANDR_CFLAGS' LIBS='$XRANDR_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            XRANDR_CFLAGS=""
-            XRANDR_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           XRANDR_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$XRANDR_MODULES") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_XRANDR=yes
-  else
-     HAVE_XRANDR=no
-  fi
-
-  if test $HAVE_XRANDR = no; then
-    # Test old way in case pkg-config doesn't have it (older machines).
-    ac_fn_c_check_header_mongrel "$LINENO" "X11/extensions/Xrandr.h" "ac_cv_header_X11_extensions_Xrandr_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_extensions_Xrandr_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XRRGetScreenResources in -lXrandr" >&5
-$as_echo_n "checking for XRRGetScreenResources in -lXrandr... " >&6; }
-if test "${ac_cv_lib_Xrandr_XRRGetScreenResources+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXrandr  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XRRGetScreenResources ();
-int
-main ()
-{
-return XRRGetScreenResources ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xrandr_XRRGetScreenResources=yes
-else
-  ac_cv_lib_Xrandr_XRRGetScreenResources=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xrandr_XRRGetScreenResources" >&5
-$as_echo "$ac_cv_lib_Xrandr_XRRGetScreenResources" >&6; }
-if test "x$ac_cv_lib_Xrandr_XRRGetScreenResources" = x""yes; then :
-  HAVE_XRANDR=yes
-fi
-
-fi
-
-
-    if test $HAVE_XRANDR = yes; then
-      XRANDR_LIBS=-lXrandr
-
-    fi
-  fi
-  if test $HAVE_XRANDR = yes; then
-    SAVE_CFLAGS="$CFLAGS"
-    SAVE_LIBS="$LIBS"
-    CFLAGS="$XRANDR_CFLAGS $CFLAGS"
-    LIBS="$XRANDR_LIBS $LIBS"
-    for ac_func in XRRGetOutputPrimary XRRGetScreenResourcesCurrent
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-    CFLAGS="$SAVE_CFLAGS"
-    LIBS="$SAVE_LIBS"
-
-
-$as_echo "#define HAVE_XRANDR 1" >>confdefs.h
-
-  fi
-fi
-
-### Use Xinerama (-lXinerama) if available
-HAVE_XINERAMA=no
-if test "${HAVE_X11}" = "yes"; then
-  XINERAMA_REQUIRED=1.0.2
-  XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_XINERAMA=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $XINERAMA_MODULES" >&5
-$as_echo_n "checking for $XINERAMA_MODULES... " >&6; }
-
-        if "$PKG_CONFIG" --exists "$XINERAMA_MODULES" 2>&5 &&
-          XINERAMA_CFLAGS=`"$PKG_CONFIG" --cflags "$XINERAMA_MODULES" 2>&5` &&
-          XINERAMA_LIBS=`"$PKG_CONFIG" --libs "$XINERAMA_MODULES" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           XINERAMA_CFLAGS=`$as_echo "$XINERAMA_CFLAGS" | sed -e "$edit_cflags"`
-           XINERAMA_LIBS=`$as_echo "$XINERAMA_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$XINERAMA_CFLAGS' LIBS='$XINERAMA_LIBS'" >&5
-$as_echo "yes CFLAGS='$XINERAMA_CFLAGS' LIBS='$XINERAMA_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            XINERAMA_CFLAGS=""
-            XINERAMA_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           XINERAMA_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$XINERAMA_MODULES") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_XINERAMA=yes
-  else
-     HAVE_XINERAMA=no
-  fi
-
-  if test $HAVE_XINERAMA = no; then
-    # Test old way in case pkg-config doesn't have it (older machines).
-    ac_fn_c_check_header_mongrel "$LINENO" "X11/extensions/Xinerama.h" "ac_cv_header_X11_extensions_Xinerama_h" "$ac_includes_default"
-if test "x$ac_cv_header_X11_extensions_Xinerama_h" = x""yes; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XineramaQueryExtension in -lXinerama" >&5
-$as_echo_n "checking for XineramaQueryExtension in -lXinerama... " >&6; }
-if test "${ac_cv_lib_Xinerama_XineramaQueryExtension+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXinerama  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XineramaQueryExtension ();
-int
-main ()
-{
-return XineramaQueryExtension ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_Xinerama_XineramaQueryExtension=yes
-else
-  ac_cv_lib_Xinerama_XineramaQueryExtension=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xinerama_XineramaQueryExtension" >&5
-$as_echo "$ac_cv_lib_Xinerama_XineramaQueryExtension" >&6; }
-if test "x$ac_cv_lib_Xinerama_XineramaQueryExtension" = x""yes; then :
-  HAVE_XINERAMA=yes
-fi
-
-fi
-
-
-    if test $HAVE_XINERAMA = yes; then
-      XINERAMA_LIBS=-lXinerama
-
-    fi
-  fi
-  if test $HAVE_XINERAMA = yes; then
-
-$as_echo "#define HAVE_XINERAMA 1" >>confdefs.h
-
-  fi
-fi
-
-
-### Use libxml (-lxml2) if available
-### mingw32 doesn't use -lxml2, since it loads the library dynamically.
-HAVE_LIBXML2=no
-if test "${with_xml2}" != "no"; then
-  ### I'm not sure what the version number should be, so I just guessed.
-
-  succeeded=no
-
-  if test "$PKG_CONFIG" = "no" ; then
-     HAVE_LIBXML2=no
-  else
-     PKG_CONFIG_MIN_VERSION=0.9.0
-     if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml-2.0 > 2.6.17" >&5
-$as_echo_n "checking for libxml-2.0 > 2.6.17... " >&6; }
-
-        if "$PKG_CONFIG" --exists "libxml-2.0 > 2.6.17" 2>&5 &&
-          LIBXML2_CFLAGS=`"$PKG_CONFIG" --cflags "libxml-2.0 > 2.6.17" 2>&5` &&
-          LIBXML2_LIBS=`"$PKG_CONFIG" --libs "libxml-2.0 > 2.6.17" 2>&5`; then
-           edit_cflags="
-             s,///*,/,g
-             s/^/ /
-             s/ -I/ $isystem/g
-             s/^ //
-           "
-           LIBXML2_CFLAGS=`$as_echo "$LIBXML2_CFLAGS" | sed -e "$edit_cflags"`
-           LIBXML2_LIBS=`$as_echo "$LIBXML2_LIBS" | sed -e 's,///*,/,g'`
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS'" >&5
-$as_echo "yes CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS'" >&6; }
-            succeeded=yes
-        else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-            LIBXML2_CFLAGS=""
-            LIBXML2_LIBS=""
-            ## If we have a custom action on failure, don't print errors, but
-           ## do set a variable so people can do so.  Do it in a subshell
-           ## to capture any diagnostics in invoking pkg-config.
-           LIBXML2_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "libxml-2.0 > 2.6.17") 2>&1`
-
-        fi
-
-
-
-     else
-        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-        echo "*** See http://www.freedesktop.org/software/pkgconfig"
-     fi
-  fi
-
-  if test $succeeded = yes; then
-     HAVE_LIBXML2=yes
-  else
-     HAVE_LIBXML2=no
-  fi
-
-  # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
-  if test "${HAVE_LIBXML2}" != "yes" -a "$opsys" = "darwin"; then
-    SAVE_CPPFLAGS="$CPPFLAGS"
-    CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
-    ac_fn_c_check_header_mongrel "$LINENO" "libxml/HTMLparser.h" "ac_cv_header_libxml_HTMLparser_h" "$ac_includes_default"
-if test "x$ac_cv_header_libxml_HTMLparser_h" = x""yes; then :
-  ac_fn_c_check_decl "$LINENO" "HTML_PARSE_RECOVER" "ac_cv_have_decl_HTML_PARSE_RECOVER" "#include <libxml/HTMLparser.h>
-"
-if test "x$ac_cv_have_decl_HTML_PARSE_RECOVER" = x""yes; then :
-  HAVE_LIBXML2=yes
-fi
-
-fi
-
-
-    CPPFLAGS="$SAVE_CPPFLAGS"
-    if test "${HAVE_LIBXML2}" = "yes"; then
-      LIBXML2_LIBS="-lxml2"
-      LIBXML2_CFLAGS="-I/usr/include/libxml2"
-    fi
-  fi
-  if test "${HAVE_LIBXML2}" = "yes"; then
-    if test "${opsys}" != "mingw32"; then
-      LIBS="$LIBXML2_LIBS $LIBS"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for htmlReadMemory in -lxml2" >&5
-$as_echo_n "checking for htmlReadMemory in -lxml2... " >&6; }
-if test "${ac_cv_lib_xml2_htmlReadMemory+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lxml2  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char htmlReadMemory ();
-int
-main ()
-{
-return htmlReadMemory ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_xml2_htmlReadMemory=yes
-else
-  ac_cv_lib_xml2_htmlReadMemory=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_htmlReadMemory" >&5
-$as_echo "$ac_cv_lib_xml2_htmlReadMemory" >&6; }
-if test "x$ac_cv_lib_xml2_htmlReadMemory" = x""yes; then :
-  HAVE_LIBXML2=yes
-else
-  HAVE_LIBXML2=no
-fi
-
-    else
-      LIBXML2_LIBS=""
-    fi
-    if test "${HAVE_LIBXML2}" = "yes"; then
-
-$as_echo "#define HAVE_LIBXML2 1" >>confdefs.h
-
-    else
-      LIBXML2_LIBS=""
-      LIBXML2_CFLAGS=""
-    fi
-  fi
-fi
-
-
-
-# If netdb.h doesn't declare h_errno, we must declare it by hand.
-# On MinGW, that is provided by nt/inc/sys/socket.h and w32.c.
-if test "${opsys}" = "mingw32"; then
-  emacs_cv_netdb_declares_h_errno=yes
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether netdb declares h_errno" >&5
-$as_echo_n "checking whether netdb declares h_errno... " >&6; }
-if test "${emacs_cv_netdb_declares_h_errno+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <netdb.h>
-int
-main ()
-{
-return h_errno;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_netdb_declares_h_errno=yes
-else
-  emacs_cv_netdb_declares_h_errno=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_netdb_declares_h_errno" >&5
-$as_echo "$emacs_cv_netdb_declares_h_errno" >&6; }
-if test $emacs_cv_netdb_declares_h_errno = yes; then
-
-$as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h
-
-fi
-
-# sqrt and other floating-point functions such as fmod and frexp
-# are found in -lm on most systems, but mingw32 doesn't use -lm.
-if test "${opsys}" != "mingw32"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5
-$as_echo_n "checking for sqrt in -lm... " >&6; }
-if test "${ac_cv_lib_m_sqrt+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char sqrt ();
-int
-main ()
-{
-return sqrt ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_m_sqrt=yes
-else
-  ac_cv_lib_m_sqrt=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sqrt" >&5
-$as_echo "$ac_cv_lib_m_sqrt" >&6; }
-if test "x$ac_cv_lib_m_sqrt" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-fi
-
-fi
-
-# Check for mail-locking functions in a "mail" library.  Probably this should
-# have the same check as for liblockfile below.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for maillock in -lmail" >&5
-$as_echo_n "checking for maillock in -lmail... " >&6; }
-if test "${ac_cv_lib_mail_maillock+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmail  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char maillock ();
-int
-main ()
-{
-return maillock ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_mail_maillock=yes
-else
-  ac_cv_lib_mail_maillock=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mail_maillock" >&5
-$as_echo "$ac_cv_lib_mail_maillock" >&6; }
-if test "x$ac_cv_lib_mail_maillock" = x""yes; then :
-  have_mail=yes
-else
-  have_mail=no
-fi
-
-if test $have_mail = yes; then
-  LIBS_MAIL=-lmail
-  LIBS="$LIBS_MAIL $LIBS"
-
-$as_echo "#define HAVE_LIBMAIL 1" >>confdefs.h
-
-else
-  LIBS_MAIL=
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for maillock in -llockfile" >&5
-$as_echo_n "checking for maillock in -llockfile... " >&6; }
-if test "${ac_cv_lib_lockfile_maillock+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-llockfile  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char maillock ();
-int
-main ()
-{
-return maillock ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_lockfile_maillock=yes
-else
-  ac_cv_lib_lockfile_maillock=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lockfile_maillock" >&5
-$as_echo "$ac_cv_lib_lockfile_maillock" >&6; }
-if test "x$ac_cv_lib_lockfile_maillock" = x""yes; then :
-  have_lockfile=yes
-else
-  have_lockfile=no
-fi
-
-if test $have_lockfile = yes; then
-   LIBS_MAIL=-llockfile
-   LIBS="$LIBS_MAIL $LIBS"
-
-$as_echo "#define HAVE_LIBLOCKFILE 1" >>confdefs.h
-
-else
-# If we have the shared liblockfile, assume we must use it for mail
-# locking (e.g. Debian).  If we couldn't link against liblockfile
-# (no liblockfile.a installed), ensure that we don't need to.
-      # Extract the first word of "liblockfile.so", so it can be a program name with args.
-set dummy liblockfile.so; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_liblockfile+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$liblockfile"; then
-  ac_cv_prog_liblockfile="$liblockfile" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_dummy="/usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH"
-for as_dir in $as_dummy
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_liblockfile="yes"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_prog_liblockfile" && ac_cv_prog_liblockfile="no"
-fi
-fi
-liblockfile=$ac_cv_prog_liblockfile
-if test -n "$liblockfile"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $liblockfile" >&5
-$as_echo "$liblockfile" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  if test $ac_cv_prog_liblockfile = yes; then
-    as_fn_error "Shared liblockfile found but can't link against it.
-This probably means that movemail could lose mail.
-There may be a \`development' package to install containing liblockfile." "$LINENO" 5
-  fi
-fi
-
-
-
-
-
-## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
-## interlock access to the mail spool.  The alternative is a lock file named
-## /usr/spool/mail/$USER.lock.
-mail_lock=no
-case "$opsys" in
-  aix4-2) mail_lock="lockf" ;;
-
-  gnu|freebsd|dragonfly|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;;
-
-  ## On GNU/Linux systems, both methods are used by various mail programs.
-  ## I assume most people are using newer mailers that have heard of flock.
-  ## Change this if you need to.
-  ## Debian contains a patch which says: ``On Debian/GNU/Linux systems,
-  ## configure gets the right answers, and that means *NOT* using flock.
-  ## Using flock is guaranteed to be the wrong thing. See Debian Policy
-  ## for details.'' and then uses `#ifdef DEBIAN'.  Unfortunately the
-  ## Debian maintainer hasn't provided a clean fix for Emacs.
-  ## movemail.c will use `maillock' when MAILDIR, HAVE_LIBMAIL and
-  ## HAVE_MAILLOCK_H are defined, so the following appears to be the
-  ## correct logic.  -- fx
-  ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
-  ## liblockfile is a Free Software replacement for libmail, used on
-  ## Debian systems and elsewhere. -rfr.
-  gnu-*)
-    mail_lock="flock"
-    if test $have_mail = yes || test $have_lockfile = yes; then
-      test $ac_cv_header_maillock_h = yes && mail_lock=no
-    fi
-    ;;
-
-  mingw32)
-    mail_lock="none-needed" ;;
-esac
-
-BLESSMAIL_TARGET=
-case "$mail_lock" in
-  flock)
-$as_echo "#define MAIL_USE_FLOCK 1" >>confdefs.h
- ;;
-
-  lockf)
-$as_echo "#define MAIL_USE_LOCKF 1" >>confdefs.h
- ;;
-
-  none-needed) ;;
-
-  *) BLESSMAIL_TARGET="need-blessmail" ;;
-esac
-
-
-
-for ac_func in accept4 gethostname \
-getrusage get_current_dir_name \
-lrand48 \
-select getpagesize setlocale \
-getrlimit setrlimit shutdown getaddrinfo \
-strsignal setitimer \
-sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
-gai_strerror getline getdelim sync \
-difftime posix_memalign \
-getpwent endpwent getgrent endgrent \
-touchlock \
-cfmakeraw cfsetspeed copysign __executable_start log2
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
-## has a broken `rint' in some library versions including math library
-## version number A.09.05.
-## You can fix the math library by installing patch number PHSS_4630.
-## But we can fix it more reliably for Emacs by just not using rint.
-## We also skip HAVE_RANDOM - see comments in src/conf_post.h.
-case $opsys in
-   hpux*) : ;;
-   *) for ac_func in random rint
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
- ;;
-esac
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_unwind_init" >&5
-$as_echo_n "checking for __builtin_unwind_init... " >&6; }
-if test "${emacs_cv_func___builtin_unwind_init+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-__builtin_unwind_init ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_func___builtin_unwind_init=yes
-else
-  emacs_cv_func___builtin_unwind_init=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_func___builtin_unwind_init" >&5
-$as_echo "$emacs_cv_func___builtin_unwind_init" >&6; }
-if test $emacs_cv_func___builtin_unwind_init = yes; then
-
-$as_echo "#define HAVE___BUILTIN_UNWIND_INIT 1" >>confdefs.h
-
-fi
-
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
-$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_source+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  while :; do
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_sys_largefile_source=no; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
-int
-main ()
-{
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_sys_largefile_source=1; break
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  ac_cv_sys_largefile_source=unknown
-  break
-done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5
-$as_echo "$ac_cv_sys_largefile_source" >&6; }
-case $ac_cv_sys_largefile_source in #(
-  no | unknown) ;;
-  *)
-cat >>confdefs.h <<_ACEOF
-#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
-_ACEOF
-;;
-esac
-rm -rf conftest*
-
-# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
-# in glibc 2.1.3, but that breaks too many other things.
-# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-if test $ac_cv_sys_largefile_source != unknown; then
-
-$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
-
-fi
-
-
-# UNIX98 PTYs.
-for ac_func in grantpt
-do :
-  ac_fn_c_check_func "$LINENO" "grantpt" "ac_cv_func_grantpt"
-if test "x$ac_cv_func_grantpt" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GRANTPT 1
-_ACEOF
-
-fi
-done
-
-
-# PTY-related GNU extensions.
-for ac_func in getpt posix_openpt
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-# Check this now, so that we will NOT find the above functions in ncurses.
-# That is because we have not set up to link ncurses in lib-src.
-# It's better to believe a function is not available
-# than to expect to find it in ncurses.
-# Also we need tputs and friends to be able to build at all.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tputs" >&5
-$as_echo_n "checking for library containing tputs... " >&6; }
-# Run a test program that contains a call to tputs, a call that is
-# never executed.  This tests whether a pre-'main' dynamic linker
-# works with the library.  It's too much trouble to actually call
-# tputs in the test program, due to portability hassles.  When
-# cross-compiling, assume the test program will run if it links.
-
-if test "${opsys}" = "mingw32"; then
-  msg='none required'
-else
-  # Maybe curses should be tried earlier?
-  # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
-  for tputs_library in '' tinfo ncurses terminfo termcap curses; do
-    OLIBS=$LIBS
-    if test -z "$tputs_library"; then
-      LIBS_TERMCAP=
-      msg='none required'
-    else
-      LIBS_TERMCAP=-l$tputs_library
-      msg=$LIBS_TERMCAP
-      LIBS="$LIBS_TERMCAP $LIBS"
-    fi
-    if test "$cross_compiling" = yes; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  extern void tputs (const char *, int, int (*)(int));
-       int main (int argc, char **argv)
-       {
-         if (argc == 10000)
-           tputs (argv[0], 0, 0);
-         return 0;
-       }
-
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  msg=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  extern void tputs (const char *, int, int (*)(int));
-       int main (int argc, char **argv)
-       {
-         if (argc == 10000)
-           tputs (argv[0], 0, 0);
-         return 0;
-       }
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  msg=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-    LIBS=$OLIBS
-    if test "X$msg" != Xno; then
-      break
-    fi
-  done
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5
-$as_echo "$msg" >&6; }
-if test "X$msg" = Xno; then
-  as_fn_error "The required function \`tputs' was not found in any library.
-The following libraries were tried (in order):
-  libtinfo, libncurses, libterminfo, libtermcap, libcurses
-Please try installing whichever of these libraries is most appropriate
-for your system, together with its header files.
-For example, a libncurses-dev(el) or similar package." "$LINENO" 5
-fi
-
-## Use termcap instead of terminfo?
-## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
-TERMINFO=yes
-## FIXME?  In the cases below where we unconditionally set
-## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
-## if that was found above to have tputs.
-## Should we use the gnu* logic everywhere?
-case "$opsys" in
-  ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
-  ##  The ncurses library has been moved out of the System framework in
-  ##  Mac OS X 10.2.  So if configure detects it, set the command-line
-  ##  option to use it.
-  darwin) LIBS_TERMCAP="-lncurses" ;;
-
-  gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
-
-  freebsd)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether FreeBSD is new enough to use terminfo" >&5
-$as_echo_n "checking whether FreeBSD is new enough to use terminfo... " >&6; }
-    if test "${emacs_cv_freebsd_terminfo+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <osreldate.h>
-int
-main ()
-{
-#if __FreeBSD_version < 400000
-fail;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_freebsd_terminfo=yes
-else
-  emacs_cv_freebsd_terminfo=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_freebsd_terminfo" >&5
-$as_echo "$emacs_cv_freebsd_terminfo" >&6; }
-
-    if test $emacs_cv_freebsd_terminfo = yes; then
-      LIBS_TERMCAP="-lncurses"
-    else
-      TERMINFO=no
-      LIBS_TERMCAP="-ltermcap"
-    fi
-    ;;
-
-  mingw32)
-    TERMINFO=no
-    LIBS_TERMCAP=
-    ;;
-
-  netbsd)
-    if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
-      TERMINFO=no
-      LIBS_TERMCAP="-ltermcap"
-    fi
-    ;;
-
-  openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
-
-  ## hpux: Make sure we get select from libc rather than from libcurses
-  ##  because libcurses on HPUX 10.10 has a broken version of select.
-  ##  We used to use -lc -lcurses, but this may be cleaner.
-  ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
-  # set that way, now it uses the default).  Isn't this a contradiction?
-  hpux*) LIBS_TERMCAP="-ltermcap" ;;
-
-esac
-
-TERMCAP_OBJ=tparam.o
-if test $TERMINFO = yes; then
-
-$as_echo "#define TERMINFO 1" >>confdefs.h
-
-  TERMCAP_OBJ=terminfo.o
-fi
-if test "X$LIBS_TERMCAP" = "X-lncurses"; then
-
-$as_echo "#define USE_NCURSES 1" >>confdefs.h
-
-fi
-
-
-
-
-# Do we have res_init, for detecting changes in /etc/resolv.conf?
-# On Darwin, res_init appears not to be useful: see bug#562 and
-# http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html
-resolv=no
-
-if test $opsys != darwin; then
-
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-int
-main ()
-{
-return res_init();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  have_res_init=yes
-else
-  have_res_init=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test "$have_res_init" = no; then
-    OLIBS="$LIBS"
-    LIBS="$LIBS -lresolv"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_init with -lresolv" >&5
-$as_echo_n "checking for res_init with -lresolv... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
-int
-main ()
-{
-return res_init();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  have_res_init=yes
-else
-  have_res_init=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_res_init" >&5
-$as_echo "$have_res_init" >&6; }
-    if test "$have_res_init" = yes ; then
-      resolv=yes
-    fi
-    LIBS="$OLIBS"
-  fi
-
-  if test "$have_res_init" = yes; then
-
-$as_echo "#define HAVE_RES_INIT 1" >>confdefs.h
-
-  fi
-fi
-# Do we need the Hesiod library to provide the support routines?
-LIBHESIOD=
-if test "$with_hesiod" != no ; then
-  # Don't set $LIBS here -- see comments above.  FIXME which comments?
-  ac_fn_c_check_func "$LINENO" "res_send" "ac_cv_func_res_send"
-if test "x$ac_cv_func_res_send" = x""yes; then :
-
-else
-  ac_fn_c_check_func "$LINENO" "__res_send" "ac_cv_func___res_send"
-if test "x$ac_cv_func___res_send" = x""yes; then :
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_send in -lresolv" >&5
-$as_echo_n "checking for res_send in -lresolv... " >&6; }
-if test "${ac_cv_lib_resolv_res_send+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char res_send ();
-int
-main ()
-{
-return res_send ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_resolv_res_send=yes
-else
-  ac_cv_lib_resolv_res_send=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_res_send" >&5
-$as_echo "$ac_cv_lib_resolv_res_send" >&6; }
-if test "x$ac_cv_lib_resolv_res_send" = x""yes; then :
-  resolv=yes
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __res_send in -lresolv" >&5
-$as_echo_n "checking for __res_send in -lresolv... " >&6; }
-if test "${ac_cv_lib_resolv___res_send+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char __res_send ();
-int
-main ()
-{
-return __res_send ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_resolv___res_send=yes
-else
-  ac_cv_lib_resolv___res_send=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv___res_send" >&5
-$as_echo "$ac_cv_lib_resolv___res_send" >&6; }
-if test "x$ac_cv_lib_resolv___res_send" = x""yes; then :
-  resolv=yes
-fi
-
-fi
-
-fi
-
-fi
-
-  if test "$resolv" = yes ; then
-    RESOLVLIB=-lresolv
-  else
-    RESOLVLIB=
-  fi
-  ac_fn_c_check_func "$LINENO" "hes_getmailhost" "ac_cv_func_hes_getmailhost"
-if test "x$ac_cv_func_hes_getmailhost" = x""yes; then :
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hes_getmailhost in -lhesiod" >&5
-$as_echo_n "checking for hes_getmailhost in -lhesiod... " >&6; }
-if test "${ac_cv_lib_hesiod_hes_getmailhost+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lhesiod $RESOLVLIB $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char hes_getmailhost ();
-int
-main ()
-{
-return hes_getmailhost ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_hesiod_hes_getmailhost=yes
-else
-  ac_cv_lib_hesiod_hes_getmailhost=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_hesiod_hes_getmailhost" >&5
-$as_echo "$ac_cv_lib_hesiod_hes_getmailhost" >&6; }
-if test "x$ac_cv_lib_hesiod_hes_getmailhost" = x""yes; then :
-  hesiod=yes
-else
-  :
-fi
-
-fi
-
-
-  if test x"$hesiod" = xyes; then
-    LIBHESIOD=-lhesiod
-  fi
-fi
-
-
-# Do we need libresolv (due to res_init or Hesiod)?
-if test "$resolv" = yes && test $opsys != darwin; then
-  LIBRESOLV=-lresolv
-else
-  LIBRESOLV=
-fi
-
-
-# These tell us which Kerberos-related libraries to use.
-COM_ERRLIB=
-CRYPTOLIB=
-KRB5LIB=
-DESLIB=
-KRB4LIB=
-
-if test "${with_kerberos}" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for com_err in -lcom_err" >&5
-$as_echo_n "checking for com_err in -lcom_err... " >&6; }
-if test "${ac_cv_lib_com_err_com_err+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcom_err  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char com_err ();
-int
-main ()
-{
-return com_err ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_com_err_com_err=yes
-else
-  ac_cv_lib_com_err_com_err=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_com_err_com_err" >&5
-$as_echo "$ac_cv_lib_com_err_com_err" >&6; }
-if test "x$ac_cv_lib_com_err_com_err" = x""yes; then :
-  have_com_err=yes
-else
-  have_com_err=no
-fi
-
-  if test $have_com_err = yes; then
-    COM_ERRLIB=-lcom_err
-    LIBS="$COM_ERRLIB $LIBS"
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lcrypto" >&5
-$as_echo_n "checking for mit_des_cbc_encrypt in -lcrypto... " >&6; }
-if test "${ac_cv_lib_crypto_mit_des_cbc_encrypt+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcrypto  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char mit_des_cbc_encrypt ();
-int
-main ()
-{
-return mit_des_cbc_encrypt ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_crypto_mit_des_cbc_encrypt=yes
-else
-  ac_cv_lib_crypto_mit_des_cbc_encrypt=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_mit_des_cbc_encrypt" >&5
-$as_echo "$ac_cv_lib_crypto_mit_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_crypto_mit_des_cbc_encrypt" = x""yes; then :
-  have_crypto=yes
-else
-  have_crypto=no
-fi
-
-  if test $have_crypto = yes; then
-    CRYPTOLIB=-lcrypto
-    LIBS="$CRYPTOLIB $LIBS"
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mit_des_cbc_encrypt in -lk5crypto" >&5
-$as_echo_n "checking for mit_des_cbc_encrypt in -lk5crypto... " >&6; }
-if test "${ac_cv_lib_k5crypto_mit_des_cbc_encrypt+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lk5crypto  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char mit_des_cbc_encrypt ();
-int
-main ()
-{
-return mit_des_cbc_encrypt ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_k5crypto_mit_des_cbc_encrypt=yes
-else
-  ac_cv_lib_k5crypto_mit_des_cbc_encrypt=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_k5crypto_mit_des_cbc_encrypt" >&5
-$as_echo "$ac_cv_lib_k5crypto_mit_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_k5crypto_mit_des_cbc_encrypt" = x""yes; then :
-  have_k5crypto=yes
-else
-  have_k5crypto=no
-fi
-
-  if test $have_k5crypto = yes; then
-    CRYPTOLIB=-lk5crypto
-    LIBS="$CRYPTOLIB $LIBS"
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb5_init_context in -lkrb5" >&5
-$as_echo_n "checking for krb5_init_context in -lkrb5... " >&6; }
-if test "${ac_cv_lib_krb5_krb5_init_context+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkrb5  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char krb5_init_context ();
-int
-main ()
-{
-return krb5_init_context ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_krb5_krb5_init_context=yes
-else
-  ac_cv_lib_krb5_krb5_init_context=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb5_krb5_init_context" >&5
-$as_echo "$ac_cv_lib_krb5_krb5_init_context" >&6; }
-if test "x$ac_cv_lib_krb5_krb5_init_context" = x""yes; then :
-  have_krb5=yes
-else
-  have_krb5=no
-fi
-
-  if test $have_krb5=yes; then
-    KRB5LIB=-lkrb5
-    LIBS="$KRB5LIB $LIBS"
-  fi
-    if test "${with_kerberos5}" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes425" >&5
-$as_echo_n "checking for des_cbc_encrypt in -ldes425... " >&6; }
-if test "${ac_cv_lib_des425_des_cbc_encrypt+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldes425  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char des_cbc_encrypt ();
-int
-main ()
-{
-return des_cbc_encrypt ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_des425_des_cbc_encrypt=yes
-else
-  ac_cv_lib_des425_des_cbc_encrypt=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_des425_des_cbc_encrypt" >&5
-$as_echo "$ac_cv_lib_des425_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_des425_des_cbc_encrypt" = x""yes; then :
-  have_des425=yes
-else
-  have_des425=no
-fi
-
-    if test $have_des425 = yes; then
-      DESLIB=-ldes425
-      LIBS="$DESLIB $LIBS"
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for des_cbc_encrypt in -ldes" >&5
-$as_echo_n "checking for des_cbc_encrypt in -ldes... " >&6; }
-if test "${ac_cv_lib_des_des_cbc_encrypt+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldes  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char des_cbc_encrypt ();
-int
-main ()
-{
-return des_cbc_encrypt ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_des_des_cbc_encrypt=yes
-else
-  ac_cv_lib_des_des_cbc_encrypt=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_des_des_cbc_encrypt" >&5
-$as_echo "$ac_cv_lib_des_des_cbc_encrypt" >&6; }
-if test "x$ac_cv_lib_des_des_cbc_encrypt" = x""yes; then :
-  have_des=yes
-else
-  have_des=no
-fi
-
-      if test $have_des = yes; then
-        DESLIB=-ldes
-        LIBS="$DESLIB $LIBS"
-      fi
-    fi
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb4" >&5
-$as_echo_n "checking for krb_get_cred in -lkrb4... " >&6; }
-if test "${ac_cv_lib_krb4_krb_get_cred+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkrb4  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char krb_get_cred ();
-int
-main ()
-{
-return krb_get_cred ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_krb4_krb_get_cred=yes
-else
-  ac_cv_lib_krb4_krb_get_cred=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb4_krb_get_cred" >&5
-$as_echo "$ac_cv_lib_krb4_krb_get_cred" >&6; }
-if test "x$ac_cv_lib_krb4_krb_get_cred" = x""yes; then :
-  have_krb4=yes
-else
-  have_krb4=no
-fi
-
-    if test $have_krb4 = yes; then
-      KRB4LIB=-lkrb4
-      LIBS="$KRB4LIB $LIBS"
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for krb_get_cred in -lkrb" >&5
-$as_echo_n "checking for krb_get_cred in -lkrb... " >&6; }
-if test "${ac_cv_lib_krb_krb_get_cred+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkrb  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char krb_get_cred ();
-int
-main ()
-{
-return krb_get_cred ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_krb_krb_get_cred=yes
-else
-  ac_cv_lib_krb_krb_get_cred=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_krb_krb_get_cred" >&5
-$as_echo "$ac_cv_lib_krb_krb_get_cred" >&6; }
-if test "x$ac_cv_lib_krb_krb_get_cred" = x""yes; then :
-  have_krb=yes
-else
-  have_krb=no
-fi
-
-      if test $have_krb = yes; then
-        KRB4LIB=-lkrb
-        LIBS="$KRB4LIB $LIBS"
-      fi
-    fi
-  fi
-
-  if test "${with_kerberos5}" != no; then
-    for ac_header in krb5.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "krb5.h" "ac_cv_header_krb5_h" "$ac_includes_default"
-if test "x$ac_cv_header_krb5_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_KRB5_H 1
-_ACEOF
- ac_fn_c_check_member "$LINENO" "krb5_error" "text" "ac_cv_member_krb5_error_text" "#include <krb5.h>
-"
-if test "x$ac_cv_member_krb5_error_text" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_KRB5_ERROR_TEXT 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_member "$LINENO" "krb5_error" "e_text" "ac_cv_member_krb5_error_e_text" "#include <krb5.h>
-"
-if test "x$ac_cv_member_krb5_error_e_text" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_KRB5_ERROR_E_TEXT 1
-_ACEOF
-
-
-fi
-
-fi
-
-done
-
-  else
-    for ac_header in krb.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "krb.h" "ac_cv_header_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_krb_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_KRB_H 1
-_ACEOF
-
-else
-  for ac_header in kerberosIV/krb.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "kerberosIV/krb.h" "ac_cv_header_kerberosIV_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberosIV_krb_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_KERBEROSIV_KRB_H 1
-_ACEOF
-
-else
-  for ac_header in kerberos/krb.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "kerberos/krb.h" "ac_cv_header_kerberos_krb_h" "$ac_includes_default"
-if test "x$ac_cv_header_kerberos_krb_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_KERBEROS_KRB_H 1
-_ACEOF
-
-fi
-
-done
-
-fi
-
-done
-
-fi
-
-done
-
-  fi
-  for ac_header in com_err.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "com_err.h" "ac_cv_header_com_err_h" "$ac_includes_default"
-if test "x$ac_cv_header_com_err_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_COM_ERR_H 1
-_ACEOF
-
-fi
-
-done
-
-fi
-
-
-
-
-
-
-
-for ac_header in valgrind/valgrind.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "valgrind/valgrind.h" "ac_cv_header_valgrind_valgrind_h" "$ac_includes_default"
-if test "x$ac_cv_header_valgrind_valgrind_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_VALGRIND_VALGRIND_H 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-  for ac_func in $ac_func_list
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime caches TZ" >&5
-$as_echo_n "checking whether localtime caches TZ... " >&6; }
-if test "${emacs_cv_localtime_cache+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test x$ac_cv_func_tzset = xyes; then
-if test "$cross_compiling" = yes; then :
-  # If we have tzset, assume the worst when cross-compiling.
-emacs_cv_localtime_cache=yes
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-char TZ_GMT0[] = "TZ=GMT0";
-char TZ_PST8[] = "TZ=PST8";
-main()
-{
-  time_t now = time ((time_t *) 0);
-  int hour_GMT0, hour_unset;
-  if (putenv (TZ_GMT0) != 0)
-    exit (1);
-  hour_GMT0 = localtime (&now)->tm_hour;
-  unsetenv("TZ");
-  hour_unset = localtime (&now)->tm_hour;
-  if (putenv (TZ_PST8) != 0)
-    exit (1);
-  if (localtime (&now)->tm_hour == hour_GMT0)
-    exit (1);
-  unsetenv("TZ");
-  if (localtime (&now)->tm_hour != hour_unset)
-    exit (1);
-  exit (0);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  emacs_cv_localtime_cache=no
-else
-  emacs_cv_localtime_cache=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-else
-       # If we lack tzset, report that localtime does not cache TZ,
-       # since we can't invalidate the cache if we don't have tzset.
-       emacs_cv_localtime_cache=no
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_localtime_cache" >&5
-$as_echo "$emacs_cv_localtime_cache" >&6; }
-if test $emacs_cv_localtime_cache = yes; then
-
-$as_echo "#define LOCALTIME_CACHE 1" >>confdefs.h
-
-fi
-
-ok_so_far=yes
-ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket"
-if test "x$ac_cv_func_socket" = x""yes; then :
-
-else
-  ok_so_far=no
-fi
-
-if test $ok_so_far = yes; then
-  ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default"
-if test "x$ac_cv_header_netinet_in_h" = x""yes; then :
-
-else
-  ok_so_far=no
-fi
-
-
-fi
-if test $ok_so_far = yes; then
-  ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default"
-if test "x$ac_cv_header_arpa_inet_h" = x""yes; then :
-
-else
-  ok_so_far=no
-fi
-
-
-fi
-if test $ok_so_far = yes; then
-
-$as_echo "#define HAVE_INET_SOCKETS 1" >>confdefs.h
-
-fi
-
-case $canonical in
-  *-solaris2.4 | *-solaris2.4.*)
-        : ${ac_cv_func_vfork_works=no};;
-esac
-
-ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default"
-if test "x$ac_cv_type_pid_t" = x""yes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define pid_t int
-_ACEOF
-
-fi
-
-for ac_header in vfork.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default"
-if test "x$ac_cv_header_vfork_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_VFORK_H 1
-_ACEOF
-
-fi
-
-done
-
-for ac_func in fork vfork
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-if test "x$ac_cv_func_fork" = xyes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5
-$as_echo_n "checking for working fork... " >&6; }
-if test "${ac_cv_func_fork_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  ac_cv_func_fork_works=cross
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-
-         /* By Ruediger Kuhlmann. */
-         return fork () < 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_func_fork_works=yes
-else
-  ac_cv_func_fork_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5
-$as_echo "$ac_cv_func_fork_works" >&6; }
-
-else
-  ac_cv_func_fork_works=$ac_cv_func_fork
-fi
-if test "x$ac_cv_func_fork_works" = xcross; then
-  case $host in
-    *-*-amigaos* | *-*-msdosdjgpp*)
-      # Override, as these systems have only a dummy fork() stub
-      ac_cv_func_fork_works=no
-      ;;
-    *)
-      ac_cv_func_fork_works=yes
-      ;;
-  esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5
-$as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;}
-fi
-ac_cv_func_vfork_works=$ac_cv_func_vfork
-if test "x$ac_cv_func_vfork" = xyes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5
-$as_echo_n "checking for working vfork... " >&6; }
-if test "${ac_cv_func_vfork_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  ac_cv_func_vfork_works=cross
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Thanks to Paul Eggert for this test.  */
-$ac_includes_default
-#include <sys/wait.h>
-#ifdef HAVE_VFORK_H
-# include <vfork.h>
-#endif
-/* On some sparc systems, changes by the child to local and incoming
-   argument registers are propagated back to the parent.  The compiler
-   is told about this with #include <vfork.h>, but some compilers
-   (e.g. gcc -O) don't grok <vfork.h>.  Test for this by using a
-   static variable whose address is put into a register that is
-   clobbered by the vfork.  */
-static void
-#ifdef __cplusplus
-sparc_address_test (int arg)
-# else
-sparc_address_test (arg) int arg;
-#endif
-{
-  static pid_t child;
-  if (!child) {
-    child = vfork ();
-    if (child < 0) {
-      perror ("vfork");
-      _exit(2);
-    }
-    if (!child) {
-      arg = getpid();
-      write(-1, "", 0);
-      _exit (arg);
-    }
-  }
-}
-
-int
-main ()
-{
-  pid_t parent = getpid ();
-  pid_t child;
-
-  sparc_address_test (0);
-
-  child = vfork ();
-
-  if (child == 0) {
-    /* Here is another test for sparc vfork register problems.  This
-       test uses lots of local variables, at least as many local
-       variables as main has allocated so far including compiler
-       temporaries.  4 locals are enough for gcc 1.40.3 on a Solaris
-       4.1.3 sparc, but we use 8 to be safe.  A buggy compiler should
-       reuse the register of parent for one of the local variables,
-       since it will think that parent can't possibly be used any more
-       in this routine.  Assigning to the local variable will thus
-       munge parent in the parent process.  */
-    pid_t
-      p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
-      p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
-    /* Convince the compiler that p..p7 are live; otherwise, it might
-       use the same hardware register for all 8 local variables.  */
-    if (p != p1 || p != p2 || p != p3 || p != p4
-       || p != p5 || p != p6 || p != p7)
-      _exit(1);
-
-    /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
-       from child file descriptors.  If the child closes a descriptor
-       before it execs or exits, this munges the parent's descriptor
-       as well.  Test for this by closing stdout in the child.  */
-    _exit(close(fileno(stdout)) != 0);
-  } else {
-    int status;
-    struct stat st;
-
-    while (wait(&status) != child)
-      ;
-    return (
-        /* Was there some problem with vforking?  */
-        child < 0
-
-        /* Did the child fail?  (This shouldn't happen.)  */
-        || status
-
-        /* Did the vfork/compiler bug occur?  */
-        || parent != getpid()
-
-        /* Did the file descriptor bug occur?  */
-        || fstat(fileno(stdout), &st) != 0
-        );
-  }
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_func_vfork_works=yes
-else
-  ac_cv_func_vfork_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5
-$as_echo "$ac_cv_func_vfork_works" >&6; }
-
-fi;
-if test "x$ac_cv_func_fork_works" = xcross; then
-  ac_cv_func_vfork_works=$ac_cv_func_vfork
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5
-$as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;}
-fi
-
-if test "x$ac_cv_func_vfork_works" = xyes; then
-
-$as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h
-
-else
-
-$as_echo "#define vfork fork" >>confdefs.h
-
-fi
-if test "x$ac_cv_func_fork_works" = xyes; then
-
-$as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h
-
-fi
-
-
-for ac_func in snprintf
-do :
-  ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
-if test "x$ac_cv_func_snprintf" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SNPRINTF 1
-_ACEOF
-
-fi
-done
-
-
-XGSELOBJ=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GLib is linked in" >&5
-$as_echo_n "checking whether GLib is linked in... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <glib.h>
-
-int
-main ()
-{
-g_print ("Hello world");
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  links_glib=yes
-else
-  links_glib=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $links_glib" >&5
-$as_echo "$links_glib" >&6; }
-if test "${links_glib}" = "yes"; then
-
-$as_echo "#define HAVE_GLIB 1" >>confdefs.h
-
-  if test "$HAVE_NS" = no;then
-    XGSELOBJ=xgselect.o
-  fi
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
-$as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
-if test "${emacs_cv_langinfo_codeset+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <langinfo.h>
-int
-main ()
-{
-char* cs = nl_langinfo(CODESET);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_langinfo_codeset=yes
-else
-  emacs_cv_langinfo_codeset=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_langinfo_codeset" >&5
-$as_echo "$emacs_cv_langinfo_codeset" >&6; }
-if test $emacs_cv_langinfo_codeset = yes; then
-
-$as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mbstate_t" >&5
-$as_echo_n "checking for mbstate_t... " >&6; }
-if test "${ac_cv_type_mbstate_t+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-#          include <wchar.h>
-int
-main ()
-{
-mbstate_t x; return sizeof x;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_type_mbstate_t=yes
-else
-  ac_cv_type_mbstate_t=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_mbstate_t" >&5
-$as_echo "$ac_cv_type_mbstate_t" >&6; }
-   if test $ac_cv_type_mbstate_t = yes; then
-
-$as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h
-
-   else
-
-$as_echo "#define mbstate_t int" >>confdefs.h
-
-   fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C restricted array declarations" >&5
-$as_echo_n "checking for C restricted array declarations... " >&6; }
-if test "${emacs_cv_c_restrict_arr+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-void fred (int x[__restrict]);
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_c_restrict_arr=yes
-else
-  emacs_cv_c_restrict_arr=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_c_restrict_arr" >&5
-$as_echo "$emacs_cv_c_restrict_arr" >&6; }
-if test "$emacs_cv_c_restrict_arr" = yes; then
-
-$as_echo "#define __restrict_arr __restrict" >>confdefs.h
-
-fi
-
-
-if test "${opsys}" != "mingw32"; then
-
-$as_echo "#define AMPERSAND_FULL_NAME 1" >>confdefs.h
-
-fi
-
-
-$as_echo "#define CLASH_DETECTION 1" >>confdefs.h
-
-
-## Note: PTYs are broken on darwin <6.  Use at your own risk.
-if test "${opsys}" != "mingw32"; then
-
-$as_echo "#define HAVE_PTYS 1" >>confdefs.h
-
-fi
-
-
-$as_echo "#define HAVE_SOCKETS 1" >>confdefs.h
-
-
-
-
-
-if test "${opsys}" = "mingw32"; then
-  $as_echo "#define NULL_DEVICE \"NUL:\"" >>confdefs.h
-
-else
-  $as_echo "#define NULL_DEVICE \"/dev/null\"" >>confdefs.h
-
-fi
-
-
-if test "${opsys}" = "mingw32"; then
-  $as_echo "#define SEPCHAR ';'" >>confdefs.h
-
-else
-  $as_echo "#define SEPCHAR ':'" >>confdefs.h
-
-fi
-
-
-$as_echo "#define subprocesses 1" >>confdefs.h
-
-
-
-$as_echo "#define USER_FULL_NAME pw->pw_gecos" >>confdefs.h
-
-
-
-
-$as_echo "#define DIRECTORY_SEP '/'" >>confdefs.h
-
-
-if test "${opsys}" = "mingw32"; then
-
-$as_echo "#define IS_DEVICE_SEP(_c_) ((_c_) == ':')" >>confdefs.h
-
-
-
-$as_echo "#define IS_DIRECTORY_SEP(_c_) ((_c_) == '/' || (_c_) == '\\\\')" >>confdefs.h
-
-
-
-$as_echo "#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))" >>confdefs.h
-
-else
-
-$as_echo "#define IS_DEVICE_SEP(_c_) 0" >>confdefs.h
-
-
-
-$as_echo "#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)" >>confdefs.h
-
-
-
-$as_echo "#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_))" >>confdefs.h
-
-fi
-
-
-
-case $opsys in
-  aix4-2)
-        if test x$ac_cv_lib_Xmu_XmuConvertStandardSelection != xyes; then
-      $as_echo "#define NO_EDITRES 1" >>confdefs.h
-
-    fi
-    ;;
-
-  hpux*)
-            $as_echo "#define NO_EDITRES 1" >>confdefs.h
-
-    ;;
-esac
-
-
-case $opsys in
-  irix6-5 | sol2* | unixware )
-
-$as_echo "#define NSIG_MINIMUM 32" >>confdefs.h
-
-    ;;
-esac
-
-emacs_broken_SIGIO=no
-
-case $opsys in
-      hpux* | irix6-5 | openbsd | sol2* | unixware )
-    emacs_broken_SIGIO=yes
-    ;;
-
-  aix4-2)
-
-$as_echo "#define BROKEN_GET_CURRENT_DIR_NAME 1" >>confdefs.h
-
-    ;;
-
-  freebsd)
-
-$as_echo "#define BROKEN_PTY_READ_AFTER_EAGAIN 1" >>confdefs.h
-
-    ;;
-esac
-
-case $opsys in
-  gnu-* | sol2-10 )
-
-$as_echo "#define HAVE_PROCFS 1" >>confdefs.h
-
-  ;;
-esac
-
-case $opsys in
-  darwin | dragonfly | freebsd | netbsd | openbsd )
-
-$as_echo "#define DONT_REOPEN_PTY 1" >>confdefs.h
-
-  ;;
-esac
-
-case $opsys in
-  netbsd | openbsd) sound_device="/dev/audio" ;;
-  *) sound_device="/dev/dsp" ;;
-esac
-
-
-cat >>confdefs.h <<_ACEOF
-#define DEFAULT_SOUND_DEVICE "$sound_device"
-_ACEOF
-
-
-
-case $opsys in
-  darwin | gnu-linux | gnu-kfreebsd )
-
-$as_echo "#define INTERRUPT_INPUT 1" >>confdefs.h
-
-  ;;
-esac
-
-
-case $opsys in
-  cygwin|gnu|gnu-linux|gnu-kfreebsd|irix6-5|freebsd|netbsd|openbsd)
-
-$as_echo "#define NARROWPROTO 1" >>confdefs.h
-
-  ;;
-esac
-
-
-
-
-
-
-
-
-case $opsys in
-  aix4-2 )
-    $as_echo "#define PTY_ITERATION int c; for (c = 0; !c ; c++)" >>confdefs.h
-
-            $as_echo "#define PTY_NAME_SPRINTF strcpy (pty_name, \"/dev/ptc\");" >>confdefs.h
-
-    $as_echo "#define PTY_TTY_NAME_SPRINTF strcpy (pty_name, ttyname (fd));" >>confdefs.h
-
-    ;;
-
-  cygwin )
-    $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h
-
-        $as_echo "#define PTY_OPEN  do { int dummy; sigset_t blocked, procmask; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, &procmask); if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) fd = -1; pthread_sigmask (SIG_SETMASK, &procmask, 0); if (fd >= 0) emacs_close (dummy); } while (0)" >>confdefs.h
-
-    $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
-
-    $as_echo "#define PTY_TTY_NAME_SPRINTF /**/" >>confdefs.h
-
-    ;;
-
-    darwin )
-    $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h
-
-        $as_echo "#define FIRST_PTY_LETTER 'p'" >>confdefs.h
-
-                $as_echo "#define PTY_OPEN  do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)" >>confdefs.h
-
-    $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
-
-    $as_echo "#define PTY_TTY_NAME_SPRINTF /**/" >>confdefs.h
-
-    ;;
-
-  gnu | openbsd )
-    $as_echo "#define FIRST_PTY_LETTER 'p'" >>confdefs.h
-
-    ;;
-
-  gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd )
-        if test "x$ac_cv_func_grantpt" = xyes; then
-
-$as_echo "#define UNIX98_PTYS 1" >>confdefs.h
-
-      $as_echo "#define PTY_ITERATION int i; for (i = 0; i < 1; i++)" >>confdefs.h
-
-                  $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, \"%s\", ptyname); }" >>confdefs.h
-
-            if test "x$ac_cv_func_posix_openpt" = xyes; then
-        $as_echo "#define PTY_OPEN do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (0)" >>confdefs.h
-
-        $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
-
-            elif test "x$ac_cv_func_getpt" = xyes; then
-        $as_echo "#define PTY_OPEN fd = getpt ()" >>confdefs.h
-
-        $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
-
-      else
-        $as_echo "#define PTY_NAME_SPRINTF strcpy (pty_name, \"/dev/ptmx\");" >>confdefs.h
-
-      fi
-    else
-      $as_echo "#define FIRST_PTY_LETTER 'p'" >>confdefs.h
-
-    fi
-    ;;
-
-  hpux*)
-    $as_echo "#define FIRST_PTY_LETTER 'p'" >>confdefs.h
-
-    $as_echo "#define PTY_NAME_SPRINTF sprintf (pty_name, \"/dev/ptym/pty%c%x\", c, i);" >>confdefs.h
-
-    $as_echo "#define PTY_TTY_NAME_SPRINTF sprintf (pty_name, \"/dev/pty/tty%c%x\", c, i);" >>confdefs.h
-
-    ;;
-
-  irix6-5 )
-                                            $as_echo "#define PTY_ITERATION /**/" >>confdefs.h
-
-        $as_echo "#define FIRST_PTY_LETTER 'q'" >>confdefs.h
-
-    $as_echo "#define PTY_OPEN  { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }" >>confdefs.h
-
-        $as_echo "#define PTY_NAME_SPRINTF /**/" >>confdefs.h
-
-        $as_echo "#define PTY_TTY_NAME_SPRINTF /**/" >>confdefs.h
-
-    ;;
-
-  sol2* )
-                $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, \"%s\", ptyname); }" >>confdefs.h
-
-    ;;
-
-  unixware )
-        $as_echo "#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal(\"could not grant slave pty\"); if (unlockpt(fd) == -1) fatal(\"could not unlock slave pty\"); if (!(ptyname = ptsname(fd))) fatal (\"could not enable slave pty\"); snprintf (pty_name, PTY_NAME_SIZE, \"%s\", ptyname); }" >>confdefs.h
-
-    ;;
-esac
-
-
-case $opsys in
-  sol2* | unixware )
-            $as_echo "#define FIRST_PTY_LETTER 'z'" >>confdefs.h
-
-    $as_echo "#define PTY_NAME_SPRINTF strcpy (pty_name, \"/dev/ptmx\");" >>confdefs.h
-
-
-$as_echo "#define SETUP_SLAVE_PTY if (ioctl (xforkin, I_PUSH, \"ptem\") == -1) fatal (\"ioctl I_PUSH ptem\"); if (ioctl (xforkin, I_PUSH, \"ldterm\") == -1) fatal (\"ioctl I_PUSH ldterm\"); if (ioctl (xforkin, I_PUSH, \"ttcompat\") == -1) fatal (\"ioctl I_PUSH ttcompat\");" >>confdefs.h
-
-    ;;
-esac
-
-
-
-
-case $opsys in
-      aix4-2 | cygwin | gnu | irix6-5 | dragonfly | freebsd | netbsd | openbsd | darwin )
-    $as_echo "#define SIGNALS_VIA_CHARACTERS 1" >>confdefs.h
-
-    ;;
-
-      gnu-linux | gnu-kfreebsd )
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signals via characters" >&5
-$as_echo_n "checking for signals via characters... " >&6; }
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < 0x20400
-# error "Linux version too old"
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  emacs_signals_via_chars=yes
-else
-  emacs_signals_via_chars=no
-fi
-rm -f conftest.err conftest.$ac_ext
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_signals_via_chars" >&5
-$as_echo "$emacs_signals_via_chars" >&6; }
-    test $emacs_signals_via_chars = yes && $as_echo "#define SIGNALS_VIA_CHARACTERS 1" >>confdefs.h
-
-    ;;
-esac
-
-
-
-
-case $opsys in
-  aix*)
-        $as_echo "#define DATA_SEG_BITS 0x20000000" >>confdefs.h
-
-    ;;
-  hpux*)
-        $as_echo "#define DATA_SEG_BITS 0x40000000" >>confdefs.h
-
-    ;;
-  irix6-5)
-    $as_echo "#define DATA_SEG_BITS 0x10000000" >>confdefs.h
-
-    ;;
-esac
-
-
-
-
-case $opsys in
-  darwin) $as_echo "#define TAB3 OXTABS" >>confdefs.h
- ;;
-
-  gnu | dragonfly | freebsd | netbsd | openbsd )
-
-$as_echo "#define TABDLY OXTABS" >>confdefs.h
-
-    $as_echo "#define TAB3 OXTABS" >>confdefs.h
-
-    ;;
-
-  gnu-linux | gnu-kfreebsd )
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifndef __ia64__
-# error "not ia64"
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-$as_echo "#define GC_MARK_SECONDARY_STACK() do { extern void *__libc_ia64_register_backing_store_base; __builtin_ia64_flushrs (); mark_memory (__libc_ia64_register_backing_store_base, __builtin_ia64_bsp ());} while (0)" >>confdefs.h
-
-fi
-rm -f conftest.err conftest.$ac_ext
-    ;;
-
-  hpux*)
-
-$as_echo "#define RUN_TIME_REMAP 1" >>confdefs.h
-
-    ;;
-esac
-
-
-
-
-
-case $opsys in
-          gnu-linux | gnu-kfreebsd )
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#if defined __i386__ || defined __sparc__ || defined __mc68000__ \
-  || defined __alpha__ || defined __mips__ || defined __s390__ \
-  || defined __arm__ || defined __powerpc__ || defined __amd64__ \
-  || defined __ia64__ || defined __sh__
-/* ok */
-#else
-# error "setjmp not known to work on this arch"
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  $as_echo "#define GC_SETJMP_WORKS 1" >>confdefs.h
-
-fi
-rm -f conftest.err conftest.$ac_ext
-    ;;
-esac
-
-
-if test x$GCC = xyes; then
-      $as_echo "#define GC_SETJMP_WORKS 1" >>confdefs.h
-
-else
-  case $opsys in
-        dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
-      $as_echo "#define GC_SETJMP_WORKS 1" >>confdefs.h
-
-      ;;
-  esac
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _setjmp" >&5
-$as_echo_n "checking for _setjmp... " >&6; }
-if test "${emacs_cv_func__setjmp+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <setjmp.h>
-         #ifdef __MINGW32__
-         # define _longjmp longjmp
-         #endif
-
-int
-main ()
-{
-jmp_buf j;
-        if (! _setjmp (j))
-          _longjmp (j, 1);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_func__setjmp=yes
-else
-  emacs_cv_func__setjmp=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_func__setjmp" >&5
-$as_echo "$emacs_cv_func__setjmp" >&6; }
-if test $emacs_cv_func__setjmp = yes; then
-
-$as_echo "#define HAVE__SETJMP 1" >>confdefs.h
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
-$as_echo_n "checking for sigsetjmp... " >&6; }
-if test "${emacs_cv_func_sigsetjmp+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <setjmp.h>
-
-int
-main ()
-{
-sigjmp_buf j;
-          if (! sigsetjmp (j, 1))
-            siglongjmp (j, 1);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  emacs_cv_func_sigsetjmp=yes
-else
-  emacs_cv_func_sigsetjmp=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_func_sigsetjmp" >&5
-$as_echo "$emacs_cv_func_sigsetjmp" >&6; }
-  if test $emacs_cv_func_sigsetjmp = yes; then
-
-$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
-
-  fi
-fi
-
-case $opsys in
-  sol2* | unixware )
-
-$as_echo "#define TIOCSIGSEND TIOCSIGNAL" >>confdefs.h
-
-    ;;
-esac
-
-
-case $opsys in
-  hpux* | sol2* )
-
-$as_echo "#define XOS_NEEDS_TIME_H 1" >>confdefs.h
-
-    ;;
-esac
-
-
-
-
-
-
-
-case $opsys in
-  aix4-2)
-    $as_echo "#define USG /**/" >>confdefs.h
-
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifndef _AIX
-# error "_AIX not defined"
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-
-else
-
-$as_echo "#define _AIX /**/" >>confdefs.h
-
-fi
-rm -f conftest.err conftest.$ac_ext
-    ;;
-
-  cygwin)
-
-$as_echo "#define CYGWIN 1" >>confdefs.h
-
-    ;;
-
-  darwin)
-
-$as_echo "#define DARWIN_OS /**/" >>confdefs.h
-
-    ;;
-
-  gnu-linux | gnu-kfreebsd )
-    $as_echo "#define USG /**/" >>confdefs.h
-
-
-$as_echo "#define GNU_LINUX /**/" >>confdefs.h
-
-    ;;
-
-  hpux*)
-    $as_echo "#define USG /**/" >>confdefs.h
-
-
-$as_echo "#define HPUX /**/" >>confdefs.h
-
-    ;;
-
-  irix6-5)
-    $as_echo "#define USG /**/" >>confdefs.h
-
-    $as_echo "#define USG5_4 /**/" >>confdefs.h
-
-
-$as_echo "#define IRIX6_5 /**/" >>confdefs.h
-
-    ;;
-
-  mingw32)
-    $as_echo "#define DOS_NT /**/" >>confdefs.h
-
-
-$as_echo "#define WINDOWSNT 1" >>confdefs.h
-
-    if test "x$ac_enable_checking" != "x" ; then
-
-$as_echo "#define EMACSDEBUG 1" >>confdefs.h
-
-    fi
-    ;;
-
-  sol2*)
-    $as_echo "#define USG /**/" >>confdefs.h
-
-    $as_echo "#define USG5_4 /**/" >>confdefs.h
-
-
-$as_echo "#define SOLARIS2 /**/" >>confdefs.h
-
-    ;;
-
-  unixware)
-    $as_echo "#define USG /**/" >>confdefs.h
-
-    $as_echo "#define USG5_4 /**/" >>confdefs.h
-
-    ;;
-esac
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usable FIONREAD" >&5
-$as_echo_n "checking for usable FIONREAD... " >&6; }
-if test "${emacs_cv_usable_FIONREAD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $opsys in
-     aix4-2)
-              emacs_cv_usable_FIONREAD=no
-       ;;
-
-     mingw32)
-       emacs_cv_usable_FIONREAD=yes
-       ;;
-
-     *)
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-                           #include <sys/ioctl.h>
-                           #ifdef USG5_4
-                           # include <sys/filio.h>
-                           #endif
-
-int
-main ()
-{
-int foo = ioctl (0, FIONREAD, &foo);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_usable_FIONREAD=yes
-else
-  emacs_cv_usable_FIONREAD=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       ;;
-   esac
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_usable_FIONREAD" >&5
-$as_echo "$emacs_cv_usable_FIONREAD" >&6; }
-if test $emacs_cv_usable_FIONREAD = yes; then
-
-$as_echo "#define USABLE_FIONREAD 1" >>confdefs.h
-
-
-  if test $emacs_broken_SIGIO = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usable SIGIO" >&5
-$as_echo_n "checking for usable SIGIO... " >&6; }
-if test "${emacs_cv_usable_SIGIO+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <fcntl.h>
-                           #include <signal.h>
-
-int
-main ()
-{
-int foo = SIGIO | F_SETFL | FASYNC;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  emacs_cv_usable_SIGIO=yes
-else
-  emacs_cv_usable_SIGIO=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $emacs_cv_usable_SIGIO" >&5
-$as_echo "$emacs_cv_usable_SIGIO" >&6; }
-    if test $emacs_cv_usable_SIGIO = yes; then
-
-$as_echo "#define USABLE_SIGIO 1" >>confdefs.h
-
-    fi
-  fi
-fi
-
-
-case $opsys in
-                cygwin)
-
-$as_echo "#define G_SLICE_ALWAYS_MALLOC 1" >>confdefs.h
-
-    ;;
-
-  hpux11)
-
-$as_echo "#define USG_SUBTTY_WORKS 1" >>confdefs.h
-
-    ;;
-
-  irix6-5)
-
-$as_echo "#define PREFER_VSUSP 1" >>confdefs.h
-
-    ;;
-
-  sol2-10)
-
-$as_echo "#define _STRUCTURED_PROC 1" >>confdefs.h
-
-    ;;
-esac
-
-# Set up the CFLAGS for real compilation, so we can substitute it.
-CFLAGS="$REAL_CFLAGS"
-CPPFLAGS="$REAL_CPPFLAGS"
-
-## Hack to detect a buggy GCC version.
-if test "x$GCC" = xyes \
-   && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
-   && test x"`echo $CFLAGS | grep '\-O[23]'`" != x \
-   && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
-   as_fn_error "GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'." "$LINENO" 5
-fi
-
-version=$PACKAGE_VERSION
-
-copyright="Copyright (C) 2013 Free Software Foundation, Inc."
-
-cat >>confdefs.h <<_ACEOF
-#define COPYRIGHT "$copyright"
-_ACEOF
-
-
-
-### Specify what sort of things we'll be editing into Makefile and config.h.
-### Use configuration here uncanonicalized to avoid exceeding size limits.
-
-
-## Unused?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
-## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
-## end of LIBX_BASE, but nothing ever set it.
-
-
-
-
-## Used in lwlib/Makefile.in.
-
-
-
-
-
-
-
-
-if test -n "${term_header}"; then
-
-cat >>confdefs.h <<_ACEOF
-#define TERM_HEADER "${term_header}"
-_ACEOF
-
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define EMACS_CONFIGURATION "${canonical}"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define EMACS_CONFIG_OPTIONS "${emacs_config_options}"
-_ACEOF
-
-
-
-case $opsys in
-  mingw32)
-    $as_echo "#define config_opsysfile <ms-w32.h>" >>confdefs.h
-
-    ;;
-esac
-
-XMENU_OBJ=
-XOBJ=
-FONT_OBJ=
-if test "${HAVE_X_WINDOWS}" = "yes" ; then
-
-$as_echo "#define HAVE_X_WINDOWS 1" >>confdefs.h
-
-  XMENU_OBJ=xmenu.o
-  XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
-  FONT_OBJ=xfont.o
-  if test "$HAVE_XFT" = "yes"; then
-    FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
-  elif test "$HAVE_FREETYPE" = "yes"; then
-    FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
-  fi
-
-fi
-
-
-
-
-WIDGET_OBJ=
-MOTIF_LIBW=
-if test "${USE_X_TOOLKIT}" != "none" ; then
-  WIDGET_OBJ=widget.o
-
-$as_echo "#define USE_X_TOOLKIT 1" >>confdefs.h
-
-  if test "${USE_X_TOOLKIT}" = "LUCID"; then
-
-$as_echo "#define USE_LUCID 1" >>confdefs.h
-
-  elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
-
-$as_echo "#define USE_MOTIF 1" >>confdefs.h
-
-    MOTIF_LIBW=-lXm
-    case "$opsys" in
-      gnu-linux)
-        ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
-        MOTIF_LIBW="$MOTIF_LIBW -lXpm"
-        ;;
-
-      unixware)
-        ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
-        ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
-        MOTIF_LIBW="MOTIF_LIBW -lXimp"
-        ;;
-
-      aix4-2)
-        ## olson@mcs.anl.gov says -li18n is needed by -lXm.
-        MOTIF_LIBW="$MOTIF_LIBW -li18n"
-        ;;
-    esac
-    MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
-  fi
-fi
-
-
-TOOLKIT_LIBW=
-case "$USE_X_TOOLKIT" in
-  MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
-  LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
-  none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
-esac
-
-
-if test "${opsys}" != "mingw32"; then
-  if test "$USE_X_TOOLKIT" = "none"; then
-    LIBXT_OTHER="\$(LIBXSM)"
-    OLDXMENU_TARGET="really-oldXMenu"
-  else
-    LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
-    OLDXMENU_TARGET="really-lwlib"
-  fi
-fi
-
-
-## The X Menu stuff is present in the X10 distribution, but missing
-## from X11.  If we have X10, just use the installed library;
-## otherwise, use our own copy.
-if test "${HAVE_X11}" = "yes" ; then
-
-$as_echo "#define HAVE_X11 1" >>confdefs.h
-
-
-  if test "$USE_X_TOOLKIT" = "none"; then
-    OLDXMENU="\${oldXMenudir}/libXMenu11.a"
-  else
-    OLDXMENU="\${lwlibdir}/liblw.a"
-  fi
-  LIBXMENU="\$(OLDXMENU)"
-  LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
-  OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
-else
-  ## For a syntactically valid Makefile; not actually used for anything.
-  ## See comments in src/Makefile.in.
-  OLDXMENU=nothing
-  ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
-  if test "${HAVE_X_WINDOWS}" = "yes"; then
-    LIBXMENU="-lXMenu"
-  else
-    LIBXMENU=
-  fi
-  LIBX_OTHER=
-  OLDXMENU_DEPS=
-fi
-
-if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
-  OLDXMENU_TARGET=
-  OLDXMENU=nothing
-  LIBXMENU=
-  OLDXMENU_DEPS=
-fi
-
-
-
-
-
-
-
-if test "${HAVE_MENUS}" = "yes" ; then
-
-$as_echo "#define HAVE_MENUS 1" >>confdefs.h
-
-fi
-
-if test "${GNU_MALLOC}" = "yes" ; then
-
-$as_echo "#define GNU_MALLOC 1" >>confdefs.h
-
-fi
-
-RALLOC_OBJ=
-if test "${REL_ALLOC}" = "yes" ; then
-
-$as_echo "#define REL_ALLOC 1" >>confdefs.h
-
-
-  test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
-fi
-
-
-if test "$opsys" = "cygwin"; then
-  CYGWIN_OBJ="sheap.o cygw32.o"
-  ## Cygwin differs because of its unexec().
-  PRE_ALLOC_OBJ=
-  POST_ALLOC_OBJ=lastfile.o
-elif test "$opsys" = "mingw32"; then
-  CYGWIN_OBJ=
-  PRE_ALLOC_OBJ=
-  POST_ALLOC_OBJ=lastfile.o
-else
-  CYGWIN_OBJ=
-  PRE_ALLOC_OBJ=lastfile.o
-  POST_ALLOC_OBJ=
-fi
-
-
-
-
-
-
-# Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
-# it temporarily reverts them to their pre-pkg-config values,
-# because gnulib needs to work with both src (which uses the
-# pkg-config stuff) and lib-src (which does not).  For example, gnulib
-# may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
-# and it therefore needs to run in an environment where LIBS does not
-# already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
-# for some package unrelated to lib-src.
-SAVE_CFLAGS=$CFLAGS
-SAVE_LIBS=$LIBS
-CFLAGS=$pre_PKG_CONFIG_CFLAGS
-LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
-
-
-
-
-
-
-
-
-
-
-
-          LIBC_FATAL_STDERR_=1
-  export LIBC_FATAL_STDERR_
-
-# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-# for constant arguments.  Useless!
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
-$as_echo_n "checking for working alloca.h... " >&6; }
-if test "${ac_cv_working_alloca_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <alloca.h>
-int
-main ()
-{
-char *p = (char *) alloca (2 * sizeof (int));
-                         if (p) return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_working_alloca_h=yes
-else
-  ac_cv_working_alloca_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
-$as_echo "$ac_cv_working_alloca_h" >&6; }
-if test $ac_cv_working_alloca_h = yes; then
-
-$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
-
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
-$as_echo_n "checking for alloca... " >&6; }
-if test "${ac_cv_func_alloca_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# ifdef _MSC_VER
-#  include <malloc.h>
-#  define alloca _alloca
-# else
-#  ifdef HAVE_ALLOCA_H
-#   include <alloca.h>
-#  else
-#   ifdef _AIX
- #pragma alloca
-#   else
-#    ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-#    endif
-#   endif
-#  endif
-# endif
-#endif
-
-int
-main ()
-{
-char *p = (char *) alloca (1);
-                                   if (p) return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_func_alloca_works=yes
-else
-  ac_cv_func_alloca_works=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
-$as_echo "$ac_cv_func_alloca_works" >&6; }
-
-if test $ac_cv_func_alloca_works = yes; then
-
-$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
-
-else
-  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
-# that cause trouble.  Some versions do not even contain alloca or
-# contain a buggy version.  If you still want to use their alloca,
-# use ar to extract alloca.o from them instead of compiling alloca.c.
-
-
-
-
-
-ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
-
-$as_echo "#define C_ALLOCA 1" >>confdefs.h
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether 'alloca.c' needs Cray hooks" >&5
-$as_echo_n "checking whether 'alloca.c' needs Cray hooks... " >&6; }
-if test "${ac_cv_os_cray+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if defined CRAY && ! defined CRAY2
-webecray
-#else
-wenotbecray
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "webecray" >/dev/null 2>&1; then :
-  ac_cv_os_cray=yes
-else
-  ac_cv_os_cray=no
-fi
-rm -f conftest*
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
-$as_echo "$ac_cv_os_cray" >&6; }
-if test $ac_cv_os_cray = yes; then
-  for ac_func in _getb67 GETB67 getb67; do
-    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define CRAY_STACKSEG_END $ac_func
-_ACEOF
-
-    break
-fi
-
-  done
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
-$as_echo_n "checking stack direction for C alloca... " >&6; }
-if test "${ac_cv_c_stack_direction+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  ac_cv_c_stack_direction=0
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-find_stack_direction (int *addr, int depth)
-{
-  int dir, dummy = 0;
-  if (! addr)
-    addr = &dummy;
-  *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
-  dir = depth ? find_stack_direction (addr, depth - 1) : 0;
-  return dir + dummy;
-}
-
-int
-main (int argc, char **argv)
-{
-  return find_stack_direction (0, argc + !argv + 20) < 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_c_stack_direction=1
-else
-  ac_cv_c_stack_direction=-1
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
-$as_echo "$ac_cv_c_stack_direction" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define STACK_DIRECTION $ac_cv_c_stack_direction
-_ACEOF
-
-
-fi
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5
-$as_echo_n "checking for unsigned long long int... " >&6; }
-if test "${ac_cv_type_unsigned_long_long_int+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_type_unsigned_long_long_int=yes
-     if test "x${ac_cv_prog_cc_c99-no}" = xno; then
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  /* For now, do not test the preprocessor; as of 2007 there are too many
-         implementations with broken preprocessors.  Perhaps this can
-         be revisited in 2012.  In the meantime, code should not expect
-         #if to work with literals wider than 32 bits.  */
-      /* Test literals.  */
-      long long int ll = 9223372036854775807ll;
-      long long int nll = -9223372036854775807LL;
-      unsigned long long int ull = 18446744073709551615ULL;
-      /* Test constant expressions.   */
-      typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
-                     ? 1 : -1)];
-      typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
-                     ? 1 : -1)];
-      int i = 63;
-int
-main ()
-{
-/* Test availability of runtime routines for shift and division.  */
-      long long int llmax = 9223372036854775807ll;
-      unsigned long long int ullmax = 18446744073709551615ull;
-      return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
-              | (llmax / ll) | (llmax % ll)
-              | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
-              | (ullmax / ull) | (ullmax % ull));
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  ac_cv_type_unsigned_long_long_int=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-     fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5
-$as_echo "$ac_cv_type_unsigned_long_long_int" >&6; }
-  if test $ac_cv_type_unsigned_long_long_int = yes; then
-
-$as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h
-
-  fi
-
-
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
-$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
-if test "${ac_cv_c_bigendian+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_c_bigendian=unknown
-    # See if we're dealing with a universal compiler.
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifndef __APPLE_CC__
-              not a universal capable compiler
-            #endif
-            typedef int dummy;
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-       # Check for potential -arch flags.  It is not universal unless
-       # there are at least two -arch flags with different values.
-       ac_arch=
-       ac_prev=
-       for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
-        if test -n "$ac_prev"; then
-          case $ac_word in
-            i?86 | x86_64 | ppc | ppc64)
-              if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
-                ac_arch=$ac_word
-              else
-                ac_cv_c_bigendian=universal
-                break
-              fi
-              ;;
-          esac
-          ac_prev=
-        elif test "x$ac_word" = "x-arch"; then
-          ac_prev=arch
-        fi
-       done
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    if test $ac_cv_c_bigendian = unknown; then
-      # See if sys/param.h defines the BYTE_ORDER macro.
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-            #include <sys/param.h>
-
-int
-main ()
-{
-#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
-                    && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
-                    && LITTLE_ENDIAN)
-             bogus endian macros
-            #endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  # It does; now see whether it defined to BIG_ENDIAN or not.
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-               #include <sys/param.h>
-
-int
-main ()
-{
-#if BYTE_ORDER != BIG_ENDIAN
-                not big endian
-               #endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_c_bigendian=yes
-else
-  ac_cv_c_bigendian=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    fi
-    if test $ac_cv_c_bigendian = unknown; then
-      # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-
-int
-main ()
-{
-#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
-             bogus endian macros
-            #endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  # It does; now see whether it defined to _BIG_ENDIAN or not.
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-
-int
-main ()
-{
-#ifndef _BIG_ENDIAN
-                not big endian
-               #endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_c_bigendian=yes
-else
-  ac_cv_c_bigendian=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-    fi
-    if test $ac_cv_c_bigendian = unknown; then
-      # Compile a test program.
-      if test "$cross_compiling" = yes; then :
-  # Try to guess by grepping values from an object file.
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-short int ascii_mm[] =
-                 { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
-               short int ascii_ii[] =
-                 { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
-               int use_ascii (int i) {
-                 return ascii_mm[i] + ascii_ii[i];
-               }
-               short int ebcdic_ii[] =
-                 { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
-               short int ebcdic_mm[] =
-                 { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
-               int use_ebcdic (int i) {
-                 return ebcdic_mm[i] + ebcdic_ii[i];
-               }
-               extern int foo;
-
-int
-main ()
-{
-return use_ascii (foo) == use_ebcdic (foo);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
-             ac_cv_c_bigendian=yes
-           fi
-           if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
-             if test "$ac_cv_c_bigendian" = unknown; then
-               ac_cv_c_bigendian=no
-             else
-               # finding both strings is unlikely to happen, but who knows?
-               ac_cv_c_bigendian=unknown
-             fi
-           fi
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-
-            /* Are we little or big endian?  From Harbison&Steele.  */
-            union
-            {
-              long int l;
-              char c[sizeof (long int)];
-            } u;
-            u.l = 1;
-            return u.c[sizeof (long int) - 1] == 1;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_c_bigendian=no
-else
-  ac_cv_c_bigendian=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-    fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
-$as_echo "$ac_cv_c_bigendian" >&6; }
- case $ac_cv_c_bigendian in #(
-   yes)
-     $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
-;; #(
-   no)
-      ;; #(
-   universal)
-
-$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
-
-     ;; #(
-   *)
-     as_fn_error "unknown endianness
- presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
- esac
-
-
-
-  GNULIB_CHDIR=0;
-  GNULIB_CHOWN=0;
-  GNULIB_CLOSE=0;
-  GNULIB_DUP=0;
-  GNULIB_DUP2=0;
-  GNULIB_DUP3=0;
-  GNULIB_ENVIRON=0;
-  GNULIB_EUIDACCESS=0;
-  GNULIB_FACCESSAT=0;
-  GNULIB_FCHDIR=0;
-  GNULIB_FCHOWNAT=0;
-  GNULIB_FDATASYNC=0;
-  GNULIB_FSYNC=0;
-  GNULIB_FTRUNCATE=0;
-  GNULIB_GETCWD=0;
-  GNULIB_GETDOMAINNAME=0;
-  GNULIB_GETDTABLESIZE=0;
-  GNULIB_GETGROUPS=0;
-  GNULIB_GETHOSTNAME=0;
-  GNULIB_GETLOGIN=0;
-  GNULIB_GETLOGIN_R=0;
-  GNULIB_GETPAGESIZE=0;
-  GNULIB_GETUSERSHELL=0;
-  GNULIB_GROUP_MEMBER=0;
-  GNULIB_ISATTY=0;
-  GNULIB_LCHOWN=0;
-  GNULIB_LINK=0;
-  GNULIB_LINKAT=0;
-  GNULIB_LSEEK=0;
-  GNULIB_PIPE=0;
-  GNULIB_PIPE2=0;
-  GNULIB_PREAD=0;
-  GNULIB_PWRITE=0;
-  GNULIB_READ=0;
-  GNULIB_READLINK=0;
-  GNULIB_READLINKAT=0;
-  GNULIB_RMDIR=0;
-  GNULIB_SETHOSTNAME=0;
-  GNULIB_SLEEP=0;
-  GNULIB_SYMLINK=0;
-  GNULIB_SYMLINKAT=0;
-  GNULIB_TTYNAME_R=0;
-  GNULIB_UNISTD_H_NONBLOCKING=0;
-  GNULIB_UNISTD_H_SIGPIPE=0;
-  GNULIB_UNLINK=0;
-  GNULIB_UNLINKAT=0;
-  GNULIB_USLEEP=0;
-  GNULIB_WRITE=0;
-    HAVE_CHOWN=1;
-  HAVE_DUP2=1;
-  HAVE_DUP3=1;
-  HAVE_EUIDACCESS=1;
-  HAVE_FACCESSAT=1;
-  HAVE_FCHDIR=1;
-  HAVE_FCHOWNAT=1;
-  HAVE_FDATASYNC=1;
-  HAVE_FSYNC=1;
-  HAVE_FTRUNCATE=1;
-  HAVE_GETDTABLESIZE=1;
-  HAVE_GETGROUPS=1;
-  HAVE_GETHOSTNAME=1;
-  HAVE_GETLOGIN=1;
-  HAVE_GETPAGESIZE=1;
-  HAVE_GROUP_MEMBER=1;
-  HAVE_LCHOWN=1;
-  HAVE_LINK=1;
-  HAVE_LINKAT=1;
-  HAVE_PIPE=1;
-  HAVE_PIPE2=1;
-  HAVE_PREAD=1;
-  HAVE_PWRITE=1;
-  HAVE_READLINK=1;
-  HAVE_READLINKAT=1;
-  HAVE_SETHOSTNAME=1;
-  HAVE_SLEEP=1;
-  HAVE_SYMLINK=1;
-  HAVE_SYMLINKAT=1;
-  HAVE_UNLINKAT=1;
-  HAVE_USLEEP=1;
-  HAVE_DECL_ENVIRON=1;
-  HAVE_DECL_FCHDIR=1;
-  HAVE_DECL_FDATASYNC=1;
-  HAVE_DECL_GETDOMAINNAME=1;
-  HAVE_DECL_GETLOGIN_R=1;
-  HAVE_DECL_GETPAGESIZE=1;
-  HAVE_DECL_GETUSERSHELL=1;
-  HAVE_DECL_SETHOSTNAME=1;
-  HAVE_DECL_TTYNAME_R=1;
-  HAVE_OS_H=0;
-  HAVE_SYS_PARAM_H=0;
-  REPLACE_CHOWN=0;
-  REPLACE_CLOSE=0;
-  REPLACE_DUP=0;
-  REPLACE_DUP2=0;
-  REPLACE_FCHOWNAT=0;
-  REPLACE_FTRUNCATE=0;
-  REPLACE_GETCWD=0;
-  REPLACE_GETDOMAINNAME=0;
-  REPLACE_GETDTABLESIZE=0;
-  REPLACE_GETLOGIN_R=0;
-  REPLACE_GETGROUPS=0;
-  REPLACE_GETPAGESIZE=0;
-  REPLACE_ISATTY=0;
-  REPLACE_LCHOWN=0;
-  REPLACE_LINK=0;
-  REPLACE_LINKAT=0;
-  REPLACE_LSEEK=0;
-  REPLACE_PREAD=0;
-  REPLACE_PWRITE=0;
-  REPLACE_READ=0;
-  REPLACE_READLINK=0;
-  REPLACE_RMDIR=0;
-  REPLACE_SLEEP=0;
-  REPLACE_SYMLINK=0;
-  REPLACE_TTYNAME_R=0;
-  REPLACE_UNLINK=0;
-  REPLACE_UNLINKAT=0;
-  REPLACE_USLEEP=0;
-  REPLACE_WRITE=0;
-  UNISTD_H_HAVE_WINSOCK2_H=0;
-  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
-
-
-
-     GNULIB_OPENDIR=0;
-  GNULIB_READDIR=0;
-  GNULIB_REWINDDIR=0;
-  GNULIB_CLOSEDIR=0;
-  GNULIB_DIRFD=0;
-  GNULIB_FDOPENDIR=0;
-  GNULIB_SCANDIR=0;
-  GNULIB_ALPHASORT=0;
-    HAVE_OPENDIR=1;
-  HAVE_READDIR=1;
-  HAVE_REWINDDIR=1;
-  HAVE_CLOSEDIR=1;
-  HAVE_DECL_DIRFD=1;
-  HAVE_DECL_FDOPENDIR=1;
-  HAVE_FDOPENDIR=1;
-  HAVE_SCANDIR=1;
-  HAVE_ALPHASORT=1;
-  REPLACE_OPENDIR=0;
-  REPLACE_CLOSEDIR=0;
-  REPLACE_DIRFD=0;
-  REPLACE_FDOPENDIR=0;
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5
-$as_echo_n "checking whether the preprocessor supports include_next... " >&6; }
-if test "${gl_cv_have_include_next+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  rm -rf conftestd1a conftestd1b conftestd2
-     mkdir conftestd1a conftestd1b conftestd2
-                                                  cat <<EOF > conftestd1a/conftest.h
-#define DEFINED_IN_CONFTESTD1
-#include_next <conftest.h>
-#ifdef DEFINED_IN_CONFTESTD2
-int foo;
-#else
-#error "include_next doesn't work"
-#endif
-EOF
-     cat <<EOF > conftestd1b/conftest.h
-#define DEFINED_IN_CONFTESTD1
-#include <stdio.h>
-#include_next <conftest.h>
-#ifdef DEFINED_IN_CONFTESTD2
-int foo;
-#else
-#error "include_next doesn't work"
-#endif
-EOF
-     cat <<EOF > conftestd2/conftest.h
-#ifndef DEFINED_IN_CONFTESTD1
-#error "include_next test doesn't work"
-#endif
-#define DEFINED_IN_CONFTESTD2
-EOF
-     gl_save_CPPFLAGS="$CPPFLAGS"
-     CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <conftest.h>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_have_include_next=yes
-else
-  CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <conftest.h>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_have_include_next=buggy
-else
-  gl_cv_have_include_next=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-     CPPFLAGS="$gl_save_CPPFLAGS"
-     rm -rf conftestd1a conftestd1b conftestd2
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5
-$as_echo "$gl_cv_have_include_next" >&6; }
-  PRAGMA_SYSTEM_HEADER=
-  if test $gl_cv_have_include_next = yes; then
-    INCLUDE_NEXT=include_next
-    INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
-    if test -n "$GCC"; then
-      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
-    fi
-  else
-    if test $gl_cv_have_include_next = buggy; then
-      INCLUDE_NEXT=include
-      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
-    else
-      INCLUDE_NEXT=include
-      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
-    fi
-  fi
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5
-$as_echo_n "checking whether system header files limit the line length... " >&6; }
-if test "${gl_cv_pragma_columns+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifdef __TANDEM
-choke me
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "choke me" >/dev/null 2>&1; then :
-  gl_cv_pragma_columns=yes
-else
-  gl_cv_pragma_columns=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5
-$as_echo "$gl_cv_pragma_columns" >&6; }
-  if test $gl_cv_pragma_columns = yes; then
-    PRAGMA_COLUMNS="#pragma COLUMNS 10000"
-  else
-    PRAGMA_COLUMNS=
-  fi
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtold conforms to C99" >&5
-$as_echo_n "checking whether strtold conforms to C99... " >&6; }
-if test "${gl_cv_func_c99_strtold+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* On HP-UX before 11.23, strtold returns a struct instead of
-                long double.  Reject implementations like that, by requiring
-                compatibility with the C99 prototype.  */
-             #include <stdlib.h>
-             static long double (*p) (char const *, char **) = strtold;
-             static long double
-             test (char const *nptr, char **endptr)
-             {
-               long double r;
-               r = strtold (nptr, endptr);
-               return r;
-             }
-int
-main ()
-{
-return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_func_c99_strtold=yes
-else
-  gl_cv_func_c99_strtold=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_c99_strtold" >&5
-$as_echo "$gl_cv_func_c99_strtold" >&6; }
-  if test $gl_cv_func_c99_strtold = yes; then
-
-$as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h
-
-  fi
-
-
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5
-$as_echo_n "checking if environ is properly declared... " >&6; }
-  if test "${gt_cv_var_environ_declaration+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if HAVE_UNISTD_H
-     #include <unistd.h>
-     #endif
-     /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
-     #include <stdlib.h>
-
-           extern struct { int foo; } environ;
-int
-main ()
-{
-environ.foo = 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gt_cv_var_environ_declaration=no
-else
-  gt_cv_var_environ_declaration=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_var_environ_declaration" >&5
-$as_echo "$gt_cv_var_environ_declaration" >&6; }
-  if test $gt_cv_var_environ_declaration = yes; then
-
-$as_echo "#define HAVE_ENVIRON_DECL 1" >>confdefs.h
-
-  fi
-
-
-  if test $gt_cv_var_environ_declaration != yes; then
-    HAVE_DECL_ENVIRON=0
-  fi
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for complete errno.h" >&5
-$as_echo_n "checking for complete errno.h... " >&6; }
-if test "${gl_cv_header_errno_h_complete+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <errno.h>
-#if !defined ETXTBSY
-booboo
-#endif
-#if !defined ENOMSG
-booboo
-#endif
-#if !defined EIDRM
-booboo
-#endif
-#if !defined ENOLINK
-booboo
-#endif
-#if !defined EPROTO
-booboo
-#endif
-#if !defined EMULTIHOP
-booboo
-#endif
-#if !defined EBADMSG
-booboo
-#endif
-#if !defined EOVERFLOW
-booboo
-#endif
-#if !defined ENOTSUP
-booboo
-#endif
-#if !defined ENETRESET
-booboo
-#endif
-#if !defined ECONNABORTED
-booboo
-#endif
-#if !defined ESTALE
-booboo
-#endif
-#if !defined EDQUOT
-booboo
-#endif
-#if !defined ECANCELED
-booboo
-#endif
-#if !defined EOWNERDEAD
-booboo
-#endif
-#if !defined ENOTRECOVERABLE
-booboo
-#endif
-#if !defined EILSEQ
-booboo
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "booboo" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_complete=no
-else
-  gl_cv_header_errno_h_complete=yes
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_complete" >&5
-$as_echo "$gl_cv_header_errno_h_complete" >&6; }
-  if test $gl_cv_header_errno_h_complete = yes; then
-    ERRNO_H=''
-  else
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_errno_h='<'errno.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <errno.h>" >&5
-$as_echo_n "checking absolute name of <errno.h>... " >&6; }
-if test "${gl_cv_next_errno_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <errno.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'errno.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_errno_h" >&5
-$as_echo "$gl_cv_next_errno_h" >&6; }
-     fi
-     NEXT_ERRNO_H=$gl_cv_next_errno_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'errno.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_errno_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_ERRNO_H=$gl_next_as_first_directive
-
-
-
-
-    ERRNO_H='errno.h'
-  fi
-
-   if test -n "$ERRNO_H"; then
-  GL_GENERATE_ERRNO_H_TRUE=
-  GL_GENERATE_ERRNO_H_FALSE='#'
-else
-  GL_GENERATE_ERRNO_H_TRUE='#'
-  GL_GENERATE_ERRNO_H_FALSE=
-fi
-
-
-  if test -n "$ERRNO_H"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EMULTIHOP value" >&5
-$as_echo_n "checking for EMULTIHOP value... " >&6; }
-if test "${gl_cv_header_errno_h_EMULTIHOP+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <errno.h>
-#ifdef EMULTIHOP
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_EMULTIHOP=yes
-else
-  gl_cv_header_errno_h_EMULTIHOP=no
-fi
-rm -f conftest*
-
-      if test $gl_cv_header_errno_h_EMULTIHOP = no; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-#ifdef EMULTIHOP
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_EMULTIHOP=hidden
-fi
-rm -f conftest*
-
-        if test $gl_cv_header_errno_h_EMULTIHOP = hidden; then
-                              if ac_fn_c_compute_int "$LINENO" "EMULTIHOP" "gl_cv_header_errno_h_EMULTIHOP"        "
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-/* The following two lines are a workaround against an autoconf-2.52 bug.  */
-#include <stdio.h>
-#include <stdlib.h>
-"; then :
-
-fi
-
-        fi
-      fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EMULTIHOP" >&5
-$as_echo "$gl_cv_header_errno_h_EMULTIHOP" >&6; }
-    case $gl_cv_header_errno_h_EMULTIHOP in
-      yes | no)
-        EMULTIHOP_HIDDEN=0; EMULTIHOP_VALUE=
-        ;;
-      *)
-        EMULTIHOP_HIDDEN=1; EMULTIHOP_VALUE="$gl_cv_header_errno_h_EMULTIHOP"
-        ;;
-    esac
-
-
-  fi
-
-
-  if test -n "$ERRNO_H"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ENOLINK value" >&5
-$as_echo_n "checking for ENOLINK value... " >&6; }
-if test "${gl_cv_header_errno_h_ENOLINK+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <errno.h>
-#ifdef ENOLINK
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_ENOLINK=yes
-else
-  gl_cv_header_errno_h_ENOLINK=no
-fi
-rm -f conftest*
-
-      if test $gl_cv_header_errno_h_ENOLINK = no; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-#ifdef ENOLINK
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_ENOLINK=hidden
-fi
-rm -f conftest*
-
-        if test $gl_cv_header_errno_h_ENOLINK = hidden; then
-                              if ac_fn_c_compute_int "$LINENO" "ENOLINK" "gl_cv_header_errno_h_ENOLINK"        "
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-/* The following two lines are a workaround against an autoconf-2.52 bug.  */
-#include <stdio.h>
-#include <stdlib.h>
-"; then :
-
-fi
-
-        fi
-      fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_ENOLINK" >&5
-$as_echo "$gl_cv_header_errno_h_ENOLINK" >&6; }
-    case $gl_cv_header_errno_h_ENOLINK in
-      yes | no)
-        ENOLINK_HIDDEN=0; ENOLINK_VALUE=
-        ;;
-      *)
-        ENOLINK_HIDDEN=1; ENOLINK_VALUE="$gl_cv_header_errno_h_ENOLINK"
-        ;;
-    esac
-
-
-  fi
-
-
-  if test -n "$ERRNO_H"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EOVERFLOW value" >&5
-$as_echo_n "checking for EOVERFLOW value... " >&6; }
-if test "${gl_cv_header_errno_h_EOVERFLOW+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <errno.h>
-#ifdef EOVERFLOW
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_EOVERFLOW=yes
-else
-  gl_cv_header_errno_h_EOVERFLOW=no
-fi
-rm -f conftest*
-
-      if test $gl_cv_header_errno_h_EOVERFLOW = no; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-#ifdef EOVERFLOW
-yes
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "yes" >/dev/null 2>&1; then :
-  gl_cv_header_errno_h_EOVERFLOW=hidden
-fi
-rm -f conftest*
-
-        if test $gl_cv_header_errno_h_EOVERFLOW = hidden; then
-                              if ac_fn_c_compute_int "$LINENO" "EOVERFLOW" "gl_cv_header_errno_h_EOVERFLOW"        "
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-/* The following two lines are a workaround against an autoconf-2.52 bug.  */
-#include <stdio.h>
-#include <stdlib.h>
-"; then :
-
-fi
-
-        fi
-      fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_errno_h_EOVERFLOW" >&5
-$as_echo "$gl_cv_header_errno_h_EOVERFLOW" >&6; }
-    case $gl_cv_header_errno_h_EOVERFLOW in
-      yes | no)
-        EOVERFLOW_HIDDEN=0; EOVERFLOW_VALUE=
-        ;;
-      *)
-        EOVERFLOW_HIDDEN=1; EOVERFLOW_VALUE="$gl_cv_header_errno_h_EOVERFLOW"
-        ;;
-    esac
-
-
-  fi
-
-
-
-
-
-
-
-
-
-
-  GNULIB_FCNTL=0;
-  GNULIB_NONBLOCKING=0;
-  GNULIB_OPEN=0;
-  GNULIB_OPENAT=0;
-    HAVE_FCNTL=1;
-  HAVE_OPENAT=1;
-  REPLACE_FCNTL=0;
-  REPLACE_OPEN=0;
-  REPLACE_OPENAT=0;
-
-
-
-
-ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
-if test "x$ac_cv_type_mode_t" = x""yes; then :
-
-else
-
-cat >>confdefs.h <<_ACEOF
-#define mode_t int
-_ACEOF
-
-fi
-
-ac_fn_c_check_decl "$LINENO" "fdatasync" "ac_cv_have_decl_fdatasync" "$ac_includes_default"
-if test "x$ac_cv_have_decl_fdatasync" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FDATASYNC $ac_have_decl
-_ACEOF
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_dm_mode in struct stat" >&5
-$as_echo_n "checking for st_dm_mode in struct stat... " >&6; }
-if test "${ac_cv_struct_st_dm_mode+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-int
-main ()
-{
-struct stat s; s.st_dm_mode;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_struct_st_dm_mode=yes
-else
-  ac_cv_struct_st_dm_mode=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_st_dm_mode" >&5
-$as_echo "$ac_cv_struct_st_dm_mode" >&6; }
-
-  if test $ac_cv_struct_st_dm_mode = yes; then
-
-$as_echo "#define HAVE_ST_DM_MODE 1" >>confdefs.h
-
-  fi
-
-
-ac_fn_c_check_decl "$LINENO" "strmode" "ac_cv_have_decl_strmode" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strmode" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRMODE $ac_have_decl
-_ACEOF
-
-
-
-
-     GNULIB_FCHMODAT=0;
-  GNULIB_FSTAT=0;
-  GNULIB_FSTATAT=0;
-  GNULIB_FUTIMENS=0;
-  GNULIB_LCHMOD=0;
-  GNULIB_LSTAT=0;
-  GNULIB_MKDIRAT=0;
-  GNULIB_MKFIFO=0;
-  GNULIB_MKFIFOAT=0;
-  GNULIB_MKNOD=0;
-  GNULIB_MKNODAT=0;
-  GNULIB_STAT=0;
-  GNULIB_UTIMENSAT=0;
-    HAVE_FCHMODAT=1;
-  HAVE_FSTATAT=1;
-  HAVE_FUTIMENS=1;
-  HAVE_LCHMOD=1;
-  HAVE_LSTAT=1;
-  HAVE_MKDIRAT=1;
-  HAVE_MKFIFO=1;
-  HAVE_MKFIFOAT=1;
-  HAVE_MKNOD=1;
-  HAVE_MKNODAT=1;
-  HAVE_UTIMENSAT=1;
-  REPLACE_FSTAT=0;
-  REPLACE_FSTATAT=0;
-  REPLACE_FUTIMENS=0;
-  REPLACE_LSTAT=0;
-  REPLACE_MKDIR=0;
-  REPLACE_MKFIFO=0;
-  REPLACE_MKNOD=0;
-  REPLACE_STAT=0;
-  REPLACE_UTIMENSAT=0;
-
-
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5
-$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; }
-if test "${gl_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  rm -f conftest.sym conftest.file
-     echo >conftest.file
-     if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
-       if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-struct stat sbuf;
-              /* Linux will dereference the symlink and fail, as required by
-                 POSIX.  That is better in the sense that it means we will not
-                 have to compile and use the lstat wrapper.  */
-              return lstat ("conftest.sym/", &sbuf) == 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_lstat_dereferences_slashed_symlink=yes
-else
-  gl_cv_func_lstat_dereferences_slashed_symlink=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-     else
-       # If the 'ln -s' command failed, then we probably don't even
-       # have an lstat function.
-       gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
-     fi
-     rm -f conftest.sym conftest.file
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_lstat_dereferences_slashed_symlink" >&5
-$as_echo "$gl_cv_func_lstat_dereferences_slashed_symlink" >&6; }
-  case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
-    *yes)
-
-cat >>confdefs.h <<_ACEOF
-#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
-_ACEOF
-
-      ;;
-  esac
-
-
-
-
-
-
-  GNULIB__EXIT=0;
-  GNULIB_ATOLL=0;
-  GNULIB_CALLOC_POSIX=0;
-  GNULIB_CANONICALIZE_FILE_NAME=0;
-  GNULIB_GETLOADAVG=0;
-  GNULIB_GETSUBOPT=0;
-  GNULIB_GRANTPT=0;
-  GNULIB_MALLOC_POSIX=0;
-  GNULIB_MBTOWC=0;
-  GNULIB_MKDTEMP=0;
-  GNULIB_MKOSTEMP=0;
-  GNULIB_MKOSTEMPS=0;
-  GNULIB_MKSTEMP=0;
-  GNULIB_MKSTEMPS=0;
-  GNULIB_POSIX_OPENPT=0;
-  GNULIB_PTSNAME=0;
-  GNULIB_PTSNAME_R=0;
-  GNULIB_PUTENV=0;
-  GNULIB_RANDOM=0;
-  GNULIB_RANDOM_R=0;
-  GNULIB_REALLOC_POSIX=0;
-  GNULIB_REALPATH=0;
-  GNULIB_RPMATCH=0;
-  GNULIB_SECURE_GETENV=0;
-  GNULIB_SETENV=0;
-  GNULIB_STRTOD=0;
-  GNULIB_STRTOLL=0;
-  GNULIB_STRTOULL=0;
-  GNULIB_SYSTEM_POSIX=0;
-  GNULIB_UNLOCKPT=0;
-  GNULIB_UNSETENV=0;
-  GNULIB_WCTOMB=0;
-    HAVE__EXIT=1;
-  HAVE_ATOLL=1;
-  HAVE_CANONICALIZE_FILE_NAME=1;
-  HAVE_DECL_GETLOADAVG=1;
-  HAVE_GETSUBOPT=1;
-  HAVE_GRANTPT=1;
-  HAVE_MKDTEMP=1;
-  HAVE_MKOSTEMP=1;
-  HAVE_MKOSTEMPS=1;
-  HAVE_MKSTEMP=1;
-  HAVE_MKSTEMPS=1;
-  HAVE_POSIX_OPENPT=1;
-  HAVE_PTSNAME=1;
-  HAVE_PTSNAME_R=1;
-  HAVE_RANDOM=1;
-  HAVE_RANDOM_H=1;
-  HAVE_RANDOM_R=1;
-  HAVE_REALPATH=1;
-  HAVE_RPMATCH=1;
-  HAVE_SECURE_GETENV=1;
-  HAVE_SETENV=1;
-  HAVE_DECL_SETENV=1;
-  HAVE_STRTOD=1;
-  HAVE_STRTOLL=1;
-  HAVE_STRTOULL=1;
-  HAVE_STRUCT_RANDOM_DATA=1;
-  HAVE_SYS_LOADAVG_H=0;
-  HAVE_UNLOCKPT=1;
-  HAVE_DECL_UNSETENV=1;
-  REPLACE_CALLOC=0;
-  REPLACE_CANONICALIZE_FILE_NAME=0;
-  REPLACE_MALLOC=0;
-  REPLACE_MBTOWC=0;
-  REPLACE_MKSTEMP=0;
-  REPLACE_PTSNAME=0;
-  REPLACE_PTSNAME_R=0;
-  REPLACE_PUTENV=0;
-  REPLACE_RANDOM_R=0;
-  REPLACE_REALLOC=0;
-  REPLACE_REALPATH=0;
-  REPLACE_SETENV=0;
-  REPLACE_STRTOD=0;
-  REPLACE_UNSETENV=0;
-  REPLACE_WCTOMB=0;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_getopt_h='<'getopt.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <getopt.h>" >&5
-$as_echo_n "checking absolute name of <getopt.h>... " >&6; }
-if test "${gl_cv_next_getopt_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_getopt_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <getopt.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'getopt.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_getopt_h='<'getopt.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5
-$as_echo "$gl_cv_next_getopt_h" >&6; }
-     fi
-     NEXT_GETOPT_H=$gl_cv_next_getopt_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'getopt.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_getopt_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_GETOPT_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_getopt_h = yes; then
-    HAVE_GETOPT_H=1
-  else
-    HAVE_GETOPT_H=0
-  fi
-
-
-  gl_replace_getopt=
-
-    if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
-    for ac_header in getopt.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
-if test "x$ac_cv_header_getopt_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GETOPT_H 1
-_ACEOF
-
-else
-  gl_replace_getopt=yes
-fi
-
-done
-
-  fi
-
-    if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
-    for ac_func in getopt_long_only
-do :
-  ac_fn_c_check_func "$LINENO" "getopt_long_only" "ac_cv_func_getopt_long_only"
-if test "x$ac_cv_func_getopt_long_only" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GETOPT_LONG_ONLY 1
-_ACEOF
-
-else
-  gl_replace_getopt=yes
-fi
-done
-
-  fi
-
-          if test -z "$gl_replace_getopt"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5
-$as_echo_n "checking whether getopt is POSIX compatible... " >&6; }
-if test "${gl_cv_func_getopt_posix+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-                                                if test $cross_compiling = no; then
-                              if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run test program while cross compiling
-See \`config.log' for more details." "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-main ()
-{
-  static char program[] = "program";
-  static char a[] = "-a";
-  static char foo[] = "foo";
-  static char bar[] = "bar";
-  char *argv[] = { program, a, foo, bar, NULL };
-  int c;
-
-  c = getopt (4, argv, "ab");
-  if (!(c == 'a'))
-    return 1;
-  c = getopt (4, argv, "ab");
-  if (!(c == -1))
-    return 2;
-  if (!(optind == 2))
-    return 3;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getopt_posix=maybe
-else
-  gl_cv_func_getopt_posix=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-          if test $gl_cv_func_getopt_posix = maybe; then
-                                    if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run test program while cross compiling
-See \`config.log' for more details." "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-main ()
-{
-  static char program[] = "program";
-  static char donald[] = "donald";
-  static char p[] = "-p";
-  static char billy[] = "billy";
-  static char duck[] = "duck";
-  static char a[] = "-a";
-  static char bar[] = "bar";
-  char *argv[] = { program, donald, p, billy, duck, a, bar, NULL };
-  int c;
-
-  c = getopt (7, argv, "+abp:q:");
-  if (!(c == -1))
-    return 4;
-  if (!(strcmp (argv[0], "program") == 0))
-    return 5;
-  if (!(strcmp (argv[1], "donald") == 0))
-    return 6;
-  if (!(strcmp (argv[2], "-p") == 0))
-    return 7;
-  if (!(strcmp (argv[3], "billy") == 0))
-    return 8;
-  if (!(strcmp (argv[4], "duck") == 0))
-    return 9;
-  if (!(strcmp (argv[5], "-a") == 0))
-    return 10;
-  if (!(strcmp (argv[6], "bar") == 0))
-    return 11;
-  if (!(optind == 1))
-    return 12;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getopt_posix=maybe
-else
-  gl_cv_func_getopt_posix=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-          fi
-          if test $gl_cv_func_getopt_posix = maybe; then
-                        if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run test program while cross compiling
-See \`config.log' for more details." "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-main ()
-{
-  static char program[] = "program";
-  static char ab[] = "-ab";
-  char *argv[3] = { program, ab, NULL };
-  if (getopt (2, argv, "ab:") != 'a')
-    return 13;
-  if (getopt (2, argv, "ab:") != '?')
-    return 14;
-  if (optopt != 'b')
-    return 15;
-  if (optind != 2)
-    return 16;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getopt_posix=yes
-else
-  gl_cv_func_getopt_posix=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-          fi
-        else
-          case "$host_os" in
-            darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";;
-            *)                       gl_cv_func_getopt_posix="guessing yes";;
-          esac
-        fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_posix" >&5
-$as_echo "$gl_cv_func_getopt_posix" >&6; }
-    case "$gl_cv_func_getopt_posix" in
-      *no) gl_replace_getopt=yes ;;
-    esac
-  fi
-
-  if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt function" >&5
-$as_echo_n "checking for working GNU getopt function... " >&6; }
-if test "${gl_cv_func_getopt_gnu+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
-       # optstring is necessary for programs like m4 that have POSIX-mandated
-       # semantics for supporting options interspersed with files.
-       # Also, since getopt_long is a GNU extension, we require optind=0.
-       # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
-       # so take care to revert to the correct (non-)export state.
-       gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
-       case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
-         xx) gl_had_POSIXLY_CORRECT=exported ;;
-         x)  gl_had_POSIXLY_CORRECT=yes      ;;
-         *)  gl_had_POSIXLY_CORRECT=         ;;
-       esac
-       POSIXLY_CORRECT=1
-       export POSIXLY_CORRECT
-       if test "$cross_compiling" = yes; then :
-           gl_cv_func_getopt_gnu="guessing no"
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <getopt.h>
-                           #include <stddef.h>
-                           #include <string.h>
-
-#include <stdlib.h>
-#if defined __MACH__ && defined __APPLE__
-/* Avoid a crash on Mac OS X.  */
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-#include <mach/thread_status.h>
-#include <mach/exception.h>
-#include <mach/task.h>
-#include <pthread.h>
-/* The exception port on which our thread listens.  */
-static mach_port_t our_exception_port;
-/* The main function of the thread listening for exceptions of type
-   EXC_BAD_ACCESS.  */
-static void *
-mach_exception_thread (void *arg)
-{
-  /* Buffer for a message to be received.  */
-  struct {
-    mach_msg_header_t head;
-    mach_msg_body_t msgh_body;
-    char data[1024];
-  } msg;
-  mach_msg_return_t retval;
-  /* Wait for a message on the exception port.  */
-  retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg),
-                     our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
-  if (retval != MACH_MSG_SUCCESS)
-    abort ();
-  exit (1);
-}
-static void
-nocrash_init (void)
-{
-  mach_port_t self = mach_task_self ();
-  /* Allocate a port on which the thread shall listen for exceptions.  */
-  if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
-      == KERN_SUCCESS) {
-    /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html.  */
-    if (mach_port_insert_right (self, our_exception_port, our_exception_port,
-                                MACH_MSG_TYPE_MAKE_SEND)
-        == KERN_SUCCESS) {
-      /* The exceptions we want to catch.  Only EXC_BAD_ACCESS is interesting
-         for us.  */
-      exception_mask_t mask = EXC_MASK_BAD_ACCESS;
-      /* Create the thread listening on the exception port.  */
-      pthread_attr_t attr;
-      pthread_t thread;
-      if (pthread_attr_init (&attr) == 0
-          && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0
-          && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) {
-        pthread_attr_destroy (&attr);
-        /* Replace the exception port info for these exceptions with our own.
-           Note that we replace the exception port for the entire task, not only
-           for a particular thread.  This has the effect that when our exception
-           port gets the message, the thread specific exception port has already
-           been asked, and we don't need to bother about it.
-           See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html.  */
-        task_set_exception_ports (self, mask, our_exception_port,
-                                  EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
-      }
-    }
-  }
-}
-#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Avoid a crash on native Windows.  */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <winerror.h>
-static LONG WINAPI
-exception_filter (EXCEPTION_POINTERS *ExceptionInfo)
-{
-  switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
-    {
-    case EXCEPTION_ACCESS_VIOLATION:
-    case EXCEPTION_IN_PAGE_ERROR:
-    case EXCEPTION_STACK_OVERFLOW:
-    case EXCEPTION_GUARD_PAGE:
-    case EXCEPTION_PRIV_INSTRUCTION:
-    case EXCEPTION_ILLEGAL_INSTRUCTION:
-    case EXCEPTION_DATATYPE_MISALIGNMENT:
-    case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
-    case EXCEPTION_NONCONTINUABLE_EXCEPTION:
-      exit (1);
-    }
-  return EXCEPTION_CONTINUE_SEARCH;
-}
-static void
-nocrash_init (void)
-{
-  SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter);
-}
-#else
-/* Avoid a crash on POSIX systems.  */
-#include <signal.h>
-/* A POSIX signal handler.  */
-static void
-exception_handler (int sig)
-{
-  exit (1);
-}
-static void
-nocrash_init (void)
-{
-#ifdef SIGSEGV
-  signal (SIGSEGV, exception_handler);
-#endif
-#ifdef SIGBUS
-  signal (SIGBUS, exception_handler);
-#endif
-}
-#endif
-
-
-int
-main ()
-{
-
-             int result = 0;
-
-             nocrash_init();
-
-             /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
-                and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
-                OSF/1 5.1, Solaris 10.  */
-             {
-               static char conftest[] = "conftest";
-               static char plus[] = "-+";
-               char *argv[3] = { conftest, plus, NULL };
-               opterr = 0;
-               if (getopt (2, argv, "+a") != '?')
-                 result |= 1;
-             }
-             /* This code succeeds on glibc 2.8, mingw,
-                and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
-                IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x.  */
-             {
-               static char program[] = "program";
-               static char p[] = "-p";
-               static char foo[] = "foo";
-               static char bar[] = "bar";
-               char *argv[] = { program, p, foo, bar, NULL };
-
-               optind = 1;
-               if (getopt (4, argv, "p::") != 'p')
-                 result |= 2;
-               else if (optarg != NULL)
-                 result |= 4;
-               else if (getopt (4, argv, "p::") != -1)
-                 result |= 6;
-               else if (optind != 2)
-                 result |= 8;
-             }
-             /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0.  */
-             {
-               static char program[] = "program";
-               static char foo[] = "foo";
-               static char p[] = "-p";
-               char *argv[] = { program, foo, p, NULL };
-               optind = 0;
-               if (getopt (3, argv, "-p") != 1)
-                 result |= 16;
-               else if (getopt (3, argv, "-p") != 'p')
-                 result |= 16;
-             }
-             /* This code fails on glibc 2.11.  */
-             {
-               static char program[] = "program";
-               static char b[] = "-b";
-               static char a[] = "-a";
-               char *argv[] = { program, b, a, NULL };
-               optind = opterr = 0;
-               if (getopt (3, argv, "+:a:b") != 'b')
-                 result |= 32;
-               else if (getopt (3, argv, "+:a:b") != ':')
-                 result |= 32;
-             }
-             /* This code dumps core on glibc 2.14.  */
-             {
-               static char program[] = "program";
-               static char w[] = "-W";
-               static char dummy[] = "dummy";
-               char *argv[] = { program, w, dummy, NULL };
-               optind = opterr = 1;
-               if (getopt (3, argv, "W;") != 'W')
-                 result |= 64;
-             }
-             return result;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getopt_gnu=yes
-else
-  gl_cv_func_getopt_gnu=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-       case $gl_had_POSIXLY_CORRECT in
-         exported) ;;
-         yes) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;}; POSIXLY_CORRECT=1 ;;
-         *) { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;} ;;
-       esac
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5
-$as_echo "$gl_cv_func_getopt_gnu" >&6; }
-    if test "$gl_cv_func_getopt_gnu" != yes; then
-      gl_replace_getopt=yes
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working GNU getopt_long function" >&5
-$as_echo_n "checking for working GNU getopt_long function... " >&6; }
-if test "${gl_cv_func_getopt_long_gnu+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-              case "$host_os" in
-              openbsd*) gl_cv_func_getopt_long_gnu="guessing no";;
-              *)        gl_cv_func_getopt_long_gnu="guessing yes";;
-            esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <getopt.h>
-                #include <stddef.h>
-                #include <string.h>
-
-int
-main ()
-{
-static const struct option long_options[] =
-                  {
-                    { "xtremely-",no_argument,       NULL, 1003 },
-                    { "xtra",     no_argument,       NULL, 1001 },
-                    { "xtreme",   no_argument,       NULL, 1002 },
-                    { "xtremely", no_argument,       NULL, 1003 },
-                    { NULL,       0,                 NULL, 0 }
-                  };
-                /* This code fails on OpenBSD 5.0.  */
-                {
-                  static char program[] = "program";
-                  static char xtremel[] = "--xtremel";
-                  char *argv[] = { program, xtremel, NULL };
-                  int option_index;
-                  optind = 1; opterr = 0;
-                  if (getopt_long (2, argv, "", long_options, &option_index) != 1003)
-                    return 1;
-                }
-                return 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getopt_long_gnu=yes
-else
-  gl_cv_func_getopt_long_gnu=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_long_gnu" >&5
-$as_echo "$gl_cv_func_getopt_long_gnu" >&6; }
-      case "$gl_cv_func_getopt_long_gnu" in
-        *yes) ;;
-        *) gl_replace_getopt=yes ;;
-      esac
-    fi
-  fi
-
-
-
-
-
-
-    REPLACE_GETOPT=0
-    if test -n "$gl_replace_getopt"; then
-      REPLACE_GETOPT=1
-    fi
-
-  if test $REPLACE_GETOPT = 1; then
-
-  GETOPT_H=getopt.h
-
-$as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
-
-
-
-  fi
-
-ac_fn_c_check_decl "$LINENO" "getenv" "ac_cv_have_decl_getenv" "$ac_includes_default"
-if test "x$ac_cv_have_decl_getenv" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETENV $ac_have_decl
-_ACEOF
-
-:
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
-$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
-if test "${ac_cv_c_restrict+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_c_restrict=no
-   # The order here caters to the fact that C++ does not require restrict.
-   for ac_kw in __restrict __restrict__ _Restrict restrict; do
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-typedef int * int_ptr;
-       int foo (int_ptr $ac_kw ip) {
-       return ip[0];
-       }
-int
-main ()
-{
-int s[1];
-       int * $ac_kw t = s;
-       t[0] = 0;
-       return foo(t)
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_c_restrict=$ac_kw
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-     test "$ac_cv_c_restrict" != no && break
-   done
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
-$as_echo "$ac_cv_c_restrict" >&6; }
-
- case $ac_cv_c_restrict in
-   restrict) ;;
-   no) $as_echo "#define restrict /**/" >>confdefs.h
- ;;
-   *)  cat >>confdefs.h <<_ACEOF
-#define restrict $ac_cv_c_restrict
-_ACEOF
- ;;
- esac
-
-
-  GNULIB_GETTIMEOFDAY=0;
-    HAVE_GETTIMEOFDAY=1;
-  HAVE_STRUCT_TIMEVAL=1;
-  HAVE_SYS_TIME_H=1;
-  REPLACE_GETTIMEOFDAY=0;
-  REPLACE_STRUCT_TIMEVAL=0;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_sys_time_h='<'sys/time.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/time.h>" >&5
-$as_echo_n "checking absolute name of <sys/time.h>... " >&6; }
-if test "${gl_cv_next_sys_time_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_sys_time_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/time.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'sys/time.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_sys_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_sys_time_h='<'sys/time.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_time_h" >&5
-$as_echo "$gl_cv_next_sys_time_h" >&6; }
-     fi
-     NEXT_SYS_TIME_H=$gl_cv_next_sys_time_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'sys/time.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_sys_time_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H=$gl_next_as_first_directive
-
-
-
-
-
-  if test $ac_cv_header_sys_time_h != yes; then
-    HAVE_SYS_TIME_H=0
-  fi
-
-
-
-
-
-  if test $ac_cv_header_sys_socket_h != yes; then
-                    for ac_header in winsock2.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default"
-if test "x$ac_cv_header_winsock2_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_WINSOCK2_H 1
-_ACEOF
-
-fi
-
-done
-
-  fi
-  if test "$ac_cv_header_winsock2_h" = yes; then
-    HAVE_WINSOCK2_H=1
-    UNISTD_H_HAVE_WINSOCK2_H=1
-    SYS_IOCTL_H_HAVE_WINSOCK2_H=1
-  else
-    HAVE_WINSOCK2_H=0
-  fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timeval" >&5
-$as_echo_n "checking for struct timeval... " >&6; }
-if test "${gl_cv_sys_struct_timeval+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if HAVE_SYS_TIME_H
-             #include <sys/time.h>
-            #endif
-            #include <time.h>
-            #if HAVE_WINSOCK2_H
-            # include <winsock2.h>
-            #endif
-
-int
-main ()
-{
-static struct timeval x; x.tv_sec = x.tv_usec;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_timeval=yes
-else
-  gl_cv_sys_struct_timeval=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timeval" >&5
-$as_echo "$gl_cv_sys_struct_timeval" >&6; }
-  if test $gl_cv_sys_struct_timeval != yes; then
-    HAVE_STRUCT_TIMEVAL=0
-  else
-                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wide-enough struct timeval.tv_sec member" >&5
-$as_echo_n "checking for wide-enough struct timeval.tv_sec member... " >&6; }
-if test "${gl_cv_sys_struct_timeval_tv_sec+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if HAVE_SYS_TIME_H
-               #include <sys/time.h>
-              #endif
-              #include <time.h>
-              #if HAVE_WINSOCK2_H
-              # include <winsock2.h>
-              #endif
-
-int
-main ()
-{
-static struct timeval x;
-              typedef int verify_tv_sec_type[
-                sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1
-              ];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_timeval_tv_sec=yes
-else
-  gl_cv_sys_struct_timeval_tv_sec=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timeval_tv_sec" >&5
-$as_echo "$gl_cv_sys_struct_timeval_tv_sec" >&6; }
-    if test $gl_cv_sys_struct_timeval_tv_sec != yes; then
-      REPLACE_STRUCT_TIMEVAL=1
-    fi
-  fi
-
-
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5
-$as_echo_n "checking for long long int... " >&6; }
-if test "${ac_cv_type_long_long_int+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_type_long_long_int=yes
-      if test "x${ac_cv_prog_cc_c99-no}" = xno; then
-        ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
-        if test $ac_cv_type_long_long_int = yes; then
-                                        if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <limits.h>
-                 #ifndef LLONG_MAX
-                 # define HALF \
-                          (1LL << (sizeof (long long int) * CHAR_BIT - 2))
-                 # define LLONG_MAX (HALF - 1 + HALF)
-                 #endif
-int
-main ()
-{
-long long int n = 1;
-                 int i;
-                 for (i = 0; ; i++)
-                   {
-                     long long int m = n << i;
-                     if (m >> i != n)
-                       return 1;
-                     if (LLONG_MAX / 2 < m)
-                       break;
-                   }
-                 return 0;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  ac_cv_type_long_long_int=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-        fi
-      fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5
-$as_echo "$ac_cv_type_long_long_int" >&6; }
-  if test $ac_cv_type_long_long_int = yes; then
-
-$as_echo "#define HAVE_LONG_LONG_INT 1" >>confdefs.h
-
-  fi
-
-
-
-
-
-
-    gl_cv_c_multiarch=no
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifndef __APPLE_CC__
-         not a universal capable compiler
-        #endif
-        typedef int dummy;
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-               arch=
-     prev=
-     for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
-       if test -n "$prev"; then
-         case $word in
-           i?86 | x86_64 | ppc | ppc64)
-             if test -z "$arch" || test "$arch" = "$word"; then
-               arch="$word"
-             else
-               gl_cv_c_multiarch=yes
-             fi
-             ;;
-         esac
-         prev=
-       else
-         if test "x$word" = "x-arch"; then
-           prev=arch
-         fi
-       fi
-     done
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  if test $gl_cv_c_multiarch = yes; then
-    APPLE_UNIVERSAL_BUILD=1
-  else
-    APPLE_UNIVERSAL_BUILD=0
-  fi
-
-
-
-
-
-  if test $ac_cv_type_long_long_int = yes; then
-    HAVE_LONG_LONG_INT=1
-  else
-    HAVE_LONG_LONG_INT=0
-  fi
-
-
-  if test $ac_cv_type_unsigned_long_long_int = yes; then
-    HAVE_UNSIGNED_LONG_LONG_INT=1
-  else
-    HAVE_UNSIGNED_LONG_LONG_INT=0
-  fi
-
-
-
-  if test $ac_cv_header_wchar_h = yes; then
-    HAVE_WCHAR_H=1
-  else
-    HAVE_WCHAR_H=0
-  fi
-
-
-      if test $ac_cv_header_inttypes_h = yes; then
-    HAVE_INTTYPES_H=1
-  else
-    HAVE_INTTYPES_H=0
-  fi
-
-
-      if test $ac_cv_header_sys_types_h = yes; then
-    HAVE_SYS_TYPES_H=1
-  else
-    HAVE_SYS_TYPES_H=0
-  fi
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_stdint_h='<'stdint.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdint.h>" >&5
-$as_echo_n "checking absolute name of <stdint.h>... " >&6; }
-if test "${gl_cv_next_stdint_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_stdint_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdint.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'stdint.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_stdint_h='<'stdint.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5
-$as_echo "$gl_cv_next_stdint_h" >&6; }
-     fi
-     NEXT_STDINT_H=$gl_cv_next_stdint_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'stdint.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_stdint_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STDINT_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_stdint_h = yes; then
-    HAVE_STDINT_H=1
-  else
-    HAVE_STDINT_H=0
-  fi
-
-
-    if test $ac_cv_header_stdint_h = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stdint.h conforms to C99" >&5
-$as_echo_n "checking whether stdint.h conforms to C99... " >&6; }
-if test "${gl_cv_header_working_stdint_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  gl_cv_header_working_stdint_h=no
-       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
-#include <stdint.h>
-/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
-#if !(defined WCHAR_MIN && defined WCHAR_MAX)
-#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
-#endif
-
-
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-
-#ifdef INT8_MAX
-int8_t a1 = INT8_MAX;
-int8_t a1min = INT8_MIN;
-#endif
-#ifdef INT16_MAX
-int16_t a2 = INT16_MAX;
-int16_t a2min = INT16_MIN;
-#endif
-#ifdef INT32_MAX
-int32_t a3 = INT32_MAX;
-int32_t a3min = INT32_MIN;
-#endif
-#ifdef INT64_MAX
-int64_t a4 = INT64_MAX;
-int64_t a4min = INT64_MIN;
-#endif
-#ifdef UINT8_MAX
-uint8_t b1 = UINT8_MAX;
-#else
-typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
-#endif
-#ifdef UINT16_MAX
-uint16_t b2 = UINT16_MAX;
-#endif
-#ifdef UINT32_MAX
-uint32_t b3 = UINT32_MAX;
-#endif
-#ifdef UINT64_MAX
-uint64_t b4 = UINT64_MAX;
-#endif
-int_least8_t c1 = INT8_C (0x7f);
-int_least8_t c1max = INT_LEAST8_MAX;
-int_least8_t c1min = INT_LEAST8_MIN;
-int_least16_t c2 = INT16_C (0x7fff);
-int_least16_t c2max = INT_LEAST16_MAX;
-int_least16_t c2min = INT_LEAST16_MIN;
-int_least32_t c3 = INT32_C (0x7fffffff);
-int_least32_t c3max = INT_LEAST32_MAX;
-int_least32_t c3min = INT_LEAST32_MIN;
-int_least64_t c4 = INT64_C (0x7fffffffffffffff);
-int_least64_t c4max = INT_LEAST64_MAX;
-int_least64_t c4min = INT_LEAST64_MIN;
-uint_least8_t d1 = UINT8_C (0xff);
-uint_least8_t d1max = UINT_LEAST8_MAX;
-uint_least16_t d2 = UINT16_C (0xffff);
-uint_least16_t d2max = UINT_LEAST16_MAX;
-uint_least32_t d3 = UINT32_C (0xffffffff);
-uint_least32_t d3max = UINT_LEAST32_MAX;
-uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
-uint_least64_t d4max = UINT_LEAST64_MAX;
-int_fast8_t e1 = INT_FAST8_MAX;
-int_fast8_t e1min = INT_FAST8_MIN;
-int_fast16_t e2 = INT_FAST16_MAX;
-int_fast16_t e2min = INT_FAST16_MIN;
-int_fast32_t e3 = INT_FAST32_MAX;
-int_fast32_t e3min = INT_FAST32_MIN;
-int_fast64_t e4 = INT_FAST64_MAX;
-int_fast64_t e4min = INT_FAST64_MIN;
-uint_fast8_t f1 = UINT_FAST8_MAX;
-uint_fast16_t f2 = UINT_FAST16_MAX;
-uint_fast32_t f3 = UINT_FAST32_MAX;
-uint_fast64_t f4 = UINT_FAST64_MAX;
-#ifdef INTPTR_MAX
-intptr_t g = INTPTR_MAX;
-intptr_t gmin = INTPTR_MIN;
-#endif
-#ifdef UINTPTR_MAX
-uintptr_t h = UINTPTR_MAX;
-#endif
-intmax_t i = INTMAX_MAX;
-uintmax_t j = UINTMAX_MAX;
-
-#include <limits.h> /* for CHAR_BIT */
-#define TYPE_MINIMUM(t) \
-  ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
-#define TYPE_MAXIMUM(t) \
-  ((t) ((t) 0 < (t) -1 \
-        ? (t) -1 \
-        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
-struct s {
-  int check_PTRDIFF:
-      PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
-      && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
-      ? 1 : -1;
-  /* Detect bug in FreeBSD 6.0 / ia64.  */
-  int check_SIG_ATOMIC:
-      SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
-      && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
-      ? 1 : -1;
-  int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
-  int check_WCHAR:
-      WCHAR_MIN == TYPE_MINIMUM (wchar_t)
-      && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
-      ? 1 : -1;
-  /* Detect bug in mingw.  */
-  int check_WINT:
-      WINT_MIN == TYPE_MINIMUM (wint_t)
-      && WINT_MAX == TYPE_MAXIMUM (wint_t)
-      ? 1 : -1;
-
-  /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
-  int check_UINT8_C:
-        (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
-  int check_UINT16_C:
-        (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
-
-  /* Detect bugs in OpenBSD 3.9 stdint.h.  */
-#ifdef UINT8_MAX
-  int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
-#endif
-#ifdef UINT16_MAX
-  int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
-#endif
-#ifdef UINT32_MAX
-  int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
-#endif
-#ifdef UINT64_MAX
-  int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
-#endif
-  int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
-  int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
-  int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
-  int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
-  int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
-  int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
-  int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
-  int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
-  int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
-  int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
-  int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
-};
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-                                                    if test "$cross_compiling" = yes; then :
-                 gl_cv_header_working_stdint_h=yes
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-
-#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
-#include <stdint.h>
-
-
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-
-#include <stdio.h>
-#include <string.h>
-#define MVAL(macro) MVAL1(macro)
-#define MVAL1(expression) #expression
-static const char *macro_values[] =
-  {
-#ifdef INT8_MAX
-    MVAL (INT8_MAX),
-#endif
-#ifdef INT16_MAX
-    MVAL (INT16_MAX),
-#endif
-#ifdef INT32_MAX
-    MVAL (INT32_MAX),
-#endif
-#ifdef INT64_MAX
-    MVAL (INT64_MAX),
-#endif
-#ifdef UINT8_MAX
-    MVAL (UINT8_MAX),
-#endif
-#ifdef UINT16_MAX
-    MVAL (UINT16_MAX),
-#endif
-#ifdef UINT32_MAX
-    MVAL (UINT32_MAX),
-#endif
-#ifdef UINT64_MAX
-    MVAL (UINT64_MAX),
-#endif
-    NULL
-  };
-
-int
-main ()
-{
-
-  const char **mv;
-  for (mv = macro_values; *mv != NULL; mv++)
-    {
-      const char *value = *mv;
-      /* Test whether it looks like a cast expression.  */
-      if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
-          || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
-          || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
-          || strncmp (value, "((int)"/*)*/, 6) == 0
-          || strncmp (value, "((signed short)"/*)*/, 15) == 0
-          || strncmp (value, "((signed char)"/*)*/, 14) == 0)
-        return mv - macro_values + 1;
-    }
-  return 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_header_working_stdint_h=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdint_h" >&5
-$as_echo "$gl_cv_header_working_stdint_h" >&6; }
-  fi
-  if test "$gl_cv_header_working_stdint_h" = yes; then
-    STDINT_H=
-  else
-            for ac_header in sys/inttypes.h sys/bitypes.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-eval as_val=\$$as_ac_Header
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-    if test $ac_cv_header_sys_inttypes_h = yes; then
-      HAVE_SYS_INTTYPES_H=1
-    else
-      HAVE_SYS_INTTYPES_H=0
-    fi
-
-    if test $ac_cv_header_sys_bitypes_h = yes; then
-      HAVE_SYS_BITYPES_H=1
-    else
-      HAVE_SYS_BITYPES_H=0
-    fi
-
-
-
-
-  if test $APPLE_UNIVERSAL_BUILD = 0; then
-
-
-  for gltype in ptrdiff_t size_t ; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5
-$as_echo_n "checking for bit size of $gltype... " >&6; }
-if { as_var=gl_cv_bitsizeof_${gltype}; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result"        "
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-#include <limits.h>"; then :
-
-else
-  result=unknown
-fi
-
-       eval gl_cv_bitsizeof_${gltype}=\$result
-
-fi
-eval ac_res=\$gl_cv_bitsizeof_${gltype}
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-    eval result=\$gl_cv_bitsizeof_${gltype}
-    if test $result = unknown; then
-                                                result=0
-    fi
-    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
-    cat >>confdefs.h <<_ACEOF
-#define BITSIZEOF_${GLTYPE} $result
-_ACEOF
-
-    eval BITSIZEOF_${GLTYPE}=\$result
-  done
-
-
-  fi
-
-
-  for gltype in sig_atomic_t wchar_t wint_t ; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bit size of $gltype" >&5
-$as_echo_n "checking for bit size of $gltype... " >&6; }
-if { as_var=gl_cv_bitsizeof_${gltype}; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  if ac_fn_c_compute_int "$LINENO" "sizeof ($gltype) * CHAR_BIT" "result"        "
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-#include <limits.h>"; then :
-
-else
-  result=unknown
-fi
-
-       eval gl_cv_bitsizeof_${gltype}=\$result
-
-fi
-eval ac_res=\$gl_cv_bitsizeof_${gltype}
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-    eval result=\$gl_cv_bitsizeof_${gltype}
-    if test $result = unknown; then
-                                                result=0
-    fi
-    GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
-    cat >>confdefs.h <<_ACEOF
-#define BITSIZEOF_${GLTYPE} $result
-_ACEOF
-
-    eval BITSIZEOF_${GLTYPE}=\$result
-  done
-
-
-
-
-  for gltype in sig_atomic_t wchar_t wint_t ; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gltype is signed" >&5
-$as_echo_n "checking whether $gltype is signed... " >&6; }
-if { as_var=gl_cv_type_${gltype}_signed; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-            int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  result=yes
-else
-  result=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-       eval gl_cv_type_${gltype}_signed=\$result
-
-fi
-eval ac_res=\$gl_cv_type_${gltype}_signed
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-    eval result=\$gl_cv_type_${gltype}_signed
-    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
-    if test "$result" = yes; then
-      cat >>confdefs.h <<_ACEOF
-#define HAVE_SIGNED_${GLTYPE} 1
-_ACEOF
-
-      eval HAVE_SIGNED_${GLTYPE}=1
-    else
-      eval HAVE_SIGNED_${GLTYPE}=0
-    fi
-  done
-
-
-  gl_cv_type_ptrdiff_t_signed=yes
-  gl_cv_type_size_t_signed=no
-  if test $APPLE_UNIVERSAL_BUILD = 0; then
-
-
-  for gltype in ptrdiff_t size_t ; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5
-$as_echo_n "checking for $gltype integer literal suffix... " >&6; }
-if { as_var=gl_cv_type_${gltype}_suffix; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval gl_cv_type_${gltype}_suffix=no
-       eval result=\$gl_cv_type_${gltype}_signed
-       if test "$result" = yes; then
-         glsufu=
-       else
-         glsufu=u
-       fi
-       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
-         case $glsuf in
-           '')  gltype1='int';;
-           l)   gltype1='long int';;
-           ll)  gltype1='long long int';;
-           i64) gltype1='__int64';;
-           u)   gltype1='unsigned int';;
-           ul)  gltype1='unsigned long int';;
-           ull) gltype1='unsigned long long int';;
-           ui64)gltype1='unsigned __int64';;
-         esac
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-              extern $gltype foo;
-              extern $gltype1 foo;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval gl_cv_type_${gltype}_suffix=\$glsuf
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-         eval result=\$gl_cv_type_${gltype}_suffix
-         test "$result" != no && break
-       done
-fi
-eval ac_res=\$gl_cv_type_${gltype}_suffix
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
-    eval result=\$gl_cv_type_${gltype}_suffix
-    test "$result" = no && result=
-    eval ${GLTYPE}_SUFFIX=\$result
-    cat >>confdefs.h <<_ACEOF
-#define ${GLTYPE}_SUFFIX $result
-_ACEOF
-
-  done
-
-
-  fi
-
-
-  for gltype in sig_atomic_t wchar_t wint_t ; do
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $gltype integer literal suffix" >&5
-$as_echo_n "checking for $gltype integer literal suffix... " >&6; }
-if { as_var=gl_cv_type_${gltype}_suffix; eval "test \"\${$as_var+set}\" = set"; }; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval gl_cv_type_${gltype}_suffix=no
-       eval result=\$gl_cv_type_${gltype}_signed
-       if test "$result" = yes; then
-         glsufu=
-       else
-         glsufu=u
-       fi
-       for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
-         case $glsuf in
-           '')  gltype1='int';;
-           l)   gltype1='long int';;
-           ll)  gltype1='long long int';;
-           i64) gltype1='__int64';;
-           u)   gltype1='unsigned int';;
-           ul)  gltype1='unsigned long int';;
-           ull) gltype1='unsigned long long int';;
-           ui64)gltype1='unsigned __int64';;
-         esac
-         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-  /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
-     included before <wchar.h>.  */
-  #include <stddef.h>
-  #include <signal.h>
-  #if HAVE_WCHAR_H
-  # include <stdio.h>
-  # include <time.h>
-  # include <wchar.h>
-  #endif
-
-              extern $gltype foo;
-              extern $gltype1 foo;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval gl_cv_type_${gltype}_suffix=\$glsuf
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-         eval result=\$gl_cv_type_${gltype}_suffix
-         test "$result" != no && break
-       done
-fi
-eval ac_res=\$gl_cv_type_${gltype}_suffix
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-    GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
-    eval result=\$gl_cv_type_${gltype}_suffix
-    test "$result" = no && result=
-    eval ${GLTYPE}_SUFFIX=\$result
-    cat >>confdefs.h <<_ACEOF
-#define ${GLTYPE}_SUFFIX $result
-_ACEOF
-
-  done
-
-
-
-          if test $BITSIZEOF_WINT_T -lt 32; then
-    BITSIZEOF_WINT_T=32
-  fi
-
-    STDINT_H=stdint.h
-  fi
-
-   if test -n "$STDINT_H"; then
-  GL_GENERATE_STDINT_H_TRUE=
-  GL_GENERATE_STDINT_H_FALSE='#'
-else
-  GL_GENERATE_STDINT_H_TRUE='#'
-  GL_GENERATE_STDINT_H_FALSE=
-fi
-
-
-
-
-
-  GNULIB_IMAXABS=0;
-  GNULIB_IMAXDIV=0;
-  GNULIB_STRTOIMAX=0;
-  GNULIB_STRTOUMAX=0;
-    HAVE_DECL_IMAXABS=1;
-  HAVE_DECL_IMAXDIV=1;
-  HAVE_DECL_STRTOIMAX=1;
-  HAVE_DECL_STRTOUMAX=1;
-  REPLACE_STRTOIMAX=0;
-  REPLACE_STRTOUMAX=0;
-  INT32_MAX_LT_INTMAX_MAX=1;
-  INT64_MAX_EQ_LONG_MAX='defined _LP64';
-  PRI_MACROS_BROKEN=0;
-  PRIPTR_PREFIX=__PRIPTR_PREFIX;
-  UINT32_MAX_LT_UINTMAX_MAX=1;
-  UINT64_MAX_EQ_ULONG_MAX='defined _LP64';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_inttypes_h='<'inttypes.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <inttypes.h>" >&5
-$as_echo_n "checking absolute name of <inttypes.h>... " >&6; }
-if test "${gl_cv_next_inttypes_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_inttypes_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <inttypes.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'inttypes.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_inttypes_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_inttypes_h='<'inttypes.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_inttypes_h" >&5
-$as_echo "$gl_cv_next_inttypes_h" >&6; }
-     fi
-     NEXT_INTTYPES_H=$gl_cv_next_inttypes_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'inttypes.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_inttypes_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
-
-
-  case "$host_os" in
-    mingw*)
-                        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit off_t" >&5
-$as_echo_n "checking for 64-bit off_t... " >&6; }
-if test "${gl_cv_type_off_t_64+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-                int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_type_off_t_64=yes
-else
-  gl_cv_type_off_t_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_type_off_t_64" >&5
-$as_echo "$gl_cv_type_off_t_64" >&6; }
-      if test $gl_cv_type_off_t_64 = no; then
-        WINDOWS_64_BIT_OFF_T=1
-      else
-        WINDOWS_64_BIT_OFF_T=0
-      fi
-                  WINDOWS_64_BIT_ST_SIZE=1
-      ;;
-    *)
-                                                      WINDOWS_64_BIT_OFF_T=0
-      WINDOWS_64_BIT_ST_SIZE=0
-      ;;
-  esac
-
-
-
-
-  GNULIB_FFSL=0;
-  GNULIB_FFSLL=0;
-  GNULIB_MEMCHR=0;
-  GNULIB_MEMMEM=0;
-  GNULIB_MEMPCPY=0;
-  GNULIB_MEMRCHR=0;
-  GNULIB_RAWMEMCHR=0;
-  GNULIB_STPCPY=0;
-  GNULIB_STPNCPY=0;
-  GNULIB_STRCHRNUL=0;
-  GNULIB_STRDUP=0;
-  GNULIB_STRNCAT=0;
-  GNULIB_STRNDUP=0;
-  GNULIB_STRNLEN=0;
-  GNULIB_STRPBRK=0;
-  GNULIB_STRSEP=0;
-  GNULIB_STRSTR=0;
-  GNULIB_STRCASESTR=0;
-  GNULIB_STRTOK_R=0;
-  GNULIB_MBSLEN=0;
-  GNULIB_MBSNLEN=0;
-  GNULIB_MBSCHR=0;
-  GNULIB_MBSRCHR=0;
-  GNULIB_MBSSTR=0;
-  GNULIB_MBSCASECMP=0;
-  GNULIB_MBSNCASECMP=0;
-  GNULIB_MBSPCASECMP=0;
-  GNULIB_MBSCASESTR=0;
-  GNULIB_MBSCSPN=0;
-  GNULIB_MBSPBRK=0;
-  GNULIB_MBSSPN=0;
-  GNULIB_MBSSEP=0;
-  GNULIB_MBSTOK_R=0;
-  GNULIB_STRERROR=0;
-  GNULIB_STRERROR_R=0;
-  GNULIB_STRSIGNAL=0;
-  GNULIB_STRVERSCMP=0;
-  HAVE_MBSLEN=0;
-    HAVE_FFSL=1;
-  HAVE_FFSLL=1;
-  HAVE_MEMCHR=1;
-  HAVE_DECL_MEMMEM=1;
-  HAVE_MEMPCPY=1;
-  HAVE_DECL_MEMRCHR=1;
-  HAVE_RAWMEMCHR=1;
-  HAVE_STPCPY=1;
-  HAVE_STPNCPY=1;
-  HAVE_STRCHRNUL=1;
-  HAVE_DECL_STRDUP=1;
-  HAVE_DECL_STRNDUP=1;
-  HAVE_DECL_STRNLEN=1;
-  HAVE_STRPBRK=1;
-  HAVE_STRSEP=1;
-  HAVE_STRCASESTR=1;
-  HAVE_DECL_STRTOK_R=1;
-  HAVE_DECL_STRERROR_R=1;
-  HAVE_DECL_STRSIGNAL=1;
-  HAVE_STRVERSCMP=1;
-  REPLACE_MEMCHR=0;
-  REPLACE_MEMMEM=0;
-  REPLACE_STPNCPY=0;
-  REPLACE_STRDUP=0;
-  REPLACE_STRSTR=0;
-  REPLACE_STRCASESTR=0;
-  REPLACE_STRCHRNUL=0;
-  REPLACE_STRERROR=0;
-  REPLACE_STRERROR_R=0;
-  REPLACE_STRNCAT=0;
-  REPLACE_STRNDUP=0;
-  REPLACE_STRNLEN=0;
-  REPLACE_STRSIGNAL=0;
-  REPLACE_STRTOK_R=0;
-  UNDEFINE_STRTOK_R=0;
-
-ac_fn_c_check_decl "$LINENO" "memrchr" "ac_cv_have_decl_memrchr" "$ac_includes_default"
-if test "x$ac_cv_have_decl_memrchr" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_MEMRCHR $ac_have_decl
-_ACEOF
-
-
-
-
-  GNULIB_MKTIME=0;
-  GNULIB_NANOSLEEP=0;
-  GNULIB_STRPTIME=0;
-  GNULIB_TIMEGM=0;
-  GNULIB_TIME_R=0;
-    HAVE_DECL_LOCALTIME_R=1;
-  HAVE_NANOSLEEP=1;
-  HAVE_STRPTIME=1;
-  HAVE_TIMEGM=1;
-        REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;
-  REPLACE_MKTIME=GNULIB_PORTCHECK;
-  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;
-  REPLACE_TIMEGM=GNULIB_PORTCHECK;
-
-ac_fn_c_check_decl "$LINENO" "alarm" "ac_cv_have_decl_alarm" "$ac_includes_default"
-if test "x$ac_cv_have_decl_alarm" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ALARM $ac_have_decl
-_ACEOF
-
-
-
-
-  GNULIB_PSELECT=0;
-  GNULIB_SELECT=0;
-    HAVE_PSELECT=1;
-  REPLACE_PSELECT=0;
-  REPLACE_SELECT=0;
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <sys/select.h> is self-contained" >&5
-$as_echo_n "checking whether <sys/select.h> is self-contained... " >&6; }
-if test "${gl_cv_header_sys_select_h_selfcontained+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-                                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-struct timeval b;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_header_sys_select_h_selfcontained=yes
-else
-  gl_cv_header_sys_select_h_selfcontained=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-                        if test $gl_cv_header_sys_select_h_selfcontained = yes; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-int memset; int bzero;
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-
-                  #undef memset
-                  #define memset nonexistent_memset
-                  extern
-                  #ifdef __cplusplus
-                  "C"
-                  #endif
-                  void *memset (void *, int, unsigned long);
-                  #undef bzero
-                  #define bzero nonexistent_bzero
-                  extern
-                  #ifdef __cplusplus
-                  "C"
-                  #endif
-                  void bzero (void *, unsigned long);
-                  fd_set fds;
-                  FD_ZERO (&fds);
-
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  gl_cv_header_sys_select_h_selfcontained=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5
-$as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; }
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_sys_select_h='<'sys/select.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/select.h>" >&5
-$as_echo_n "checking absolute name of <sys/select.h>... " >&6; }
-if test "${gl_cv_next_sys_select_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_sys_select_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'sys/select.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_sys_select_h='<'sys/select.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5
-$as_echo "$gl_cv_next_sys_select_h" >&6; }
-     fi
-     NEXT_SYS_SELECT_H=$gl_cv_next_sys_select_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'sys/select.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_sys_select_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_sys_select_h = yes; then
-    HAVE_SYS_SELECT_H=1
-  else
-    HAVE_SYS_SELECT_H=0
-  fi
-
-
-
-
-
-  if test $ac_cv_header_sys_socket_h != yes; then
-                    for ac_header in winsock2.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default"
-if test "x$ac_cv_header_winsock2_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_WINSOCK2_H 1
-_ACEOF
-
-fi
-
-done
-
-  fi
-  if test "$ac_cv_header_winsock2_h" = yes; then
-    HAVE_WINSOCK2_H=1
-    UNISTD_H_HAVE_WINSOCK2_H=1
-    SYS_IOCTL_H_HAVE_WINSOCK2_H=1
-  else
-    HAVE_WINSOCK2_H=0
-  fi
-
-
-
-
-
-
-
-
-  GNULIB_PTHREAD_SIGMASK=0;
-  GNULIB_RAISE=0;
-  GNULIB_SIGNAL_H_SIGPIPE=0;
-  GNULIB_SIGPROCMASK=0;
-  GNULIB_SIGACTION=0;
-    HAVE_POSIX_SIGNALBLOCKING=1;
-  HAVE_PTHREAD_SIGMASK=1;
-  HAVE_RAISE=1;
-  HAVE_SIGSET_T=1;
-  HAVE_SIGINFO_T=1;
-  HAVE_SIGACTION=1;
-  HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
-
-  HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
-
-  HAVE_SIGHANDLER_T=1;
-  REPLACE_PTHREAD_SIGMASK=0;
-  REPLACE_RAISE=0;
-
-
-
-
-
-
-
-  ac_fn_c_check_type "$LINENO" "sigset_t" "ac_cv_type_sigset_t" "
-      #include <signal.h>
-      /* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
-      #include <sys/types.h>
-
-"
-if test "x$ac_cv_type_sigset_t" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_SIGSET_T 1
-_ACEOF
-
-gl_cv_type_sigset_t=yes
-else
-  gl_cv_type_sigset_t=no
-fi
-
-  if test $gl_cv_type_sigset_t != yes; then
-    HAVE_SIGSET_T=0
-  fi
-
-
-
-   if test $ac_cv_header_sys_socket_h = no; then
-                         for ac_header in ws2tcpip.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default"
-if test "x$ac_cv_header_ws2tcpip_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_WS2TCPIP_H 1
-_ACEOF
-
-fi
-
-done
-
-   fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
-$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
-if test "${ac_cv_header_stdbool_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-             #include <stdbool.h>
-             #ifndef bool
-              "error: bool is not defined"
-             #endif
-             #ifndef false
-              "error: false is not defined"
-             #endif
-             #if false
-              "error: false is not 0"
-             #endif
-             #ifndef true
-              "error: true is not defined"
-             #endif
-             #if true != 1
-              "error: true is not 1"
-             #endif
-             #ifndef __bool_true_false_are_defined
-              "error: __bool_true_false_are_defined is not defined"
-             #endif
-
-             struct s { _Bool s: 1; _Bool t; } s;
-
-             char a[true == 1 ? 1 : -1];
-             char b[false == 0 ? 1 : -1];
-             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-             char d[(bool) 0.5 == true ? 1 : -1];
-             /* See body of main program for 'e'.  */
-             char f[(_Bool) 0.0 == false ? 1 : -1];
-             char g[true];
-             char h[sizeof (_Bool)];
-             char i[sizeof s.t];
-             enum { j = false, k = true, l = false * true, m = true * 256 };
-             /* The following fails for
-                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
-             _Bool n[m];
-             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
-             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
-             /* Catch a bug in an HP-UX C compiler.  See
-                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
-                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
-              */
-             _Bool q = true;
-             _Bool *pq = &q;
-
-int
-main ()
-{
-
-             bool e = &s;
-             *pq |= q;
-             *pq |= ! q;
-             /* Refer to every declared value, to avoid compiler optimizations.  */
-             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
-                     + !m + !n + !o + !p + !q + !pq);
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdbool_h=yes
-else
-  ac_cv_header_stdbool_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
-$as_echo "$ac_cv_header_stdbool_h" >&6; }
-   ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
-if test "x$ac_cv_type__Bool" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE__BOOL 1
-_ACEOF
-
-
-fi
-
-
-
-    REPLACE_NULL=0;
-  HAVE_WCHAR_T=1;
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t" >&5
-$as_echo_n "checking for wchar_t... " >&6; }
-if test "${gt_cv_c_wchar_t+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stddef.h>
-            wchar_t foo = (wchar_t)'\0';
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gt_cv_c_wchar_t=yes
-else
-  gt_cv_c_wchar_t=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_c_wchar_t" >&5
-$as_echo "$gt_cv_c_wchar_t" >&6; }
-  if test $gt_cv_c_wchar_t = yes; then
-
-$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h
-
-  fi
-
-
-  GNULIB_DPRINTF=0;
-  GNULIB_FCLOSE=0;
-  GNULIB_FDOPEN=0;
-  GNULIB_FFLUSH=0;
-  GNULIB_FGETC=0;
-  GNULIB_FGETS=0;
-  GNULIB_FOPEN=0;
-  GNULIB_FPRINTF=0;
-  GNULIB_FPRINTF_POSIX=0;
-  GNULIB_FPURGE=0;
-  GNULIB_FPUTC=0;
-  GNULIB_FPUTS=0;
-  GNULIB_FREAD=0;
-  GNULIB_FREOPEN=0;
-  GNULIB_FSCANF=0;
-  GNULIB_FSEEK=0;
-  GNULIB_FSEEKO=0;
-  GNULIB_FTELL=0;
-  GNULIB_FTELLO=0;
-  GNULIB_FWRITE=0;
-  GNULIB_GETC=0;
-  GNULIB_GETCHAR=0;
-  GNULIB_GETDELIM=0;
-  GNULIB_GETLINE=0;
-  GNULIB_OBSTACK_PRINTF=0;
-  GNULIB_OBSTACK_PRINTF_POSIX=0;
-  GNULIB_PCLOSE=0;
-  GNULIB_PERROR=0;
-  GNULIB_POPEN=0;
-  GNULIB_PRINTF=0;
-  GNULIB_PRINTF_POSIX=0;
-  GNULIB_PUTC=0;
-  GNULIB_PUTCHAR=0;
-  GNULIB_PUTS=0;
-  GNULIB_REMOVE=0;
-  GNULIB_RENAME=0;
-  GNULIB_RENAMEAT=0;
-  GNULIB_SCANF=0;
-  GNULIB_SNPRINTF=0;
-  GNULIB_SPRINTF_POSIX=0;
-  GNULIB_STDIO_H_NONBLOCKING=0;
-  GNULIB_STDIO_H_SIGPIPE=0;
-  GNULIB_TMPFILE=0;
-  GNULIB_VASPRINTF=0;
-  GNULIB_VFSCANF=0;
-  GNULIB_VSCANF=0;
-  GNULIB_VDPRINTF=0;
-  GNULIB_VFPRINTF=0;
-  GNULIB_VFPRINTF_POSIX=0;
-  GNULIB_VPRINTF=0;
-  GNULIB_VPRINTF_POSIX=0;
-  GNULIB_VSNPRINTF=0;
-  GNULIB_VSPRINTF_POSIX=0;
-    HAVE_DECL_FPURGE=1;
-  HAVE_DECL_FSEEKO=1;
-  HAVE_DECL_FTELLO=1;
-  HAVE_DECL_GETDELIM=1;
-  HAVE_DECL_GETLINE=1;
-  HAVE_DECL_OBSTACK_PRINTF=1;
-  HAVE_DECL_SNPRINTF=1;
-  HAVE_DECL_VSNPRINTF=1;
-  HAVE_DPRINTF=1;
-  HAVE_FSEEKO=1;
-  HAVE_FTELLO=1;
-  HAVE_PCLOSE=1;
-  HAVE_POPEN=1;
-  HAVE_RENAMEAT=1;
-  HAVE_VASPRINTF=1;
-  HAVE_VDPRINTF=1;
-  REPLACE_DPRINTF=0;
-  REPLACE_FCLOSE=0;
-  REPLACE_FDOPEN=0;
-  REPLACE_FFLUSH=0;
-  REPLACE_FOPEN=0;
-  REPLACE_FPRINTF=0;
-  REPLACE_FPURGE=0;
-  REPLACE_FREOPEN=0;
-  REPLACE_FSEEK=0;
-  REPLACE_FSEEKO=0;
-  REPLACE_FTELL=0;
-  REPLACE_FTELLO=0;
-  REPLACE_GETDELIM=0;
-  REPLACE_GETLINE=0;
-  REPLACE_OBSTACK_PRINTF=0;
-  REPLACE_PERROR=0;
-  REPLACE_POPEN=0;
-  REPLACE_PRINTF=0;
-  REPLACE_REMOVE=0;
-  REPLACE_RENAME=0;
-  REPLACE_RENAMEAT=0;
-  REPLACE_SNPRINTF=0;
-  REPLACE_SPRINTF=0;
-  REPLACE_STDIO_READ_FUNCS=0;
-  REPLACE_STDIO_WRITE_FUNCS=0;
-  REPLACE_TMPFILE=0;
-  REPLACE_VASPRINTF=0;
-  REPLACE_VDPRINTF=0;
-  REPLACE_VFPRINTF=0;
-  REPLACE_VPRINTF=0;
-  REPLACE_VSNPRINTF=0;
-  REPLACE_VSPRINTF=0;
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
-$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
-if test "${ac_cv_struct_tm+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <time.h>
-
-int
-main ()
-{
-struct tm tm;
-                                    int *p = &tm.tm_sec;
-                                    return !p;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_struct_tm=time.h
-else
-  ac_cv_struct_tm=sys/time.h
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
-$as_echo "$ac_cv_struct_tm" >&6; }
-if test $ac_cv_struct_tm = sys/time.h; then
-
-$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
-
-fi
-
-ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include <sys/types.h>
-#include <$ac_cv_struct_tm>
-
-"
-if test "x$ac_cv_member_struct_tm_tm_zone" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_TM_TM_ZONE 1
-_ACEOF
-
-
-fi
-
-if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
-
-$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h
-
-else
-  ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include <time.h>
-"
-if test "x$ac_cv_have_decl_tzname" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_TZNAME $ac_have_decl
-_ACEOF
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5
-$as_echo_n "checking for tzname... " >&6; }
-if test "${ac_cv_var_tzname+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-#if !HAVE_DECL_TZNAME
-extern char *tzname[];
-#endif
-
-int
-main ()
-{
-return tzname[0][0];
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_var_tzname=yes
-else
-  ac_cv_var_tzname=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5
-$as_echo "$ac_cv_var_tzname" >&6; }
-  if test $ac_cv_var_tzname = yes; then
-
-$as_echo "#define HAVE_TZNAME 1" >>confdefs.h
-
-  fi
-fi
-
-
- ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" "#include <time.h>
-"
-if test "x$ac_cv_member_struct_tm_tm_gmtoff" = x""yes; then :
-
-$as_echo "#define HAVE_TM_GMTOFF 1" >>confdefs.h
-
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_string_h='<'string.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <string.h>" >&5
-$as_echo_n "checking absolute name of <string.h>... " >&6; }
-if test "${gl_cv_next_string_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'string.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_string_h" >&5
-$as_echo "$gl_cv_next_string_h" >&6; }
-     fi
-     NEXT_STRING_H=$gl_cv_next_string_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'string.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_string_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STRING_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
-ac_fn_c_check_decl "$LINENO" "strtoimax" "ac_cv_have_decl_strtoimax" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strtoimax" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRTOIMAX $ac_have_decl
-_ACEOF
-
-
-
-ac_fn_c_check_decl "$LINENO" "strtoumax" "ac_cv_have_decl_strtoumax" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strtoumax" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRTOUMAX $ac_have_decl
-_ACEOF
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5
-$as_echo_n "checking whether stat file-mode macros are broken... " >&6; }
-if test "${ac_cv_header_stat_broken+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if defined S_ISBLK && defined S_IFDIR
-extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
-#endif
-
-#if defined S_ISBLK && defined S_IFCHR
-extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
-#endif
-
-#if defined S_ISLNK && defined S_IFREG
-extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
-#endif
-
-#if defined S_ISSOCK && defined S_IFREG
-extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
-#endif
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stat_broken=no
-else
-  ac_cv_header_stat_broken=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5
-$as_echo "$ac_cv_header_stat_broken" >&6; }
-if test $ac_cv_header_stat_broken = yes; then
-
-$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h
-
-fi
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <time.h>" >&5
-$as_echo_n "checking for struct timespec in <time.h>... " >&6; }
-if test "${gl_cv_sys_struct_timespec_in_time_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-
-int
-main ()
-{
-static struct timespec x; x.tv_sec = x.tv_nsec;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_timespec_in_time_h=yes
-else
-  gl_cv_sys_struct_timespec_in_time_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_time_h" >&5
-$as_echo "$gl_cv_sys_struct_timespec_in_time_h" >&6; }
-
-  TIME_H_DEFINES_STRUCT_TIMESPEC=0
-  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
-  PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
-  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
-    TIME_H_DEFINES_STRUCT_TIMESPEC=1
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <sys/time.h>" >&5
-$as_echo_n "checking for struct timespec in <sys/time.h>... " >&6; }
-if test "${gl_cv_sys_struct_timespec_in_sys_time_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/time.h>
-
-int
-main ()
-{
-static struct timespec x; x.tv_sec = x.tv_nsec;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_timespec_in_sys_time_h=yes
-else
-  gl_cv_sys_struct_timespec_in_sys_time_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_sys_time_h" >&5
-$as_echo "$gl_cv_sys_struct_timespec_in_sys_time_h" >&6; }
-    if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
-      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in <pthread.h>" >&5
-$as_echo_n "checking for struct timespec in <pthread.h>... " >&6; }
-if test "${gl_cv_sys_struct_timespec_in_pthread_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <pthread.h>
-
-int
-main ()
-{
-static struct timespec x; x.tv_sec = x.tv_nsec;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_timespec_in_pthread_h=yes
-else
-  gl_cv_sys_struct_timespec_in_pthread_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_pthread_h" >&5
-$as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; }
-      if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
-        PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
-      fi
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_time_h='<'time.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <time.h>" >&5
-$as_echo_n "checking absolute name of <time.h>... " >&6; }
-if test "${gl_cv_next_time_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'time.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5
-$as_echo "$gl_cv_next_time_h" >&6; }
-     fi
-     NEXT_TIME_H=$gl_cv_next_time_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'time.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_time_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_TIME_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" "$ac_includes_default"
-if test "x$ac_cv_have_decl_unsetenv" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_UNSETENV $ac_have_decl
-_ACEOF
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the utimes function works" >&5
-$as_echo_n "checking whether the utimes function works... " >&6; }
-if test "${gl_cv_func_working_utimes+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-  if test "$cross_compiling" = yes; then :
-  gl_cv_func_working_utimes=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <time.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <utime.h>
-
-static int
-inorder (time_t a, time_t b, time_t c)
-{
-  return a <= b && b <= c;
-}
-
-int
-main ()
-{
-  int result = 0;
-  char const *file = "conftest.utimes";
-  static struct timeval timeval[2] = {{9, 10}, {999999, 999999}};
-
-  /* Test whether utimes() essentially works.  */
-  {
-    struct stat sbuf;
-    FILE *f = fopen (file, "w");
-    if (f == NULL)
-      result |= 1;
-    else if (fclose (f) != 0)
-      result |= 1;
-    else if (utimes (file, timeval) != 0)
-      result |= 2;
-    else if (lstat (file, &sbuf) != 0)
-      result |= 1;
-    else if (!(sbuf.st_atime == timeval[0].tv_sec
-               && sbuf.st_mtime == timeval[1].tv_sec))
-      result |= 4;
-    if (unlink (file) != 0)
-      result |= 1;
-  }
-
-  /* Test whether utimes() with a NULL argument sets the file's timestamp
-     to the current time.  Use 'fstat' as well as 'time' to
-     determine the "current" time, to accommodate NFS file systems
-     if there is a time skew between the host and the NFS server.  */
-  {
-    int fd = open (file, O_WRONLY|O_CREAT, 0644);
-    if (fd < 0)
-      result |= 1;
-    else
-      {
-        time_t t0, t2;
-        struct stat st0, st1, st2;
-        if (time (&t0) == (time_t) -1)
-          result |= 1;
-        else if (fstat (fd, &st0) != 0)
-          result |= 1;
-        else if (utimes (file, timeval) != 0)
-          result |= 2;
-        else if (utimes (file, NULL) != 0)
-          result |= 8;
-        else if (fstat (fd, &st1) != 0)
-          result |= 1;
-        else if (write (fd, "\n", 1) != 1)
-          result |= 1;
-        else if (fstat (fd, &st2) != 0)
-          result |= 1;
-        else if (time (&t2) == (time_t) -1)
-          result |= 1;
-        else
-          {
-            int m_ok_POSIX = inorder (t0, st1.st_mtime, t2);
-            int m_ok_NFS = inorder (st0.st_mtime, st1.st_mtime, st2.st_mtime);
-            if (! (st1.st_atime == st1.st_mtime))
-              result |= 16;
-            if (! (m_ok_POSIX || m_ok_NFS))
-              result |= 32;
-          }
-        if (close (fd) != 0)
-          result |= 1;
-      }
-    if (unlink (file) != 0)
-      result |= 1;
-  }
-
-  /* Test whether utimes() with a NULL argument works on read-only files.  */
-  {
-    int fd = open (file, O_WRONLY|O_CREAT, 0444);
-    if (fd < 0)
-      result |= 1;
-    else if (close (fd) != 0)
-      result |= 1;
-    else if (utimes (file, NULL) != 0)
-      result |= 64;
-    if (unlink (file) != 0)
-      result |= 1;
-  }
-
-  return result;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_working_utimes=yes
-else
-  gl_cv_func_working_utimes=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_utimes" >&5
-$as_echo "$gl_cv_func_working_utimes" >&6; }
-
-  if test $gl_cv_func_working_utimes = yes; then
-
-$as_echo "#define HAVE_WORKING_UTIMES 1" >>confdefs.h
-
-  fi
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct utimbuf" >&5
-$as_echo_n "checking for struct utimbuf... " >&6; }
-if test "${gl_cv_sys_struct_utimbuf+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if HAVE_SYS_TIME_H
-             #include <sys/time.h>
-            #endif
-            #include <time.h>
-            #ifdef HAVE_UTIME_H
-             #include <utime.h>
-            #endif
-
-int
-main ()
-{
-static struct utimbuf x; x.actime = x.modtime;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_sys_struct_utimbuf=yes
-else
-  gl_cv_sys_struct_utimbuf=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_utimbuf" >&5
-$as_echo "$gl_cv_sys_struct_utimbuf" >&6; }
-
-  if test $gl_cv_sys_struct_utimbuf = yes; then
-
-$as_echo "#define HAVE_STRUCT_UTIMBUF 1" >>confdefs.h
-
-  fi
-
-
-
-
-
-
-
-
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5
-$as_echo_n "checking type of array argument to getgroups... " >&6; }
-if test "${ac_cv_type_getgroups+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  ac_cv_type_getgroups=cross
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Thanks to Mike Rendell for this test.  */
-$ac_includes_default
-#define NGID 256
-#undef MAX
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-
-int
-main ()
-{
-  gid_t gidset[NGID];
-  int i, n;
-  union { gid_t gval; long int lval; }  val;
-
-  val.lval = -1;
-  for (i = 0; i < NGID; i++)
-    gidset[i] = val.gval;
-  n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
-                gidset);
-  /* Exit non-zero if getgroups seems to require an array of ints.  This
-     happens when gid_t is short int but getgroups modifies an array
-     of ints.  */
-  return n > 0 && gidset[n] != val.gval;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_type_getgroups=gid_t
-else
-  ac_cv_type_getgroups=int
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-if test $ac_cv_type_getgroups = cross; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <unistd.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then :
-  ac_cv_type_getgroups=gid_t
-else
-  ac_cv_type_getgroups=int
-fi
-rm -f conftest*
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5
-$as_echo "$ac_cv_type_getgroups" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define GETGROUPS_T $ac_cv_type_getgroups
-_ACEOF
-
-
-
-
-
-
-
-
-   if false; then
-  GL_COND_LIBTOOL_TRUE=
-  GL_COND_LIBTOOL_FALSE='#'
-else
-  GL_COND_LIBTOOL_TRUE='#'
-  GL_COND_LIBTOOL_FALSE=
-fi
-
-  gl_cond_libtool=false
-  gl_libdeps=
-  gl_ltlibdeps=
-  gl_m4_base='m4'
-
-
-
-
-
-
-
-
-
-  gl_source_base='lib'
-
-
-  if test $ac_cv_func_alloca_works = no; then
-    :
-  fi
-
-  # Define an additional variable used in the Makefile substitution.
-  if test $ac_cv_working_alloca_h = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca as a compiler built-in" >&5
-$as_echo_n "checking for alloca as a compiler built-in... " >&6; }
-if test "${gl_cv_rpl_alloca+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#if defined __GNUC__ || defined _AIX || defined _MSC_VER
-        Need own alloca
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "Need own alloca" >/dev/null 2>&1; then :
-  gl_cv_rpl_alloca=yes
-else
-  gl_cv_rpl_alloca=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_rpl_alloca" >&5
-$as_echo "$gl_cv_rpl_alloca" >&6; }
-    if test $gl_cv_rpl_alloca = yes; then
-
-$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
-
-      ALLOCA_H=alloca.h
-    else
-                  ALLOCA_H=
-    fi
-  else
-    ALLOCA_H=alloca.h
-  fi
-
-   if test -n "$ALLOCA_H"; then
-  GL_GENERATE_ALLOCA_H_TRUE=
-  GL_GENERATE_ALLOCA_H_FALSE='#'
-else
-  GL_GENERATE_ALLOCA_H_TRUE='#'
-  GL_GENERATE_ALLOCA_H_FALSE=
-fi
-
-
-
-    for ac_header in byteswap.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default"
-if test "x$ac_cv_header_byteswap_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_BYTESWAP_H 1
-_ACEOF
-
-    BYTESWAP_H=''
-
-else
-
-    BYTESWAP_H='byteswap.h'
-
-fi
-
-done
-
-
-   if test -n "$BYTESWAP_H"; then
-  GL_GENERATE_BYTESWAP_H_TRUE=
-  GL_GENERATE_BYTESWAP_H_FALSE='#'
-else
-  GL_GENERATE_BYTESWAP_H_TRUE='#'
-  GL_GENERATE_BYTESWAP_H_FALSE=
-fi
-
-
-
-
-
-
-  # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
-  # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
-
-  # Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
-  # programs in the package would end up linked with that potentially-shared
-  # library, inducing unnecessary run-time overhead.
-  LIB_CLOCK_GETTIME=
-
-  gl_saved_libs=$LIBS
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
-$as_echo_n "checking for library containing clock_gettime... " >&6; }
-if test "${ac_cv_search_clock_gettime+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char clock_gettime ();
-int
-main ()
-{
-return clock_gettime ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' rt posix4; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_clock_gettime=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_clock_gettime+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_clock_gettime+set}" = set; then :
-
-else
-  ac_cv_search_clock_gettime=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
-$as_echo "$ac_cv_search_clock_gettime" >&6; }
-ac_res=$ac_cv_search_clock_gettime
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  test "$ac_cv_search_clock_gettime" = "none required" ||
-                    LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime
-fi
-
-    for ac_func in clock_gettime clock_settime
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-  LIBS=$gl_saved_libs
-
-
-  :
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_CLOSE_STREAM 1
-_ACEOF
-
-
-
-
-
-
-
-
-
-
-  :
-
-
-
-  :
-
-
-
-  :
-
-
-
-  :
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_dirent_h='<'dirent.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <dirent.h>" >&5
-$as_echo_n "checking absolute name of <dirent.h>... " >&6; }
-if test "${gl_cv_next_dirent_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_dirent_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <dirent.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'dirent.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_dirent_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_dirent_h='<'dirent.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_dirent_h" >&5
-$as_echo "$gl_cv_next_dirent_h" >&6; }
-     fi
-     NEXT_DIRENT_H=$gl_cv_next_dirent_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'dirent.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_dirent_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_DIRENT_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_dirent_h = yes; then
-    HAVE_DIRENT_H=1
-  else
-    HAVE_DIRENT_H=0
-  fi
-
-
-
-
-
-
-
-
-
-
-$as_echo "#define HAVE_DUP2 1" >>confdefs.h
-
-
-  if test $HAVE_DUP2 = 1; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dup2 works" >&5
-$as_echo_n "checking whether dup2 works... " >&6; }
-if test "${gl_cv_func_dup2_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-           mingw*) # on this platform, dup2 always returns 0 for success
-             gl_cv_func_dup2_works="guessing no" ;;
-           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
-             gl_cv_func_dup2_works="guessing no" ;;
-           linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
-                   # closed fd may yield -EBADF instead of -1 / errno=EBADF.
-             gl_cv_func_dup2_works="guessing no" ;;
-           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
-             gl_cv_func_dup2_works="guessing no" ;;
-           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
-             gl_cv_func_dup2_works="guessing no" ;;
-           *) gl_cv_func_dup2_works="guessing yes" ;;
-         esac
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-         #include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-int
-main ()
-{
-int result = 0;
-#ifdef FD_CLOEXEC
-            if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
-              result |= 1;
-#endif
-            if (dup2 (1, 1) == 0)
-              result |= 2;
-#ifdef FD_CLOEXEC
-            if (fcntl (1, F_GETFD) != FD_CLOEXEC)
-              result |= 4;
-#endif
-            close (0);
-            if (dup2 (0, 0) != -1)
-              result |= 8;
-            /* Many gnulib modules require POSIX conformance of EBADF.  */
-            if (dup2 (2, 1000000) == -1 && errno != EBADF)
-              result |= 16;
-            /* Flush out some cygwin core dumps.  */
-            if (dup2 (2, -1) != -1 || errno != EBADF)
-              result |= 32;
-            dup2 (2, 255);
-            dup2 (2, 256);
-            return result;
-
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_dup2_works=yes
-else
-  gl_cv_func_dup2_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dup2_works" >&5
-$as_echo "$gl_cv_func_dup2_works" >&6; }
-    case "$gl_cv_func_dup2_works" in
-      *yes) ;;
-      *)
-        REPLACE_DUP2=1
-        for ac_func in setdtablesize
-do :
-  ac_fn_c_check_func "$LINENO" "setdtablesize" "ac_cv_func_setdtablesize"
-if test "x$ac_cv_func_setdtablesize" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SETDTABLESIZE 1
-_ACEOF
-
-fi
-done
-
-        ;;
-    esac
-  fi
-
-
-  if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS dup2.$ac_objext"
-
-
-  fi
-
-
-
-
-
-          GNULIB_DUP2=1
-
-
-
-
-
-
-
-
-
-
-
-          GNULIB_ENVIRON=1
-
-
-
-
-
-
-
-
-
-  LIB_EXECINFO=''
-  EXECINFO_H='execinfo.h'
-
-  if test $ac_cv_header_execinfo_h = yes; then
-    gl_saved_libs=$LIBS
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing backtrace_symbols_fd" >&5
-$as_echo_n "checking for library containing backtrace_symbols_fd... " >&6; }
-if test "${ac_cv_search_backtrace_symbols_fd+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char backtrace_symbols_fd ();
-int
-main ()
-{
-return backtrace_symbols_fd ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' execinfo; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_backtrace_symbols_fd=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_backtrace_symbols_fd+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_backtrace_symbols_fd+set}" = set; then :
-
-else
-  ac_cv_search_backtrace_symbols_fd=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_backtrace_symbols_fd" >&5
-$as_echo "$ac_cv_search_backtrace_symbols_fd" >&6; }
-ac_res=$ac_cv_search_backtrace_symbols_fd
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  test "$ac_cv_search_backtrace_symbols_fd" = "none required" ||
-         LIB_EXECINFO=$ac_cv_search_backtrace_symbols_fd
-fi
-
-    LIBS=$gl_saved_libs
-    test "$ac_cv_search_backtrace_symbols_fd" = no || EXECINFO_H=''
-  fi
-
-  if test -n "$EXECINFO_H"; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS execinfo.$ac_objext"
-
-  fi
-
-
-
-   if test -n "$EXECINFO_H"; then
-  GL_GENERATE_EXECINFO_H_TRUE=
-  GL_GENERATE_EXECINFO_H_FALSE='#'
-else
-  GL_GENERATE_EXECINFO_H_TRUE='#'
-  GL_GENERATE_EXECINFO_H_FALSE=
-fi
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_faccessat = no; then
-    HAVE_FACCESSAT=0
-  fi
-
-  if test $HAVE_FACCESSAT = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS faccessat.$ac_objext"
-
-
-  for ac_func in access
-do :
-  ac_fn_c_check_func "$LINENO" "access" "ac_cv_func_access"
-if test "x$ac_cv_func_access" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACCESS 1
-_ACEOF
-
-fi
-done
-
-
-  fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_FACCESSAT 1
-_ACEOF
-
-
-
-
-
-
-
-          GNULIB_FACCESSAT=1
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_fcntl = no; then
-
-
-
-  if test $ac_cv_func_fcntl = no; then
-    HAVE_FCNTL=0
-  else
-    REPLACE_FCNTL=1
-  fi
-
-  else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5
-$as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; }
-if test "${gl_cv_func_fcntl_f_dupfd_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  # Guess that it works on glibc systems
-          case $host_os in #((
-            *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
-            *)      gl_cv_func_fcntl_f_dupfd_works="guessing no";;
-          esac
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <fcntl.h>
-#include <errno.h>
-
-int
-main ()
-{
-int result = 0;
-      if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
-      if (errno != EINVAL) result |= 2;
-      return result;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_fcntl_f_dupfd_works=yes
-else
-  gl_cv_func_fcntl_f_dupfd_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5
-$as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; }
-    case $gl_cv_func_fcntl_f_dupfd_works in
-      *yes) ;;
-      *)
-
-
-  if test $ac_cv_func_fcntl = no; then
-    HAVE_FCNTL=0
-  else
-    REPLACE_FCNTL=1
-  fi
-
-
-$as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h
- ;;
-    esac
-
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5
-$as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; }
-if test "${gl_cv_func_fcntl_f_dupfd_cloexec+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <fcntl.h>
-#ifndef F_DUPFD_CLOEXEC
-choke me
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#ifdef __linux__
-/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
-   it to support the semantics on older kernels that failed with EINVAL.  */
-choke me
-#endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_func_fcntl_f_dupfd_cloexec=yes
-else
-  gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-  gl_cv_func_fcntl_f_dupfd_cloexec=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5
-$as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; }
-    if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
-
-
-
-  if test $ac_cv_func_fcntl = no; then
-    HAVE_FCNTL=0
-  else
-    REPLACE_FCNTL=1
-  fi
-
-          fi
-  fi
-
-
-  if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_FCNTL=1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_fcntl_h='<'fcntl.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <fcntl.h>" >&5
-$as_echo_n "checking absolute name of <fcntl.h>... " >&6; }
-if test "${gl_cv_next_fcntl_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <fcntl.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'fcntl.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_fcntl_h" >&5
-$as_echo "$gl_cv_next_fcntl_h" >&6; }
-     fi
-     NEXT_FCNTL_H=$gl_cv_next_fcntl_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'fcntl.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_fcntl_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_FCNTL_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-  LIB_FDATASYNC=
-
-
-  if test $ac_cv_have_decl_fdatasync = no; then
-    HAVE_DECL_FDATASYNC=0
-        for ac_func in fdatasync
-do :
-  ac_fn_c_check_func "$LINENO" "fdatasync" "ac_cv_func_fdatasync"
-if test "x$ac_cv_func_fdatasync" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_FDATASYNC 1
-_ACEOF
-
-fi
-done
-
-    if test $ac_cv_func_fdatasync = no; then
-      HAVE_FDATASYNC=0
-    fi
-  else
-            gl_saved_libs=$LIBS
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fdatasync" >&5
-$as_echo_n "checking for library containing fdatasync... " >&6; }
-if test "${ac_cv_search_fdatasync+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char fdatasync ();
-int
-main ()
-{
-return fdatasync ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' rt posix4; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_fdatasync=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_fdatasync+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_fdatasync+set}" = set; then :
-
-else
-  ac_cv_search_fdatasync=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_fdatasync" >&5
-$as_echo "$ac_cv_search_fdatasync" >&6; }
-ac_res=$ac_cv_search_fdatasync
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  test "$ac_cv_search_fdatasync" = "none required" ||
-                    LIB_FDATASYNC=$ac_cv_search_fdatasync
-fi
-
-    LIBS=$gl_saved_libs
-  fi
-
-  if test $HAVE_FDATASYNC = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fdatasync.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_FDATASYNC=1
-
-
-
-
-
-
-
-
-
-
-    ac_fn_c_check_decl "$LINENO" "fdopendir" "ac_cv_have_decl_fdopendir" "
-#include <dirent.h>
-
-"
-if test "x$ac_cv_have_decl_fdopendir" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_FDOPENDIR $ac_have_decl
-_ACEOF
-if test $ac_have_decl = 1; then :
-
-else
-  HAVE_DECL_FDOPENDIR=0
-fi
-
-
-  if test $ac_cv_func_fdopendir = no; then
-    HAVE_FDOPENDIR=0
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fdopendir works" >&5
-$as_echo_n "checking whether fdopendir works... " >&6; }
-if test "${gl_cv_func_fdopendir_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_fdopendir_works="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <unistd.h>
-#if !HAVE_DECL_FDOPENDIR
-extern
-# ifdef __cplusplus
-"C"
-# endif
-DIR *fdopendir (int);
-#endif
-
-int
-main ()
-{
-int result = 0;
-     int fd = open ("conftest.c", O_RDONLY);
-     if (fd < 0) result |= 1;
-     if (fdopendir (fd)) result |= 2;
-     if (close (fd)) result |= 4;
-     return result;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_fdopendir_works=yes
-else
-  gl_cv_func_fdopendir_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fdopendir_works" >&5
-$as_echo "$gl_cv_func_fdopendir_works" >&6; }
-    case "$gl_cv_func_fdopendir_works" in
-      *yes) ;;
-      *)
-        REPLACE_FDOPENDIR=1
-        ;;
-    esac
-  fi
-
-  if test $HAVE_FDOPENDIR = 0 || test $REPLACE_FDOPENDIR = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_FDOPENDIR=1
-
-
-
-
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_FDOPENDIR 1
-_ACEOF
-
-
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __fpending" >&5
-$as_echo_n "checking for __fpending... " >&6; }
-if test "${gl_cv_func___fpending+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-             #if HAVE_STDIO_EXT_H
-             # include <stdio_ext.h>
-             #endif
-
-int
-main ()
-{
-return ! __fpending (stdin);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_func___fpending=yes
-else
-  gl_cv_func___fpending=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func___fpending" >&5
-$as_echo "$gl_cv_func___fpending" >&6; }
-
-  if test $gl_cv_func___fpending = no; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fpending.$ac_objext"
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to determine the number of pending output bytes on a stream" >&5
-$as_echo_n "checking how to determine the number of pending output bytes on a stream... " >&6; }
-if test "${ac_cv_sys_pending_output_n_bytes+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-      for ac_expr in                                                    \
-                                                                        \
-          '# glibc2'                                                    \
-          'fp->_IO_write_ptr - fp->_IO_write_base'                      \
-                                                                        \
-          '# traditional Unix'                                          \
-          'fp->_ptr - fp->_base'                                        \
-                                                                        \
-          '# BSD'                                                       \
-          'fp->_p - fp->_bf._base'                                      \
-                                                                        \
-          '# SCO, Unixware'                                             \
-          '(fp->__ptr ? fp->__ptr - fp->__base : 0)'                    \
-                                                                        \
-          '# QNX'                                                       \
-          '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
-                                                                        \
-          '# old glibc?'                                                \
-          'fp->__bufp - fp->__buffer'                                   \
-                                                                        \
-          '# old glibc iostream?'                                       \
-          'fp->_pptr - fp->_pbase'                                      \
-                                                                        \
-          '# emx+gcc'                                                   \
-          'fp->_ptr - fp->_buffer'                                      \
-                                                                        \
-          '# Minix'                                                     \
-          'fp->_ptr - fp->_buf'                                         \
-                                                                        \
-          '# Plan9'                                                     \
-          'fp->wp - fp->buf'                                            \
-                                                                        \
-          '# VMS'                                                       \
-          '(*fp)->_ptr - (*fp)->_base'                                  \
-                                                                        \
-          '# e.g., DGUX R4.11; the info is not available'               \
-          1                                                             \
-          ; do
-
-        # Skip each embedded comment.
-        case "$ac_expr" in '#'*) continue;; esac
-
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *fp = stdin; (void) ($ac_expr);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  fp_done=yes
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-        test "$fp_done" = yes && break
-      done
-
-      ac_cv_sys_pending_output_n_bytes=$ac_expr
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_pending_output_n_bytes" >&5
-$as_echo "$ac_cv_sys_pending_output_n_bytes" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define PENDING_OUTPUT_N_BYTES $ac_cv_sys_pending_output_n_bytes
-_ACEOF
-
-
-  fi
-
-
-
-
-
-
-  if test $ac_cv_func_fstatat = no; then
-    HAVE_FSTATAT=0
-  else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fstatat (..., 0) works" >&5
-$as_echo_n "checking whether fstatat (..., 0) works... " >&6; }
-if test "${gl_cv_func_fstatat_zero_flag+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-            aix*) gl_cv_func_fstatat_zero_flag="guessing no";;
-            *)    gl_cv_func_fstatat_zero_flag="guessing yes";;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-              #include <fcntl.h>
-              #include <sys/stat.h>
-              int
-              main (void)
-              {
-                struct stat a;
-                return fstatat (AT_FDCWD, ".", &a, 0) != 0;
-              }
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_fstatat_zero_flag=yes
-else
-  gl_cv_func_fstatat_zero_flag=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fstatat_zero_flag" >&5
-$as_echo "$gl_cv_func_fstatat_zero_flag" >&6; }
-
-    case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in
-    *yes+*yes) ;;
-    *) REPLACE_FSTATAT=1
-       case $gl_cv_func_fstatat_zero_flag in
-       *yes)
-
-$as_echo "#define HAVE_WORKING_FSTATAT_ZERO_FLAG 1" >>confdefs.h
-
-         ;;
-       esac
-       ;;
-    esac
-  fi
-
-  if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_FSTATAT=1
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_fsync = no; then
-    HAVE_FSYNC=0
-  fi
-
-  if test $HAVE_FSYNC = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS fsync.$ac_objext"
-
-    :
-  fi
-
-
-
-
-
-          GNULIB_FSYNC=1
-
-
-
-
-
-
-
-# Persuade glibc <stdlib.h> to declare getloadavg().
-
-
-gl_save_LIBS=$LIBS
-
-# getloadvg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
-# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
-HAVE_GETLOADAVG=1
-ac_fn_c_check_func "$LINENO" "getloadavg" "ac_cv_func_getloadavg"
-if test "x$ac_cv_func_getloadavg" = x""yes; then :
-
-else
-  gl_func_getloadavg_done=no
-
-   # Some systems with -lutil have (and need) -lkvm as well, some do not.
-   # On Solaris, -lkvm requires nlist from -lelf, so check that first
-   # to get the right answer into the cache.
-   # For kstat on solaris, we need to test for libelf and libkvm to force the
-   # definition of SVR4 below.
-   if test $gl_func_getloadavg_done = no; then
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_begin in -lelf" >&5
-$as_echo_n "checking for elf_begin in -lelf... " >&6; }
-if test "${ac_cv_lib_elf_elf_begin+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lelf  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char elf_begin ();
-int
-main ()
-{
-return elf_begin ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_elf_elf_begin=yes
-else
-  ac_cv_lib_elf_elf_begin=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_elf_begin" >&5
-$as_echo "$ac_cv_lib_elf_elf_begin" >&6; }
-if test "x$ac_cv_lib_elf_elf_begin" = x""yes; then :
-  LIBS="-lelf $LIBS"
-fi
-
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kvm_open in -lkvm" >&5
-$as_echo_n "checking for kvm_open in -lkvm... " >&6; }
-if test "${ac_cv_lib_kvm_kvm_open+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkvm  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char kvm_open ();
-int
-main ()
-{
-return kvm_open ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_kvm_kvm_open=yes
-else
-  ac_cv_lib_kvm_kvm_open=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_kvm_open" >&5
-$as_echo "$ac_cv_lib_kvm_kvm_open" >&6; }
-if test "x$ac_cv_lib_kvm_kvm_open" = x""yes; then :
-  LIBS="-lkvm $LIBS"
-fi
-
-     # Check for the 4.4BSD definition of getloadavg.
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lutil" >&5
-$as_echo_n "checking for getloadavg in -lutil... " >&6; }
-if test "${ac_cv_lib_util_getloadavg+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lutil  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getloadavg ();
-int
-main ()
-{
-return getloadavg ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_util_getloadavg=yes
-else
-  ac_cv_lib_util_getloadavg=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_getloadavg" >&5
-$as_echo "$ac_cv_lib_util_getloadavg" >&6; }
-if test "x$ac_cv_lib_util_getloadavg" = x""yes; then :
-  LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes
-fi
-
-   fi
-
-   if test $gl_func_getloadavg_done = no; then
-     # There is a commonly available library for RS/6000 AIX.
-     # Since it is not a standard part of AIX, it might be installed locally.
-     gl_getloadavg_LIBS=$LIBS
-     LIBS="-L/usr/local/lib $LIBS"
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getloadavg in -lgetloadavg" >&5
-$as_echo_n "checking for getloadavg in -lgetloadavg... " >&6; }
-if test "${ac_cv_lib_getloadavg_getloadavg+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgetloadavg  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getloadavg ();
-int
-main ()
-{
-return getloadavg ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_getloadavg_getloadavg=yes
-else
-  ac_cv_lib_getloadavg_getloadavg=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_getloadavg_getloadavg" >&5
-$as_echo "$ac_cv_lib_getloadavg_getloadavg" >&6; }
-if test "x$ac_cv_lib_getloadavg_getloadavg" = x""yes; then :
-  LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes
-else
-  LIBS=$gl_getloadavg_LIBS
-fi
-
-   fi
-
-   # Set up the replacement function if necessary.
-   if test $gl_func_getloadavg_done = no; then
-     HAVE_GETLOADAVG=0
-
-     # Solaris has libkstat which does not require root.
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kstat_open in -lkstat" >&5
-$as_echo_n "checking for kstat_open in -lkstat... " >&6; }
-if test "${ac_cv_lib_kstat_kstat_open+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lkstat  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char kstat_open ();
-int
-main ()
-{
-return kstat_open ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_kstat_kstat_open=yes
-else
-  ac_cv_lib_kstat_kstat_open=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kstat_kstat_open" >&5
-$as_echo "$ac_cv_lib_kstat_kstat_open" >&6; }
-if test "x$ac_cv_lib_kstat_kstat_open" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBKSTAT 1
-_ACEOF
-
-  LIBS="-lkstat $LIBS"
-
-fi
-
-     test $ac_cv_lib_kstat_kstat_open = yes && gl_func_getloadavg_done=yes
-
-     # AIX has libperfstat which does not require root
-     if test $gl_func_getloadavg_done = no; then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perfstat_cpu_total in -lperfstat" >&5
-$as_echo_n "checking for perfstat_cpu_total in -lperfstat... " >&6; }
-if test "${ac_cv_lib_perfstat_perfstat_cpu_total+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lperfstat  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char perfstat_cpu_total ();
-int
-main ()
-{
-return perfstat_cpu_total ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_perfstat_perfstat_cpu_total=yes
-else
-  ac_cv_lib_perfstat_perfstat_cpu_total=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_perfstat_perfstat_cpu_total" >&5
-$as_echo "$ac_cv_lib_perfstat_perfstat_cpu_total" >&6; }
-if test "x$ac_cv_lib_perfstat_perfstat_cpu_total" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBPERFSTAT 1
-_ACEOF
-
-  LIBS="-lperfstat $LIBS"
-
-fi
-
-       test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_func_getloadavg_done=yes
-     fi
-
-     if test $gl_func_getloadavg_done = no; then
-       ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_dg_sys_info_h" = x""yes; then :
-  gl_func_getloadavg_done=yes
-
-$as_echo "#define DGUX 1" >>confdefs.h
-
-          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dg_sys_info in -ldgc" >&5
-$as_echo_n "checking for dg_sys_info in -ldgc... " >&6; }
-if test "${ac_cv_lib_dgc_dg_sys_info+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldgc  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dg_sys_info ();
-int
-main ()
-{
-return dg_sys_info ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dgc_dg_sys_info=yes
-else
-  ac_cv_lib_dgc_dg_sys_info=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dgc_dg_sys_info" >&5
-$as_echo "$ac_cv_lib_dgc_dg_sys_info" >&6; }
-if test "x$ac_cv_lib_dgc_dg_sys_info" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDGC 1
-_ACEOF
-
-  LIBS="-ldgc $LIBS"
-
-fi
-
-fi
-
-
-     fi
-   fi
-fi
-
-
-if test "x$gl_save_LIBS" = x; then
-  GETLOADAVG_LIBS=$LIBS
-else
-  GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$gl_save_LIBS!!"`
-fi
-LIBS=$gl_save_LIBS
-
-
-# Test whether the system declares getloadavg. Solaris has the function
-# but declares it in <sys/loadavg.h>, not <stdlib.h>.
-for ac_header in sys/loadavg.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/loadavg.h" "ac_cv_header_sys_loadavg_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_loadavg_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_LOADAVG_H 1
-_ACEOF
-
-fi
-
-done
-
-if test $ac_cv_header_sys_loadavg_h = yes; then
-  HAVE_SYS_LOADAVG_H=1
-else
-  HAVE_SYS_LOADAVG_H=0
-fi
-ac_fn_c_check_decl "$LINENO" "getloadavg" "ac_cv_have_decl_getloadavg" "#if HAVE_SYS_LOADAVG_H
-    # include <sys/loadavg.h>
-    #endif
-    #include <stdlib.h>
-"
-if test "x$ac_cv_have_decl_getloadavg" = x""yes; then :
-
-else
-  HAVE_DECL_GETLOADAVG=0
-fi
-
-
-  if test $HAVE_GETLOADAVG = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getloadavg.$ac_objext"
-
-
-# Figure out what our getloadavg.c needs.
-
-
-
-# On HPUX9, an unprivileged user can get load averages this way.
-if test $gl_func_getloadavg_done = no; then
-  for ac_func in pstat_getdynamic
-do :
-  ac_fn_c_check_func "$LINENO" "pstat_getdynamic" "ac_cv_func_pstat_getdynamic"
-if test "x$ac_cv_func_pstat_getdynamic" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_PSTAT_GETDYNAMIC 1
-_ACEOF
- gl_func_getloadavg_done=yes
-fi
-done
-
-fi
-
-# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
-# uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
-# Irix 4.0.5F has the header but not the library.
-if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \
-    && test "$ac_cv_lib_kvm_kvm_open" = yes; then
-  gl_func_getloadavg_done=yes
-
-$as_echo "#define SVR4 1" >>confdefs.h
-
-fi
-
-if test $gl_func_getloadavg_done = no; then
-  ac_fn_c_check_header_mongrel "$LINENO" "inq_stats/cpustats.h" "ac_cv_header_inq_stats_cpustats_h" "$ac_includes_default"
-if test "x$ac_cv_header_inq_stats_cpustats_h" = x""yes; then :
-  gl_func_getloadavg_done=yes
-
-$as_echo "#define UMAX 1" >>confdefs.h
-
-
-$as_echo "#define UMAX4_3 1" >>confdefs.h
-
-fi
-
-
-fi
-
-if test $gl_func_getloadavg_done = no; then
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/cpustats.h" "ac_cv_header_sys_cpustats_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_cpustats_h" = x""yes; then :
-  gl_func_getloadavg_done=yes; $as_echo "#define UMAX 1" >>confdefs.h
-
-fi
-
-
-fi
-
-if test $gl_func_getloadavg_done = no; then
-  for ac_header in mach/mach.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "mach/mach.h" "ac_cv_header_mach_mach_h" "$ac_includes_default"
-if test "x$ac_cv_header_mach_mach_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_MACH_MACH_H 1
-_ACEOF
-
-fi
-
-done
-
-fi
-
-for ac_header in nlist.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default"
-if test "x$ac_cv_header_nlist_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NLIST_H 1
-_ACEOF
- ac_fn_c_check_member "$LINENO" "struct nlist" "n_un.n_name" "ac_cv_member_struct_nlist_n_un_n_name" "#include <nlist.h>
-"
-if test "x$ac_cv_member_struct_nlist_n_un_n_name" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_NLIST_N_UN_N_NAME 1
-_ACEOF
-
-
-fi
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <nlist.h>
-int
-main ()
-{
-struct nlist x;
-                    #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
-                    x.n_un.n_name = "";
-                    #else
-                    x.n_name = "";
-                    #endif
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-$as_echo "#define N_NAME_POINTER 1" >>confdefs.h
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-
-done
-
-  fi
-
-
-
-
-
-          GNULIB_GETLOADAVG=1
-
-
-
-
-
-
-
-
-
-
-  if test $REPLACE_GETOPT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
-
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
-
-
-
-
-        GNULIB_GL_UNISTD_H_GETOPT=1
-  fi
-
-
-
-
-
-
-
-    REPLACE_GETOPT=0
-    if test -n "$gl_replace_getopt"; then
-      REPLACE_GETOPT=1
-    fi
-
-  if test $REPLACE_GETOPT = 1; then
-
-  GETOPT_H=getopt.h
-
-$as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
-
-
-
-  fi
-
-  if test $REPLACE_GETOPT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
-
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
-
-
-
-
-        GNULIB_GL_UNISTD_H_GETOPT=1
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-  gl_gettimeofday_timezone=void
-  if test $ac_cv_func_gettimeofday != yes; then
-    HAVE_GETTIMEOFDAY=0
-  else
-
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gettimeofday clobbers localtime buffer" >&5
-$as_echo_n "checking whether gettimeofday clobbers localtime buffer... " >&6; }
-if test "${gl_cv_func_gettimeofday_clobber+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  # When cross-compiling:
-      case "$host_os" in
-                # Guess all is fine on glibc systems.
-        *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
-                # If we don't know, assume the worst.
-        *)      gl_cv_func_gettimeofday_clobber="guessing yes" ;;
-      esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
-          #include <sys/time.h>
-          #include <time.h>
-          #include <stdlib.h>
-
-int
-main ()
-{
-
-          time_t t = 0;
-          struct tm *lt;
-          struct tm saved_lt;
-          struct timeval tv;
-          lt = localtime (&t);
-          saved_lt = *lt;
-          gettimeofday (&tv, NULL);
-          return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_gettimeofday_clobber=no
-else
-  gl_cv_func_gettimeofday_clobber=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_gettimeofday_clobber" >&5
-$as_echo "$gl_cv_func_gettimeofday_clobber" >&6; }
-
- case "$gl_cv_func_gettimeofday_clobber" in
-   *yes)
-     REPLACE_GETTIMEOFDAY=1
-
-
-$as_echo "#define gmtime rpl_gmtime" >>confdefs.h
-
-
-$as_echo "#define localtime rpl_localtime" >>confdefs.h
-
-
-
-$as_echo "#define GETTIMEOFDAY_CLOBBERS_LOCALTIME 1" >>confdefs.h
-
-     ;;
- esac
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gettimeofday with POSIX signature" >&5
-$as_echo_n "checking for gettimeofday with POSIX signature... " >&6; }
-if test "${gl_cv_func_gettimeofday_posix_signature+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/time.h>
-              struct timeval c;
-              int gettimeofday (struct timeval *restrict, void *restrict);
-
-int
-main ()
-{
-/* glibc uses struct timezone * rather than the POSIX void *
-                 if _GNU_SOURCE is defined.  However, since the only portable
-                 use of gettimeofday uses NULL as the second parameter, and
-                 since the glibc definition is actually more typesafe, it is
-                 not worth wrapping this to get a compliant signature.  */
-              int (*f) (struct timeval *restrict, void *restrict)
-                = gettimeofday;
-              int x = f (&c, 0);
-              return !(x | c.tv_sec | c.tv_usec);
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_func_gettimeofday_posix_signature=yes
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/time.h>
-int gettimeofday (struct timeval *restrict, struct timezone *restrict);
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_func_gettimeofday_posix_signature=almost
-else
-  gl_cv_func_gettimeofday_posix_signature=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_gettimeofday_posix_signature" >&5
-$as_echo "$gl_cv_func_gettimeofday_posix_signature" >&6; }
-    if test $gl_cv_func_gettimeofday_posix_signature = almost; then
-      gl_gettimeofday_timezone='struct timezone'
-    elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
-      REPLACE_GETTIMEOFDAY=1
-    fi
-        if test $REPLACE_STRUCT_TIMEVAL = 1; then
-      REPLACE_GETTIMEOFDAY=1
-    fi
-
-  fi
-
-cat >>confdefs.h <<_ACEOF
-#define GETTIMEOFDAY_TIMEZONE $gl_gettimeofday_timezone
-_ACEOF
-
-
-  if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS gettimeofday.$ac_objext"
-
-
-  for ac_header in sys/timeb.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/timeb.h" "ac_cv_header_sys_timeb_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_timeb_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_TIMEB_H 1
-_ACEOF
-
-fi
-
-done
-
-  for ac_func in _ftime
-do :
-  ac_fn_c_check_func "$LINENO" "_ftime" "ac_cv_func__ftime"
-if test "x$ac_cv_func__ftime" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE__FTIME 1
-_ACEOF
-
-fi
-done
-
-
-  fi
-
-
-
-
-
-          GNULIB_GETTIMEOFDAY=1
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_lstat = yes; then
-
-    case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
-      *no)
-        REPLACE_LSTAT=1
-        ;;
-    esac
-  else
-    HAVE_LSTAT=0
-  fi
-
-  if test $REPLACE_LSTAT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS lstat.$ac_objext"
-
-    :
-  fi
-
-
-
-
-
-          GNULIB_LSTAT=1
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_have_decl_memrchr = no; then
-    HAVE_DECL_MEMRCHR=0
-  fi
-
-  for ac_func in memrchr
-do :
-  ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
-if test "x$ac_cv_func_memrchr" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_MEMRCHR 1
-_ACEOF
-
-fi
-done
-
-
-  if test $ac_cv_func_memrchr = no; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS memrchr.$ac_objext"
-
-    :
-  fi
-
-
-
-
-
-          GNULIB_MEMRCHR=1
-
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_mkostemp != yes; then
-    HAVE_MKOSTEMP=0
-  fi
-
-  if test $HAVE_MKOSTEMP = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS mkostemp.$ac_objext"
-
-
-
-  fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_MKOSTEMP 1
-_ACEOF
-
-
-
-
-
-
-
-          GNULIB_MKOSTEMP=1
-
-
-
-
-
-
-
-
-
-
-
-  if test $APPLE_UNIVERSAL_BUILD = 1; then
-    # A universal build on Apple Mac OS X platforms.
-    # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
-    # But we need a configuration result that is valid in both modes.
-    gl_cv_func_working_mktime=no
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5
-$as_echo_n "checking for working mktime... " >&6; }
-if test "${gl_cv_func_working_mktime+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  gl_cv_func_working_mktime=no
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-/* Test program from Paul Eggert and Tony Leneis.  */
-#include <limits.h>
-#include <stdlib.h>
-#include <time.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_DECL_ALARM
-# include <signal.h>
-#endif
-
-/* Work around redefinition to rpl_putenv by other config tests.  */
-#undef putenv
-
-static time_t time_t_max;
-static time_t time_t_min;
-
-/* Values we'll use to set the TZ environment variable.  */
-static char *tz_strings[] = {
-  (char *) 0, "TZ=GMT0", "TZ=JST-9",
-  "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
-};
-#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
-
-/* Return 0 if mktime fails to convert a date in the spring-forward gap.
-   Based on a problem report from Andreas Jaeger.  */
-static int
-spring_forward_gap ()
-{
-  /* glibc (up to about 1998-10-07) failed this test. */
-  struct tm tm;
-
-  /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
-     instead of "TZ=America/Vancouver" in order to detect the bug even
-     on systems that don't support the Olson extension, or don't have the
-     full zoneinfo tables installed.  */
-  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
-
-  tm.tm_year = 98;
-  tm.tm_mon = 3;
-  tm.tm_mday = 5;
-  tm.tm_hour = 2;
-  tm.tm_min = 0;
-  tm.tm_sec = 0;
-  tm.tm_isdst = -1;
-  return mktime (&tm) != (time_t) -1;
-}
-
-static int
-mktime_test1 (time_t now)
-{
-  struct tm *lt;
-  return ! (lt = localtime (&now)) || mktime (lt) == now;
-}
-
-static int
-mktime_test (time_t now)
-{
-  return (mktime_test1 (now)
-          && mktime_test1 ((time_t) (time_t_max - now))
-          && mktime_test1 ((time_t) (time_t_min + now)));
-}
-
-static int
-irix_6_4_bug ()
-{
-  /* Based on code from Ariel Faigon.  */
-  struct tm tm;
-  tm.tm_year = 96;
-  tm.tm_mon = 3;
-  tm.tm_mday = 0;
-  tm.tm_hour = 0;
-  tm.tm_min = 0;
-  tm.tm_sec = 0;
-  tm.tm_isdst = -1;
-  mktime (&tm);
-  return tm.tm_mon == 2 && tm.tm_mday == 31;
-}
-
-static int
-bigtime_test (int j)
-{
-  struct tm tm;
-  time_t now;
-  tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
-  now = mktime (&tm);
-  if (now != (time_t) -1)
-    {
-      struct tm *lt = localtime (&now);
-      if (! (lt
-             && lt->tm_year == tm.tm_year
-             && lt->tm_mon == tm.tm_mon
-             && lt->tm_mday == tm.tm_mday
-             && lt->tm_hour == tm.tm_hour
-             && lt->tm_min == tm.tm_min
-             && lt->tm_sec == tm.tm_sec
-             && lt->tm_yday == tm.tm_yday
-             && lt->tm_wday == tm.tm_wday
-             && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
-                  == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
-        return 0;
-    }
-  return 1;
-}
-
-static int
-year_2050_test ()
-{
-  /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
-     ignoring leap seconds.  */
-  unsigned long int answer = 2527315200UL;
-
-  struct tm tm;
-  time_t t;
-  tm.tm_year = 2050 - 1900;
-  tm.tm_mon = 2 - 1;
-  tm.tm_mday = 1;
-  tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
-  tm.tm_isdst = -1;
-
-  /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
-     instead of "TZ=America/Vancouver" in order to detect the bug even
-     on systems that don't support the Olson extension, or don't have the
-     full zoneinfo tables installed.  */
-  putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
-
-  t = mktime (&tm);
-
-  /* Check that the result is either a failure, or close enough
-     to the correct answer that we can assume the discrepancy is
-     due to leap seconds.  */
-  return (t == (time_t) -1
-          || (0 < t && answer - 120 <= t && t <= answer + 120));
-}
-
-int
-main ()
-{
-  int result = 0;
-  time_t t, delta;
-  int i, j;
-  int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
-  int time_t_signed = ! ((time_t) 0 < (time_t) -1);
-
-#if HAVE_DECL_ALARM
-  /* This test makes some buggy mktime implementations loop.
-     Give up after 60 seconds; a mktime slower than that
-     isn't worth using anyway.  */
-  signal (SIGALRM, SIG_DFL);
-  alarm (60);
-#endif
-
-  time_t_max = (! time_t_signed
-                ? (time_t) -1
-                : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
-                   * 2 + 1));
-  time_t_min = (! time_t_signed
-                ? (time_t) 0
-                : time_t_signed_magnitude
-                ? ~ (time_t) 0
-                : ~ time_t_max);
-
-  delta = time_t_max / 997; /* a suitable prime number */
-  for (i = 0; i < N_STRINGS; i++)
-    {
-      if (tz_strings[i])
-        putenv (tz_strings[i]);
-
-      for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta)
-        if (! mktime_test (t))
-          result |= 1;
-      if ((result & 2) == 0
-          && ! (mktime_test ((time_t) 1)
-                && mktime_test ((time_t) (60 * 60))
-                && mktime_test ((time_t) (60 * 60 * 24))))
-        result |= 2;
-
-      for (j = 1; (result & 4) == 0; j <<= 1)
-        {
-          if (! bigtime_test (j))
-            result |= 4;
-          if (INT_MAX / 2 < j)
-            break;
-        }
-      if ((result & 8) == 0 && ! bigtime_test (INT_MAX))
-        result |= 8;
-    }
-  if (! irix_6_4_bug ())
-    result |= 16;
-  if (! spring_forward_gap ())
-    result |= 32;
-  if (! year_2050_test ())
-    result |= 64;
-  return result;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_working_mktime=yes
-else
-  gl_cv_func_working_mktime=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_mktime" >&5
-$as_echo "$gl_cv_func_working_mktime" >&6; }
-
-  if test $gl_cv_func_working_mktime = no; then
-    REPLACE_MKTIME=1
-  else
-    REPLACE_MKTIME=0
-  fi
-
-  if test $REPLACE_MKTIME = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS mktime.$ac_objext"
-
-    :
-  fi
-
-
-
-
-
-          GNULIB_MKTIME=1
-
-
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_pipe2 != yes; then
-    HAVE_PIPE2=0
-  fi
-
-
-
-
-
-
-          GNULIB_PIPE2=1
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_pselect = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signature of pselect conforms to POSIX" >&5
-$as_echo_n "checking whether signature of pselect conforms to POSIX... " >&6; }
-if test "${gl_cv_sig_pselect+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-
-int
-main ()
-{
-int (*p) (int, fd_set *, fd_set *, fd_set *restrict,
-                          struct timespec const *restrict,
-                          sigset_t const *restrict) = pselect;
-                return !p;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_sig_pselect=yes
-else
-  gl_cv_sig_pselect=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sig_pselect" >&5
-$as_echo "$gl_cv_sig_pselect" >&6; }
-
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pselect detects invalid fds" >&5
-$as_echo_n "checking whether pselect detects invalid fds... " >&6; }
-if test "${gl_cv_func_pselect_detects_ebadf+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-        if test "$cross_compiling" = yes; then :
-
-           case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_pselect_detects_ebadf="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_pselect_detects_ebadf="guessing no" ;;
-           esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#if HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
-#include <unistd.h>
-#include <errno.h>
-
-int
-main ()
-{
-
-  fd_set set;
-  dup2(0, 16);
-  FD_ZERO(&set);
-  FD_SET(16, &set);
-  close(16);
-  struct timespec timeout;
-  timeout.tv_sec = 0;
-  timeout.tv_nsec = 5000;
-  return pselect (17, &set, NULL, NULL, &timeout, NULL) != -1 || errno != EBADF;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_pselect_detects_ebadf=yes
-else
-  gl_cv_func_pselect_detects_ebadf=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_pselect_detects_ebadf" >&5
-$as_echo "$gl_cv_func_pselect_detects_ebadf" >&6; }
-    case $gl_cv_func_pselect_detects_ebadf in
-      *yes) ;;
-      *) REPLACE_PSELECT=1 ;;
-    esac
-  fi
-
-  if test $ac_cv_func_pselect = no || test $gl_cv_sig_pselect = no; then
-    REPLACE_PSELECT=1
-  fi
-
-  if test $HAVE_PSELECT = 0 || test $REPLACE_PSELECT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS pselect.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_PSELECT=1
-
-
-
-
-
-
-
-
-
-  LIB_PTHREAD_SIGMASK=
-
-
-
-
-    if test "$gl_threads_api" = posix; then
-      if test $ac_cv_func_pthread_sigmask = yes; then
-                :
-      else
-        if test -n "$LIBMULTITHREAD"; then
-          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_sigmask in $LIBMULTITHREAD" >&5
-$as_echo_n "checking for pthread_sigmask in $LIBMULTITHREAD... " >&6; }
-if test "${gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  gl_save_LIBS="$LIBS"
-             LIBS="$LIBS $LIBMULTITHREAD"
-             cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <pthread.h>
-                    #include <signal.h>
-
-int
-main ()
-{
-return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 0);
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes
-else
-  gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-             LIBS="$gl_save_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD" >&5
-$as_echo "$gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD" >&6; }
-          if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then
-                        LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD"
-          else
-                        HAVE_PTHREAD_SIGMASK=0
-          fi
-        else
-                    HAVE_PTHREAD_SIGMASK=0
-        fi
-      fi
-    else
-                                          if test $ac_cv_func_pthread_sigmask = yes; then
-        REPLACE_PTHREAD_SIGMASK=1
-      else
-        HAVE_PTHREAD_SIGMASK=0
-      fi
-    fi
-
-
-
-
-    if test $HAVE_PTHREAD_SIGMASK = 1; then
-
-
-                if test -z "$LIB_PTHREAD_SIGMASK"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_sigmask works without -lpthread" >&5
-$as_echo_n "checking whether pthread_sigmask works without -lpthread... " >&6; }
-if test "${gl_cv_func_pthread_sigmask_in_libc_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-          if test "$cross_compiling" = yes; then :
-
-             case "$host_os" in
-               freebsd* | hpux* | solaris | solaris2.[2-9]*)
-                 gl_cv_func_pthread_sigmask_in_libc_works="guessing no";;
-               *)
-                 gl_cv_func_pthread_sigmask_in_libc_works="guessing yes";;
-             esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stddef.h>
-int main ()
-{
-  sigset_t set;
-  sigemptyset (&set);
-  return pthread_sigmask (1729, &set, NULL) != 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_pthread_sigmask_in_libc_works=no
-else
-  gl_cv_func_pthread_sigmask_in_libc_works=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_pthread_sigmask_in_libc_works" >&5
-$as_echo "$gl_cv_func_pthread_sigmask_in_libc_works" >&6; }
-      case "$gl_cv_func_pthread_sigmask_in_libc_works" in
-        *no)
-          REPLACE_PTHREAD_SIGMASK=1
-
-$as_echo "#define PTHREAD_SIGMASK_INEFFECTIVE 1" >>confdefs.h
-
-          ;;
-      esac
-    fi
-
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_sigmask returns error numbers" >&5
-$as_echo_n "checking whether pthread_sigmask returns error numbers... " >&6; }
-if test "${gl_cv_func_pthread_sigmask_return_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-        gl_save_LIBS="$LIBS"
-        LIBS="$LIBS $LIB_PTHREAD_SIGMASK"
-        if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-             cygwin*)
-               gl_cv_func_pthread_sigmask_return_works="guessing no";;
-             *)
-               gl_cv_func_pthread_sigmask_return_works="guessing yes";;
-           esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stddef.h>
-int main ()
-{
-  sigset_t set;
-  sigemptyset (&set);
-  if (pthread_sigmask (1729, &set, NULL) == -1)
-    return 1;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_pthread_sigmask_return_works=yes
-else
-  gl_cv_func_pthread_sigmask_return_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-        LIBS="$gl_save_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_pthread_sigmask_return_works" >&5
-$as_echo "$gl_cv_func_pthread_sigmask_return_works" >&6; }
-    case "$gl_cv_func_pthread_sigmask_return_works" in
-      *no)
-        REPLACE_PTHREAD_SIGMASK=1
-
-$as_echo "#define PTHREAD_SIGMASK_FAILS_WITH_ERRNO 1" >>confdefs.h
-
-        ;;
-    esac
-
-                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_sigmask unblocks signals correctly" >&5
-$as_echo_n "checking whether pthread_sigmask unblocks signals correctly... " >&6; }
-if test "${gl_cv_func_pthread_sigmask_unblock_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-        case "$host_os" in
-          irix*)
-            gl_cv_func_pthread_sigmask_unblock_works="guessing no";;
-          *)
-            gl_cv_func_pthread_sigmask_unblock_works="guessing yes";;
-        esac
-                                gl_save_LIBS="$LIBS"
-        LIBS="$LIBS $LIBMULTITHREAD"
-        if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-static volatile int sigint_occurred;
-static void
-sigint_handler (int sig)
-{
-  sigint_occurred++;
-}
-int main ()
-{
-  sigset_t set;
-  int pid = getpid ();
-  char command[80];
-  signal (SIGINT, sigint_handler);
-  sigemptyset (&set);
-  sigaddset (&set, SIGINT);
-  if (!(pthread_sigmask (SIG_BLOCK, &set, NULL) == 0))
-    return 1;
-  sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, pid);
-  if (!(system (command) == 0))
-    return 2;
-  sleep (2);
-  if (!(sigint_occurred == 0))
-    return 3;
-  if (!(pthread_sigmask (SIG_UNBLOCK, &set, NULL) == 0))
-    return 4;
-  if (!(sigint_occurred == 1)) /* This fails on IRIX.  */
-    return 5;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  :
-else
-  gl_cv_func_pthread_sigmask_unblock_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-        LIBS="$gl_save_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_pthread_sigmask_unblock_works" >&5
-$as_echo "$gl_cv_func_pthread_sigmask_unblock_works" >&6; }
-    case "$gl_cv_func_pthread_sigmask_unblock_works" in
-      *no)
-        REPLACE_PTHREAD_SIGMASK=1
-
-$as_echo "#define PTHREAD_SIGMASK_UNBLOCK_BUG 1" >>confdefs.h
-
-        ;;
-    esac
-  fi
-
-  if test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS pthread_sigmask.$ac_objext"
-
-
-  if test $HAVE_PTHREAD_SIGMASK = 1; then
-
-$as_echo "#define HAVE_PTHREAD_SIGMASK 1" >>confdefs.h
-
-  fi
-
-  fi
-
-
-
-
-
-          GNULIB_PTHREAD_SIGMASK=1
-
-
-
-
-
-
-
-     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for putenv compatible with GNU and SVID" >&5
-$as_echo_n "checking for putenv compatible with GNU and SVID... " >&6; }
-if test "${gl_cv_func_svid_putenv+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-               case "$host_os" in
-                        # Guess yes on glibc systems.
-                *-gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
-                        # If we don't know, assume the worst.
-                *)      gl_cv_func_svid_putenv="guessing no" ;;
-              esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-
-    /* Put it in env.  */
-    if (putenv ("CONFTEST_putenv=val"))
-      return 1;
-
-    /* Try to remove it.  */
-    if (putenv ("CONFTEST_putenv"))
-      return 2;
-
-    /* Make sure it was deleted.  */
-    if (getenv ("CONFTEST_putenv") != 0)
-      return 3;
-
-    return 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_svid_putenv=yes
-else
-  gl_cv_func_svid_putenv=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_svid_putenv" >&5
-$as_echo "$gl_cv_func_svid_putenv" >&6; }
-  case "$gl_cv_func_svid_putenv" in
-    *yes) ;;
-    *)
-      REPLACE_PUTENV=1
-      ;;
-  esac
-
-  if test $REPLACE_PUTENV = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS putenv.$ac_objext"
-
-
-  ac_fn_c_check_decl "$LINENO" "_putenv" "ac_cv_have_decl__putenv" "$ac_includes_default"
-if test "x$ac_cv_have_decl__putenv" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL__PUTENV $ac_have_decl
-_ACEOF
-
-
-  fi
-
-
-
-
-
-          GNULIB_PUTENV=1
-
-
-
-
-
-
-  # Check whether --enable-acl was given.
-if test "${enable_acl+set}" = set; then :
-  enableval=$enable_acl;
-else
-  enable_acl=auto
-fi
-
-
-  LIB_ACL=
-  use_acl=0
-  if test "x$enable_acl" != "xno"; then
-        for ac_header in sys/acl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "sys/acl.h" "ac_cv_header_sys_acl_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_acl_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SYS_ACL_H 1
-_ACEOF
-
-fi
-
-done
-
-    if test $ac_cv_header_sys_acl_h = yes; then
-      ac_save_LIBS=$LIBS
-
-                  if test $use_acl = 0; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_get_file" >&5
-$as_echo_n "checking for library containing acl_get_file... " >&6; }
-if test "${ac_cv_search_acl_get_file+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char acl_get_file ();
-int
-main ()
-{
-return acl_get_file ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' acl pacl; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_acl_get_file=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_acl_get_file+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_acl_get_file+set}" = set; then :
-
-else
-  ac_cv_search_acl_get_file=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_acl_get_file" >&5
-$as_echo "$ac_cv_search_acl_get_file" >&6; }
-ac_res=$ac_cv_search_acl_get_file
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  if test "$ac_cv_search_acl_get_file" != "none required"; then
-             LIB_ACL=$ac_cv_search_acl_get_file
-           fi
-           for ac_func in acl_get_file acl_get_fd acl_set_file acl_set_fd \
-              acl_free acl_from_mode acl_from_text \
-              acl_delete_def_file acl_extended_file \
-              acl_delete_fd_np acl_delete_file_np \
-              acl_copy_ext_native acl_create_entry_np \
-              acl_to_short_text acl_free_text
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-eval as_val=\$$as_ac_var
-   if test "x$as_val" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-           # If the acl_get_file bug is detected, don't enable the ACL support.
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working acl_get_file" >&5
-$as_echo_n "checking for working acl_get_file... " >&6; }
-if test "${gl_cv_func_working_acl_get_file+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  gl_cv_func_working_acl_get_file=cross-compiling
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-           #include <sys/acl.h>
-           #include <errno.h>
-
-int
-main ()
-{
-if (!acl_get_file (".", ACL_TYPE_ACCESS) && errno == ENOENT)
-              return 1;
-            return 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_working_acl_get_file=yes
-else
-  gl_cv_func_working_acl_get_file=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_working_acl_get_file" >&5
-$as_echo "$gl_cv_func_working_acl_get_file" >&6; }
-
-  if test $gl_cv_func_working_acl_get_file = yes; then :
-  use_acl=1
-fi
-
-           if test $use_acl = 1; then
-                          for ac_header in acl/libacl.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "acl/libacl.h" "ac_cv_header_acl_libacl_h" "$ac_includes_default"
-if test "x$ac_cv_header_acl_libacl_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACL_LIBACL_H 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-
-
-
-
-  for ac_func in acl_entries
-do :
-  ac_fn_c_check_func "$LINENO" "acl_entries" "ac_cv_func_acl_entries"
-if test "x$ac_cv_func_acl_entries" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACL_ENTRIES 1
-_ACEOF
-
-else
-
-    gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
-
-fi
-done
-
-
-             { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_FIRST_ENTRY" >&5
-$as_echo_n "checking for ACL_FIRST_ENTRY... " >&6; }
-if test "${gl_cv_acl_ACL_FIRST_ENTRY+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/acl.h>
-int type = ACL_FIRST_ENTRY;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_acl_ACL_FIRST_ENTRY=yes
-else
-  gl_cv_acl_ACL_FIRST_ENTRY=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_acl_ACL_FIRST_ENTRY" >&5
-$as_echo "$gl_cv_acl_ACL_FIRST_ENTRY" >&6; }
-             if test $gl_cv_acl_ACL_FIRST_ENTRY = yes; then
-
-$as_echo "#define HAVE_ACL_FIRST_ENTRY 1" >>confdefs.h
-
-             fi
-                          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ACL_TYPE_EXTENDED" >&5
-$as_echo_n "checking for ACL_TYPE_EXTENDED... " >&6; }
-if test "${gl_cv_acl_ACL_TYPE_EXTENDED+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-#include <sys/acl.h>
-int type = ACL_TYPE_EXTENDED;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_acl_ACL_TYPE_EXTENDED=yes
-else
-  gl_cv_acl_ACL_TYPE_EXTENDED=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_acl_ACL_TYPE_EXTENDED" >&5
-$as_echo "$gl_cv_acl_ACL_TYPE_EXTENDED" >&6; }
-             if test $gl_cv_acl_ACL_TYPE_EXTENDED = yes; then
-
-$as_echo "#define HAVE_ACL_TYPE_EXTENDED 1" >>confdefs.h
-
-             fi
-           else
-             LIB_ACL=
-           fi
-
-fi
-
-      fi
-
-            if test $use_acl = 0; then
-        for ac_func in facl
-do :
-  ac_fn_c_check_func "$LINENO" "facl" "ac_cv_func_facl"
-if test "x$ac_cv_func_facl" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_FACL 1
-_ACEOF
-
-fi
-done
-
-        if test $ac_cv_func_facl = yes; then
-          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing acl_trivial" >&5
-$as_echo_n "checking for library containing acl_trivial... " >&6; }
-if test "${ac_cv_search_acl_trivial+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char acl_trivial ();
-int
-main ()
-{
-return acl_trivial ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' sec; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_acl_trivial=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_acl_trivial+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_acl_trivial+set}" = set; then :
-
-else
-  ac_cv_search_acl_trivial=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_acl_trivial" >&5
-$as_echo "$ac_cv_search_acl_trivial" >&6; }
-ac_res=$ac_cv_search_acl_trivial
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  if test "$ac_cv_search_acl_trivial" != "none required"; then
-               LIB_ACL=$ac_cv_search_acl_trivial
-             fi
-
-fi
-
-          for ac_func in acl_trivial
-do :
-  ac_fn_c_check_func "$LINENO" "acl_trivial" "ac_cv_func_acl_trivial"
-if test "x$ac_cv_func_acl_trivial" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACL_TRIVIAL 1
-_ACEOF
-
-fi
-done
-
-          use_acl=1
-        fi
-      fi
-
-            if test $use_acl = 0; then
-        for ac_func in getacl
-do :
-  ac_fn_c_check_func "$LINENO" "getacl" "ac_cv_func_getacl"
-if test "x$ac_cv_func_getacl" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_GETACL 1
-_ACEOF
-
-fi
-done
-
-        if test $ac_cv_func_getacl = yes; then
-          use_acl=1
-        fi
-                for ac_header in aclv.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "aclv.h" "ac_cv_header_aclv_h" "#include <sys/types.h>
-"
-if test "x$ac_cv_header_aclv_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACLV_H 1
-_ACEOF
-
-fi
-
-done
-
-      fi
-
-            if test $use_acl = 0; then
-        for ac_func in aclx_get
-do :
-  ac_fn_c_check_func "$LINENO" "aclx_get" "ac_cv_func_aclx_get"
-if test "x$ac_cv_func_aclx_get" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACLX_GET 1
-_ACEOF
-
-fi
-done
-
-        if test $ac_cv_func_aclx_get = yes; then
-          use_acl=1
-        fi
-      fi
-
-            if test $use_acl = 0 || test "$ac_cv_func_aclx_get" = yes; then
-        for ac_func in statacl
-do :
-  ac_fn_c_check_func "$LINENO" "statacl" "ac_cv_func_statacl"
-if test "x$ac_cv_func_statacl" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_STATACL 1
-_ACEOF
-
-fi
-done
-
-        if test $ac_cv_func_statacl = yes; then
-          use_acl=1
-        fi
-      fi
-
-            if test $use_acl = 0; then
-        for ac_func in aclsort
-do :
-  ac_fn_c_check_func "$LINENO" "aclsort" "ac_cv_func_aclsort"
-if test "x$ac_cv_func_aclsort" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ACLSORT 1
-_ACEOF
-
-fi
-done
-
-        if test $ac_cv_func_aclsort = yes; then
-          use_acl=1
-        fi
-      fi
-
-      LIBS=$ac_save_LIBS
-    fi
-    if test "x$enable_acl$use_acl" = "xyes0"; then
-      as_fn_error "ACLs enabled but support not detected" "$LINENO" 5
-    elif test "x$enable_acl$use_acl" = "xauto0"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libacl development library was not found or not usable." >&5
-$as_echo "$as_me: WARNING: libacl development library was not found or not usable." >&2;}
-      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: emacs will be built without ACL support." >&5
-$as_echo "$as_me: WARNING: emacs will be built without ACL support." >&2;}
-    fi
-  fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define USE_ACL $use_acl
-_ACEOF
-
-  USE_ACL=$use_acl
-
-
-
-
-
-  if test $ac_cv_func_readlink = no; then
-    HAVE_READLINK=0
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink signature is correct" >&5
-$as_echo_n "checking whether readlink signature is correct... " >&6; }
-if test "${gl_cv_decl_readlink_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <unistd.h>
-      /* Cause compilation failure if original declaration has wrong type.  */
-      ssize_t readlink (const char *, char *, size_t);
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_decl_readlink_works=yes
-else
-  gl_cv_decl_readlink_works=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_readlink_works" >&5
-$as_echo "$gl_cv_decl_readlink_works" >&6; }
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlink handles trailing slash correctly" >&5
-$as_echo_n "checking whether readlink handles trailing slash correctly... " >&6; }
-if test "${gl_cv_func_readlink_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # We have readlink, so assume ln -s works.
-       ln -s conftest.no-such conftest.link
-       ln -s conftest.link conftest.lnk2
-       if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_readlink_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_readlink_works="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <unistd.h>
-
-int
-main ()
-{
-char buf[20];
-      return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_readlink_works=yes
-else
-  gl_cv_func_readlink_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-      rm -f conftest.link conftest.lnk2
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_readlink_works" >&5
-$as_echo "$gl_cv_func_readlink_works" >&6; }
-    case "$gl_cv_func_readlink_works" in
-      *yes)
-        if test "$gl_cv_decl_readlink_works" != yes; then
-          REPLACE_READLINK=1
-        fi
-        ;;
-      *)
-
-$as_echo "#define READLINK_TRAILING_SLASH_BUG 1" >>confdefs.h
-
-        REPLACE_READLINK=1
-        ;;
-    esac
-  fi
-
-  if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS readlink.$ac_objext"
-
-
-  :
-
-  fi
-
-
-
-
-
-          GNULIB_READLINK=1
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_readlinkat = no; then
-    HAVE_READLINKAT=0
-  fi
-
-  if test $HAVE_READLINKAT = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS readlinkat.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_READLINKAT=1
-
-
-
-
-
-
-  for ac_func in sig2str
-do :
-  ac_fn_c_check_func "$LINENO" "sig2str" "ac_cv_func_sig2str"
-if test "x$ac_cv_func_sig2str" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_SIG2STR 1
-_ACEOF
-
-fi
-done
-
-
-  if test $ac_cv_func_sig2str = no; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS sig2str.$ac_objext"
-
-
-  :
-
-  fi
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_signal_h='<'signal.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <signal.h>" >&5
-$as_echo_n "checking absolute name of <signal.h>... " >&6; }
-if test "${gl_cv_next_signal_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <signal.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'signal.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_signal_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_signal_h" >&5
-$as_echo "$gl_cv_next_signal_h" >&6; }
-     fi
-     NEXT_SIGNAL_H=$gl_cv_next_signal_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'signal.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_signal_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H=$gl_next_as_first_directive
-
-
-
-
-
-# AIX declares sig_atomic_t to already include volatile, and C89 compilers
-# then choke on 'volatile sig_atomic_t'.  C99 requires that it compile.
-  ac_fn_c_check_type "$LINENO" "volatile sig_atomic_t" "ac_cv_type_volatile_sig_atomic_t" "
-#include <signal.h>
-
-"
-if test "x$ac_cv_type_volatile_sig_atomic_t" = x""yes; then :
-
-else
-  HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0
-fi
-
-
-
-
-
-
-
-  ac_fn_c_check_type "$LINENO" "sighandler_t" "ac_cv_type_sighandler_t" "
-#include <signal.h>
-
-"
-if test "x$ac_cv_type_sighandler_t" = x""yes; then :
-
-else
-  HAVE_SIGHANDLER_T=0
-fi
-
-
-
-
-     ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
-/* <sys/types.h> is not needed according to POSIX, but the
-   <sys/socket.h> in i386-unknown-freebsd4.10 and
-   powerpc-apple-darwin5.5 required it. */
-#include <sys/types.h>
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#elif HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-#endif
-
-"
-if test "x$ac_cv_type_socklen_t" = x""yes; then :
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t equivalent" >&5
-$as_echo_n "checking for socklen_t equivalent... " >&6; }
-      if test "${gl_cv_socklen_t_equiv+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # Systems have either "struct sockaddr *" or
-         # "void *" as the second argument to getpeername
-         gl_cv_socklen_t_equiv=
-         for arg2 in "struct sockaddr" void; do
-           for t in int size_t "unsigned int" "long int" "unsigned long int"; do
-             cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-                   #include <sys/socket.h>
-
-                   int getpeername (int, $arg2 *, $t *);
-int
-main ()
-{
-$t len;
-                  getpeername (0, 0, &len);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_socklen_t_equiv="$t"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-             test "$gl_cv_socklen_t_equiv" != "" && break
-           done
-           test "$gl_cv_socklen_t_equiv" != "" && break
-         done
-
-fi
-
-      if test "$gl_cv_socklen_t_equiv" = ""; then
-        as_fn_error "Cannot find a type to use in place of socklen_t" "$LINENO" 5
-      fi
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_socklen_t_equiv" >&5
-$as_echo "$gl_cv_socklen_t_equiv" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define socklen_t $gl_cv_socklen_t_equiv
-_ACEOF
-
-fi
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssize_t" >&5
-$as_echo_n "checking for ssize_t... " >&6; }
-if test "${gt_cv_ssize_t+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/types.h>
-int
-main ()
-{
-int x = sizeof (ssize_t *) + sizeof (ssize_t);
-            return !x;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gt_cv_ssize_t=yes
-else
-  gt_cv_ssize_t=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_ssize_t" >&5
-$as_echo "$gt_cv_ssize_t" >&6; }
-  if test $gt_cv_ssize_t = no; then
-
-$as_echo "#define ssize_t int" >>confdefs.h
-
-  fi
-
-
-
-
-
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.tv_nsec" "ac_cv_member_struct_stat_st_atim_tv_nsec" "#include <sys/types.h>
-     #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_atim_tv_nsec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1
-_ACEOF
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct stat.st_atim is of type struct timespec" >&5
-$as_echo_n "checking whether struct stat.st_atim is of type struct timespec... " >&6; }
-if test "${ac_cv_typeof_struct_stat_st_atim_is_struct_timespec+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-            #include <sys/types.h>
-            #include <sys/stat.h>
-            #if HAVE_SYS_TIME_H
-            # include <sys/time.h>
-            #endif
-            #include <time.h>
-            struct timespec ts;
-            struct stat st;
-
-int
-main ()
-{
-
-            st.st_atim = ts;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes
-else
-  ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&5
-$as_echo "$ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&6; }
-     if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
-
-$as_echo "#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1" >>confdefs.h
-
-     fi
-else
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include <sys/types.h>
-        #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 1
-_ACEOF
-
-
-else
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include <sys/types.h>
-           #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_atimensec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1
-_ACEOF
-
-
-else
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include <sys/types.h>
-              #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC 1
-_ACEOF
-
-
-fi
-
-fi
-
-fi
-
-fi
-
-
-
-
-
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtimespec.tv_nsec" "ac_cv_member_struct_stat_st_birthtimespec_tv_nsec" "#include <sys/types.h>
-     #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_birthtimespec_tv_nsec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
-_ACEOF
-
-
-else
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtimensec" "ac_cv_member_struct_stat_st_birthtimensec" "#include <sys/types.h>
-        #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_birthtimensec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC 1
-_ACEOF
-
-
-else
-  ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtim.tv_nsec" "ac_cv_member_struct_stat_st_birthtim_tv_nsec" "#include <sys/types.h>
-          #include <sys/stat.h>
-"
-if test "x$ac_cv_member_struct_stat_st_birthtim_tv_nsec" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC 1
-_ACEOF
-
-
-fi
-
-fi
-
-fi
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working stdalign.h" >&5
-$as_echo_n "checking for working stdalign.h... " >&6; }
-if test "${gl_cv_header_working_stdalign_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdalign.h>
-            #include <stddef.h>
-
-            /* Test that alignof yields a result consistent with offsetof.
-               This catches GCC bug 52023
-               <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.  */
-            #ifdef __cplusplus
-               template <class t> struct alignof_helper { char a; t b; };
-            # define ao(type) offsetof (alignof_helper<type>, b)
-            #else
-            # define ao(type) offsetof (struct { char a; type b; }, b)
-            #endif
-            char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
-            char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
-            char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
-
-            /* Test _Alignas only on platforms where gnulib can help.  */
-            #if \
-                ((defined __cplusplus && 201103 <= __cplusplus) \
-                 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
-                 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
-              struct alignas_test { char c; char alignas (8) alignas_8; };
-              char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
-                                ? 1 : -1];
-            #endif
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_header_working_stdalign_h=yes
-else
-  gl_cv_header_working_stdalign_h=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_working_stdalign_h" >&5
-$as_echo "$gl_cv_header_working_stdalign_h" >&6; }
-
-  if test $gl_cv_header_working_stdalign_h = yes; then
-    STDALIGN_H=''
-  else
-    STDALIGN_H='stdalign.h'
-  fi
-
-
-   if test -n "$STDALIGN_H"; then
-  GL_GENERATE_STDALIGN_H_TRUE=
-  GL_GENERATE_STDALIGN_H_FALSE='#'
-else
-  GL_GENERATE_STDALIGN_H_TRUE='#'
-  GL_GENERATE_STDALIGN_H_FALSE=
-fi
-
-
-
-  STDARG_H=''
-  NEXT_STDARG_H='<stdarg.h>'
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5
-$as_echo_n "checking for va_copy... " >&6; }
-  if test "${gl_cv_func_va_copy+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-int
-main ()
-{
-
-#ifndef va_copy
-void (*func) (va_list, va_list) = va_copy;
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_func_va_copy=yes
-else
-  gl_cv_func_va_copy=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_va_copy" >&5
-$as_echo "$gl_cv_func_va_copy" >&6; }
-  if test $gl_cv_func_va_copy = no; then
-                                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#if defined _AIX && !defined __GNUC__
-        AIX vaccine
-       #endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "vaccine" >/dev/null 2>&1; then :
-  gl_aixcc=yes
-else
-  gl_aixcc=no
-fi
-rm -f conftest*
-
-    if test $gl_aixcc = yes; then
-            STDARG_H=stdarg.h
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_stdarg_h='<'stdarg.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdarg.h>" >&5
-$as_echo_n "checking absolute name of <stdarg.h>... " >&6; }
-if test "${gl_cv_next_stdarg_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'stdarg.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_stdarg_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdarg_h" >&5
-$as_echo "$gl_cv_next_stdarg_h" >&6; }
-     fi
-     NEXT_STDARG_H=$gl_cv_next_stdarg_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'stdarg.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_stdarg_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STDARG_H=$gl_next_as_first_directive
-
-
-
-
-            if test "$gl_cv_next_stdarg_h" = '""'; then
-        gl_cv_next_stdarg_h='"///usr/include/stdarg.h"'
-        NEXT_STDARG_H="$gl_cv_next_stdarg_h"
-      fi
-    else
-
-  saved_as_echo_n="$as_echo_n"
-  as_echo_n=':'
-  if test "${gl_cv_func___va_copy+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-int
-main ()
-{
-
-#ifndef __va_copy
-error, bail out
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_func___va_copy=yes
-else
-  gl_cv_func___va_copy=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-  as_echo_n="$saved_as_echo_n"
-
-      if test $gl_cv_func___va_copy = yes; then
-
-$as_echo "#define va_copy __va_copy" >>confdefs.h
-
-      else
-
-
-$as_echo "#define va_copy gl_va_copy" >>confdefs.h
-
-      fi
-    fi
-  fi
-
-   if test -n "$STDARG_H"; then
-  GL_GENERATE_STDARG_H_TRUE=
-  GL_GENERATE_STDARG_H_FALSE='#'
-else
-  GL_GENERATE_STDARG_H_TRUE='#'
-  GL_GENERATE_STDARG_H_FALSE=
-fi
-
-
-
-
-
-
-  # Define two additional variables used in the Makefile substitution.
-
-  if test "$ac_cv_header_stdbool_h" = yes; then
-    STDBOOL_H=''
-  else
-    STDBOOL_H='stdbool.h'
-  fi
-
-   if test -n "$STDBOOL_H"; then
-  GL_GENERATE_STDBOOL_H_TRUE=
-  GL_GENERATE_STDBOOL_H_FALSE='#'
-else
-  GL_GENERATE_STDBOOL_H_TRUE='#'
-  GL_GENERATE_STDBOOL_H_FALSE=
-fi
-
-
-  if test "$ac_cv_type__Bool" = yes; then
-    HAVE__BOOL=1
-  else
-    HAVE__BOOL=0
-  fi
-
-
-
-
-
-  STDDEF_H=
-  if test $gt_cv_c_wchar_t = no; then
-    HAVE_WCHAR_T=0
-    STDDEF_H=stddef.h
-  fi
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NULL can be used in arbitrary expressions" >&5
-$as_echo_n "checking whether NULL can be used in arbitrary expressions... " >&6; }
-if test "${gl_cv_decl_null_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stddef.h>
-      int test[2 * (sizeof NULL == sizeof (void *)) -1];
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_decl_null_works=yes
-else
-  gl_cv_decl_null_works=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_null_works" >&5
-$as_echo "$gl_cv_decl_null_works" >&6; }
-  if test $gl_cv_decl_null_works = no; then
-    REPLACE_NULL=1
-    STDDEF_H=stddef.h
-  fi
-
-   if test -n "$STDDEF_H"; then
-  GL_GENERATE_STDDEF_H_TRUE=
-  GL_GENERATE_STDDEF_H_FALSE='#'
-else
-  GL_GENERATE_STDDEF_H_TRUE='#'
-  GL_GENERATE_STDDEF_H_FALSE=
-fi
-
-  if test -n "$STDDEF_H"; then
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_stddef_h='<'stddef.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stddef.h>" >&5
-$as_echo_n "checking absolute name of <stddef.h>... " >&6; }
-if test "${gl_cv_next_stddef_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stddef.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'stddef.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5
-$as_echo "$gl_cv_next_stddef_h" >&6; }
-     fi
-     NEXT_STDDEF_H=$gl_cv_next_stddef_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'stddef.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_stddef_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STDDEF_H=$gl_next_as_first_directive
-
-
-
-
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_stdio_h='<'stdio.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdio.h>" >&5
-$as_echo_n "checking absolute name of <stdio.h>... " >&6; }
-if test "${gl_cv_next_stdio_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'stdio.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdio_h" >&5
-$as_echo "$gl_cv_next_stdio_h" >&6; }
-     fi
-     NEXT_STDIO_H=$gl_cv_next_stdio_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'stdio.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_stdio_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STDIO_H=$gl_next_as_first_directive
-
-
-
-
-
-      GNULIB_FSCANF=1
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_FSCANF 1
-_ACEOF
-
-
-  GNULIB_SCANF=1
-
-
-cat >>confdefs.h <<_ACEOF
-#define GNULIB_SCANF 1
-_ACEOF
-
-
-  GNULIB_FGETC=1
-  GNULIB_GETC=1
-  GNULIB_GETCHAR=1
-  GNULIB_FGETS=1
-  GNULIB_FREAD=1
-
-
-      GNULIB_FPRINTF=1
-  GNULIB_PRINTF=1
-  GNULIB_VFPRINTF=1
-  GNULIB_VPRINTF=1
-  GNULIB_FPUTC=1
-  GNULIB_PUTC=1
-  GNULIB_PUTCHAR=1
-  GNULIB_FPUTS=1
-  GNULIB_PUTS=1
-  GNULIB_FWRITE=1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_stdlib_h='<'stdlib.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <stdlib.h>" >&5
-$as_echo_n "checking absolute name of <stdlib.h>... " >&6; }
-if test "${gl_cv_next_stdlib_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'stdlib.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5
-$as_echo "$gl_cv_next_stdlib_h" >&6; }
-     fi
-     NEXT_STDLIB_H=$gl_cv_next_stdlib_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'stdlib.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_stdlib_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_STDLIB_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
- # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
-
-
-
-
-
-
-
-$as_echo "#define my_strftime nstrftime" >>confdefs.h
-
-
-
-
-
-
-
-
-
-
-
-  if test "$ac_cv_have_decl_strtoimax" != yes; then
-    HAVE_DECL_STRTOIMAX=0
-  fi
-
-  if test "$ac_cv_func_strtoimax" = yes; then
-    HAVE_STRTOIMAX=1
-             { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtoimax works" >&5
-$as_echo_n "checking whether strtoimax works... " >&6; }
-if test "${gl_cv_func_strtoimax+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                   # Guess no on AIX 5.
-            aix5*) gl_cv_func_strtoimax="guessing no" ;;
-                   # Guess yes otherwise.
-            *)     gl_cv_func_strtoimax="guessing yes" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <errno.h>
-#include <string.h>
-#include <inttypes.h>
-int main ()
-{
-  if (sizeof (intmax_t) > sizeof (int))
-    {
-      const char *s = "4294967295";
-      char *p;
-      intmax_t res;
-      errno = 0;
-      res = strtoimax (s, &p, 10);
-      if (p != s + strlen (s))
-        return 1;
-      if (errno != 0)
-        return 2;
-      if (res != (intmax_t) 65535 * (intmax_t) 65537)
-        return 3;
-    }
-  else
-    {
-      const char *s = "2147483647";
-      char *p;
-      intmax_t res;
-      errno = 0;
-      res = strtoimax (s, &p, 10);
-      if (p != s + strlen (s))
-        return 1;
-      if (errno != 0)
-        return 2;
-      if (res != 2147483647)
-        return 3;
-    }
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_strtoimax=yes
-else
-  gl_cv_func_strtoimax=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_strtoimax" >&5
-$as_echo "$gl_cv_func_strtoimax" >&6; }
-    case "$gl_cv_func_strtoimax" in
-      *no) REPLACE_STRTOIMAX=1 ;;
-    esac
-  else
-    if test "$ac_cv_have_decl_strtoimax" = yes; then
-      # HP-UX 11.11 has "#define strtoimax(...) ..." but no function.
-      REPLACE_STRTOIMAX=1
-    fi
-    HAVE_STRTOIMAX=0
-  fi
-
-  if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS strtoimax.$ac_objext"
-
-
-  ac_fn_c_check_decl "$LINENO" "strtoll" "ac_cv_have_decl_strtoll" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strtoll" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRTOLL $ac_have_decl
-_ACEOF
-
-
-
-  fi
-
-
-
-
-
-          GNULIB_STRTOIMAX=1
-
-
-
-
-
-
-
-
-
-  if test "$ac_cv_have_decl_strtoumax" = yes; then
-    if test "$ac_cv_func_strtoumax" != yes; then
-      # HP-UX 11.11 has "#define strtoimax(...) ..." but no function.
-      REPLACE_STRTOUMAX=1
-    fi
-  else
-    HAVE_DECL_STRTOUMAX=0
-  fi
-
-  if test $HAVE_DECL_STRTOUMAX = 0 || test $REPLACE_STRTOUMAX = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS strtoumax.$ac_objext"
-
-
-  ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strtoull" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRTOULL $ac_have_decl
-_ACEOF
-
-
-
-  fi
-
-
-
-
-
-          GNULIB_STRTOUMAX=1
-
-
-
-
-
-
-
-        if test $ac_cv_func_symlink = no; then
-    HAVE_SYMLINK=0
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether symlink handles trailing slash correctly" >&5
-$as_echo_n "checking whether symlink handles trailing slash correctly... " >&6; }
-if test "${gl_cv_func_symlink_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_symlink_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_symlink_works="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <unistd.h>
-
-int
-main ()
-{
-int result = 0;
-             if (!symlink ("a", "conftest.link/"))
-               result |= 1;
-             if (symlink ("conftest.f", "conftest.lnk2"))
-               result |= 2;
-             else if (!symlink ("a", "conftest.lnk2/"))
-               result |= 4;
-             return result;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_symlink_works=yes
-else
-  gl_cv_func_symlink_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-      rm -f conftest.f conftest.link conftest.lnk2
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_symlink_works" >&5
-$as_echo "$gl_cv_func_symlink_works" >&6; }
-    case "$gl_cv_func_symlink_works" in
-      *yes) ;;
-      *)
-        REPLACE_SYMLINK=1
-        ;;
-    esac
-  fi
-
-  if test $HAVE_SYMLINK = 0 || test $REPLACE_SYMLINK = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS symlink.$ac_objext"
-
-  fi
-
-
-
-
-
-          GNULIB_SYMLINK=1
-
-
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <sys/select.h> is self-contained" >&5
-$as_echo_n "checking whether <sys/select.h> is self-contained... " >&6; }
-if test "${gl_cv_header_sys_select_h_selfcontained+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-                                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-struct timeval b;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_header_sys_select_h_selfcontained=yes
-else
-  gl_cv_header_sys_select_h_selfcontained=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-                        if test $gl_cv_header_sys_select_h_selfcontained = yes; then
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-int memset; int bzero;
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-int
-main ()
-{
-
-                  #undef memset
-                  #define memset nonexistent_memset
-                  extern
-                  #ifdef __cplusplus
-                  "C"
-                  #endif
-                  void *memset (void *, int, unsigned long);
-                  #undef bzero
-                  #define bzero nonexistent_bzero
-                  extern
-                  #ifdef __cplusplus
-                  "C"
-                  #endif
-                  void bzero (void *, unsigned long);
-                  fd_set fds;
-                  FD_ZERO (&fds);
-
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-else
-  gl_cv_header_sys_select_h_selfcontained=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-      fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_sys_select_h_selfcontained" >&5
-$as_echo "$gl_cv_header_sys_select_h_selfcontained" >&6; }
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_sys_select_h='<'sys/select.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/select.h>" >&5
-$as_echo_n "checking absolute name of <sys/select.h>... " >&6; }
-if test "${gl_cv_next_sys_select_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_sys_select_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/select.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'sys/select.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_sys_select_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_sys_select_h='<'sys/select.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_select_h" >&5
-$as_echo "$gl_cv_next_sys_select_h" >&6; }
-     fi
-     NEXT_SYS_SELECT_H=$gl_cv_next_sys_select_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'sys/select.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_sys_select_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_sys_select_h = yes; then
-    HAVE_SYS_SELECT_H=1
-  else
-    HAVE_SYS_SELECT_H=0
-  fi
-
-
-
-
-
-  if test $ac_cv_header_sys_socket_h != yes; then
-                    for ac_header in winsock2.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default"
-if test "x$ac_cv_header_winsock2_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_WINSOCK2_H 1
-_ACEOF
-
-fi
-
-done
-
-  fi
-  if test "$ac_cv_header_winsock2_h" = yes; then
-    HAVE_WINSOCK2_H=1
-    UNISTD_H_HAVE_WINSOCK2_H=1
-    SYS_IOCTL_H_HAVE_WINSOCK2_H=1
-  else
-    HAVE_WINSOCK2_H=0
-  fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_sys_stat_h='<'sys/stat.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <sys/stat.h>" >&5
-$as_echo_n "checking absolute name of <sys/stat.h>... " >&6; }
-if test "${gl_cv_next_sys_stat_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_sys_stat_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/stat.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'sys/stat.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_sys_stat_h='<'sys/stat.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5
-$as_echo "$gl_cv_next_sys_stat_h" >&6; }
-     fi
-     NEXT_SYS_STAT_H=$gl_cv_next_sys_stat_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'sys/stat.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_sys_stat_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H=$gl_next_as_first_directive
-
-
-
-
-
-
-
-
-
-
-
-  if test $WINDOWS_64_BIT_ST_SIZE = 1; then
-
-$as_echo "#define _GL_WINDOWS_64_BIT_ST_SIZE 1" >>confdefs.h
-
-  fi
-
-      ac_fn_c_check_type "$LINENO" "nlink_t" "ac_cv_type_nlink_t" "#include <sys/types.h>
-     #include <sys/stat.h>
-"
-if test "x$ac_cv_type_nlink_t" = x""yes; then :
-
-else
-
-$as_echo "#define nlink_t int" >>confdefs.h
-
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-      ac_fn_c_check_decl "$LINENO" "localtime_r" "ac_cv_have_decl_localtime_r" "#include <time.h>
-"
-if test "x$ac_cv_have_decl_localtime_r" = x""yes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_LOCALTIME_R $ac_have_decl
-_ACEOF
-
-  if test $ac_cv_have_decl_localtime_r = no; then
-    HAVE_DECL_LOCALTIME_R=0
-  fi
-
-
-  if test $ac_cv_func_localtime_r = yes; then
-    HAVE_LOCALTIME_R=1
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether localtime_r is compatible with its POSIX signature" >&5
-$as_echo_n "checking whether localtime_r is compatible with its POSIX signature... " >&6; }
-if test "${gl_cv_time_r_posix+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <time.h>
-int
-main ()
-{
-/* We don't need to append 'restrict's to the argument types,
-                 even though the POSIX signature has the 'restrict's,
-                 since C99 says they can't affect type compatibility.  */
-              struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
-              if (ptr) return 0;
-              /* Check the return type is a pointer.
-                 On HP-UX 10 it is 'int'.  */
-              *localtime_r (0, 0);
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gl_cv_time_r_posix=yes
-else
-  gl_cv_time_r_posix=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_time_r_posix" >&5
-$as_echo "$gl_cv_time_r_posix" >&6; }
-    if test $gl_cv_time_r_posix = yes; then
-      REPLACE_LOCALTIME_R=0
-    else
-      REPLACE_LOCALTIME_R=1
-    fi
-  else
-    HAVE_LOCALTIME_R=0
-  fi
-
-  if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS time_r.$ac_objext"
-
-
-  :
-
-  fi
-
-
-
-
-
-          GNULIB_TIME_R=1
-
-
-
-
-
-
-
-
-
-
-  LIB_TIMER_TIME=
-
-  gl_saved_libs=$LIBS
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing timer_settime" >&5
-$as_echo_n "checking for library containing timer_settime... " >&6; }
-if test "${ac_cv_search_timer_settime+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char timer_settime ();
-int
-main ()
-{
-return timer_settime ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' rt posix4; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_timer_settime=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_timer_settime+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_timer_settime+set}" = set; then :
-
-else
-  ac_cv_search_timer_settime=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_timer_settime" >&5
-$as_echo "$ac_cv_search_timer_settime" >&6; }
-ac_res=$ac_cv_search_timer_settime
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  test "$ac_cv_search_timer_settime" = "none required" ||
-                    LIB_TIMER_TIME=$ac_cv_search_timer_settime
-fi
-
-                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <features.h>
-#ifdef __GNU_LIBRARY__
- #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
-     && !defined __UCLIBC__
-  Thread emulation available
- #endif
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "Thread" >/dev/null 2>&1; then :
-  LIB_TIMER_TIME="$LIB_TIMER_TIME $LIBMULTITHREAD"
-fi
-rm -f conftest*
-
-    for ac_func in timer_settime
-do :
-  ac_fn_c_check_func "$LINENO" "timer_settime" "ac_cv_func_timer_settime"
-if test "x$ac_cv_func_timer_settime" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_TIMER_SETTIME 1
-_ACEOF
-
-fi
-done
-
-  LIBS=$gl_saved_libs
-
-  :
-
-
-
-
-
-
-
-
-
-
-
-
-     if test $gl_cv_have_include_next = yes; then
-       gl_cv_next_unistd_h='<'unistd.h'>'
-     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <unistd.h>" >&5
-$as_echo_n "checking absolute name of <unistd.h>... " >&6; }
-if test "${gl_cv_next_unistd_h+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-             if test $ac_cv_header_unistd_h = yes; then
-
-
-               cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <unistd.h>
-
-_ACEOF
-                                                                                                                        case "$host_os" in
-                 aix*) gl_absname_cpp="$ac_cpp -C" ;;
-                 *)    gl_absname_cpp="$ac_cpp" ;;
-               esac
-
-               case "$host_os" in
-                 mingw*)
-                                                                                                                                     gl_dirsep_regex='[/\\]'
-                   ;;
-                 *)
-                   gl_dirsep_regex='\/'
-                   ;;
-               esac
-                                             gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
-
-               gl_header_literal_regex=`echo 'unistd.h' \
-                                        | sed -e "$gl_make_literal_regex_sed"`
-               gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
-                   s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
-                   s|^/[^/]|//&|
-                   p
-                   q
-                 }'
-                                                            gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
-                      sed -n "$gl_absolute_header_sed"`'"'
-          else
-               gl_cv_next_unistd_h='<'unistd.h'>'
-             fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5
-$as_echo "$gl_cv_next_unistd_h" >&6; }
-     fi
-     NEXT_UNISTD_H=$gl_cv_next_unistd_h
-
-     if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
-       gl_next_as_first_directive='<'unistd.h'>'
-     else
-       # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
-       gl_next_as_first_directive=$gl_cv_next_unistd_h
-     fi
-     NEXT_AS_FIRST_DIRECTIVE_UNISTD_H=$gl_next_as_first_directive
-
-
-
-
-  if test $ac_cv_header_unistd_h = yes; then
-    HAVE_UNISTD_H=1
-  else
-    HAVE_UNISTD_H=0
-  fi
-
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_have_decl_unsetenv = no; then
-    HAVE_DECL_UNSETENV=0
-  fi
-  for ac_func in unsetenv
-do :
-  ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv"
-if test "x$ac_cv_func_unsetenv" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_UNSETENV 1
-_ACEOF
-
-fi
-done
-
-  if test $ac_cv_func_unsetenv = no; then
-    HAVE_UNSETENV=0
-  else
-    HAVE_UNSETENV=1
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsetenv() return type" >&5
-$as_echo_n "checking for unsetenv() return type... " >&6; }
-if test "${gt_cv_func_unsetenv_ret+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#undef _BSD
-#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
-#include <stdlib.h>
-extern
-#ifdef __cplusplus
-"C"
-#endif
-int unsetenv (const char *name);
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gt_cv_func_unsetenv_ret='int'
-else
-  gt_cv_func_unsetenv_ret='void'
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_unsetenv_ret" >&5
-$as_echo "$gt_cv_func_unsetenv_ret" >&6; }
-    if test $gt_cv_func_unsetenv_ret = 'void'; then
-
-$as_echo "#define VOID_UNSETENV 1" >>confdefs.h
-
-      REPLACE_UNSETENV=1
-    fi
-
-                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unsetenv obeys POSIX" >&5
-$as_echo_n "checking whether unsetenv obeys POSIX... " >&6; }
-if test "${gl_cv_func_unsetenv_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                 # Guess yes on glibc systems.
-         *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
-                 # If we don't know, assume the worst.
-         *)      gl_cv_func_unsetenv_works="guessing no" ;;
-       esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-       #include <stdlib.h>
-       #include <errno.h>
-       extern char **environ;
-
-int
-main ()
-{
-
-       char entry1[] = "a=1";
-       char entry2[] = "b=2";
-       char *env[] = { entry1, entry2, NULL };
-       if (putenv ((char *) "a=1")) return 1;
-       if (putenv (entry2)) return 2;
-       entry2[0] = 'a';
-       unsetenv ("a");
-       if (getenv ("a")) return 3;
-       if (!unsetenv ("") || errno != EINVAL) return 4;
-       entry2[0] = 'b';
-       environ = env;
-       if (!getenv ("a")) return 5;
-       entry2[0] = 'a';
-       unsetenv ("a");
-       if (getenv ("a")) return 6;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_unsetenv_works=yes
-else
-  gl_cv_func_unsetenv_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unsetenv_works" >&5
-$as_echo "$gl_cv_func_unsetenv_works" >&6; }
-    case "$gl_cv_func_unsetenv_works" in
-      *yes) ;;
-      *)
-        REPLACE_UNSETENV=1
-        ;;
-    esac
-  fi
-
-  if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS unsetenv.$ac_objext"
-
-
-
-
-
-  fi
-
-
-
-
-
-          GNULIB_UNSETENV=1
-
-
-
-
-
-
-
-
-
-
-
-  if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
-                { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether futimesat handles NULL file" >&5
-$as_echo_n "checking whether futimesat handles NULL file... " >&6; }
-if test "${gl_cv_func_futimesat_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  touch conftest.file
-       if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                   # Guess yes on glibc systems.
-           *-gnu*) gl_cv_func_futimesat_works="guessing yes" ;;
-                   # If we don't know, assume the worst.
-           *)      gl_cv_func_futimesat_works="guessing no" ;;
-         esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include <stddef.h>
-#include <sys/times.h>
-#include <fcntl.h>
-
-int
-main ()
-{
-    int fd = open ("conftest.file", O_RDWR);
-          if (fd < 0) return 1;
-          if (futimesat (fd, NULL, NULL)) return 2;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_futimesat_works=yes
-else
-  gl_cv_func_futimesat_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-      rm -f conftest.file
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_futimesat_works" >&5
-$as_echo "$gl_cv_func_futimesat_works" >&6; }
-    case "$gl_cv_func_futimesat_works" in
-      *yes) ;;
-      *)
-
-$as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
-
-        ;;
-    esac
-  fi
-
-  gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
-  gl_gnulib_enabled_dosname=false
-  gl_gnulib_enabled_euidaccess=false
-  gl_gnulib_enabled_getdtablesize=false
-  gl_gnulib_enabled_getgroups=false
-  gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
-  gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
-  gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false
-  gl_gnulib_enabled_pathmax=false
-  gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false
-  gl_gnulib_enabled_secure_getenv=false
-  gl_gnulib_enabled_stat=false
-  gl_gnulib_enabled_strtoll=false
-  gl_gnulib_enabled_strtoull=false
-  gl_gnulib_enabled_tempname=false
-  gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
-  func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
-  {
-    if ! $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext"
-
-      gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true
-    fi
-  }
-  func_gl_gnulib_m4code_dosname ()
-  {
-    if ! $gl_gnulib_enabled_dosname; then
-      gl_gnulib_enabled_dosname=true
-    fi
-  }
-  func_gl_gnulib_m4code_euidaccess ()
-  {
-    if ! $gl_gnulib_enabled_euidaccess; then
-
-
-
-
-
-  for ac_func in euidaccess
-do :
-  ac_fn_c_check_func "$LINENO" "euidaccess" "ac_cv_func_euidaccess"
-if test "x$ac_cv_func_euidaccess" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_EUIDACCESS 1
-_ACEOF
-
-fi
-done
-
-  if test $ac_cv_func_euidaccess = no; then
-    HAVE_EUIDACCESS=0
-  fi
-
-      if test $HAVE_EUIDACCESS = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS euidaccess.$ac_objext"
-
-
-
-    for ac_header in libgen.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "libgen.h" "ac_cv_header_libgen_h" "$ac_includes_default"
-if test "x$ac_cv_header_libgen_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGEN_H 1
-_ACEOF
-
-fi
-
-done
-
-
-        ac_fn_c_check_func "$LINENO" "getgroups" "ac_cv_func_getgroups"
-if test "x$ac_cv_func_getgroups" = x""yes; then :
-
-fi
-
-
-  # If we don't yet have getgroups, see if it's in -lbsd.
-  # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
-  ac_save_LIBS=$LIBS
-  if test $ac_cv_func_getgroups = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getgroups in -lbsd" >&5
-$as_echo_n "checking for getgroups in -lbsd... " >&6; }
-if test "${ac_cv_lib_bsd_getgroups+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getgroups ();
-int
-main ()
-{
-return getgroups ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_bsd_getgroups=yes
-else
-  ac_cv_lib_bsd_getgroups=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_getgroups" >&5
-$as_echo "$ac_cv_lib_bsd_getgroups" >&6; }
-if test "x$ac_cv_lib_bsd_getgroups" = x""yes; then :
-  GETGROUPS_LIB=-lbsd
-fi
-
-  fi
-
-  # Run the program to test the functionality of the system-supplied
-  # getgroups function only if there is such a function.
-  if test $ac_cv_func_getgroups = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getgroups" >&5
-$as_echo_n "checking for working getgroups... " >&6; }
-if test "${ac_cv_func_getgroups_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in # ((
-                    # Guess yes on glibc systems.
-            *-gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      ac_cv_func_getgroups_works="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-/* On Ultrix 4.3, getgroups (0, 0) always fails.  */
-              return getgroups (0, 0) == -1;
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_func_getgroups_works=yes
-else
-  ac_cv_func_getgroups_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getgroups_works" >&5
-$as_echo "$ac_cv_func_getgroups_works" >&6; }
-  else
-    ac_cv_func_getgroups_works=no
-  fi
-  case "$ac_cv_func_getgroups_works" in
-    *yes)
-
-$as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h
-
-      ;;
-  esac
-  LIBS=$ac_save_LIBS
-
-
-  # Solaris 9 and 10 need -lgen to get the eaccess function.
-  # Save and restore LIBS so -lgen isn't added to it.  Otherwise, *all*
-  # programs in the package would end up linked with that potentially-shared
-  # library, inducing unnecessary run-time overhead.
-  LIB_EACCESS=
-
-  gl_saved_libs=$LIBS
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing eaccess" >&5
-$as_echo_n "checking for library containing eaccess... " >&6; }
-if test "${ac_cv_search_eaccess+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char eaccess ();
-int
-main ()
-{
-return eaccess ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' gen; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_eaccess=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_eaccess+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_eaccess+set}" = set; then :
-
-else
-  ac_cv_search_eaccess=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_eaccess" >&5
-$as_echo "$ac_cv_search_eaccess" >&6; }
-ac_res=$ac_cv_search_eaccess
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  test "$ac_cv_search_eaccess" = "none required" ||
-                    LIB_EACCESS=$ac_cv_search_eaccess
-fi
-
-    for ac_func in eaccess
-do :
-  ac_fn_c_check_func "$LINENO" "eaccess" "ac_cv_func_eaccess"
-if test "x$ac_cv_func_eaccess" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_EACCESS 1
-_ACEOF
-
-fi
-done
-
-  LIBS=$gl_saved_libs
-
-      fi
-
-
-
-
-
-          GNULIB_EUIDACCESS=1
-
-
-
-
-
-      gl_gnulib_enabled_euidaccess=true
-      if test $HAVE_EUIDACCESS = 0; then
-        func_gl_gnulib_m4code_a9786850e999ae65a836a6041e8e5ed1
-      fi
-      func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c
-      if test $HAVE_EUIDACCESS = 0; then
-        func_gl_gnulib_m4code_stat
-      fi
-    fi
-  }
-  func_gl_gnulib_m4code_getdtablesize ()
-  {
-    if ! $gl_gnulib_enabled_getdtablesize; then
-
-
-
-
-  if test $ac_cv_func_getdtablesize = yes; then
-    # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
-    # up to an unchangeable hard limit; all other platforms correctly
-    # require setrlimit before getdtablesize() can report a larger value.
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getdtablesize works" >&5
-$as_echo_n "checking whether getdtablesize works... " >&6; }
-if test "${gl_cv_func_getdtablesize_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-          cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
-            gl_cv_func_getdtablesize_works="guessing no" ;;
-          *) gl_cv_func_getdtablesize_works="guessing yes" ;;
-         esac
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-        #include <unistd.h>
-int
-main ()
-{
-int size = getdtablesize();
-           if (dup2 (0, getdtablesize()) != -1)
-             return 1;
-           if (size != getdtablesize())
-             return 2;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getdtablesize_works=yes
-else
-  gl_cv_func_getdtablesize_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getdtablesize_works" >&5
-$as_echo "$gl_cv_func_getdtablesize_works" >&6; }
-    case "$gl_cv_func_getdtablesize_works" in
-      *yes) ;;
-      *) REPLACE_GETDTABLESIZE=1 ;;
-    esac
-  else
-    HAVE_GETDTABLESIZE=0
-  fi
-
-      if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getdtablesize.$ac_objext"
-
-        :
-      fi
-
-
-
-
-
-          GNULIB_GETDTABLESIZE=1
-
-
-
-
-
-      gl_gnulib_enabled_getdtablesize=true
-    fi
-  }
-  func_gl_gnulib_m4code_getgroups ()
-  {
-    if ! $gl_gnulib_enabled_getgroups; then
-
-
-
-
-
-        ac_fn_c_check_func "$LINENO" "getgroups" "ac_cv_func_getgroups"
-if test "x$ac_cv_func_getgroups" = x""yes; then :
-
-fi
-
-
-  # If we don't yet have getgroups, see if it's in -lbsd.
-  # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
-  ac_save_LIBS=$LIBS
-  if test $ac_cv_func_getgroups = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getgroups in -lbsd" >&5
-$as_echo_n "checking for getgroups in -lbsd... " >&6; }
-if test "${ac_cv_lib_bsd_getgroups+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getgroups ();
-int
-main ()
-{
-return getgroups ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_bsd_getgroups=yes
-else
-  ac_cv_lib_bsd_getgroups=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_getgroups" >&5
-$as_echo "$ac_cv_lib_bsd_getgroups" >&6; }
-if test "x$ac_cv_lib_bsd_getgroups" = x""yes; then :
-  GETGROUPS_LIB=-lbsd
-fi
-
-  fi
-
-  # Run the program to test the functionality of the system-supplied
-  # getgroups function only if there is such a function.
-  if test $ac_cv_func_getgroups = yes; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working getgroups" >&5
-$as_echo_n "checking for working getgroups... " >&6; }
-if test "${ac_cv_func_getgroups_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in # ((
-                    # Guess yes on glibc systems.
-            *-gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      ac_cv_func_getgroups_works="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-/* On Ultrix 4.3, getgroups (0, 0) always fails.  */
-              return getgroups (0, 0) == -1;
-  ;
-  return 0;
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  ac_cv_func_getgroups_works=yes
-else
-  ac_cv_func_getgroups_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getgroups_works" >&5
-$as_echo "$ac_cv_func_getgroups_works" >&6; }
-  else
-    ac_cv_func_getgroups_works=no
-  fi
-  case "$ac_cv_func_getgroups_works" in
-    *yes)
-
-$as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h
-
-      ;;
-  esac
-  LIBS=$ac_save_LIBS
-
-  if test $ac_cv_func_getgroups != yes; then
-    HAVE_GETGROUPS=0
-  else
-    if test "$ac_cv_type_getgroups" != gid_t \
-       || { case "$ac_cv_func_getgroups_works" in
-              *yes) false;;
-              *) true;;
-            esac
-          }; then
-      REPLACE_GETGROUPS=1
-
-$as_echo "#define GETGROUPS_ZERO_BUG 1" >>confdefs.h
-
-    else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getgroups handles negative values" >&5
-$as_echo_n "checking whether getgroups handles negative values... " >&6; }
-if test "${gl_cv_func_getgroups_works+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                     # Guess yes on glibc systems.
-             *-gnu*) gl_cv_func_getgroups_works="guessing yes" ;;
-                     # If we don't know, assume the worst.
-             *)      gl_cv_func_getgroups_works="guessing no" ;;
-           esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-int size = getgroups (0, 0);
-            gid_t *list = malloc (size * sizeof *list);
-            return getgroups (-1, list) != -1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_getgroups_works=yes
-else
-  gl_cv_func_getgroups_works=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getgroups_works" >&5
-$as_echo "$gl_cv_func_getgroups_works" >&6; }
-      case "$gl_cv_func_getgroups_works" in
-        *yes) ;;
-        *) REPLACE_GETGROUPS=1 ;;
-      esac
-    fi
-  fi
-  test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"
-
-      if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS getgroups.$ac_objext"
-
-      fi
-
-
-
-
-
-          GNULIB_GETGROUPS=1
-
-
-
-
-
-      gl_gnulib_enabled_getgroups=true
-    fi
-  }
-  func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 ()
-  {
-    if ! $gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36; then
-
-
-      gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=true
-    fi
-  }
-  func_gl_gnulib_m4code_a9786850e999ae65a836a6041e8e5ed1 ()
-  {
-    if ! $gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1; then
-
-
-
-
-
-      ac_fn_c_check_func "$LINENO" "group_member" "ac_cv_func_group_member"
-if test "x$ac_cv_func_group_member" = x""yes; then :
-
-else
-
-    HAVE_GROUP_MEMBER=0
-
-fi
-
-
-      if test $HAVE_GROUP_MEMBER = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS group-member.$ac_objext"
-
-
-
-
-      fi
-
-
-
-
-
-          GNULIB_GROUP_MEMBER=1
-
-
-
-
-
-      gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=true
-      if test $HAVE_GROUP_MEMBER = 0; then
-        func_gl_gnulib_m4code_getgroups
-      fi
-      if test $HAVE_GROUP_MEMBER = 0; then
-        func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec
-      fi
-    fi
-  }
-  func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7 ()
-  {
-    if ! $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7; then
-      gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=true
-    fi
-  }
-  func_gl_gnulib_m4code_pathmax ()
-  {
-    if ! $gl_gnulib_enabled_pathmax; then
-
-
-
-      gl_gnulib_enabled_pathmax=true
-    fi
-  }
-  func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c ()
-  {
-    if ! $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c; then
-      gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=true
-    fi
-  }
-  func_gl_gnulib_m4code_secure_getenv ()
-  {
-    if ! $gl_gnulib_enabled_secure_getenv; then
-
-
-
-
-
-  if test $ac_cv_func_secure_getenv = no; then
-    HAVE_SECURE_GETENV=0
-  fi
-
-      if test $HAVE_SECURE_GETENV = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS secure_getenv.$ac_objext"
-
-
-  for ac_func in __secure_getenv
-do :
-  ac_fn_c_check_func "$LINENO" "__secure_getenv" "ac_cv_func___secure_getenv"
-if test "x$ac_cv_func___secure_getenv" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE___SECURE_GETENV 1
-_ACEOF
-
-fi
-done
-
-  if test $ac_cv_func___secure_getenv = no; then
-    for ac_func in issetugid
-do :
-  ac_fn_c_check_func "$LINENO" "issetugid" "ac_cv_func_issetugid"
-if test "x$ac_cv_func_issetugid" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ISSETUGID 1
-_ACEOF
-
-fi
-done
-
-  fi
-
-      fi
-
-
-
-
-
-          GNULIB_SECURE_GETENV=1
-
-
-
-
-
-      gl_gnulib_enabled_secure_getenv=true
-    fi
-  }
-  func_gl_gnulib_m4code_stat ()
-  {
-    if ! $gl_gnulib_enabled_stat; then
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on directories" >&5
-$as_echo_n "checking whether stat handles trailing slashes on directories... " >&6; }
-if test "${gl_cv_func_stat_dir_slash+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "$cross_compiling" = yes; then :
-  case $host_os in
-            mingw*) gl_cv_func_stat_dir_slash="guessing no";;
-            *) gl_cv_func_stat_dir_slash="guessing yes";;
-          esac
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/stat.h>
-
-int
-main ()
-{
-struct stat st; return stat (".", &st) != stat ("./", &st);
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_stat_dir_slash=yes
-else
-  gl_cv_func_stat_dir_slash=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_dir_slash" >&5
-$as_echo "$gl_cv_func_stat_dir_slash" >&6; }
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5
-$as_echo_n "checking whether stat handles trailing slashes on files... " >&6; }
-if test "${gl_cv_func_stat_file_slash+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  touch conftest.tmp
-       # Assume that if we have lstat, we can also check symlinks.
-       if test $ac_cv_func_lstat = yes; then
-         ln -s conftest.tmp conftest.lnk
-       fi
-       if test "$cross_compiling" = yes; then :
-  case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_stat_file_slash="guessing no" ;;
-          esac
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <sys/stat.h>
-
-int
-main ()
-{
-int result = 0;
-      struct stat st;
-      if (!stat ("conftest.tmp/", &st))
-        result |= 1;
-#if HAVE_LSTAT
-      if (!stat ("conftest.lnk/", &st))
-        result |= 2;
-#endif
-      return result;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  gl_cv_func_stat_file_slash=yes
-else
-  gl_cv_func_stat_file_slash=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-       rm -f conftest.tmp conftest.lnk
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_file_slash" >&5
-$as_echo "$gl_cv_func_stat_file_slash" >&6; }
-  case $gl_cv_func_stat_dir_slash in
-    *no) REPLACE_STAT=1
-
-$as_echo "#define REPLACE_FUNC_STAT_DIR 1" >>confdefs.h
-;;
-  esac
-  case $gl_cv_func_stat_file_slash in
-    *no) REPLACE_STAT=1
-
-$as_echo "#define REPLACE_FUNC_STAT_FILE 1" >>confdefs.h
-;;
-  esac
-
-      if test $REPLACE_STAT = 1; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS stat.$ac_objext"
-
-        :
-      fi
-
-
-
-
-
-          GNULIB_STAT=1
-
-
-
-
-
-      gl_gnulib_enabled_stat=true
-      if test $REPLACE_STAT = 1; then
-        func_gl_gnulib_m4code_dosname
-      fi
-      if test $REPLACE_STAT = 1; then
-        func_gl_gnulib_m4code_pathmax
-      fi
-    fi
-  }
-  func_gl_gnulib_m4code_strtoll ()
-  {
-    if ! $gl_gnulib_enabled_strtoll; then
-
-
-
-  if test "$ac_cv_type_long_long_int" = yes; then
-    for ac_func in strtoll
-do :
-  ac_fn_c_check_func "$LINENO" "strtoll" "ac_cv_func_strtoll"
-if test "x$ac_cv_func_strtoll" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_STRTOLL 1
-_ACEOF
-
-fi
-done
-
-    if test $ac_cv_func_strtoll = no; then
-      HAVE_STRTOLL=0
-    fi
-  fi
-
-      if test $HAVE_STRTOLL = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS strtoll.$ac_objext"
-
-
-  :
-
-      fi
-
-
-
-
-
-          GNULIB_STRTOLL=1
-
-
-
-
-
-      gl_gnulib_enabled_strtoll=true
-    fi
-  }
-  func_gl_gnulib_m4code_strtoull ()
-  {
-    if ! $gl_gnulib_enabled_strtoull; then
-
-
-
-  if test "$ac_cv_type_unsigned_long_long_int" = yes; then
-    for ac_func in strtoull
-do :
-  ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull"
-if test "x$ac_cv_func_strtoull" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_STRTOULL 1
-_ACEOF
-
-fi
-done
-
-    if test $ac_cv_func_strtoull = no; then
-      HAVE_STRTOULL=0
-    fi
-  fi
-
-      if test $HAVE_STRTOULL = 0; then
-
-
-
-
-
-
-
-
-  gl_LIBOBJS="$gl_LIBOBJS strtoull.$ac_objext"
-
-
-  :
-
-      fi
-
-
-
-
-
-          GNULIB_STRTOULL=1
-
-
-
-
-
-      gl_gnulib_enabled_strtoull=true
-    fi
-  }
-  func_gl_gnulib_m4code_tempname ()
-  {
-    if ! $gl_gnulib_enabled_tempname; then
-
-
-  :
-
-
-      gl_gnulib_enabled_tempname=true
-      func_gl_gnulib_m4code_secure_getenv
-    fi
-  }
-  func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
-  {
-    if ! $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
-      gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=true
-    fi
-  }
-  if test $HAVE_FACCESSAT = 0; then
-    func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
-  fi
-  if test $HAVE_FACCESSAT = 0; then
-    func_gl_gnulib_m4code_dosname
-  fi
-  if test $HAVE_FACCESSAT = 0; then
-    func_gl_gnulib_m4code_euidaccess
-  fi
-  if test $HAVE_FACCESSAT = 0; then
-    func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
-  fi
-  if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then
-    func_gl_gnulib_m4code_getdtablesize
-  fi
-  if test $HAVE_FDOPENDIR = 0; then
-    func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
-  fi
-  if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
-    func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
-  fi
-  if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
-    func_gl_gnulib_m4code_dosname
-  fi
-  if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
-    func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
-  fi
-  if test $REPLACE_GETOPT = 1; then
-    func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36
-  fi
-  if test $REPLACE_LSTAT = 1; then
-    func_gl_gnulib_m4code_dosname
-  fi
-  if test $REPLACE_LSTAT = 1; then
-    func_gl_gnulib_m4code_stat
-  fi
-  if test $HAVE_MKOSTEMP = 0; then
-    func_gl_gnulib_m4code_tempname
-  fi
-  if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
-    func_gl_gnulib_m4code_stat
-  fi
-  if test $HAVE_READLINKAT = 0; then
-    func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
-  fi
-  if test $HAVE_READLINKAT = 0; then
-    func_gl_gnulib_m4code_dosname
-  fi
-  if test $HAVE_READLINKAT = 0; then
-    func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
-  fi
-  if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
-    func_gl_gnulib_m4code_strtoll
-  fi
-  if { test $HAVE_DECL_STRTOUMAX = 0 || test $REPLACE_STRTOUMAX = 1; } && test $ac_cv_type_unsigned_long_long_int = yes; then
-    func_gl_gnulib_m4code_strtoull
-  fi
-
-   if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then
-  gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE=
-  gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_FALSE='#'
-else
-  gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE='#'
-  gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_FALSE=
-fi
-
-   if $gl_gnulib_enabled_dosname; then
-  gl_GNULIB_ENABLED_dosname_TRUE=
-  gl_GNULIB_ENABLED_dosname_FALSE='#'
-else
-  gl_GNULIB_ENABLED_dosname_TRUE='#'
-  gl_GNULIB_ENABLED_dosname_FALSE=
-fi
-
-   if $gl_gnulib_enabled_euidaccess; then
-  gl_GNULIB_ENABLED_euidaccess_TRUE=
-  gl_GNULIB_ENABLED_euidaccess_FALSE='#'
-else
-  gl_GNULIB_ENABLED_euidaccess_TRUE='#'
-  gl_GNULIB_ENABLED_euidaccess_FALSE=
-fi
-
-   if $gl_gnulib_enabled_getdtablesize; then
-  gl_GNULIB_ENABLED_getdtablesize_TRUE=
-  gl_GNULIB_ENABLED_getdtablesize_FALSE='#'
-else
-  gl_GNULIB_ENABLED_getdtablesize_TRUE='#'
-  gl_GNULIB_ENABLED_getdtablesize_FALSE=
-fi
-
-   if $gl_gnulib_enabled_getgroups; then
-  gl_GNULIB_ENABLED_getgroups_TRUE=
-  gl_GNULIB_ENABLED_getgroups_FALSE='#'
-else
-  gl_GNULIB_ENABLED_getgroups_TRUE='#'
-  gl_GNULIB_ENABLED_getgroups_FALSE=
-fi
-
-   if $gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36; then
-  gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE=
-  gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE='#'
-else
-  gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE='#'
-  gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE=
-fi
-
-   if $gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1; then
-  gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_TRUE=
-  gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_FALSE='#'
-else
-  gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_TRUE='#'
-  gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_FALSE=
-fi
-
-   if $gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7; then
-  gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_TRUE=
-  gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_FALSE='#'
-else
-  gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_TRUE='#'
-  gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_FALSE=
-fi
-
-   if $gl_gnulib_enabled_pathmax; then
-  gl_GNULIB_ENABLED_pathmax_TRUE=
-  gl_GNULIB_ENABLED_pathmax_FALSE='#'
-else
-  gl_GNULIB_ENABLED_pathmax_TRUE='#'
-  gl_GNULIB_ENABLED_pathmax_FALSE=
-fi
-
-   if $gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c; then
-  gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_TRUE=
-  gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_FALSE='#'
-else
-  gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_TRUE='#'
-  gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_FALSE=
-fi
-
-   if $gl_gnulib_enabled_secure_getenv; then
-  gl_GNULIB_ENABLED_secure_getenv_TRUE=
-  gl_GNULIB_ENABLED_secure_getenv_FALSE='#'
-else
-  gl_GNULIB_ENABLED_secure_getenv_TRUE='#'
-  gl_GNULIB_ENABLED_secure_getenv_FALSE=
-fi
-
-   if $gl_gnulib_enabled_stat; then
-  gl_GNULIB_ENABLED_stat_TRUE=
-  gl_GNULIB_ENABLED_stat_FALSE='#'
-else
-  gl_GNULIB_ENABLED_stat_TRUE='#'
-  gl_GNULIB_ENABLED_stat_FALSE=
-fi
-
-   if $gl_gnulib_enabled_strtoll; then
-  gl_GNULIB_ENABLED_strtoll_TRUE=
-  gl_GNULIB_ENABLED_strtoll_FALSE='#'
-else
-  gl_GNULIB_ENABLED_strtoll_TRUE='#'
-  gl_GNULIB_ENABLED_strtoll_FALSE=
-fi
-
-   if $gl_gnulib_enabled_strtoull; then
-  gl_GNULIB_ENABLED_strtoull_TRUE=
-  gl_GNULIB_ENABLED_strtoull_FALSE='#'
-else
-  gl_GNULIB_ENABLED_strtoull_TRUE='#'
-  gl_GNULIB_ENABLED_strtoull_FALSE=
-fi
-
-   if $gl_gnulib_enabled_tempname; then
-  gl_GNULIB_ENABLED_tempname_TRUE=
-  gl_GNULIB_ENABLED_tempname_FALSE='#'
-else
-  gl_GNULIB_ENABLED_tempname_TRUE='#'
-  gl_GNULIB_ENABLED_tempname_FALSE=
-fi
-
-   if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then
-  gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE=
-  gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE='#'
-else
-  gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE='#'
-  gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE=
-fi
-
-  # End of code from modules
-
-
-
-
-
-
-
-
-
-  gltests_libdeps=
-  gltests_ltlibdeps=
-
-
-
-
-
-
-
-
-
-  gl_source_base='tests'
-  gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
-
-  gl_module_indicator_condition=$gltests_WITNESS
-
-
-
-
-
-
-
-
-
-
-  LIBGNU_LIBDEPS="$gl_libdeps"
-
-  LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
-
-
-CFLAGS=$SAVE_CFLAGS
-LIBS=$SAVE_LIBS
-
-if test "${opsys}" = "mingw32"; then
-  CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I $srcdir/nt/inc"
-  # Remove unneeded switches from the value of CC that goes to Makefiles
-  CC=`echo $CC | sed -e "s,$GCC_TEST_OPTIONS,,"`
-fi
-
-case "$opsys" in
-  aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
-
-  darwin)
-   ## The -headerpad option tells ld (see man page) to leave room at the
-   ## end of the header for adding load commands.  Needed for dumping.
-   ## 0x690 is the total size of 30 segment load commands (at 56
-   ## each); under Cocoa 31 commands are required.
-   if test "$HAVE_NS" = "yes"; then
-     libs_nsgui="-framework AppKit"
-     if test "$NS_IMPL_COCOA" = "yes"; then
-        libs_nsgui="$libs_nsgui -framework IOKit"
-     fi
-     headerpad_extra=6C8
-   else
-     libs_nsgui=
-     headerpad_extra=690
-   fi
-   LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
-
-   ## This is here because src/Makefile.in did some extra fiddling around
-   ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
-   ## LD_SWITCH_SYSTEM_TEMACS instead,
-   test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
-     LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
-   ;;
-
-  ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
-  ## find X at run-time.
-  ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
-  ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
-  ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
-  ## had different values in configure (in ac_link) and src/Makefile.in.
-  ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
-  gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
-
-  mingw32)
-   ## MinGW64 does not prepend an underscore to symbols, so we must
-   ## pass a different -entry switch to linker.  FIXME: It is better
-   ## to make the entry points the same by changing unexw32.c.
-   case "$canonical" in
-     x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,_start -Wl,-Map,./temacs.map" ;;
-     *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
-   esac
-   ;;
-
-  openbsd) LD_SWITCH_SYSTEM_TEMACS='-nopie' ;;
-
-  *) LD_SWITCH_SYSTEM_TEMACS= ;;
-esac
-
-if test x$ac_enable_profiling != x ; then
-  case $opsys in
-    *freebsd | gnu-linux) ;;
-    *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
-  esac
-fi
-
-LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
-
-
-
-## MinGW-specific post-link processing of temacs.
-TEMACS_POST_LINK=":"
-ADDSECTION=
-EMACS_HEAPSIZE=
-if test "${opsys}" = "mingw32"; then
-  TEMACS_POST_LINK="\$(MINGW_TEMACS_POST_LINK)"
-  ADDSECTION="../nt/addsection\$(EXEEXT)"
-  ## Preload heap size of temacs.exe in MB.
-  case "$canonical" in
-    x86_64-*-*) EMACS_HEAPSIZE=42 ;;
-    *) EMACS_HEAPSIZE=27 ;;
-  esac
-fi
-
-
-
-
-
-## Common for all window systems
-if test "$window_system" != "none"; then
-
-$as_echo "#define HAVE_WINDOW_SYSTEM 1" >>confdefs.h
-
-  WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
-fi
-
-
-
-
-
-#### Report on what we decided to do.
-#### Report GTK as a toolkit, even if it doesn't use Xt.
-#### It makes printing result more understandable as using GTK sets
-#### toolkit_scroll_bars to yes by default.
-if test "${HAVE_GTK}" = "yes"; then
-  USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
-fi
-
-if test $USE_ACL -ne 0; then
-  acl_summary="yes $LIB_ACL"
-else
-  acl_summary=no
-fi
-
-echo "
-Configured for \`${canonical}'.
-
-  Where should the build process find the source code?    ${srcdir}
-  What compiler should emacs be built with?               ${CC} ${CFLAGS}
-  Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
-  Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
-  Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
-  What window system should Emacs use?                    ${window_system}
-  What toolkit should Emacs use?                          ${USE_X_TOOLKIT}"
-
-if test -n "${x_includes}"; then
-echo "  Where do we find X Windows header files?                ${x_includes}"
-else
-echo "  Where do we find X Windows header files?                Standard dirs"
-fi
-if test -n "${x_libraries}"; then
-echo "  Where do we find X Windows libraries?                   ${x_libraries}"
-else
-echo "  Where do we find X Windows libraries?                   Standard dirs"
-fi
-
-echo "  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}"
-echo "  Does Emacs use -lXpm?                                   ${HAVE_XPM}"
-echo "  Does Emacs use -ljpeg?                                  ${HAVE_JPEG}"
-echo "  Does Emacs use -ltiff?                                  ${HAVE_TIFF}"
-echo "  Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF"
-echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
-echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
-echo "  Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}"
-
-echo "  Does Emacs support sound?                               ${HAVE_SOUND}"
-
-echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
-echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
-echo "  Does Emacs use -lgconf?                                 ${HAVE_GCONF}"
-echo "  Does Emacs use GSettings?                               ${HAVE_GSETTINGS}"
-echo "  Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}"
-echo "  Does Emacs use access control lists?                    ${acl_summary}"
-echo "  Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}"
-echo "  Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}"
-echo "  Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}"
-
-echo "  Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}"
-echo "  Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}"
-echo "  Does Emacs use -lotf?                                   ${HAVE_LIBOTF}"
-echo "  Does Emacs use -lxft?                                   ${HAVE_XFT}"
-echo "  Does Emacs directly use zlib?                           ${HAVE_ZLIB}"
-
-echo "  Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}"
-echo
-
-if test -n "${EMACSDATA}"; then
-   echo "  Environment variable EMACSDATA set to:                  $EMACSDATA"
-fi
-if test -n "${EMACSDOC}"; then
-   echo "  Environment variable EMACSDOC set to:                   $EMACSDOC"
-fi
-
-echo
-
-if test "$HAVE_NS" = "yes"; then
-   echo
-   echo "You must run \"${MAKE-make} install\" in order to test the built application.
-The installed application will go to nextstep/Emacs.app and can be
-run or moved from there."
-   if test "$EN_NS_SELF_CONTAINED" = "yes"; then
-      echo "The application will be fully self-contained."
-    else
-      echo "The lisp resources for the application will be installed under ${prefix}.
-You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
-to run if these resources are not installed."
-   fi
-   echo
-fi
-
-if test "${opsys}" = "cygwin"; then
-  case `uname -r` in
-    1.5.*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: building Emacs on Cygwin 1.5 is not supported." >&5
-$as_echo "$as_me: WARNING: building Emacs on Cygwin 1.5 is not supported." >&2;}
-           echo
-          ;;
-  esac
-fi
-
-# Remove any trailing slashes in these variables.
-test "${prefix}" != NONE &&
-  prefix=`echo "${prefix}" | sed 's,\([^/]\)/*$,\1,'`
-test "${exec_prefix}" != NONE &&
-  exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`
-
-if test "$HAVE_NS" = "yes"; then
-  if test "$NS_IMPL_GNUSTEP" = yes; then
-    ac_config_files="$ac_config_files nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in"
-
-    ns_check_file=Resources/Info-gnustep.plist
-  else
-    ac_config_files="$ac_config_files nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in"
-
-    ns_check_file=Contents/Info.plist
-  fi
-
-fi
-
-SUBDIR_MAKEFILES="lib/Makefile lib-src/Makefile oldXMenu/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile leim/Makefile nextstep/Makefile nt/Makefile"
-
-ac_config_files="$ac_config_files Makefile lib/Makefile lib-src/Makefile oldXMenu/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile leim/Makefile nextstep/Makefile nt/Makefile"
-
-
-opt_makefile=test/automated/Makefile
-
-if test -f "$srcdir/$opt_makefile.in"; then
-  SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
-      ac_config_files="$ac_config_files test/automated/Makefile"
-
-fi
-
-
-opt_makefile=admin/unidata/Makefile
-
-if test -f "$srcdir/$opt_makefile.in"; then
-  SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
-  ac_config_files="$ac_config_files admin/unidata/Makefile"
-
-fi
-
-
-SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
-
-
-
-ac_config_commands="$ac_config_commands src/epaths.h"
-
-
-ac_config_commands="$ac_config_commands src/.gdbinit"
-
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
-  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-
-  (set) 2>&1 |
-    case $as_nl`(ac_space=' '; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
-      sed -n \
-       "s/'/'\\\\''/g;
-         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;; #(
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-) |
-  sed '
-     /^ac_cv_env_/b end
-     t clear
-     :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-  if test -w "$cache_file"; then
-    test "x$cache_file" != "x/dev/null" &&
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
-    cat confcache >$cache_file
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
- if test -n "$EXEEXT"; then
-  am__EXEEXT_TRUE=
-  am__EXEEXT_FALSE='#'
-else
-  am__EXEEXT_TRUE='#'
-  am__EXEEXT_FALSE=
-fi
-
-if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
-  as_fn_error "conditional \"AMDEP\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  as_fn_error "conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${BUILDING_FOR_WINDOWSNT_TRUE}" && test -z "${BUILDING_FOR_WINDOWSNT_FALSE}"; then
-  as_fn_error "conditional \"BUILDING_FOR_WINDOWSNT\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_COND_LIBTOOL_TRUE}" && test -z "${GL_COND_LIBTOOL_FALSE}"; then
-  as_fn_error "conditional \"GL_COND_LIBTOOL\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_ALLOCA_H_TRUE}" && test -z "${GL_GENERATE_ALLOCA_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_ALLOCA_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_BYTESWAP_H_TRUE}" && test -z "${GL_GENERATE_BYTESWAP_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_BYTESWAP_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-
-if test -z "${GL_GENERATE_ERRNO_H_TRUE}" && test -z "${GL_GENERATE_ERRNO_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_ERRNO_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_EXECINFO_H_TRUE}" && test -z "${GL_GENERATE_EXECINFO_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_EXECINFO_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_STDINT_H_TRUE}" && test -z "${GL_GENERATE_STDINT_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_STDINT_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_STDALIGN_H_TRUE}" && test -z "${GL_GENERATE_STDALIGN_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_STDALIGN_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_STDARG_H_TRUE}" && test -z "${GL_GENERATE_STDARG_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_STDARG_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_STDBOOL_H_TRUE}" && test -z "${GL_GENERATE_STDBOOL_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_STDBOOL_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${GL_GENERATE_STDDEF_H_TRUE}" && test -z "${GL_GENERATE_STDDEF_H_FALSE}"; then
-  as_fn_error "conditional \"GL_GENERATE_STDDEF_H\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_TRUE}" && test -z "${gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_dosname_TRUE}" && test -z "${gl_GNULIB_ENABLED_dosname_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_dosname\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_euidaccess_TRUE}" && test -z "${gl_GNULIB_ENABLED_euidaccess_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_euidaccess\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_getdtablesize_TRUE}" && test -z "${gl_GNULIB_ENABLED_getdtablesize_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_getdtablesize\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_getgroups_TRUE}" && test -z "${gl_GNULIB_ENABLED_getgroups_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_getgroups\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_TRUE}" && test -z "${gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_TRUE}" && test -z "${gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_TRUE}" && test -z "${gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_pathmax_TRUE}" && test -z "${gl_GNULIB_ENABLED_pathmax_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_pathmax\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_TRUE}" && test -z "${gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_secure_getenv_TRUE}" && test -z "${gl_GNULIB_ENABLED_secure_getenv_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_secure_getenv\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_stat_TRUE}" && test -z "${gl_GNULIB_ENABLED_stat_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_stat\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_strtoll_TRUE}" && test -z "${gl_GNULIB_ENABLED_strtoll_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoll\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_strtoull_TRUE}" && test -z "${gl_GNULIB_ENABLED_strtoull_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_strtoull\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_tempname_TRUE}" && test -z "${gl_GNULIB_ENABLED_tempname_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_tempname\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_TRUE}" && test -z "${gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_FALSE}"; then
-  as_fn_error "conditional \"gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-
-    gl_libobjs=
-    gl_ltlibobjs=
-    if test -n "$gl_LIBOBJS"; then
-      # Remove the extension.
-      sed_drop_objext='s/\.o$//;s/\.obj$//'
-      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
-        gl_libobjs="$gl_libobjs $i.$ac_objext"
-        gl_ltlibobjs="$gl_ltlibobjs $i.lo"
-      done
-    fi
-    gl_LIBOBJS=$gl_libobjs
-
-    gl_LTLIBOBJS=$gl_ltlibobjs
-
-
-
-    gltests_libobjs=
-    gltests_ltlibobjs=
-    if test -n "$gltests_LIBOBJS"; then
-      # Remove the extension.
-      sed_drop_objext='s/\.o$//;s/\.obj$//'
-      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
-        gltests_libobjs="$gltests_libobjs $i.$ac_objext"
-        gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
-      done
-    fi
-    gltests_LIBOBJS=$gltests_libobjs
-
-    gltests_LTLIBOBJS=$gltests_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-       expr "X$arg" : "X\\(.*\\)$as_nl";
-       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""       $as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$?; test $as_status -eq 0 && as_status=1
-  if test "$3"; then
-    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
-  fi
-  $as_echo "$as_me: error: $1" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-        X"$0" : 'X\(//\)$' \| \
-        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-           s//\1/
-           q
-         }
-         /^X\/\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\/\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='        ';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -p'
-  fi
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$as_dir" : 'X\(//\)[^/]' \| \
-        X"$as_dir" : 'X\(//\)$' \| \
-        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-       test -d "$1/.";
-      else
-       case $1 in #(
-       -*)set "./$1";;
-       esac;
-       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-       ???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by emacs $as_me 24.3.50, which was
-generated by GNU Autoconf 2.65.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-config_headers="$ac_config_headers"
-config_commands="$ac_config_commands"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
-  -q, --quiet, --silent
-                   do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-      --file=FILE[:TEMPLATE]
-                   instantiate the configuration file FILE
-      --header=FILE[:TEMPLATE]
-                   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to the package provider."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-emacs config.status 24.3.50
-configured by $0, generated by GNU Autoconf 2.65,
-  with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2009 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-MKDIR_P='$MKDIR_P'
-AWK='$AWK'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --he | --h)
-    # Conflict between --help and --header
-    as_fn_error "ambiguous option: \`$1'
-Try \`$0 --help' for more information.";;
-  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) as_fn_error "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
-  *) as_fn_append ac_config_targets " $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-  shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-  CONFIG_SHELL='$SHELL'
-  export CONFIG_SHELL
-  exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-#
-# INIT-COMMANDS
-#
-AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
-GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h:src/config.in" ;;
-    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
-    "nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist") CONFIG_FILES="$CONFIG_FILES nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in" ;;
-    "nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop") CONFIG_FILES="$CONFIG_FILES nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in" ;;
-    "nextstep/Cocoa/Emacs.base/Contents/Info.plist") CONFIG_FILES="$CONFIG_FILES nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in" ;;
-    "nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings") CONFIG_FILES="$CONFIG_FILES nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in" ;;
-    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-    "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
-    "lib-src/Makefile") CONFIG_FILES="$CONFIG_FILES lib-src/Makefile" ;;
-    "oldXMenu/Makefile") CONFIG_FILES="$CONFIG_FILES oldXMenu/Makefile" ;;
-    "doc/emacs/Makefile") CONFIG_FILES="$CONFIG_FILES doc/emacs/Makefile" ;;
-    "doc/misc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/misc/Makefile" ;;
-    "doc/lispintro/Makefile") CONFIG_FILES="$CONFIG_FILES doc/lispintro/Makefile" ;;
-    "doc/lispref/Makefile") CONFIG_FILES="$CONFIG_FILES doc/lispref/Makefile" ;;
-    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
-    "lwlib/Makefile") CONFIG_FILES="$CONFIG_FILES lwlib/Makefile" ;;
-    "lisp/Makefile") CONFIG_FILES="$CONFIG_FILES lisp/Makefile" ;;
-    "leim/Makefile") CONFIG_FILES="$CONFIG_FILES leim/Makefile" ;;
-    "nextstep/Makefile") CONFIG_FILES="$CONFIG_FILES nextstep/Makefile" ;;
-    "nt/Makefile") CONFIG_FILES="$CONFIG_FILES nt/Makefile" ;;
-    "test/automated/Makefile") CONFIG_FILES="$CONFIG_FILES test/automated/Makefile" ;;
-    "admin/unidata/Makefile") CONFIG_FILES="$CONFIG_FILES admin/unidata/Makefile" ;;
-    "src/epaths.h") CONFIG_COMMANDS="$CONFIG_COMMANDS src/epaths.h" ;;
-    "src/.gdbinit") CONFIG_COMMANDS="$CONFIG_COMMANDS src/.gdbinit" ;;
-
-  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp=
-  trap 'exit_status=$?
-  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
-' 0
-  trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-if $AWK 'BEGIN { getline <"/dev/null" }' </dev/null 2>/dev/null; then
-  ac_cs_awk_getline=:
-  ac_cs_awk_pipe_init=
-  ac_cs_awk_read_file='
-      while ((getline aline < (F[key])) > 0)
-       print(aline)
-      close(F[key])'
-  ac_cs_awk_pipe_fini=
-else
-  ac_cs_awk_getline=false
-  ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\""
-  ac_cs_awk_read_file='
-      print "|#_!!_#|"
-      print "cat " F[key] " &&"
-      '$ac_cs_awk_pipe_init
-  # The final `:' finishes the AND list.
-  ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }'
-fi
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\r'
-else
-  ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$tmp/subs1.awk" &&
-_ACEOF
-
-# Create commands to substitute file output variables.
-{
-  echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" &&
-  echo 'cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&' &&
-  echo "$ac_subst_files" | sed 's/.*/F["&"]="$&"/' &&
-  echo "_ACAWK" &&
-  echo "_ACEOF"
-} >conf$$files.sh &&
-. ./conf$$files.sh ||
-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-rm -f conf$$files.sh
-
-{
-  echo "cat >conf$$subs.awk <<_ACEOF" &&
-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-  echo "_ACEOF"
-} >conf$$subs.sh ||
-  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  . ./conf$$subs.sh ||
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-
-  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-  if test $ac_delim_n = $ac_delim_num; then
-    break
-  elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
-  N
-  s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
-  for (key in S) S_is_set[key] = 1
-  FS = "\a"
-  \$ac_cs_awk_pipe_init
-}
-{
-  line = $ 0
-  nfields = split(line, field, "@")
-  substed = 0
-  len = length(field[1])
-  for (i = 2; i < nfields; i++) {
-    key = field[i]
-    keylen = length(key)
-    if (S_is_set[key]) {
-      value = S[key]
-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
-      len += length(value) + length(field[++i])
-      substed = 1
-    } else
-      len += 1 + keylen
-  }
-  if (nfields == 3 && !substed) {
-    key = field[2]
-    if (F[key] != "" && line ~ /^[      ]*@.*@[         ]*$/) {
-      \$ac_cs_awk_read_file
-      next
-    }
-  }
-  print line
-}
-\$ac_cs_awk_pipe_fini
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
-  cat
-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
-  || as_fn_error "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[         ]*VPATH[        ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[    ]*\):*/\1/
-s/:*$//
-s/^[^=]*=[      ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
-  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_t"; then
-    break
-  elif $ac_last_try; then
-    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any.  Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[    ]*#[    ]*define[       ][      ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  for (key in D) D_is_set[key] = 1
-  FS = "\a"
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
-  line = \$ 0
-  split(line, arg, " ")
-  if (arg[1] == "#") {
-    defundef = arg[2]
-    mac1 = arg[3]
-  } else {
-    defundef = substr(arg[1], 2)
-    mac1 = arg[2]
-  }
-  split(mac1, mac2, "(") #)
-  macro = mac2[1]
-  prefix = substr(line, 1, index(line, defundef) - 1)
-  if (D_is_set[macro]) {
-    # Preserve the white space surrounding the "#".
-    print prefix "define", macro P[macro] D[macro]
-    next
-  } else {
-    # Replace #undef with comments.  This is necessary, for example,
-    # in the case of _POSIX_SOURCE, which is predefined and required
-    # on some systems where configure will not decide to define it.
-    if (defundef == "undef") {
-      print "/*", prefix defundef, macro, "*/"
-      next
-    }
-  }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-  as_fn_error "could not setup config headers machinery" "$LINENO" 5
-fi # test -n "$CONFIG_HEADERS"
-
-
-eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
-shift
-for ac_tag
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-        # (if the path is not absolute).  The absolute path cannot be DOS-style,
-        # because $ac_f cannot contain `:'.
-        test -f "$ac_f" ||
-          case $ac_f in
-          [\\/$]*) false;;
-          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-          esac ||
-          as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-      esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input='Generated from '`
-         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
-       `' by configure.'
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
-    fi
-    # Neutralize special characters interpreted by sed in replacement strings.
-    case $configure_input in #(
-    *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
-       sed 's/[\\\\&|]/\\\\&/g'`;; #(
-    *) ac_sed_conf_input=$configure_input;;
-    esac
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$tmp/stdin" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$ac_file" : 'X\(//\)[^/]' \| \
-        X"$ac_file" : 'X\(//\)$' \| \
-        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
-  ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
-  case $ac_mode in
-  :F)
-  #
-  # CONFIG_FILE
-  #
-
-  case $INSTALL in
-  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
-  esac
-  ac_MKDIR_P=$MKDIR_P
-  case $MKDIR_P in
-  [\\/$]* | ?:[\\/]* ) ;;
-  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
-  esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
-  p
-  q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  ac_datarootdir_hack='
-  s&@datadir@&$datadir&g
-  s&@docdir@&$docdir&g
-  s&@infodir@&$infodir&g
-  s&@localedir@&$localedir&g
-  s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-s&@MKDIR_P@&$ac_MKDIR_P&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" |
-if $ac_cs_awk_getline; then
-  $AWK -f "$tmp/subs.awk"
-else
-  $AWK -f "$tmp/subs.awk" | $SHELL
-fi >$tmp/out \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined." >&2;}
-
-  rm -f "$tmp/stdin"
-  case $ac_file in
-  -) cat "$tmp/out" && rm -f "$tmp/out";;
-  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
-  esac \
-  || as_fn_error "could not create $ac_file" "$LINENO" 5
- ;;
-  :H)
-  #
-  # CONFIG_HEADER
-  #
-  if test x"$ac_file" != x-; then
-    {
-      $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
-    } >"$tmp/config.h" \
-      || as_fn_error "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
-    else
-      rm -f "$ac_file"
-      mv "$tmp/config.h" "$ac_file" \
-       || as_fn_error "could not create $ac_file" "$LINENO" 5
-    fi
-  else
-    $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
-      || as_fn_error "could not create -" "$LINENO" 5
-  fi
-# Compute "$ac_file"'s index in $config_headers.
-_am_arg="$ac_file"
-_am_stamp_count=1
-for _am_header in $config_headers :; do
-  case $_am_header in
-    $_am_arg | $_am_arg:* )
-      break ;;
-    * )
-      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
-  esac
-done
-echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
-$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$_am_arg" : 'X\(//\)[^/]' \| \
-        X"$_am_arg" : 'X\(//\)$' \| \
-        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$_am_arg" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`/stamp-h$_am_stamp_count
- ;;
-
-  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
-$as_echo "$as_me: executing $ac_file commands" >&6;}
- ;;
-  esac
-
-
-  case $ac_file$ac_mode in
-    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
-  # are listed without --file.  Let's play safe and only enable the eval
-  # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
-  shift
-  for mf
-  do
-    # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
-    # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`$as_dirname -- "$mf" ||
-$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$mf" : 'X\(//\)[^/]' \| \
-        X"$mf" : 'X\(//\)$' \| \
-        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$mf" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`$as_dirname -- "$file" ||
-$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-        X"$file" : 'X\(//\)[^/]' \| \
-        X"$file" : 'X\(//\)$' \| \
-        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)[^/].*/{
-           s//\1/
-           q
-         }
-         /^X\(\/\/\)$/{
-           s//\1/
-           q
-         }
-         /^X\(\/\).*/{
-           s//\1/
-           q
-         }
-         s/.*/./; q'`
-      as_dir=$dirpart/$fdir; as_fn_mkdir_p
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
-  done
-}
- ;;
-    "src/epaths.h":C)
-if test "${opsys}" = "mingw32"; then
-  ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
-else
-  ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
-fi
- ;;
-    "src/.gdbinit":C)
-if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
-  echo "source $srcdir/src/.gdbinit" > src/.gdbinit
-fi
- ;;
-
-  esac
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
-  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit $?
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
diff --git a/autogen/copy_autogen b/autogen/copy_autogen
deleted file mode 100755 (executable)
index 8aacd4d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-## Helper script for those building Emacs from bzr without autoconf etc.
-## This installs some pre-generated versions of the automatically
-## generated files.  It is highly recommended to install the necessary
-## tools instead of using this.  Note that if eg configure.ac
-## is updated, the next time you run make it will attempt to
-## regenerate configure and will fail if you do not have the required
-## tools.  You will have to run this script again.
-
-test ! -d autogen || cd autogen || exit
-
-if test ! -e config.in; then
-    echo "Cannot find autogen/ directory."
-    exit 1
-fi
-
-## Order implied by top-level Makefile's rules, for time-stamps.
-cp -f compile config.guess config.sub depcomp install-sh missing \
-  ../build-aux &&
-cp aclocal.m4 ../ &&
-cp configure ../ &&
-touch ../src/stamp-h.in &&
-cp config.in ../src/ &&
-cp Makefile.in ../lib/ &&
-
-echo "You can now run configure"
diff --git a/autogen/depcomp b/autogen/depcomp
deleted file mode 100755 (executable)
index df8eea7..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2009-04-28.21; # UTC
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
-# Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
-  '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
-     exit 1;
-     ;;
-  -h | --h*)
-    cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
-  depmode     Dependency tracking mode.
-  source      Source file read by `PROGRAMS ARGS'.
-  object      Object file output by `PROGRAMS ARGS'.
-  DEPDIR      directory where to store dependencies.
-  depfile     Dependency file to output.
-  tmpdepfile  Temporary file to use when outputing dependencies.
-  libtool     Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
-    exit $?
-    ;;
-  -v | --v*)
-    echo "depcomp $scriptversion"
-    exit $?
-    ;;
-esac
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
-  echo "depcomp: Variables source, object and depmode must be set" 1>&2
-  exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
-  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags.  We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write.  Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
-  # HP compiler uses -M and no extra arg.
-  gccflag=-M
-  depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
-   # This is just like dashmstdout with a different argument.
-   dashmflag=-xM
-   depmode=dashmstdout
-fi
-
-cygpath_u="cygpath -u -f -"
-if test "$depmode" = msvcmsys; then
-   # This is just like msvisualcpp but w/o cygpath translation.
-   # Just convert the backslash-escaped backslashes to single forward
-   # slashes to satisfy depend.m4
-   cygpath_u="sed s,\\\\\\\\,/,g"
-   depmode=msvisualcpp
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff.  Hmm.
-## Unfortunately, FreeBSD c89 acceptance of flags depends upon
-## the command line argument order; so add the flags where they
-## appear in depend2.am.  Note that the slowdown incurred here
-## affects only configure: in makefiles, %FASTDEP% shortcuts this.
-  for arg
-  do
-    case $arg in
-    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
-    *)  set fnord "$@" "$arg" ;;
-    esac
-    shift # fnord
-    shift # $arg
-  done
-  "$@"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  mv "$tmpdepfile" "$depfile"
-  ;;
-
-gcc)
-## There are various ways to get dependency output from gcc.  Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-##   up in a subdir.  Having to rename by hand is ugly.
-##   (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-##   -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-##   than renaming).
-  if test -z "$gccflag"; then
-    gccflag=-MD,
-  fi
-  "$@" -Wp,"$gccflag$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
-  sed -e 's/^[^:]*: / /' \
-      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header).  We avoid this by adding
-## dummy dependencies for each header file.  Too bad gcc doesn't do
-## this for us directly.
-  tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'.  On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-hp)
-  # This case exists only to let depend.m4 do its work.  It works by
-  # looking at the text of this script.  This case will never be run,
-  # since it is checked for above.
-  exit 1
-  ;;
-
-sgi)
-  if test "$libtool" = yes; then
-    "$@" "-Wp,-MDupdate,$tmpdepfile"
-  else
-    "$@" -MDupdate "$tmpdepfile"
-  fi
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-
-  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
-    echo "$object : \\" > "$depfile"
-
-    # Clip off the initial element (the dependent).  Don't try to be
-    # clever and replace this with sed code, as IRIX sed won't handle
-    # lines with more than a fixed number of characters (4096 in
-    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
-    # the IRIX cc adds comments like `#:fec' to the end of the
-    # dependency line.
-    tr ' ' '
-' < "$tmpdepfile" \
-    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> "$depfile"
-    echo >> "$depfile"
-
-    # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
-   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> "$depfile"
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
-  fi
-  rm -f "$tmpdepfile"
-  ;;
-
-aix)
-  # The C for AIX Compiler uses -M and outputs the dependencies
-  # in a .u file.  In older versions, this file always lives in the
-  # current directory.  Also, the AIX compiler puts `$object:' at the
-  # start of each line; $object doesn't have directory information.
-  # Version 6 uses the directory in both cases.
-  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-  test "x$dir" = "x$object" && dir=
-  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-  if test "$libtool" = yes; then
-    tmpdepfile1=$dir$base.u
-    tmpdepfile2=$base.u
-    tmpdepfile3=$dir.libs/$base.u
-    "$@" -Wc,-M
-  else
-    tmpdepfile1=$dir$base.u
-    tmpdepfile2=$dir$base.u
-    tmpdepfile3=$dir$base.u
-    "$@" -M
-  fi
-  stat=$?
-
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
-    exit $stat
-  fi
-
-  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
-  do
-    test -f "$tmpdepfile" && break
-  done
-  if test -f "$tmpdepfile"; then
-    # Each line is of the form `foo.o: dependent.h'.
-    # Do two passes, one to just change these to
-    # `$object: dependent.h' and one to simply `dependent.h:'.
-    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-    # That's a tab and a space in the [].
-    sed -e 's,^.*\.[a-z]*:[     ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
-  fi
-  rm -f "$tmpdepfile"
-  ;;
-
-icc)
-  # Intel's C compiler understands `-MD -MF file'.  However on
-  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
-  # ICC 7.0 will fill foo.d with something like
-  #    foo.o: sub/foo.c
-  #    foo.o: sub/foo.h
-  # which is wrong.  We want:
-  #    sub/foo.o: sub/foo.c
-  #    sub/foo.o: sub/foo.h
-  #    sub/foo.c:
-  #    sub/foo.h:
-  # ICC 7.1 will output
-  #    foo.o: sub/foo.c sub/foo.h
-  # and will wrap long lines using \ :
-  #    foo.o: sub/foo.c ... \
-  #     sub/foo.h ... \
-  #     ...
-
-  "$@" -MD -MF "$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-  # Each line is of the form `foo.o: dependent.h',
-  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
-  # Do two passes, one to just change these to
-  # `$object: dependent.h' and one to simply `dependent.h:'.
-  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
-  # Some versions of the HPUX 10.20 sed can't process this invocation
-  # correctly.  Breaking it into two sed invocations is a workaround.
-  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
-    sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-hp2)
-  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
-  # compilers, which have integrated preprocessors.  The correct option
-  # to use with these is +Maked; it writes dependencies to a file named
-  # 'foo.d', which lands next to the object file, wherever that
-  # happens to be.
-  # Much of this is similar to the tru64 case; see comments there.
-  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-  test "x$dir" = "x$object" && dir=
-  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-  if test "$libtool" = yes; then
-    tmpdepfile1=$dir$base.d
-    tmpdepfile2=$dir.libs/$base.d
-    "$@" -Wc,+Maked
-  else
-    tmpdepfile1=$dir$base.d
-    tmpdepfile2=$dir$base.d
-    "$@" +Maked
-  fi
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-     rm -f "$tmpdepfile1" "$tmpdepfile2"
-     exit $stat
-  fi
-
-  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
-  do
-    test -f "$tmpdepfile" && break
-  done
-  if test -f "$tmpdepfile"; then
-    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
-    # Add `dependent.h:' lines.
-    sed -ne '2,${
-              s/^ *//
-              s/ \\*$//
-              s/$/:/
-              p
-            }' "$tmpdepfile" >> "$depfile"
-  else
-    echo "#dummy" > "$depfile"
-  fi
-  rm -f "$tmpdepfile" "$tmpdepfile2"
-  ;;
-
-tru64)
-   # The Tru64 compiler uses -MD to generate dependencies as a side
-   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
-   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
-   # dependencies in `foo.d' instead, so we check for that too.
-   # Subdirectories are respected.
-   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-   test "x$dir" = "x$object" && dir=
-   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
-   if test "$libtool" = yes; then
-      # With Tru64 cc, shared objects can also be used to make a
-      # static library.  This mechanism is used in libtool 1.4 series to
-      # handle both shared and static libraries in a single compilation.
-      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
-      #
-      # With libtool 1.5 this exception was removed, and libtool now
-      # generates 2 separate objects for the 2 libraries.  These two
-      # compilations output dependencies in $dir.libs/$base.o.d and
-      # in $dir$base.o.d.  We have to check for both files, because
-      # one of the two compilations can be disabled.  We should prefer
-      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
-      # automatically cleaned when .libs/ is deleted, while ignoring
-      # the former would cause a distcleancheck panic.
-      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
-      tmpdepfile2=$dir$base.o.d          # libtool 1.5
-      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
-      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
-      "$@" -Wc,-MD
-   else
-      tmpdepfile1=$dir$base.o.d
-      tmpdepfile2=$dir$base.d
-      tmpdepfile3=$dir$base.d
-      tmpdepfile4=$dir$base.d
-      "$@" -MD
-   fi
-
-   stat=$?
-   if test $stat -eq 0; then :
-   else
-      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
-      exit $stat
-   fi
-
-   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
-   do
-     test -f "$tmpdepfile" && break
-   done
-   if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a tab and a space in the [].
-      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-   else
-      echo "#dummy" > "$depfile"
-   fi
-   rm -f "$tmpdepfile"
-   ;;
-
-#nosideeffect)
-  # This comment above is used by automake to tell side-effect
-  # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o.
-  "$@" || exit $?
-
-  # Remove the call to Libtool.
-  if test "$libtool" = yes; then
-    while test "X$1" != 'X--mode=compile'; do
-      shift
-    done
-    shift
-  fi
-
-  # Remove `-o $object'.
-  IFS=" "
-  for arg
-  do
-    case $arg in
-    -o)
-      shift
-      ;;
-    $object)
-      shift
-      ;;
-    *)
-      set fnord "$@" "$arg"
-      shift # fnord
-      shift # $arg
-      ;;
-    esac
-  done
-
-  test -z "$dashmflag" && dashmflag=-M
-  # Require at least two characters before searching for `:'
-  # in the target name.  This is to cope with DOS-style filenames:
-  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
-  "$@" $dashmflag |
-    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
-  rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-dashXmstdout)
-  # This case only exists to satisfy depend.m4.  It is never actually
-  # run, as this mode is specially recognized in the preamble.
-  exit 1
-  ;;
-
-makedepend)
-  "$@" || exit $?
-  # Remove any Libtool call
-  if test "$libtool" = yes; then
-    while test "X$1" != 'X--mode=compile'; do
-      shift
-    done
-    shift
-  fi
-  # X makedepend
-  shift
-  cleared=no eat=no
-  for arg
-  do
-    case $cleared in
-    no)
-      set ""; shift
-      cleared=yes ;;
-    esac
-    if test $eat = yes; then
-      eat=no
-      continue
-    fi
-    case "$arg" in
-    -D*|-I*)
-      set fnord "$@" "$arg"; shift ;;
-    # Strip any option that makedepend may not understand.  Remove
-    # the object too, otherwise makedepend will parse it as a source file.
-    -arch)
-      eat=yes ;;
-    -*|$object)
-      ;;
-    *)
-      set fnord "$@" "$arg"; shift ;;
-    esac
-  done
-  obj_suffix=`echo "$object" | sed 's/^.*\././'`
-  touch "$tmpdepfile"
-  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
-  rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile" "$tmpdepfile".bak
-  ;;
-
-cpp)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout.
-  "$@" || exit $?
-
-  # Remove the call to Libtool.
-  if test "$libtool" = yes; then
-    while test "X$1" != 'X--mode=compile'; do
-      shift
-    done
-    shift
-  fi
-
-  # Remove `-o $object'.
-  IFS=" "
-  for arg
-  do
-    case $arg in
-    -o)
-      shift
-      ;;
-    $object)
-      shift
-      ;;
-    *)
-      set fnord "$@" "$arg"
-      shift # fnord
-      shift # $arg
-      ;;
-    esac
-  done
-
-  "$@" -E |
-    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
-    sed '$ s: \\$::' > "$tmpdepfile"
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  cat < "$tmpdepfile" >> "$depfile"
-  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-msvisualcpp)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout.
-  "$@" || exit $?
-
-  # Remove the call to Libtool.
-  if test "$libtool" = yes; then
-    while test "X$1" != 'X--mode=compile'; do
-      shift
-    done
-    shift
-  fi
-
-  IFS=" "
-  for arg
-  do
-    case "$arg" in
-    -o)
-      shift
-      ;;
-    $object)
-      shift
-      ;;
-    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
-       set fnord "$@"
-       shift
-       shift
-       ;;
-    *)
-       set fnord "$@" "$arg"
-       shift
-       shift
-       ;;
-    esac
-  done
-  "$@" -E 2>/dev/null |
-  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::     \1 \\:p' >> "$depfile"
-  echo "       " >> "$depfile"
-  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-msvcmsys)
-  # This case exists only to let depend.m4 do its work.  It works by
-  # looking at the text of this script.  This case will never be run,
-  # since it is checked for above.
-  exit 1
-  ;;
-
-none)
-  exec "$@"
-  ;;
-
-*)
-  echo "Unknown depmode $depmode" 1>&2
-  exit 1
-  ;;
-esac
-
-exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
diff --git a/autogen/install-sh b/autogen/install-sh
deleted file mode 100755 (executable)
index 6781b98..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2009-04-28.21; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-nl='
-'
-IFS=" ""       $nl"
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-no_target_directory=
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
-   or: $0 [OPTION]... SRCFILES... DIRECTORY
-   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
-   or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
-     --help     display this help and exit.
-     --version  display version info and exit.
-
-  -c            (ignored)
-  -C            install only if different (preserve the last data modification time)
-  -d            create directories instead of installing files.
-  -g GROUP      $chgrpprog installed files to GROUP.
-  -m MODE       $chmodprog installed files to MODE.
-  -o USER       $chownprog installed files to USER.
-  -s            $stripprog installed files.
-  -t DIRECTORY  install into DIRECTORY.
-  -T            report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
-  RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
-  case $1 in
-    -c) ;;
-
-    -C) copy_on_change=true;;
-
-    -d) dir_arg=true;;
-
-    -g) chgrpcmd="$chgrpprog $2"
-       shift;;
-
-    --help) echo "$usage"; exit $?;;
-
-    -m) mode=$2
-       case $mode in
-         *' '* | *'    '* | *'
-'*       | *'*'* | *'?'* | *'['*)
-           echo "$0: invalid mode: $mode" >&2
-           exit 1;;
-       esac
-       shift;;
-
-    -o) chowncmd="$chownprog $2"
-       shift;;
-
-    -s) stripcmd=$stripprog;;
-
-    -t) dst_arg=$2
-       shift;;
-
-    -T) no_target_directory=true;;
-
-    --version) echo "$0 $scriptversion"; exit $?;;
-
-    --)        shift
-       break;;
-
-    -*)        echo "$0: invalid option: $1" >&2
-       exit 1;;
-
-    *)  break;;
-  esac
-  shift
-done
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
-  # When -d is used, all remaining arguments are directories to create.
-  # When -t is used, the destination is already specified.
-  # Otherwise, the last argument is the destination.  Remove it from $@.
-  for arg
-  do
-    if test -n "$dst_arg"; then
-      # $@ is not empty: it contains at least $arg.
-      set fnord "$@" "$dst_arg"
-      shift # fnord
-    fi
-    shift # arg
-    dst_arg=$arg
-  done
-fi
-
-if test $# -eq 0; then
-  if test -z "$dir_arg"; then
-    echo "$0: no input file specified." >&2
-    exit 1
-  fi
-  # It's OK to call `install-sh -d' without argument.
-  # This can happen when creating conditional directories.
-  exit 0
-fi
-
-if test -z "$dir_arg"; then
-  trap '(exit $?); exit' 1 2 13 15
-
-  # Set umask so as not to create temps with too-generous modes.
-  # However, 'strip' requires both read and write access to temps.
-  case $mode in
-    # Optimize common cases.
-    *644) cp_umask=133;;
-    *755) cp_umask=22;;
-
-    *[0-7])
-      if test -z "$stripcmd"; then
-       u_plus_rw=
-      else
-       u_plus_rw='% 200'
-      fi
-      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
-    *)
-      if test -z "$stripcmd"; then
-       u_plus_rw=
-      else
-       u_plus_rw=,u+rw
-      fi
-      cp_umask=$mode$u_plus_rw;;
-  esac
-fi
-
-for src
-do
-  # Protect names starting with `-'.
-  case $src in
-    -*) src=./$src;;
-  esac
-
-  if test -n "$dir_arg"; then
-    dst=$src
-    dstdir=$dst
-    test -d "$dstdir"
-    dstdir_status=$?
-  else
-
-    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
-    # might cause directories to be created, which would be especially bad
-    # if $src (and thus $dsttmp) contains '*'.
-    if test ! -f "$src" && test ! -d "$src"; then
-      echo "$0: $src does not exist." >&2
-      exit 1
-    fi
-
-    if test -z "$dst_arg"; then
-      echo "$0: no destination specified." >&2
-      exit 1
-    fi
-
-    dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
-
-    # If destination is a directory, append the input filename; won't work
-    # if double slashes aren't ignored.
-    if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-       echo "$0: $dst_arg: Is a directory" >&2
-       exit 1
-      fi
-      dstdir=$dst
-      dst=$dstdir/`basename "$src"`
-      dstdir_status=0
-    else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-       (dirname "$dst") 2>/dev/null ||
-       expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-            X"$dst" : 'X\(//\)[^/]' \| \
-            X"$dst" : 'X\(//\)$' \| \
-            X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-       echo X"$dst" |
-           sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-                  s//\1/
-                  q
-                }
-                /^X\(\/\/\)[^/].*/{
-                  s//\1/
-                  q
-                }
-                /^X\(\/\/\)$/{
-                  s//\1/
-                  q
-                }
-                /^X\(\/\).*/{
-                  s//\1/
-                  q
-                }
-                s/.*/./; q'
-      `
-
-      test -d "$dstdir"
-      dstdir_status=$?
-    fi
-  fi
-
-  obsolete_mkdir_used=false
-
-  if test $dstdir_status != 0; then
-    case $posix_mkdir in
-      '')
-       # Create intermediate dirs using mode 755 as modified by the umask.
-       # This is like FreeBSD 'install' as of 1997-10-28.
-       umask=`umask`
-       case $stripcmd.$umask in
-         # Optimize common cases.
-         *[2367][2367]) mkdir_umask=$umask;;
-         .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-         *[0-7])
-           mkdir_umask=`expr $umask + 22 \
-             - $umask % 100 % 40 + $umask % 20 \
-             - $umask % 10 % 4 + $umask % 2
-           `;;
-         *) mkdir_umask=$umask,go-w;;
-       esac
-
-       # With -d, create the new directory with the user-specified mode.
-       # Otherwise, rely on $mkdir_umask.
-       if test -n "$dir_arg"; then
-         mkdir_mode=-m$mode
-       else
-         mkdir_mode=
-       fi
-
-       posix_mkdir=false
-       case $umask in
-         *[123567][0-7][0-7])
-           # POSIX mkdir -p sets u+wx bits regardless of umask, which
-           # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-           ;;
-         *)
-           tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-           trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-           if (umask $mkdir_umask &&
-               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-           then
-             if test -z "$dir_arg" || {
-                  # Check for POSIX incompatibilities with -m.
-                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-                  # other-writeable bit of parent directory when it shouldn't.
-                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
-                  case $ls_ld_tmpdir in
-                    d????-?r-*) different_mode=700;;
-                    d????-?--*) different_mode=755;;
-                    *) false;;
-                  esac &&
-                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-                  }
-                }
-             then posix_mkdir=:
-             fi
-             rmdir "$tmpdir/d" "$tmpdir"
-           else
-             # Remove any dirs left behind by ancient mkdir implementations.
-             rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-           fi
-           trap '' 0;;
-       esac;;
-    esac
-
-    if
-      $posix_mkdir && (
-       umask $mkdir_umask &&
-       $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
-      )
-    then :
-    else
-
-      # The umask is ridiculous, or mkdir does not conform to POSIX,
-      # or it failed possibly due to a race condition.  Create the
-      # directory the slow way, step by step, checking for races as we go.
-
-      case $dstdir in
-       /*) prefix='/';;
-       -*) prefix='./';;
-       *)  prefix='';;
-      esac
-
-      eval "$initialize_posix_glob"
-
-      oIFS=$IFS
-      IFS=/
-      $posix_glob set -f
-      set fnord $dstdir
-      shift
-      $posix_glob set +f
-      IFS=$oIFS
-
-      prefixes=
-
-      for d
-      do
-       test -z "$d" && continue
-
-       prefix=$prefix$d
-       if test -d "$prefix"; then
-         prefixes=
-       else
-         if $posix_mkdir; then
-           (umask=$mkdir_umask &&
-            $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-           # Don't fail if two instances are running concurrently.
-           test -d "$prefix" || exit 1
-         else
-           case $prefix in
-             *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-             *) qprefix=$prefix;;
-           esac
-           prefixes="$prefixes '$qprefix'"
-         fi
-       fi
-       prefix=$prefix/
-      done
-
-      if test -n "$prefixes"; then
-       # Don't fail if two instances are running concurrently.
-       (umask $mkdir_umask &&
-        eval "\$doit_exec \$mkdirprog $prefixes") ||
-         test -d "$dstdir" || exit 1
-       obsolete_mkdir_used=true
-      fi
-    fi
-  fi
-
-  if test -n "$dir_arg"; then
-    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
-    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
-    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
-      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
-  else
-
-    # Make a couple of temp file names in the proper directory.
-    dsttmp=$dstdir/_inst.$$_
-    rmtmp=$dstdir/_rm.$$_
-
-    # Trap to clean up those temp files at exit.
-    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
-    # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
-    # and set any options; do chmod last to preserve setuid bits.
-    #
-    # If any of these fail, we abort the whole thing.  If we want to
-    # ignore errors from any of these, just make sure not to ignore
-    # errors from the above "$doit $cpprog $src $dsttmp" command.
-    #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
-    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
-    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
-    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
-    # If -C, don't bother to copy if it wouldn't change the file.
-    if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"    2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
-       set X $old && old=:$2:$4:$5:$6 &&
-       set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
-       test "$old" = "$new" &&
-       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
-    then
-      rm -f "$dsttmp"
-    else
-      # Rename the file to the real destination.
-      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
-      # The rename failed, perhaps because mv can't rename something else
-      # to itself, or perhaps because mv is so ancient that it does not
-      # support -f.
-      {
-       # Now remove or move aside any old file at destination location.
-       # We try this two ways since rm can't unlink itself on some
-       # systems and the destination file might be busy for other
-       # reasons.  In this case, the final cleanup might fail but the new
-       # file should still install successfully.
-       {
-         test ! -f "$dst" ||
-         $doit $rmcmd -f "$dst" 2>/dev/null ||
-         { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-           { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-         } ||
-         { echo "$0: cannot unlink or rename $dst" >&2
-           (exit 1); exit 1
-         }
-       } &&
-
-       # Now rename the file to the real destination.
-       $doit $mvcmd "$dsttmp" "$dst"
-      }
-    fi || exit 1
-
-    trap '' 0
-  fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
diff --git a/autogen/missing b/autogen/missing
deleted file mode 100755 (executable)
index 28055d2..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2009-04-28.21; # UTC
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
-  exit 1
-fi
-
-run=:
-sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
-sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case $1 in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  # Exit code 63 means version mismatch.  This often happens
-  # when the user try to use an ancient version of a tool on
-  # a file that requires a minimum version.  In this case we
-  # we should proceed has if the program had been absent, or
-  # if --run hadn't been passed.
-  if test $? = 63; then
-    run=:
-    msg="probably too old"
-  fi
-  ;;
-
-  -h|--h|--he|--hel|--help)
-    echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
-  -h, --help      display this help and exit
-  -v, --version   output version information and exit
-  --run           try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
-  autom4te     touch the output file, or create a stub one
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
-  help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
-  makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
-\`g' are ignored when checking the name.
-
-Send bug reports to <bug-automake@gnu.org>."
-    exit $?
-    ;;
-
-  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing $scriptversion (GNU Automake)"
-    exit $?
-    ;;
-
-  -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
-    exit 1
-    ;;
-
-esac
-
-# normalize program name to check for.
-program=`echo "$1" | sed '
-  s/^gnu-//; t
-  s/^gnu//; t
-  s/^g//; t'`
-
-# Now exit if we have it, but it failed.  Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).  This is about non-GNU programs, so use $1 not
-# $program.
-case $1 in
-  lex*|yacc*)
-    # Not GNU programs, they don't have --version.
-    ;;
-
-  tar*)
-    if test -n "$run"; then
-       echo 1>&2 "ERROR: \`tar' requires --run"
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       exit 1
-    fi
-    ;;
-
-  *)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       # Could not run --version or --help.  This is probably someone
-       # running `$TOOL --version' or `$TOOL --help' to check whether
-       # $TOOL exists and not knowing $TOOL uses missing.
-       exit 1
-    fi
-    ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case $program in
-  aclocal*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
-         any GNU archive site."
-    touch aclocal.m4
-    ;;
-
-  autoconf*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
-         archive site."
-    touch configure
-    ;;
-
-  autoheader*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
-         from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
-    test -z "$files" && files="config.h"
-    touch_files=
-    for f in $files; do
-      case $f in
-      *:*) touch_files="$touch_files "`echo "$f" |
-                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
-         Grab them from any GNU archive site."
-    find . -type f -name Makefile.am -print |
-          sed 's/\.am$/.in/' |
-          while read f; do touch "$f"; done
-    ;;
-
-  autom4te*)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo "#! /bin/sh"
-       echo "# Created by GNU Automake missing as a replacement of"
-       echo "#  $ $@"
-       echo "exit 0"
-       chmod +x $file
-       exit 1
-    fi
-    ;;
-
-  bison*|yacc*)
-    echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
-         in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
-    rm -f y.tab.c y.tab.h
-    if test $# -ne 1; then
-        eval LASTARG="\${$#}"
-       case $LASTARG in
-       *.y)
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-           if test -f "$SRCFILE"; then
-                cp "$SRCFILE" y.tab.c
-           fi
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-           if test -f "$SRCFILE"; then
-                cp "$SRCFILE" y.tab.h
-           fi
-         ;;
-       esac
-    fi
-    if test ! -f y.tab.h; then
-       echo >y.tab.h
-    fi
-    if test ! -f y.tab.c; then
-       echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex*|flex*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
-         in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
-    rm -f lex.yy.c
-    if test $# -ne 1; then
-        eval LASTARG="\${$#}"
-       case $LASTARG in
-       *.l)
-           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-           if test -f "$SRCFILE"; then
-                cp "$SRCFILE" lex.yy.c
-           fi
-         ;;
-       esac
-    fi
-    if test ! -f lex.yy.c; then
-       echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-        you modified a dependency of a manual page.  You may need the
-        \`Help2man' package in order for those modifications to take
-        effect.  You can get \`Help2man' from any GNU archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo ".ab help2man is required to generate this page"
-       exit $?
-    fi
-    ;;
-
-  makeinfo*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
-         indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
-    # The file to touch is that specified with -o ...
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -z "$file"; then
-      # ... or it is the one specified with @setfilename ...
-      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '
-       /^@setfilename/{
-         s/.* \([^ ]*\) *$/\1/
-         p
-         q
-       }' $infile`
-      # ... or it is derived from the source name (dir/f.texi becomes f.info)
-      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
-    fi
-    # If the file does not exist, the user really needs makeinfo;
-    # let's fail without touching anything.
-    test -f $file || exit 1
-    touch $file
-    ;;
-
-  tar*)
-    shift
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar "$@" && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar "$@" && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-       case $firstarg in
-       *o*)
-           firstarg=`echo "$firstarg" | sed s/o//`
-           tar "$firstarg" "$@" && exit 0
-           ;;
-       esac
-       case $firstarg in
-       *h*)
-           firstarg=`echo "$firstarg" | sed s/h//`
-           tar "$firstarg" "$@" && exit 0
-           ;;
-       esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequisites for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
-    ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
index 3c429b8b5e431b43cc6406e2b1f09b05768c2bc7..fb271f76ddd4f30c98c386c71802df6ed0cd59bc 100755 (executable)
@@ -20,7 +20,7 @@
 # along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 
-cd $1
+cd "$1" || exit 1
 for file in *; do
     case $file in
        *.elc | *.el | term | RCS | CVS | Old | . | .. | =* | *~ | *.orig | *.rej)
index 683bb7062cf9efbc396b849b6465d8e18be67d31..08dc395a5a1f8f5820a64bb761d13bf521d804c3 100644 (file)
@@ -155,10 +155,10 @@ rm -f epaths.tmp
 rem   Create "config.h"\r
 rm -f config.h2 config.tmp\r
 if exist config.in sed -e '' config.in > config.tmp\r
-if exist ..\autogen\config.in sed -e '' ../autogen/config.in > config.tmp\r
+if exist ..\msdos\autogen\config.in sed -e '' ../msdos/autogen/config.in > config.tmp\r
 if "%X11%" == "" goto src4\r
 if exist config.in sed -f ../msdos/sed2x.inp < config.in > config.tmp\r
-if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp\r
+if exist ..\msdos\autogen\config.in sed -f ../msdos/sed2x.inp < ..\msdos\autogen\config.in > config.tmp\r
 :src4\r
 sed -f ../msdos/sed2v2.inp <config.tmp >config.h2\r
 Rem See if they have libxml2 later than v2.2.0 installed\r
@@ -279,7 +279,7 @@ If Exist sys_types.in.h update sys_types.in.h sys_types.in-h
 If Exist time.in.h update time.in.h time.in-h\r
 If Exist unistd.in.h update unistd.in.h unistd.in-h\r
 If Exist Makefile.in sed -f ../msdos/sedlibcf.inp < Makefile.in > makefile.tmp\r
-If Exist ..\autogen\Makefile.in sed -f ../msdos/sedlibcf.inp < ..\autogen\Makefile.in > makefile.tmp\r
+If Exist ..\msdos\autogen\Makefile.in sed -f ../msdos/sedlibcf.inp < ..\msdos\autogen\Makefile.in > makefile.tmp\r
 sed -f ../msdos/sedlibmk.inp < makefile.tmp > Makefile\r
 rm -f makefile.tmp\r
 Rem Create .Po files for new files in lib/\r
index ee6d6959ba69e18ef38b38fbb3bd24ca530c0354..a9baf608bf382df8ac0db7a434d827a8a24f4fec 100644 (file)
@@ -24,6 +24,8 @@ dnl  along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 AC_PREREQ(2.65)
 AC_INIT(emacs, 24.3.50)
 
+test "x$MSYSTEM" = "xMINGW32" && . $srcdir/nt/mingw-cfg.site
+
 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
 dnl and then quoted again for a C string.  Separate options with spaces.
 dnl Add some environment variables, if they were passed via the environment
@@ -419,41 +421,6 @@ AC_ARG_ENABLE(gtk-deprecation-warnings,
                [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
 
-#### Make srcdir absolute, if it isn't already.  It's important to
-#### avoid running the file name through pwd unnecessarily, since pwd can
-#### give you automounter prefixes, which can go away.  We do all this
-#### so Emacs can find its files when run uninstalled.
-## Make sure CDPATH doesn't affect cd (in case PWD is relative).
-unset CDPATH
-case "${srcdir}" in
-  [[\\/]]* | ?:[[\\/]]*) ;;
-  . )
-    ## We may be able to use the $PWD environment variable to make this
-    ## absolute.  But sometimes PWD is inaccurate.
-    ## Note: we used to use $PWD at the end instead of `pwd`,
-    ## but that tested only for a well-formed and valid PWD,
-    ## it did not object when PWD was well-formed and valid but just wrong.
-    if test ".$PWD" != "." && test ".`(cd "$PWD" ; sh -c pwd)`" = ".`pwd`"  ;
-    then
-      srcdir="$PWD"
-    else
-      srcdir=`(cd "$srcdir"; pwd)`
-    fi
-  ;;
-  *  ) srcdir=`(cd "$srcdir"; pwd)` ;;
-esac
-
-#### When building with MinGW inside the MSYS tree, 'pwd' produces
-#### directories relative to the root of the MSYS tree,
-#### e.g. '/home/user/foo' instead of '/d/MSYS/home/user/foo'.  When
-#### such a value of srcdir is written to the top-level Makefile, it
-#### gets propagated to src/epaths.h, and that causes temacs to fail,
-#### because, being a MinGW program that knows nothing of MSYS root
-#### substitution, it cannot find the data directory.  "pwd -W"
-#### produces Windows-style 'd:/foo/bar' absolute directory names, so
-#### we use it here to countermand that lossage.
-test "$MSYSTEM" = "MINGW32" && srcdir=`(cd "$srcdir"; pwd -W | sed -e 's,^\([[A-Za-z]]\):,/\1,')`
-
 ### Canonicalize the configuration name.
 
 AC_CANONICAL_HOST
@@ -1930,12 +1897,14 @@ case "$opsys" in
   darwin|sol2-10) system_malloc=yes ;;
 esac
 
+GMALLOC_OBJ=
 if test "${system_malloc}" = "yes"; then
-  AC_DEFINE(SYSTEM_MALLOC, 1, [Define to use system malloc.])
+  AC_DEFINE([SYSTEM_MALLOC], 1,
+    [Define to 1 to use the system memory allocator, even if it is not
+     Doug Lea style.])
   GNU_MALLOC=no
   GNU_MALLOC_reason="
     (The GNU allocators don't work with this system configuration.)"
-  GMALLOC_OBJ=
   VMLIMIT_OBJ=
 else
   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
@@ -1964,7 +1933,8 @@ if test "$doug_lea_malloc" = "yes" ; then
       (Using Doug Lea's new malloc from the GNU C Library.)"
   fi
   AC_DEFINE(DOUG_LEA_MALLOC, 1,
-           [Define to 1 if you are using the GNU C Library.])
+    [Define to 1 if the system memory allocator is Doug Lea style,
+     with malloc hooks and malloc_set_state.])
 
   ## Use mmap directly for allocating larger buffers.
   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
@@ -3407,11 +3377,18 @@ getrlimit setrlimit shutdown getaddrinfo \
 strsignal setitimer \
 sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
 gai_strerror getline getdelim sync \
-difftime posix_memalign \
+difftime \
 getpwent endpwent getgrent endgrent \
 touchlock \
 cfmakeraw cfsetspeed copysign __executable_start log2)
 
+dnl No need to check for aligned_alloc and posix_memalign if using
+dnl gmalloc.o, as it supplies them.  Don't use these functions on
+dnl Darwin as they are incompatible with unexmacosx.c.
+if test -z "$GMALLOC_OBJ" && test "$opsys" != darwin; then
+  AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
+fi
+
 ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
 ## has a broken `rint' in some library versions including math library
 ## version number A.09.05.
@@ -4747,7 +4724,7 @@ CFLAGS=$SAVE_CFLAGS
 LIBS=$SAVE_LIBS
 
 if test "${opsys}" = "mingw32"; then
-  CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I $srcdir/nt/inc"
+  CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
   # Remove unneeded switches from the value of CC that goes to Makefiles
   CC=`echo $CC | sed -e "s,$GCC_TEST_OPTIONS,,"`
 fi
@@ -5051,9 +5028,12 @@ else
 fi
 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
 
+dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
+dnl is not yet set, sigh.  Or we could use ../$srcdir/src/.gdbinit,
+dnl or a symlink?
 AC_CONFIG_COMMANDS([src/.gdbinit], [
 if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
-  echo "source $srcdir/src/.gdbinit" > src/.gdbinit
+  echo "source $ac_abs_top_srcdir/src/.gdbinit" > src/.gdbinit
 fi
 ])
 
index 389757eee6599d44f959624e51e922742ed92ae9..7f051e751e53b70486d6906ddc37daed669f8811 100644 (file)
@@ -1,3 +1,25 @@
+2013-11-04  Glenn Morris  <rgm@gnu.org>
+
+       * cmdargs.texi (Action Arguments): Mention that `-L :...' appends.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * cmdargs.texi (Action Arguments): Clarify `-L' a bit.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * files.texi, glossary.texi, killing.texi, search.texi, sending.texi:
+       Nuke @refill.
+
+       * Makefile.in (install-dvi, install-html, install-pdf)
+       (install-ps, uninstall-dvi, uninstall-html, uninstall-ps)
+       (uninstall-pdf): Quote entities that might contain whitespace.
+
+2013-10-20  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * custom.texi (Init Syntax, Terminal Init, Terminal Init):
+       Remove @refill.
+
 2013-10-13  Glenn Morris  <rgm@gnu.org>
 
        * ack.texi (Acknowledgments): Comment out old alpha stuff.
index bf9f8152ad467d2bd3d3965bdd8f9fe1af303666..9c4a90db4aa1868b32c67f16dd7eb4648d369f9e 100644 (file)
@@ -229,21 +229,21 @@ dist:
 .PHONY: install-dvi install-html install-pdf install-ps install-doc
 
 install-dvi: dvi
-       umask 022; $(MKDIR_P) $(DESTDIR)$(dvidir)
-       $(INSTALL_DATA) $(DVI_TARGETS) $(DESTDIR)$(dvidir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(dvidir)"
+       $(INSTALL_DATA) $(DVI_TARGETS) "$(DESTDIR)$(dvidir)"
 install-html: html
-       umask 022; $(MKDIR_P) $(DESTDIR)$(htmldir)
-       $(INSTALL_DATA) $(HTML_TARGETS) $(DESTDIR)$(htmldir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+       $(INSTALL_DATA) $(HTML_TARGETS) "$(DESTDIR)$(htmldir)"
 install-pdf: pdf
-        umask 022;$(MKDIR_P) $(DESTDIR)$(pdfdir)
-       $(INSTALL_DATA) $(PDF_TARGETS) $(DESTDIR)$(pdfdir)
+        umask 022;$(MKDIR_P) "$(DESTDIR)$(pdfdir)"
+       $(INSTALL_DATA) $(PDF_TARGETS) "$(DESTDIR)$(pdfdir)"
 install-ps: ps
-       umask 022; $(MKDIR_P) $(DESTDIR)$(psdir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(psdir)"
        for file in $(PS_TARGETS); do \
-         $(INSTALL_DATA) $${file} $(DESTDIR)$(psdir); \
+         $(INSTALL_DATA) $${file} "$(DESTDIR)$(psdir)"; \
          [ -n "${GZIP_PROG}" ] || continue; \
-         rm -f $(DESTDIR)$(psdir)/$${file}.gz; \
-         ${GZIP_PROG} -9n $(DESTDIR)$(psdir)/$${file}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}.gz"; \
+         ${GZIP_PROG} -9n "$(DESTDIR)$(psdir)/$${file}"; \
        done
 
 ## Top-level Makefile installs the info pages.
@@ -254,20 +254,20 @@ install-doc: install-dvi install-html install-pdf install-ps
 
 uninstall-dvi:
        for file in $(DVI_TARGETS); do \
-         rm -f $(DESTDIR)$(dvidir)/$${file}; \
+         rm -f "$(DESTDIR)$(dvidir)/$${file}"; \
        done
 uninstall-html:
        for file in $(HTML_TARGETS); do \
-         rm -f $(DESTDIR)$(htmldir)/$${file}; \
+         rm -f "$(DESTDIR)$(htmldir)/$${file}"; \
        done
 uninstall-ps:
        ext= ; [ -n "${GZIP_PROG}" ] && ext=.gz; \
        for file in $(PS_TARGETS); do \
-         rm -f $(DESTDIR)$(psdir)/$${file}$${ext}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}$${ext}"; \
        done
 uninstall-pdf:
        for file in $(PDF_TARGETS); do \
-         rm -f $(DESTDIR)$(pdfdir)/$${file}; \
+         rm -f "$(DESTDIR)$(pdfdir)/$${file}"; \
        done
 
 uninstall-doc: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
index 3dc64fdd127f357868a2b3d3cd273a32f3558dcb..d0f5f1e06b1e4eb2b47b30fa4223260e10a35784 100644 (file)
@@ -135,7 +135,12 @@ visited.
 @opindex -L
 @itemx --directory=@var{dir}
 @opindex --directory
-Add directory @var{dir} to the variable @code{load-path}.
+Prepend directory @var{dir} to the variable @code{load-path}.
+If you specify multiple @samp{-L} options, Emacs preserves the
+relative order; i.e., using @samp{-L /foo -L /bar} results in
+a @code{load-path} of the form @code{("/foo" "/bar" @dots{})}.
+If @var{dir} begins with @samp{:}, Emacs removes the @samp{:} and
+appends (rather than prepends) the remainder to @code{load-path}.
 
 @item -f @var{function}
 @opindex -f
index f3e07fd8ba0b2f66b7d993591e94dae9ea180436..741028cc0a88be93f99f6089ff5d0a9bac084cde 100644 (file)
@@ -2188,7 +2188,7 @@ sequences are mandatory.
 @samp{\C-} can be used as a prefix for a control character, as in
 @samp{\C-s} for @acronym{ASCII} control-S, and @samp{\M-} can be used as a prefix for
 a Meta character, as in @samp{\M-a} for @kbd{Meta-A} or @samp{\M-\C-a} for
-@kbd{Control-Meta-A}.@refill
+@kbd{Control-Meta-A}.
 
 @xref{Init Non-ASCII}, for information about including
 non-@acronym{ASCII} in your init file.
@@ -2451,7 +2451,7 @@ it is run on that type of terminal.  For a terminal type named
 found by searching the directories @code{load-path} as usual and trying the
 suffixes @samp{.elc} and @samp{.el}.  Normally it appears in the
 subdirectory @file{term} of the directory where most Emacs libraries are
-kept.@refill
+kept.
 
   The usual purpose of the terminal-specific library is to map the
 escape sequences used by the terminal's function keys onto more
@@ -2466,7 +2466,7 @@ function keys that Termcap does not specify.
 before the first hyphen is significant in choosing the library name.
 Thus, terminal types @samp{aaa-48} and @samp{aaa-30-rv} both use
 the library @file{term/aaa}.  The code in the library can use
-@code{(getenv "TERM")} to find the full terminal type name.@refill
+@code{(getenv "TERM")} to find the full terminal type name.
 
 @vindex term-file-prefix
   The library's name is constructed by concatenating the value of the
index 1ebe4caa290f9abfb4821b8e27a91cb9c2fbeb65..4117248cbe4631fd2c83d97de49e148d3e631a6c 100644 (file)
@@ -1089,7 +1089,7 @@ of data with the command @kbd{M-x recover-file @key{RET} @var{file}
 restores the contents from its auto-save file @file{#@var{file}#}.
 You can then save with @kbd{C-x C-s} to put the recovered text into
 @var{file} itself.  For example, to recover file @file{foo.c} from its
-auto-save file @file{#foo.c#}, do:@refill
+auto-save file @file{#foo.c#}, do:
 
 @example
 M-x recover-file @key{RET} foo.c @key{RET}
index e4693a5293f85b29b87df17b4b823354add534e4..c8b4b40416f1318c597d19b5009d85170db1ad37 100644 (file)
@@ -256,7 +256,7 @@ abbreviation for a name into the entire name.  Completion is done for
 minibuffer (q.v.@:) arguments when the set of possible valid inputs
 is known; for example, on command names, buffer names, and
 file names.  Completion usually occurs when @key{TAB}, @key{SPC} or
-@key{RET} is typed.  @xref{Completion}.@refill
+@key{RET} is typed.  @xref{Completion}.
 
 @anchor{Glossary---Continuation Line}
 @item Continuation Line
index cb33327faa1e6d5962878df4a6c8abbf2f8c9230..30b3a2c5ff0a36e2ad71a464526ddb8628b5989e 100644 (file)
@@ -423,7 +423,7 @@ ring.  But you can force it to append by first typing the command
 tells the following command, if it is a kill command, to append the text
 it kills to the last killed text, instead of starting a new entry.  With
 @kbd{C-M-w}, you can kill several separated pieces of text and
-accumulate them to be yanked back in one place.@refill
+accumulate them to be yanked back in one place.
 
   A kill command following @kbd{M-w} (@code{kill-ring-save}) does not
 append to the text that @kbd{M-w} copied into the kill ring.
index ead7c3cbf1631863622a550fe82d50716d3bbc86..13e61b7026486a6115a9b9ed39b63208d85b754e 100644 (file)
@@ -668,7 +668,7 @@ it possible to match the rest of the pattern.  For example, in matching
 tries to match all three @samp{a}s; but the rest of the pattern is
 @samp{ar} and there is only @samp{r} left to match, so this try fails.
 The next alternative is for @samp{a*} to match only two @samp{a}s.
-With this choice, the rest of the regexp matches successfully.@refill
+With this choice, the rest of the regexp matches successfully.
 
 @item @kbd{+}
 is a postfix operator, similar to @samp{*} except that it must match
@@ -830,11 +830,11 @@ either @var{a} matches it or @var{b} matches it.  It works by trying to
 match @var{a}, and if that fails, by trying to match @var{b}.
 
 Thus, @samp{foo\|bar} matches either @samp{foo} or @samp{bar}
-but no other string.@refill
+but no other string.
 
 @samp{\|} applies to the largest possible surrounding expressions.  Only a
 surrounding @samp{\( @dots{} \)} grouping can limit the grouping power of
-@samp{\|}.@refill
+@samp{\|}.
 
 Full backtracking capability exists to handle multiple uses of @samp{\|}.
 
@@ -850,7 +850,7 @@ Thus, @samp{\(foo\|bar\)x} matches either @samp{foox} or @samp{barx}.
 To enclose a complicated expression for the postfix operators @samp{*},
 @samp{+} and @samp{?} to operate on.  Thus, @samp{ba\(na\)*} matches
 @samp{bananana}, etc., with any (zero or more) number of @samp{na}
-strings.@refill
+strings.
 
 @item
 To record a matched substring for future reference.
@@ -912,7 +912,7 @@ matches the empty string, but only at point.
 matches the empty string, but only at the beginning or
 end of a word.  Thus, @samp{\bfoo\b} matches any occurrence of
 @samp{foo} as a separate word.  @samp{\bballs?\b} matches
-@samp{ball} or @samp{balls} as a separate word.@refill
+@samp{ball} or @samp{balls} as a separate word.
 
 @samp{\b} matches at the beginning or end of the buffer
 regardless of what text appears next to it.
@@ -1005,7 +1005,7 @@ searching through, if you specify the text in lower case.  Thus, if
 you specify searching for @samp{foo}, then @samp{Foo} and @samp{foo}
 also match.  Regexps, and in particular character sets, behave
 likewise: @samp{[ab]} matches @samp{a} or @samp{A} or @samp{b} or
-@samp{B}.@refill
+@samp{B}.
 
   An upper-case letter anywhere in the incremental search string makes
 the search case-sensitive.  Thus, searching for @samp{Foo} does not find
index 1402d8a85be20df643fadad42bbb4f42cf173df4..ac723fb63ad07ec52be50ef1ea3b3520e8c6d7d4 100644 (file)
@@ -256,7 +256,7 @@ This means that @var{nick} should expand into @var{fulladdresses},
 where @var{fulladdresses} can be either a single address, or multiple
 addresses separated with spaces.  For instance, to make @code{maingnu}
 stand for @code{gnu@@gnu.org} plus a local address of your own, put in
-this line:@refill
+this line:
 
 @example
 alias maingnu gnu@@gnu.org local-gnu
index ec082eecb528fe093493925b1c14c98533b521cb..2e6164968c391cea7d0256236c9478ca03320e99 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (install-dvi, install-html, install-pdf)
+       (install-ps, uninstall-dvi, uninstall-html, uninstall-ps)
+       (uninstall-pdf): Quote entities that might contain whitespace.
+
 2013-09-01  Glenn Morris  <rgm@gnu.org>
 
        * emacs-lisp-intro.texi (beginning-of-buffer complete):
index 363e12215b3b06c71831eb02a274f98649ab0082..9a643c004ed8ff72f634ef7577e2107cc5682e53 100644 (file)
@@ -145,21 +145,21 @@ dist:
 .PHONY: install-dvi install-html install-pdf install-ps install-doc
 
 install-dvi: dvi
-       umask 022; $(MKDIR_P) $(DESTDIR)$(dvidir)
-       $(INSTALL_DATA) $(DVI_TARGETS) $(DESTDIR)$(dvidir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(dvidir)"
+       $(INSTALL_DATA) $(DVI_TARGETS) "$(DESTDIR)$(dvidir)"
 install-html: html
-       umask 022; $(MKDIR_P) $(DESTDIR)$(htmldir)
-       $(INSTALL_DATA) $(HTML_TARGETS) $(DESTDIR)$(htmldir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+       $(INSTALL_DATA) $(HTML_TARGETS) "$(DESTDIR)$(htmldir)"
 install-pdf: pdf
-        umask 022;$(MKDIR_P) $(DESTDIR)$(pdfdir)
-       $(INSTALL_DATA) $(PDF_TARGETS) $(DESTDIR)$(pdfdir)
+        umask 022;$(MKDIR_P) "$(DESTDIR)$(pdfdir)"
+       $(INSTALL_DATA) $(PDF_TARGETS) "$(DESTDIR)$(pdfdir)"
 install-ps: ps
-       umask 022; $(MKDIR_P) $(DESTDIR)$(psdir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(psdir)"
        for file in $(PS_TARGETS); do \
-         $(INSTALL_DATA) $${file} $(DESTDIR)$(psdir); \
+         $(INSTALL_DATA) $${file} "$(DESTDIR)$(psdir)"; \
          [ -n "${GZIP_PROG}" ] || continue; \
-         rm -f $(DESTDIR)$(psdir)/$${file}.gz; \
-         ${GZIP_PROG} -9n $(DESTDIR)$(psdir)/$${file}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}.gz"; \
+         ${GZIP_PROG} -9n "$(DESTDIR)$(psdir)/$${file}"; \
        done
 
 ## Top-level Makefile installs the info pages.
@@ -170,20 +170,20 @@ install-doc: install-dvi install-html install-pdf install-ps
 
 uninstall-dvi:
        for file in $(DVI_TARGETS); do \
-         rm -f $(DESTDIR)$(dvidir)/$${file}; \
+         rm -f "$(DESTDIR)$(dvidir)/$${file}"; \
        done
 uninstall-html:
        for file in $(HTML_TARGETS); do \
-         rm -f $(DESTDIR)$(htmldir)/$${file}; \
+         rm -f "$(DESTDIR)$(htmldir)/$${file}"; \
        done
 uninstall-ps:
        ext= ; [ -n "${GZIP_PROG}" ] && ext=.gz; \
        for file in $(PS_TARGETS); do \
-         rm -f $(DESTDIR)$(psdir)/$${file}$${ext}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}$${ext}"; \
        done
 uninstall-pdf:
        for file in $(PDF_TARGETS); do \
-         rm -f $(DESTDIR)$(pdfdir)/$${file}; \
+         rm -f "$(DESTDIR)$(pdfdir)/$${file}"; \
        done
 
 uninstall-doc: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
index 426591500588061ad6a01a80d0196ca96ab37987..f4fc1acfa692563b3df6ff1daa02ce15a86db87f 100644 (file)
@@ -1,6 +1,101 @@
+2013-11-17  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * os.texi (Time Parsing):
+       (Processor Run Time, Input Modes, Terminal Output): Minor fixes.
+
+2013-11-14  Glenn Morris  <rgm@gnu.org>
+
+       * loading.texi (Library Search): Update section.
+
+2013-11-11  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * os.texi (User Identification, Time of Day, Time Conversion):
+       Minor fixes.
+
+2013-11-10  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * keymaps.texi (Tool Bar): Mention that Gtk+/NS ignores item 1 to 3.
+
+2013-11-09  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * os.texi (Startup Summary): Add an index about startup screen.
+       Typo fix.
+       (Command-Line Arguments): Add cross-reference for `dump-emacs'.
+
+2013-11-08  Eli Zaretskii  <eliz@gnu.org>
+
+       * display.texi (Truncation): Document that cache-long-scans is now
+       non-nil by default.  (Bug#15797)
+
+2013-11-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * lists.texi (Rearrangement): Fix indexing.
+
+       * display.texi (Bidirectional Display): Fix indexing.
+
+2013-11-05  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * lists.texi (Rearrangement): Improve indexing.
+
+       * display.texi (Glyphs): Add an index for glyph code.
+       (Bidirectional Display): Improve indexing.
+
+2013-11-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * display.texi (Face Attributes): Document :distant-foreground.
+
+2013-10-30  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Abstract Display): Improve indexing.
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * display.texi (Selective Display): Discourage the use of explicit
+       selective display.
+
+2013-10-29  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Showing Images): Add an index for image-size.
+       Use @code instead of @var for a normal variable.
+       (Multi-Frame Images): Improve indexing.
+       (Button Buffer Commands): Use @code instead of @var for a normal variable.
+       (Abstract Display): Explain the meaning of Ewoc.
+
+2013-10-27  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Image Descriptors): Improve indexing.
+
+2013-10-26  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Fringe Indicators): Add indexes for fringe indicators.
+       (Customizing Bitmaps): Add an index for customizing fringe bitmaps.
+
+2013-10-25  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Fontsets): Minor wording fix.
+       (Low-Level Font): Improve indexing.
+
+       * nonascii.texi (Character Properties): Add an index for script symbols.
+
+2013-10-24  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * display.texi (Face Remapping): Add indexes for face remapping.
+       (Font Selection): Add indexes.
+       (Low-Level Font): Add an index for font registry.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * eval.texi, files.texi, intro.texi, objects.texi, searching.texi:
+       Nuke @refill.
+
+       * Makefile.in (install-dvi, install-html, install-pdf)
+       (install-ps, uninstall-dvi, uninstall-html, uninstall-ps)
+       (uninstall-pdf): Quote entities that might contain whitespace.
+
 2013-10-19  Xue Fuqiao  <xfq.free@gmail.com>
 
-       * display.texi (Face Attributes): Add indexes for the ‘:box’ face attribute.
+       * display.texi (Face Attributes): Add indexes for the ‘:box’
+       face attribute.
 
 2013-10-18  Xue Fuqiao  <xfq.free@gmail.com>
 
index 164646ac4332f96632e838c3b67e88c97a8c43b2..e2cc9ac088a9eaa925253b2dfed69c85394bead7 100644 (file)
@@ -201,21 +201,21 @@ dist:
 .PHONY: install-dvi install-html install-pdf install-ps install-doc
 
 install-dvi: dvi
-       umask 022; $(MKDIR_P) $(DESTDIR)$(dvidir)
-       $(INSTALL_DATA) $(DVI_TARGETS) $(DESTDIR)$(dvidir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(dvidir)"
+       $(INSTALL_DATA) $(DVI_TARGETS) "$(DESTDIR)$(dvidir)"
 install-html: html
-       umask 022; $(MKDIR_P) $(DESTDIR)$(htmldir)
-       $(INSTALL_DATA) $(HTML_TARGETS) $(DESTDIR)$(htmldir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+       $(INSTALL_DATA) $(HTML_TARGETS) "$(DESTDIR)$(htmldir)"
 install-pdf: pdf
-        umask 022;$(MKDIR_P) $(DESTDIR)$(pdfdir)
-       $(INSTALL_DATA) $(PDF_TARGETS) $(DESTDIR)$(pdfdir)
+        umask 022;$(MKDIR_P) "$(DESTDIR)$(pdfdir)"
+       $(INSTALL_DATA) $(PDF_TARGETS) "$(DESTDIR)$(pdfdir)"
 install-ps: ps
-       umask 022; $(MKDIR_P) $(DESTDIR)$(psdir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(psdir)"
        for file in $(PS_TARGETS); do \
-         $(INSTALL_DATA) $${file} $(DESTDIR)$(psdir); \
+         $(INSTALL_DATA) $${file} "$(DESTDIR)$(psdir)"; \
          [ -n "${GZIP_PROG}" ] || continue; \
-         rm -f $(DESTDIR)$(psdir)/$${file}.gz; \
-         ${GZIP_PROG} -9n $(DESTDIR)$(psdir)/$${file}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}.gz"; \
+         ${GZIP_PROG} -9n "$(DESTDIR)$(psdir)/$${file}"; \
        done
 
 ## Top-level Makefile installs the info pages.
@@ -226,20 +226,20 @@ install-doc: install-dvi install-html install-pdf install-ps
 
 uninstall-dvi:
        for file in $(DVI_TARGETS); do \
-         rm -f $(DESTDIR)$(dvidir)/$${file}; \
+         rm -f "$(DESTDIR)$(dvidir)/$${file}"; \
        done
 uninstall-html:
        for file in $(HTML_TARGETS); do \
-         rm -f $(DESTDIR)$(htmldir)/$${file}; \
+         rm -f "$(DESTDIR)$(htmldir)/$${file}"; \
        done
 uninstall-ps:
        ext= ; [ -n "${GZIP_PROG}" ] && ext=.gz; \
        for file in $(PS_TARGETS); do \
-         rm -f $(DESTDIR)$(psdir)/$${file}$${ext}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}$${ext}"; \
        done
 uninstall-pdf:
        for file in $(PDF_TARGETS); do \
-         rm -f $(DESTDIR)$(pdfdir)/$${file}; \
+         rm -f "$(DESTDIR)$(pdfdir)/$${file}"; \
        done
 
 uninstall-doc: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
index cd2626043d76da74090efaddee9ecb9397f06c19..eeede08ecd9e4fc10117fbb71fc2ca65b12066b9 100644 (file)
@@ -214,19 +214,16 @@ A line prefix may also be specified for regions of text using the
 over the @code{line-prefix} variable.  @xref{Special Properties}.
 @end defvar
 
-  If your buffer contains @emph{very} long lines, and you use
-continuation to display them, computing the continuation lines can
-make redisplay slow.  The column computation and indentation functions
-also become slow.  Then you might find it advisable to set
-@code{cache-long-scans} to @code{t}.
+  If your buffer contains only very short lines, you might find it
+advisable to set @code{cache-long-scans} to @code{nil}.
 
 @defvar cache-long-scans
-If this variable is non-@code{nil}, various indentation and motion
-functions, and Emacs redisplay, cache the results of scanning the
-buffer, and consult the cache to avoid rescanning regions of the buffer
-unless they are modified.
+If this variable is non-@code{nil} (the default), various indentation
+and motion functions, and Emacs redisplay, cache the results of
+scanning the buffer, and consult the cache to avoid rescanning regions
+of the buffer unless they are modified.
 
-Turning on the cache slows down processing of short lines somewhat.
+Turning off the cache speeds up processing of short lines somewhat.
 
 This variable is automatically buffer-local in every buffer.
 @end defvar
@@ -962,11 +959,10 @@ make it invisible again.
 hiding certain lines on the screen.
 
 @cindex explicit selective display
-  The first variant, explicit selective display, is designed for use
-in a Lisp program: it controls which lines are hidden by altering the
-text.  This kind of hiding in some ways resembles the effect of the
-@code{invisible} property (@pxref{Invisible Text}), but the two
-features are different and do not work the same way.
+  The first variant, explicit selective display, was designed for use in a Lisp
+program: it controls which lines are hidden by altering the text.  This kind of
+hiding is now obsolete; instead you can get the same effect with the
+@code{invisible} property (@pxref{Invisible Text}).
 
   In the second variant, the choice of lines to hide is made
 automatically based on indentation.  This variant is designed to be a
@@ -2037,6 +2033,15 @@ name, or a hexadecimal color specification.  @xref{Color Names}.  On
 black-and-white displays, certain shades of gray are implemented by
 stipple patterns.
 
+@item :distant-foreground
+Alternative foreground color, a string.  This is like @code{:foreground}
+but the color is only used as a foreground when the background color is
+near to the foreground that would have been used.  This is useful for
+example when marking text (i.e. the region face).  If the text has a foreground 
+that is visible with the region face, that foreground is used.
+If the foreground is near the region face background,
+@code{:distant-foreground} is used instead so the text is readable.
+
 @item :background
 Background color, a string.  The value can be a system-defined color
 name, or a hexadecimal color specification.  @xref{Color Names}.
@@ -2392,6 +2397,7 @@ For example,
 @end example
 @end defun
 
+@c FIXME: Add an index for "relative face attribute", maybe here?  --xfq
 @defun face-attribute-relative-p attribute value
 This function returns non-@code{nil} if @var{value}, when used as the
 value of the face attribute @var{attribute}, is relative.  This means
@@ -2650,6 +2656,8 @@ then the new definition of the @code{mode-line} face inherits from the
 @code{mode-line} face.
 @end defvar
 
+@cindex relative remapping, faces
+@cindex base remapping, faces
   The following functions implement a higher-level interface to
 @code{face-remapping-alist}.  Most Lisp code should use these
 functions instead of setting @code{face-remapping-alist} directly, to
@@ -2861,6 +2869,8 @@ these are used for messages in @file{*Compilation*} buffers.
 
 @node Font Selection
 @subsection Font Selection
+@cindex font selection
+@cindex selecting a font
 
   Before Emacs can draw a character on a graphical display, it must
 select a @dfn{font} for that character@footnote{In this context, the
@@ -2931,6 +2941,7 @@ other registries given in @var{alternate-registries}, one by one,
 until it finds a registry that does exist.
 @end defopt
 
+@cindex scalable fonts
   Emacs can make use of scalable fonts, but by default it does not use
 them.
 
@@ -3058,7 +3069,7 @@ function does nothing.
 If optional argument @var{style-variant-p} is non-@code{nil}, that says
 to create bold, italic and bold-italic variants of the fontset as well.
 These variant fontsets do not have a short name, only a long one, which
-is made by altering @var{fontpattern} to indicate the bold or italic
+is made by altering @var{fontpattern} to indicate the bold and/or italic
 status.
 
 The specification string also says which fonts to use in the fontset.
@@ -3175,6 +3186,7 @@ does that, this function's value may not be accurate.
 
 @node Low-Level Font
 @subsection Low-Level Font Representation
+@cindex font property
 
   Normally, it is not necessary to manipulate fonts directly.  In case
 you need to do so, this section explains how.
@@ -3193,6 +3205,7 @@ should be one of @code{font-object}, @code{font-spec}, or
 @code{font-entity}.
 @end defun
 
+@cindex font object
   A font object is a Lisp object that represents a font that Emacs has
 @dfn{opened}.  Font objects cannot be modified in Lisp, but they can
 be inspected.
@@ -3206,6 +3219,7 @@ otherwise, @var{string} should be a string, and @var{position}
 specifies a position in that string.
 @end defun
 
+@cindex font spec
   A font spec is a Lisp object that contains a set of specifications
 that can be used to find a font.  More than one font may match the
 specifications in a font spec.
@@ -3236,6 +3250,7 @@ size, or a floating point number that specifies the point size.
 Additional typographic style information for the font, such as
 @samp{sans}.  The value should be a string or a symbol.
 
+@cindex font registry
 @item :registry
 The charset registry and encoding of the font, such as
 @samp{iso8859-1}.  The value should be a string or a symbol.
@@ -3244,6 +3259,7 @@ The charset registry and encoding of the font, such as
 The script that the font must support (a symbol).
 
 @item :otf
+@cindex OpenType font
 The font must be an OpenType font that supports these OpenType
 features, provided Emacs is compiled with support for @samp{libotf} (a
 library for performing complex text layout in certain scripts).  The
@@ -3270,6 +3286,7 @@ Set the font property @var{property} in the font-spec @var{font-spec}
 to @var{value}.
 @end defun
 
+@cindex font entity
   A font entity is a reference to a font that need not be open.  Its
 properties are intermediate between a font object and a font spec:
 like a font object, and unlike a font spec, it refers to a single,
@@ -3428,6 +3445,7 @@ etc.
 
 @defopt indicate-empty-lines
 @cindex fringes, and empty line indication
+@cindex empty lines, indicating
 When this is non-@code{nil}, Emacs displays a special glyph in the
 fringe of each empty line at the end of the buffer, on graphical
 displays.  @xref{Fringes}.  This variable is automatically
@@ -3435,6 +3453,7 @@ buffer-local in every buffer.
 @end defopt
 
 @defopt indicate-buffer-boundaries
+@cindex buffer boundaries, indicating
 This buffer-local variable controls how the buffer boundaries and
 window scrolling are indicated in the window fringes.
 
@@ -3563,6 +3582,8 @@ See the next subsection for details.
 @xref{Fringe Bitmaps}.
 @end ifnottex
 
+@c FIXME: I can't find the ‘fringes-indicator-alist’ variable.  Maybe
+@c it should be ‘fringe-indicator-alist’ or ‘fringe-cursor-alist’?  --xfq
 When @code{fringe-cursor-alist} has a buffer-local value, and there is
 no bitmap defined for a cursor type, the corresponding value from the
 default value of @code{fringes-indicator-alist} is used.
@@ -3654,6 +3675,7 @@ If @var{pos} is @code{nil}, that stands for the value of point in
 
 @node Customizing Bitmaps
 @subsection Customizing Fringe Bitmaps
+@cindex fringe bitmaps, customizing
 
 @defun define-fringe-bitmap bitmap bits &optional height width align
 This function defines the symbol @var{bitmap} as a new fringe bitmap,
@@ -4115,6 +4137,7 @@ Here are the possibilities for @var{height}:
 
 @table @asis
 @item @code{(+ @var{n})}
+@c FIXME: Add an index for "step"?  --xfq
 This means to use a font that is @var{n} steps larger.  A ``step'' is
 defined by the set of available fonts---specifically, those that match
 what was otherwise specified for this text, in all attributes except
@@ -4395,6 +4418,7 @@ sometimes consider this useful for displaying the image for a
 ``disabled'' button.
 
 @item (edge-detection :matrix @var{matrix} :color-adjust @var{adjust})
+@cindex edge detection, images
 Specifies a general edge-detection algorithm.  @var{matrix} must be
 either a nine-element list or a nine-element vector of numbers.  A pixel
 at position @math{x/y} in the transformed image is computed from
@@ -4478,6 +4502,7 @@ This specifies the pointer shape when the mouse pointer is over this
 image.  @xref{Pointer Shape}, for available pointer shapes.
 
 @item :map @var{map}
+@cindex image maps
 This associates an image map of @dfn{hot spots} with this image.
 
 An image map is an alist where each element has the format
@@ -4680,6 +4705,7 @@ and if @code{:height} is set it will have precedence over
 wish.  @code{:max-width} and @code{:max-height} will always preserve
 the aspect ratio.
 
+@c FIXME: ‘:format-type’ or ‘:format’?  --xfq
 @item :format
 ImageMagick tries to auto-detect the image type, but it isn't always
 able to.  By using @code{:format-type}, we can give ImageMagick a hint
@@ -4760,6 +4786,7 @@ from the file's name.
 The remaining arguments, @var{props}, specify additional image
 properties---for example,
 
+@c ‘:heuristic-mask’ is not documented?
 @example
 (create-image "foo.xpm" 'xpm nil :heuristic-mask t)
 @end example
@@ -4946,6 +4973,7 @@ This removes only images that were put into @var{buffer} the way
 @end defun
 
 @defun image-size spec &optional pixels frame
+@cindex size of image
 This function returns the size of an image as a pair
 @w{@code{(@var{width} . @var{height})}}.  @var{spec} is an image
 specification.  @var{pixels} non-@code{nil} means return sizes
@@ -4971,11 +4999,12 @@ The purpose of this variable is to prevent unreasonably large images
 from accidentally being loaded into Emacs.  It only takes effect the
 first time an image is loaded.  Once an image is placed in the image
 cache, it can always be displayed, even if the value of
-@var{max-image-size} is subsequently changed (@pxref{Image Cache}).
+@code{max-image-size} is subsequently changed (@pxref{Image Cache}).
 @end defvar
 
 @node Multi-Frame Images
 @subsection Multi-Frame Images
+@cindex multi-frame images
 
 @cindex animation
 @cindex image animation
@@ -5023,6 +5052,8 @@ or @code{nil}, the image animates once only; if @code{t} it loops
 forever; if a number animation stops after that many seconds.
 @end defun
 
+@vindex image-minimum-frame-delay
+@vindex image-default-frame-delay
 @noindent Animation operates by means of a timer.  Note that Emacs imposes a
 minimum frame delay of 0.01 (@code{image-minimum-frame-delay}) seconds.
 If the image itself does not specify a delay, Emacs uses
@@ -5367,7 +5398,7 @@ additionally available in the keymap stored in
 @code{button-buffer-map} as a parent keymap for its keymap.
 
 If the button has a non-@code{nil} @code{follow-link} property, and
-@var{mouse-1-click-follows-link} is set, a quick @key{Mouse-1} click
+@code{mouse-1-click-follows-link} is set, a quick @key{Mouse-1} click
 will also activate the @code{push-button} command.
 @xref{Clickable Text}.
 
@@ -5406,7 +5437,7 @@ is skipped over.  Returns the button found.
 
 @defun next-button pos &optional count-current
 @defunx previous-button pos &optional count-current
-Return the next button after (for @code{next-button} or before (for
+Return the next button after (for @code{next-button}) or before (for
 @code{previous-button}) position @var{pos} in the current buffer.  If
 @var{count-current} is non-@code{nil}, count any button at @var{pos}
 in the search, instead of starting at the next button.
@@ -5423,7 +5454,8 @@ in the search, instead of starting at the next button.
   The Ewoc package constructs buffer text that represents a structure
 of Lisp objects, and updates the text to follow changes in that
 structure.  This is like the ``view'' component in the
-``model/view/controller'' design paradigm.
+``model/view/controller'' design paradigm.  Ewoc means ``Emacs's
+Widget for Object Collections''.
 
   An @dfn{ewoc} is a structure that organizes information required to
 construct buffer text that represents certain Lisp data.  The buffer
@@ -5443,6 +5475,8 @@ The text's start position in the buffer.
 The header and footer strings.
 
 @item
+@cindex node, ewoc
+@c or "@cindex node, abstract display"?
 A doubly-linked chain of @dfn{nodes}, each of which contains:
 
 @itemize
@@ -5467,6 +5501,8 @@ between buffer positions and nodes, move point from one node's textual
 representation to another, and so forth.  @xref{Abstract Display
 Functions}.
 
+@cindex encapsulation, ewoc
+@c or "@cindex encapsulation, abstract display"?
   A node @dfn{encapsulates} a data element much the way a variable
 holds a value.  Normally, encapsulation occurs as a part of adding a
 node to the ewoc.  You can retrieve the data element value and place a
@@ -6073,6 +6109,7 @@ the standard display table.
 @subsection Glyphs
 @cindex glyph
 
+@cindex glyph code
   A @dfn{glyph} is a graphical symbol which occupies a single
 character position on the screen.  Each glyph is represented in Lisp
 as a @dfn{glyph code}, which specifies a character and optionally a
@@ -6348,7 +6385,9 @@ and displaying bidirectional text.
 @cindex reading order
 @cindex visual order
 @cindex unicode bidirectional algorithm
+@cindex UBA
 @cindex bidirectional reordering
+@cindex reordering, of bidirectional text
   Text is stored in Emacs buffers and strings in @dfn{logical} (or
 @dfn{reading}) order, i.e., the order in which a human would read
 each character.  In right-to-left and bidirectional text, the order in
index 4b83d575fef85fc9b7f23ad25d16892b6c20bbda..1139331f0ef5e1385b4fbe65bd6d3245a8fbb94b 100644 (file)
@@ -523,7 +523,7 @@ GNU Emacs Lisp and Common Lisp.  @code{setq}, @code{if}, and
 doesn't exist in Common Lisp.  @code{throw} is a special form in
 Common Lisp (because it must be able to throw multiple values), but it
 is a function in Emacs Lisp (which doesn't have multiple
-values).@refill
+values).
 @end quotation
 
 @node Autoloading
index 1f7169522cce6bb5382edb69b325e90c06663948..944a1e37cc4c4f88aea6e3257325994f45cf85c9 100644 (file)
@@ -2378,7 +2378,7 @@ buffer's default directory is prepended to @var{directory}, if
 In the following example, suppose that @file{~rms/lewis} is the current
 default directory, and has five files whose names begin with @samp{f}:
 @file{foo}, @file{file~}, @file{file.c}, @file{file.c.~1~}, and
-@file{file.c.~2~}.@refill
+@file{file.c.~2~}.
 
 @example
 @group
@@ -2409,7 +2409,7 @@ function returns @code{t}.  The function returns @code{nil} if directory
 In the following example, suppose that the current default directory
 has five files whose names begin with @samp{f}: @file{foo},
 @file{file~}, @file{file.c}, @file{file.c.~1~}, and
-@file{file.c.~2~}.@refill
+@file{file.c.~2~}.
 
 @example
 @group
@@ -2438,7 +2438,7 @@ has five files whose names begin with @samp{f}: @file{foo},
 @code{file-name-completion} usually ignores file names that end in any
 string in this list.  It does not ignore them when all the possible
 completions end in one of these suffixes.  This variable has no effect
-on @code{file-name-all-completions}.@refill
+on @code{file-name-all-completions}.
 
 A typical value might look like this:
 
index 84da0bd3769ef34991ffe955dc60fec1b234043d..82c4d8517626fe904291ab87ce07ec44ff22e360 100644 (file)
@@ -456,7 +456,7 @@ described using a format like that for functions, except that there
 are no arguments.
 
   Here is a description of the imaginary @code{electric-future-map}
-variable.@refill
+variable.
 
 @defvar electric-future-map
 The value of this variable is a full keymap used by Electric Command
index 73d869d59fd40f1dab38f277e6a47ec5c32ee2a8..855420a70c9b61ee2fb8aade28a62e73555fe8c2 100644 (file)
@@ -2631,6 +2631,9 @@ Used when the item is disabled and deselected.
 @end table
 @end table
 
+The GTK+ and NS versions of Emacs ignores items 1 to 3, because disabled and/or
+deselected images are autocomputed from item 0.
+
 If @var{image} is a single image specification, Emacs draws the tool bar
 button in disabled state by applying an edge-detection algorithm to the
 image.
index 9daf01cd0a292f5f5627e769a21772cc52c62ac8..45115d483324648a1a8a871828e652b886727480 100644 (file)
@@ -1044,6 +1044,7 @@ x1
 @node Rearrangement
 @subsection Functions that Rearrange Lists
 @cindex rearrangement of lists
+@cindex reordering, of elements in lists
 @cindex modification of lists
 
   Here are some functions that rearrange lists ``destructively'' by
index dab8e8d1255e30380662623bde49480a650e784d..637057c99b0348653a539ed376d2d771acc79e3a 100644 (file)
@@ -253,37 +253,38 @@ it skips the latter group.
 in a list of directories specified by the variable @code{load-path}.
 
 @defvar load-path
-@cindex @env{EMACSLOADPATH} environment variable
 The value of this variable is a list of directories to search when
 loading files with @code{load}.  Each element is a string (which must be
 a directory name) or @code{nil} (which stands for the current working
 directory).
 @end defvar
 
-  Each time Emacs starts up, it sets up the value of @code{load-path}
-in several steps.  First, it initializes @code{load-path} to the
-directories specified by the environment variable @env{EMACSLOADPATH},
-if that exists.  The syntax of @env{EMACSLOADPATH} is the same as used
-for @code{PATH}; directory names are separated by @samp{:} (or
-@samp{;}, on some operating systems), and @samp{.} stands for the
-current default directory.  Here is an example of how to set
-@env{EMACSLOADPATH} variable from @command{sh}:
+  When Emacs starts up, it sets up the value of @code{load-path}
+in several steps.  First, it initializes @code{load-path} using
+default locations set when Emacs was compiled.  Normally, this
+is a directory something like
 
 @example
-export EMACSLOADPATH
-EMACSLOADPATH=/home/foo/.emacs.d/lisp:/opt/emacs/lisp
+"/usr/local/share/emacs/@var{version}/lisp"
 @end example
 
-@noindent
-Here is how to set it from @code{csh}:
+followed by a similarly named @file{leim} directory.  These
+directories contain the standard Lisp files that come with Emacs.
+If Emacs cannot find them, it will not start correctly.
 
-@example
-setenv EMACSLOADPATH /home/foo/.emacs.d/lisp:/opt/emacs/lisp
-@end example
+If you run Emacs from the directory where it was built---that is, an
+executable that has not been formally installed---Emacs instead
+initializes @code{load-path} using the @file{lisp} and @file{leim}
+directories in the directory containing the sources from which it
+was built.  If you built Emacs in a separate directory from the
+sources, it also adds those directories from the build directory.
+(In all cases, elements are represented as absolute file names.)
 
 @cindex site-lisp directories
-  If @env{EMACSLOADPATH} is not set (which is usually the case), Emacs
-initializes @code{load-path} with the following two directories:
+Unless you start Emacs with the @option{--no-site-lisp} option,
+it then adds two more @file{site-lisp} directories to the front of
+@code{load-path}.  These are intended for locally installed Lisp files,
+and are normally of the form:
 
 @example
 "/usr/local/share/emacs/@var{version}/site-lisp"
@@ -297,26 +298,45 @@ and
 @end example
 
 @noindent
-The first one is for locally installed packages for a particular Emacs
-version; the second is for locally installed packages meant for use
-with all installed Emacs versions.
-
-  If you run Emacs from the directory where it was built---that is, an
-executable that has not been formally installed---Emacs puts two more
-directories in @code{load-path}.  These are the @code{lisp} and
-@code{site-lisp} subdirectories of the main build directory.  (Both
-are represented as absolute file names.)
-
-  Next, Emacs ``expands'' the initial list of directories in
-@code{load-path} by adding the subdirectories of those directories.
-Both immediate subdirectories and subdirectories multiple levels down
-are added.  But it excludes subdirectories whose names do not start
-with a letter or digit, and subdirectories named @file{RCS} or
-@file{CVS}, and subdirectories containing a file named
-@file{.nosearch}.
-
-  Next, Emacs adds any extra load directory that you specify using the
-@samp{-L} command-line option (@pxref{Action Arguments,,,emacs, The
+The first one is for locally installed files for a specific Emacs
+version; the second is for locally installed files meant for use
+with all installed Emacs versions.  (If Emacs is running uninstalled,
+it also adds @file{site-lisp} directories from the source and build
+directories, if they exist.  Normally these directories do not contain
+@file{site-lisp} directories.)
+
+@cindex @env{EMACSLOADPATH} environment variable
+If the environment variable @env{EMACSLOADPATH} is set, it overrides
+the above initialization procedure.  That is, Emacs initializes
+@code{load-path} based solely on the value of the environment
+variable.  You must therefore include the directory containing the
+standard Lisp files, else Emacs will not function.  In most
+situations, it is better to use the @option{-L} command-line option
+(see below) to add elements to @code{load-path}.
+
+The syntax of @env{EMACSLOADPATH} is the same as used for @code{PATH};
+directory names are separated by @samp{:} (or @samp{;}, on some
+operating systems), and @samp{.} stands for the current default
+directory.  Here is an example of how to set @env{EMACSLOADPATH}
+variable (from a @command{sh}-style shell):
+
+@example
+export EMACSLOADPATH
+EMACSLOADPATH=/home/foo/.emacs.d/lisp:/usr/local/emacs/24.3/lisp
+@end example
+
+  For each directory in @code{load-path}, Emacs then checks to see if
+it contains a file @file{subdirs.el}, and if so, loads it.  The
+@file{subdirs.el} file is created when Emacs is built/installed,
+and contains code that causes Emacs to add any subdirectories of those
+directories to @code{load-path}.  Both immediate subdirectories and
+subdirectories multiple levels down are added.  But it excludes
+subdirectories whose names do not start with a letter or digit, and
+subdirectories named @file{RCS} or @file{CVS}, and subdirectories
+containing a file named @file{.nosearch}.
+
+  Next, Emacs adds any extra load directories that you specify using the
+@option{-L} command-line option (@pxref{Action Arguments,,,emacs, The
 GNU Emacs Manual}).  It also adds the directories where optional
 packages are installed, if any (@pxref{Packaging Basics}).
 
index 94a7bdf1b2341b488be39b13af332cfae5ecd64f..96adb629f37210a9e5b67bc0a2c2561a97224fcd 100644 (file)
@@ -610,6 +610,7 @@ property as a symbol.
 @end defvar
 
 @defvar char-script-table
+@cindex script symbols
 The value of this variable is a char-table that specifies, for each
 character, a symbol whose name is the script to which the character
 belongs, according to the Unicode Standard classification of the
index 3b7dc41335b1303276d897285dbf0b6cc89fcbf5..a145b1e9bd2a2889fa3946fa3298c9b28378f483 100644 (file)
@@ -1301,7 +1301,7 @@ called @dfn{subrs} or @dfn{built-in functions}.  (The word ``subr'' is
 derived from ``subroutine''.)  Most primitive functions evaluate all
 their arguments when they are called.  A primitive function that does
 not evaluate all its arguments is called a @dfn{special form}
-(@pxref{Special Forms}).@refill
+(@pxref{Special Forms}).
 
   It does not matter to the caller of a function whether the function is
 primitive.  However, this does matter if you try to redefine a primitive
index 071fcf526da271e200ebc6a8244e75ab4242f0fc..0cd9e1465dc867aa9dc8c3976e536290ce002400 100644 (file)
@@ -218,6 +218,7 @@ specify.
 It runs @code{window-setup-hook}.  @xref{Window Systems}.
 
 @item
+@cindex startup screen
 It displays the @dfn{startup screen}, which is a special buffer that
 contains information about copyleft and basic Emacs usage.  This is
 not done if @code{inhibit-startup-screen} or @code{initial-buffer-choice}
@@ -316,7 +317,7 @@ Run without an interactive terminal.  @xref{Batch Mode}.
 Do not initialize any display; just start a server in the background.
 
 @item --no-init-file
-@itemx -Q
+@itemx -q
 Do not load either the init file, or the @file{default} library.
 
 @item --no-site-file
@@ -516,9 +517,10 @@ displays the startup messages.
 The value of this variable is @code{t} once the command line has been
 processed.
 
-If you redump Emacs by calling @code{dump-emacs}, you may wish to set
-this variable to @code{nil} first in order to cause the new dumped Emacs
-to process its new command-line arguments.
+If you redump Emacs by calling @code{dump-emacs} (@pxref{Building
+Emacs}), you may wish to set this variable to @code{nil} first in
+order to cause the new dumped Emacs to process its new command-line
+arguments.
 @end defvar
 
 @defvar command-switch-alist
@@ -550,8 +552,8 @@ sole argument.
 In some cases, the option is followed in the command line by an
 argument.  In these cases, the @var{handler-function} can find all the
 remaining command-line arguments in the variable
-@code{command-line-args-left}.  (The entire list of command-line
-arguments is in @code{command-line-args}.)
+@code{command-line-args-left} (see below).  (The entire list of
+command-line arguments is in @code{command-line-args}.)
 
 The command-line arguments are parsed by the @code{command-line-1}
 function in the @file{startup.el} file.  See also @ref{Emacs
@@ -959,6 +961,7 @@ to access the value of @var{variable}.  If @var{value} is omitted or
 removes @var{variable} from the environment.  Otherwise, @var{value}
 should be a string.
 
+@c FIXME: Document `substitute-env-vars'?  --xfq
 If the optional argument @var{substitute} is non-@code{nil}, Emacs
 calls the function @code{substitute-env-vars} to expand any
 environment variables in @var{value}.
@@ -1095,9 +1098,9 @@ originally logged in.  The value reflects command-line options such as
 Lisp packages that load files of customizations, or any other sort of
 user profile, should obey this variable in deciding where to find it.
 They should load the profile of the user name found in this variable.
-If @code{init-file-user} is @code{nil}, meaning that the @samp{-q}
-option was used, then Lisp packages should not load any customization
-files or user profile.
+If @code{init-file-user} is @code{nil}, meaning that the @samp{-q},
+@samp{-Q}, or @samp{-batch} option was used, then Lisp packages should
+not load any customization files or user profile.
 @end defvar
 
 @defopt user-mail-address
@@ -1147,6 +1150,7 @@ you to ``fake out'' Emacs by telling the functions what to return.  The
 variables are also useful for constructing frame titles (@pxref{Frame
 Titles}).
 
+@cindex UID
 @defun user-real-uid
 This function returns the real @acronym{UID} of the user.
 The value may be a floating point number, in the (unlikely) event that
@@ -1158,6 +1162,7 @@ This function returns the effective @acronym{UID} of the user.
 The value may be a floating point number.
 @end defun
 
+@cindex GID
 @defun group-gid
 This function returns the effective @acronym{GID} of the Emacs process.
 The value may be a floating point number.
@@ -1217,9 +1222,9 @@ file-attributes}).  In function arguments, e.g., the @var{time-value}
 argument to @code{current-time-string}, two-, three-, and four-integer
 lists are accepted.  You can convert times from the list
 representation into standard human-readable strings using
-@code{current-time}, or to other forms using the @code{decode-time}
-and @code{format-time-string} functions documented in the following
-sections.
+@code{current-time-string}, or to other forms using the
+@code{decode-time} and @code{format-time-string} functions documented
+in the following sections.
 
 @defun current-time-string &optional time-value
 This function returns the current time and date as a human-readable
@@ -1263,6 +1268,7 @@ exact.  Do not use this function if precise time stamps are required.
 @end defun
 
 @defun current-time-zone &optional time-value
+@cindex time zone, current
 This function returns a list describing the time zone that the user is
 in.
 
@@ -1289,6 +1295,7 @@ time zone.
 
 @node Time Conversion
 @section Time Conversion
+@cindex calendrical information
 
   These functions convert time values (lists of two to four integers,
 as explained in the previous section) into calendrical information and
@@ -1517,7 +1524,7 @@ system.
 @defun seconds-to-time seconds
 This function converts @var{seconds}, a floating point number of
 seconds since the epoch, to a time value and returns that.  To perform
-the inverse conversion, use @code{float-time}.
+the inverse conversion, use @code{float-time} (@pxref{Time of Day}).
 @end defun
 
 @defun format-seconds format-string seconds
@@ -1579,6 +1586,7 @@ most-positive-fixnum}).
 both elapsed and processor time, used by the Emacs process.
 
 @deffn Command emacs-uptime &optional format
+@cindex uptime of Emacs
 This function returns a string representing the Emacs
 @dfn{uptime}---the elapsed wall-clock time this instance of Emacs is
 running.  The string is formatted by @code{format-seconds} according
@@ -1915,10 +1923,10 @@ functions.
 
 @defun set-input-mode interrupt flow meta &optional quit-char
 This function sets the mode for reading keyboard input.  If
-@var{interrupt} is non-null, then Emacs uses input interrupts.  If it is
-@code{nil}, then it uses @sc{cbreak} mode.  The default setting is
-system-dependent.  Some systems always use @sc{cbreak} mode regardless
-of what is specified.
+@var{interrupt} is non-@code{nil}, then Emacs uses input interrupts.
+If it is @code{nil}, then it uses @sc{cbreak} mode.  The default
+setting is system-dependent.  Some systems always use @sc{cbreak} mode
+regardless of what is specified.
 
 When Emacs communicates directly with X, it ignores this argument and
 uses interrupts if that is the way it knows how to communicate.
@@ -2068,17 +2076,17 @@ often than to actual Emacs bugs.  Once you are certain which characters
 were actually output, you can determine reliably whether they correspond
 to the Termcap specifications in use.
 
-You close the termscript file by calling this function with an
-argument of @code{nil}.
-
-See also @code{open-dribble-file} in @ref{Recording Input}.
-
 @example
 @group
 (open-termscript "../junk/termscript")
      @result{} nil
 @end group
 @end example
+
+You close the termscript file by calling this function with an
+argument of @code{nil}.
+
+See also @code{open-dribble-file} in @ref{Recording Input}.
 @end deffn
 
 @node Sound Output
@@ -2089,6 +2097,7 @@ See also @code{open-dribble-file} in @ref{Recording Input}.
 certain systems are supported; if you call @code{play-sound} on a
 system which cannot really do the job, it gives an error.
 
+@c FIXME: Add indexes for Au and WAV?  --xfq
   The sound must be stored as a file in RIFF-WAVE format (@samp{.wav})
 or Sun Audio format (@samp{.au}).
 
index 4a222a6e7af9c0e556a93809b70237d9f6764b19..15aa23f77ea3179895b7f2a6d37a48d6b452d927 100644 (file)
@@ -273,12 +273,12 @@ expression is ordinary, unless a @samp{\} precedes it.
 therefore @samp{f} is a regular expression that matches the string
 @samp{f} and no other string.  (It does @emph{not} match the string
 @samp{fg}, but it does match a @emph{part} of that string.)  Likewise,
-@samp{o} is a regular expression that matches only @samp{o}.@refill
+@samp{o} is a regular expression that matches only @samp{o}.
 
   Any two regular expressions @var{a} and @var{b} can be concatenated.  The
 result is a regular expression that matches a string if @var{a} matches
 some amount of the beginning of that string and @var{b} matches the rest of
-the string.@refill
+the string.
 
   As a simple example, we can concatenate the regular expressions @samp{f}
 and @samp{o} to get the regular expression @samp{fo}, which matches only
@@ -304,7 +304,7 @@ expression.
 is a special character that matches any single character except a newline.
 Using concatenation, we can make regular expressions like @samp{a.b}, which
 matches any three-character string that begins with @samp{a} and ends with
-@samp{b}.@refill
+@samp{b}.
 
 @item @samp{*}
 @cindex @samp{*} in regexp
@@ -488,7 +488,7 @@ example, the regular expression that matches the @samp{\} character is
 @samp{\\}.  To write a Lisp string that contains the characters
 @samp{\\}, Lisp syntax requires you to quote each @samp{\} with another
 @samp{\}.  Therefore, the read syntax for a regular expression matching
-@samp{\} is @code{"\\\\"}.@refill
+@samp{\} is @code{"\\\\"}.
 @end table
 
 @strong{Please note:} For historical compatibility, special characters
@@ -496,7 +496,7 @@ are treated as ordinary ones if they are in contexts where their special
 meanings make no sense.  For example, @samp{*foo} treats @samp{*} as
 ordinary since there is no preceding expression on which the @samp{*}
 can act.  It is poor practice to depend on this behavior; quote the
-special character anyway, regardless of where it appears.@refill
+special character anyway, regardless of where it appears.
 
 As a @samp{\} is not special inside a character alternative, it can
 never remove the special meaning of @samp{-} or @samp{]}.  So you
@@ -599,14 +599,14 @@ a table of the special @samp{\} constructs.
 specifies an alternative.
 Two regular expressions @var{a} and @var{b} with @samp{\|} in
 between form an expression that matches anything that either @var{a} or
-@var{b} matches.@refill
+@var{b} matches.
 
 Thus, @samp{foo\|bar} matches either @samp{foo} or @samp{bar}
-but no other string.@refill
+but no other string.
 
 @samp{\|} applies to the largest possible surrounding expressions.  Only a
 surrounding @samp{\( @dots{} \)} grouping can limit the grouping power of
-@samp{\|}.@refill
+@samp{\|}.
 
 If you need full backtracking capability to handle multiple uses of
 @samp{\|}, use the POSIX regular expression functions (@pxref{POSIX
@@ -785,7 +785,7 @@ matches the empty string, but only at point.
 matches the empty string, but only at the beginning or
 end of a word.  Thus, @samp{\bfoo\b} matches any occurrence of
 @samp{foo} as a separate word.  @samp{\bballs?\b} matches
-@samp{ball} or @samp{balls} as a separate word.@refill
+@samp{ball} or @samp{balls} as a separate word.
 
 @samp{\b} matches at the beginning or end of the buffer (or string)
 regardless of what text appears next to it.
index 76d3954cfcf19ee632672b309463ceb5ad287268..6ea80e4be8d1b71022fff0e4980e81ab266786e8 100644 (file)
@@ -1,3 +1,503 @@
+2013-11-17  Jay Belanger  <jay.p.belanger@gmail.com>
+
+       * calc.texi (Customizing Calc): Mention new variable
+       `calc-context-sensitive-enter'.
+
+2013-11-12  Aaron Ecay  <aaronecay@gmail.com>
+
+       * org.texi (Exporting code blocks): Document the 'inline-only
+       setting for `org-export-babel-evaluate'.  Document how :var
+       introduces code block dependencies.
+
+2013-11-12  Achim Gratz  <Stromeko@Stromeko.DE>
+
+       * org.texi (Header arguments): Document header-args[:lang]
+       properties and remove deprecated old-style properties from
+       documentation.
+
+       * org.texi (Agenda commands): Remove footnote from @tsubheading
+       and add a sentence with the reference instead.
+
+2013-11-12  Bastien Guerry  <bzg@gnu.org>
+
+       * org.texi (Catching invisible edits):
+       * org.texi (Plain lists, Plain lists):
+       * org.texi (Advanced configuration):
+       * org.texi (Tag groups):
+       * org.texi (Conventions):
+       * org.texi (Checkboxes, Radio lists):
+       * org.texi (Top, Summary, Exporting):
+       * org.texi (In-buffer settings): Fix typos.
+
+       * org.texi (Refile and copy): Document `org-copy' and `C-3 C-c
+       C-w'.  Add an index entry for `org-refile-keep'.
+
+       * org.texi (Plain lists): Add an index entry for sorting plain
+       list.  Document sorting by checked status for check lists.
+
+       * org.texi (Publishing options): Fix old variable names.
+
+       * org.texi (Orgstruct mode): Fix suggested setting of
+       `orgstruct-heading-prefix-regexp'.
+
+       * org.texi (Export settings): Document
+       `org-export-allow-bind-keywords'.
+
+       * org.texi (History and Acknowledgments): Small rephrasing.
+
+       * org.texi (Template elements): Add a footnote about tags accepted
+       in a year datetree.
+
+       * org.texi (Beamer export, @LaTeX{} and PDF export)
+       (Header and sectioning, @LaTeX{} specific attributes): Enhance
+       style.
+
+       * org.texi (Agenda commands): Add a footnote about dragging agenda
+       lines: it does not persist and it does not change the .org files.
+
+       * org.texi (Agenda commands): Add a table heading for dragging
+       agenda lines forward/backward.
+
+       * org.texi (Agenda commands): Add documentation for
+       `org-agenda-bulk-toggle' and `org-agenda-bulk-toggle-all'.
+
+       * org.texi (Publishing options): Update the list of options.
+       (Simple example, Complex example): Fix the examples.
+
+       * org.texi (Formula syntax for Calc): Don't use a bold font the
+       warning.
+
+       * org.texi (Other built-in back-ends): New section.
+
+       * org.texi (Editing source code): Document
+       `org-edit-src-auto-save-idle-delay' and
+       `org-edit-src-turn-on-auto-save'.
+
+       * org.texi (External links): Document contributed link types
+       separately.
+
+       * org.texi (Closing items): Document
+       `org-closed-keep-when-no-todo'.
+
+       * org.texi (Export back-ends): Rename from "Export formats".
+       (The Export Dispatcher): Remove reference to
+       `org-export-run-in-background'.
+       (Export settings): Minor rewrites.
+       (ASCII/Latin-1/UTF-8 export): Update variable's name.
+       (In-buffer settings): Add #+HTML_HEAD_EXTRA.
+
+       * org.texi (Export in foreign buffers): New section.
+       (Exporting): Remove documentation about converting the selected
+       region.
+
+       * org.texi (Advanced configuration): Put the filter valid types in
+       a table.  Use @lisp and @smalllisp.
+
+       * org.texi: Use @code{nil} instead of nil.  Update the maintainer
+       contact info.
+
+       * org.texi (Exporting): Better introductory sentence.  Add a note
+       about conversion commands.
+       (Feedback, Orgstruct mode, Built-in table editor)
+       (Built-in table editor, Orgtbl mode, Updating the table)
+       (Property syntax, Capturing column view, Capture)
+       (Agenda files, Agenda commands, CDLaTeX mode, CDLaTeX mode)
+       (Exporting, Extending ODT export)
+       (Working with @LaTeX{} math snippets, dir, Customization)
+       (Radio tables, A @LaTeX{} example, Pulling from MobileOrg):
+       Uniformly use @kbd{M-x command RET}.
+
+       * org.texi (Filtering/limiting agenda items): New subsection.
+       Document the use of `org-agenda-max-*' options and
+       `org-agenda-limit-interactively' from the agenda.
+       (Agenda commands): Move details about filtering commands to
+       the new section, only include a summary here.
+       (Customizing tables in ODT export)
+       (System-wide header arguments, Conflicts, Dynamic blocks): Use
+       spaces for indentation.
+
+       * org.texi (Emphasis and monospace): Mention `org-emphasis-alist'.
+
+       * org.texi (Links in HTML export, Images in HTML export)
+       (post): Fix syntax within #+ATTR_*.
+       (Tables in HTML export): Document `org-html-table-row-tags'
+       and use `org-html-table-default-attributes' instead of
+       `org-html-table-tag'.
+
+       * org.texi (Publishing action, Publishing options)
+       (Publishing links): Major rewrite.  Enhance explanations for
+       `org-org-publish-to-org'.  Remove reference to
+       `org-export-run-in-background'.
+
+       * org.texi: Fix many small typos.  Use #+NAME instead of
+       #+TBLNAME.  Use @smalllisp instead of @example.
+       (Special symbols): Add index?
+       (HTML preamble and postamble): Don't mention obsolete use of
+       opt-plist.
+       (JavaScript support): Don't mention the org-jsinfo.el file as it
+       has been merged with ox-html.el.
+
+       * org.texi (Installation, Feedback, Setting Options)
+       (Code evaluation security, org-crypt.el): Use @lisp instead of
+       @example.
+       (Agenda commands): Use @table instead of @example.
+
+       * org.texi (Adding hyperlink types): New appendix.
+
+       * org.texi (ODT export commands, Extending ODT export)
+       (Applying custom styles, Images in ODT export)
+       (Labels and captions in ODT export)
+       (Literal examples in ODT export)
+       (Configuring a document converter)
+       (Working with OpenDocument style files)
+       (Customizing tables in ODT export)
+       (Validating OpenDocument XML): Fix options names.
+
+       * org.texi (History and Acknowledgments): Update acknowledgments
+       to Nicolas.  Add Nicolas Goaziou to the list of contributors.
+
+       * org.texi (System-wide header arguments): Don't use "customizing"
+       for setting a variable.  Also remove comments.
+
+       * org.texi (Weekly/daily agenda): Add `org-agenda-start-day' and
+       `org-agenda-start-on-weekday' to the variable index and document
+       them.
+
+       * org.texi (Sparse trees, Agenda commands)
+       (@LaTeX{} fragments, Selective export, Export options)
+       (The export dispatcher, ASCII/Latin-1/UTF-8 export)
+       (HTML Export commands, @LaTeX{}/PDF export commands)
+       (iCalendar export, Publishing options, Triggering publication)
+       (In-buffer settings): Update to reflect changes from the new
+       export engine.
+
+       * org.texi (Matching tags and properties): More examples.  Explain
+       group tags expansion as regular expressions.
+
+       * org.texi (Tag groups): New section.
+
+       * org.texi (Setting tags): Tiny formatting fixes.
+
+       * org.texi (Plain lists, Checkboxes): Use non-obsolete variable
+       names.
+
+       * org.texi (Storing searches): Add "agenda" and "agenda*" to the
+       concept index.  Include example for these agenda views.
+       (Special agenda views): Mention the "agenda*" agenda view.
+
+       * org.texi (Repeated tasks): Document how to ignore a repeater
+       when using both a scheduled and a deadline timetamp.
+
+       * org.texi (Global and local cycling): Wrap in a new subsection.
+       (Initial visibility, Catching invisible edits): New subsections.
+
+       * org.texi (Visibility cycling): Mention that
+       `org-agenda-inhibit-startup' will prevent visibility setting when
+       the agenda opens an Org file for the first time.
+
+       * org.texi (Org syntax): New section.
+
+       * org.texi (Orgstruct mode): Document
+       `orgstruct-heading-prefix-regexp'.
+
+       * org.texi (Speeding up your agendas): New section.
+
+       * org.texi (Installation): When installing Org from ELPA, users
+       should do this from an Emacs session where no .org file has been
+       visited.
+
+       * org.texi (CSS support, In-buffer settings): Update HTML options
+       names.
+
+       * org.texi (Structure editing): Update documentation for
+       `org-insert-heading-or-item'.
+       (Plain lists, Relative timer): Update index entry.
+
+       * org.texi (JavaScript support): Update variable names.
+
+       * org.texi (comments): Minor formatting fix.
+
+       * org.texi (@LaTeX{} fragments): Minor enhancement.
+
+       * org.texi: Update the list contributions.
+
+       * org.texi (Agenda commands): Exporting the agenda to an .org file
+       will not copy the subtrees and the inherited tags.  Document
+       `org-agenda-filter-by-regexp'.
+
+       * org.texi (Publishing action, Complex example): Fix names of
+       publishing functions.
+
+       * org.texi (Top, Exporting): Delete references to Freemind.
+       (Freemind export): Delete section.
+
+       * org.texi (Top, Exporting): Delete references to the XOXO export.
+       (XOXO export): Delete section.
+
+       * org.texi (Capture): Mention that org-remember.el is not
+       supported anymore.
+
+       * org.texi (Top, Exporting, Beamer class export): Delete
+       references to the TaskJuggler export.
+       (History and Acknowledgments): Mention that the TaskJuggler has
+       been rewritten by Nicolas and now lives in the contrib/ directory
+       of Org's distribution.  Mention that Jambunathan rewrote the HTML
+       exporter.  Remove Jambunathan from my own acknowledgments.
+       (TaskJuggler export): Delete.
+
+       * org.texi (HTML preamble and postamble)
+       (Tables in HTML export, Images in HTML export)
+       (Math formatting in HTML export, CSS support)
+       (@LaTeX{} and PDF export, Publishing options): Fix the names of
+       the HTML export and publishing options.
+
+       * org.texi (Literal examples, Export options)
+       (@LaTeX{} and PDF export, Header and sectioning)
+       (Publishing options): Fix LaTeX options names.
+
+       * org.texi (Export options, CSS support, In-buffer settings): Fix
+       references to HTML_LINK_* and HTML_STYLE keywords.
+
+       * org.texi (Export options, In-buffer settings): Fix references to
+       #+SELECT_TAGS and #+EXCLUDE_TAGS and remove reference to #+XSLT.
+
+       * org.texi (Top, Markup, Initial text, Images and tables)
+       (@LaTeX{} fragments, @LaTeX{} fragments, Exporting)
+       (Export options, JavaScript support, Beamer class export): Remove
+       references to the DocBook export, which has been deleted.
+       (History and Acknowledgments): Mention that DocBook has been
+       deleted, suggest to use the Texinfo exporter instead, then to
+       convert the .texi to DocBook with makeinfo.
+       (Links in ODT export, Tables in ODT export): Fix indices.
+
+       * org.texi (Deadlines and scheduling): Add a variable to the
+       index.  Add documentation about delays for scheduled tasks.
+
+       * org.texi (Emphasis and monospace): Mention
+       `org-fontify-emphasized-text' and
+       `org-emphasis-regexp-components'.
+
+       * org.texi (References): Small enhancement.
+
+       * org.texi (Column width and alignment): Make the example visually
+       more clear.
+
+       * org.texi (The clock table): Document :mstart and :wstart as a
+       way to set the starting day of the week.
+
+       * org.texi (In-buffer settings): Document new startup keywords.
+       Thanks to John J Foerch for this idea.
+
+       * org.texi (Include files): Tiny formatting fix.
+
+       * org.texi (Activation): Point to the "Conflicts" section.
+
+2013-11-12  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org.texi (CSS support): Clarify this section.
+
+       * org.texi (@LaTeX{} specific attributes): Document that tabu and
+       tabularx packages are not in the default set of packages.
+
+       * org.texi (Agenda commands): Document fortnight view.
+
+       * org.texi: Document conflict with ecomplete.el.
+
+       * org.texi (History and Acknowledgments): Acknowledgements for
+       Jason Dunsmore and Rakcspace.
+
+       * org.texi: Rename org-crypt.el node to org-crypt.
+
+       * org.texi (A @LaTeX{} example): Fix typo in variable name.
+
+       * org.texi (MobileOrg): Mention the new iPhone developer.
+
+       * org.texi (Table of contents) Improve documentation of TOC
+       placement.
+
+       * org.texi: Explain that date/time information at read-date prompt
+       should start at the beginning, not anywhere in the middle of a
+       long string.
+
+2013-11-12  Christopher Schmidt  <christopher@ch.ristopher.com>
+
+       * org.texi (Orgstruct mode): Fix wrong regexp.
+
+2013-11-12  Eric Abrahamsen  <eric@ericabrahamsen.net>
+
+       * org.texi: Document export to (X)HTML flavors.
+
+2013-11-12  Eric Schulte  <schulte.eric@gmail.com>
+
+       * org.texi (Extracting source code): Mention the prefix argument
+       to org-babel-tangle.
+       (noweb): Removed erroneous negative.
+       (Specific header arguments): Document new header arguments.
+       Documentation for new tangle-mode header argument.
+       (Top): Documentation for new tangle-mode header argument.
+       (rownames): Documentation for new tangle-mode header argument.
+       Mention elisp as special rowname case.
+       (tangle-mode): Documentation for new tangle-mode header argument.
+       (post): Documentation and an example of usage.
+       (var): Remove the "Alternate argument syntax" section from the
+       documentation.
+       (hlines): Note that :hline has no effect for Emacs Lisp code
+       blocks.
+
+2013-11-12  Feng Shu  <tumashu@gmail.com>
+
+       * org.texi (@LaTeX{} fragments, Previewing @LaTeX{} fragments)
+       (Math formatting in HTML export)
+       (Working with @LaTeX{} math snippets): Add document about creating
+       formula image with imagemagick.
+
+       * org.texi (@LaTeX{} specific attributes): Document `:caption'
+       attribute of #+ATTR_LATEX.
+
+2013-11-12  Grégoire Jadi  <gregoire.jadi@gmail.com>
+
+       * org.texi (Handling links): Fix a typo in
+       `org-startup-with-inline-images' documentation.
+
+       * org.texi (Previewing @LaTeX{} fragments): Document the startup
+       keywords to use for previewing LaTeX fragments or not.
+       (Summary of in-buffer settings): Improve formatting and add an
+       entry for the variable `org-startup-with-latex-preview'.
+
+       * org.texi (Property syntax): Recall the user to refresh the org
+       buffer when properties are set on a per-file basis.
+
+2013-11-12  Gustav Wikström  <gustav.erik@gmail.com>  (tiny change)
+
+       * org.texi (Matching tags and properties): Clarification.
+
+2013-11-12  Ippei Furuhashi  <top.tuna+orgmode@gmail.com>
+
+       * org.texi (Editing and debugging formulas): Add an example when a
+       table has multiple #+TBLFM lines.
+
+2013-11-12  Ivan Vilata i Balaguer  <ivan@selidor.net>  (tiny change)
+
+       * org.texi (The clock table): Document acceptance of relative
+       times in tstart and tend, link to syntax description and provide
+       example.
+
+2013-11-12  Jarmo Hurri  <jarmo.hurri@syk.fi>
+
+       * org.texi (The spreadsheet): Document lookup functions.
+
+2013-11-12  Kodi Arfer  <git@arfer.net>  (tiny change)
+
+       * org.text (CSS support): Mention .figure-number, .listing-number,
+       and .table-number.
+
+2013-11-12  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org.texi
+       (Formula syntax for Calc, Emacs Lisp forms as formulas): Reformat
+       spreadsheet formula mode strings and some examples from @example
+       block with xy @r{yz} to @table.
+
+       * org.texi (Formula syntax for Calc): Improve the documentation of
+       empty fields in formulas for spreadsheet.  Add explanation and
+       example for empty field.  Extend explanations of format
+       specifiers.  Add a sentence to mention Calc defmath.
+
+       * org.texi (Column formulas): Add a sentence to be more explicit
+       about when a table header is mandatory.
+
+2013-11-12  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * org.texi (Subscripts and superscripts): Remove reference to
+       quoted underscores until this mechanism is implemented again.
+
+       * org.texi (Beamer export): Be more accurate about BEAMER_OPT
+       property.
+
+       * org.texi (Document title): Subtree export is no longer triggered
+       by marking one as the region.
+       (Horizontal rules): LaTeX export doesn't use "\hrule" anymore, and
+       giving examples isn't very useful: "horizontal rule" is, at least,
+       as explicit as <hr/>.
+
+       * org.texi (HTML doctypes): Reflect keyword removal.
+       (CSS support): Reflect keyword removal.
+
+       * org.texi (@LaTeX{} specific attributes): Document new :float
+       values.
+
+       * org.texi (Export settings): Improve documentation.
+
+       * org.texi (Math formatting in HTML export): Fix OPTIONS item's name.
+       (Text areas in HTML export): Update text areas.
+       (HTML Export commands): Update export commands.
+
+       * org.texi (Header and sectioning): Add a footnote about the
+       different between LATEX_HEADER_EXTRA and LATEX_HEADER.
+
+       * org.texi (The Export Dispatcher): Document
+       `org-export-in-background'.
+
+       * org.texi (Footnotes): Export back-ends do not use
+       `org-footnote-normalize' anymore.
+
+       * org.texi: Document variable changes.
+
+       * org.texi (Export settings): Doument p: item in OPTIONS keyword.
+
+       * org.texi (Exporting): Massive rewrite of the first sections.
+       (Selective export): Delete.
+       (The Export Dispatcher): Rewrite.
+       (Export options): Rewrite as "Export settings".
+
+       * org.texi: Small changes to documentation for embedded LaTeX.
+
+       * org.texi (Internal links): Document #+NAME keyword and
+       cross-referencing during export.
+
+       * org.texi (Include files): Remove reference to :prefix1
+       and :prefix.  Give more details for :minlevel.
+
+       * org.texi (Macro replacement): Fix macro name.  Update
+       documentation about possible locations and escaping mechanism.
+
+       * org.texi (Table of contents): Update documentation.  Document
+       lists of listings and lists of tables.  Add documentation for
+       optional title and #+TOC: keyword.
+
+2013-11-12  Rick Frankel  <rick@rickster.com>
+
+       * org.texi (results): Add Format section, broken out of Type
+       section to match code.
+       (hlines, colnames): Remove incorrect Emacs Lisp exception.  Note
+       that the actual default handling (at least for python and
+       emacs-lisp) does not seem to match the description.
+
+2013-11-12  Sacha Chua  <sacha@sachachua.com>  (tiny change)
+
+       * org.texi (The date/time prompt): Update the documentation to
+       reflect the new way `org-read-date-get-relative' handles weekdays.
+
+2013-11-12  Yasushi Shoji  <yashi@atmark-techno.com>
+
+       * org.texi (Resolving idle time): Document
+       `org-clock-x11idle-program-name'.
+
+2013-10-24  Michael Albinus  <michael.albinus@gmx.de>
+
+       * ert.texi (Running Tests Interactively): Adapt examle output.
+       (Tests and Their Environment): Mention skip-unless.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * dired-x.texi, ebrowse.texi, ede.texi, eieio.texi, eshell.texi:
+       * pcl-cvs.texi, sc.texi, srecode.texi, vip.texi, viper.texi:
+       * widget.texi: Nuke @refill.
+
+       * Makefile.in (install-dvi, install-html, install-pdf)
+       (install-ps, uninstall-dvi, uninstall-html, uninstall-ps)
+       (uninstall-pdf): Quote entities that might contain whitespace.
+
 2013-10-17  Jay Belanger  <jay.p.belanger@gmail.com>
 
        * calc.el (Data Type Formats): Don't specify the size at
        * org.texi (Clocking commands): Document the use of S-M-<up/down>
        on clock timestamps.
 
-       * org.texi (Fast access to TODO states): Explicitely says only
+       * org.texi (Fast access to TODO states): Explicitly says only
        letters are supported as fast TODO selection keys.
 
        * org.texi (Link abbreviations): Illustrate the use of the "%h"
 
 2012-01-03  Bastien Guerry  <bzg@gnu.org>  (tiny change)
 
-       * org.texi (Selective export): Explicitely mention the default
+       * org.texi (Selective export): Explicitly mention the default
        values for `org-export-select-tags',
        `org-export-exclude-tags'.
 
index 30fc495317224f5c77f99728623deeb63d87dede..f43520e97a43c5a91a0afda734263075b6a59a55 100644 (file)
@@ -877,21 +877,21 @@ dist:
 .PHONY: install-dvi install-html install-pdf install-ps install-doc
 
 install-dvi: dvi
-       umask 022; $(MKDIR_P) $(DESTDIR)$(dvidir)
-       $(INSTALL_DATA) $(DVI_TARGETS) $(DESTDIR)$(dvidir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(dvidir)"
+       $(INSTALL_DATA) $(DVI_TARGETS) "$(DESTDIR)$(dvidir)"
 install-html: html
-       umask 022; $(MKDIR_P) $(DESTDIR)$(htmldir)
-       $(INSTALL_DATA) $(HTML_TARGETS) $(DESTDIR)$(htmldir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+       $(INSTALL_DATA) $(HTML_TARGETS) "$(DESTDIR)$(htmldir)"
 install-pdf: pdf
-        umask 022;$(MKDIR_P) $(DESTDIR)$(pdfdir)
-       $(INSTALL_DATA) $(PDF_TARGETS) $(DESTDIR)$(pdfdir)
+        umask 022;$(MKDIR_P) "$(DESTDIR)$(pdfdir)"
+       $(INSTALL_DATA) $(PDF_TARGETS) "$(DESTDIR)$(pdfdir)"
 install-ps: ps
-       umask 022; $(MKDIR_P) $(DESTDIR)$(psdir)
+       umask 022; $(MKDIR_P) "$(DESTDIR)$(psdir)"
        for file in $(PS_TARGETS); do \
-         $(INSTALL_DATA) $${file} $(DESTDIR)$(psdir); \
+         $(INSTALL_DATA) $${file} "$(DESTDIR)$(psdir)"; \
          [ -n "${GZIP_PROG}" ] || continue; \
-         rm -f $(DESTDIR)$(psdir)/$${file}.gz; \
-         ${GZIP_PROG} -9n $(DESTDIR)$(psdir)/$${file}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}.gz"; \
+         ${GZIP_PROG} -9n "$(DESTDIR)$(psdir)/$${file}"; \
        done
 
 ## Top-level Makefile installs the info pages.
@@ -903,20 +903,20 @@ install-doc: install-dvi install-html install-pdf install-ps
 
 uninstall-dvi:
        for file in $(DVI_TARGETS); do \
-         rm -f $(DESTDIR)$(dvidir)/$${file}; \
+         rm -f "$(DESTDIR)$(dvidir)/$${file}"; \
        done
 uninstall-html:
        for file in $(HTML_TARGETS); do \
-         rm -f $(DESTDIR)$(htmldir)/$${file}; \
+         rm -f "$(DESTDIR)$(htmldir)/$${file}"; \
        done
 uninstall-ps:
        ext= ; [ -n "${GZIP_PROG}" ] && ext=.gz; \
        for file in $(PS_TARGETS); do \
-         rm -f $(DESTDIR)$(psdir)/$${file}$${ext}; \
+         rm -f "$(DESTDIR)$(psdir)/$${file}$${ext}"; \
        done
 uninstall-pdf:
        for file in $(PDF_TARGETS); do \
-         rm -f $(DESTDIR)$(pdfdir)/$${file}; \
+         rm -f "$(DESTDIR)$(pdfdir)/$${file}"; \
        done
 
 uninstall-doc: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
index 04160eafad051ee0461230f138a8182a32ebd52e..0154c82750a56e3f7ef4d484efe58ba67db47f5f 100644 (file)
@@ -35696,6 +35696,14 @@ have different dimensions. The default value of @code{calc-ensure-consistent-uni
 is @code{nil}.
 @end defvar
 
+@defvar calc-context-sensitive-enter
+The command @code{calc-enter} will typically duplicate the top of the
+stack.  If @code{calc-context-sensitive-enter} is non-@code{nil},
+then the @code{calc-enter} will copy the element at the cursor to the
+top of the stack.  The default value of
+@code{calc-context-sensitive-enter} is @code{nil}.
+@end defvar
+
 @defvar calc-undo-length
 The variable @code{calc-undo-length} determines the number of undo
 steps that Calc will keep track of when @code{calc-quit} is called.
index 1e3d11f6dc6bd4dbd528a6af17286e0880fedf5c..0b88604543e896645efe3f58260de96b0a901dd9 100644 (file)
@@ -560,7 +560,7 @@ of marked files.
 @vindex dired-guess-shell-alist-default
 Predefined rules for shell commands.  Set this to @code{nil} to turn guessing off.
 The elements of @code{dired-guess-shell-alist-user} (defined by the
-user) will override these rules.@refill
+user) will override these rules.
 
 @item dired-guess-shell-alist-user
 @vindex dired-guess-shell-alist-user
@@ -568,7 +568,6 @@ If non-@code{nil}, a user-defined alist of file regexps and their suggested
 commands.  These rules take precedence over the predefined rules in the
 variable @code{dired-guess-shell-alist-default} (to which they are prepended)
 when @code{dired-do-shell-command} is run).
-@refill
 
 Each element of the alist looks like
 
index c7f3e3b1a61db827e0295b0f56ebc6b9fca14ba8..aa9df988969ffee4f992383b74940831e0c91e1d 100644 (file)
@@ -138,7 +138,7 @@ list of the pseudo-class @samp{*Globals*};
 
 @item
 Types (@code{enum}s, and @code{typedef}s defined with class
-scope).@refill
+scope).
 @end itemize
 
 You can switch member buffers from one list to another, or to another
@@ -210,7 +210,7 @@ per line.
 
 @findex --help
 When invoked with option @samp{--help}, @command{ebrowse} prints a list of
-available command line options.@refill
+available command line options.
 
 @menu
 * Input files::         Specifying which files to parse
@@ -478,12 +478,12 @@ name.
 This command views the class declaration if the database
 contains information about it.  If you don't parse the entire source
 you are working on, some classes will only be known to exist but the
-location of their declarations and definitions will not be known.@refill
+location of their declarations and definitions will not be known.
 
 @item RET
 Works like @kbd{SPC}, except that it finds the class
 declaration rather than viewing it, so that it is ready for
-editing.@refill
+editing.
 @end table
 
 The same functionality is available from the menu opened with
@@ -570,7 +570,7 @@ positions the cursor on the class in the class tree.
 If the branch of the class tree containing the class searched for is
 currently collapsed, the class itself and all its base classes are
 recursively made visible.  (See also @ref{Expanding and
-Collapsing}.)@refill
+Collapsing}.)
 
 This function is also available from the tree buffer's context menu.
 
@@ -634,7 +634,7 @@ Here is an example of a tree buffer with file names displayed.
 You can expand and collapse parts of a tree to reduce the complexity of
 large class hierarchies.  Expanding or collapsing branches of a tree has
 no impact on the functionality of other commands, like @kbd{/}.  (See
-also @ref{Go to Class}.)@refill
+also @ref{Go to Class}.)
 
 Collapsed branches are indicated with an ellipsis following the class
 name like in the example below.
@@ -734,7 +734,7 @@ context menu.
 
 Classes can be marked for operations similar to the standard Emacs
 commands @kbd{M-x tags-search} and @kbd{M-x tags-query-replace} (see
-also @xref{Tags-like Functions}.)@refill
+also @xref{Tags-like Functions}.)
 
 @table @kbd
 @cindex toggle mark
@@ -1292,7 +1292,7 @@ When jumping to a member declaration or definition with one of
 Ebrowse's commands, the position from where you performed the
 jump and the position where you jumped to are recorded in a
 @dfn{position stack}.  There are several ways in which you can quickly
-move to positions in the stack:@refill
+move to positions in the stack:
 
 @table @kbd
 @cindex return to original position
index f2e787fd5888965a1195fa231e0937712cadcc45..283082141dc3890463616259f329eed94b4aef29 100644 (file)
@@ -1564,26 +1564,22 @@ Type: @code{string} @*
 Default Value: @code{"Untitled"}
 
 The name used when generating distribution files.
-@refill
 
 @item :version
 Type: @code{string} @*
 Default Value: @code{"1.0"}
 
 The version number used when distributing files.
-@refill
 
 @item :directory
 Type: @code{string}
 
 Directory this project is associated with.
-@refill
 
 @item :file
 Type: @code{string}
 
 File name where this project is stored.
-@refill
 
 @end table
 
@@ -1656,35 +1652,30 @@ Make sure placeholder @var{THIS} is replaced with the real thing, and pass throu
 Type: @code{list}
 
 List of top level targets in this project.
-@refill
 
 @item :tool-cache
 Type: @code{list}
 
 List of tool cache configurations in this project.
 This allows any tool to create, manage, and persist project-specific settings.
-@refill
 
 @item :web-site-url
 Type: @code{string} @*
 
 URL to this projects web site.
 This is a URL to be sent to a web site for documentation.
-@refill
 
 @item :web-site-directory @*
 
 A directory where web pages can be found by Emacs.
 For remote locations use a path compatible with ange-ftp or EFS@.
 You can also use TRAMP for use with rcp & scp.
-@refill
 
 @item :web-site-file @*
 
 A file which contains the home page for this project.
 This file can be relative to slot @code{web-site-directory}.
 This can be a local file, use ange-ftp, EFS, or TRAMP.
-@refill
 
 @item :ftp-site
 Type: @code{string} @*
@@ -1692,7 +1683,6 @@ Type: @code{string} @*
 FTP site where this project's distribution can be found.
 This FTP site should be in Emacs form, as needed by @code{ange-ftp}, but can
 also be of a form used by TRAMP for use with scp, or rcp.
-@refill
 
 @item :ftp-upload-site
 Type: @code{string} @*
@@ -1700,7 +1690,6 @@ Type: @code{string} @*
 FTP Site to upload new distributions to.
 This FTP site should be in Emacs form as needed by @code{ange-ftp}.
 If this slot is @code{nil}, then use @code{ftp-site} instead.
-@refill
 
 @item :configurations
 Type: @code{list} @*
@@ -1709,19 +1698,16 @@ Default Value: @code{("debug" "release")}
 List of available configuration types.
 Individual target/project types can form associations between a configuration,
 and target specific elements such as build variables.
-@refill
 
 @item :configuration-default @*
 Default Value: @code{"debug"}
 
 The default configuration.
-@refill
 
 @item :local-variables @*
 Default Value: @code{nil}
 
 Project local variables
-@refill
 
 @end table
 
@@ -1966,7 +1952,6 @@ buffer's @code{default-directory} (not starting with a /).  Directories
 that are relative to the project's root should start with a /, such
 as  "/include", meaning the directory @code{include} off the project root
 directory.
-@refill
 
 @item :system-include-path
 Type: @code{list} @*
@@ -1976,7 +1961,6 @@ The system include path for files in this project.
 C files initialized in an ede-cpp-root-project have their semantic
 system include path set to this value.  If this is @code{nil}, then the
 semantic path is not modified.
-@refill
 
 @item :spp-table
 Type: @code{list} @*
@@ -1988,7 +1972,6 @@ These macros might be passed in through the command line compiler, or
 are critical symbols derived from header files.  Providing header files
 macro values through this slot improves accuracy and performance.
 Use `:spp-files' to use these files directly.
-@refill
 
 @item :spp-files
 Type: @code{list} @*
@@ -1998,14 +1981,12 @@ C header file with Preprocessor macros for your files.
 The PreProcessor symbols appearing in these files will be used while
 parsing files in this project.
 See @code{semantic-lex-c-preprocessor-symbol-map} for more on how this works.
-@refill
 
 @item :header-match-regexp
 Type: @code{string} @*
 Default Value: @code{"\\.\\(h\\(h\\|xx\\|pp\\|\\+\\+\\)?\\|H\\)$\\|\\<\\w+$"}
 
 Regexp used to identify C/C++ header files.
-@refill
 
 @item :locate-fcn
 Type: @code{(or null function)} @*
@@ -2020,7 +2001,6 @@ The function symbol must take two arguments:
 
 It should return the fully qualified file name passed in from NAME@.  If that file does not
 exist, it should return nil.
-@refill
 
 @end table
 
@@ -2144,14 +2124,12 @@ The type of Makefile to generate.
 Can be one of @code{'Makefile}, 'Makefile.in, or 'Makefile.am.
 If this value is NOT @code{'Makefile}, then that overrides the @code{:makefile} slot
 in targets.
-@refill
 
 @item :variables
 Type: @code{list} @*
 Default Value: @code{nil}
 
 Variables to set in this Makefile.
-@refill
 
 @item :configuration-variables
 Type: @code{list} @*
@@ -2159,27 +2137,23 @@ Default Value: @code{("debug" (("DEBUG" . "1")))}
 
 Makefile variables to use in different configurations.
 These variables are used in the makefile when a configuration becomes active.
-@refill
 
 @item :inference-rules @*
 Default Value: @code{nil}
 
 Inference rules to add to the makefile.
-@refill
 
 @item :include-file @*
 Default Value: @code{nil}
 
 Additional files to include.
 These files can contain additional rules, variables, and customizations.
-@refill
 
 @item :automatic-dependencies
 Type: @code{boolean} @*
 Default Value: @code{t}
 
 Non-@code{nil} to do implement automatic dependencies in the Makefile.
-@refill
 
 @item :metasubproject
 Type: @code{boolean} @*
@@ -2190,7 +2164,6 @@ Usually, a subproject is determined by a parent project.  If multiple top level
 projects are grouped into a large project not maintained by EDE, then you need
 to set this to non-nil.  The only effect is that the @code{dist} rule will then avoid
 making a tar file.
-@refill
 
 @end table
 
@@ -2380,7 +2353,6 @@ Type: @code{list} @*
 Default Value: @code{nil}
 
 Variables to set in this Makefile, at top of file.
-@refill
 
 @item :additional-variables
 Type: @code{(or null list)} @*
@@ -2388,7 +2360,6 @@ Default Value: @code{nil}
 
 Arbitrary variables needed from this project.
 It is safe to leave this blank.
-@refill
 
 @item :additional-rules
 Type: @code{(or null list)} @*
@@ -2396,7 +2367,6 @@ Default Value: @code{nil}
 
 Arbitrary rules and dependencies needed to make this target.
 It is safe to leave this blank.
-@refill
 
 @item :installation-domain
 Type: @code{symbol} @*
@@ -2404,7 +2374,6 @@ Default Value: @code{user}
 
 Installation domain specification.
 The variable GNUSTEP_INSTALLATION_DOMAIN is set at this value.
-@refill
 
 @item :preamble
 Type: @code{(or null list)} @*
@@ -2412,7 +2381,6 @@ Default Value: @code{(quote ("GNUmakefile.preamble"))}
 
 The auxiliary makefile for additional variables.
 Included just before the specific target files.
-@refill
 
 @item :postamble
 Type: @code{(or null list)} @*
@@ -2420,7 +2388,6 @@ Default Value: @code{(quote ("GNUmakefile.postamble"))}
 
 The auxiliary makefile for additional rules.
 Included just after the specific target files.
-@refill
 
 @item :metasubproject
 Type: @code{boolean} @*
@@ -2431,7 +2398,6 @@ Usually, a subproject is determined by a parent project.  If multiple top level
 projects are grouped into a large project not maintained by EDE, then you need
 to set this to non-nil.  The only effect is that the @code{dist} rule will then avoid
 making a tar file.
-@refill
 
 @end table
 
@@ -2536,21 +2502,18 @@ Commit change to local variables in @var{PROJ}.
 Type: @code{string}
 
 Name of this target.
-@refill
 
 @item :path
 Type: @code{string}
 
 The path to the sources of this target.
 Relative to the path of the project it belongs to.
-@refill
 
 @item :source
 Type: @code{list} @*
 Default Value: @code{nil}
 
 Source files in this target.
-@refill
 
 @item :versionsource
 Type: @code{list} @*
@@ -2560,7 +2523,6 @@ Source files with a version string in them.
 These files are checked for a version string whenever the EDE version
 of the master project is changed.  When strings are found, the version
 previously there is updated.
-@refill
 
 @end table
 
@@ -2752,14 +2714,12 @@ Retrieves the slot @code{menu} from an object of class @code{ede-target}
 Type: @code{string}
 
 Name of this target.
-@refill
 
 @item :path
 Type: @code{string}
 
 The path to the sources of this target.
 Relative to the path of the project it belongs to.
-@refill
 
 @item :auxsource
 Type: @code{list} @*
@@ -2768,7 +2728,6 @@ Default Value: @code{nil}
 Auxiliary source files included in this target.
 Each of these is considered equivalent to a source file, but it is not
 distributed, and each should have a corresponding rule to build it.
-@refill
 
 @item :compiler
 Type: @code{(or null symbol)} @*
@@ -2778,7 +2737,6 @@ The compiler to be used to compile this object.
 This should be a symbol, which contains the object defining the compiler.
 This enables save/restore to do so by name, permitting the sharing
 of these compiler resources, and global customization thereof.
-@refill
 
 @item :linker
 Type: @code{(or null symbol)} @*
@@ -2788,7 +2746,6 @@ The linker to be used to link compiled sources for this object.
 This should be a symbol, which contains the object defining the linker.
 This enables save/restore to do so by name, permitting the sharing
 of these linker resources, and global customization thereof.
-@refill
 
 @end table
 
@@ -2950,7 +2907,6 @@ Type: @code{string} @*
 Default Value: @code{"Makefile"}
 
 File name of generated Makefile.
-@refill
 
 @item :partofall
 Type: @code{boolean} @*
@@ -2959,7 +2915,6 @@ Default Value: @code{t}
 Non @code{nil} means the rule created is part of the all target.
 Setting this to @code{nil} creates the rule to build this item, but does not
 include it in the ALL`all:' rule.
-@refill
 
 @item :configuration-variables
 Type: @code{list} @*
@@ -2969,7 +2924,6 @@ Makefile variables appended to use in different configurations.
 These variables are used in the makefile when a configuration becomes active.
 Target variables are always renamed such as foo_CFLAGS, then included into
 commands where the variable would usually appear.
-@refill
 
 @item :rules
 Type: @code{list} @*
@@ -2977,7 +2931,6 @@ Default Value: @code{nil}
 
 Arbitrary rules and dependencies needed to make this target.
 It is safe to leave this blank.
-@refill
 
 @end table
 
@@ -3221,7 +3174,6 @@ The linker flag "-l" is automatically prepended.  Do not include a "lib"
 prefix, or a ".so" suffix.
 
 Note: Currently only used for Automake projects.
-@refill
 
 @item :ldflags
 Type: @code{list} @*
@@ -3232,7 +3184,6 @@ Use ldlibs to add addition libraries.  Use this to specify specific
 options to the linker.
 
 Note: Not currently used.  This bug needs to be fixed.
-@refill
 
 @end table
 
@@ -3358,7 +3309,6 @@ Additional packages needed.
 There should only be one toplevel package per auxiliary tool needed.
 These packages location is found, and added to the compile time
 load path.
-@refill
 
 @end table
 
@@ -3439,7 +3389,6 @@ Default Value: @code{"loaddefs.el"}
 The file that autoload definitions are placed in.
 There should be one load defs file for a given package.  The load defs are created
 for all Emacs Lisp sources that exist in the directory of the created target.
-@refill
 
 @item :autoload-dirs
 Type: @code{list} @*
@@ -3447,7 +3396,6 @@ Default Value: @code{nil}
 
 The directories to scan for autoload definitions.
 If @code{nil} defaults to the current directory.
-@refill
 
 @end table
 
@@ -3547,7 +3495,6 @@ Default Value: @code{""}
 
 Miscellaneous sources which have a specialized makefile.
 The sub-makefile is used to build this target.
-@refill
 
 @end table
 
@@ -3604,7 +3551,6 @@ Default Value: @code{""}
 
 The main menu resides in this file.
 All other sources should be included independently.
-@refill
 
 @end table
 
@@ -3687,7 +3633,6 @@ Type: @code{string} @*
 Default Value: @code{"guile"}
 
 The preferred interpreter for this code.
-@refill
 
 @end table
 
@@ -3817,7 +3762,6 @@ No children
 Default Value: @code{nil}
 
 Additional LD args.
-@refill
 @end table
 @end table
 
@@ -3949,7 +3893,6 @@ No children
 Default Value: @code{nil}
 
 Additional texinfo included in this one.
-@refill
 
 @end table
 @end table
@@ -4036,21 +3979,18 @@ Type: @code{eieio-instance-inheritor-child}
 The parent of this instance.
 If a slot of this class is reference, and is unbound, then  the parent
 is checked for a value.
-@refill
 
 @item :name
 Type: @code{string}
 
 The name of this type of source code.
 Such as "C" or "Emacs Lisp"
-@refill
 
 @item :sourcepattern
 Type: @code{string} @*
 Default Value: @code{".*"}
 
 Emacs regex matching sourcecode this target accepts.
-@refill
 
 @item :auxsourcepattern
 Type: @code{(or null string)} @*
@@ -4059,7 +3999,6 @@ Default Value: @code{nil}
 Emacs regex matching auxiliary source code this target accepts.
 Aux source are source code files needed for compilation, which are not compiled
 themselves.
-@refill
 
 @item :enable-subdirectories
 Type: @code{boolean} @*
@@ -4069,7 +4008,6 @@ Non @code{nil} if this sourcecode type uses subdirectores.
 If sourcecode always lives near the target creating it, this should be nil.
 If sourcecode can, or typically lives in a subdirectory of the owning
 target, set this to t.
-@refill
 
 @item :garbagepattern
 Type: @code{list} @*
@@ -4078,7 +4016,6 @@ Default Value: @code{nil}
 Shell file regex matching files considered as garbage.
 This is a list of items added to an @code{rm} command when executing a @code{clean}
 type directive.
-@refill
 
 @end table
 
@@ -4158,13 +4095,11 @@ Type: @code{eieio-instance-inheritor-child}
 The parent of this instance.
 If a slot of this class is reference, and is unbound, then  the parent
 is checked for a value.
-@refill
 
 @item :name
 Type: @code{string}
 
 Name of this type of compiler.
-@refill
 
 @item :variables
 Type: @code{list}
@@ -4173,7 +4108,6 @@ Variables needed in the Makefile for this compiler.
 An assoc list where each element is (VARNAME . VALUE) where VARNAME
 is a string, and VALUE is either a string, or a list of strings.
 For example, GCC would define CC=gcc, and emacs would define EMACS=emacs.
-@refill
 
 @item :sourcetype
 Type: @code{list}
@@ -4181,7 +4115,6 @@ Type: @code{list}
 A list of @code{ede-sourcecode} @xref{ede-sourcecode}. objects this class will handle.
 This is used to match target objects with the compilers and linkers
 they can use, and which files this object is interested in.
-@refill
 
 @item :rules
 Type: @code{list} @*
@@ -4189,7 +4122,6 @@ Default Value: @code{nil}
 
 Auxiliary rules needed for this compiler to run.
 For example, yacc/lex files need additional chain rules, or inferences.
-@refill
 
 @item :commands
 Type: @code{list}
@@ -4197,7 +4129,6 @@ Type: @code{list}
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
 it's rule definition.
-@refill
 
 @item :autoconf
 Type: @code{list} @*
@@ -4208,14 +4139,12 @@ When a project is in Automake mode, this defines the autoconf function to
 call to initialize automake to use this compiler.
 For example, there may be multiple C compilers, but they all probably
 use the same autoconf form.
-@refill
 
 @item :objectextention
 Type: @code{string}
 
 A string which is the extension used for object files.
 For example, C code uses .o on unix, and Emacs Lisp uses .elc.
-@refill
 
 @end table
 
@@ -4285,13 +4214,11 @@ Type: @code{eieio-instance-inheritor-child}
 The parent of this instance.
 If a slot of this class is reference, and is unbound, then  the parent
 is checked for a value.
-@refill
 
 @item :name
 Type: @code{string}
 
 Name of this type of compiler.
-@refill
 
 @item :variables
 Type: @code{list}
@@ -4300,7 +4227,6 @@ Variables needed in the Makefile for this compiler.
 An assoc list where each element is (VARNAME . VALUE) where VARNAME
 is a string, and VALUE is either a string, or a list of strings.
 For example, GCC would define CC=gcc, and emacs would define EMACS=emacs.
-@refill
 
 @item :sourcetype
 Type: @code{list}
@@ -4308,7 +4234,6 @@ Type: @code{list}
 A list of @code{ede-sourcecode} @xref{ede-sourcecode}. objects this class will handle.
 This is used to match target objects with the compilers and linkers
 they can use, and which files this object is interested in.
-@refill
 
 @item :commands
 Type: @code{list}
@@ -4316,21 +4241,18 @@ Type: @code{list}
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
 it's rule definition.
-@refill
 
 @item :objectextention
 Type: @code{string}
 
 A string which is the extension used for object files.
 For example, C code uses .o on unix, and Emacs Lisp uses .elc.
-@refill
 
 @item :makedepends
 Type: @code{boolean} @*
 Default Value: @code{nil}
 
 Non-@code{nil} if this compiler can make dependencies.
-@refill
 
 @item :uselinker
 Type: @code{boolean} @*
@@ -4339,7 +4261,6 @@ Default Value: @code{nil}
 Non-@code{nil} if this compiler creates code that can be linked.
 This requires that the containing target also define a list of available
 linkers that can be used.
-@refill
 
 @end table
 
@@ -4399,7 +4320,6 @@ Default Value: @code{t}
 Type: @code{list}
 
 A variable dedicated to dependency generation.
-@refill
 @end table
 @end table
 
@@ -4439,7 +4359,6 @@ No children
 Type: @code{string}
 
 Name of this type of compiler.
-@refill
 
 @item :variables
 Type: @code{list}
@@ -4448,7 +4367,6 @@ Variables needed in the Makefile for this compiler.
 An assoc list where each element is (VARNAME . VALUE) where VARNAME
 is a string, and VALUE is either a string, or a list of strings.
 For example, GCC would define CC=gcc, and emacs would define EMACS=emacs.
-@refill
 
 @item :sourcetype
 Type: @code{list}
@@ -4456,7 +4374,6 @@ Type: @code{list}
 A list of @code{ede-sourcecode} @xref{ede-sourcecode}. objects this class will handle.
 This is used to match target objects with the compilers and linkers
 they can use, and which files this object is interested in.
-@refill
 
 @item :commands
 Type: @code{list}
@@ -4464,14 +4381,12 @@ Type: @code{list}
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
 it's rule definition.
-@refill
 
 @item :objectextention
 Type: @code{string}
 
 A string which is the extension used for object files.
 For example, C code uses .o on unix, and Emacs Lisp uses .elc.
-@refill
 
 @end table
 @end table
index e199417aa9d1ea5c7f19eb70e8d7674d4e9764df..5b9f3a8e0045511b3ada58caa95c928abc9b67da 100644 (file)
@@ -1625,7 +1625,6 @@ inherit from a special class stored in
 with it, certain default methods or attributes can be added to all
 objects.  In CLOS, this would be named @code{STANDARD-CLASS}, and that
 symbol is an alias to @code{eieio-default-superclass}.
-@refill
 
 Currently, the default superclass is defined as follows:
 
index bdba071be55fa6395080ea2381237402c453453f..79f76560eb44f2adeb4cb1de96e90191222eb489 100644 (file)
@@ -396,7 +396,7 @@ which encryption method should be used through @xref{File Variables, ,
 variable for this.
 @vindex epa-file-encrypt-to
 
-For example, if you want an Elisp file should be encrypted with a
+For example, if you want an Elisp file to be encrypted with a
 public key associated with an email address @samp{ueno@@unixuser.org},
 add the following line to the beginning of the file.
 
index 8728d53ea27502b2c18bb665ee20d194d87c1167..ac87b98eae988b4ab0dd2f7e14f6f3c260ef9886 100644 (file)
@@ -183,9 +183,10 @@ tests run.  It looks like this:
 
 @example
 Selector: t
-Passed: 31
-Failed: 2 (2 unexpected)
-Total:  33/33
+Passed:  31
+Skipped: 0
+Failed:  2 (2 unexpected)
+Total:   33/33
 
 Started at:   2008-09-11 08:39:25-0700
 Finished.
@@ -454,6 +455,19 @@ versions, specific architectures, etc.:
 @node Tests and Their Environment
 @section Tests and Their Environment
 
+Sometimes, it doesn't make sense to run a test due to missing
+preconditions.  A required Emacs feature might not be compiled in, the
+function to be tested could call an external binary which might not be
+available on the test machine, you name it.  In this case, the macro
+@code{skip-unless} could be used to skip the test:
+
+@lisp
+(ert-deftest test-dbus ()
+  "A test that checks D-BUS functionality."
+  (skip-unless (featurep 'dbusbind))
+  ...)
+@end lisp
+
 The outcome of running a test should not depend on the current state
 of the environment, and each test should leave its environment in the
 same state it found it in.  In particular, a test should not depend on
index bbe741a7a1d9ac45206e09b3029423ad70056cf8..e8fab42b899527412a67c6547c1a53f7757a6340 100644 (file)
@@ -158,25 +158,25 @@ The following persons have made contributions to Eshell.
 @item
 Eli Zaretskii made it possible for Eshell to run without requiring
 asynchronous subprocess support.  This is important for MS-DOS, which
-does not have such support.@refill
+does not have such support.
 
 @item
-Miles Bader contributed many fixes during the port to Emacs 21.@refill
+Miles Bader contributed many fixes during the port to Emacs 21.
 
 @item
 Stefan Monnier fixed the things which bothered him, which of course made
-things better for all.@refill
+things better for all.
 
 @item
 Gerd Moellmann also helped to contribute bug fixes during the initial
-integration with Emacs 21.@refill
+integration with Emacs 21.
 
 @item
 Alex Schroeder contributed code for interactively querying the user
-before overwriting files.@refill
+before overwriting files.
 
 @item
-Sudish Joseph helped with some XEmacs compatibility issues.@refill
+Sudish Joseph helped with some XEmacs compatibility issues.
 @end itemize
 
 Apart from these, a lot of people have sent suggestions, ideas,
index 832976e9ea0dcf7fee54374fbb9b6e16ced5e16e..5c416b65d7747c6af3c57c98eb8142c8887718fb 100644 (file)
@@ -2,7 +2,7 @@
 @c %**start of header
 @setfilename ../../info/org
 @settitle The Org Manual
-@set VERSION 7.9.3f (GNU Emacs 24.3)
+@set VERSION 8.2.3 (GNU Emacs 24.3)
 
 @c Use proper quote and backtick for code sections in PDF output
 @c Cf. Texinfo manual 14.2
@@ -10,7 +10,7 @@
 @set txicodequotebacktick
 
 @c Version and Contact Info
-@set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
+@set MAINTAINERSITE @uref{http://orgmode.org,maintainers web page}
 @set AUTHOR Carsten Dominik
 @set MAINTAINER Carsten Dominik
 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
@@ -287,7 +287,8 @@ modify this GNU manual.''
 
 @subtitle Release @value{VERSION}
 @author by Carsten Dominik
-with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, Thomas Dye and Jambunathan K.
+with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan
+Davison, Eric Schulte, Thomas Dye, Jambunathan K and Nicolas Goaziou.
 
 @c The following two commands start the copyright page.
 @page
@@ -320,7 +321,7 @@ with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison,
 * Capture - Refile - Archive::  The ins and outs for projects
 * Agenda Views::                Collecting information into views
 * Markup::                      Prepare text for rich export
-* Exporting::                   Sharing and publishing of notes
+* Exporting::                   Sharing and publishing notes
 * Publishing::                  Create a web site of linked Org files
 * Working With Source Code::    Export, evaluate, and tangle code blocks
 * Miscellaneous::               All the rest which did not fit elsewhere
@@ -357,6 +358,18 @@ Document structure
 * Blocks::                      Folding blocks
 * Footnotes::                   How footnotes are defined in Org's syntax
 * Orgstruct mode::              Structure editing outside Org
+* Org syntax::                  Formal description of Org's syntax
+
+Visibility cycling
+
+* Global and local cycling::    Cycling through various visibility states
+* Initial visibility::          Setting the initial visibility state
+* Catching invisible edits::    Preventing mistakes when editing invisible parts
+
+Global and local cycling
+
+* Initial visibility::          Setting the initial visibility state
+* Catching invisible edits::    Preventing mistakes when editing invisible parts
 
 Tables
 
@@ -375,6 +388,7 @@ The spreadsheet
 * Durations and time values::   How to compute durations and time values
 * Field and range formulas::    Formula for specific (ranges of) fields
 * Column formulas::             Formulas valid for an entire column
+* Lookup functions::            Lookup functions for searching tables
 * Editing and debugging formulas::  Fixing formulas
 * Updating the table::          Recomputing all dependent fields
 * Advanced features::           Field and column names, parameters and automatic recalc
@@ -423,6 +437,7 @@ Tags
 
 * Tag inheritance::             Tags use the tree structure of the outline
 * Setting tags::                How to assign tags to a headline
+* Tag groups::                  Use one tag to search for several tags
 * Tag searches::                Searching for combinations of tags
 
 Properties and columns
@@ -477,7 +492,7 @@ Capture - Refile - Archive
 * Attachments::                 Add files to tasks
 * RSS Feeds::                   Getting input from RSS feeds
 * Protocols::                   External (e.g., Browser) access to Emacs and Org
-* Refiling notes::              Moving a tree from one place to another
+* Refile and copy::             Moving/copying a tree from one place to another
 * Archiving::                   What to do with finished projects
 
 Capture
@@ -521,7 +536,8 @@ Presentation and sorting
 
 * Categories::                  Not all tasks are equal
 * Time-of-day specifications::  How the agenda knows the time
-* Sorting of agenda items::     The order of things
+* Sorting agenda items::        The order of things
+* Filtering/limiting agenda items::  Dynamically narrow the agenda
 
 Custom agenda views
 
@@ -532,19 +548,19 @@ Custom agenda views
 Markup for rich export
 
 * Structural markup elements::  The basic structure as seen by the exporter
-* Images and tables::           Tables and Images will be included
+* Images and tables::           Images, tables and caption mechanism
 * Literal examples::            Source code examples with special formatting
 * Include files::               Include additional files into a document
 * Index entries::               Making an index
-* Macro replacement::           Use macros to create complex output
+* Macro replacement::           Use macros to create templates
 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
+* Special blocks::              Containers targeted at export back-ends
 
 Structural markup elements
 
 * Document title::              Where the title is taken from
 * Headings and sections::       The document structure as seen by the exporter
 * Table of contents::           The if and where of the table of contents
-* Initial text::                Text before the first heading?
 * Lists::                       Lists
 * Paragraphs::                  Paragraphs
 * Footnote markup::             Footnotes
@@ -562,22 +578,24 @@ Embedded @LaTeX{}
 
 Exporting
 
-* Selective export::            Using tags to select and exclude trees
-* Export options::              Per-file export settings
-* The export dispatcher::       How to access exporter commands
+* The Export Dispatcher::       The main exporter interface
+* Export back-ends::            Built-in export formats
+* Export settings::             Generic export settings
 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
+* Beamer export::               Exporting as a Beamer presentation
 * HTML export::                 Exporting to HTML
 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
-* DocBook export::              Exporting to DocBook
+* Markdown export::             Exporting to Markdown
 * OpenDocument Text export::    Exporting to OpenDocument Text
-* TaskJuggler export::          Exporting to TaskJuggler
-* Freemind export::             Exporting to Freemind mind maps
-* XOXO export::                 Exporting to XOXO
-* iCalendar export::            Exporting in iCalendar format
+* iCalendar export::            Exporting to iCalendar
+* Other built-in back-ends::    Exporting to @code{Texinfo}, a man page, or Org
+* Export in foreign buffers::   Author tables in lists in Org syntax
+* Advanced configuration::      Fine-tuning the export output
 
 HTML export
 
 * HTML Export commands::        How to invoke HTML export
+* HTML doctypes::               Org can export to various (X)HTML flavors
 * HTML preamble and postamble::  How to insert a preamble and a postamble
 * Quoting HTML tags::           Using direct HTML in Org mode
 * Links in HTML export::        How links will be interpreted and formatted
@@ -590,21 +608,10 @@ HTML export
 
 @LaTeX{} and PDF export
 
-* @LaTeX{}/PDF export commands::
+* @LaTeX{} export commands::    How to export to LaTeX and PDF
 * Header and sectioning::       Setting up the export file structure
 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
-* Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
-* Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
-* Beamer class export::         Turning the file into a presentation
-
-DocBook export
-
-* DocBook export commands::     How to invoke DocBook export
-* Quoting DocBook code::        Incorporating DocBook code in Org files
-* Recursive sections::          Recursive sections in DocBook
-* Tables in DocBook export::    Tables are exported as HTML tables
-* Images in DocBook export::    How to insert figures into DocBook output
-* Special characters::          How to handle special characters
+* @LaTeX{} specific attributes::  Controlling @LaTeX{} output
 
 OpenDocument Text export
 
@@ -680,8 +687,8 @@ Using header arguments
 
 * System-wide header arguments::  Set global default values
 * Language-specific header arguments::  Set default values by language
-* Buffer-wide header arguments::  Set default values for a specific buffer
 * Header arguments in Org mode properties::  Set default values for a buffer or heading
+* Language-specific header arguments in Org mode properties::  Set language-specific default values for a buffer or heading
 * Code block specific header arguments::  The most common way to set values
 * Header arguments in function calls::  The most specific level
 
@@ -714,8 +721,12 @@ Specific header arguments
 * colnames::                    Handle column names in tables
 * rownames::                    Handle row names in tables
 * shebang::                     Make tangled files executable
+* tangle-mode::                 Set permission of tangled files
 * eval::                        Limit evaluation of specific code blocks
 * wrap::                        Mark source block evaluation results
+* post::                        Post processing of code block results
+* prologue::                    Text to prepend to code block body
+* epilogue::                    Text to append to code block body
 
 Miscellaneous
 
@@ -729,7 +740,7 @@ Miscellaneous
 * Clean view::                  Getting rid of leading stars in the outline
 * TTY keys::                    Using Org on a tty
 * Interaction::                 Other Emacs packages
-* org-crypt.el::                Encrypting Org files
+* org-crypt::                   Encrypting Org files
 
 Interaction with other packages
 
@@ -741,11 +752,13 @@ Hacking
 * Hooks::                       How to reach into Org's internals
 * Add-on packages::             Available extensions
 * Adding hyperlink types::      New custom link types
+* Adding export back-ends::     How to write new export back-ends
 * Context-sensitive commands::  How to add functionality to such commands
 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
-* Extracting agenda information::  Postprocessing of agenda information
+* Speeding up your agendas::    Tips on how to speed up your agendas
+* Extracting agenda information::  Post-processing of agenda information
 * Using the property API::      Writing programs that use entry properties
 * Using the mapping API::       Mapping over all or selected entries
 
@@ -754,7 +767,7 @@ Tables and lists in arbitrary syntax
 * Radio tables::                Sending and receiving radio tables
 * A @LaTeX{} example::          Step by step, almost a tutorial
 * Translator functions::        Copy and modify
-* Radio lists::                 Doing the same for lists
+* Radio lists::                 Sending and receiving lists
 
 MobileOrg
 
@@ -794,7 +807,7 @@ timestamps, and scheduling.  It dynamically compiles entries into an
 agenda that utilizes and smoothly integrates much of the Emacs calendar
 and diary.  Plain text URL-like links connect to websites, emails,
 Usenet messages, BBDB entries, and any files related to the projects.
-For printing and sharing of notes, an Org file can be exported as a
+For printing and sharing notes, an Org file can be exported as a
 structured ASCII file, as HTML, or (TODO and agenda items only) as an
 iCalendar file.  It can also serve as a publishing tool for a set of
 linked web pages.
@@ -828,7 +841,7 @@ ends, for example:
 @pindex GTD, Getting Things Done
 @r{@bullet{} an environment in which to implement David Allen's GTD system}
 @r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
-@r{@bullet{} a publishing tool to create a set of interlinked webpages}
+@r{@bullet{} a publishing tool to create a set of interlinked web pages}
 @r{@bullet{} an environment for literate programming}
 @end example
 
@@ -867,10 +880,11 @@ We @b{strongly recommend} to stick to a single installation method.
 
 Recent Emacs distributions include a packaging system which lets you install
 Elisp libraries.  You can install Org with @kbd{M-x package-install RET org}.
-To make sure your Org configuration is well taken into account, initialize
-the package system with @code{(package-initialize)} before setting any Org
-option.  If you want to use Org's package repository, check out the
-@uref{http://orgmode.org/elpa.html, Org ELPA page}.
+You need to do this in a session where no @code{.org} file has been visited.
+Then, to make sure your Org configuration is taken into account, initialize
+the package system with @code{(package-initialize)} in your @file{.emacs}
+before setting any Org option.  If you want to use Org's package repository,
+check out the @uref{http://orgmode.org/elpa.html, Org ELPA page}.
 
 @subsubheading Downloading Org as an archive
 
@@ -878,17 +892,17 @@ You can download Org latest release from @uref{http://orgmode.org/, Org's
 website}.  In this case, make sure you set the load-path correctly in your
 @file{.emacs}:
 
-@example
+@lisp
 (add-to-list 'load-path "~/path/to/orgdir/lisp")
-@end example
+@end lisp
 
 The downloaded archive contains contributed libraries that are not included
 in Emacs.  If you want to use them, add the @file{contrib} directory to your
 load-path:
 
-@example
+@lisp
 (add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
-@end example
+@end lisp
 
 Optionally, you can compile the files and/or install them in your system.
 Run @code{make help} to list compilation and installation options.
@@ -1001,10 +1015,10 @@ version of Org available---if you are running an outdated version, it is
 quite possible that the bug has been fixed already.  If the bug persists,
 prepare a report and provide as much information as possible, including the
 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
-(@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
+(@kbd{M-x org-version RET}), as well as the Org related setup in
 @file{.emacs}.  The easiest way to do this is to use the command
 @example
-@kbd{M-x org-submit-bug-report}
+@kbd{M-x org-submit-bug-report RET}
 @end example
 @noindent which will put all this information into an Emacs mail buffer so
 that you only need to add your description.  If you re not sending the Email
@@ -1025,7 +1039,7 @@ is not necessary.  In that case it is sufficient to start Emacs as
 @code{emacs -Q}.  The @code{minimal-org.el} setup file can have contents as
 shown below.
 
-@example
+@lisp
 ;;; Minimal setup to load latest `org-mode'
 
 ;; activate debugging
@@ -1036,7 +1050,7 @@ shown below.
 ;; add latest org-mode to load path
 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
-@end example
+@end lisp
 
 If an error occurs, a backtrace can be very useful (see below on how to
 create one).  Often a small example file helps, along with clear information
@@ -1064,7 +1078,7 @@ Reload uncompiled versions of all Org mode Lisp files.  The backtrace
 contains much more information if it is produced with uncompiled code.
 To do this, use
 @example
-C-u M-x org-reload RET
+@kbd{C-u M-x org-reload RET}
 @end example
 @noindent
 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
@@ -1109,7 +1123,7 @@ and @i{environment keywords} (like @code{#+BEGIN_HTML} to start a @code{HTML}
 environment).  They are written in uppercase in the manual to enhance its
 readability, but you can use lowercase in your Org files@footnote{Easy
 templates insert lowercase keywords and Babel dynamically inserts
-@code{#+results}.}
+@code{#+results}.}.
 
 @subsubheading Keybindings and commands
 @kindex C-c a
@@ -1152,6 +1166,7 @@ edit the structure of the document.
 * Blocks::                      Folding blocks
 * Footnotes::                   How footnotes are defined in Org's syntax
 * Orgstruct mode::              Structure editing outside Org
+* Org syntax::                  Formal description of Org's syntax
 @end menu
 
 @node Outlines, Headlines, Document Structure, Document Structure
@@ -1213,6 +1228,15 @@ variable @code{org-cycle-separator-lines} to modify this behavior.
 @cindex show hidden text
 @cindex hide text
 
+@menu
+* Global and local cycling::    Cycling through various visibility states
+* Initial visibility::          Setting the initial visibility state
+* Catching invisible edits::    Preventing mistakes when editing invisible parts
+@end menu
+
+@node Global and local cycling, Initial visibility, Visibility cycling, Visibility cycling
+@subsection Global and local cycling
+
 Outlines make it possible to hide parts of the text in the buffer.
 Org uses just two commands, bound to @key{TAB} and
 @kbd{S-@key{TAB}} to change the visibility in the buffer.
@@ -1295,6 +1319,15 @@ the previously used indirect buffer.
 Copy the @i{visible} text in the region into the kill ring.
 @end table
 
+@menu
+* Initial visibility::          Setting the initial visibility state
+* Catching invisible edits::    Preventing mistakes when editing invisible parts
+@end menu
+
+@node Initial visibility, Catching invisible edits, Global and local cycling, Visibility cycling
+@subsection Initial visibility
+
+@cindex visibility, initialize
 @vindex org-startup-folded
 @vindex org-agenda-inhibit-startup
 @cindex @code{overview}, STARTUP keyword
@@ -1302,11 +1335,13 @@ Copy the @i{visible} text in the region into the kill ring.
 @cindex @code{showall}, STARTUP keyword
 @cindex @code{showeverything}, STARTUP keyword
 
-When Emacs first visits an Org file, the global state is set to
-OVERVIEW, i.e., only the top level headlines are visible.  This can be
-configured through the variable @code{org-startup-folded}, or on a
-per-file basis by adding one of the following lines anywhere in the
-buffer:
+When Emacs first visits an Org file, the global state is set to OVERVIEW,
+i.e., only the top level headlines are visible@footnote{When
+@code{org-agenda-inhibit-startup} is non-@code{nil}, Org will not honor the default
+visibility state when first opening a file for the agenda (@pxref{Speeding up
+your agendas}).}  This can be configured through the variable
+@code{org-startup-folded}, or on a per-file basis by adding one of the
+following lines anywhere in the buffer:
 
 @example
 #+STARTUP: overview
@@ -1317,7 +1352,7 @@ buffer:
 
 The startup visibility options are ignored when the file is open for the
 first time during the agenda generation: if you want the agenda to honor
-the startup visibility, set @code{org-agenda-inhibit-startup} to nil.
+the startup visibility, set @code{org-agenda-inhibit-startup} to @code{nil}.
 
 @cindex property, VISIBILITY
 @noindent
@@ -1325,6 +1360,7 @@ Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
 and Columns}) will get their visibility adapted accordingly.  Allowed values
 for this property are @code{folded}, @code{children}, @code{content}, and
 @code{all}.
+
 @table @asis
 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
 Switch back to the startup visibility of the buffer, i.e., whatever is
@@ -1332,6 +1368,17 @@ requested by startup options and @samp{VISIBILITY} properties in individual
 entries.
 @end table
 
+@node Catching invisible edits,  , Initial visibility, Visibility cycling
+@subsection Catching invisible edits
+
+@vindex org-catch-invisible-edits
+@cindex edits, catching invisible
+Sometimes you may inadvertently edit an invisible part of the buffer and be
+confused on what has been edited and how to undo the mistake.  Setting
+@code{org-catch-invisible-edits} to non-@code{nil} will help prevent this.  See the
+docstring of this option on how Org should catch invisible edits and process
+them.
+
 @node Motion, Structure editing, Visibility cycling, Document Structure
 @section Motion
 @cindex motion, between headlines
@@ -1369,7 +1416,7 @@ q            @r{Quit}
 @end example
 @vindex org-goto-interface
 @noindent
-See also the variable @code{org-goto-interface}.
+See also the option @code{org-goto-interface}.
 @end table
 
 @node Structure editing, Sparse trees, Motion, Document Structure
@@ -1388,17 +1435,20 @@ See also the variable @code{org-goto-interface}.
 @table @asis
 @orgcmd{M-@key{RET},org-insert-heading}
 @vindex org-M-RET-may-split-line
-Insert new heading with same level as current.  If the cursor is in a plain
-list item, a new item is created (@pxref{Plain lists}).  To force creation of
-a new headline, use a prefix argument.  When this command is used in the
-middle of a line, the line is split and the rest of the line becomes the new
-headline@footnote{If you do not want the line to be split, customize the
-variable @code{org-M-RET-may-split-line}.}.  If the command is used at the
-beginning of a headline, the new headline is created before the current line.
-If at the beginning of any other line, the content of that line is made the
-new heading.  If the command is used at the end of a folded subtree (i.e.,
-behind the ellipses at the end of a headline), then a headline like the
-current one will be inserted after the end of the subtree.
+Insert a new heading/item with the same level than the one at point.
+If the cursor is in a plain list item, a new item is created
+(@pxref{Plain lists}).  To prevent this behavior in lists, call the
+command with a prefix argument.  When this command is used in the
+middle of a line, the line is split and the rest of the line becomes
+the new item or headline@footnote{If you do not want the line to be
+split, customize the variable @code{org-M-RET-may-split-line}.}.  If
+the command is used at the @emph{beginning} of a headline, the new
+headline is created before the current line.  If the command is used
+at the @emph{end} of a folded subtree (i.e., behind the ellipses at
+the end of a headline), then a headline will be
+inserted after the end of the subtree.  Calling this command with
+@kbd{C-u C-u} will unconditionally respect the headline's content and
+create a new item at the end of the parent subtree.
 @orgcmd{C-@key{RET},org-insert-heading-respect-content}
 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
 current heading, the new heading is placed after the body instead of before
@@ -1450,7 +1500,7 @@ headline marker like @samp{****}.
 @orgcmd{C-y,org-yank}
 @vindex org-yank-adjusted-subtrees
 @vindex org-yank-folded-subtrees
-Depending on the variables @code{org-yank-adjusted-subtrees} and
+Depending on the options @code{org-yank-adjusted-subtrees} and
 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
 C-x C-y}.  With the default settings, no level adjustment will take place,
@@ -1468,7 +1518,7 @@ to create a number of tasks related to a series of lectures to prepare.  For
 more details, see the docstring of the command
 @code{org-clone-subtree-with-time-shift}.
 @orgcmd{C-c C-w,org-refile}
-Refile entry or region to a different location.  @xref{Refiling notes}.
+Refile entry or region to a different location.  @xref{Refile and copy}.
 @orgcmd{C-c ^,org-sort}
 Sort same-level entries.  When there is an active region, all entries in the
 region will be sorted.  Otherwise the children of the current headline are
@@ -1550,11 +1600,10 @@ Jump to the next sparse tree match in this buffer.
 Jump to the previous sparse tree match in this buffer.
 @end table
 
-
 @noindent
 @vindex org-agenda-custom-commands
 For frequently used sparse trees of specific search strings, you can
-use the variable @code{org-agenda-custom-commands} to define fast
+use the option @code{org-agenda-custom-commands} to define fast
 keyboard access to specific sparse trees.  These commands will then be
 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
 For example:
@@ -1570,15 +1619,15 @@ a sparse tree matching the string @samp{FIXME}.
 The other sparse tree commands select headings based on TODO keywords,
 tags, or properties and will be discussed later in this manual.
 
-@kindex C-c C-e v
+@kindex C-c C-e C-v
 @cindex printing sparse trees
 @cindex visible text, printing
 To print a sparse tree, you can use the Emacs command
 @code{ps-print-buffer-with-faces} which does not print invisible parts
 of the document @footnote{This does not work under XEmacs, because
 XEmacs uses selective display for outlining, not text properties.}.
-Or you can use the command @kbd{C-c C-e v} to export only the visible
-part of the document and print the resulting file.
+Or you can use @kbd{C-c C-e C-v} to export only the visible part of
+the document and print the resulting file.
 
 @node Plain lists, Drawers, Sparse trees, Document Structure
 @section Plain lists
@@ -1604,12 +1653,12 @@ is supported, it may be better to not use it for plain list items.}  as
 bullets.
 @item
 @vindex org-plain-list-ordered-item-terminator
-@vindex org-alphabetical-lists
+@vindex org-list-allow-alphabetical
 @emph{Ordered} list items start with a numeral followed by either a period or
 a right parenthesis@footnote{You can filter out any of them by configuring
 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
 @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and
-@samp{A)} by configuring @code{org-alphabetical-lists}.  To minimize
+@samp{A)} by configuring @code{org-list-allow-alphabetical}.  To minimize
 confusion with normal text, those are limited to one character only.  Beyond
 that limit, bullets will automatically fallback to numbers.}.  If you want a
 list to start with a different value (e.g., 20), start the text of the item
@@ -1629,11 +1678,11 @@ line.  In particular, if an ordered list reaches number @samp{10.}, then the
 list.  An item ends before the next line that is less or equally indented
 than its bullet/number.
 
-@vindex org-empty-line-terminates-plain-lists
+@vindex org-list-empty-line-terminates-plain-lists
 A list ends whenever every item has ended, which means before any line less
 or equally indented than items at top level.  It also ends before two blank
-lines@footnote{See also @code{org-empty-line-terminates-plain-lists}.}.  In
-that case, all items are closed.  Here is an example:
+lines@footnote{See also @code{org-list-empty-line-terminates-plain-lists}.}.
+In that case, all items are closed.  Here is an example:
 
 @example
 @group
@@ -1705,7 +1754,7 @@ one.
 
 @table @kbd
 @kindex M-S-@key{RET}
-@item M-S-RET
+@item M-S-@key{RET}
 Insert a new item with a checkbox (@pxref{Checkboxes}).
 @kindex S-@key{down}
 @item S-up
@@ -1724,7 +1773,7 @@ similar effect.
 @item M-up
 @itemx M-down
 Move the item including subitems up/down@footnote{See
-@code{org-liste-use-circular-motion} for a cyclic behavior.} (swap with
+@code{org-list-use-circular-motion} for a cyclic behavior.} (swap with
 previous/next item of same indentation).  If the list is ordered, renumbering
 is automatic.
 @kindex M-@key{left}
@@ -1734,8 +1783,8 @@ is automatic.
 Decrease/increase the indentation of an item, leaving children alone.
 @kindex M-S-@key{left}
 @kindex M-S-@key{right}
-@item M-S-left
-@itemx M-S-right
+@item M-S-@key{left}
+@itemx M-S-@key{right}
 Decrease/increase the indentation of the item, including subitems.
 Initially, the item tree is selected based on current indentation.  When
 these commands are executed several times in direct succession, the initially
@@ -1781,9 +1830,11 @@ This command also cycles bullet styles when the cursor in on the bullet or
 anywhere in an item line, details depending on
 @code{org-support-shift-select}.
 @kindex C-c ^
+@cindex sorting, of plain list
 @item C-c ^
 Sort the plain list.  You will be prompted for the sorting method:
-numerically, alphabetically, by time, or by custom function.
+numerically, alphabetically, by time, by checked status for check lists,
+or by a custom function.
 @end table
 
 @node Drawers, Blocks, Plain lists, Document Structure
@@ -1797,10 +1848,9 @@ numerically, alphabetically, by time, or by custom function.
 @kindex C-c C-x d
 Sometimes you want to keep information associated with an entry, but you
 normally don't want to see it.  For this, Org mode has @emph{drawers}.
-Drawers need to be configured with the variable
-@code{org-drawers}@footnote{You can define additional drawers on a
-per-file basis with a line like @code{#+DRAWERS: HIDDEN STATE}}.  Drawers
-look like this:
+Drawers need to be configured with the option @code{org-drawers}@footnote{You
+can define additional drawers on a per-file basis with a line like
+@code{#+DRAWERS: HIDDEN STATE}}.  Drawers look like this:
 
 @example
 ** This is a headline
@@ -1833,6 +1883,12 @@ want to store a quick note in the LOGBOOK drawer, in a similar way to state chan
 Add a time-stamped note to the LOGBOOK drawer.
 @end table
 
+@vindex org-export-with-drawers
+You can select the name of the drawers which should be exported with
+@code{org-export-with-drawers}.  In that case, drawer contents will appear in
+export output.  Property drawers are not affected by this variable and are
+never exported.
+
 @node Blocks, Footnotes, Drawers, Document Structure
 @section Blocks
 
@@ -1842,7 +1898,7 @@ Org mode uses begin...end blocks for various purposes from including source
 code examples (@pxref{Literal examples}) to capturing time logging
 information (@pxref{Clocking work time}).  These blocks can be folded and
 unfolded by pressing TAB in the begin line.  You can also get all blocks
-folded at startup by configuring the variable @code{org-hide-block-startup}
+folded at startup by configuring the option @code{org-hide-block-startup}
 or on a per-file basis by using
 
 @cindex @code{hideblocks}, STARTUP keyword
@@ -1857,13 +1913,13 @@ or on a per-file basis by using
 @cindex footnotes
 
 Org mode supports the creation of footnotes.  In contrast to the
-@file{footnote.el} package, Org mode's footnotes are designed for work on a
-larger document, not only for one-off documents like emails.  The basic
-syntax is similar to the one used by @file{footnote.el}, i.e., a footnote is
-defined in a paragraph that is started by a footnote marker in square
-brackets in column 0, no indentation allowed.  If you need a paragraph break
-inside a footnote, use the @LaTeX{} idiom @samp{\par}.  The footnote reference
-is simply the marker in square brackets, inside text.  For example:
+@file{footnote.el} package, Org mode's footnotes are designed for work on
+a larger document, not only for one-off documents like emails.
+
+A footnote is started by a footnote marker in square brackets in column 0, no
+indentation allowed.  It ends at the next footnote definition, headline, or
+after two consecutive empty lines.  The footnote reference is simply the
+marker in square brackets, inside text.  For example:
 
 @example
 The Org homepage[fn:1] now looks a lot better than it used to.
@@ -1913,11 +1969,11 @@ is at a definition, jump to the (first) reference.
 @vindex org-footnote-define-inline
 @vindex org-footnote-section
 @vindex org-footnote-auto-adjust
-Otherwise, create a new footnote.  Depending on the variable
+Otherwise, create a new footnote.  Depending on the option
 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
 definition will be placed right into the text as part of the reference, or
-separately into the location determined by the variable
+separately into the location determined by the option
 @code{org-footnote-section}.
 
 When this command is called with a prefix argument, a menu of additional
@@ -1928,17 +1984,16 @@ s   @r{Sort the footnote definitions by reference sequence.  During editing,}
     @r{sequence.  If you want them sorted, use this command, which will}
     @r{also move entries according to @code{org-footnote-section}.  Automatic}
     @r{sorting after each insertion/deletion can be configured using the}
-    @r{variable @code{org-footnote-auto-adjust}.}
+    @r{option @code{org-footnote-auto-adjust}.}
 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
-    @r{after each insertion/deletion can be configured using the variable}
+    @r{after each insertion/deletion can be configured using the option}
     @r{@code{org-footnote-auto-adjust}.}
 S   @r{Short for first @code{r}, then @code{s} action.}
 n   @r{Normalize the footnotes by collecting all definitions (including}
     @r{inline definitions) into a special section, and then numbering them}
     @r{in sequence.  The references will then also be numbers.  This is}
     @r{meant to be the final step before finishing a document (e.g., sending}
-    @r{off an email).  The exporters do this automatically, and so could}
-    @r{something like @code{message-send-hook}.}
+    @r{off an email).}
 d   @r{Delete the footnote at point, and all definitions of and references}
     @r{to it.}
 @end example
@@ -1960,7 +2015,7 @@ Footnote labels are also links to the corresponding definition/reference, and
 you can use the usual commands to follow these links.
 @end table
 
-@node Orgstruct mode,  , Footnotes, Document Structure
+@node Orgstruct mode, Org syntax, Footnotes, Document Structure
 @section The Orgstruct minor mode
 @cindex Orgstruct mode
 @cindex minor mode for structure editing
@@ -1968,7 +2023,7 @@ you can use the usual commands to follow these links.
 If you like the intuitive way the Org mode structure editing and list
 formatting works, you might want to use these commands in other modes like
 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
-this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
+this possible.   Toggle the mode with @kbd{M-x orgstruct-mode RET}, or
 turn it on by default, for example in Message mode, with one of:
 
 @lisp
@@ -1980,10 +2035,42 @@ When this mode is active and the cursor is on a line that looks to Org like a
 headline or the first line of a list item, most structure editing commands
 will work, even if the same keys normally have different functionality in the
 major mode you are using.  If the cursor is not in one of those special
-lines, Orgstruct mode lurks silently in the shadows.  When you use
-@code{orgstruct++-mode}, Org will also export indentation and autofill
-settings into that mode, and detect item context after the first line of an
-item.
+lines, Orgstruct mode lurks silently in the shadows.
+
+When you use @code{orgstruct++-mode}, Org will also export indentation and
+autofill settings into that mode, and detect item context after the first
+line of an item.
+
+@vindex orgstruct-heading-prefix-regexp
+You can also use Org structure editing to fold and unfold headlines in
+@emph{any} file, provided you defined @code{orgstruct-heading-prefix-regexp}:
+the regular expression must match the local prefix to use before Org's
+headlines.  For example, if you set this variable to @code{";; "} in Emacs
+Lisp files, you will be able to fold and unfold headlines in Emacs Lisp
+commented lines.  Some commands like @code{org-demote} are disabled when the
+prefix is set, but folding/unfolding will work correctly.
+
+@node Org syntax,  , Orgstruct mode, Document Structure
+@section Org syntax
+@cindex Org syntax
+
+A reference document providing a formal description of Org's syntax is
+available as @uref{http://orgmode.org/worg/dev/org-syntax.html, a draft on
+Worg}, written and maintained by Nicolas Goaziou.  It defines Org's core
+internal concepts such as @code{headlines}, @code{sections}, @code{affiliated
+keywords}, @code{(greater) elements} and @code{objects}.  Each part of an Org
+file falls into one of the categories above.
+
+To explore the abstract structure of an Org buffer, run this in a buffer:
+
+@lisp
+M-: (org-element-parse-buffer) RET
+@end lisp
+
+It will output a list containing the buffer's content represented as an
+abstract structure.  The export engine relies on the information stored in
+this list.  Most interactive commands (e.g., for structure editing) also
+rely on the syntactic meaning of the surrounding context.
 
 @node Tables, Hyperlinks, Document Structure, Top
 @chapter Tables
@@ -2046,7 +2133,7 @@ inserting and deleting avoids shifting other fields.  Also, when
 typing @emph{immediately after the cursor was moved into a new field
 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
 field is automatically made blank.  If this behavior is too
-unpredictable for you, configure the variables
+unpredictable for you, configure the options
 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
 
 @table @kbd
@@ -2066,7 +2153,7 @@ table.  But it is easier just to start typing, like
 
 @tsubheading{Re-aligning and field motion}
 @orgcmd{C-c C-c,org-table-align}
-Re-align the table without moving the cursor.
+Re-align the table and don't move to another field.
 @c
 @orgcmd{<TAB>,org-table-next-field}
 Re-align the table, move to the next field.  Creates a new row if
@@ -2165,7 +2252,7 @@ be inserted with @kbd{C-y}.
 @vindex org-table-copy-increment
 When current field is empty, copy from first non-empty field above.  When not
 empty, copy current field down to next row and move cursor along with it.
-Depending on the variable @code{org-table-copy-increment}, integer field
+Depending on the option @code{org-table-copy-increment}, integer field
 values will be incremented during copy.  Integers that are too large will not
 be incremented.  Also, a @code{0} prefix argument temporarily disables the
 increment.  This key is also used by shift-selection and related modes
@@ -2181,7 +2268,7 @@ window follow the cursor through the table and always show the current
 field.  The follow mode exits automatically when the cursor leaves the table,
 or when you repeat this command with @kbd{C-u C-u C-c `}.
 @c
-@item M-x org-table-import
+@item M-x org-table-import RET
 Import a file as a table.  The table should be TAB or whitespace
 separated.  Use, for example, to import a spreadsheet table or data
 from a database, because these programs generally can write
@@ -2194,12 +2281,12 @@ Tables can also be imported by pasting tabular text into the Org
 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
 @kbd{C-c |} command (see above under @i{Creation and conversion}).
 @c
-@item M-x org-table-export
+@item M-x org-table-export RET
 @findex org-table-export
 @vindex org-table-export-default-format
 Export the table, by default as a TAB-separated file.  Use for data
 exchange with, for example, spreadsheet or database programs.  The format
-used to export the file can be configured in the variable
+used to export the file can be configured in the option
 @code{org-table-export-default-format}.  You may also use properties
 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
 name and the format for table export in a subtree.  Org supports quite
@@ -2274,7 +2361,7 @@ If you would like to overrule the automatic alignment of number-rich columns
 to the right and of string-rich column to the left, you can use @samp{<r>},
 @samp{<c>}@footnote{Centering does not work inside Emacs, but it does have an
 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
-also combine alignment and field width like this: @samp{<l10>}.
+also combine alignment and field width like this: @samp{<r10>}.
 
 Lines which only contain these formatting cookies will be removed
 automatically when exporting the document.
@@ -2323,7 +2410,7 @@ every vertical line you would like to have:
 If you like the intuitive way the Org table editor works, you
 might also want to use it in other modes like Text mode or Mail mode.
 The minor mode Orgtbl mode makes this possible.  You can always toggle
-the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
+the mode with @kbd{M-x orgtbl-mode RET}.  To turn it on by default, for
 example in Message mode, use
 
 @lisp
@@ -2359,6 +2446,7 @@ formula, moving these references by arrow keys
 * Durations and time values::   How to compute durations and time values
 * Field and range formulas::    Formula for specific (ranges of) fields
 * Column formulas::             Formulas valid for an entire column
+* Lookup functions::            Lookup functions for searching tables
 * Editing and debugging formulas::  Fixing formulas
 * Updating the table::          Recomputing all dependent fields
 * Advanced features::           Field and column names, parameters and automatic recalc
@@ -2384,8 +2472,8 @@ combination like @code{B3}, meaning the 2nd field in the 3rd row.
 @vindex org-table-use-standard-references
 However, Org prefers@footnote{Org will understand references typed by the
 user as @samp{B4}, but it will not use this syntax when offering a formula
-for editing.  You can customize this behavior using the variable
-@code{org-table-use-standard-references}.}  to use another, more general
+for editing.  You can customize this behavior using the option
+@code{org-table-use-standard-references}.} to use another, more general
 representation that looks like this:
 @example
 @@@var{row}$@var{column}
@@ -2452,15 +2540,15 @@ $1..$3        @r{first three fields in the current row}
 $P..$Q        @r{range, using column names (see under Advanced)}
 $<<<..$>>     @r{start in third column, continue to the one but last}
 @@2$1..@@4$3    @r{6 fields between these two fields (same as @code{A2..C4})}
-@@-1$-2..@@-1   @r{in the first row up, 3 fields from 2 columns on the left}
+@@-1$-2..@@-1   @r{3 fields in the row above, starting from 2 columns on the left}
 @@I..II        @r{between first and second hline, short for @code{@@I..@@II}}
 @end example
 
 @noindent Range references return a vector of values that can be fed
-into Calc vector functions.  Empty fields in ranges are normally
-suppressed, so that the vector contains only the non-empty fields (but
-see the @samp{E} mode switch below).  If there are no non-empty fields,
-@samp{[0]} is returned to avoid syntax errors in formulas.
+into Calc vector functions.  Empty fields in ranges are normally suppressed,
+so that the vector contains only the non-empty fields.  For other options
+with the mode switches @samp{E}, @samp{N} and examples @pxref{Formula syntax
+for Calc}.
 
 @subsubheading Field coordinates in formulas
 @cindex field coordinates
@@ -2493,7 +2581,7 @@ number of rows.
 
 @vindex org-table-formula-constants
 @samp{$name} is interpreted as the name of a column, parameter or
-constant.  Constants are defined globally through the variable
+constant.  Constants are defined globally through the option
 @code{org-table-formula-constants}, and locally (for the file) through a
 line like
 
@@ -2526,7 +2614,7 @@ numbers.
 @cindex references, to a different table
 @cindex name, of column or field
 @cindex constants, in calculations
-@cindex #+TBLNAME
+@cindex #+NAME, for table
 
 You may also reference constants, fields and ranges from a different table,
 either in the current file or even in a different file.  The syntax is
@@ -2537,7 +2625,7 @@ remote(NAME-OR-ID,REF)
 
 @noindent
 where NAME can be the name of a table in the current file as set by a
-@code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
+@code{#+NAME: Name} line before the table.  It can also be the ID of an
 entry, even in a different file, and the reference then refers to the first
 table in that entry.  REF is an absolute field or range reference as
 described above for example @code{@@3$3} or @code{$somename}, valid in the
@@ -2548,14 +2636,13 @@ referenced table.
 @cindex formula syntax, Calc
 @cindex syntax, of formulas
 
-A formula can be any algebraic expression understood by the Emacs
-@file{Calc} package.  @b{Note that @file{calc} has the
-non-standard convention that @samp{/} has lower precedence than
-@samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
-evaluation by @code{calc-eval} (@pxref{Calling Calc from
-Your Programs, calc-eval, Calling Calc from Your Lisp Programs, calc, GNU
-Emacs Calc Manual}),
-variable substitution takes place according to the rules described above.
+A formula can be any algebraic expression understood by the Emacs @file{Calc}
+package.  Note that @file{calc} has the non-standard convention that @samp{/}
+has lower precedence than @samp{*}, so that @samp{a/b*c} is interpreted as
+@samp{a/(b*c)}.  Before evaluation by @code{calc-eval} (@pxref{Calling Calc
+from Your Programs, calc-eval, Calling Calc from Your Lisp Programs, calc,
+GNU Emacs Calc Manual}), variable substitution takes place according to the
+rules described above.
 @cindex vectors, in table calculations
 The range vectors can be directly fed into the Calc vector functions
 like @samp{vmean} and @samp{vsum}.
@@ -2568,33 +2655,52 @@ string consists of flags to influence Calc and other modes during
 execution.  By default, Org uses the standard Calc modes (precision
 12, angular units degrees, fraction and symbolic modes off).  The display
 format, however, has been changed to @code{(float 8)} to keep tables
-compact.  The default settings can be configured using the variable
+compact.  The default settings can be configured using the option
 @code{org-calc-default-modes}.
 
-@example
-p20           @r{set the internal Calc calculation precision to 20 digits}
-n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
-              @r{format of the result of Calc passed back to Org.}
-              @r{Calc formatting is unlimited in precision as}
-              @r{long as the Calc calculation precision is greater.}
-D R           @r{angle modes: degrees, radians}
-F S           @r{fraction and symbolic modes}
-N             @r{interpret all fields as numbers, use 0 for non-numbers}
-E             @r{keep empty fields in ranges}
-L             @r{literal}
-@end example
+@noindent List of modes:
+
+@table @asis
+@item @code{p20}
+Set the internal Calc calculation precision to 20 digits.
+@item @code{n3}, @code{s3}, @code{e2}, @code{f4}
+Normal, scientific, engineering or fixed format of the result of Calc passed
+back to Org.  Calc formatting is unlimited in precision as long as the Calc
+calculation precision is greater.
+@item @code{D}, @code{R}
+Degree and radian angle modes of Calc.
+@item @code{F}, @code{S}
+Fraction and symbolic modes of Calc.
+@item @code{T}, @code{t}
+Duration computations in Calc or Lisp, @pxref{Durations and time values}.
+@item @code{E}
+If and how to consider empty fields.  Without @samp{E} empty fields in range
+references are suppressed so that the Calc vector or Lisp list contains only
+the non-empty fields.  With @samp{E} the empty fields are kept.  For empty
+fields in ranges or empty field references the value @samp{nan} (not a
+number) is used in Calc formulas and the empty string is used for Lisp
+formulas.  Add @samp{N} to use 0 instead for both formula types.  For the
+value of a field the mode @samp{N} has higher precedence than @samp{E}.
+@item @code{N}
+Interpret all fields as numbers, use 0 for non-numbers.  See the next section
+to see how this is essential for computations with Lisp formulas.  In Calc
+formulas it is used only occasionally because there number strings are
+already interpreted as numbers without @samp{N}.
+@item @code{L}
+Literal, for Lisp formulas only.  See the next section.
+@end table
 
 @noindent
-Unless you use large integer numbers or high-precision-calculation
-and -display for floating point numbers you may alternatively provide a
-@code{printf} format specifier to reformat the Calc result after it has been
+Unless you use large integer numbers or high-precision-calculation and
+-display for floating point numbers you may alternatively provide a
+@samp{printf} format specifier to reformat the Calc result after it has been
 passed back to Org instead of letting Calc already do the
-formatting@footnote{The @code{printf} reformatting is limited in precision
-because the value passed to it is converted into an @code{integer} or
-@code{double}.  The @code{integer} is limited in size by truncating the
-signed value to 32 bits.  The @code{double} is limited in precision to 64
-bits overall which leaves approximately 16 significant decimal digits.}.
-few examples:
+formatting@footnote{The @samp{printf} reformatting is limited in precision
+because the value passed to it is converted into an @samp{integer} or
+@samp{double}.  The @samp{integer} is limited in size by truncating the
+signed value to 32 bits.  The @samp{double} is limited in precision to 64
+bits overall which leaves approximately 16 significant decimal digits.}.  A
+few examples:
 
 @example
 $1+$2                @r{Sum of first and second field}
@@ -2605,19 +2711,38 @@ $0;%.1f              @r{Reformat current cell to 1 decimal}
 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
-vmean($2..$7)        @r{Compute column range mean, using vector function}
-vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
 taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
 @end example
 
-Calc also contains a complete set of logical operations.  For example
+Calc also contains a complete set of logical operations, (@pxref{Logical
+Operations, , Logical Operations, calc, GNU Emacs Calc Manual}).  For example
 
-@example
-if($1<20,teen,string(""))  @r{"teen" if age $1 less than 20, else empty}
-@end example
+@table @code
+@item if($1 < 20, teen, string(""))
+"teen" if age $1 is less than 20, else the Org table result field is set to
+empty with the empty string.
+@item if("$1" == "nan" || "$2" == "nan", string(""), $1 + $2); E
+Sum of the first two columns.  When at least one of the input fields is empty
+the Org table result field is set to empty.
+@item if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E
+Mean value of a range unless there is any empty field.  Every field in the
+range that is empty is replaced by @samp{nan} which lets @samp{vmean} result
+in @samp{nan}.  Then @samp{typeof == 12} detects the @samp{nan} from
+@samp{vmean} and the Org table result field is set to empty.  Use this when
+the sample set is expected to never have missing values.
+@item if("$1..$7" == "[]", string(""), vmean($1..$7))
+Mean value of a range with empty fields skipped.  Every field in the range
+that is empty is skipped.  When all fields in the range are empty the mean
+value is not defined and the Org table result field is set to empty.  Use
+this when the sample set can have a variable size.
+@item vmean($1..$7); EN
+To complete the example before: Mean value of a range with empty fields
+counting as samples with value 0.  Use this only when incomplete sample sets
+should be padded with 0 to the full size.
+@end table
 
-Note that you can also use two org-specific flags @code{T} and @code{t} for
-durations computations @ref{Durations and time values}.
+You can add your own Calc functions defined in Emacs Lisp with @code{defmath}
+and use them in formula syntax for Calc.
 
 @node Formula syntax for Lisp, Durations and time values, Formula syntax for Calc, The spreadsheet
 @subsection Emacs Lisp forms as formulas
@@ -2646,14 +2771,14 @@ fields, so you can embed them in list or vector syntax.
 Here are a few examples---note how the @samp{N} mode is used when we do
 computations in Lisp:
 
-@example
-@r{Swap the first two characters of the content of column 1}
-  '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
-@r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
-  '(+ $1 $2);N
-@r{Compute the sum of columns 1--4, like Calc's @code{vsum($1..$4)}}
-  '(apply '+ '($1..$4));N
-@end example
+@table @code
+@item '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
+Swap the first two characters of the content of column 1.
+@item '(+ $1 $2);N
+Add columns 1 and 2, equivalent to Calc's @code{$1+$2}.
+@item '(apply '+ '($1..$4));N
+Compute the sum of columns 1 to 4, like Calc's @code{vsum($1..$4)}.
+@end table
 
 @node Durations and time values, Field and range formulas, Formula syntax for Lisp, The spreadsheet
 @subsection Durations and time values
@@ -2677,7 +2802,7 @@ formulas or Elisp formulas:
 Input duration values must be of the form @code{[HH:MM[:SS]}, where seconds
 are optional.  With the @code{T} flag, computed durations will be displayed
 as @code{HH:MM:SS} (see the first formula above).  With the @code{t} flag,
-computed durations will be displayed according to the value of the variable
+computed durations will be displayed according to the value of the option
 @code{org-table-duration-custom-format}, which defaults to @code{'hours} and
 will display the result as a fraction of hours (see the second formula in the
 example above).
@@ -2741,7 +2866,7 @@ can also be used to assign a formula to some but not all fields in a row.
 Named field, see @ref{Advanced features}.
 @end table
 
-@node Column formulas, Editing and debugging formulas, Field and range formulas, The spreadsheet
+@node Column formulas, Lookup functions, Field and range formulas, The spreadsheet
 @subsection Column formulas
 @cindex column formula
 @cindex formula, for table column
@@ -2749,10 +2874,13 @@ Named field, see @ref{Advanced features}.
 When you assign a formula to a simple column reference like @code{$3=}, the
 same formula will be used in all fields of that column, with the following
 very convenient exceptions: (i) If the table contains horizontal separator
-hlines, everything before the first such line is considered part of the table
-@emph{header} and will not be modified by column formulas.  (ii) Fields that
-already get a value from a field/range formula will be left alone by column
-formulas.  These conditions make column formulas very easy to use.
+hlines with rows above and below, everything before the first such hline is
+considered part of the table @emph{header} and will not be modified by column
+formulas.  Therefore a header is mandatory when you use column formulas and
+want to add hlines to group rows, like for example to separate a total row at
+the bottom from the summand rows above.  (ii) Fields that already get a value
+from a field/range formula will be left alone by column formulas.  These
+conditions make column formulas very easy to use.
 
 To assign a formula to a column, type it directly into any field in the
 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
@@ -2777,19 +2905,62 @@ stores it.  With a numeric prefix argument(e.g., @kbd{C-5 C-c =}) the command
 will apply it to that many consecutive fields in the current column.
 @end table
 
-@node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
+@node Lookup functions, Editing and debugging formulas, Column formulas, The spreadsheet
+@subsection Lookup functions
+@cindex lookup functions in tables
+@cindex table lookup functions
+
+Org has three predefined Emacs Lisp functions for lookups in tables.
+@table @code
+@item (org-lookup-first VAL S-LIST R-LIST &optional PREDICATE)
+@findex org-lookup-first
+Searches for the first element @code{S} in list @code{S-LIST} for which
+@lisp
+(PREDICATE VAL S)
+@end lisp
+is @code{t}; returns the value from the corresponding position in list
+@code{R-LIST}.  The default @code{PREDICATE} is @code{equal}.  Note that the
+parameters @code{VAL} and @code{S} are passed to @code{PREDICATE} in the same
+order as the corresponding parameters are in the call to
+@code{org-lookup-first}, where @code{VAL} precedes @code{S-LIST}.  If
+@code{R-LIST} is @code{nil}, the matching element @code{S} of @code{S-LIST}
+is returned.
+@item (org-lookup-last VAL S-LIST R-LIST &optional PREDICATE)
+@findex org-lookup-last
+Similar to @code{org-lookup-first} above, but searches for the @i{last}
+element for which @code{PREDICATE} is @code{t}.
+@item (org-lookup-all VAL S-LIST R-LIST &optional PREDICATE)
+@findex org-lookup-all
+Similar to @code{org-lookup-first}, but searches for @i{all} elements for
+which @code{PREDICATE} is @code{t}, and returns @i{all} corresponding
+values.  This function can not be used by itself in a formula, because it
+returns a list of values.  However, powerful lookups can be built when this
+function is combined with other Emacs Lisp functions.
+@end table
+
+If the ranges used in these functions contain empty fields, the @code{E} mode
+for the formula should usually be specified: otherwise empty fields will not be
+included in @code{S-LIST} and/or @code{R-LIST} which can, for example, result
+in an incorrect mapping from an element of @code{S-LIST} to the corresponding
+element of @code{R-LIST}.
+
+These three functions can be used to implement associative arrays, count
+matching cells, rank results, group data etc.  For practical examples
+see @uref{http://orgmode.org/worg/org-tutorials/org-lookups.html, this
+tutorial on Worg}.
+
+@node Editing and debugging formulas, Updating the table, Lookup functions, The spreadsheet
 @subsection Editing and debugging formulas
 @cindex formula editing
 @cindex editing, of table formulas
 
 @vindex org-table-use-standard-references
-You can edit individual formulas in the minibuffer or directly in the
-field.  Org can also prepare a special buffer with all active
-formulas of a table.  When offering a formula for editing, Org
-converts references to the standard format (like @code{B3} or @code{D&})
-if possible.  If you prefer to only work with the internal format (like
-@code{@@3$2} or @code{$4}), configure the variable
-@code{org-table-use-standard-references}.
+You can edit individual formulas in the minibuffer or directly in the field.
+Org can also prepare a special buffer with all active formulas of a table.
+When offering a formula for editing, Org converts references to the standard
+format (like @code{B3} or @code{D&}) if possible.  If you prefer to only work
+with the internal format (like @code{@@3$2} or @code{$4}), configure the
+option @code{org-table-use-standard-references}.
 
 @table @kbd
 @orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
@@ -2821,6 +2992,7 @@ active formula, the cursor in the formula editor will mark it.
 While inside the special buffer, Org will automatically highlight
 any field or range reference at the cursor position.  You may edit,
 remove and add formulas, and use the following commands:
+
 @table @kbd
 @orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
@@ -2872,6 +3044,52 @@ You may edit the @samp{#+TBLFM} directly and re-apply the changed
 equations with @kbd{C-c C-c} in that line or with the normal
 recalculation commands in the table.
 
+@anchor{Using multiple #+TBLFM lines}
+@subsubheading Using multiple #+TBLFM lines
+@cindex #+TBLFM line, multiple
+@cindex #+TBLFM
+@cindex #+TBLFM, switching
+@kindex C-c C-c
+
+You may apply the formula temporarily.  This is useful when you
+switch the formula.  Place multiple @samp{#+TBLFM} lines right
+after the table, and then press @kbd{C-c C-c} on the formula to
+apply.  Here is an example:
+
+@example
+| x | y |
+|---+---|
+| 1 |   |
+| 2 |   |
+#+TBLFM: $2=$1*1
+#+TBLFM: $2=$1*2
+@end example
+
+@noindent
+Pressing @kbd{C-c C-c} in the line of @samp{#+TBLFM: $2=$1*2} yields:
+
+@example
+| x | y |
+|---+---|
+| 1 | 2 |
+| 2 | 4 |
+#+TBLFM: $2=$1*1
+#+TBLFM: $2=$1*2
+@end example
+
+@noindent
+Note: If you recalculate this table (with @kbd{C-u C-c *}, for example), you
+will get the following result of applying only the first @samp{#+TBLFM} line.
+
+@example
+| x | y |
+|---+---|
+| 1 | 1 |
+| 2 | 2 |
+#+TBLFM: $2=$1*1
+#+TBLFM: $2=$1*2
+@end example
+
 @subsubheading Debugging formulas
 @cindex formula debugging
 @cindex debugging, of table formulas
@@ -2910,10 +3128,10 @@ hline are left alone, assuming that these are part of the table header.
 Iterate the table by recomputing it until no further changes occur.
 This may be necessary if some computed fields use the value of other
 fields that are computed @i{later} in the calculation sequence.
-@item M-x org-table-recalculate-buffer-tables
+@item M-x org-table-recalculate-buffer-tables RET
 @findex org-table-recalculate-buffer-tables
 Recompute all tables in the current buffer.
-@item M-x org-table-iterate-buffer-tables
+@item M-x org-table-iterate-buffer-tables RET
 @findex org-table-iterate-buffer-tables
 Iterate all tables in the current buffer, in order to converge table-to-table
 dependencies.
@@ -2966,6 +3184,7 @@ empty first field.
 
 @cindex marking characters, tables
 The marking characters have the following meaning:
+
 @table @samp
 @item !
 The fields in this line define names for the columns, so that you may
@@ -3167,10 +3386,8 @@ internal structure of all links, use the menu entry
 If the link does not look like a URL, it is considered to be internal in the
 current file.  The most important case is a link like
 @samp{[[#my-custom-id]]} which will link to the entry with the
-@code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
-for HTML export (@pxref{HTML export}) where they produce pretty section
-links.  You are responsible yourself to make sure these custom IDs are unique
-in a file.
+@code{CUSTOM_ID} property @samp{my-custom-id}.  You are responsible yourself
+to make sure these custom IDs are unique in a file.
 
 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
 lead to a text search in the current file.
@@ -3178,27 +3395,48 @@ lead to a text search in the current file.
 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
 point to the corresponding headline.  The preferred match for a text link is
-a @i{dedicated target}: the same string in double angular brackets.  Targets
-may be located anywhere; sometimes it is convenient to put them into a
-comment line.  For example
+a @i{dedicated target}: the same string in double angular brackets, like
+@samp{<<My Target>>}.
+
+@cindex #+NAME
+If no dedicated target exists, the link will then try to match the exact name
+of an element within the buffer.  Naming is done with the @code{#+NAME}
+keyword, which has to be put the line before the element it refers to, as in
+the following example
 
 @example
-# <<My Target>>
+#+NAME: My Target
+| a  | table      |
+|----+------------|
+| of | four cells |
 @end example
 
-@noindent In HTML export (@pxref{HTML export}), such targets will become
-named anchors for direct access through @samp{http} links@footnote{Note that
-text before the first headline is usually not exported, so the first such
-target should be after the first headline, or in the line directly before the
-first headline.}.
-
-If no dedicated target exists, Org will search for a headline that is exactly
+If none of the above succeeds, Org will search for a headline that is exactly
 the link text but may also include a TODO keyword and tags@footnote{To insert
-a link targeting a headline, in-buffer completion can be used.  Just type a
-star followed by a few optional letters into the buffer and press
+a link targeting a headline, in-buffer completion can be used.  Just type
+star followed by a few optional letters into the buffer and press
 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
-completions.}.  In non-Org files, the search will look for the words in the
-link text.  In the above example the search would be for @samp{my target}.
+completions.}.
+
+During export, internal links will be used to mark objects and assign them
+a number.  Marked objects will then be referenced by links pointing to them.
+In particular, links without a description will appear as the number assigned
+to the marked object@footnote{When targeting a @code{#+NAME} keyword,
+@code{#+CAPTION} keyword is mandatory in order to get proper numbering
+(@pxref{Images and tables}).}.  In the following excerpt from an Org buffer
+
+@example
+- one item
+- <<target>>another item
+Here we refer to item [[target]].
+@end example
+
+@noindent
+The last sentence will appear as @samp{Here we refer to item 2} when
+exported.
+
+In non-Org files, the search will look for the words in the link text.  In
+the above example the search would be for @samp{my target}.
 
 Following a link pushes a mark onto Org's own mark ring.  You can
 return to the previous position with @kbd{C-c &}.  Using this command
@@ -3229,26 +3467,23 @@ cursor on or at a target.
 @section External links
 @cindex links, external
 @cindex external links
-@cindex links, external
 @cindex Gnus links
 @cindex BBDB links
 @cindex IRC links
 @cindex URL links
 @cindex file links
-@cindex VM links
 @cindex RMAIL links
-@cindex WANDERLUST links
 @cindex MH-E links
 @cindex USENET links
 @cindex SHELL links
 @cindex Info links
 @cindex Elisp links
 
-Org supports links to files, websites, Usenet and email messages,
-BBDB database entries and links to both IRC conversations and their
-logs.  External links are URL-like locators.  They start with a short
-identifying string followed by a colon.  There can be no space after
-the colon.  The following list shows examples for each link type.
+Org supports links to files, websites, Usenet and email messages, BBDB
+database entries and links to both IRC conversations and their logs.
+External links are URL-like locators.  They start with a short identifying
+string followed by a colon.  There can be no space after the colon.  The
+following list shows examples for each link type.
 
 @example
 http://www.astro.uva.nl/~dominik          @r{on the web}
@@ -3263,8 +3498,8 @@ file:sometextfile::NNN                    @r{file, jump to line number}
 file:projects.org                         @r{another Org file}
 file:projects.org::some words             @r{text search in Org file}@footnote{
 The actual behavior of the search will depend on the value of
-the variable @code{org-link-search-must-match-exact-headline}.  If its value
-is nil, then a fuzzy text search will be done.  If it is t, then only the
+the option @code{org-link-search-must-match-exact-headline}.  If its value
+is @code{nil}, then a fuzzy text search will be done.  If it is t, then only the
 exact headline will be matched.  If the value is @code{'query-to-create},
 then an exact headline will be searched; if it is not found, then the user
 will be queried to create it.}
@@ -3275,13 +3510,6 @@ docview:papers/last.pdf::NNN              @r{open in doc-view mode at page}
 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
 news:comp.emacs                           @r{Usenet link}
 mailto:adent@@galaxy.net                   @r{Mail link}
-vm:folder                                 @r{VM folder link}
-vm:folder#id                              @r{VM message link}
-vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
-vm-imap:account:folder                    @r{VM IMAP folder link}
-vm-imap:account:folder#id                 @r{VM IMAP message link}
-wl:folder                                 @r{WANDERLUST folder link}
-wl:folder#id                              @r{WANDERLUST message link}
 mhe:folder                                @r{MH-E folder link}
 mhe:folder#id                             @r{MH-E message link}
 rmail:folder                              @r{RMAIL folder link}
@@ -3296,11 +3524,27 @@ elisp:org-agenda                          @r{Interactive Elisp command}
 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
 @end example
 
+@cindex VM links
+@cindex WANDERLUST links
+On top of these built-in link types, some are available through the
+@code{contrib/} directory (@pxref{Installation}).  For example, these links
+to VM or Wanderlust messages are available when you load the corresponding
+libraries from the @code{contrib/} directory:
+
+@example
+vm:folder                                 @r{VM folder link}
+vm:folder#id                              @r{VM message link}
+vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
+vm-imap:account:folder                    @r{VM IMAP folder link}
+vm-imap:account:folder#id                 @r{VM IMAP message link}
+wl:folder                                 @r{WANDERLUST folder link}
+wl:folder#id                              @r{WANDERLUST message link}
+@end example
+
 For customizing Org to add new link types @ref{Adding hyperlink types}.
 
-A link should be enclosed in double brackets and may contain a
-descriptive text to be displayed instead of the URL (@pxref{Link
-format}), for example:
+A link should be enclosed in double brackets and may contain a descriptive
+text to be displayed instead of the URL (@pxref{Link format}), for example:
 
 @example
 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
@@ -3349,14 +3593,13 @@ timestamp in the headline.}.
 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
 will be stored.  In addition or alternatively (depending on the value of
 @code{org-id-link-to-org-use-id}), a globally unique @code{ID} property will
-be created and/or used to construct a link@footnote{The library @code{org-id}
-must first be loaded, either through @code{org-customize} by enabling
-@code{id} in @code{org-modules} , or by adding @code{(require 'org-id)} in
-your @file{.emacs}.}. So using this command in Org
-buffers will potentially create two links: a human-readable from the custom
-ID, and one that is globally unique and works even if the entry is moved from
-file to file.  Later, when inserting the link, you need to decide which one
-to use.
+be created and/or used to construct a link@footnote{The library
+@file{org-id.el} must first be loaded, either through @code{org-customize} by
+enabling @code{org-id} in @code{org-modules}, or by adding @code{(require
+'org-id)} in your @file{.emacs}.}. So using this command in Org buffers will
+potentially create two links: a human-readable from the custom ID, and one
+that is globally unique and works even if the entry is moved from file to
+file.  Later, when inserting the link, you need to decide which one to use.
 
 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
 Pretty much all Emacs mail clients are supported.  The link will point to the
@@ -3371,10 +3614,10 @@ Links created in a BBDB buffer will point to the current entry.
 
 @b{Chat: IRC}@*
 @vindex org-irc-link-to-logs
-For IRC links, if you set the variable @code{org-irc-link-to-logs} to
-@code{t}, a @samp{file:/} style link to the relevant point in the logs for
-the current conversation is created.  Otherwise an @samp{irc:/} style link to
-the user/channel/server under the point will be stored.
+For IRC links, if you set the option @code{org-irc-link-to-logs} to @code{t},
+a @samp{file:/} style link to the relevant point in the logs for the current
+conversation is created.  Otherwise an @samp{irc:/} style link to the
+user/channel/server under the point will be stored.
 
 @b{Other files}@*
 For any other files, the link will point to the file, with a search string
@@ -3476,7 +3719,7 @@ would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
 @vindex org-display-internal-link-with-indirect-buffer
 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
 internal links to be displayed in another window@footnote{See the
-variable @code{org-display-internal-link-with-indirect-buffer}}.
+option @code{org-display-internal-link-with-indirect-buffer}}.
 @c
 @orgcmd{C-c C-x C-v,org-toggle-inline-images}
 @cindex inlining images
@@ -3490,7 +3733,7 @@ be inlined during export.  When called with a prefix argument, also display
 images that do have a link description.  You can ask for inline images to be
 displayed at startup by configuring the variable
 @code{org-startup-with-inline-images}@footnote{with corresponding
-@code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
+@code{#+STARTUP} keywords @code{inlineimages} and @code{noinlineimages}}.
 @orgcmd{C-c %,org-mark-ring-push}
 @cindex mark ring
 Push the current position onto the mark ring, to be able to return
@@ -3631,7 +3874,7 @@ Jump to line 255.
 Search for a link target @samp{<<My Target>>}, or do a text search for
 @samp{my target}, similar to the search in internal links, see
 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
-link will become a HTML reference to the corresponding named anchor in
+link will become an HTML reference to the corresponding named anchor in
 the linked file.
 @item *My Target
 In an Org file, restrict search to headlines.
@@ -3728,7 +3971,7 @@ Rotate the TODO state of the current item among
 If TODO keywords have fast access keys (see @ref{Fast access to TODO
 states}), you will be prompted for a TODO keyword through the fast selection
 interface; this is the default behavior when
-@var{org-use-fast-todo-selection} is @code{non-nil}.
+@code{org-use-fast-todo-selection} is non-@code{nil}.
 
 The same rotation can also be done ``remotely'' from the timeline and agenda
 buffers with the @kbd{t} command key (@pxref{Agenda commands}).
@@ -3736,7 +3979,7 @@ buffers with the @kbd{t} command key (@pxref{Agenda commands}).
 @orgkey{C-u C-c C-t}
 When TODO keywords have no selection keys, select a specific keyword using
 completion; otherwise force cycling through TODO states with no prompt.  When
-@var{org-use-fast-todo-selection} is set to @code{prefix}, use the fast
+@code{org-use-fast-todo-selection} is set to @code{prefix}, use the fast
 selection interface.
 
 @kindex S-@key{right}
@@ -3754,12 +3997,11 @@ with @code{shift-selection-mode}.  See also the variable
 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
 entire buffer, but shows all TODO items (with not-DONE state) and the
 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
-/ T}), search for a specific TODO@.  You will be prompted for the keyword, and
-you can also give a list of keywords like @code{KWD1|KWD2|...} to list
+/ T}), search for a specific TODO@.  You will be prompted for the keyword,
+and you can also give a list of keywords like @code{KWD1|KWD2|...} to list
 entries that match any one of these keywords.  With a numeric prefix argument
-N, show the tree for the Nth keyword in the variable
-@code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
-both un-done and done.
+N, show the tree for the Nth keyword in the option @code{org-todo-keywords}.
+With two prefix arguments, find all TODO states, both un-done and done.
 @orgcmd{C-c a t,org-todo-list}
 Show the global TODO list.  Collects the TODO items (with not-DONE states)
 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
@@ -3930,7 +4172,7 @@ each keyword, in parentheses@footnote{All characters are allowed except
 @vindex org-fast-tag-selection-include-todo
 If you then press @kbd{C-c C-t} followed by the selection key, the entry
 will be switched to this state.  @kbd{SPC} can be used to remove any TODO
-keyword from an entry.@footnote{Check also the variable
+keyword from an entry.@footnote{Check also the option
 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
 state through the tags interface (@pxref{Setting tags}), in case you like to
 mingle the two concepts.  Note that this means you need to come up with
@@ -3994,7 +4236,7 @@ Org mode highlights TODO keywords with special faces: @code{org-todo}
 for keywords indicating that an item still has to be acted upon, and
 @code{org-done} for keywords indicating that an item is finished.  If
 you are using more than 2 different states, you might want to use
-special faces for some of them.  This can be done using the variable
+special faces for some of them.  This can be done using the option
 @code{org-todo-keyword-faces}.  For example:
 
 @lisp
@@ -4007,7 +4249,7 @@ special faces for some of them.  This can be done using the variable
 
 While using a list with face properties as shown for CANCELED @emph{should}
 work, this does not always seem to be the case.  If necessary, define a
-special face and use that.  A string is interpreted as a color.  The variable
+special face and use that.  A string is interpreted as a color.  The option
 @code{org-faces-easy-properties} determines if that color is interpreted as a
 foreground or a background color.
 
@@ -4023,7 +4265,7 @@ dependencies.  Usually, a parent TODO task should not be marked DONE until
 all subtasks (defined as children tasks) are marked as DONE@.  And sometimes
 there is a logical sequence to a number of (sub)tasks, so that one task
 cannot be acted upon before all siblings above it are done.  If you customize
-the variable @code{org-enforce-todo-dependencies}, Org will block entries
+the option @code{org-enforce-todo-dependencies}, Org will block entries
 from changing state to DONE while they have children that are not DONE@.
 Furthermore, if an entry has a property @code{ORDERED}, each of its children
 will be blocked until all earlier siblings are marked DONE@.  Here is an
@@ -4050,21 +4292,21 @@ example:
 Toggle the @code{ORDERED} property of the current entry.  A property is used
 for this behavior because this should be local to the current entry, not
 inherited like a tag.  However, if you would like to @i{track} the value of
-this property with a tag for better visibility, customize the variable
+this property with a tag for better visibility, customize the option
 @code{org-track-ordered-property-with-tag}.
 @orgkey{C-u C-u C-u C-c C-t}
 Change TODO state, circumventing any state blocking.
 @end table
 
 @vindex org-agenda-dim-blocked-tasks
-If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
+If you set the option @code{org-agenda-dim-blocked-tasks}, TODO entries
 that cannot be closed because of such dependencies will be shown in a dimmed
 font or even made invisible in agenda views (@pxref{Agenda Views}).
 
 @cindex checkboxes and TODO dependencies
 @vindex org-enforce-todo-dependencies
 You can also block changes of TODO states by looking at checkboxes
-(@pxref{Checkboxes}).  If you set the variable
+(@pxref{Checkboxes}).  If you set the option
 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
 checkboxes will be blocked from switching to DONE.
 
@@ -4102,13 +4344,17 @@ in-buffer setting is: @code{#+STARTUP: logdone}}
 (setq org-log-done 'time)
 @end lisp
 
+@vindex org-closed-keep-when-no-todo
 @noindent
-Then each time you turn an entry from a TODO (not-done) state into any
-of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
-just after the headline.  If you turn the entry back into a TODO item
-through further state cycling, that line will be removed again.  If you
-want to record a note along with the timestamp, use@footnote{The
-corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
+Then each time you turn an entry from a TODO (not-done) state into any of the
+DONE states, a line @samp{CLOSED: [timestamp]} will be inserted just after
+the headline.  If you turn the entry back into a TODO item through further
+state cycling, that line will be removed again.  If you turn the entry back
+to a non-TODO state (by pressing @key{C-c C-t SPC} for example), that line
+will also be removed, unless you set @code{org-closed-keep-when-no-todo} to
+non-@code{nil}.  If you want to record a note along with the timestamp,
+use@footnote{The corresponding in-buffer setting is: @code{#+STARTUP:
+lognotedone}.}
 
 @lisp
 (setq org-log-done 'note)
@@ -4134,11 +4380,11 @@ When TODO keywords are used as workflow states (@pxref{Workflow states}), you
 might want to keep track of when a state change occurred and maybe take a
 note about this change.  You can either record just a timestamp, or a
 time-stamped note for a change.  These records will be inserted after the
-headline as an itemized list, newest first@footnote{See the variable
+headline as an itemized list, newest first@footnote{See the option
 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
 want to get the notes out of the way into a drawer (@pxref{Drawers}).
-Customize the variable @code{org-log-into-drawer} to get this behavior---the
-recommended drawer for this is called @code{LOGBOOK}@footnote{Note that the
+Customize @code{org-log-into-drawer} to get this behavior---the recommended
+drawer for this is called @code{LOGBOOK}@footnote{Note that the
 @code{LOGBOOK} drawer is unfolded when pressing @key{SPC} in the agenda to
 show an entry---use @key{C-u SPC} to keep it folded here}.  You can also
 overrule the setting of this variable for a subtree by setting a
@@ -4186,7 +4432,7 @@ to a buffer:
 @cindex property, LOGGING
 In order to define logging settings that are local to a subtree or a
 single item, define a LOGGING property in this entry.  Any non-empty
-LOGGING property resets all logging settings to nil.  You may then turn
+LOGGING property resets all logging settings to @code{nil}.  You may then turn
 on logging for this specific tree using STARTUP keywords like
 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
 settings like @code{TODO(!)}.  For example
@@ -4215,8 +4461,7 @@ called ``habits''.  A habit has the following properties:
 
 @enumerate
 @item
-You have enabled the @code{habits} module by customizing the variable
-@code{org-modules}.
+You have enabled the @code{habits} module by customizing @code{org-modules}.
 @item
 The habit is a TODO item, with a TODO keyword representing an open state.
 @item
@@ -4298,7 +4543,7 @@ The amount of history, in days before today, to appear in consistency graphs.
 @item org-habit-following-days
 The number of days after today that will appear in consistency graphs.
 @item org-habit-show-habits-only-for-today
-If non-nil, only show habits in today's agenda view.  This is set to true by
+If non-@code{nil}, only show habits in today's agenda view.  This is set to true by
 default.
 @end table
 
@@ -4326,7 +4571,7 @@ By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
 treated just like priority @samp{B}.  Priorities make a difference only for
 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
 have no inherent meaning to Org mode.  The cookies can be highlighted with
-special faces by customizing the variable @code{org-priority-faces}.
+special faces by customizing @code{org-priority-faces}.
 
 Priorities can be attached to any outline node; they do not need to be TODO
 items.
@@ -4353,7 +4598,7 @@ also used to modify timestamps (@pxref{Creating timestamps}).  See also
 @vindex org-highest-priority
 @vindex org-lowest-priority
 @vindex org-default-priority
-You can change the range of allowed priorities by setting the variables
+You can change the range of allowed priorities by setting the options
 @code{org-highest-priority}, @code{org-lowest-priority}, and
 @code{org-default-priority}.  For an individual buffer, you may set
 these values (highest, lowest, default) like this (please make sure that
@@ -4397,7 +4642,7 @@ this issue.
 
 @vindex org-hierarchical-todo-statistics
 If you would like to have the statistics cookie count any TODO entries in the
-subtree (not just direct children), configure the variable
+subtree (not just direct children), configure
 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
 property.
@@ -4462,15 +4707,15 @@ checked.
 @cindex statistics, for checkboxes
 @cindex checkbox statistics
 @cindex property, COOKIE_DATA
-@vindex org-hierarchical-checkbox-statistics
+@vindex org-checkbox-hierarchical-statistics
 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
 indicating how many checkboxes present in this entry have been checked off,
 and the total number of checkboxes present.  This can give you an idea on how
 many checkboxes remain, even without opening a folded entry.  The cookies can
 be placed into a headline or into (the first line of) a plain list item.
 Each cookie covers checkboxes of direct children structurally below the
-headline/item on which the cookie appears@footnote{Set the variable
-@code{org-hierarchical-checkbox-statistics} if you want such cookies to
+headline/item on which the cookie appears@footnote{Set the option
+@code{org-checkbox-hierarchical-statistics} if you want such cookies to
 count all checkboxes below the cookie, not just those belonging to direct
 children.}.  You have to insert the cookie yourself by typing either
 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
@@ -4522,8 +4767,7 @@ Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
 be checked off in sequence.  A property is used for this behavior because
 this should be local to the current entry, not inherited like a tag.
 However, if you would like to @i{track} the value of this property with a tag
-for better visibility, customize the variable
-@code{org-track-ordered-property-with-tag}.
+for better visibility, customize @code{org-track-ordered-property-with-tag}.
 @orgcmd{C-c #,org-update-statistics-cookies}
 Update the statistics cookie in the current outline entry.  When called with
 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
@@ -4550,13 +4794,14 @@ headline.  Tags are normal words containing letters, numbers, @samp{_}, and
 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
 Tags will by default be in bold face with the same color as the headline.
-You may specify special faces for specific tags using the variable
+You may specify special faces for specific tags using the option
 @code{org-tag-faces}, in much the same way as you can for TODO keywords
 (@pxref{Faces for TODO keywords}).
 
 @menu
 * Tag inheritance::             Tags use the tree structure of the outline
 * Setting tags::                How to assign tags to a headline
+* Tag groups::                  Use one tag to search for several tags
 * Tag searches::                Searching for combinations of tags
 @end menu
 
@@ -4602,8 +4847,8 @@ on, all the sublevels in the same tree will (for a simple match form) match
 as well@footnote{This is only true if the search does not involve more
 complex tests including properties (@pxref{Property searches}).}.  The list
 of matches may then become very long.  If you only want to see the first tags
-match in a subtree, configure the variable
-@code{org-tags-match-list-sublevels} (not recommended).
+match in a subtree, configure @code{org-tags-match-list-sublevels} (not
+recommended).
 
 @vindex org-agenda-use-tag-inheritance
 Tag inheritance is relevant when the agenda search tries to match a tag,
@@ -4611,10 +4856,10 @@ either in the @code{tags} or @code{tags-todo} agenda types.  In other agenda
 types, @code{org-use-tag-inheritance} has no effect.  Still, you may want to
 have your tags correctly set in the agenda, so that tag filtering works fine,
 with inherited tags.  Set @code{org-agenda-use-tag-inheritance} to control
-this: the default value includes all agenda types, but setting this to nil
+this: the default value includes all agenda types, but setting this to @code{nil}
 can really speed up agenda generation.
 
-@node Setting tags, Tag searches, Tag inheritance, Tags
+@node Setting tags, Tag groups, Tag inheritance, Tags
 @section Setting tags
 @cindex setting tags
 @cindex tags, setting
@@ -4635,6 +4880,7 @@ to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
 tags in the current buffer will be aligned to that column, just to make
 things look nice.  TAGS are automatically realigned after promotion,
 demotion, and TODO state changes (@pxref{TODO basics}).
+
 @orgcmd{C-c C-c,org-set-tags-command}
 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
 @end table
@@ -4722,7 +4968,7 @@ and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
 these lines to activate any changes.
 
 @noindent
-To set these mutually exclusive groups in the variable @code{org-tags-alist},
+To set these mutually exclusive groups in the variable @code{org-tag-alist},
 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
 of the braces.  Similarly, you can use @code{:newline} to indicate a line
 break.  The previous example would be set globally by the following
@@ -4785,17 +5031,58 @@ alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
 
 @vindex org-fast-tag-selection-single-key
 If you find that most of the time you need only a single key press to
-modify your list of tags, set the variable
-@code{org-fast-tag-selection-single-key}.  Then you no longer have to
-press @key{RET} to exit fast tag selection---it will immediately exit
-after the first change.  If you then occasionally need more keys, press
-@kbd{C-c} to turn off auto-exit for the current tag selection process
-(in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
-C-c}).  If you set the variable to the value @code{expert}, the special
-window is not even shown for single-key tag selection, it comes up only
-when you press an extra @kbd{C-c}.
-
-@node Tag searches,  , Setting tags, Tags
+modify your list of tags, set @code{org-fast-tag-selection-single-key}.
+Then you no longer have to press @key{RET} to exit fast tag selection---it
+will immediately exit after the first change.  If you then occasionally
+need more keys, press @kbd{C-c} to turn off auto-exit for the current tag
+selection process (in effect: start selection with @kbd{C-c C-c C-c}
+instead of @kbd{C-c C-c}).  If you set the variable to the value
+@code{expert}, the special window is not even shown for single-key tag
+selection, it comes up only when you press an extra @kbd{C-c}.
+
+@node Tag groups, Tag searches, Setting tags, Tags
+@section Tag groups
+
+@cindex group tags
+@cindex tags, groups
+In a set of mutually exclusive tags, the first tag can be defined as a
+@emph{group tag}.  When you search for a group tag, it will return matches
+for all members in the group.  In an agenda view, filtering by a group tag
+will display headlines tagged with at least one of the members of the
+group.  This makes tag searches and filters even more flexible.
+
+You can set group tags by inserting a colon between the group tag and other
+tags---beware that all whitespaces are mandatory so that Org can parse this
+line correctly:
+
+@example
+#+TAGS: @{ @@read : @@read_book @@read_ebook @}
+@end example
+
+In this example, @samp{@@read} is a @emph{group tag} for a set of three
+tags: @samp{@@read}, @samp{@@read_book} and @samp{@@read_ebook}.
+
+You can also use the @code{:grouptags} keyword directly when setting
+@code{org-tag-alist}:
+
+@lisp
+(setq org-tag-alist '((:startgroup . nil)
+                      ("@@read" . nil)
+                      (:grouptags . nil)
+                      ("@@read_book" . nil)
+                      ("@@read_ebook" . nil)
+                      (:endgroup . nil)))
+@end lisp
+
+You cannot nest group tags or use a group tag as a tag in another group.
+
+@kindex C-c C-x q
+@vindex org-group-tags
+If you want to ignore group tags temporarily, toggle group tags support
+with @command{org-toggle-tags-groups}, bound to @kbd{C-c C-x q}.  If you
+want to disable tag groups completely, set @code{org-group-tags} to @code{nil}.
+
+@node Tag searches,  , Tag groups, Tags
 @section Tag searches
 @cindex tag searches
 @cindex searching for tags
@@ -4805,15 +5092,16 @@ information into special lists.
 
 @table @kbd
 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
-Create a sparse tree with all headlines matching a tags search.  With a
-@kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
-@orgcmd{C-c a m,org-tags-view}
-Create a global list of tag matches from all agenda files.
+Create a sparse tree with all headlines matching a tags/property/TODO search.
+With a @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
 @xref{Matching tags and properties}.
+@orgcmd{C-c a m,org-tags-view}
+Create a global list of tag matches from all agenda files.  @xref{Matching
+tags and properties}.
 @orgcmd{C-c a M,org-tags-view}
 @vindex org-tags-match-list-sublevels
 Create a global list of tag matches from all agenda files, but check
-only TODO items and force checking subitems (see variable
+only TODO items and force checking subitems (see the option
 @code{org-tags-match-list-sublevels}).
 @end table
 
@@ -4908,6 +5196,9 @@ file, use a line like
 #+PROPERTY: NDisks_ALL 1 2 3 4
 @end example
 
+Contrary to properties set from a special drawer, you have to refresh the
+buffer with @kbd{C-c C-c} to activate this changes.
+
 If you want to add to the value of an existing property, append a @code{+} to
 the property name.  The following results in the property @code{var} having
 the value ``foo=1 bar=2''.
@@ -4954,7 +5245,7 @@ in the current file will be offered as possible completions.
 @orgcmd{C-c C-x p,org-set-property}
 Set a property.  This prompts for a property name and a value.  If
 necessary, the property drawer is created as well.
-@item C-u M-x org-insert-drawer
+@item C-u M-x org-insert-drawer RET
 @cindex org-insert-drawer
 Insert a property drawer into the current entry.  The drawer will be
 inserted early in the entry, but after the lines with planning
@@ -5033,6 +5324,7 @@ FILE         @r{The filename the entry is located in.}
 
 To create sparse trees and special lists with selection based on properties,
 the same commands are used as for tag searches (@pxref{Tag searches}).
+
 @table @kbd
 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
 Create a sparse tree with all matching entries.  With a
@@ -5043,7 +5335,7 @@ Create a global list of tag/property  matches from all agenda files.
 @orgcmd{C-c a M,org-tags-view}
 @vindex org-tags-match-list-sublevels
 Create a global list of tag matches from all agenda files, but check
-only TODO items and force checking of subitems (see variable
+only TODO items and force checking of subitems (see the option
 @code{org-tags-match-list-sublevels}).
 @end table
 
@@ -5077,7 +5369,7 @@ useful, you can turn it on by setting the variable
 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
 all properties inherited from the parent, to a list of properties
 that should be inherited, or to a regular expression that matches
-inherited properties.  If a property has the value @samp{nil}, this is
+inherited properties.  If a property has the value @code{nil}, this is
 interpreted as an explicit undefine of the property, so that inheritance
 search will stop at this value and return @code{nil}.
 
@@ -5351,7 +5643,7 @@ global    @r{make a global view, including all headings in the file}
           @r{run column view at the top of this file}
 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
           @r{property with the value @i{label}.  You can use}
-          @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
+          @r{@kbd{M-x org-id-copy RET} to create a globally unique ID for}
           @r{the current entry and copy it to the kill-ring.}
 @end example
 @item :hlines
@@ -5604,10 +5896,9 @@ the following column).
 @vindex org-read-date-prefer-future
 When Org mode prompts for a date/time, the default is shown in default
 date/time format, and the prompt therefore seems to ask for a specific
-format.  But it will in fact accept any string containing some date and/or
-time information, and it is really smart about interpreting your input.  You
-can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
-copied from an email message.  Org mode will find whatever information is in
+format.  But it will in fact accept date/time information in a variety of
+formats.  Generally, the information should start at the beginning of the
+string.  Org mode will find whatever information is in
 there and derive anything you have not specified from the @emph{default date
 and time}.  The default is usually the current date and time, but when
 modifying an existing timestamp, or when entering the second stamp of a
@@ -5630,7 +5921,7 @@ in @b{bold}.
 14            @result{} @b{2006}-@b{06}-14
 12            @result{} @b{2006}-@b{07}-12
 2/5           @result{} @b{2007}-02-05
-Fri           @result{} nearest Friday (default date or later)
+Fri           @result{} nearest Friday after the default date
 sep 15        @result{} @b{2006}-09-15
 feb 15        @result{} @b{2007}-02-15
 sep 12 9      @result{} 2009-09-12
@@ -5641,13 +5932,12 @@ w4            @result{} ISO week for of the current year @b{2006}
 2012-w04-5    @result{} Same as above
 @end example
 
-Furthermore you can specify a relative date by giving, as the
-@emph{first} thing in the input: a plus/minus sign, a number and a
-letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
-single plus or minus, the date is always relative to today.  With a
-double plus or minus, it is relative to the default date.  If instead of
-a single letter, you use the abbreviation of day name, the date will be
-the Nth such day, e.g.:
+Furthermore you can specify a relative date by giving, as the @emph{first}
+thing in the input: a plus/minus sign, a number and a letter ([hdwmy]) to
+indicate change in hours, days, weeks, months, or years.  With a single plus
+or minus, the date is always relative to today.  With a double plus or minus,
+it is relative to the default date.  If instead of a single letter, you use
+the abbreviation of day name, the date will be the Nth such day, e.g.:
 
 @example
 +0            @result{} today
@@ -5656,7 +5946,8 @@ the Nth such day, e.g.:
 +4            @result{} same as above
 +2w           @result{} two weeks from today
 ++5           @result{} five days from default date
-+2tue         @result{} second Tuesday from now.
++2tue         @result{} second Tuesday from now
+-wed          @result{} last Wednesday
 @end example
 
 @vindex parse-time-months
@@ -5720,7 +6011,7 @@ The actions of the date/time prompt may seem complex, but I assure you they
 will grow on you, and you will start getting annoyed by pretty much any other
 way of entering a date/time out there.  To help you understand what is going
 on, the current interpretation of your input will be displayed live in the
-minibuffer@footnote{If you find this distracting, turn the display of with
+minibuffer@footnote{If you find this distracting, turn the display off with
 @code{org-read-date-display-live}.}.
 
 @node Custom time format,  , The date/time prompt, Creating timestamps
@@ -5734,7 +6025,7 @@ minibuffer@footnote{If you find this distracting, turn the display of with
 Org mode uses the standard ISO notation for dates and times as it is
 defined in ISO 8601.  If you cannot get used to this and require another
 representation of date and time to keep you happy, you can get it by
-customizing the variables @code{org-display-custom-times} and
+customizing the options @code{org-display-custom-times} and
 @code{org-time-stamp-custom-formats}.
 
 @table @kbd
@@ -5784,6 +6075,7 @@ Meaning: the task (most likely a TODO item, though not necessarily) is supposed
 to be finished on that date.
 
 @vindex org-deadline-warning-days
+@vindex org-agenda-skip-deadline-prewarning-if-scheduled
 On the deadline date, the task will be listed in the agenda.  In
 addition, the agenda for @emph{today} will carry a warning about the
 approaching or missed deadline, starting
@@ -5798,7 +6090,9 @@ until the entry is marked DONE@.  An example:
 
 You can specify a different lead time for warnings for a specific
 deadlines using the following syntax.  Here is an example with a warning
-period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
+period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.  This warning is
+deactivated if the task get scheduled and you set
+@code{org-agenda-skip-deadline-prewarning-if-scheduled} to @code{t}.
 
 @item SCHEDULED
 @cindex SCHEDULED keyword
@@ -5819,6 +6113,17 @@ the task will automatically be forwarded until completed.
     SCHEDULED: <2004-12-25 Sat>
 @end example
 
+@vindex org-scheduled-delay-days
+@vindex org-agenda-skip-scheduled-delay-if-deadline
+If you want to @emph{delay} the display of this task in the agenda, use
+@code{SCHEDULED: <2004-12-25 Sat -2d>}: the task is still scheduled on the
+25th but will appear two days later.  In case the task contains a repeater,
+the delay is considered to affect all occurrences; if you want the delay to
+only affect the first scheduled occurrence of the task, use @code{--2d}
+instead.  See @code{org-scheduled-delay-days} and
+@code{org-agenda-skip-scheduled-delay-if-deadline} for details on how to
+control this globally or per agenda.
+
 @noindent
 @b{Important:} Scheduling an item in Org mode should @i{not} be
 understood in the same way that we understand @i{scheduling a meeting}.
@@ -5979,8 +6284,14 @@ special repeaters  @samp{++} and @samp{.+}.  For example:
    today.
 @end example
 
-You may have both scheduling and deadline information for a specific
-task---just make sure that the repeater intervals on both are the same.
+@vindex org-agenda-skip-scheduled-if-deadline-is-shown
+You may have both scheduling and deadline information for a specific task.
+If the repeater is set for the scheduling information only, you probably want
+the repeater to be ignored after the deadline.  If so, set the variable
+@code{org-agenda-skip-scheduled-if-deadline-is-shown} to
+@code{repeated-after-deadline}.  If you want both scheduling and deadline
+information to repeat after the same interval, set the same repeater for both
+timestamps.
 
 An alternative to using a repeater is to create a number of copies of a task
 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
@@ -6192,7 +6503,14 @@ be selected:
              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
 :tstart      @r{A time string specifying when to start considering times.}
+             @r{Relative times like @code{"<-2w>"} can also be used.  See}
+             @r{@ref{Matching tags and properties} for relative time syntax.}
 :tend        @r{A time string specifying when to stop considering times.}
+             @r{Relative times like @code{"<now>"} can also be used.  See}
+             @r{@ref{Matching tags and properties} for relative time syntax.}
+:wstart      @r{The starting day of the week.  The default is 1 for monday.}
+:mstart      @r{The starting day of the month.  The default 1 is for the first}
+             @r{day of the month.}
 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
 :stepskip0   @r{Do not show steps that have zero time.}
@@ -6243,6 +6561,11 @@ only to fit it into the manual.}
                     :tend "<2006-08-10 Thu 12:00>"
 #+END: clocktable
 @end example
+A range starting a week ago and ending right now could be written as
+@example
+#+BEGIN: clocktable :tstart "<-1w>" :tend "<now>"
+#+END: clocktable
+@end example
 A summary of the current subtree with % times would be
 @example
 #+BEGIN: clocktable :scope subtree :link t :formula %
@@ -6260,6 +6583,7 @@ would be
 
 @subsubheading Resolving idle time
 @cindex resolve idle time
+@vindex org-clock-x11idle-program-name
 
 @cindex idle, resolve, dangling
 If you clock in on a work item, and then walk away from your
@@ -6273,12 +6597,14 @@ as 10 or 15, Emacs can alert you when you get back to your computer after
 being idle for that many minutes@footnote{On computers using Mac OS X,
 idleness is based on actual user idleness, not just Emacs' idle time.  For
 X11, you can install a utility program @file{x11idle.c}, available in the
-@code{contrib/scripts} directory of the Org git distribution, to get the same
-general treatment of idleness.  On other systems, idle time refers to Emacs
-idle time only.}, and ask what you want to do with the idle time.  There will
-be a question waiting for you when you get back, indicating how much idle
-time has passed (constantly updated with the current amount), as well as a
-set of choices to correct the discrepancy:
+@code{contrib/scripts} directory of the Org git distribution, or install the
+@file{xprintidle} package and set it to the variable
+@code{org-clock-x11idle-program-name} if you are running Debian, to get the
+same general treatment of idleness.  On other systems, idle time refers to
+Emacs idle time only.}, and ask what you want to do with the idle time.
+There will be a question waiting for you when you get back, indicating how
+much idle time has passed (constantly updated with the current amount), as
+well as a set of choices to correct the discrepancy:
 
 @table @kbd
 @item k
@@ -6470,7 +6796,7 @@ trees to an archive file keeps the system compact and fast.
 * Attachments::                 Add files to tasks
 * RSS Feeds::                   Getting input from RSS feeds
 * Protocols::                   External (e.g., Browser) access to Emacs and Org
-* Refiling notes::              Moving a tree from one place to another
+* Refile and copy::             Moving/copying a tree from one place to another
 * Archiving::                   What to do with finished projects
 @end menu
 
@@ -6478,25 +6804,22 @@ trees to an archive file keeps the system compact and fast.
 @section Capture
 @cindex capture
 
-Org's method for capturing new items is heavily inspired by John Wiegley
-excellent remember package.  Up to version 6.36 Org used a special setup
-for @file{remember.el}.  @file{org-remember.el} is still part of Org mode for
-backward compatibility with existing setups.  You can find the documentation
-for org-remember at @url{http://orgmode.org/org-remember.pdf}.
+Capture lets you quickly store notes with little interruption of your work
+flow.  Org's method for capturing new items is heavily inspired by John
+Wiegley excellent @file{remember.el} package.  Up to version 6.36, Org
+used a special setup for @file{remember.el}, then replaced it with
+@file{org-remember.el}.  As of version 8.0, @file{org-remember.el} has
+been completely replaced by @file{org-capture.el}.
 
-The new capturing setup described here is preferred and should be used by new
-users.  To convert your @code{org-remember-templates}, run the command
+If your configuration depends on @file{org-remember.el}, you need to update
+it and use the setup described below.  To convert your
+@code{org-remember-templates}, run the command
 @example
-@kbd{M-x org-capture-import-remember-templates @key{RET}}
+@kbd{M-x org-capture-import-remember-templates RET}
 @end example
 @noindent and then customize the new variable with @kbd{M-x
 customize-variable org-capture-templates}, check the result, and save the
-customization.  You can then use both remember and capture until
-you are familiar with the new mechanism.
-
-Capture lets you quickly store notes with little interruption of your work
-flow.  The basic process of capturing is very similar to remember, but Org
-does enhance it with templates and more.
+customization.
 
 @menu
 * Setting up capture::          Where notes will be stored
@@ -6512,10 +6835,12 @@ a global key@footnote{Please select your own key, @kbd{C-c c} is only a
 suggestion.}  for capturing new material.
 
 @vindex org-default-notes-file
-@example
+@smalllisp
+@group
 (setq org-default-notes-file (concat org-directory "/notes.org"))
 (define-key global-map "\C-cc" 'org-capture)
-@end example
+@end group
+@end smalllisp
 
 @node Using capture, Capture templates, Setting up capture, Capture
 @subsection Using capture
@@ -6537,7 +6862,7 @@ so that you can resume your work without further distraction.  When called
 with a prefix arg, finalize and then jump to the captured item.
 
 @orgcmd{C-c C-w,org-capture-refile}
-Finalize the capture process by refiling (@pxref{Refiling notes}) the note to
+Finalize the capture process by refiling (@pxref{Refile and copy}) the note to
 a different place.  Please realize that this is a normal refiling command
 that will be executed---so the cursor position at the moment you run this
 command is important.  If you have inserted a tree with a parent and
@@ -6594,13 +6919,15 @@ your file @file{~/org/gtd.org}.  Also, a date tree in the file
 @file{journal.org} should capture journal entries.  A possible configuration
 would look like:
 
-@example
+@smalllisp
+@group
 (setq org-capture-templates
  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
         "* TODO %?\n  %i\n  %a")
    ("j" "Journal" entry (file+datetree "~/org/journal.org")
         "* %?\nEntered on %U\n  %i\n  %a")))
-@end example
+@end group
+@end smalllisp
 
 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
 for you like this:
@@ -6613,7 +6940,7 @@ for you like this:
 During expansion of the template, @code{%a} has been replaced by a link to
 the location from where you called the capture command.  This can be
 extremely useful for deriving tasks from emails, for example.  You fill in
-the task definition, press @code{C-c C-c} and Org returns you to the same
+the task definition, press @kbd{C-c C-c} and Org returns you to the same
 place where you started the capture process.
 
 To define special keys to capture to a particular template without going
@@ -6645,9 +6972,9 @@ single key, or @code{"bt"} for selection with two keys.  When using
 several keys, keys using the same prefix key must be sequential
 in the list and preceded by a 2-element entry explaining the
 prefix key, for example
-@example
+@smalllisp
          ("b" "Templates for marking stuff to buy")
-@end example
+@end smalllisp
 @noindent If you do not define a template for the @kbd{C} key, this key will
 be used to open the customize buffer for this complex variable.
 
@@ -6657,6 +6984,7 @@ selection.
 
 @item type
 The type of entry, a symbol.  Valid values are:
+
 @table @code
 @item entry
 An Org mode node, with a headline.  Will be filed as the child of the target
@@ -6685,6 +7013,7 @@ the empty string, it defaults to @code{org-default-notes-file}.  A file can
 also be given as a variable, function, or Emacs Lisp form.
 
 Valid values are:
+
 @table @code
 @item (file "path/to/file")
 Text will be placed at the beginning or end of that file.
@@ -6702,7 +7031,10 @@ For non-unique headings, the full path is safer.
 Use a regular expression to position the cursor.
 
 @item (file+datetree "path/to/file")
-Will create a heading in a date tree for today's date.
+Will create a heading in a date tree for today's date@footnote{Datetree
+headlines for years accept tags, so if you use both @code{* 2013 :noexport:}
+and @code{* 2013} in your file, the capture will refile the note to the first
+one matched.}.
 
 @item (file+datetree+prompt "path/to/file")
 Will create a heading in a date tree, but will prompt for the date.
@@ -6729,6 +7061,7 @@ more details.
 @item properties
 The rest of the entry is a property list of additional options.
 Recognized properties are:
+
 @table @code
 @item :prepend
 Normally new captured information will be appended at
@@ -6782,7 +7115,9 @@ dynamic insertion of content.  The templates are expanded in the order given her
 @smallexample
 %[@var{file}]     @r{Insert the contents of the file given by @var{file}.}
 %(@var{sexp})     @r{Evaluate Elisp @var{sexp} and replace with the result.}
-            @r{The sexp must return a string.}
+                  @r{For convenience, %:keyword (see below) placeholders}
+                  @r{within the expression will be expanded prior to this.}
+                  @r{The sexp must return a string.}
 %<...>      @r{The result of format-time-string on the ... format specification.}
 %t          @r{Timestamp, date only.}
 %T          @r{Timestamp, with date and time.}
@@ -6855,22 +7190,22 @@ To place the cursor after template expansion use:
 
 @vindex org-capture-templates-contexts
 To control whether a capture template should be accessible from a specific
-context, you can customize @var{org-capture-templates-contexts}.  Let's say
+context, you can customize @code{org-capture-templates-contexts}.  Let's say
 for example that you have a capture template @code{"p"} for storing Gnus
 emails containing patches.  Then you would configure this option like this:
 
-@example
+@smalllisp
 (setq org-capture-templates-contexts
       '(("p" (in-mode . "message-mode"))))
-@end example
+@end smalllisp
 
 You can also tell that the command key @code{"p"} should refer to another
 template.  In that case, add this command key like this:
 
-@example
+@smalllisp
 (setq org-capture-templates-contexts
       '(("p" "q" (in-mode . "message-mode"))))
-@end example
+@end smalllisp
 
 See the docstring of the variable for more information.
 
@@ -6901,7 +7236,6 @@ directory.
 @noindent The following commands deal with attachments:
 
 @table @kbd
-
 @orgcmd{C-c C-a,org-attach}
 The dispatcher for commands related to the attachment system.  After these
 keys, a list of commands is displayed and you must press an additional key
@@ -6975,12 +7309,14 @@ web to import tasks into Org.  To access feeds, configure the variable
 @code{org-feed-alist}.  The docstring of this variable has detailed
 information.  Here is just an example:
 
-@example
+@smalllisp
+@group
 (setq org-feed-alist
      '(("Slashdot"
          "http://rss.slashdot.org/Slashdot/slashdot"
          "~/txt/org/feeds.org" "Slashdot Entries")))
-@end example
+@end group
+@end smalllisp
 
 @noindent
 will configure that new items from the feed provided by
@@ -7009,7 +7345,7 @@ list of drawers in that file:
 For more information, including how to read atom feeds, see
 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
 
-@node Protocols, Refiling notes, RSS Feeds, Capture - Refile - Archive
+@node Protocols, Refile and copy, RSS Feeds, Capture - Refile - Archive
 @section Protocols for external access
 @cindex protocols, for external access
 @cindex emacsserver
@@ -7023,17 +7359,22 @@ a remote website you are looking at with the browser.  See
 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
 documentation and setup instructions.
 
-@node Refiling notes, Archiving, Protocols, Capture - Refile - Archive
-@section Refiling notes
+@node Refile and copy, Archiving, Protocols, Capture - Refile - Archive
+@section Refile and copy
 @cindex refiling notes
+@cindex copying notes
 
-When reviewing the captured data, you may want to refile some of the entries
-into a different list, for example into a project.  Cutting, finding the
-right location, and then pasting the note is cumbersome.  To simplify this
-process, you can use the following special command:
+When reviewing the captured data, you may want to refile or to copy some of
+the entries into a different list, for example into a project.  Cutting,
+finding the right location, and then pasting the note is cumbersome.  To
+simplify this process, you can use the following special command:
 
 @table @kbd
+@orgcmd{C-c M-w,org-copy}
+@findex org-copy
+Copying works like refiling, except that the original note is not deleted.
 @orgcmd{C-c C-w,org-refile}
+@findex org-refile
 @vindex org-reverse-note-order
 @vindex org-refile-targets
 @vindex org-refile-use-outline-path
@@ -7041,6 +7382,7 @@ process, you can use the following special command:
 @vindex org-refile-allow-creating-parent-nodes
 @vindex org-log-refile
 @vindex org-refile-use-cache
+@vindex org-refile-keep
 Refile the entry or region at point.  This command offers possible locations
 for refiling the entry and lets you select one with completion.  The item (or
 all items in the region) is filed below the target heading as a subitem.
@@ -7064,13 +7406,17 @@ Use the refile interface to jump to a heading.
 Jump to the location where @code{org-refile} last moved a tree to.
 @item C-2 C-c C-w
 Refile as the child of the item currently being clocked.
+@item C-3 C-c C-w
+Refile and keep the entry in place.  Also see @code{org-refile-keep} to make
+this the default behavior, and beware that this may result in duplicated
+@code{ID} properties.
 @orgcmdtkc{C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w,C-0 C-c C-w,org-refile-cache-clear}
 Clear the target cache.  Caching of refile targets can be turned on by
 setting @code{org-refile-use-cache}.  To make the command see new possible
 targets, you have to clear the cache with this command.
 @end table
 
-@node Archiving,  , Refiling notes, Capture - Refile - Archive
+@node Archiving,  , Refile and copy, Capture - Refile - Archive
 @section Archiving
 @cindex archiving
 
@@ -7307,7 +7653,7 @@ Remove current file from the list of agenda files.
 @itemx C-,
 Cycle through agenda file list, visiting one file after the other.
 @kindex M-x org-iswitchb
-@item M-x org-iswitchb
+@item M-x org-iswitchb RET
 Command to use an @code{iswitchb}-like interface to switch to and between Org
 buffers.
 @end table
@@ -7338,6 +7684,7 @@ Remove the permanent restriction created by @kbd{C-c C-x <}.
 @noindent
 When working with @file{speedbar.el}, you can use the following commands in
 the Speedbar frame:
+
 @table @kbd
 @orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
 Permanently restrict the agenda to the item---either an Org file or a subtree
@@ -7358,6 +7705,7 @@ following we will assume that @kbd{C-c a} is indeed how the dispatcher
 is accessed and list keyboard access to commands accordingly.  After
 pressing @kbd{C-c a}, an additional letter is required to execute a
 command.  The dispatcher offers the following default commands:
+
 @table @kbd
 @item a
 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
@@ -7446,11 +7794,16 @@ C-c a a}) you may set the number of days to be displayed.
 
 @vindex org-agenda-span
 @vindex org-agenda-ndays
+@vindex org-agenda-start-day
+@vindex org-agenda-start-on-weekday
 The default number of days displayed in the agenda is set by the variable
 @code{org-agenda-span} (or the obsolete @code{org-agenda-ndays}).  This
 variable can be set to any number of days you want to see by default in the
-agenda, or to a span name, such a @code{day}, @code{week}, @code{month} or
-@code{year}.
+agenda, or to a span name, such as @code{day}, @code{week}, @code{month} or
+@code{year}.  For weekly agendas, the default is to start on the previous
+monday (see @code{org-agenda-start-on-weekday}).  You can also set the start
+date using a date shift: @code{(setq org-agenda-start-day "+10d")} will
+start the agenda ten days from today in the future.
 
 Remote editing from the agenda buffer means, for example, that you can
 change the dates of deadlines and appointments from the agenda buffer.
@@ -7656,16 +8009,21 @@ commands}.
 @subsubheading Match syntax
 
 @cindex Boolean logic, for tag/property searches
-A search string can use Boolean operators @samp{&} for AND and @samp{|} for
-OR@.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
-not implemented.  Each element in the search is either a tag, a regular
-expression matching tags, or an expression like @code{PROPERTY OPERATOR
-VALUE} with a comparison operator, accessing a property value.  Each element
-may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
-sugar for positive selection.  The AND operator @samp{&} is optional when
-@samp{+} or @samp{-} is present.  Here are some examples, using only tags.
+A search string can use Boolean operators @samp{&} for @code{AND} and
+@samp{|} for @code{OR}@.  @samp{&} binds more strongly than @samp{|}.
+Parentheses are not implemented.  Each element in the search is either a
+tag, a regular expression matching tags, or an expression like
+@code{PROPERTY OPERATOR VALUE} with a comparison operator, accessing a
+property value.  Each element may be preceded by @samp{-}, to select
+against it, and @samp{+} is syntactic sugar for positive selection.  The
+@code{AND} operator @samp{&} is optional when @samp{+} or @samp{-} is
+present.  Here are some examples, using only tags.
 
 @table @samp
+@item work
+Select headlines tagged @samp{:work:}.
+@item work&boss
+Select headlines tagged @samp{:work:} and @samp{:boss:}.
 @item +work-boss
 Select headlines tagged @samp{:work:}, but discard those also tagged
 @samp{:boss:}.
@@ -7682,6 +8040,13 @@ braces.  For example,
 @samp{work+@{^boss.*@}} matches headlines that contain the tag
 @samp{:work:} and any tag @i{starting} with @samp{boss}.
 
+@cindex group tags, as regular expressions
+Group tags (@pxref{Tag groups}) are expanded as regular expressions.  E.g.,
+if @samp{:work:} is a group tag for the group @samp{:work:lab:conf:}, then
+searching for @samp{work} will search for @samp{@{\(?:work\|lab\|conf\)@}}
+and searching for @samp{-work} will search for all headlines but those with
+one of the tag in the group (i.e., @samp{-@{\(?:work\|lab\|conf\)@}}).
+
 @cindex TODO keyword matching, with tags search
 @cindex level, require for tags/property match
 @cindex category, require for tags/property match
@@ -7690,16 +8055,20 @@ You may also test for properties (@pxref{Properties and Columns}) at the same
 time as matching tags.  The properties may be real properties, or special
 properties that represent other metadata (@pxref{Special properties}).  For
 example, the ``property'' @code{TODO} represents the TODO keyword of the
-entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
-So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
-that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
-DONE@.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
-count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
-The ITEM special property cannot currently be used in tags/property
+entry and the ``property'' @code{PRIORITY} represents the PRIORITY keyword of
+the entry.  The ITEM special property cannot currently be used in tags/property
 searches@footnote{But @pxref{x-agenda-skip-entry-regexp,
 ,skipping entries based on regexp}.}.
 
+Except the @pxref{Special properties}, one other ``property'' can also be
+used. @code{LEVEL} represents the level of an entry.  So a search
+@samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines that have
+the tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE@.
+In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not count
+the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
+
 Here are more examples:
+
 @table @samp
 @item work+TODO="WAITING"
 Select @samp{:work:}-tagged TODO lines with the specific TODO
@@ -7899,7 +8268,8 @@ associated with the item.
 @menu
 * Categories::                  Not all tasks are equal
 * Time-of-day specifications::  How the agenda knows the time
-* Sorting of agenda items::     The order of things
+* Sorting agenda items::        The order of things
+* Filtering/limiting agenda items::  Dynamically narrow the agenda
 @end menu
 
 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
@@ -7936,7 +8306,7 @@ longer than 10 characters.
 You can set up icons for category by customizing the
 @code{org-agenda-category-icon-alist} variable.
 
-@node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
+@node Time-of-day specifications, Sorting agenda items, Categories, Presentation and sorting
 @subsection Time-of-day specifications
 @cindex time-of-day specification
 
@@ -7987,8 +8357,8 @@ The time grid can be turned on and off with the variable
 @code{org-agenda-use-time-grid}, and can be configured with
 @code{org-agenda-time-grid}.
 
-@node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
-@subsection Sorting of agenda items
+@node Sorting agenda items, Filtering/limiting agenda items, Time-of-day specifications, Presentation and sorting
+@subsection Sorting agenda items
 @cindex sorting, of agenda items
 @cindex priorities, of agenda items
 Before being inserted into a view, the items are sorted.  How this is
@@ -8021,73 +8391,257 @@ Sorting can be customized using the variable
 @code{org-agenda-sorting-strategy}, and may also include criteria based on
 the estimated effort of an entry (@pxref{Effort estimates}).
 
-@node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
-@section Commands in the agenda buffer
-@cindex commands, in agenda buffer
+@node Filtering/limiting agenda items,  , Sorting agenda items, Presentation and sorting
+@subsection Filtering/limiting agenda items
 
-Entries in the agenda buffer are linked back to the Org file or diary
-file where they originate.  You are not allowed to edit the agenda
-buffer itself, but commands are provided to show and jump to the
-original entry location, and to edit the Org files ``remotely'' from
-the agenda buffer.  In this way, all information is stored only once,
-removing the risk that your agenda and note files may diverge.
+Agenda built-in or customized commands are statically defined.  Agenda
+filters and limits provide two ways of dynamically narrowing down the list of
+agenda entries: @emph{fitlers} and @emph{limits}.  Filters only act on the
+display of the items, while limits take effect before the list of agenda
+entries is built.  Filter are more often used interactively, while limits are
+mostly useful when defined as local variables within custom agenda commands.
 
-Some commands can be executed with mouse clicks on agenda lines.  For
-the other commands, the cursor needs to be in the desired line.
+@subsubheading Filtering in the agenda
+@cindex filtering, by tag, category, top headline and effort, in agenda
+@cindex tag filtering, in agenda
+@cindex category filtering, in agenda
+@cindex top headline filtering, in agenda
+@cindex effort filtering, in agenda
+@cindex query editing, in agenda
 
 @table @kbd
-@tsubheading{Motion}
-@cindex motion commands in agenda
-@orgcmd{n,org-agenda-next-line}
-Next line (same as @key{down} and @kbd{C-n}).
-@orgcmd{p,org-agenda-previous-line}
-Previous line (same as @key{up} and @kbd{C-p}).
-@tsubheading{View/Go to Org file}
-@orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
-Display the original location of the item in another window.
-With prefix arg, make sure that the entire entry is made visible in the
-outline, not only the heading.
-@c
-@orgcmd{L,org-agenda-recenter}
-Display original location and recenter that window.
-@c
-@orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
-Go to the original location of the item in another window.
-@c
-@orgcmd{@key{RET},org-agenda-switch-to}
-Go to the original location of the item and delete other windows.
-@c
-@orgcmd{F,org-agenda-follow-mode}
-@vindex org-agenda-start-with-follow-mode
-Toggle Follow mode.  In Follow mode, as you move the cursor through
-the agenda buffer, the other window always shows the corresponding
-location in the Org file.  The initial setting for this mode in new
-agenda buffers can be set with the variable
-@code{org-agenda-start-with-follow-mode}.
-@c
-@orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
-Display the entire subtree of the current item in an indirect buffer.  With a
-numeric prefix argument N, go up to level N and then take that tree.  If N is
-negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
-previously used indirect buffer.
+@orgcmd{/,org-agenda-filter-by-tag}
+@vindex org-agenda-tag-filter-preset
+Filter the agenda view with respect to a tag and/or effort estimates.  The
+difference between this and a custom agenda command is that filtering is very
+fast, so that you can switch quickly between different filters without having
+to recreate the agenda.@footnote{Custom commands can preset a filter by
+binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
+filter will then be applied to the view and persist as a basic filter through
+refreshes and more secondary filtering.  The filter is a global property of
+the entire agenda view---in a block agenda, you should only set this in the
+global options section, not in the section of an individual block.}
 
-@orgcmd{C-c C-o,org-agenda-open-link}
-Follow a link in the entry.  This will offer a selection of any links in the
-text belonging to the referenced Org node.  If there is only one link, it
-will be followed without a selection prompt.
+You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
+all.  Pressing @key{TAB} at that prompt will offer use completion to select a
+tag (including any tags that do not have a selection character).  The command
+then hides all entries that do not contain or inherit this tag.  When called
+with prefix arg, remove the entries that @emph{do} have the tag.  A second
+@kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
+If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
+will be narrowed by requiring or forbidding the selected additional tag.
+Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
+immediately use the @kbd{\} command.
 
-@tsubheading{Change display}
-@cindex display changing, in agenda
-@kindex A
-@item A
-Interactively select another agenda view and append it to the current view.
-@c
+@vindex org-sort-agenda-noeffort-is-high
+In order to filter for effort estimates, you should set up allowed
+efforts globally, for example
+@lisp
+(setq org-global-properties
+    '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
+@end lisp
+You can then filter for an effort by first typing an operator, one of
+@kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
+estimate in your array of allowed values, where @kbd{0} means the 10th value.
+The filter will then restrict to entries with effort smaller-or-equal, equal,
+or larger-or-equal than the selected value.  If the digits 0--9 are not used
+as fast access keys to tags, you can also simply press the index digit
+directly without an operator.  In this case, @kbd{<} will be assumed.  For
+application of the operator, entries without a defined effort will be treated
+according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
+for tasks without effort definition, press @kbd{?} as the operator.
+
+Org also supports automatic, context-aware tag filtering.  If the variable
+@code{org-agenda-auto-exclude-function} is set to a user-defined function,
+that function can decide which tags should be excluded from the agenda
+automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
+as a sub-option key and runs the auto exclusion logic.  For example, let's
+say you use a @code{Net} tag to identify tasks which need network access, an
+@code{Errand} tag for errands in town, and a @code{Call} tag for making phone
+calls.  You could auto-exclude these tags based on the availability of the
+Internet, and outside of business hours, with something like this:
+
+@smalllisp
+@group
+(defun org-my-auto-exclude-function (tag)
+  (and (cond
+        ((string= tag "Net")
+         (/= 0 (call-process "/sbin/ping" nil nil nil
+                             "-c1" "-q" "-t1" "mail.gnu.org")))
+        ((or (string= tag "Errand") (string= tag "Call"))
+         (let ((hour (nth 2 (decode-time))))
+           (or (< hour 8) (> hour 21)))))
+       (concat "-" tag)))
+
+(setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
+@end group
+@end smalllisp
+
+@orgcmd{\\,org-agenda-filter-by-tag-refine}
+Narrow the current agenda filter by an additional condition.  When called with
+prefix arg, remove the entries that @emph{do} have the tag, or that do match
+the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
+@kbd{-} as the first key after the @kbd{/} command.
+
+@c
+@kindex [
+@kindex ]
+@kindex @{
+@kindex @}
+@item [ ] @{ @}
+@table @i
+@item @r{in} search view
+add new search words (@kbd{[} and @kbd{]}) or new regular expressions
+(@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
+add a positive search term prefixed by @samp{+}, indicating that this search
+term @i{must} occur/match in the entry.  The closing bracket/brace will add a
+negative search term which @i{must not} occur/match in the entry for it to be
+selected.
+@end table
+
+@orgcmd{<,org-agenda-filter-by-category}
+@vindex org-agenda-category-filter-preset
+
+Filter the current agenda view with respect to the category of the item at
+point.  Pressing @code{<} another time will remove this filter.  You can add
+a filter preset through the option @code{org-agenda-category-filter-preset}
+(see below.)
+
+@orgcmd{^,org-agenda-filter-by-top-headline}
+Filter the current agenda view and only display the siblings and the parent
+headline of the one at point.
+
+@orgcmd{=,org-agenda-filter-by-regexp}
+@vindex org-agenda-regexp-filter-preset
+
+Filter the agenda view by a regular expression: only show agenda entries
+matching the regular expression the user entered.  When called with a prefix
+argument, it will filter @emph{out} entries matching the regexp.  With two
+universal prefix arguments, it will remove all the regexp filters, which can
+be accumulated.  You can add a filter preset through the option
+@code{org-agenda-category-filter-preset} (see below.)
+
+@orgcmd{|,org-agenda-filter-remove-all}
+Remove all filters in the current agenda view.
+@end table
+
+@subsubheading Setting limits for the agenda
+@cindex limits, in agenda
+@vindex org-agenda-max-entries
+@vindex org-agenda-max-effort
+@vindex org-agenda-max-todos
+@vindex org-agenda-max-tags
+
+Here is a list of options that you can set, either globally, or locally in
+your custom agenda views@pxref{Custom agenda views}.
+
+@table @var
+@item org-agenda-max-entries
+Limit the number of entries.
+@item org-agenda-max-effort
+Limit the duration of accumulated efforts (as minutes).
+@item org-agenda-max-todos
+Limit the number of entries with TODO keywords.
+@item org-agenda-max-tags
+Limit the number of tagged entries.
+@end table
+
+When set to a positive integer, each option will exclude entries from other
+categories: for example, @code{(setq org-agenda-max-effort 100)} will limit
+the agenda to 100 minutes of effort and exclude any entry that as no effort
+property.  If you want to include entries with no effort property, use a
+negative value for @code{org-agenda-max-effort}.
+
+One useful setup is to use @code{org-agenda-max-entries} locally in a custom
+command.  For example, this custom command will display the next five entries
+with a @code{NEXT} TODO keyword.
+
+@smalllisp
+(setq org-agenda-custom-commands
+      '(("n" todo "NEXT"
+         ((org-agenda-max-entries 5)))))
+@end smalllisp
+
+Once you mark one of these five entry as @code{DONE}, rebuilding the agenda
+will again the next five entries again, including the first entry that was
+excluded so far.
+
+You can also dynamically set temporary limits@footnote{Those temporary limits
+are lost when rebuilding the agenda.}:
+
+@table @kbd
+@orgcmd{~,org-agenda-limit-interactively}
+This prompts for the type of limit to apply and its value.
+@end table
+
+@node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
+@section Commands in the agenda buffer
+@cindex commands, in agenda buffer
+
+Entries in the agenda buffer are linked back to the Org file or diary
+file where they originate.  You are not allowed to edit the agenda
+buffer itself, but commands are provided to show and jump to the
+original entry location, and to edit the Org files ``remotely'' from
+the agenda buffer.  In this way, all information is stored only once,
+removing the risk that your agenda and note files may diverge.
+
+Some commands can be executed with mouse clicks on agenda lines.  For
+the other commands, the cursor needs to be in the desired line.
+
+@table @kbd
+@tsubheading{Motion}
+@cindex motion commands in agenda
+@orgcmd{n,org-agenda-next-line}
+Next line (same as @key{down} and @kbd{C-n}).
+@orgcmd{p,org-agenda-previous-line}
+Previous line (same as @key{up} and @kbd{C-p}).
+@tsubheading{View/Go to Org file}
+@orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
+Display the original location of the item in another window.
+With prefix arg, make sure that the entire entry is made visible in the
+outline, not only the heading.
+@c
+@orgcmd{L,org-agenda-recenter}
+Display original location and recenter that window.
+@c
+@orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
+Go to the original location of the item in another window.
+@c
+@orgcmd{@key{RET},org-agenda-switch-to}
+Go to the original location of the item and delete other windows.
+@c
+@orgcmd{F,org-agenda-follow-mode}
+@vindex org-agenda-start-with-follow-mode
+Toggle Follow mode.  In Follow mode, as you move the cursor through
+the agenda buffer, the other window always shows the corresponding
+location in the Org file.  The initial setting for this mode in new
+agenda buffers can be set with the variable
+@code{org-agenda-start-with-follow-mode}.
+@c
+@orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
+Display the entire subtree of the current item in an indirect buffer.  With a
+numeric prefix argument N, go up to level N and then take that tree.  If N is
+negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
+previously used indirect buffer.
+
+@orgcmd{C-c C-o,org-agenda-open-link}
+Follow a link in the entry.  This will offer a selection of any links in the
+text belonging to the referenced Org node.  If there is only one link, it
+will be followed without a selection prompt.
+
+@tsubheading{Change display}
+@cindex display changing, in agenda
+@kindex A
+@item A
+Interactively select another agenda view and append it to the current view.
+@c
 @kindex o
 @item o
 Delete other windows.
 @c
 @orgcmdkskc{v d,d,org-agenda-day-view}
 @xorgcmdkskc{v w,w,org-agenda-week-view}
+@xorgcmd{v t,org-agenda-fortnight-view}
 @xorgcmd{v m,org-agenda-month-view}
 @xorgcmd{v y,org-agenda-year-view}
 @xorgcmd{v SPC,org-agenda-reset-view}
@@ -8134,7 +8688,7 @@ entries that have been clocked on that day.  You can configure the entry
 types that should be included in log mode using the variable
 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
 all possible logbook entries, including state changes.  When called with two
-prefix args @kbd{C-u C-u}, show only logging information, nothing else.
+prefix arguments @kbd{C-u C-u}, show only logging information, nothing else.
 @kbd{v L} is equivalent to @kbd{C-u v l}.
 @c
 @orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
@@ -8152,7 +8706,7 @@ press @kbd{v a} again.
 @vindex org-agenda-start-with-clockreport-mode
 @vindex org-clock-report-include-clocking-task
 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
-always show a table with the clocked times for the timespan and file scope
+always show a table with the clocked times for the time span and file scope
 covered by the current agenda view.  The initial setting for this mode in new
 agenda buffers can be set with the variable
 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
@@ -8212,108 +8766,39 @@ Remove the restriction lock on the agenda, if it is currently restricted to a
 file or subtree (@pxref{Agenda files}).
 
 @tsubheading{Secondary filtering and query editing}
-@cindex filtering, by tag category and effort, in agenda
-@cindex tag filtering, in agenda
-@cindex category filtering, in agenda
-@cindex effort filtering, in agenda
-@cindex query editing, in agenda
-
-@orgcmd{<,org-agenda-filter-by-category}
-@vindex org-agenda-category-filter-preset
 
-Filter the current agenda view with respect to the category of the item at
-point.  Pressing @code{<} another time will remove this filter.  You can add
-a filter preset through the option @code{org-agenda-category-filter-preset}
-(see below.)
+For a detailed description of these commands, see @pxref{Filtering/limiting
+agenda items}.
 
 @orgcmd{/,org-agenda-filter-by-tag}
 @vindex org-agenda-tag-filter-preset
-Filter the current agenda view with respect to a tag and/or effort estimates.
-The difference between this and a custom agenda command is that filtering is
-very fast, so that you can switch quickly between different filters without
-having to recreate the agenda.@footnote{Custom commands can preset a filter by
-binding the variable @code{org-agenda-tag-filter-preset} as an option.  This
-filter will then be applied to the view and persist as a basic filter through
-refreshes and more secondary filtering.  The filter is a global property of
-the entire agenda view---in a block agenda, you should only set this in the
-global options section, not in the section of an individual block.}
+Filter the agenda view with respect to a tag and/or effort estimates.
 
-You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
-all.  Pressing @key{TAB} at that prompt will offer use completion to select a
-tag (including any tags that do not have a selection character).  The command
-then hides all entries that do not contain or inherit this tag.  When called
-with prefix arg, remove the entries that @emph{do} have the tag.  A second
-@kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
-If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
-will be narrowed by requiring or forbidding the selected additional tag.
-Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
-immediately use the @kbd{\} command.
+@orgcmd{\\,org-agenda-filter-by-tag-refine}
+Narrow the current agenda filter by an additional condition.
 
-@vindex org-sort-agenda-noeffort-is-high
-In order to filter for effort estimates, you should set up allowed
-efforts globally, for example
-@lisp
-(setq org-global-properties
-    '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
-@end lisp
-You can then filter for an effort by first typing an operator, one of
-@kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
-estimate in your array of allowed values, where @kbd{0} means the 10th value.
-The filter will then restrict to entries with effort smaller-or-equal, equal,
-or larger-or-equal than the selected value.  If the digits 0--9 are not used
-as fast access keys to tags, you can also simply press the index digit
-directly without an operator.  In this case, @kbd{<} will be assumed.  For
-application of the operator, entries without a defined effort will be treated
-according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
-for tasks without effort definition, press @kbd{?} as the operator.
+@orgcmd{<,org-agenda-filter-by-category}
+@vindex org-agenda-category-filter-preset
 
-Org also supports automatic, context-aware tag filtering.  If the variable
-@code{org-agenda-auto-exclude-function} is set to a user-defined function,
-that function can decide which tags should be excluded from the agenda
-automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
-as a sub-option key and runs the auto exclusion logic.  For example, let's
-say you use a @code{Net} tag to identify tasks which need network access, an
-@code{Errand} tag for errands in town, and a @code{Call} tag for making phone
-calls.  You could auto-exclude these tags based on the availability of the
-Internet, and outside of business hours, with something like this:
+Filter the current agenda view with respect to the category of the item at
+point.  Pressing @code{<} another time will remove this filter.
 
-@lisp
-@group
-(defun org-my-auto-exclude-function (tag)
-  (and (cond
-        ((string= tag "Net")
-         (/= 0 (call-process "/sbin/ping" nil nil nil
-                             "-c1" "-q" "-t1" "mail.gnu.org")))
-        ((or (string= tag "Errand") (string= tag "Call"))
-         (let ((hour (nth 2 (decode-time))))
-           (or (< hour 8) (> hour 21)))))
-       (concat "-" tag)))
+@orgcmd{^,org-agenda-filter-by-top-headline}
+Filter the current agenda view and only display the siblings and the parent
+headline of the one at point.
 
-(setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
-@end group
-@end lisp
+@orgcmd{=,org-agenda-filter-by-regexp}
+@vindex org-agenda-regexp-filter-preset
 
-@orgcmd{\\,org-agenda-filter-by-tag-refine}
-Narrow the current agenda filter by an additional condition.  When called with
-prefix arg, remove the entries that @emph{do} have the tag, or that do match
-the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
-@kbd{-} as the first key after the @kbd{/} command.
+Filter the agenda view by a regular expression: only show agenda entries
+matching the regular expression the user entered.  When called with a prefix
+argument, it will filter @emph{out} entries matching the regexp.  With two
+universal prefix arguments, it will remove all the regexp filters, which can
+be accumulated.  You can add a filter preset through the option
+@code{org-agenda-category-filter-preset} (see below.)
 
-@c
-@kindex [
-@kindex ]
-@kindex @{
-@kindex @}
-@item [ ] @{ @}
-@table @i
-@item @r{in} search view
-add new search words (@kbd{[} and @kbd{]}) or new regular expressions
-(@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
-add a positive search term prefixed by @samp{+}, indicating that this search
-term @i{must} occur/match in the entry.  The closing bracket/brace will add a
-negative search term which @i{must not} occur/match in the entry for it to be
-selected.
-@end table
+@orgcmd{|,org-agenda-filter-remove-all}
+Remove all filters in the current agenda view.
 
 @tsubheading{Remote editing}
 @cindex remote editing, from agenda
@@ -8440,29 +8925,50 @@ Jump to the running clock in another window.
 @c
 @orgcmd{k,org-agenda-capture}
 Like @code{org-capture}, but use the date at point as the default date for
-the capture template.  See @var{org-capture-use-agenda-date} to make this
+the capture template.  See @code{org-capture-use-agenda-date} to make this
 the default behavior of @code{org-capture}.
 @cindex capturing, from agenda
 @vindex org-capture-use-agenda-date
 
+@tsubheading{Dragging agenda lines forward/backward}
+@cindex dragging, agenda lines
+
+@orgcmd{M-<up>,org-agenda-drag-line-backward}
+Drag the line at point backward one line@footnote{Moving agenda lines does
+not persist after an agenda refresh and does not modify the contributing
+@file{.org} files}.  With a numeric prefix argument, drag backward by that
+many lines.
+
+@orgcmd{M-<down>,org-agenda-drag-line-forward}
+Drag the line at point forward one line.  With a numeric prefix argument,
+drag forward by that many lines.
+
 @tsubheading{Bulk remote editing selected entries}
 @cindex remote editing, bulk, from agenda
-@vindex org-agenda-bulk-persistent-marks
 @vindex org-agenda-bulk-custom-functions
 
 @orgcmd{m,org-agenda-bulk-mark}
-Mark the entry at point for bulk action.  With prefix arg, mark that many
-successive entries.
+Mark the entry at point for bulk action.  With numeric prefix argument, mark
+that many successive entries.
 @c
-@orgcmd{%,org-agenda-bulk-mark-regexp}
-Mark entries matching a regular expression for bulk action.
+@orgcmd{*,org-agenda-bulk-mark-all}
+Mark all visible agenda entries for bulk action.
 @c
 @orgcmd{u,org-agenda-bulk-unmark}
-Unmark entry for bulk action.
+Unmark entry at point for bulk action.
 @c
 @orgcmd{U,org-agenda-bulk-remove-all-marks}
 Unmark all marked entries for bulk action.
 @c
+@orgcmd{M-m,org-agenda-bulk-toggle}
+Toggle mark of the entry at point for bulk action.
+@c
+@orgcmd{M-*,org-agenda-bulk-toggle-all}
+Toggle marks of all visible entries for bulk action.
+@c
+@orgcmd{%,org-agenda-bulk-mark-regexp}
+Mark entries matching a regular expression for bulk action.
+@c
 @orgcmd{B,org-agenda-bulk-action}
 Bulk action: act on all marked entries in the agenda.  This will prompt for
 another key to select the action to be applied.  The prefix arg to @kbd{B}
@@ -8471,40 +8977,55 @@ these special timestamps.  By default, marks are removed after the bulk.  If
 you want them to persist, set @code{org-agenda-bulk-persistent-marks} to
 @code{t} or hit @kbd{p} at the prompt.
 
-@example
-*  @r{Toggle persistent marks.}
-$  @r{Archive all selected entries.}
-A  @r{Archive entries by moving them to their respective archive siblings.}
-t  @r{Change TODO state.  This prompts for a single TODO keyword and}
-   @r{changes the state of all selected entries, bypassing blocking and}
-   @r{suppressing logging notes (but not timestamps).}
-+  @r{Add a tag to all selected entries.}
--  @r{Remove a tag from all selected entries.}
-s  @r{Schedule all items to a new date.  To shift existing schedule dates}
-   @r{by a fixed number of days, use something starting with double plus}
-   @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
-d  @r{Set deadline to a specific date.}
-r  @r{Prompt for a single refile target and move all entries.  The entries}
-   @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
-S  @r{Reschedule randomly into the coming N days.  N will be prompted for.}
-   @r{With prefix arg (@kbd{C-u B S}), scatter only across weekdays.}
-f  @r{Apply a function@footnote{You can also create persistent custom functions through@code{org-agenda-bulk-custom-functions}.} to marked entries.}
-   @r{For example, the function below sets the CATEGORY property of the}
-   @r{entries to web.}
-   @r{(defun set-category ()}
-   @r{  (interactive "P")}
-   @r{  (let* ((marker (or (org-get-at-bol 'org-hd-marker)}
-   @r{                     (org-agenda-error)))}
-   @r{            (buffer (marker-buffer marker)))}
-   @r{       (with-current-buffer buffer}
-   @r{         (save-excursion}
-   @r{           (save-restriction}
-   @r{             (widen)}
-   @r{             (goto-char marker)}
-   @r{             (org-back-to-heading t)}
-   @r{             (org-set-property "CATEGORY" "web"))))))}
-@end example
+@table @kbd
+@item *
+Toggle persistent marks.
+@item $
+Archive all selected entries.
+@item A
+Archive entries by moving them to their respective archive siblings.
+@item t
+Change TODO state.  This prompts for a single TODO keyword and changes the
+state of all selected entries, bypassing blocking and suppressing logging
+notes (but not timestamps).
+@item +
+Add a tag to all selected entries.
+@item -
+Remove a tag from all selected entries.
+@item s
+Schedule all items to a new date.  To shift existing schedule dates by a
+fixed number of days, use something starting with double plus at the prompt,
+for example @samp{++8d} or @samp{++2w}.
+@item d
+Set deadline to a specific date.
+@item r
+Prompt for a single refile target and move all entries.  The entries will no
+longer be in the agenda; refresh (@kbd{g}) to bring them back.
+@item S
+Reschedule randomly into the coming N days.  N will be prompted for.  With
+prefix arg (@kbd{C-u B S}), scatter only across weekdays.
+@item f
+Apply a function@footnote{You can also create persistent custom functions
+through @code{org-agenda-bulk-custom-functions}.} to marked entries.  For
+example, the function below sets the CATEGORY property of the entries to web.
 
+@lisp
+@group
+(defun set-category ()
+  (interactive "P")
+  (let* ((marker (or (org-get-at-bol 'org-hd-marker)
+                     (org-agenda-error)))
+         (buffer (marker-buffer marker)))
+    (with-current-buffer buffer
+      (save-excursion
+        (save-restriction
+          (widen)
+          (goto-char marker)
+          (org-back-to-heading t)
+          (org-set-property "CATEGORY" "web"))))))
+@end group
+@end lisp
+@end table
 
 @tsubheading{Calendar commands}
 @cindex calendar commands, from agenda
@@ -8551,7 +9072,7 @@ calendars.
 @orgcmd{H,org-agenda-holidays}
 Show holidays for three months around the cursor date.
 
-@item M-x org-export-icalendar-combine-agenda-files
+@item M-x org-icalendar-combine-agenda-files RET
 Export a single iCalendar file containing entries from all agenda files.
 This is a globally available command, and also available in the agenda menu.
 
@@ -8561,12 +9082,13 @@ This is a globally available command, and also available in the agenda menu.
 @cindex agenda views, exporting
 @vindex org-agenda-exporter-settings
 Write the agenda view to a file.  Depending on the extension of the selected
-file name, the view will be exported as HTML (extension @file{.html} or
-@file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
-and plain text (any other extension).  When called with a @kbd{C-u} prefix
-argument, immediately open the newly created file.  Use the variable
-@code{org-agenda-exporter-settings} to set options for @file{ps-print} and
-for @file{htmlize} to be used during export.
+file name, the view will be exported as HTML (@file{.html} or @file{.htm}),
+Postscript (@file{.ps}), PDF (@file{.pdf}), Org (@file{.org}) and plain text
+(any other extension).  When exporting to Org, only the body of original
+headlines are exported, not subtrees or inherited tags.  When called with a
+@kbd{C-u} prefix argument, immediately open the newly created file.  Use the
+variable @code{org-agenda-exporter-settings} to set options for
+@file{ps-print} and for @file{htmlize} to be used during export.
 
 @tsubheading{Quit and Exit}
 @orgcmd{q,org-agenda-quit}
@@ -8606,6 +9128,8 @@ buffer).
 @kindex C-c a C
 @vindex org-agenda-custom-commands
 @cindex agenda views, main example
+@cindex agenda, as an agenda views
+@cindex agenda*, as an agenda views
 @cindex tags, as an agenda view
 @cindex todo, as an agenda view
 @cindex tags-todo
@@ -8616,13 +9140,15 @@ buffer).
 Custom commands are configured in the variable
 @code{org-agenda-custom-commands}.  You can customize this variable, for
 example by pressing @kbd{C-c a C}.  You can also directly set it with Emacs
-Lisp in @file{.emacs}.  The following example contains all valid search
-types:
+Lisp in @file{.emacs}.  The following example contains all valid agenda
+views:
 
 @lisp
 @group
 (setq org-agenda-custom-commands
-      '(("w" todo "WAITING")
+      '(("x" agenda)
+        ("y" agenda*)
+        ("w" todo "WAITING")
         ("W" todo-tree "WAITING")
         ("u" tags "+boss-urgent")
         ("v" tags-todo "+boss-urgent")
@@ -8648,6 +9174,15 @@ expression to be used for the matching.  The example above will
 therefore define:
 
 @table @kbd
+@item C-c a x
+as a global search for agenda entries planned@footnote{@emph{Planned} means
+here that these entries have some planning information attached to them, like
+a time-stamp, a scheduled or a deadline string.  See
+@code{org-agenda-entry-types} on how to set what planning information will be
+taken into account.} this week/day.
+@item C-c a y
+as a global search for agenda entries planned this week/day, but only those
+with an hour specification like @code{[h]h:mm}---think of them as appointments.
 @item C-c a w
 as a global search for TODO entries with @samp{WAITING} as the TODO
 keyword
@@ -8782,23 +9317,23 @@ yourself.
 
 @vindex org-agenda-custom-commands-contexts
 To control whether an agenda command should be accessible from a specific
-context, you can customize @var{org-agenda-custom-commands-contexts}.  Let's
+context, you can customize @code{org-agenda-custom-commands-contexts}.  Let's
 say for example that you have an agenda commands @code{"o"} displaying a view
 that you only need when reading emails.  Then you would configure this option
 like this:
 
-@example
+@lisp
 (setq org-agenda-custom-commands-contexts
       '(("o" (in-mode . "message-mode"))))
-@end example
+@end lisp
 
 You can also tell that the command key @code{"o"} should refer to another
 command key @code{"r"}.  In that case, add this command key like this:
 
-@example
+@lisp
 (setq org-agenda-custom-commands-contexts
       '(("o" "r" (in-mode . "message-mode"))))
-@end example
+@end lisp
 
 See the docstring of the variable for more information.
 
@@ -9009,19 +9544,20 @@ spent (via @code{CLOCKSUM}) and with the planned total effort for it.
 @chapter Markup for rich export
 
 When exporting Org mode documents, the exporter tries to reflect the
-structure of the document as accurately as possible in the backend.  Since
-export targets like HTML, @LaTeX{}, or DocBook allow much richer formatting,
-Org mode has rules on how to prepare text for rich export.  This section
-summarizes the markup rules used in an Org mode buffer.
+structure of the document as accurately as possible in the back-end.  Since
+export targets like HTML, @LaTeX{} allow much richer formatting, Org mode has
+rules on how to prepare text for rich export.  This section summarizes the
+markup rules used in an Org mode buffer.
 
 @menu
 * Structural markup elements::  The basic structure as seen by the exporter
-* Images and tables::           Tables and Images will be included
+* Images and tables::           Images, tables and caption mechanism
 * Literal examples::            Source code examples with special formatting
 * Include files::               Include additional files into a document
 * Index entries::               Making an index
-* Macro replacement::           Use macros to create complex output
+* Macro replacement::           Use macros to create templates
 * Embedded @LaTeX{}::           LaTeX can be freely used inside Org documents
+* Special blocks::              Containers targeted at export back-ends
 @end menu
 
 @node Structural markup elements, Images and tables, Markup, Markup
@@ -9031,7 +9567,6 @@ summarizes the markup rules used in an Org mode buffer.
 * Document title::              Where the title is taken from
 * Headings and sections::       The document structure as seen by the exporter
 * Table of contents::           The if and where of the table of contents
-* Initial text::                Text before the first heading?
 * Lists::                       Lists
 * Paragraphs::                  Paragraphs
 * Footnote markup::             Footnotes
@@ -9053,15 +9588,13 @@ The title of the exported document is taken from the special line
 @end example
 
 @noindent
-If this line does not exist, the title is derived from the first non-empty,
-non-comment line in the buffer.  If no such line exists, or if you have
-turned off exporting of the text before the first headline (see below), the
-title will be the file name without extension.
+If this line does not exist, the title will be the name of the file
+associated to buffer, without extension, or the buffer name.
 
 @cindex property, EXPORT_TITLE
-If you are exporting only a subtree by marking is as the region, the heading
-of the subtree will become the title of the document.  If the subtree has a
-property @code{EXPORT_TITLE}, that will take precedence.
+If you are exporting only a subtree, its heading will become the title of the
+document.  If the subtree has a property @code{EXPORT_TITLE}, that will take
+precedence.
 
 @node Headings and sections, Table of contents, Document title, Structural markup elements
 @subheading Headings and sections
@@ -9081,58 +9614,55 @@ per-file basis with a line
 #+OPTIONS: H:4
 @end example
 
-@node Table of contents, Initial text, Headings and sections, Structural markup elements
+@node Table of contents, Lists, Headings and sections, Structural markup elements
 @subheading Table of contents
 @cindex table of contents, markup rules
 
+@cindex #+TOC
 @vindex org-export-with-toc
 The table of contents is normally inserted directly before the first headline
-of the file.  If you would like to get it to a different location, insert the
-string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
-location.  The depth of the table of contents is by default the same as the
-number of headline levels, but you can choose a smaller number, or turn off
-the table of contents entirely, by configuring the variable
-@code{org-export-with-toc}, or on a per-file basis with a line like
+of the file.  The depth of the table is by default the same as the number of
+headline levels, but you can choose a smaller number, or turn off the table
+of contents entirely, by configuring the variable @code{org-export-with-toc},
+or on a per-file basis with a line like
 
 @example
 #+OPTIONS: toc:2          (only to two levels in TOC)
-#+OPTIONS: toc:nil        (no TOC at all)
+#+OPTIONS: toc:nil        (no default TOC at all)
 @end example
 
-@node Initial text, Lists, Table of contents, Structural markup elements
-@subheading Text before the first headline
-@cindex text before first headline, markup rules
-@cindex #+TEXT
-
-Org mode normally exports the text before the first headline, and even uses
-the first line as the document title.  The text will be fully marked up.  If
-you need to include literal HTML, @LaTeX{}, or DocBook code, use the special
-constructs described below in the sections for the individual exporters.
+If you would like to move the table of contents to a different location, you
+should turn off the default table using @code{org-export-with-toc} or
+@code{#+OPTIONS} and insert @code{#+TOC: headlines N} at the desired
+location(s).
 
-@vindex org-export-skip-text-before-1st-heading
-Some people like to use the space before the first headline for setup and
-internal links and therefore would like to control the exported text before
-the first headline in a different way.  You can do so by setting the variable
-@code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
-basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
+@example
+#+OPTIONS: toc:nil        (no default TOC)
+...
+#+TOC: headlines 2        (insert TOC here, with two headline levels)
+@end example
 
-@noindent
-If you still want to have some text before the first headline, use the
-@code{#+TEXT} construct:
+Multiple @code{#+TOC: headline} lines are allowed.  The same @code{TOC}
+keyword can also generate a list of all tables (resp.@: all listings) with a
+caption in the buffer.
 
 @example
-#+OPTIONS: skip:t
-#+TEXT: This text will go before the *first* headline.
-#+TEXT: [TABLE-OF-CONTENTS]
-#+TEXT: This goes between the table of contents and the *first* headline
+#+TOC: listings           (build a list of listings)
+#+TOC: tables             (build a list of tables)
 @end example
 
-@node Lists, Paragraphs, Initial text, Structural markup elements
+@cindex property, ALT_TITLE
+The headline's title usually determines its corresponding entry in a table of
+contents.  However, it is possible to specify an alternative title by
+setting @code{ALT_TITLE} property accordingly.  It will then be used when
+building the table.
+
+@node Lists, Paragraphs, Table of contents, Structural markup elements
 @subheading Lists
 @cindex lists, markup rules
 
-Plain lists as described in @ref{Plain lists}, are translated to the backend's
-syntax for such lists.  Most backends support unordered, ordered, and
+Plain lists as described in @ref{Plain lists}, are translated to the back-end's
+syntax for such lists.  Most back-ends support unordered, ordered, and
 description lists.
 
 @node Paragraphs, Footnote markup, Lists, Structural markup elements
@@ -9184,7 +9714,7 @@ but not any simpler
 @cindex @file{footnote.el}
 
 Footnotes defined in the way described in @ref{Footnotes}, will be exported
-by all backends.  Org allows multiple references to the same note, and
+by all back-ends.  Org allows multiple references to the same note, and
 multiple footnotes side by side.
 
 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
@@ -9196,16 +9726,27 @@ multiple footnotes side by side.
 @cindex verbatim text, markup rules
 @cindex code text, markup rules
 @cindex strike-through text, markup rules
+@vindex org-fontify-emphasized-text
+@vindex org-emphasis-regexp-components
+@vindex org-emphasis-alist
 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
 in the code and verbatim string is not processed for Org mode specific
-syntax; it is exported verbatim.
+syntax, it is exported verbatim.
+
+To turn off fontification for marked up text, you can set
+@code{org-fontify-emphasized-text} to @code{nil}.  To narrow down the list of
+available markup syntax, you can customize @code{org-emphasis-alist}.  To fine
+tune what characters are allowed before and after the markup characters, you
+can tweak @code{org-emphasis-regexp-components}.  Beware that changing one of
+the above variables will no take effect until you reload Org, for which you
+may need to restart Emacs.
 
 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
 @subheading  Horizontal rules
 @cindex horizontal rules, markup rules
 A line consisting of only dashes, and at least 5 of them, will be exported as
-a horizontal line (@samp{<hr/>} in HTML and @code{\hrule} in @LaTeX{}).
+a horizontal line.
 
 @node Comment lines,  , Horizontal rules, Structural markup elements
 @subheading Comment lines
@@ -9231,45 +9772,48 @@ Toggle the COMMENT keyword at the beginning of an entry.
 
 @cindex tables, markup rules
 @cindex #+CAPTION
-@cindex #+LABEL
+@cindex #+NAME
 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
 the @file{table.el} package will be exported properly.  For Org mode tables,
 the lines before the first horizontal separator line will become table header
 lines.  You can use the following lines somewhere before the table to assign
 a caption and a label for cross references, and in the text you can refer to
-the object with @code{\ref@{tab:basic-data@}}:
+the object with @code{[[tab:basic-data]]} (@pxref{Internal links}):
 
 @example
 #+CAPTION: This is the caption for the next table (or link)
-#+LABEL:   tab:basic-data
+#+NAME:   tab:basic-data
    | ... | ...|
    |-----|----|
 @end example
 
 Optionally, the caption can take the form:
 @example
-#+CAPTION: [Caption for list of figures]@{Caption for table (or link).@}
+#+CAPTION[Caption for list of tables]: Caption for table.
 @end example
 
 @cindex inlined images, markup rules
-Some backends (HTML, @LaTeX{}, and DocBook) allow you to directly include
-images into the exported document.  Org does this, if a link to an image
-files does not have a description part, for example @code{[[./img/a.jpg]]}.
-If you wish to define a caption for the image and maybe a label for internal
-cross references, make sure that the link is on a line by itself and precede
-it with @code{#+CAPTION} and @code{#+LABEL} as follows:
+Some back-ends allow you to directly include images into the exported
+document.  Org does this, if a link to an image files does not have
+a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
+define a caption for the image and maybe a label for internal cross
+references, make sure that the link is on a line by itself and precede it
+with @code{#+CAPTION} and @code{#+NAME} as follows:
 
 @example
 #+CAPTION: This is the caption for the next figure link (or table)
-#+LABEL:   fig:SED-HR4049
+#+NAME:   fig:SED-HR4049
 [[./img/a.jpg]]
 @end example
 
-You may also define additional attributes for the figure.  As this is
-backend-specific, see the sections about the individual backends for more
-information.
+@noindent
+Such images can be displayed within the buffer.  @xref{Handling links,the
+discussion of image links}.
 
-@xref{Handling links,the discussion of image links}.
+Even though images and tables are prominent examples of captioned structures,
+the same caption mechanism can apply to many others (e.g., @LaTeX{}
+equations, source code blocks).  Depending on the export back-end, those may
+or may not be handled.
 
 @node Literal examples, Include files, Images and tables, Markup
 @section Literal examples
@@ -9302,11 +9846,11 @@ Here is an example
 If the example is source code from a programming language, or any other text
 that can be marked up by font-lock in Emacs, you can ask for the example to
 look like the fontified Emacs buffer@footnote{This works automatically for
-the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
+the HTML back-end (it requires version 1.34 of the @file{htmlize.el} package,
 which is distributed with Org).  Fontified code chunks in @LaTeX{} can be
 achieved using either the listings or the
 @url{http://code.google.com/p/minted, minted,} package.  Refer to
-@code{org-export-latex-listings} documentation for details.}.  This is done
+@code{org-latex-listings} documentation for details.}.  This is done
 with the @samp{src} block, where you also need to specify the name of the
 major mode that should be used to fontify the example@footnote{Code in
 @samp{src} blocks may also be evaluated either interactively or on export.
@@ -9398,20 +9942,24 @@ include your @file{.emacs} file, you could use:
 @example
 #+INCLUDE: "~/.emacs" src emacs-lisp
 @end example
+
 @noindent
 The optional second and third parameter are the markup (e.g., @samp{quote},
 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
 language for formatting the contents.  The markup is optional; if it is not
 given, the text will be assumed to be in Org mode format and will be
-processed normally.  The include line will also allow additional keyword
-parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
-first line and for each following line, @code{:minlevel} in order to get
-Org mode content demoted to a specified level, as well as any options
-accepted by the selected markup.  For example, to include a file as an item,
-use
+processed normally.
+
+Contents of the included file will belong to the same structure (headline,
+item) containing the @code{INCLUDE} keyword.  In particular, headlines within
+the file will become children of the current section.  That behaviour can be
+changed by providing an additional keyword parameter, @code{:minlevel}.  In
+that case, all headlines in the included file will be shifted so the one with
+the lowest level reaches that specified level.  For example, to make a file
+become a sibling of the current top-level headline, use
 
 @example
-#+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
+#+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
 @end example
 
 You can also include a portion of a file by specifying a lines range using
@@ -9460,21 +10008,24 @@ You can define text snippets with
 #+MACRO: name   replacement text $1, $2 are arguments
 @end example
 
-@noindent which can be referenced anywhere in the document (even in
-code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
-defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
-will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
-similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
+@noindent which can be referenced in
+paragraphs, verse blocks, table cells and some keywords with
+@code{@{@{@{name(arg1,arg2)@}@}@}}@footnote{Since commas separate arguments,
+commas within arguments have to be escaped with a backslash character.
+Conversely, backslash characters before a comma, and only them, need to be
+escaped with another backslash character.}.  In addition to defined macros,
+@code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc., will reference
+information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and similar lines.
+Also, @code{@{@{@{time(@var{FORMAT})@}@}@}} and
 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
 and to the modification time of the file being exported, respectively.
 @var{FORMAT} should be a format string understood by
 @code{format-time-string}.
 
-Macro expansion takes place during export, and some people use it to
-construct complex HTML code.
+Macro expansion takes place during export.
 
 
-@node Embedded @LaTeX{},  , Macro replacement, Markup
+@node Embedded @LaTeX{}, Special blocks, Macro replacement, Markup
 @section Embedded @LaTeX{}
 @cindex @TeX{} interpretation
 @cindex @LaTeX{} interpretation
@@ -9487,7 +10038,7 @@ Donald E. Knuth's @TeX{} system.  Many of the features described here as
 distinction.}  is widely used to typeset scientific documents.  Org mode
 supports embedding @LaTeX{} code into its files, because many academics are
 used to writing and reading @LaTeX{} source code, and because it can be
-readily processed to produce pretty output for a number of export backends.
+readily processed to produce pretty output for a number of export back-ends.
 
 @menu
 * Special symbols::             Greek letters and other symbols
@@ -9506,11 +10057,11 @@ readily processed to produce pretty output for a number of export backends.
 @cindex HTML entities
 @cindex @LaTeX{} entities
 
-You can use @LaTeX{} macros to insert special symbols like @samp{\alpha} to
-indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
-for these macros is available, just type @samp{\} and maybe a few letters,
+You can use @LaTeX{}-like syntax to insert special symbols like @samp{\alpha}
+to indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
+for these symbols is available, just type @samp{\} and maybe a few letters,
 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
-code, Org mode allows these macros to be present without surrounding math
+code, Org mode allows these symbols to be present without surrounding math
 delimiters, for example:
 
 @example
@@ -9519,7 +10070,7 @@ Angles are written as Greek letters \alpha, \beta and \gamma.
 
 @vindex org-entities
 During export, these symbols will be transformed into the native format of
-the exporter backend.  Strings like @code{\alpha} will be exported as
+the exporter back-end.  Strings like @code{\alpha} will be exported as
 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
 @code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
@@ -9531,12 +10082,13 @@ A large number of entities is provided, with names taken from both HTML and
 @samp{...} are all converted into special commands creating hyphens of
 different lengths or a compact set of dots.
 
-If you would like to see entities displayed as UTF8 characters, use the
+If you would like to see entities displayed as UTF-8 characters, use the
 following command@footnote{You can turn this on by default by setting the
 variable @code{org-pretty-entities}, or on a per-file base with the
 @code{#+STARTUP} option @code{entitiespretty}.}:
 
 @table @kbd
+@cindex @code{entitiespretty}, STARTUP keyword
 @kindex C-c C-x \
 @item C-c C-x \
 Toggle display of entities as UTF-8 characters.  This does not change the
@@ -9549,31 +10101,23 @@ for display purposes only.
 @cindex subscript
 @cindex superscript
 
-Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super-
-and subscripts.  Again, these can be used without embedding them in
-math-mode delimiters.  To increase the readability of ASCII text, it is
-not necessary (but OK) to surround multi-character sub- and superscripts
-with curly braces.  For example
+Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super- and
+subscripts.  Again, these can be used without embedding them in math-mode
+delimiters.  To increase the readability of ASCII text, it is not necessary
+(but OK) to surround multi-character sub- and superscripts with curly braces.
+For example
 
 @example
 The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
 the sun is R_@{sun@} = 6.96 x 10^8 m.
 @end example
 
-@vindex org-export-with-sub-superscripts
-To avoid interpretation as raised or lowered text, you can quote @samp{^} and
-@samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
-where the underscore is often used in a different context, Org's convention
-to always interpret these as subscripts can get in your way.  Configure the
-variable @code{org-export-with-sub-superscripts} to globally change this
-convention, or use, on a per-file basis:
-
-@example
-#+OPTIONS: ^:@{@}
-@end example
-
-@noindent With this setting, @samp{a_b} will not be interpreted as a
-subscript, but @samp{a_@{b@}} will.
+@vindex org-use-sub-superscripts
+If you write a text where the underscore is often used in a different
+context, Org's convention to always interpret these as subscripts can get in
+your way.  Configure the variable @code{org-use-sub-superscripts} to change
+this convention.  For example, when setting this variable to @code{@{@}},
+@samp{a_b} will not be interpreted as a subscript, but @samp{a_@{b@}} will.
 
 @table @kbd
 @kindex C-c C-x \
@@ -9589,31 +10133,31 @@ format sub- and superscripts in a WYSIWYM way.
 @vindex org-format-latex-header
 Going beyond symbols and sub- and superscripts, a full formula language is
 needed.  Org mode can contain @LaTeX{} math fragments, and it supports ways
-to process these for several export backends.  When exporting to @LaTeX{},
+to process these for several export back-ends.  When exporting to @LaTeX{},
 the code is obviously left as it is.  When exporting to HTML, Org invokes the
 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
 HTML export}) to process and display the math@footnote{If you plan to use
 this regularly or on pages with significant page views, you should install
-@file{MathJax} on your own
-server in order to limit the load of our server.}.  Finally, it can also
-process the mathematical expressions into images@footnote{For this to work
-you need to be on a system with a working @LaTeX{} installation.  You also
-need the @file{dvipng} program or the @file{convert}, respectively available
-at @url{http://sourceforge.net/projects/dvipng/} and from the
-@file{imagemagick} suite.  The @LaTeX{} header that will be used when
-processing a fragment can be configured with the variable
-@code{org-format-latex-header}.} that can be displayed in a browser or in
-DocBook documents.
+@file{MathJax} on your own server in order to limit the load of our server.}.
+Finally, it can also process the mathematical expressions into
+images@footnote{For this to work you need to be on a system with a working
+@LaTeX{} installation.  You also need the @file{dvipng} program or the
+@file{convert}, respectively available at
+@url{http://sourceforge.net/projects/dvipng/} and from the @file{imagemagick}
+suite.  The @LaTeX{} header that will be used when processing a fragment can
+be configured with the variable @code{org-format-latex-header}.} that can be
+displayed in a browser.
 
 @LaTeX{} fragments don't need any special marking at all.  The following
 snippets will be identified as @LaTeX{} source code:
 @itemize @bullet
 @item
 Environments of any kind@footnote{When @file{MathJax} is used, only the
-environment recognized by @file{MathJax} will be processed.  When
-@file{dvipng} is used to create images, any @LaTeX{} environments will be
-handled.}.  The only requirement is that the @code{\begin} statement appears
-on a new line, preceded by only whitespace.
+environments recognized by @file{MathJax} will be processed.  When
+@file{dvipng} program or @file{imagemagick} suite is used to create images,
+any @LaTeX{} environment will be handled.}.  The only requirement is that the
+@code{\begin} and @code{\end} statements appear on a new line, at the
+beginning of the line or after whitespaces only.
 @item
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
@@ -9627,40 +10171,44 @@ For the other delimiters, there is no such restriction, so when in doubt, use
 @noindent For example:
 
 @example
-\begin@{equation@}                          % arbitrary environments,
-x=\sqrt@{b@}                                % even tables, figures
-\end@{equation@}                            % etc
+\begin@{equation@}
+x=\sqrt@{b@}
+\end@{equation@}
 
 If $a^2=b$ and \( b=2 \), then the solution must be
 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
 @end example
 
-@noindent
-@vindex org-format-latex-options
-If you need any of the delimiter ASCII sequences for other purposes, you
-can configure the option @code{org-format-latex-options} to deselect the
-ones you do not wish to have interpreted by the @LaTeX{} converter.
+@c FIXME
+@c @noindent
+@c @vindex org-format-latex-options
+@c If you need any of the delimiter ASCII sequences for other purposes, you
+@c can configure the option @code{org-format-latex-options} to deselect the
+@c ones you do not wish to have interpreted by the @LaTeX{} converter.
 
-@vindex org-export-with-LaTeX-fragments
+@vindex org-export-with-latex
 @LaTeX{} processing can be configured with the variable
-@code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
-which means @file{MathJax} for HTML, and no processing for DocBook, ASCII and
-@LaTeX{} backends.  You can also set this variable on a per-file basis using one
-of these lines:
+@code{org-export-with-latex}.  The default setting is @code{t} which means
+@file{MathJax} for HTML, and no processing for ASCII and @LaTeX{} back-ends.
+You can also set this variable on a per-file basis using one of these
+lines:
 
 @example
-#+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
-#+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
-#+OPTIONS: LaTeX:nil        @r{Do not process @LaTeX{} fragments at all}
-#+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
+#+OPTIONS: tex:t          @r{Do the right thing automatically (MathJax)}
+#+OPTIONS: tex:nil        @r{Do not process @LaTeX{} fragments at all}
+#+OPTIONS: tex:verbatim   @r{Verbatim export, for jsMath or so}
 @end example
 
 @node Previewing @LaTeX{} fragments, CDLaTeX mode, @LaTeX{} fragments, Embedded @LaTeX{}
 @subsection Previewing @LaTeX{} fragments
 @cindex @LaTeX{} fragments, preview
 
-If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
-produce preview images of the typeset expressions:
+@vindex org-latex-create-formula-image-program
+If you have @file{dvipng} or @file{imagemagick} installed@footnote{Choose the
+converter by setting the variable
+@code{org-latex-create-formula-image-program} accordingly.}, @LaTeX{}
+fragments can be processed to produce preview images of the typeset
+expressions:
 
 @table @kbd
 @kindex C-c C-x C-l
@@ -9682,6 +10230,19 @@ some aspects of the preview.  In particular, the @code{:scale} (and for HTML
 export, @code{:html-scale}) property can be used to adjust the size of the
 preview images.
 
+@vindex org-startup-with-latex-preview
+You can turn on the previewing of all @LaTeX{} fragments in a file with
+
+@example
+#+STARTUP: latexpreview
+@end example
+
+To disable it, simply use
+
+@example
+#+STARTUP: nolatexpreview
+@end example
+
 @node CDLaTeX mode,  , Previewing @LaTeX{} fragments, Embedded @LaTeX{}
 @subsection Using CD@LaTeX{} to enter math
 @cindex CD@LaTeX{}
@@ -9694,7 +10255,7 @@ some of the features of CD@LaTeX{} mode.  You need to install
 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
 Don't use CD@LaTeX{} mode itself under Org mode, but use the light
 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
-on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
+on for the current buffer with @kbd{M-x org-cdlatex-mode RET}, or for all
 Org files with
 
 @lisp
@@ -9719,7 +10280,7 @@ the second brace.  Even outside fragments, @key{TAB} will expand
 environment abbreviations at the beginning of a line.  For example, if
 you write @samp{equ} at the beginning of a line and press @key{TAB},
 this abbreviation will be expanded to an @code{equation} environment.
-To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
+To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help RET}.
 @item
 @kindex _
 @kindex ^
@@ -9743,235 +10304,394 @@ modification will work only inside @LaTeX{} fragments; outside the quote
 is normal.
 @end itemize
 
+@node Special blocks,  , Embedded @LaTeX{}, Markup
+@section Special blocks
+@cindex Special blocks
+
+Org syntax includes pre-defined blocks (@pxref{Paragraphs} and @ref{Literal
+examples}).  It is also possible to create blocks containing raw code
+targeted at a specific back-ends (e.g., @samp{#+BEGIN_LATEX}).
+
+Any other block is a @emph{special block}.  Each export back-end decides if
+they should be exported, and how.  When the block is ignored, its contents
+are still exported, as if the block were not there.  For example, when
+exporting a @samp{#+BEGIN_TEST} block, HTML back-end wraps its contents
+within @samp{<div name="test">} tag.  Refer to back-end specific
+documentation for more information.
+
 @node Exporting, Publishing, Markup, Top
 @chapter Exporting
 @cindex exporting
 
-Org mode documents can be exported into a variety of other formats.  For
-printing and sharing of notes, ASCII export produces a readable and simple
-version of an Org file.  HTML export allows you to publish a notes file on
-the web, while the XOXO format provides a solid base for exchange with a
-broad range of other applications.  @LaTeX{} export lets you use Org mode and
-its structured editing functions to easily create @LaTeX{} files.  DocBook
-export makes it possible to convert Org files to many other formats using
-DocBook tools.  OpenDocument Text (ODT) export allows seamless
-collaboration across organizational boundaries.  For project management you
-can create gantt and resource charts by using TaskJuggler export.  To
-incorporate entries with associated times like deadlines or appointments into
-a desktop calendar program like iCal, Org mode can also produce extracts in
-the iCalendar format.  Currently, Org mode only supports export, not import of
-these different formats.
-
-Org supports export of selected regions when @code{transient-mark-mode} is
-enabled (default in Emacs 23).
+The Org mode export facilities can be used to export Org documents or parts
+of Org documents to a variety of other formats.  In addition, these
+facilities can be used with @code{orgtbl-mode} and/or @code{orgstruct-mode}
+in foreign buffers so you can author tables and lists in Org syntax and
+convert them in place to the target language.
+
+ASCII export produces a readable and simple version of an Org file for
+printing and sharing notes.  HTML export allows you to easily publish notes
+on the web, or to build full-fledged websites.  @LaTeX{} export lets you use
+Org mode and its structured editing functions to create arbitrarily complex
+@LaTeX{} files for any kind of document.  OpenDocument Text (ODT) export
+allows seamless collaboration across organizational boundaries.  Markdown
+export lets you seamlessly collaborate with other developers.  Finally, iCal
+export can extract entries with deadlines or appointments to produce a file
+in the iCalendar format.
 
 @menu
-* Selective export::            Using tags to select and exclude trees
-* Export options::              Per-file export settings
-* The export dispatcher::       How to access exporter commands
+* The Export Dispatcher::       The main exporter interface
+* Export back-ends::            Built-in export formats
+* Export settings::             Generic export settings
 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
+* Beamer export::               Exporting as a Beamer presentation
 * HTML export::                 Exporting to HTML
 * @LaTeX{} and PDF export::     Exporting to @LaTeX{}, and processing to PDF
-* DocBook export::              Exporting to DocBook
+* Markdown export::             Exporting to Markdown
 * OpenDocument Text export::    Exporting to OpenDocument Text
-* TaskJuggler export::          Exporting to TaskJuggler
-* Freemind export::             Exporting to Freemind mind maps
-* XOXO export::                 Exporting to XOXO
-* iCalendar export::            Exporting in iCalendar format
+* iCalendar export::            Exporting to iCalendar
+* Other built-in back-ends::    Exporting to @code{Texinfo}, a man page, or Org
+* Export in foreign buffers::   Author tables in lists in Org syntax
+* Advanced configuration::      Fine-tuning the export output
 @end menu
 
-@node Selective export, Export options, Exporting, Exporting
-@section Selective export
-@cindex export, selective by tags or TODO keyword
+@node The Export Dispatcher, Export back-ends, Exporting, Exporting
+@section The Export Dispatcher
+@vindex org-export-dispatch-use-expert-ui
+@cindex Export, dispatcher
+
+The main entry point for export related tasks is the dispatcher, a
+hierarchical menu from which it is possible to select an export format and
+toggle export options@footnote{It is also possible to use a less intrusive
+interface by setting @code{org-export-dispatch-use-expert-ui} to a
+non-@code{nil} value.  In that case, only a prompt is visible from the
+minibuffer.  From there one can still switch back to regular menu by pressing
+@key{?}.} from which it is possible to select an export format and to toggle
+export options.
+
+@c @quotation
+@table @asis
+@orgcmd{C-c C-e,org-export-dispatch}
 
-@vindex org-export-select-tags
-@vindex org-export-exclude-tags
-@cindex org-export-with-tasks
-You may use tags to select the parts of a document that should be exported,
-or to exclude parts from export.  This behavior is governed by two variables:
-@code{org-export-select-tags} and @code{org-export-exclude-tags},
-respectively defaulting to @code{'(:export:)} and @code{'(:noexport:)}.
+Dispatch for export and publishing commands.  When called with a @kbd{C-u}
+prefix argument, repeat the last export command on the current buffer while
+preserving toggled options.  If the current buffer hasn't changed and subtree
+export was activated, the command will affect that same subtree.
+@end table
+@c @end quotation
 
-@enumerate
-@item
-Org first checks if any of the @emph{select} tags is present in the
-buffer.  If yes, all trees that do not carry one of these tags will be
-excluded.  If a selected tree is a subtree, the heading hierarchy above it
-will also be selected for export, but not the text below those headings.
+Normally the entire buffer is exported, but if there is an active region
+only that part of the buffer will be exported.
 
-@item
-If none of the select tags is found, the whole buffer will be selected for
-export.
+Several export options (@pxref{Export settings}) can be toggled from the
+export dispatcher with the following key combinations:
 
-@item
-Finally, all subtrees that are marked by any of the @emph{exclude} tags will
-be removed from the export buffer.
-@end enumerate
+@table @kbd
+@item C-a
+@vindex org-export-async-init-file
+Toggle asynchronous export.  Asynchronous export uses an external Emacs
+process that is configured with a specified initialization file.
 
-The variable @code{org-export-with-tasks} can be configured to select which
-kind of tasks should be included for export.  See the docstring of the
-variable for more information.
+While exporting asynchronously, the output is not displayed.  It is stored in
+a list called ``the export stack'', and can be viewed from there.  The stack
+can be reached by calling the dispatcher with a double @kbd{C-u} prefix
+argument, or with @kbd{&} key from the dispatcher.
 
-@node Export options, The export dispatcher, Selective export, Exporting
-@section Export options
-@cindex options, for export
+@vindex org-export-in-background
+To make this behaviour the default, customize the variable
+@code{org-export-in-background}.
 
-@cindex completion, of option keywords
-The exporter recognizes special lines in the buffer which provide
-additional information.  These lines may be put anywhere in the file.
-The whole set of lines can be inserted into the buffer with @kbd{C-c
-C-e t}.  For individual lines, a good way to make sure the keyword is
-correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
-(@pxref{Completion}).   For a summary of other in-buffer settings not
-specifically related to export, see @ref{In-buffer settings}.
-In particular, note that you can place commonly-used (export) options in
-a separate file which can be included using @code{#+SETUPFILE}.
+@item C-b
+Toggle body-only export.  Its effect depends on the back-end used.
+Typically, if the back-end has a header section (like @code{<head>...</head>}
+in the HTML back-end), a body-only export will not include this header.
+
+@item C-s
+@vindex org-export-initial-scope
+Toggle subtree export.  The top heading becomes the document title.
+
+You can change the default state of this option by setting
+@code{org-export-initial-scope}.
+
+@item C-v
+Toggle visible-only export.  Only export the text that is currently
+visible, i.e. not hidden by outline visibility in the buffer.
 
-@table @kbd
-@orgcmd{C-c C-e t,org-insert-export-options-template}
-Insert template with export options, see example below.
 @end table
 
-@cindex #+TITLE
-@cindex #+AUTHOR
-@cindex #+DATE
-@cindex #+EMAIL
-@cindex #+DESCRIPTION
-@cindex #+KEYWORDS
-@cindex #+LANGUAGE
-@cindex #+TEXT
-@cindex #+OPTIONS
-@cindex #+BIND
-@cindex #+LINK_UP
-@cindex #+LINK_HOME
-@cindex #+EXPORT_SELECT_TAGS
-@cindex #+EXPORT_EXCLUDE_TAGS
-@cindex #+XSLT
-@cindex #+LaTeX_HEADER
+@vindex org-export-copy-to-kill-ring
+With the exception of asynchronous export, a successful export process writes
+its output to the kill-ring. You can configure this behavior by altering the
+option @code{org-export-copy-to-kill-ring}.
+
+@node Export back-ends, Export settings, The Export Dispatcher, Exporting
+@section Export back-ends
+@cindex Export, back-ends
+
+An export back-end is a library that translates Org syntax into a foreign
+format.  An export format is not available until the proper back-end has been
+loaded.
+
+@vindex org-export-backends
+By default, the following four back-ends are loaded: @code{ascii},
+@code{html}, @code{icalendar} and @code{latex}.  It is possible to add more
+(or remove some) by customizing @code{org-export-backends}.
+
+Built-in back-ends include:
+
+@itemize
+@item ascii (ASCII format)
+@item beamer (@LaTeX{} Beamer format)
+@item html (HTML format)
+@item icalendar (iCalendar format)
+@item latex (@LaTeX{} format)
+@item man (Man page format)
+@item md (Markdown format)
+@item odt (OpenDocument Text format)
+@item texinfo (Texinfo format)
+@end itemize
+
+Other back-ends might be found in the @code{contrib/} directory
+(@pxref{Installation}).
+
+@node Export settings, ASCII/Latin-1/UTF-8 export, Export back-ends, Exporting
+@section Export settings
+@cindex Export, settings
+
+Export options can be set: globally with variables; for an individual file by
+making variables buffer-local with in-buffer settings (@pxref{In-buffer
+settings}), by setting individual keywords, or by specifying them in a
+compact form with the @code{#+OPTIONS} keyword; or for a tree by setting
+properties (@pxref{Properties and Columns}).  Options set at a specific level
+override options set at a more general level.
+
+@cindex #+SETUPFILE
+In-buffer settings may appear anywhere in the file, either directly or
+indirectly through a file included using @samp{#+SETUPFILE: filename} syntax.
+Option keyword sets tailored to a particular back-end can be inserted from
+the export dispatcher (@pxref{The Export Dispatcher}) using the @code{Insert
+template} command by pressing @key{#}.  To insert keywords individually,
+a good way to make sure the keyword is correct is to type @code{#+} and then
+to use @kbd{M-<TAB>} for completion.
+
+The export keywords available for every back-end, and their equivalent global
+variables, include:
+
+@table @samp
+@item AUTHOR
 @vindex user-full-name
+The document author (@code{user-full-name}).
+
+@item CREATOR
+@vindex org-export-creator-string
+Entity responsible for output generation (@code{org-export-creator-string}).
+
+@item DATE
+@vindex org-export-date-timestamp-format
+A date or a time-stamp@footnote{The variable
+@code{org-export-date-timestamp-format} defines how this time-stamp will be
+exported.}.
+
+@item DESCRIPTION
+The document description.  Back-ends handle it as they see fit (e.g., for the
+XHTML meta tag), if at all.  You can use several such keywords for long
+descriptions.
+
+@item EMAIL
 @vindex user-mail-address
+The email address (@code{user-mail-address}).
+
+@item KEYWORDS
+The keywords defining the contents of the document.  Back-ends handle it as
+they see fit (e.g., for the XHTML meta tag), if at all.  You can use several
+such keywords if the list is long.
+
+@item LANGUAGE
 @vindex org-export-default-language
-@vindex org-export-date-timestamp-format
-@example
-#+TITLE:       the title to be shown (default is the buffer name)
-#+AUTHOR:      the author (default taken from @code{user-full-name})
-#+DATE:        a date, an Org timestamp@footnote{@code{org-export-date-timestamp-format} defines how this timestamp will be exported.}, or a format string for @code{format-time-string}
-#+EMAIL:       his/her email address (default from @code{user-mail-address})
-#+DESCRIPTION: the page description, e.g., for the XHTML meta tag
-#+KEYWORDS:    the page keywords, e.g., for the XHTML meta tag
-#+LANGUAGE:    language for HTML, e.g., @samp{en} (@code{org-export-default-language})
-#+TEXT:        Some descriptive text to be inserted at the beginning.
-#+TEXT:        Several lines may be given.
-#+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
-#+BIND:        lisp-var lisp-val, e.g., @code{org-export-latex-low-levels itemize}
-               @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
-#+LINK_UP:     the ``up'' link of an exported page
-#+LINK_HOME:   the ``home'' link of an exported page
-#+LaTeX_HEADER: extra line(s) for the @LaTeX{} header, like \usepackage@{xyz@}
-#+EXPORT_SELECT_TAGS:   Tags that select a tree for export
-#+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
-#+XSLT:        the XSLT stylesheet used by DocBook exporter to generate FO file
-@end example
+The language used for translating some strings
+(@code{org-export-default-language}).  E.g., @samp{#+LANGUAGE: fr} will tell
+Org to translate @emph{File} (english) into @emph{Fichier} (french) in the
+clocktable.
 
-@noindent
-The @code{#+OPTIONS} line is a compact@footnote{If you want to configure many options
-this way, you can use several @code{#+OPTIONS} lines.} form to specify export
-settings.  Here you can:
-@cindex headline levels
-@cindex section-numbers
-@cindex table of contents
-@cindex line-break preservation
-@cindex quoted HTML tags
-@cindex fixed-width sections
-@cindex tables
-@cindex @TeX{}-like syntax for sub- and superscripts
-@cindex footnotes
-@cindex special strings
-@cindex emphasized text
-@cindex @TeX{} macros
-@cindex @LaTeX{} fragments
-@cindex author info, in export
-@cindex time info, in export
-@vindex org-export-plist-vars
-@vindex org-export-author-info
-@vindex org-export-creator-info
-@vindex org-export-email-info
+@item SELECT_TAGS
+@vindex org-export-select-tags
+The tags that select a tree for export (@code{org-export-select-tags}).  The
+default value is @code{:export:}.  Within a subtree tagged with
+@code{:export:}, you can still exclude entries with @code{:noexport:} (see
+below).
+
+@item EXCLUDE_TAGS
+The tags that exclude a tree from export (@code{org-export-exclude-tags}).
+The default value is @code{:noexport:}.  Entries with the @code{:noexport:}
+tag will be unconditionally excluded from the export, even if they have an
+@code{:export:} tag.
+
+@item TITLE
+The title to be shown (otherwise derived from buffer's name).  You can use
+several such keywords for long titles.
+@end table
+
+The @code{#+OPTIONS} keyword is a compact@footnote{If you want to configure
+many options this way, you can use several @code{#+OPTIONS} lines.} form that
+recognizes the following arguments:
+
+@table @code
+@item ':
+@vindex org-export-with-smart-quotes
+Toggle smart quotes (@code{org-export-with-smart-quotes}).
+
+@item *:
+Toggle emphasized text (@code{org-export-with-emphasize}).
+
+@item -:
+@vindex org-export-with-special-strings
+Toggle conversion of special strings
+(@code{org-export-with-special-strings}).
+
+@item ::
+@vindex org-export-with-fixed-width
+Toggle fixed-width sections
+(@code{org-export-with-fixed-width}).
+
+@item <:
+@vindex org-export-with-timestamps
+Toggle inclusion of any time/date active/inactive stamps
+(@code{org-export-with-timestamps}).
+
+@item :
+@vindex org-export-preserve-breaks
+Toggle line-break-preservation (@code{org-export-preserve-breaks}).
+
+@item ^:
+@vindex org-export-with-sub-superscripts
+Toggle @TeX{}-like syntax for sub- and superscripts.  If you write "^:@{@}",
+@samp{a_@{b@}} will be interpreted, but the simple @samp{a_b} will be left as
+it is (@code{org-export-with-sub-superscripts}).
+
+@item arch:
+@vindex org-export-with-archived-trees
+Configure export of archived trees.  Can be set to @code{headline} to only
+process the headline, skipping its contents
+(@code{org-export-with-archived-trees}).
+
+@item author:
+@vindex org-export-with-author
+Toggle inclusion of author name into exported file
+(@code{org-export-with-author}).
+
+@item c:
+@vindex org-export-with-clocks
+Toggle inclusion of CLOCK keywords (@code{org-export-with-clocks}).
+
+@item creator:
+@vindex org-export-with-creator
+Configure inclusion of creator info into exported file.  It may be set to
+@code{comment} (@code{org-export-with-creator}).
+
+@item d:
+@vindex org-export-with-drawers
+Toggle inclusion of drawers, or list drawers to include
+(@code{org-export-with-drawers}).
+
+@item e:
+@vindex org-export-with-entities
+Toggle inclusion of entities (@code{org-export-with-entities}).
+
+@item email:
+@vindex org-export-with-email
+Toggle inclusion of the author's e-mail into exported file
+(@code{org-export-with-email}).
+
+@item f:
+@vindex org-export-with-footnotes
+Toggle the inclusion of footnotes (@code{org-export-with-footnotes}).
+
+@item H:
+@vindex org-export-headline-levels
+Set the number of headline levels for export
+(@code{org-export-headline-levels}).  Below that level, headlines are treated
+differently.  In most back-ends, they become list items.
+
+@item inline:
+@vindex org-export-with-inlinetasks
+Toggle inclusion of inlinetasks (@code{org-export-with-inlinetasks}).
+
+@item num:
+@vindex org-export-with-section-numbers
+Toggle section-numbers (@code{org-export-with-section-numbers}).  It can also
+be set to a number @samp{n}, so only headlines at that level or above will be
+numbered.
+
+@item p:
+@vindex org-export-with-planning
+Toggle export of planning information (@code{org-export-with-planning}).
+``Planning information'' is the line containing the @code{SCHEDULED:}, the
+@code{DEADLINE:} or the @code{CLOSED:} cookies or a combination of them.
+
+@item pri:
+@vindex org-export-with-priority
+Toggle inclusion of priority cookies (@code{org-export-with-priority}).
+
+@item stat:
+@vindex org-export-with-statistics-cookies
+Toggle inclusion of statistics cookies
+(@code{org-export-with-statistics-cookies}).
+
+@item tags:
+@vindex org-export-with-tags
+Toggle inclusion of tags, may also be @code{not-in-toc}
+(@code{org-export-with-tags}).
+
+@item tasks:
+@vindex org-export-with-tasks
+Toggle inclusion of tasks (TODO items), can be @code{nil} to remove all
+tasks, @code{todo} to remove DONE tasks, or a list of keywords to keep
+(@code{org-export-with-tasks}).
+
+@item tex:
+@vindex org-export-with-latex
+Configure export of @LaTeX{} fragments and environments.  It may be set to
+@code{verbatim} (@code{org-export-with-latex}).
+
+@item timestamp:
 @vindex org-export-time-stamp-file
-@example
-H:         @r{set the number of headline levels for export}
-num:       @r{turn on/off section-numbers}
-toc:       @r{turn on/off table of contents, or set level limit (integer)}
-\n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
-@@:         @r{turn on/off quoted HTML tags}
-::         @r{turn on/off fixed-width sections}
-|:         @r{turn on/off tables}
-^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
-           @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
-           @r{the simple @code{a_b} will be left as it is.}
--:         @r{turn on/off conversion of special strings.}
-f:         @r{turn on/off footnotes like this[1].}
-todo:      @r{turn on/off inclusion of TODO keywords into exported text}
-tasks:     @r{turn on/off inclusion of tasks (TODO items), can be nil to remove}
-           @r{all tasks, @code{todo} to remove DONE tasks, or list of kwds to keep}
-pri:       @r{turn on/off priority cookies}
-tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
-<:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
-*:         @r{turn on/off emphasized text (bold, italic, underlined)}
-TeX:       @r{turn on/off simple @TeX{} macros in plain text}
-LaTeX:     @r{configure export of @LaTeX{} fragments.  Default @code{auto}}
-skip:      @r{turn on/off skipping the text before the first heading}
-author:    @r{turn on/off inclusion of author name/email into exported file}
-email:     @r{turn on/off inclusion of author email into exported file}
-creator:   @r{turn on/off inclusion of creator info into exported file}
-timestamp: @r{turn on/off inclusion creation time into exported file}
-d:         @r{turn on/off inclusion of drawers, or list drawers to include}
-@end example
-@noindent
-These options take effect in both the HTML and @LaTeX{} export, except for
-@code{TeX} and @code{LaTeX} options, which are respectively @code{t} and
-@code{nil} for the @LaTeX{} export.
-
-The default values for these and many other options are given by a set of
-variables.  For a list of such variables, the corresponding OPTIONS keys and
-also the publishing keys (@pxref{Project alist}), see the constant
-@code{org-export-plist-vars}.
-
-When exporting only a single subtree by selecting it with @kbd{C-c @@} before
-calling an export command, the subtree can overrule some of the file's export
-settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
-@code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
-@code{EXPORT_OPTIONS}.
-
-@node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
-@section The export dispatcher
-@cindex dispatcher, for export commands
-
-All export commands can be reached using the export dispatcher, which is a
-prefix key that prompts for an additional key specifying the command.
-Normally the entire file is exported, but if there is an active region that
-contains one outline tree, the first heading is used as document title and
-the subtrees are exported.
+Toggle inclusion of the creation time into exported file
+(@code{org-export-time-stamp-file}).
 
-@table @kbd
-@orgcmd{C-c C-e,org-export}
-@vindex org-export-run-in-background
-Dispatcher for export and publishing commands.  Displays a help-window
-listing the additional key(s) needed to launch an export or publishing
-command.  The prefix arg is passed through to the exporter.  A double prefix
-@kbd{C-u C-u} causes most commands to be executed in the background, in a
-separate Emacs process@footnote{To make this behavior the default, customize
-the variable @code{org-export-run-in-background}.}.
-@orgcmd{C-c C-e v,org-export-visible}
-Like @kbd{C-c C-e}, but only export the text that is currently visible
-(i.e., not hidden by outline visibility).
-@orgcmd{C-u C-u C-c C-e,org-export}
-@vindex org-export-run-in-background
-Call the exporter, but reverse the setting of
-@code{org-export-run-in-background}, i.e., request background processing if
-not set, or force processing in the current Emacs process if set.
+@item toc:
+@vindex org-export-with-toc
+Toggle inclusion of the table of contents, or set the level limit
+(@code{org-export-with-toc}).
+
+@item todo:
+@vindex org-export-with-todo-keywords
+Toggle inclusion of TODO keywords into exported text
+(@code{org-export-with-todo-keywords}).
+
+@item |:
+@vindex org-export-with-tables
+Toggle inclusion of tables (@code{org-export-with-tables}).
 @end table
 
-@node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
+@cindex property, EXPORT_FILE_NAME
+When exporting only a subtree, each of the previous keywords@footnote{With
+the exception of @samp{SETUPFILE}.} can be overriden locally by special node
+properties.  These begin with @samp{EXPORT_}, followed by the name of the
+keyword they supplant.  For example, @samp{DATE} and @samp{OPTIONS} keywords
+become, respectively, @samp{EXPORT_DATE} and @samp{EXPORT_OPTIONS}
+properties.  Subtree export also supports the self-explicit
+@samp{EXPORT_FILE_NAME} property@footnote{There is no buffer-wide equivalent
+for this property.  The file name in this case is derived from the file
+associated to the buffer, if possible, or asked to the user otherwise.}.
+
+@cindex #+BIND
+@vindex org-export-allow-bind-keywords
+If @code{org-export-allow-bind-keywords} is non-@code{nil}, Emacs variables
+can become buffer-local during export by using the BIND keyword.  Its syntax
+is @samp{#+BIND: variable value}.  This is particularly useful for in-buffer
+settings that cannot be changed using specific keywords.
+
+@node ASCII/Latin-1/UTF-8 export, Beamer export, Export settings, Exporting
 @section ASCII/Latin-1/UTF-8 export
 @cindex ASCII export
 @cindex Latin-1 export
@@ -9981,67 +10701,287 @@ ASCII export produces a simple and very readable version of an Org mode
 file, containing only plain ASCII@.  Latin-1 and UTF-8 export augment the file
 with special characters and symbols available in these encodings.
 
-@cindex region, active
-@cindex active region
-@cindex transient-mark-mode
+@vindex org-ascii-links-to-notes
+Links are exported in a footnote-like style, with the descriptive part in the
+text and the link in a note before the next heading.  See the variable
+@code{org-ascii-links-to-notes} for details and other options.
+
+@subheading ASCII export commands
+
 @table @kbd
-@orgcmd{C-c C-e a,org-export-as-ascii}
-@cindex property, EXPORT_FILE_NAME
+@orgcmd{C-c C-e t a/l/u,org-ascii-export-to-ascii}
 Export as an ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
-will be @file{myfile.txt}.  The file will be overwritten without
-warning.  If there is an active region@footnote{This requires
-@code{transient-mark-mode} be turned on.}, only the region will be
-exported.  If the selected region is a single tree@footnote{To select the
-current subtree, use @kbd{C-c @@}.}, the tree head will
-become the document title.  If the tree head entry has or inherits an
-@code{EXPORT_FILE_NAME} property, that name will be used for the
-export.
-@orgcmd{C-c C-e A,org-export-as-ascii-to-buffer}
+will be @file{myfile.txt}.  The file will be overwritten without warning.
+When the original file is @file{myfile.txt}, the resulting file becomes
+@file{myfile.txt.txt} in order to prevent data loss.
+@orgcmd{C-c C-e t A/L/U,org-ascii-export-as-ascii}
 Export to a temporary buffer.  Do not create a file.
-@orgcmd{C-c C-e n,org-export-as-latin1}
-@xorgcmd{C-c C-e N,org-export-as-latin1-to-buffer}
-Like the above commands, but use Latin-1 encoding.
-@orgcmd{C-c C-e u,org-export-as-utf8}
-@xorgcmd{C-c C-e U,org-export-as-utf8-to-buffer}
-Like the above commands, but use UTF-8 encoding.
-@item C-c C-e v a/n/u
-Export only the visible part of the document.
 @end table
 
-@cindex headline levels, for exporting
-In the exported version, the first 3 outline levels will become
-headlines, defining a general document structure.  Additional levels
-will be exported as itemized lists.  If you want that transition to occur
-at a different level, specify it with a prefix argument.  For example,
+@subheading Header and sectioning structure
+
+In the exported version, the first three outline levels become headlines,
+defining a general document structure.  Additional levels are exported as
+lists.  The transition can also occur at a different level (@pxref{Export
+settings}).
+
+@subheading Quoting ASCII text
+
+You can insert text that will only appear when using @code{ASCII} back-end
+with the following constructs:
+
+@cindex #+ASCII
+@cindex #+BEGIN_ASCII
+@example
+Text @@@@ascii:and additional text@@@@ within a paragraph.
+
+#+ASCII: Some text
+
+#+BEGIN_ASCII
+All lines in this block will appear only when using this back-end.
+#+END_ASCII
+@end example
+
+@subheading ASCII specific attributes
+@cindex #+ATTR_ASCII
+@cindex horizontal rules, in ASCII export
+
+@code{ASCII} back-end only understands one attribute, @code{:width}, which
+specifies the length, in characters, of a given horizontal rule.  It must be
+specified using an @code{ATTR_ASCII} line, directly preceding the rule.
+
+@example
+#+ATTR_ASCII: :width 10
+-----
+@end example
+
+@node Beamer export, HTML export, ASCII/Latin-1/UTF-8 export, Exporting
+@section Beamer export
+@cindex Beamer export
+
+The @LaTeX{} class @emph{Beamer} allows production of high quality
+presentations using @LaTeX{} and pdf processing.  Org mode has special
+support for turning an Org mode file or tree into a Beamer presentation.
+
+@subheading Beamer export commands
+
+@table @kbd
+@orgcmd{C-c C-e l b,org-beamer-export-to-latex}
+Export as a @LaTeX{} file.  For an Org file @file{myfile.org}, the @LaTeX{}
+file will be @file{myfile.tex}.  The file will be overwritten without
+warning.
+@orgcmd{C-c C-e l B,org-beamer-export-as-latex}
+Export to a temporary buffer.  Do not create a file.
+@orgcmd{C-c C-e l P,org-beamer-export-to-pdf}
+Export as @LaTeX{} and then process to PDF.
+@item C-c C-e l O
+Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
+@end table
+
+@subheading Sectioning, Frames and Blocks
+
+Any tree with not-too-deep level nesting should in principle be exportable as
+a Beamer presentation.  Headlines fall into three categories: sectioning
+elements, frames and blocks.
+
+@itemize @minus
+@item
+@vindex org-beamer-frame-level
+Headlines become frames when their level is equal to
+@code{org-beamer-frame-level} or @code{H} value in an @code{OPTIONS} line
+(@pxref{Export settings}).
+
+@cindex property, BEAMER_ENV
+Though, if a headline in the current tree has a @code{BEAMER_ENV} property
+set to either to @code{frame} or @code{fullframe}, its level overrides the
+variable.  A @code{fullframe} is a frame with an empty (ignored) title.
+
+@item
+@vindex org-beamer-environments-default
+@vindex org-beamer-environments-extra
+All frame's children become @code{block} environments.  Special block types
+can be enforced by setting headline's @code{BEAMER_ENV} property@footnote{If
+this property is set, the entry will also get a @code{:B_environment:} tag to
+make this visible.  This tag has no semantic meaning, it is only a visual
+aid.} to an appropriate value (see @code{org-beamer-environments-default} for
+supported values and @code{org-beamer-environments-extra} for adding more).
+
+@item
+@cindex property, BEAMER_REF
+As a special case, if the @code{BEAMER_ENV} property is set to either
+@code{appendix}, @code{note}, @code{noteNH} or @code{againframe}, the
+headline will become, respectively, an appendix, a note (within frame or
+between frame, depending on its level), a note with its title ignored or an
+@code{\againframe} command.  In the latter case, a @code{BEAMER_REF} property
+is mandatory in order to refer to the frame being resumed, and contents are
+ignored.
+
+Also, a headline with an @code{ignoreheading} environment will have its
+contents only inserted in the output.  This special value is useful to have
+data between frames, or to properly close a @code{column} environment.
+@end itemize
+
+@cindex property, BEAMER_ACT
+@cindex property, BEAMER_OPT
+Headlines also support @code{BEAMER_ACT} and @code{BEAMER_OPT} properties.
+The former is translated as an overlay/action specification, or a default
+overlay specification when enclosed within square brackets.  The latter
+specifies options@footnote{The @code{fragile} option is added automatically
+if it contains code that requires a verbatim environment, though.} for the
+current frame or block.  The export back-end will automatically wrap
+properties within angular or square brackets when appropriate.
+
+@cindex property, BEAMER_COL
+Moreover, headlines handle the @code{BEAMER_COL} property.  Its value should
+be a decimal number representing the width of the column as a fraction of the
+total text width.  If the headline has no specific environment, its title
+will be ignored and its contents will fill the column created.  Otherwise,
+the block will fill the whole column and the title will be preserved.  Two
+contiguous headlines with a non-@code{nil} @code{BEAMER_COL} value share the same
+@code{columns} @LaTeX{} environment.  It will end before the next headline
+without such a property.  This environment is generated automatically.
+Although, it can also be explicitly created, with a special @code{columns}
+value for @code{BEAMER_ENV} property (if it needs to be set up with some
+specific options, for example).
+
+@subheading Beamer specific syntax
+
+Beamer back-end is an extension of @LaTeX{} back-end.  As such, all @LaTeX{}
+specific syntax (e.g., @samp{#+LATEX:} or @samp{#+ATTR_LATEX:}) is
+recognized.  See @ref{@LaTeX{} and PDF export} for more information.
+
+@cindex #+BEAMER_THEME
+@cindex #+BEAMER_COLOR_THEME
+@cindex #+BEAMER_FONT_THEME
+@cindex #+BEAMER_INNER_THEME
+@cindex #+BEAMER_OUTER_THEME
+Beamer export introduces a number of keywords to insert code in the
+document's header.  Four control appearance of the presentation:
+@code{#+BEAMER_THEME}, @code{#+BEAMER_COLOR_THEME},
+@code{#+BEAMER_FONT_THEME}, @code{#+BEAMER_INNER_THEME} and
+@code{#+BEAMER_OUTER_THEME}.  All of them accept optional arguments
+within square brackets.  The last one, @code{#+BEAMER_HEADER}, is more
+generic and allows you to append any line of code in the header.
+
+@example
+#+BEAMER_THEME: Rochester [height=20pt]
+#+BEAMER_COLOR_THEME: spruce
+@end example
+
+Table of contents generated from @code{toc:t} @code{OPTION} keyword are
+wrapped within a @code{frame} environment.  Those generated from a @code{TOC}
+keyword (@pxref{Table of contents}) are not.  In that case, it is also
+possible to specify options, enclosed within square brackets.
+
+@example
+#+TOC: headlines [currentsection]
+@end example
+
+Beamer specific code can be inserted with the following constructs:
+
+@cindex #+BEAMER
+@cindex #+BEGIN_BEAMER
+@example
+#+BEAMER: \pause
+
+#+BEGIN_BEAMER
+All lines in this block will appear only when using this back-end.
+#+END_BEAMER
+
+Text @@@@beamer:some code@@@@ within a paragraph.
+@end example
+
+In particular, this last example can be used to add overlay specifications to
+objects whose type is among @code{bold}, @code{item}, @code{link},
+@code{radio-target} and @code{target}, when the value is enclosed within
+angular brackets and put at the beginning the object.
+
+@example
+A *@@@@beamer:<2->@@@@useful* feature
+@end example
+
+@cindex #+ATTR_BEAMER
+Eventually, every plain list has support for @code{:environment},
+@code{:overlay} and @code{:options} attributes through
+@code{ATTR_BEAMER} affiliated keyword.  The first one allows the use
+of a different environment, the second sets overlay specifications and
+the last one inserts optional arguments in current list environment.
+
+@example
+#+ATTR_BEAMER: :overlay +-
+- item 1
+- item 2
+@end example
+
+@subheading Editing support
+
+You can turn on a special minor mode @code{org-beamer-mode} for faster
+editing with:
+
+@example
+#+STARTUP: beamer
+@end example
+
+@table @kbd
+@orgcmd{C-c C-b,org-beamer-select-environment}
+In @code{org-beamer-mode}, this key offers fast selection of a Beamer
+environment or the @code{BEAMER_COL} property.
+@end table
+
+Also, a template for useful in-buffer settings or properties can be inserted
+into the buffer with @kbd{M-x org-beamer-insert-options-template}.  Among
+other things, this will install a column view format which is very handy for
+editing special properties used by Beamer.
+
+@subheading An example
 
-@example
-@kbd{C-1 C-c C-e a}
-@end example
+Here is a simple example Org document that is intended for Beamer export.
 
-@noindent
-creates only top level headlines and exports the rest as items.  When
-headlines are converted to items, the indentation of the text following
-the headline is changed to fit nicely under the item.  This is done with
-the assumption that the first body line indicates the base indentation of
-the body text.  Any indentation larger than this is adjusted to preserve
-the layout relative to the first line.  Should there be lines with less
-indentation than the first one, these are left alone.
-
-@vindex org-export-ascii-links-to-notes
-Links will be exported in a footnote-like style, with the descriptive part in
-the text and the link in a note before the next heading.  See the variable
-@code{org-export-ascii-links-to-notes} for details and other options.
-
-@node HTML export, @LaTeX{} and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
+@smallexample
+#+TITLE: Example Presentation
+#+AUTHOR: Carsten Dominik
+#+OPTIONS: H:2
+#+LATEX_CLASS: beamer
+#+LATEX_CLASS_OPTIONS: [presentation]
+#+BEAMER_THEME: Madrid
+#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col) %8BEAMER_OPT(Opt)
+
+* This is the first structural section
+
+** Frame 1
+*** Thanks to Eric Fraga                                           :B_block:BMCOL:
+    :PROPERTIES:
+    :BEAMER_COL: 0.48
+    :BEAMER_ENV: block
+    :END:
+    for the first viable Beamer setup in Org
+*** Thanks to everyone else                                        :B_block:BMCOL:
+    :PROPERTIES:
+    :BEAMER_COL: 0.48
+    :BEAMER_ACT: <2->
+    :BEAMER_ENV: block
+    :END:
+    for contributing to the discussion
+**** This will be formatted as a beamer note                              :B_note:
+     :PROPERTIES:
+     :BEAMER_env: note
+     :END:
+** Frame 2 (where we will not use columns)
+*** Request
+    Please test this stuff!
+@end smallexample
+
+@node HTML export, @LaTeX{} and PDF export, Beamer export, Exporting
 @section HTML export
 @cindex HTML export
 
-Org mode contains a HTML (XHTML 1.0 strict) exporter with extensive
+Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
 HTML formatting, in ways similar to John Gruber's @emph{markdown}
 language, but with additional support for tables.
 
 @menu
 * HTML Export commands::        How to invoke HTML export
+* HTML doctypes::               Org can export to various (X)HTML flavors
 * HTML preamble and postamble::  How to insert a preamble and a postamble
 * Quoting HTML tags::           Using direct HTML in Org mode
 * Links in HTML export::        How links will be interpreted and formatted
@@ -10053,100 +10993,161 @@ language, but with additional support for tables.
 * JavaScript support::          Info and Folding in a web browser
 @end menu
 
-@node HTML Export commands, HTML preamble and postamble, HTML export, HTML export
+@node HTML Export commands, HTML doctypes, HTML export, HTML export
 @subsection HTML export commands
 
-@cindex region, active
-@cindex active region
-@cindex transient-mark-mode
 @table @kbd
-@orgcmd{C-c C-e h,org-export-as-html}
-@cindex property, EXPORT_FILE_NAME
-Export as a HTML file.  For an Org file @file{myfile.org},
+@orgcmd{C-c C-e h h,org-html-export-to-html}
+Export as an HTML file.  For an Org file @file{myfile.org},
 the HTML file will be @file{myfile.html}.  The file will be overwritten
-without warning.  If there is an active region@footnote{This requires
-@code{transient-mark-mode} be turned on.}, only the region will be
-exported.  If the selected region is a single tree@footnote{To select the
-current subtree, use @kbd{C-c @@}.}, the tree head will become the document
-title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
-property, that name will be used for the export.
-@orgcmd{C-c C-e b,org-export-as-html-and-open}
-Export as a HTML file and immediately open it with a browser.
-@orgcmd{C-c C-e H,org-export-as-html-to-buffer}
+without warning.
+@kbd{C-c C-e h o}
+Export as an HTML file and immediately open it with a browser.
+@orgcmd{C-c C-e h H,org-html-export-as-html}
 Export to a temporary buffer.  Do not create a file.
-@orgcmd{C-c C-e R,org-export-region-as-html}
-Export the active region to a temporary buffer.  With a prefix argument, do
-not produce the file header and footer, but just the plain HTML section for
-the region.  This is good for cut-and-paste operations.
-@item C-c C-e v h/b/H/R
-Export only the visible part of the document.
-@item M-x org-export-region-as-html
-Convert the region to HTML under the assumption that it was in Org mode
-syntax before.  This is a global command that can be invoked in any
-buffer.
-@item M-x org-replace-region-by-HTML
-Replace the active region (assumed to be in Org mode syntax) by HTML
-code.
 @end table
 
-@cindex headline levels, for exporting
-In the exported version, the first 3 outline levels will become headlines,
-defining a general document structure.  Additional levels will be exported as
-itemized lists.  If you want that transition to occur at a different level,
-specify it with a numeric prefix argument.  For example,
+@c FIXME Exporting sublevels
+@c @cindex headline levels, for exporting
+@c In the exported version, the first 3 outline levels will become headlines,
+@c defining a general document structure.  Additional levels will be exported as
+@c itemized lists.  If you want that transition to occur at a different level,
+@c specify it with a numeric prefix argument.  For example,
+
+@c @example
+@c @kbd{C-2 C-c C-e b}
+@c @end example
+
+@c @noindent
+@c creates two levels of headings and does the rest as items.
+
+@node HTML doctypes, HTML preamble and postamble, HTML Export commands, HTML export
+@subsection HTML doctypes
+@vindex org-html-doctype
+@vindex org-html-doctype-alist
+
+Org can export to various (X)HTML flavors.
+
+Setting the variable @code{org-html-doctype} allows you to export to different
+(X)HTML variants.  The exported HTML will be adjusted according to the syntax
+requirements of that variant.  You can either set this variable to a doctype
+string directly, in which case the exporter will try to adjust the syntax
+automatically, or you can use a ready-made doctype.  The ready-made options
+are:
+
+@itemize
+@item
+``html4-strict''
+@item
+``html4-transitional''
+@item
+``html4-frameset''
+@item
+``xhtml-strict''
+@item
+``xhtml-transitional''
+@item
+``xhtml-frameset''
+@item
+``xhtml-11''
+@item
+``html5''
+@item
+``xhtml5''
+@end itemize
+
+See the variable @code{org-html-doctype-alist} for details.  The default is
+``xhtml-strict''.
+
+@subsubheading Fancy HTML5 export
+@vindex org-html-html5-fancy
+@vindex org-html-html5-elements
+
+HTML5 introduces several new element types.  By default, Org will not make
+use of these element types, but you can set @code{org-html-html5-fancy} to
+@code{t} (or set @code{html5-fancy} item in an @code{OPTIONS} line), to
+enable a few new block-level elements.  These are created using arbitrary
+#+BEGIN and #+END blocks. For instance:
 
 @example
-@kbd{C-2 C-c C-e b}
+#+BEGIN_ASIDE
+Lorem ipsum
+#+END_ASIDE
 @end example
 
-@noindent
-creates two levels of headings and does the rest as items.
+Will export to:
+
+@example
+<aside>
+  <p>Lorem ipsum</p>
+</aside>
+@end example
+
+While this:
+
+@example
+#+ATTR_HTML: :controls controls :width 350
+#+BEGIN_VIDEO
+#+HTML: <source src="movie.mp4" type="video/mp4">
+#+HTML: <source src="movie.ogg" type="video/ogg">
+Your browser does not support the video tag.
+#+END_VIDEO
+@end example
+
+Becomes:
+
+@example
+<video controls="controls" width="350">
+  <source src="movie.mp4" type="video/mp4">
+  <source src="movie.ogg" type="video/ogg">
+  <p>Your browser does not support the video tag.</p>
+</video>
+@end example
+
+Special blocks that do not correspond to HTML5 elements (see
+@code{org-html-html5-elements}) will revert to the usual behavior,
+i.e. #+BEGIN_LEDERHOSEN will still export to <div class=''lederhosen''>.
 
+Headlines cannot appear within special blocks.  To wrap a headline and its
+contents in e.g. <section> or <article> tags, set the @code{HTML_CONTAINER}
+property on the headline itself.
 
-@node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export
+@node HTML preamble and postamble, Quoting HTML tags, HTML doctypes, HTML export
 @subsection HTML preamble and postamble
-@vindex org-export-html-preamble
-@vindex org-export-html-postamble
-@vindex org-export-html-preamble-format
-@vindex org-export-html-postamble-format
-@vindex org-export-html-validation-link
-@vindex org-export-author-info
-@vindex org-export-email-info
-@vindex org-export-creator-info
+@vindex org-html-preamble
+@vindex org-html-postamble
+@vindex org-html-preamble-format
+@vindex org-html-postamble-format
+@vindex org-html-validation-link
+@vindex org-export-creator-string
 @vindex org-export-time-stamp-file
 
 The HTML exporter lets you define a preamble and a postamble.
 
-The default value for @code{org-export-html-preamble} is @code{t}, which
-means that the preamble is inserted depending on the relevant format string
-in @code{org-export-html-preamble-format}.
-
-Setting @code{org-export-html-preamble} to a string will override the default
-format string.  Setting it to a function, will insert the output of the
-function, which must be a string; such a function takes no argument but you
-can check against the value of @code{opt-plist}, which contains the list of
-publishing properties for the current file.  Setting to @code{nil} will not
-insert any preamble.
-
-The default value for @code{org-export-html-postamble} is @code{'auto}, which
-means that the HTML exporter will look for the value of
-@code{org-export-author-info}, @code{org-export-email-info},
-@code{org-export-creator-info} and @code{org-export-time-stamp-file},
-@code{org-export-html-validation-link} and build the postamble from these
-values.  Setting @code{org-export-html-postamble} to @code{t} will insert the
-postamble from the relevant format string found in
-@code{org-export-html-postamble-format}.  Setting it to @code{nil} will not
-insert any postamble.
+The default value for @code{org-html-preamble} is @code{t}, which means
+that the preamble is inserted depending on the relevant format string in
+@code{org-html-preamble-format}.
+
+Setting @code{org-html-preamble} to a string will override the default format
+string.  If you set it to a function, it will insert the output of the
+function, which must be a string.  Setting to @code{nil} will not insert any
+preamble.
+
+The default value for @code{org-html-postamble} is @code{'auto}, which means
+that the HTML exporter will look for information about the author, the email,
+the creator and the date, and build the postamble from these values.  Setting
+@code{org-html-postamble} to @code{t} will insert the postamble from the
+relevant format string found in @code{org-html-postamble-format}.  Setting it
+to @code{nil} will not insert any postamble.
 
 @node Quoting HTML tags, Links in HTML export, HTML preamble and postamble, HTML export
 @subsection Quoting HTML tags
 
 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
-@samp{&gt;} in HTML export.  If you want to include simple HTML tags
-which should be interpreted as such, mark them with @samp{@@} as in
-@samp{@@<b>bold text@@</b>}.  Note that this really works only for
-simple tags.  For more extensive HTML that should be copied verbatim to
-the exported file use either
+@samp{&gt;} in HTML export.  If you want to include raw HTML code, which
+should only appear in HTML export, mark it with @samp{@@@@html:} as in
+@samp{@@@@html:<b>@@@@bold text@@@@html:</b>@@@@}.  For more extensive HTML
+that should be copied verbatim to the exported file use either
 
 @cindex #+HTML
 @cindex #+BEGIN_HTML
@@ -10175,7 +11176,7 @@ includes automatic links created by radio targets (@pxref{Radio
 targets}).  Links to external files will still work if the target file is on
 the same @i{relative} path as the published Org file.  Links to other
 @file{.org} files will be translated into HTML links under the assumption
-that a HTML version also exists of the linked file, at the same relative
+that an HTML version also exists of the linked file, at the same relative
 path.  @samp{id:} links can then be used to jump to specific entries across
 files.  For information related to linking files while publishing them to a
 publishing directory see @ref{Publishing links}.
@@ -10187,37 +11188,42 @@ and @code{style} attributes for a link:
 
 @cindex #+ATTR_HTML
 @example
-#+ATTR_HTML: title="The Org mode homepage" style="color:red;"
+#+ATTR_HTML: :title The Org mode homepage :style color:red;
 [[http://orgmode.org]]
 @end example
 
 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
 @subsection Tables
 @cindex tables, in HTML
-@vindex org-export-html-table-tag
+@vindex org-html-table-default-attributes
 
-Org mode tables are exported to HTML using the table tag defined in
-@code{org-export-html-table-tag}.  The default setting makes tables without
-cell borders and frame.  If you would like to change this for individual
-tables, place something like the following before the table:
+Org mode tables are exported to HTML using the table attributes defined in
+@code{org-html-table-default-attributes}.  The default setting makes tables
+without cell borders and frame.  If you would like to change this for
+individual tables, place something like the following before the table:
 
 @cindex #+CAPTION
 @cindex #+ATTR_HTML
 @example
 #+CAPTION: This is a table with lines around and between cells
-#+ATTR_HTML: border="2" rules="all" frame="border"
+#+ATTR_HTML: :border 2 :rules all :frame border
 @end example
 
+@vindex org-html-table-row-tags
+You can also modify the default tags used for each row by setting
+@code{org-html-table-row-tags}.  See the docstring for an example on
+how to use this option.
+
 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
 @subsection Images in HTML export
 
 @cindex images, inline in HTML
 @cindex inlining images in HTML
-@vindex org-export-html-inline-images
+@vindex org-html-inline-images
 HTML export can inline images given as links in the Org file, and
 it can make an image the clickable part of a link.  By
 default@footnote{But see the variable
-@code{org-export-html-inline-images}.}, images are inlined if a link does
+@code{org-html-inline-images}.}, images are inlined if a link does
 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
 @samp{the image} that points to the image.  If the description part
@@ -10238,7 +11244,7 @@ support text viewers and accessibility, and align it to the right.
 @cindex #+ATTR_HTML
 @example
 #+CAPTION: A black cat stalking a spider
-#+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
+#+ATTR_HTML: :alt cat/spider image :title Action! :align right
 [[./img/a.jpg]]
 @end example
 
@@ -10249,36 +11255,43 @@ You could use @code{http} addresses just as well.
 @subsection Math formatting in HTML export
 @cindex MathJax
 @cindex dvipng
+@cindex imagemagick
 
 @LaTeX{} math snippets (@pxref{@LaTeX{} fragments}) can be displayed in two
 different ways on HTML pages.  The default is to use the
 @uref{http://www.mathjax.org, MathJax system} which should work out of the
-box with Org mode installation because @code{http://orgmode.org} serves
+box with Org mode installation because @uref{http://orgmode.org} serves
 @file{MathJax} for Org mode users for small applications and for testing
 purposes.  @b{If you plan to use this regularly or on pages with significant
 page views, you should install@footnote{Installation instructions can be
 found on the MathJax website, see
 @uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
 your own server in order to limit the load of our server.}  To configure
-@file{MathJax}, use the variable @code{org-export-html-mathjax-options} or
+@file{MathJax}, use the variable @code{org-html-mathjax-options} or
 insert something like the following into the buffer:
 
 @example
-#+MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
+#+HTML_MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
 @end example
 
 @noindent See the docstring of the variable
-@code{org-export-html-mathjax-options} for the meaning of the parameters in
+@code{org-html-mathjax-options} for the meaning of the parameters in
 this line.
 
 If you prefer, you can also request that @LaTeX{} fragments are processed
 into small images that will be inserted into the browser page.  Before the
 availability of MathJax, this was the default method for Org files.  This
-method requires that the @file{dvipng} program is available on your system.
-You can still get this processing with
+method requires that the @file{dvipng} program or @file{imagemagick} suite is
+available on your system.  You can still get this processing with
+
+@example
+#+OPTIONS: tex:dvipng
+@end example
+
+or:
 
 @example
-#+OPTIONS: LaTeX:dvipng
+#+OPTIONS: tex:imagemagick
 @end example
 
 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
@@ -10287,15 +11300,16 @@ You can still get this processing with
 @cindex text areas, in HTML
 An alternative way to publish literal code examples in HTML is to use text
 areas, where the example can even be edited before pasting it into an
-application.  It is triggered by a @code{-t} switch at an @code{example} or
-@code{src} block.  Using this switch disables any options for syntax and
-label highlighting, and line numbering, which may be present.  You may also
-use @code{-h} and @code{-w} switches to specify the height and width of the
-text area, which default to the number of lines in the example, and 80,
-respectively.  For example
+application.  It is triggered by @code{:textarea} attribute at an
+@code{example} or @code{src} block.
+
+You may also use @code{:height} and @code{:width} attributes to specify the
+height and width of the text area, which default to the number of lines in
+the example, and 80, respectively.  For example
 
 @example
-#+BEGIN_EXAMPLE -t -w 40
+#+ATTR_HTML: :textarea t :width 40
+#+BEGIN_EXAMPLE
   (defun org-xor (a b)
      "Exclusive or."
      (if a (not b) b))
@@ -10308,15 +11322,15 @@ respectively.  For example
 @cindex CSS, for HTML export
 @cindex HTML export, CSS
 
-@vindex org-export-html-todo-kwd-class-prefix
-@vindex org-export-html-tag-class-prefix
-You can also give style information for the exported file.  The HTML exporter
-assigns the following special CSS classes@footnote{If the classes on TODO
-keywords and tags lead to conflicts, use the variables
-@code{org-export-html-todo-kwd-class-prefix} and
-@code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
-parts of the document---your style specifications may change these, in
-addition to any of the standard classes like for headlines, tables, etc.
+@vindex org-html-todo-kwd-class-prefix
+@vindex org-html-tag-class-prefix
+You can modify the CSS style definitions for the exported file.  The HTML
+exporter assigns the following special CSS classes@footnote{If the classes on
+TODO keywords and tags lead to conflicts, use the variables
+@code{org-html-todo-kwd-class-prefix} and @code{org-html-tag-class-prefix} to
+make them unique.} to appropriate parts of the document---your style
+specifications may change these, in addition to any of the standard classes
+like for headlines, tables, etc.
 @example
 p.author            @r{author information, including email}
 p.date              @r{publishing date}
@@ -10336,6 +11350,9 @@ p.creator           @r{creator info, about org mode version}
 div.outline-N       @r{div for outline level N (headline plus text))}
 div.outline-text-N  @r{extra div for text at outline level N}
 .section-number-N   @r{section number in headlines, different for each level}
+.figure-number      @r{label like "Figure 1:"}
+.table-number       @r{label like "Table 1:"}
+.listing-number     @r{label like "Listing 1:"}
 div.figure          @r{how to format an inlined image}
 pre.src             @r{formatted source code}
 pre.example         @r{normal example}
@@ -10346,24 +11363,26 @@ p.footnote          @r{footnote definition paragraph, containing a footnote}
 .footnum            @r{footnote number in footnote definition (always <sup>)}
 @end example
 
-@vindex org-export-html-style-default
-@vindex org-export-html-style-include-default
-@vindex org-export-html-style
-@vindex org-export-html-extra
-@vindex org-export-html-style-default
+@vindex org-html-style-default
+@vindex org-html-head-include-default-style
+@vindex org-html-head
+@vindex org-html-head-extra
+@cindex #+HTML_INCLUDE_STYLE
 Each exported file contains a compact default style that defines these
 classes in a basic way@footnote{This style is defined in the constant
-@code{org-export-html-style-default}, which you should not modify.  To turn
+@code{org-html-style-default}, which you should not modify.  To turn
 inclusion of these defaults off, customize
-@code{org-export-html-style-include-default}}.  You may overwrite these
-settings, or add to them by using the variables @code{org-export-html-style}
-(for Org-wide settings) and @code{org-export-html-style-extra} (for more
-fine-grained settings, like file-local settings).  To set the latter variable
-individually for each file, you can use
+@code{org-html-head-include-default-style} or set @code{html-style} to
+@code{nil} in an @code{OPTIONS} line.}.  You may overwrite these settings, or
+add to them by using the variables @code{org-html-head} and
+@code{org-html-head-extra}.  You can override the global values of these
+variables for each file by using these keywords:
 
-@cindex #+STYLE
+@cindex #+HTML_HEAD
+@cindex #+HTML_HEAD_EXTRA
 @example
-#+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
+#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />
+#+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
 @end example
 
 @noindent
@@ -10392,15 +11411,12 @@ as well, press @kbd{?} for an overview of the available keys).  The second
 view type is a @emph{folding} view much like Org provides inside Emacs.  The
 script is available at @url{http://orgmode.org/org-info.js} and you can find
 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
-We host the script at our site, but if you use it a lot, you might
-not want to be dependent on @url{http://orgmode.org} and prefer to install a local
+We host the script at our site, but if you use it a lot, you might not want
+to be dependent on @url{http://orgmode.org} and prefer to install a local
 copy on your own web server.
 
-To use the script, you need to make sure that the @file{org-jsinfo.el} module
-gets loaded.  It should be loaded by default, but you can try @kbd{M-x
-customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
-this is indeed the case.  All it then takes to make use of the program is
-adding a single line to the Org file:
+All it then takes to use this program is adding a single line to the Org
+file:
 
 @cindex #+INFOJS_OPT
 @example
@@ -10440,92 +11456,61 @@ buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
          @r{default), only one such button will be present.}
 @end example
 @noindent
-@vindex org-infojs-options
-@vindex org-export-html-use-infojs
+@vindex org-html-infojs-options
+@vindex org-html-use-infojs
 You can choose default values for these options by customizing the variable
-@code{org-infojs-options}.  If you always want to apply the script to your
-pages, configure the variable @code{org-export-html-use-infojs}.
+@code{org-html-infojs-options}.  If you always want to apply the script to your
+pages, configure the variable @code{org-html-use-infojs}.
 
-@node @LaTeX{} and PDF export, DocBook export, HTML export, Exporting
+@node @LaTeX{} and PDF export, Markdown export, HTML export, Exporting
 @section @LaTeX{} and PDF export
 @cindex @LaTeX{} export
 @cindex PDF export
-@cindex Guerry, Bastien
-
-Org mode contains a @LaTeX{} exporter written by Bastien Guerry.  With
-further processing@footnote{The default @LaTeX{} output is designed for
-processing with @code{pdftex} or @LaTeX{}.  It includes packages that are not
-compatible with @code{xetex} and possibly @code{luatex}.  See the variables
-@code{org-export-latex-default-packages-alist} and
-@code{org-export-latex-packages-alist}.}, this backend is also used to
-produce PDF output.  Since the @LaTeX{} output uses @file{hyperref} to
-implement links and cross references, the PDF output file will be fully
-linked.  Beware of the fact that your @code{org} file has to be properly
-structured in order to be correctly exported: respect the hierarchy of
-sections.
+
+@LaTeX{} export can produce an arbitrarily complex LaTeX document of any
+standard or custom document class.  With further processing@footnote{The
+default @LaTeX{} output is designed for processing with @code{pdftex} or
+@LaTeX{}.  It includes packages that are not compatible with @code{xetex} and
+possibly @code{luatex}.  The @LaTeX{} exporter can be configured to support
+alternative TeX engines, see the options
+@code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}.},
+which the @LaTeX{} exporter is able to control, this back-end is able to
+produce PDF output.  Because the @LaTeX{} exporter can be configured to use
+the @code{hyperref} package, the default setup produces fully-linked PDF
+output.
+
+As in @LaTeX{}, blank lines are meaningful for this back-end: a paragraph
+will not be started if two contiguous syntactical elements are not separated
+by an empty line.
+
+This back-end also offers enhanced support for footnotes.  Thus, it handles
+nested footnotes, footnotes in tables and footnotes in a list item's
+description.
 
 @menu
-* @LaTeX{}/PDF export commands::
+* @LaTeX{} export commands::    How to export to LaTeX and PDF
 * Header and sectioning::       Setting up the export file structure
 * Quoting @LaTeX{} code::       Incorporating literal @LaTeX{} code
-* Tables in @LaTeX{} export::   Options for exporting tables to @LaTeX{}
-* Images in @LaTeX{} export::   How to insert figures into @LaTeX{} output
-* Beamer class export::         Turning the file into a presentation
+* @LaTeX{} specific attributes::  Controlling @LaTeX{} output
 @end menu
 
-@node @LaTeX{}/PDF export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
+@node @LaTeX{} export commands, Header and sectioning, @LaTeX{} and PDF export, @LaTeX{} and PDF export
 @subsection @LaTeX{} export commands
 
-@cindex region, active
-@cindex active region
-@cindex transient-mark-mode
 @table @kbd
-@orgcmd{C-c C-e l,org-export-as-latex}
-@cindex property EXPORT_FILE_NAME
-Export as a @LaTeX{} file.  For an Org file
-@file{myfile.org}, the @LaTeX{} file will be @file{myfile.tex}.  The file will
-be overwritten without warning.  If there is an active region@footnote{This
-requires @code{transient-mark-mode} be turned on.}, only the region will be
-exported.  If the selected region is a single tree@footnote{To select the
-current subtree, use @kbd{C-c @@}.}, the tree head will become the document
-title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
-property, that name will be used for the export.
-@orgcmd{C-c C-e L,org-export-as-latex-to-buffer}
+@orgcmd{C-c C-e l l,org-latex-export-to-latex}
+Export as a @LaTeX{} file.  For an Org file @file{myfile.org}, the @LaTeX{}
+file will be @file{myfile.tex}.  The file will be overwritten without
+warning.
+@orgcmd{C-c C-e l L,org-latex-export-as-latex}
 Export to a temporary buffer.  Do not create a file.
-@item C-c C-e v l/L
-Export only the visible part of the document.
-@item M-x org-export-region-as-latex
-Convert the region to @LaTeX{} under the assumption that it was in Org mode
-syntax before.  This is a global command that can be invoked in any
-buffer.
-@item M-x org-replace-region-by-latex
-Replace the active region (assumed to be in Org mode syntax) by @LaTeX{}
-code.
-@orgcmd{C-c C-e p,org-export-as-pdf}
+@orgcmd{C-c C-e l p,org-latex-export-to-pdf}
 Export as @LaTeX{} and then process to PDF.
-@orgcmd{C-c C-e d,org-export-as-pdf-and-open}
+@item C-c C-e l o
 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
 @end table
 
-@cindex headline levels, for exporting
-@vindex org-latex-low-levels
-In the exported version, the first 3 outline levels will become
-headlines, defining a general document structure.  Additional levels
-will be exported as description lists.  The exporter can ignore them or
-convert them to a custom string depending on
-@code{org-latex-low-levels}.
-
-If you want that transition to occur at a different level, specify it
-with a numeric prefix argument.  For example,
-
-@example
-@kbd{C-2 C-c C-e l}
-@end example
-
-@noindent
-creates two levels of headings and does the rest as items.
-
-@node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{}/PDF export commands, @LaTeX{} and PDF export
+@node Header and sectioning, Quoting @LaTeX{} code, @LaTeX{} export commands, @LaTeX{} and PDF export
 @subsection Header and sectioning structure
 @cindex @LaTeX{} class
 @cindex @LaTeX{} sectioning structure
@@ -10533,493 +11518,368 @@ creates two levels of headings and does the rest as items.
 @cindex header, for @LaTeX{} files
 @cindex sectioning structure, for @LaTeX{} export
 
+By default, the first three outline levels become headlines, defining a
+general document structure.  Additional levels are exported as @code{itemize}
+or @code{enumerate} lists.  The transition can also occur at a different
+level (@pxref{Export settings}).
+
 By default, the @LaTeX{} output uses the class @code{article}.
 
-@vindex org-export-latex-default-class
-@vindex org-export-latex-classes
-@vindex org-export-latex-default-packages-alist
-@vindex org-export-latex-packages-alist
-@cindex #+LaTeX_HEADER
-@cindex #+LaTeX_CLASS
-@cindex #+LaTeX_CLASS_OPTIONS
-@cindex property, LaTeX_CLASS
-@cindex property, LaTeX_CLASS_OPTIONS
+@vindex org-latex-default-class
+@vindex org-latex-classes
+@vindex org-latex-default-packages-alist
+@vindex org-latex-packages-alist
 You can change this globally by setting a different value for
-@code{org-export-latex-default-class} or locally by adding an option like
-@code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
-property that applies when exporting a region containing only this (sub)tree.
-The class must be listed in @code{org-export-latex-classes}.  This variable
-defines a header template for each class@footnote{Into which the values of
-@code{org-export-latex-default-packages-alist} and
-@code{org-export-latex-packages-alist} are spliced.}, and allows you to
-define the sectioning structure for each class.  You can also define your own
-classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{:LaTeX_CLASS_OPTIONS:}
-property can specify the options for the @code{\documentclass} macro.  The
-options to documentclass have to be provided, as expected by @LaTeX{}, within
-square brackets.  You can also use @code{#+LaTeX_HEADER: \usepackage@{xyz@}}
-to add lines to the header.  See the docstring of
-@code{org-export-latex-classes} for more information.  An example is shown
-below.
-
-@example
-#+LaTeX_CLASS: article
-#+LaTeX_CLASS_OPTIONS: [a4paper]
-#+LaTeX_HEADER: \usepackage@{xyz@}
+@code{org-latex-default-class} or locally by adding an option like
+@code{#+LATEX_CLASS: myclass} in your file, or with
+a @code{EXPORT_LATEX_CLASS} property that applies when exporting a region
+containing only this (sub)tree.  The class must be listed in
+@code{org-latex-classes}.  This variable defines a header template for each
+class@footnote{Into which the values of
+@code{org-latex-default-packages-alist} and @code{org-latex-packages-alist}
+are spliced.}, and allows you to define the sectioning structure for each
+class.  You can also define your own classes there.
+
+@cindex #+LATEX_CLASS
+@cindex #+LATEX_CLASS_OPTIONS
+@cindex property, EXPORT_LATEX_CLASS
+@cindex property, EXPORT_LATEX_CLASS_OPTIONS
+The @code{LATEX_CLASS_OPTIONS} keyword or @code{EXPORT_LATEX_CLASS_OPTIONS}
+property can specify the options for the @code{\documentclass} macro.  These
+options have to be provided, as expected by @LaTeX{}, within square brackets.
+
+@cindex #+LATEX_HEADER
+@cindex #+LATEX_HEADER_EXTRA
+You can also use the @code{LATEX_HEADER} and
+@code{LATEX_HEADER_EXTRA}@footnote{Unlike @code{LATEX_HEADER}, contents
+from @code{LATEX_HEADER_EXTRA} keywords will not be loaded when previewing
+@LaTeX{} snippets (@pxref{Previewing @LaTeX{} fragments}).} keywords in order
+to add lines to the header.  See the docstring of @code{org-latex-classes} for
+more information.
+
+An example is shown below.
+
+@example
+#+LATEX_CLASS: article
+#+LATEX_CLASS_OPTIONS: [a4paper]
+#+LATEX_HEADER: \usepackage@{xyz@}
 
 * Headline 1
   some text
 @end example
 
-@node Quoting @LaTeX{} code, Tables in @LaTeX{} export, Header and sectioning, @LaTeX{} and PDF export
+@node Quoting @LaTeX{} code, @LaTeX{} specific attributes, Header and sectioning, @LaTeX{} and PDF export
 @subsection Quoting @LaTeX{} code
 
 Embedded @LaTeX{} as described in @ref{Embedded @LaTeX{}}, will be correctly
-inserted into the @LaTeX{} file.  This includes simple macros like
-@samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
-you can add special code that should only be present in @LaTeX{} export with
-the following constructs:
+inserted into the @LaTeX{} file.  Furthermore, you can add special code that
+should only be present in @LaTeX{} export with the following constructs:
 
-@cindex #+LaTeX
-@cindex #+BEGIN_LaTeX
+@cindex #+LATEX
+@cindex #+BEGIN_LATEX
 @example
-#+LaTeX: Literal @LaTeX{} code for export
-@end example
+Code within @@@@latex:some code@@@@ a paragraph.
 
-@noindent or
-@cindex #+BEGIN_LaTeX
+#+LATEX: Literal @LaTeX{} code for export
 
-@example
-#+BEGIN_LaTeX
+#+BEGIN_LATEX
 All lines between these markers are exported literally
-#+END_LaTeX
+#+END_LATEX
 @end example
 
+@node @LaTeX{} specific attributes,  , Quoting @LaTeX{} code, @LaTeX{} and PDF export
+@subsection @LaTeX{} specific attributes
+@cindex #+ATTR_LATEX
 
-@node Tables in @LaTeX{} export, Images in @LaTeX{} export, Quoting @LaTeX{} code, @LaTeX{} and PDF export
-@subsection Tables in @LaTeX{} export
+@LaTeX{} understands attributes specified in an @code{ATTR_LATEX} line.  They
+affect tables, images, plain lists, special blocks and source blocks.
+
+@subsubheading Tables in @LaTeX{} export
 @cindex tables, in @LaTeX{} export
 
-For @LaTeX{} export of a table, you can specify a label, a caption and
-placement options (@pxref{Images and tables}).  You can also use the
-@code{ATTR_LaTeX} line to request a @code{longtable} environment for the
-table, so that it may span several pages, or to change the default table
-environment from @code{table} to @code{table*} or to change the default inner
-tabular environment to @code{tabularx} or @code{tabulary}.  Finally, you can
-set the alignment string, and (with @code{tabularx} or @code{tabulary}) the
-width:
+For @LaTeX{} export of a table, you can specify a label and a caption
+(@pxref{Images and tables}).  You can also use attributes to control table
+layout and contents.  Valid @LaTeX{} attributes include:
+
+@table @code
+@item :mode
+@vindex org-latex-default-table-mode
+Nature of table's contents.  It can be set to @code{table}, @code{math},
+@code{inline-math} or @code{verbatim}.  In particular, when in @code{math} or
+@code{inline-math} mode, every cell is exported as-is, horizontal rules are
+ignored and the table will be wrapped in a math environment.  Also,
+contiguous tables sharing the same math mode will be wrapped within the same
+environment.  Default mode is determined in
+@code{org-latex-default-table-mode}.
+@item :environment
+@vindex org-latex-default-table-environment
+Environment used for the table.  It can be set to any @LaTeX{} table
+environment, like @code{tabularx}@footnote{Requires adding the
+@code{tabularx} package to @code{org-latex-packages-alist}.},
+@code{longtable}, @code{array}, @code{tabu}@footnote{Requires adding the
+@code{tabu} package to @code{org-latex-packages-alist}.},
+@code{bmatrix}@enddots{} It defaults to
+@code{org-latex-default-table-environment} value.
+@item :caption
+@code{#+CAPTION} keyword is the simplest way to set a caption for a table
+(@pxref{Images and tables}).  If you need more advanced commands for that
+task, you can use @code{:caption} attribute instead.  Its value should be raw
+@LaTeX{} code.  It has precedence over @code{#+CAPTION}.
+@item :float
+@itemx :placement
+Float environment for the table.  Possible values are @code{sidewaystable},
+@code{multicolumn}, @code{t} and @code{nil}.  When unspecified, a table with
+a caption will have a @code{table} environment.  Moreover, @code{:placement}
+attribute can specify the positioning of the float.
+@item :align
+@itemx :font
+@itemx :width
+Set, respectively, the alignment string of the table, its font size and its
+width.  They only apply on regular tables.
+@item :spread
+Boolean specific to the @code{tabu} and @code{longtabu} environments, and
+only takes effect when used in conjunction with the @code{:width} attribute.
+When @code{:spread} is non-@code{nil}, the table will be spread or shrunk by the
+value of @code{:width}.
+@item :booktabs
+@itemx :center
+@itemx :rmlines
+@vindex org-latex-tables-booktabs
+@vindex org-latex-tables-centered
+They toggle, respectively, @code{booktabs} usage (assuming the package is
+properly loaded), table centering and removal of every horizontal rule but
+the first one (in a "table.el" table only).  In particular,
+@code{org-latex-tables-booktabs} (respectively @code{org-latex-tables-centered})
+activates the first (respectively second) attribute globally.
+@item :math-prefix
+@itemx :math-suffix
+@itemx :math-arguments
+A string that will be inserted, respectively, before the table within the
+math environment, after the table within the math environment, and between
+the macro name and the contents of the table.  The @code{:math-arguments}
+attribute is used for matrix macros that require more than one argument
+(e.g., @code{qbordermatrix}).
+@end table
+
+Thus, attributes can be used in a wide array of situations, like writing
+a table that will span over multiple pages, or a matrix product:
 
-@cindex #+CAPTION
-@cindex #+LABEL
-@cindex #+ATTR_LaTeX
 @example
-#+CAPTION: A long table
-#+LABEL: tbl:long
-#+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
+#+ATTR_LATEX: :environment longtable :align l|lp@{3cm@}r|l
 | ..... | ..... |
 | ..... | ..... |
+
+#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
+| a | b |
+| c | d |
+#+ATTR_LATEX: :mode math :environment bmatrix
+| 1 | 2 |
+| 3 | 4 |
 @end example
 
-or to specify a multicolumn table with @code{tabulary}
+In the example below, @LaTeX{} command
+@code{\bicaption@{HeadingA@}@{HeadingB@}} will set the caption.
 
-@cindex #+CAPTION
-@cindex #+LABEL
-@cindex #+ATTR_LaTeX
 @example
-#+CAPTION: A wide table with tabulary
-#+LABEL: tbl:wide
-#+ATTR_LaTeX: table* tabulary width=\textwidth
+#+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
 | ..... | ..... |
 | ..... | ..... |
 @end example
 
-@node Images in @LaTeX{} export, Beamer class export, Tables in @LaTeX{} export, @LaTeX{} and PDF export
-@subsection Images in @LaTeX{} export
+
+@subsubheading Images in @LaTeX{} export
 @cindex images, inline in @LaTeX{}
 @cindex inlining images in @LaTeX{}
 
 Images that are linked to without a description part in the link, like
 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
 output file resulting from @LaTeX{} processing.  Org will use an
-@code{\includegraphics} macro to insert the image.  If you have specified a
-caption and/or a label as described in @ref{Images and tables}, the figure
-will be wrapped into a @code{figure} environment and thus become a floating
-element.  You can use an @code{#+ATTR_LaTeX:} line to specify various other
-options.  You can ask org to export an image as a float without specifying
-a label or a caption by using the keyword @code{float} in this line.  Various
-optional arguments to the @code{\includegraphics} macro can also be specified
-in this fashion.  To modify the placement option of the floating environment,
-add something like @samp{placement=[h!]} to the attributes.  It is to be noted
-this option can be used with tables as well@footnote{One can also take
-advantage of this option to pass other, unrelated options into the figure or
-table environment.  For an example see the section ``Exporting org files'' in
-@url{http://orgmode.org/worg/org-hacks.html}}.
-
-If you would like to let text flow around the image, add the word @samp{wrap}
-to the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
-half of the page.  To fine-tune, the @code{placement} field will be the set
-of additional arguments needed by the @code{wrapfigure} environment.  Note
-that if you change the size of the image, you need to use compatible settings
-for @code{\includegraphics} and @code{wrapfigure}.
+@code{\includegraphics} macro to insert the image@footnote{In the case of
+TikZ (@url{http://sourceforge.net/projects/pgf/}) images, it will become an
+@code{\input} macro wrapped within a @code{tikzpicture} environment.}.
+
+You can specify specify image width or height with, respectively,
+@code{:width} and @code{:height} attributes.  It is also possible to add any
+other option with the @code{:options} attribute, as shown in the following
+example:
 
-@cindex #+CAPTION
-@cindex #+LABEL
-@cindex #+ATTR_LaTeX
 @example
-#+CAPTION:    The black-body emission of the disk around HR 4049
-#+LABEL:      fig:SED-HR4049
-#+ATTR_LaTeX: width=5cm,angle=90
+#+ATTR_LATEX: :width 5cm :options angle=90
 [[./img/sed-hr4049.pdf]]
-
-#+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
-[[./img/hst.png]]
 @end example
 
-If you wish to include an image which spans multiple columns in a page, you
-can use the keyword @code{multicolumn} in the @code{#+ATTR_LaTeX} line.  This
-will export the image wrapped in a @code{figure*} environment.
+If you need a specific command for the caption, use @code{:caption}
+attribute.  It will override standard @code{#+CAPTION} value, if any.
 
-If you need references to a label created in this way, write
-@samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
-
-@node Beamer class export,  , Images in @LaTeX{} export, @LaTeX{} and PDF export
-@subsection Beamer class export
-
-The @LaTeX{} class @file{beamer} allows production of high quality presentations
-using @LaTeX{} and pdf processing.  Org mode has special support for turning an
-Org mode file or tree into a @file{beamer} presentation.
-
-When the @LaTeX{} class for the current buffer (as set with @code{#+LaTeX_CLASS:
-beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
-@code{beamer}, a special export mode will turn the file or tree into a beamer
-presentation.  Any tree with not-too-deep level nesting should in principle be
-exportable as a beamer presentation.  By default, the top-level entries (or
-the first level below the selected subtree heading) will be turned into
-frames, and the outline structure below this level will become itemize lists.
-You can also configure the variable @code{org-beamer-frame-level} to a
-different level---then the hierarchy above frames will produce the sectioning
-structure of the presentation.
-
-A template for useful in-buffer settings or properties can be inserted into
-the buffer with @kbd{M-x org-insert-beamer-options-template}.  Among other
-things, this will install a column view format which is very handy for
-editing special properties used by beamer.
-
-You can influence the structure of the presentation using the following
-properties:
+@example
+#+ATTR_LATEX: :caption \bicaption@{HeadingA@}@{HeadingB@}
+[[./img/sed-hr4049.pdf]]
+@end example
 
-@table @code
-@item BEAMER_env
-The environment that should be used to format this entry.  Valid environments
-are defined in the constant @code{org-beamer-environments-default}, and you
-can define more in @code{org-beamer-environments-extra}.  If this property is
-set, the entry will also get a @code{:B_environment:} tag to make this
-visible.  This tag has no semantic meaning, it is only a visual aid.
-@item BEAMER_envargs
-The beamer-special arguments that should be used for the environment, like
-@code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
-property is also set, something like @code{C[t]} can be added here as well to
-set an options argument for the implied @code{columns} environment.
-@code{c[t]} or @code{c<2->} will set an options for the implied @code{column}
+If you have specified a caption as described in @ref{Images and tables}, the
+picture will be wrapped into a @code{figure} environment and thus become
+a floating element.  You can also ask Org to export an image as a float
+without specifying caption by setting the @code{:float} attribute.  You may
+also set it to:
+@itemize @minus
+@item
+@code{t}: if you want to use the standard @samp{figure} environment.  It is
+used by default if you provide a caption to the image.
+@item
+@code{multicolumn}: if you wish to include an image which spans multiple
+columns in a page.  This will export the image wrapped in a @code{figure*}
 environment.
-@item BEAMER_col
-The width of a column that should start with this entry.  If this property is
-set, the entry will also get a @code{:BMCOL:} property to make this visible.
-Also this tag is only a visual aid.  When this is a plain number, it will be
-interpreted as a fraction of @code{\textwidth}.  Otherwise it will be assumed
-that you have specified the units, like @samp{3cm}.  The first such property
-in a frame will start a @code{columns} environment to surround the columns.
-This environment is closed when an entry has a @code{BEAMER_col} property
-with value 0 or 1, or automatically at the end of the frame.
-@item BEAMER_extra
-Additional commands that should be inserted after the environment has been
-opened.  For example, when creating a frame, this can be used to specify
-transitions.
-@end table
-
-Frames will automatically receive a @code{fragile} option if they contain
-source code that uses the verbatim environment.  Special @file{beamer}
-specific code can be inserted using @code{#+BEAMER:} and
-@code{#+BEGIN_BEAMER...#+END_BEAMER} constructs, similar to other export
-backends, but with the difference that @code{#+LaTeX:} stuff will be included
-in the presentation as well.
-
-Outline nodes with @code{BEAMER_env} property value @samp{note} or
-@samp{noteNH} will be formatted as beamer notes, i,e, they will be wrapped
-into @code{\note@{...@}}.  The former will include the heading as part of the
-note text, the latter will ignore the heading of that node.  To simplify note
-generation, it is actually enough to mark the note with a @emph{tag} (either
-@code{:B_note:} or @code{:B_noteNH:}) instead of creating the
-@code{BEAMER_env} property.
-
-You can turn on a special minor mode @code{org-beamer-mode} for editing
-support with
+@item
+@code{wrap}: if you would like to let text flow around the image.  It will
+make the figure occupy the left half of the page.
+@item
+@code{nil}: if you need to avoid any floating environment, even when
+a caption is provided.
+@end itemize
+@noindent
+To modify the placement option of any floating environment, set the
+@code{placement} attribute.
 
 @example
-#+STARTUP: beamer
+#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement @{r@}@{0.4\textwidth@}
+[[./img/hst.png]]
 @end example
 
-@table @kbd
-@orgcmd{C-c C-b,org-beamer-select-environment}
-In @code{org-beamer-mode}, this key offers fast selection of a beamer
-environment or the @code{BEAMER_col} property.
-@end table
-
-Column view provides a great way to set the environment of a node and other
-important parameters.  Make sure you are using a COLUMN format that is geared
-toward this special purpose.  The command @kbd{M-x
-org-insert-beamer-options-template} defines such a format.
-
-Here is a simple example Org document that is intended for beamer export.
-
-@smallexample
-#+LaTeX_CLASS: beamer
-#+TITLE: Example Presentation
-#+AUTHOR: Carsten Dominik
-#+LaTeX_CLASS_OPTIONS: [presentation]
-#+BEAMER_FRAME_LEVEL: 2
-#+BEAMER_HEADER_EXTRA: \usetheme@{Madrid@}\usecolortheme@{default@}
-#+COLUMNS: %35ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Args) %4BEAMER_col(Col) %8BEAMER_extra(Ex)
-
-* This is the first structural section
-
-** Frame 1 \\ with a subtitle
-*** Thanks to Eric Fraga                                      :BMCOL:B_block:
-    :PROPERTIES:
-    :BEAMER_env: block
-    :BEAMER_envargs: C[t]
-    :BEAMER_col: 0.5
-    :END:
-    for the first viable beamer setup in Org
-*** Thanks to everyone else                                   :BMCOL:B_block:
-    :PROPERTIES:
-    :BEAMER_col: 0.5
-    :BEAMER_env: block
-    :BEAMER_envargs: <2->
-    :END:
-    for contributing to the discussion
-**** This will be formatted as a beamer note                  :B_note:
-** Frame 2 \\ where we will not use columns
-*** Request                                                   :B_block:
-    Please test this stuff!
-    :PROPERTIES:
-    :BEAMER_env: block
-    :END:
-@end smallexample
-
-For more information, see the documentation on Worg.
+If the @code{:comment-include} attribute is set to a non-@code{nil} value,
+the @LaTeX{} @code{\includegraphics} macro will be commented out.
 
-@node DocBook export, OpenDocument Text export, @LaTeX{} and PDF export, Exporting
-@section DocBook export
-@cindex DocBook export
-@cindex PDF export
-@cindex Cui, Baoqiu
+@subsubheading Plain lists in @LaTeX{} export
+@cindex plain lists, in @LaTeX{} export
 
-Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
-exported to DocBook format, it can be further processed to produce other
-formats, including PDF, HTML, man pages, etc., using many available DocBook
-tools and stylesheets.
+Plain lists accept two optional attributes: @code{:environment} and
+@code{:options}.  The first one allows the use of a non-standard
+environment (e.g., @samp{inparaenum}).  The second one specifies
+optional arguments for that environment (square brackets may be
+omitted).
 
-Currently DocBook exporter only supports DocBook V5.0.
+@example
+#+ATTR_LATEX: :environment compactitem :options $\circ$
+- you need ``paralist'' package to reproduce this example.
+@end example
 
-@menu
-* DocBook export commands::     How to invoke DocBook export
-* Quoting DocBook code::        Incorporating DocBook code in Org files
-* Recursive sections::          Recursive sections in DocBook
-* Tables in DocBook export::    Tables are exported as HTML tables
-* Images in DocBook export::    How to insert figures into DocBook output
-* Special characters::          How to handle special characters
-@end menu
+@subsubheading Source blocks in @LaTeX{} export
+@cindex source blocks, in @LaTeX{} export
 
-@node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
-@subsection DocBook export commands
+In addition to syntax defined in @ref{Literal examples}, names and captions
+(@pxref{Images and tables}), source blocks also accept a @code{:float}
+attribute.  You may set it to:
+@itemize @minus
+@item
+@code{t}: if you want to make the source block a float.  It is the default
+value when a caption is provided.
+@item
+@code{multicolumn}: if you wish to include a source block which spans multiple
+columns in a page.
+@item
+@code{nil}: if you need to avoid any floating environment, even when a caption
+is provided.  It is useful for source code that may not fit in a single page.
+@end itemize
 
-@cindex region, active
-@cindex active region
-@cindex transient-mark-mode
-@table @kbd
-@orgcmd{C-c C-e D,org-export-as-docbook}
-@cindex property EXPORT_FILE_NAME
-Export as a DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
-file will be @file{myfile.xml}.  The file will be overwritten without
-warning.  If there is an active region@footnote{This requires
-@code{transient-mark-mode} to be turned on}, only the region will be
-exported.  If the selected region is a single tree@footnote{To select the
-current subtree, use @kbd{C-c @@}.}, the tree head will become the document
-title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
-property, that name will be used for the export.
-@orgcmd{C-c C-e V,org-export-as-docbook-pdf-and-open}
-Export as a DocBook file, process to PDF, then open the resulting PDF file.
-
-@vindex org-export-docbook-xslt-proc-command
-@vindex org-export-docbook-xsl-fo-proc-command
-Note that, in order to produce PDF output based on an exported DocBook file,
-you need to have XSLT processor and XSL-FO processor software installed on your
-system.  Check variables @code{org-export-docbook-xslt-proc-command} and
-@code{org-export-docbook-xsl-fo-proc-command}.
-
-@vindex org-export-docbook-xslt-stylesheet
-The stylesheet argument @code{%s} in variable
-@code{org-export-docbook-xslt-proc-command} is replaced by the value of
-variable @code{org-export-docbook-xslt-stylesheet}, which needs to be set by
-the user.  You can also overrule this global setting on a per-file basis by
-adding an in-buffer setting @code{#+XSLT:} to the Org file.
-
-@orgkey{C-c C-e v D}
-Export only the visible part of the document.
-@end table
+@example
+#+ATTR_LATEX: :float nil
+#+BEGIN_SRC emacs-lisp
+Code that may not fit in a single page.
+#+END_SRC
+@end example
 
-@node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
-@subsection Quoting DocBook code
+@subsubheading Special blocks in @LaTeX{} export
+@cindex special blocks, in @LaTeX{} export
 
-You can quote DocBook code in Org files and copy it verbatim into exported
-DocBook file with the following constructs:
+In @LaTeX{} back-end, special blocks become environments of the same name.
+Value of @code{:options} attribute will be appended as-is to that
+environment's opening string.  For example:
 
-@cindex #+DOCBOOK
-@cindex #+BEGIN_DOCBOOK
 @example
-#+DOCBOOK: Literal DocBook code for export
+#+ATTR_LATEX: :options [Proof of important theorem]
+#+BEGIN_PROOF
+...
+Therefore, any even number greater than 2 is the sum of two primes.
+#+END_PROOF
 @end example
 
-@noindent or
-@cindex #+BEGIN_DOCBOOK
+@noindent
+becomes
 
 @example
-#+BEGIN_DOCBOOK
-All lines between these markers are exported by DocBook exporter
-literally.
-#+END_DOCBOOK
+\begin@{proof@}[Proof of important theorem]
+...
+Therefore, any even number greater than 2 is the sum of two primes.
+\end@{proof@}
 @end example
 
-For example, you can use the following lines to include a DocBook warning
-admonition.  As to what this warning says, you should pay attention to the
-document context when quoting DocBook code in Org files.  You may make
-exported DocBook XML files invalid by not quoting DocBook code correctly.
+If you need to insert a specific caption command, use @code{:caption}
+attribute.  It will override standard @code{#+CAPTION} value, if any.  For
+example:
 
 @example
-#+BEGIN_DOCBOOK
-<warning>
-  <para>You should know what you are doing when quoting DocBook XML code
-  in your Org file.  Invalid DocBook XML may be generated by
-  DocBook exporter if you are not careful!</para>
-</warning>
-#+END_DOCBOOK
+#+ATTR_LATEX: :caption \MyCaption@{HeadingA@}
+#+BEGIN_PROOF
+...
+#+END_PROOF
 @end example
 
-@node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
-@subsection Recursive sections
-@cindex DocBook recursive sections
-
-DocBook exporter exports Org files as articles using the @code{article}
-element in DocBook.  Recursive sections, i.e., @code{section} elements, are
-used in exported articles.  Top level headlines in Org files are exported as
-top level sections, and lower level headlines are exported as nested
-sections.  The entire structure of Org files will be exported completely, no
-matter how many nested levels of headlines there are.
-
-Using recursive sections makes it easy to port and reuse exported DocBook
-code in other DocBook document types like @code{book} or @code{set}.
+@subsubheading Horizontal rules
+@cindex horizontal rules, in @LaTeX{} export
 
-@node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
-@subsection Tables in DocBook export
-@cindex tables, in DocBook export
+Width and thickness of a given horizontal rule can be controlled with,
+respectively, @code{:width} and @code{:thickness} attributes:
 
-Tables in Org files are exported as HTML tables, which have been supported since
-DocBook V4.3.
-
-If a table does not have a caption, an informal table is generated using the
-@code{informaltable} element; otherwise, a formal table will be generated
-using the @code{table} element.
-
-@node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
-@subsection Images in DocBook export
-@cindex images, inline in DocBook
-@cindex inlining images in DocBook
-
-Images that are linked to without a description part in the link, like
-@samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
-using @code{mediaobject} elements.  Each @code{mediaobject} element contains
-an @code{imageobject} that wraps an @code{imagedata} element.  If you have
-specified a caption for an image as described in @ref{Images and tables}, a
-@code{caption} element will be added in @code{mediaobject}.  If a label is
-also specified, it will be exported as an @code{xml:id} attribute of the
-@code{mediaobject} element.
-
-@vindex org-export-docbook-default-image-attributes
-Image attributes supported by the @code{imagedata} element, like @code{align}
-or @code{width}, can be specified in two ways: you can either customize
-variable @code{org-export-docbook-default-image-attributes} or use the
-@code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
-@code{org-export-docbook-default-image-attributes} are applied to all inline
-images in the Org file to be exported (unless they are overridden by image
-attributes specified in @code{#+ATTR_DOCBOOK:} lines).
-
-The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
-attributes or override default image attributes for individual images.  If
-the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
-variable @code{org-export-docbook-default-image-attributes}, the former
-takes precedence.  Here is an example about how image attributes can be
-set:
-
-@cindex #+CAPTION
-@cindex #+LABEL
-@cindex #+ATTR_DOCBOOK
 @example
-#+CAPTION:    The logo of Org mode
-#+LABEL:      unicorn-svg
-#+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
-[[./img/org-mode-unicorn.svg]]
+#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt
+-----
 @end example
 
-@vindex org-export-docbook-inline-image-extensions
-By default, DocBook exporter recognizes the following image file types:
-@file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
-customize variable @code{org-export-docbook-inline-image-extensions} to add
-more types to this list as long as DocBook supports them.
+@node Markdown export, OpenDocument Text export, @LaTeX{} and PDF export, Exporting
+@section Markdown export
+@cindex Markdown export
 
-@node Special characters,  , Images in DocBook export, DocBook export
-@subsection Special characters in DocBook export
-@cindex Special characters in DocBook export
+@code{md} export back-end generates Markdown syntax@footnote{Vanilla flavor,
+as defined at @url{http://daringfireball.net/projects/markdown/}.} for an Org
+mode buffer.
 
-@vindex org-export-docbook-doctype
-@vindex org-entities
-Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
-@code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
-characters are rewritten to XML entities, like @code{&alpha;},
-@code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
-@code{org-entities}.  As long as the generated DocBook file includes the
-corresponding entities, these special characters are recognized.
+It is built over HTML back-end: any construct not supported by Markdown
+syntax (e.g., tables) will be controlled and translated by @code{html}
+back-end (@pxref{HTML export}).
 
-You can customize variable @code{org-export-docbook-doctype} to include the
-entities you need.  For example, you can set variable
-@code{org-export-docbook-doctype} to the following value to recognize all
-special characters included in XHTML entities:
+@subheading Markdown export commands
 
-@example
-"<!DOCTYPE article [
-<!ENTITY % xhtml1-symbol PUBLIC
-\"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
-\"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
->
-%xhtml1-symbol;
-]>
-"
-@end example
+@table @kbd
+@orgcmd{C-c C-e m m,org-md-export-to-markdown}
+Export as a text file written in Markdown syntax.  For an Org file,
+@file{myfile.org}, the resulting file will be @file{myfile.md}.  The file
+will be overwritten without warning.
+@orgcmd{C-c C-e m M,org-md-export-as-markdown}
+Export to a temporary buffer.  Do not create a file.
+@item C-c C-e m o
+Export as a text file with Markdown syntax, then open it.
+@end table
+
+@subheading Header and sectioning structure
+
+@vindex org-md-headline-style
+Markdown export can generate both @code{atx} and @code{setext} types for
+headlines, according to @code{org-md-headline-style}.  The former introduces
+a hard limit of two levels, whereas the latter pushes it to six.  Headlines
+below that limit are exported as lists.  You can also set a soft limit before
+that one (@pxref{Export settings}).
 
 @c begin opendocument
 
-@node OpenDocument Text export, TaskJuggler export, DocBook export, Exporting
+@node OpenDocument Text export, iCalendar export, Markdown export, Exporting
 @section OpenDocument Text export
-@cindex K, Jambunathan
 @cindex ODT
 @cindex OpenDocument
 @cindex export, OpenDocument
 @cindex LibreOffice
-@cindex org-odt.el
-@cindex org-modules
 
-Org Mode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
-(ODT) format using the @file{org-odt.el} module.  Documents created
-by this exporter use the @cite{OpenDocument-v1.2
+Org mode@footnote{Versions 7.8 or later} supports export to OpenDocument Text
+(ODT) format.  Documents created by this exporter use the
+@cite{OpenDocument-v1.2
 specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
 Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
 are compatible with LibreOffice 3.4.
@@ -11054,14 +11914,14 @@ output.  Check the availability of this program before proceeding further.
 @cindex active region
 @cindex transient-mark-mode
 @table @kbd
-@orgcmd{C-c C-e o,org-export-as-odt}
+@orgcmd{C-c C-e o o,org-odt-export-to-odt}
 @cindex property EXPORT_FILE_NAME
 
 Export as OpenDocument Text file.
 
-@vindex org-export-odt-preferred-output-format
-If @code{org-export-odt-preferred-output-format} is specified, automatically
-convert the exported file to that format.  @xref{x-export-to-other-formats, ,
+@vindex org-odt-preferred-output-format
+If @code{org-odt-preferred-output-format} is specified, automatically convert
+the exported file to that format.  @xref{x-export-to-other-formats, ,
 Automatically exporting to other formats}.
 
 For an Org file @file{myfile.org}, the ODT file will be
@@ -11073,13 +11933,13 @@ tree head will become the document title.  If the tree head entry has, or
 inherits, an @code{EXPORT_FILE_NAME} property, that name will be used for the
 export.
 
-@orgcmd{C-c C-e O,org-export-as-odt-and-open}
+@kbd{C-c C-e o O}
 Export as an OpenDocument Text file and open the resulting file.
 
-@vindex org-export-odt-preferred-output-format
-If @code{org-export-odt-preferred-output-format} is specified, open the
-converted file instead.  @xref{x-export-to-other-formats, , Automatically
-exporting to other formats}.
+@vindex org-odt-preferred-output-format
+If @code{org-odt-preferred-output-format} is specified, open the converted
+file instead.  @xref{x-export-to-other-formats, , Automatically exporting to
+other formats}.
 @end table
 
 @node Extending ODT export, Applying custom styles, ODT export commands, OpenDocument Text export
@@ -11095,7 +11955,7 @@ one format (say @samp{csv}) to another format (say @samp{ods} or @samp{xls}).
 If you have a working installation of LibreOffice, a document converter is
 pre-configured for you and you can use it right away.  If you would like to
 use @file{unoconv} as your preferred converter, customize the variable
-@code{org-export-odt-convert-process} to point to @code{unoconv}.  You can
+@code{org-odt-convert-process} to point to @code{unoconv}.  You can
 also use your own favorite converter or tweak the default settings of the
 @file{LibreOffice} and @samp{unoconv} converters.  @xref{Configuring a
 document converter}.
@@ -11103,12 +11963,12 @@ document converter}.
 @subsubsection Automatically exporting to other formats
 @anchor{x-export-to-other-formats}
 
-@vindex org-export-odt-preferred-output-format
+@vindex org-odt-preferred-output-format
 Very often, you will find yourself exporting to ODT format, only to
 immediately save the exported document to other formats like @samp{doc},
 @samp{docx}, @samp{rtf}, @samp{pdf} etc.  In such cases, you can specify your
 preferred output format by customizing the variable
-@code{org-export-odt-preferred-output-format}.  This way, the export commands
+@code{org-odt-preferred-output-format}.  This way, the export commands
 (@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to export to a
 format that is of immediate interest to you.
 
@@ -11121,10 +11981,10 @@ ODT format.  LibreOffice converter, mentioned above, is one such
 converter.  Once a converter is configured, you can interact with it using
 the following command.
 
-@vindex org-export-odt-convert
+@vindex org-odt-convert
 @table @kbd
 
-@item M-x org-export-odt-convert
+@item M-x org-odt-convert RET
 Convert an existing document from one format to another.  With a prefix
 argument, also open the newly produced file.
 @end table
@@ -11161,8 +12021,8 @@ OpenDocument Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
 
 @item
 @cindex #+ODT_STYLES_FILE
-@vindex org-export-odt-styles-file
-Customize the variable @code{org-export-odt-styles-file} and point it to the
+@vindex org-odt-styles-file
+Customize the variable @code{org-odt-styles-file} and point it to the
 newly created file.  For additional configuration options
 @pxref{x-overriding-factory-styles,,Overriding factory styles}.
 
@@ -11192,7 +12052,7 @@ the factory settings.
 
 @node Links in ODT export, Tables in ODT export, Applying custom styles, OpenDocument Text export
 @subsection Links in ODT export
-@cindex tables, in DocBook export
+@cindex links, in ODT export
 
 ODT exporter creates native cross-references for internal links.  It creates
 Internet-style links for all other links.
@@ -11206,7 +12066,7 @@ with a cross-reference and sequence number of the labeled entity.
 
 @node Tables in ODT export, Images in ODT export, Links in ODT export, OpenDocument Text export
 @subsection Tables in ODT export
-@cindex tables, in DocBook export
+@cindex tables, in ODT export
 
 Export of native Org mode tables (@pxref{Tables}) and simple @file{table.el}
 tables is supported.  However, export of complex @file{table.el} tables---tables
@@ -11285,17 +12145,17 @@ You can control the size and scale of the embedded images using the
 @code{#+ATTR_ODT} attribute.
 
 @cindex identify, ImageMagick
-@vindex org-export-odt-pixels-per-inch
+@vindex org-odt-pixels-per-inch
 The exporter specifies the desired size of the image in the final document in
 units of centimeters.  In order to scale the embedded images, the exporter
 queries for pixel dimensions of the images using one of a) ImageMagick's
 @file{identify} program or b) Emacs `create-image' and `image-size'
-APIs.@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
+APIs@footnote{Use of @file{ImageMagick} is only desirable.  However, if you
 routinely produce documents that have large images or you export your Org
 files that has images using a Emacs batch script, then the use of
-@file{ImageMagick} is mandatory.} The pixel dimensions are subsequently
+@file{ImageMagick} is mandatory.}. The pixel dimensions are subsequently
 converted in to units of centimeters using
-@code{org-export-odt-pixels-per-inch}.  The default value of this variable is
+@code{org-odt-pixels-per-inch}.  The default value of this variable is
 set to @code{display-pixels-per-inch}.  You can tweak this variable to
 achieve the best results.
 
@@ -11404,27 +12264,34 @@ You can use the following commands to quickly verify the reliability of
 the @LaTeX{}-to-MathML converter.
 
 @table @kbd
-
-@item M-x org-export-as-odf
+@item M-x org-odt-export-as-odf RET
 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file.
 
-@item M-x org-export-as-odf-and-open
+@item M-x org-odt-export-as-odf-and-open RET
 Convert a @LaTeX{} math snippet to an OpenDocument formula (@file{.odf}) file
 and open the formula file with the system-registered application.
 @end table
 
 @cindex dvipng
+@cindex imagemagick
 @item PNG images
 
 This option is activated on a per-file basis with
 
 @example
-#+OPTIONS: LaTeX:dvipng
+#+OPTIONS: tex:dvipng
+@end example
+
+or:
+
+@example
+#+OPTIONS: tex:imagemagick
 @end example
 
 With this option, @LaTeX{} fragments are processed into PNG images and the
 resulting images are embedded in the exported document.  This method requires
-that the @file{dvipng} program be available on your system.
+that the @file{dvipng} program or @file{imagemagick} suite be available on
+your system.
 @end enumerate
 
 @node Working with MathML or OpenDocument formula files,  , Working with @LaTeX{} math snippets, Math formatting in ODT export
@@ -11471,15 +12338,15 @@ It could be rendered as shown below in the exported document.
 Figure 2: Bell curve
 @end example
 
-@vindex org-export-odt-category-strings
+@vindex org-odt-category-map-alist
 You can modify the category component of the caption by customizing the
-variable @code{org-export-odt-category-strings}.  For example, to tag all
-embedded images with the string @samp{Illustration} (instead of the default
-@samp{Figure}) use the following setting.
+option @code{org-odt-category-map-alist}.  For example, to tag all embedded
+images with the string @samp{Illustration} (instead of the default
+@samp{Figure}) use the following setting:
 
 @lisp
-(setq org-export-odt-category-strings
-      '(("en" "Table" "Illustration" "Equation" "Equation")))
+(setq org-odt-category-map-alist
+      (("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))
 @end lisp
 
 With this, previous image will be captioned as below in the exported
@@ -11500,14 +12367,14 @@ fontification to be turned on.}  The auto-generated styles have @samp{OrgSrc}
 as prefix and inherit their color from the faces used by Emacs
 @code{font-lock} library for the source language.
 
-@vindex org-export-odt-fontify-srcblocks
-If you prefer to use your own custom styles for fontification, you can do so
-by customizing the variable
-@code{org-export-odt-create-custom-styles-for-srcblocks}.
+@vindex org-odt-fontify-srcblocks
+If you prefer to use your own custom styles for fontification, you can do
+so by customizing the option
+@code{org-odt-create-custom-styles-for-srcblocks}.
 
-@vindex org-export-odt-create-custom-styles-for-srcblocks
+@vindex org-odt-create-custom-styles-for-srcblocks
 You can turn off fontification of literal examples by customizing the
-variable @code{org-export-odt-fontify-srcblocks}.
+option @code{org-odt-fontify-srcblocks}.
 
 @node Advanced topics in ODT export,  , Literal examples in ODT export, OpenDocument Text export
 @subsection Advanced topics in ODT export
@@ -11538,27 +12405,27 @@ like to tweak the default converter settings, proceed as below.
 @enumerate
 @item Register the converter
 
-@vindex org-export-odt-convert-processes
-Name your converter and add it to the list of known converters by customizing
-the variable @code{org-export-odt-convert-processes}.  Also specify how the
-converter can be invoked via command-line to effect the conversion.
+@vindex org-odt-convert-processes
+Name your converter and add it to the list of known converters by
+customizing the option @code{org-odt-convert-processes}.  Also specify how
+the converter can be invoked via command-line to effect the conversion.
 
 @item Configure its capabilities
 
-@vindex org-export-odt-convert-capabilities
-@anchor{x-odt-converter-capabilities}
-Specify the set of formats the converter can handle by customizing the
-variable @code{org-export-odt-convert-capabilities}.  Use the default value
-for this variable as a guide for configuring your converter.  As suggested by
-the default setting, you can specify the full set of formats supported by the
+@vindex org-odt-convert-capabilities
+@anchor{x-odt-converter-capabilities} Specify the set of formats the
+converter can handle by customizing the variable
+@code{org-odt-convert-capabilities}.  Use the default value for this
+variable as a guide for configuring your converter.  As suggested by the
+default setting, you can specify the full set of formats supported by the
 converter and not limit yourself to specifying formats that are related to
 just the OpenDocument Text format.
 
 @item Choose the converter
 
-@vindex org-export-odt-convert-process
+@vindex org-odt-convert-process
 Select the newly added converter as the preferred one by customizing the
-variable @code{org-export-odt-convert-process}.
+option @code{org-odt-convert-process}.
 @end enumerate
 
 @node Working with OpenDocument style files, Creating one-off styles, Configuring a document converter, Advanced topics in ODT export
@@ -11626,9 +12493,9 @@ customize these variables to override the factory styles used by the
 exporter.
 
 @itemize
-@anchor{x-org-export-odt-styles-file}
+@anchor{x-org-odt-styles-file}
 @item
-@code{org-export-odt-styles-file}
+@code{org-odt-styles-file}
 
 Use this variable to specify the @file{styles.xml} that will be used in the
 final output.  You can specify one of the following values:
@@ -11657,9 +12524,9 @@ like header and footer images.
 Use the default @file{styles.xml}
 @end enumerate
 
-@anchor{x-org-export-odt-content-template-file}
+@anchor{x-org-odt-content-template-file}
 @item
-@code{org-export-odt-content-template-file}
+@code{org-odt-content-template-file}
 
 Use this variable to specify the blank @file{content.xml} that will be used
 in the final output.
@@ -11709,7 +12576,7 @@ custom @samp{PageBreak} style as shown below.
 
 @example
 <style:style style:name="PageBreak" style:family="paragraph"
-            style:parent-style-name="Text_20_body">
+             style:parent-style-name="Text_20_body">
   <style:paragraph-properties fo:break-before="page"/>
 </style:style>
 @end example
@@ -11746,22 +12613,21 @@ OpenDocument-v1.2
 specification.@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
 OpenDocument-v1.2 Specification}}
 
-
-
 @subsubheading Custom table styles: an illustration
 
-To have a quick preview of this feature, install the below setting and export
-the table that follows.
+@vindex org-odt-table-styles
+To have a quick preview of this feature, install the below setting and
+export the table that follows:
 
 @lisp
-(setq org-export-odt-table-styles
-      (append org-export-odt-table-styles
-             '(("TableWithHeaderRowAndColumn" "Custom"
-                ((use-first-row-styles . t)
-                 (use-first-column-styles . t)))
-               ("TableWithFirstRowandLastRow" "Custom"
-                ((use-first-row-styles . t)
-                 (use-last-row-styles . t))))))
+(setq org-odt-table-styles
+      (append org-odt-table-styles
+            '(("TableWithHeaderRowAndColumn" "Custom"
+                ((use-first-row-styles . t)
+                 (use-first-column-styles . t)))
+                ("TableWithFirstRowandLastRow" "Custom"
+                 ((use-first-row-styles . t)
+                 (use-last-row-styles . t))))))
 @end lisp
 
 @example
@@ -11774,9 +12640,9 @@ the table that follows.
 In the above example, you used a template named @samp{Custom} and installed
 two table styles with the names @samp{TableWithHeaderRowAndColumn} and
 @samp{TableWithFirstRowandLastRow}.  (@strong{Important:} The OpenDocument
-styles needed for producing the above template have been pre-defined for you.
-These styles are available under the section marked @samp{Custom Table
-Template} in @file{OrgOdtContentTemplate.xml}
+styles needed for producing the above template have been pre-defined for
+you.  These styles are available under the section marked @samp{Custom
+Table Template} in @file{OrgOdtContentTemplate.xml}
 (@pxref{x-orgodtcontenttemplate-xml,,Factory styles}).  If you need
 additional templates you have to define these styles yourselves.
 
@@ -11860,9 +12726,9 @@ Define a table style@footnote{See the attributes @code{table:template-name},
 @code{table:use-banding-column-styles} of the @code{<table:table>} element in
 the OpenDocument-v1.2 specification}
 
-@vindex org-export-odt-table-styles
+@vindex org-odt-table-styles
 To define a table style, create an entry for the style in the variable
-@code{org-export-odt-table-styles} and specify the following:
+@code{org-odt-table-styles} and specify the following:
 
 @itemize @minus
 @item the name of the table template created in step (1)
@@ -11875,211 +12741,53 @@ based on the same template @samp{Custom}.  The styles achieve their intended
 effect by selectively activating the individual cell styles in that template.
 
 @lisp
-(setq org-export-odt-table-styles
-      (append org-export-odt-table-styles
-             '(("TableWithHeaderRowAndColumn" "Custom"
-                ((use-first-row-styles . t)
-                 (use-first-column-styles . t)))
-               ("TableWithFirstRowandLastRow" "Custom"
-                ((use-first-row-styles . t)
-                 (use-last-row-styles . t))))))
+(setq org-odt-table-styles
+      (append org-odt-table-styles
+              '(("TableWithHeaderRowAndColumn" "Custom"
+                 ((use-first-row-styles . t)
+                  (use-first-column-styles . t)))
+                ("TableWithFirstRowandLastRow" "Custom"
+                 ((use-first-row-styles . t)
+                  (use-last-row-styles . t))))))
 @end lisp
 
-@item
-Associate a table with the table style
-
-To do this, specify the table style created in step (2) as part of
-the @code{ATTR_ODT} line as shown below.
-
-@example
-#+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
-| Name  | Phone | Age |
-| Peter |  1234 |  17 |
-| Anna  |  4321 |  25 |
-@end example
-@end enumerate
-
-@node Validating OpenDocument XML,  , Customizing tables in ODT export, Advanced topics in ODT export
-@subsubsection Validating OpenDocument XML
-
-Occasionally, you will discover that the document created by the
-ODT exporter cannot be opened by your favorite application.  One of
-the common reasons for this is that the @file{.odt} file is corrupt.  In such
-cases, you may want to validate the document against the OpenDocument RELAX
-NG Compact Syntax (RNC) schema.
-
-For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
-nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
-general help with validation (and schema-sensitive editing) of XML files:
-@inforef{Introduction,,nxml-mode}.
-
-@vindex org-export-odt-schema-dir
-If you have ready access to OpenDocument @file{.rnc} files and the needed
-schema-locating rules in a single folder, you can customize the variable
-@code{org-export-odt-schema-dir} to point to that directory.  The
-ODT exporter will take care of updating the
-@code{rng-schema-locating-files} for you.
-
-@c end opendocument
-
-@node  TaskJuggler export, Freemind export, OpenDocument Text export, Exporting
-@section TaskJuggler export
-@cindex TaskJuggler export
-@cindex Project management
-
-@uref{http://www.taskjuggler.org/, TaskJuggler} is a project management tool.
-It provides an optimizing scheduler that computes your project time lines and
-resource assignments based on the project outline and the constraints that
-you have provided.
-
-The TaskJuggler exporter is a bit different from other exporters, such as the
-@code{HTML} and @LaTeX{} exporters for example, in that it does not export all the
-nodes of a document or strictly follow the order of the nodes in the
-document.
-
-Instead the TaskJuggler exporter looks for a tree that defines the tasks and
-a optionally tree that defines the resources for this project.  It then
-creates a TaskJuggler file based on these trees and the attributes defined in
-all the nodes.
-
-@subsection TaskJuggler export commands
-
-@table @kbd
-@orgcmd{C-c C-e j,org-export-as-taskjuggler}
-Export as a TaskJuggler file.
-
-@orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
-Export as a TaskJuggler file and then open the file with TaskJugglerUI.
-@end table
-
-@subsection Tasks
-
-@vindex org-export-taskjuggler-project-tag
-Create your tasks as you usually do with Org mode.  Assign efforts to each
-task using properties (it is easiest to do this in the column view).  You
-should end up with something similar to the example by Peter Jones in
-@url{http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org}.
-Now mark the top node of your tasks with a tag named
-@code{:taskjuggler_project:} (or whatever you customized
-@code{org-export-taskjuggler-project-tag} to).  You are now ready to export
-the project plan with @kbd{C-c C-e J} which will export the project plan and
-open a gantt chart in TaskJugglerUI.
-
-@subsection Resources
-
-@vindex org-export-taskjuggler-resource-tag
-Next you can define resources and assign those to work on specific tasks.  You
-can group your resources hierarchically.  Tag the top node of the resources
-with @code{:taskjuggler_resource:} (or whatever you customized
-@code{org-export-taskjuggler-resource-tag} to).  You can optionally assign an
-identifier (named @samp{resource_id}) to the resources (using the standard
-Org properties commands, @pxref{Property syntax}) or you can let the exporter
-generate identifiers automatically (the exporter picks the first word of the
-headline as the identifier as long as it is unique---see the documentation of
-@code{org-taskjuggler-get-unique-id}).  Using that identifier you can then
-allocate resources to tasks.  This is again done with the @samp{allocate}
-property on the tasks.  Do this in column view or when on the task type
-@kbd{C-c C-x p allocate @key{RET} <resource_id> @key{RET}}.
-
-Once the allocations are done you can again export to TaskJuggler and check
-in the Resource Allocation Graph which person is working on what task at what
-time.
-
-@subsection Export of properties
-
-The exporter also takes TODO state information into consideration, i.e., if a
-task is marked as done it will have the corresponding attribute in
-TaskJuggler (@samp{complete 100}).  Also it will export any property on a task
-resource or resource node which is known to TaskJuggler, such as
-@samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
-@samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
-@samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
-@samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
-@samp{scheduling}, etc.@: for tasks.
-
-@subsection Dependencies
-
-The exporter will handle dependencies that are defined in the tasks either
-with the @samp{ORDERED} attribute (@pxref{TODO dependencies}), with the
-@samp{BLOCKER} attribute (see @file{org-depend.el}) or alternatively with a
-@samp{depends} attribute.  Both the @samp{BLOCKER} and the @samp{depends}
-attribute can be either @samp{previous-sibling} or a reference to an
-identifier (named @samp{task_id}) which is defined for another task in the
-project.  @samp{BLOCKER} and the @samp{depends} attribute can define multiple
-dependencies separated by either space or comma.  You can also specify
-optional attributes on the dependency by simply appending it.  The following
-examples should illustrate this:
-
-@example
-* Preparation
-  :PROPERTIES:
-  :task_id:  preparation
-  :ORDERED:  t
-  :END:
-* Training material
-  :PROPERTIES:
-  :task_id:  training_material
-  :ORDERED:  t
-  :END:
-** Markup Guidelines
-   :PROPERTIES:
-   :Effort:   2d
-   :END:
-** Workflow Guidelines
-   :PROPERTIES:
-   :Effort:   2d
-   :END:
-* Presentation
-  :PROPERTIES:
-  :Effort:   2d
-  :BLOCKER:  training_material @{ gapduration 1d @} preparation
-  :END:
-@end example
-
-@subsection Reports
-
-@vindex org-export-taskjuggler-default-reports
-TaskJuggler can produce many kinds of reports (e.g., gantt chart, resource
-allocation, etc).  The user defines what kind of reports should be generated
-for a project in the TaskJuggler file.  The exporter will automatically insert
-some default reports in the file.  These defaults are defined in
-@code{org-export-taskjuggler-default-reports}.  They can be modified using
-customize along with a number of other options.  For a more complete list, see
-@kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
+@item
+Associate a table with the table style
 
-For more information and examples see the Org-taskjuggler tutorial at
-@uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.html}.
+To do this, specify the table style created in step (2) as part of
+the @code{ATTR_ODT} line as shown below.
 
-@node Freemind export, XOXO export, TaskJuggler export, Exporting
-@section Freemind export
-@cindex Freemind export
-@cindex mind map
+@example
+#+ATTR_ODT: :style "TableWithHeaderRowAndColumn"
+| Name  | Phone | Age |
+| Peter |  1234 |  17 |
+| Anna  |  4321 |  25 |
+@end example
+@end enumerate
 
-The Freemind exporter was written by Lennart Borgman.
+@node Validating OpenDocument XML,  , Customizing tables in ODT export, Advanced topics in ODT export
+@subsubsection Validating OpenDocument XML
 
-@table @kbd
-@orgcmd{C-c C-e m,org-export-as-freemind}
-Export as a Freemind mind map.  For an Org file @file{myfile.org}, the Freemind
-file will be @file{myfile.mm}.
-@end table
+Occasionally, you will discover that the document created by the
+ODT exporter cannot be opened by your favorite application.  One of
+the common reasons for this is that the @file{.odt} file is corrupt.  In such
+cases, you may want to validate the document against the OpenDocument RELAX
+NG Compact Syntax (RNC) schema.
 
-@node XOXO export, iCalendar export, Freemind export, Exporting
-@section XOXO export
-@cindex XOXO export
+For de-compressing the @file{.odt} file@footnote{@file{.odt} files are
+nothing but @samp{zip} archives}: @inforef{File Archives,,emacs}.  For
+general help with validation (and schema-sensitive editing) of XML files:
+@inforef{Introduction,,nxml-mode}.
 
-Org mode contains an exporter that produces XOXO-style output.
-Currently, this exporter only handles the general outline structure and
-does not interpret any additional Org mode features.
+@vindex org-odt-schema-dir
+If you have ready access to OpenDocument @file{.rnc} files and the needed
+schema-locating rules in a single folder, you can customize the variable
+@code{org-odt-schema-dir} to point to that directory.  The ODT exporter
+will take care of updating the @code{rng-schema-locating-files} for you.
 
-@table @kbd
-@orgcmd{C-c C-e x,org-export-as-xoxo}
-Export as an XOXO file.  For an Org file @file{myfile.org}, the XOXO file will be
-@file{myfile.html}.
-@orgkey{C-c C-e v x}
-Export only the visible part of the document.
-@end table
+@c end opendocument
 
-@node iCalendar export,  , XOXO export, Exporting
+@node iCalendar export, Other built-in back-ends, OpenDocument Text export, Exporting
 @section iCalendar export
 @cindex iCalendar export
 
@@ -12118,19 +12826,19 @@ In this way the UID remains unique, but a synchronization program can still
 figure out from which entry all the different instances originate.
 
 @table @kbd
-@orgcmd{C-c C-e i,org-export-icalendar-this-file}
-Create iCalendar entries for the current file and store them in the same
+@orgcmd{C-c C-e c f,org-icalendar-export-to-ics}
+Create iCalendar entries for the current buffer and store them in the same
 directory, using a file extension @file{.ics}.
-@orgcmd{C-c C-e I, org-export-icalendar-all-agenda-files}
+@orgcmd{C-c C-e c a, org-icalendar-export-agenda-files}
 @vindex org-agenda-files
-Like @kbd{C-c C-e i}, but do this for all files in
+Like @kbd{C-c C-e c f}, but do this for all files in
 @code{org-agenda-files}.  For each of these files, a separate iCalendar
 file will be written.
-@orgcmd{C-c C-e c,org-export-icalendar-combine-agenda-files}
-@vindex org-combined-agenda-icalendar-file
+@orgcmd{C-c C-e c c,org-icalendar-combine-agenda-files}
+@vindex org-icalendar-combined-agenda-file
 Create a single large iCalendar file from all files in
 @code{org-agenda-files} and write it to the file given by
-@code{org-combined-agenda-icalendar-file}.
+@code{org-icalendar-combined-agenda-file}.
 @end table
 
 @vindex org-use-property-inheritance
@@ -12148,6 +12856,233 @@ and the description from the body (limited to
 How this calendar is best read and updated, depends on the application
 you are using.  The FAQ covers this issue.
 
+@node Other built-in back-ends, Export in foreign buffers, iCalendar export, Exporting
+@section Other built-in back-ends
+@cindex export back-ends, built-in
+@vindex org-export-backends
+
+On top of the aforementioned back-ends, Org comes with other built-in ones:
+
+@itemize
+@item @file{ox-man.el}: export to a man page.
+@item @file{ox-texinfo.el}: export to @code{Texinfo} format.
+@item @file{ox-org.el}: export to an Org document.
+@end itemize
+
+To activate these export back-end, customize @code{org-export-backends} or
+load them directly with e.g., @code{(require 'ox-texinfo)}.  This will add
+new keys in the export dispatcher (@pxref{The Export Dispatcher}).
+
+See the comment section of these files for more information on how to use
+them.
+
+@node Export in foreign buffers, Advanced configuration, Other built-in back-ends, Exporting
+@section Export in foreign buffers
+
+Most built-in back-ends come with a command to convert the selected region
+into a selected format and replace this region by the exported output.  Here
+is a list of such conversion commands:
+
+@table @code
+@item org-html-convert-region-to-html
+Convert the selected region into HTML.
+@item org-latex-convert-region-to-latex
+Convert the selected region into @LaTeX{}.
+@item org-texinfo-convert-region-to-texinfo
+Convert the selected region into @code{Texinfo}.
+@item org-md-convert-region-to-md
+Convert the selected region into @code{MarkDown}.
+@end table
+
+This is particularly useful for converting tables and lists in foreign
+buffers.  E.g., in an HTML buffer, you can turn on @code{orgstruct-mode}, then
+use Org commands for editing a list, and finally select and convert the list
+with @code{M-x org-html-convert-region-to-html RET}.
+
+@node Advanced configuration,  , Export in foreign buffers, Exporting
+@section Advanced configuration
+
+@subheading Hooks
+
+@vindex org-export-before-processing-hook
+@vindex org-export-before-parsing-hook
+Two hooks are run during the first steps of the export process.  The first
+one, @code{org-export-before-processing-hook} is called before expanding
+macros, Babel code and include keywords in the buffer.  The second one,
+@code{org-export-before-parsing-hook}, as its name suggests, happens just
+before parsing the buffer.  Their main use is for heavy duties, that is
+duties involving structural modifications of the document.  For example, one
+may want to remove every headline in the buffer during export.  The following
+code can achieve this:
+
+@lisp
+@group
+(defun my-headline-removal (backend)
+  "Remove all headlines in the current buffer.
+BACKEND is the export back-end being used, as a symbol."
+  (org-map-entries
+   (lambda () (delete-region (point) (progn (forward-line) (point))))))
+
+(add-hook 'org-export-before-parsing-hook 'my-headline-removal)
+@end group
+@end lisp
+
+Note that functions used in these hooks require a mandatory argument,
+a symbol representing the back-end used.
+
+@subheading Filters
+
+@cindex Filters, exporting
+Filters are lists of functions applied on a specific part of the output from
+a given back-end.  More explicitly, each time a back-end transforms an Org
+object or element into another language, all functions within a given filter
+type are called in turn on the string produced.  The string returned by the
+last function will be the one used in the final output.
+
+There are filters sets for each type of element or object, for plain text,
+for the parse tree, for the export options and for the final output.  They
+are all named after the same scheme: @code{org-export-filter-TYPE-functions},
+where @code{TYPE} is the type targeted by the filter.  Valid types are:
+
+@multitable @columnfractions .33 .33 .33
+@item bold
+@tab babel-call
+@tab center-block
+@item clock
+@tab code
+@tab comment
+@item comment-block
+@tab diary-sexp
+@tab drawer
+@item dynamic-block
+@tab entity
+@tab example-block
+@item export-block
+@tab export-snippet
+@tab final-output
+@item fixed-width
+@tab footnote-definition
+@tab footnote-reference
+@item headline
+@tab horizontal-rule
+@tab inline-babel-call
+@item inline-src-block
+@tab inlinetask
+@tab italic
+@item item
+@tab keyword
+@tab latex-environment
+@item latex-fragment
+@tab line-break
+@tab link
+@item node-property
+@tab options
+@tab paragraph
+@item parse-tree
+@tab plain-list
+@tab plain-text
+@item planning
+@tab property-drawer
+@tab quote-block
+@item quote-section
+@tab radio-target
+@tab section
+@item special-block
+@tab src-block
+@tab statistics-cookie
+@item strike-through
+@tab subscript
+@tab superscript
+@item table
+@tab table-cell
+@tab table-row
+@item target
+@tab timestamp
+@tab underline
+@item verbatim
+@tab verse-block
+@tab
+@end multitable
+
+For example, the following snippet allows me to use non-breaking spaces in
+the Org buffer and get them translated into @LaTeX{} without using the
+@code{\nbsp} macro (where @code{_} stands for the non-breaking space):
+
+@lisp
+@group
+(defun my-latex-filter-nobreaks (text backend info)
+  "Ensure \" \" are properly handled in LaTeX export."
+  (when (org-export-derived-backend-p backend 'latex)
+        (replace-regexp-in-string " " "~" text)))
+
+(add-to-list 'org-export-filter-plain-text-functions
+             'my-latex-filter-nobreaks)
+@end group
+@end lisp
+
+Three arguments must be provided to a filter: the code being changed, the
+back-end used, and some information about the export process.  You can safely
+ignore the third argument for most purposes.  Note the use of
+@code{org-export-derived-backend-p}, which ensures that the filter will only
+be applied when using @code{latex} back-end or any other back-end derived
+from it (e.g., @code{beamer}).
+
+@subheading Extending an existing back-end
+
+This is obviously the most powerful customization, since the changes happen
+at the parser level.  Indeed, some export back-ends are built as extensions
+of other ones (e.g. Markdown back-end an extension of HTML back-end).
+
+Extending a back-end means that if an element type is not transcoded by the
+new back-end, it will be handled by the original one.  Hence you can extend
+specific parts of a back-end without too much work.
+
+As an example, imagine we want the @code{ascii} back-end to display the
+language used in a source block, when it is available, but only when some
+attribute is non-@code{nil}, like the following:
+
+@example
+#+ATTR_ASCII: :language t
+@end example
+
+Because that back-end is lacking in that area, we are going to create a new
+back-end, @code{my-ascii} that will do the job.
+
+@lisp
+@group
+(defun my-ascii-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (if (not (org-export-read-attribute :attr_ascii src-block :language))
+    (org-export-with-backend 'ascii src-block contents info)
+  (concat
+   (format ",--[ %s ]--\n%s`----"
+           (org-element-property :language src-block)
+           (replace-regexp-in-string
+            "^" "| "
+            (org-element-normalize-string
+             (org-export-format-code-default src-block info)))))))
+
+(org-export-define-derived-backend 'my-ascii 'ascii
+  :translate-alist '((src-block . my-ascii-src-block)))
+@end group
+@end lisp
+
+The @code{my-ascii-src-block} function looks at the attribute above the
+element.  If it isn’t true, it gives hand to the @code{ascii} back-end.
+Otherwise, it creates a box around the code, leaving room for the language.
+A new back-end is then created.  It only changes its behaviour when
+translating @code{src-block} type element.  Now, all it takes to use the new
+back-end is calling the following from an Org buffer:
+
+@smalllisp
+(org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")
+@end smalllisp
+
+It is obviously possible to write an interactive function for this, install
+it in the export dispatcher menu, and so on.
+
 @node Publishing, Working With Source Code, Exporting, Top
 @chapter Publishing
 @cindex publishing
@@ -12227,7 +13162,7 @@ and where to put published files.
 @tab Directory containing publishing source files
 @item @code{:publishing-directory}
 @tab Directory where output files will be published.  You can directly
-publish to a webserver using a file name syntax appropriate for
+publish to a web server using a file name syntax appropriate for
 the Emacs @file{tramp} package.  Or you can publish to a local directory and
 use external tools to upload your website (@pxref{Uploading files}).
 @item @code{:preparation-function}
@@ -12266,7 +13201,7 @@ extension.
 and @code{:exclude}.
 
 @item @code{:recursive}
-@tab Non-nil means, check base-directory recursively for files to publish.
+@tab non-@code{nil} means, check base-directory recursively for files to publish.
 @end multitable
 
 @node Publishing action, Publishing options, Selecting files, Configuration
@@ -12276,201 +13211,164 @@ and @code{:exclude}.
 Publishing means that a file is copied to the destination directory and
 possibly transformed in the process.  The default transformation is to export
 Org files as HTML files, and this is done by the function
-@code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
+@code{org-html-publish-to-html}, which calls the HTML exporter (@pxref{HTML
 export}).  But you also can publish your content as PDF files using
-@code{org-publish-org-to-pdf}, or as @code{ascii}, @code{latin1} or
-@code{utf8} encoded files using the corresponding functions.  If you want to
-publish the Org file itself, but with @i{archived}, @i{commented}, and
-@i{tag-excluded} trees removed, use @code{org-publish-org-to-org} and set the
-parameters @code{:plain-source} and/or @code{:htmlized-source}.  This will
-produce @file{file.org} and @file{file.org.html} in the publishing
-directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
-source and publishing directories are equal.  Note that with this kind of
-setup, you need to add @code{:exclude "-source\\.org"} to the project
-definition in @code{org-publish-project-alist} to prevent the published
-source files from being considered as new org files the next time the project
-is published.}.  Other files like images only need to be copied to the
-publishing destination; for this you may use @code{org-publish-attachment}.
-For non-Org files, you always need to specify the publishing function:
+@code{org-latex-publish-to-pdf} or as @code{ascii}, @code{Texinfo}, etc.,
+using the corresponding functions.
+
+If you want to publish the Org file as an @code{.org} file but with the
+@i{archived}, @i{commented} and @i{tag-excluded} trees removed, use the
+function @code{org-org-publish-to-org}.  This will produce @file{file.org}
+and put it in the publishing directory.  If you want a htmlized version of
+this file, set the parameter @code{:htmlized-source} to @code{t}, it will
+produce @file{file.org.html} in the publishing directory@footnote{If the
+publishing directory is the same than the source directory, @file{file.org}
+will be exported as @file{file.org.org}, so probably don't want to do this.}.
+
+Other files like images only need to be copied to the publishing destination.
+For this you can use @code{org-publish-attachment}.  For non-org files, you
+always need to specify the publishing function:
 
 @multitable @columnfractions 0.3 0.7
 @item @code{:publishing-function}
 @tab Function executing the publication of a file.  This may also be a
 list of functions, which will all be called in turn.
-@item @code{:plain-source}
-@tab Non-nil means, publish plain source.
 @item @code{:htmlized-source}
-@tab Non-nil means, publish htmlized source.
+@tab non-@code{nil} means, publish htmlized source.
 @end multitable
 
 The function must accept three arguments: a property list containing at least
-a @code{:publishing-directory} property, the name of the file to be
-published, and the path to the publishing directory of the output file.  It
-should take the specified file, make the necessary transformation (if any)
-and place the result into the destination folder.
+a @code{:publishing-directory} property, the name of the file to be published
+and the path to the publishing directory of the output file.  It should take
+the specified file, make the necessary transformation (if any) and place the
+result into the destination folder.
 
 @node Publishing options, Publishing links, Publishing action, Configuration
-@subsection Options for the HTML/@LaTeX{} exporters
+@subsection Options for the exporters
 @cindex options, for publishing
 
-The property list can be used to set many export options for the HTML
-and @LaTeX{} exporters.  In most cases, these properties correspond to user
-variables in Org.  The table below lists these properties along
-with the variable they belong to.  See the documentation string for the
-respective variable for details.
+The property list can be used to set many export options for the exporters.
+In most cases, these properties correspond to user variables in Org.  The
+first table below lists these properties along with the variable they belong
+to.  The second table list HTML specific properties.  See the documentation
+string of these options for details.
 
-@vindex org-export-html-link-up
-@vindex org-export-html-link-home
-@vindex org-export-default-language
 @vindex org-display-custom-times
+@vindex org-export-default-language
+@vindex org-export-exclude-tags
 @vindex org-export-headline-levels
-@vindex org-export-with-section-numbers
-@vindex org-export-section-number-format
-@vindex org-export-with-toc
 @vindex org-export-preserve-breaks
+@vindex org-export-publishing-directory
+@vindex org-export-select-tags
 @vindex org-export-with-archived-trees
+@vindex org-export-with-author
+@vindex org-export-with-creator
+@vindex org-export-with-drawers
+@vindex org-export-with-email
 @vindex org-export-with-emphasize
-@vindex org-export-with-sub-superscripts
-@vindex org-export-with-special-strings
+@vindex org-export-with-fixed-width
 @vindex org-export-with-footnotes
-@vindex org-export-with-drawers
+@vindex org-export-with-latex
+@vindex org-export-with-planning
+@vindex org-export-with-priority
+@vindex org-export-with-section-numbers
+@vindex org-export-with-special-strings
+@vindex org-export-with-sub-superscripts
+@vindex org-export-with-tables
 @vindex org-export-with-tags
-@vindex org-export-with-todo-keywords
 @vindex org-export-with-tasks
-@vindex org-export-with-done-tasks
-@vindex org-export-with-priority
-@vindex org-export-with-TeX-macros
-@vindex org-export-with-LaTeX-fragments
-@vindex org-export-skip-text-before-1st-heading
-@vindex org-export-with-fixed-width
 @vindex org-export-with-timestamps
-@vindex org-export-author-info
-@vindex org-export-email-info
-@vindex org-export-creator-info
-@vindex org-export-time-stamp-file
-@vindex org-export-with-tables
-@vindex org-export-highlight-first-table-line
-@vindex org-export-html-style-include-default
-@vindex org-export-html-style-include-scripts
-@vindex org-export-html-style
-@vindex org-export-html-style-extra
-@vindex org-export-html-link-org-files-as-html
-@vindex org-export-html-inline-images
-@vindex org-export-html-extension
-@vindex org-export-html-table-tag
-@vindex org-export-html-expand
-@vindex org-export-html-with-timestamp
-@vindex org-export-publishing-directory
-@vindex org-export-html-preamble
-@vindex org-export-html-postamble
-@vindex user-full-name
+@vindex org-export-with-toc
+@vindex org-export-with-todo-keywords
 @vindex user-mail-address
-@vindex org-export-select-tags
-@vindex org-export-exclude-tags
 
 @multitable @columnfractions 0.32 0.68
-@item @code{:link-up}               @tab @code{org-export-html-link-up}
-@item @code{:link-home}             @tab @code{org-export-html-link-home}
-@item @code{:language}              @tab @code{org-export-default-language}
-@item @code{:customtime}            @tab @code{org-display-custom-times}
+@item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
+@item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
-@item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
-@item @code{:section-number-format} @tab @code{org-export-section-number-format}
-@item @code{:table-of-contents}     @tab @code{org-export-with-toc}
+@item @code{:language}              @tab @code{org-export-default-language}
 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
-@item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
-@item @code{:emphasize}             @tab @code{org-export-with-emphasize}
-@item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
-@item @code{:special-strings}       @tab @code{org-export-with-special-strings}
-@item @code{:footnotes}             @tab @code{org-export-with-footnotes}
-@item @code{:drawers}               @tab @code{org-export-with-drawers}
-@item @code{:tags}                  @tab @code{org-export-with-tags}
-@item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
-@item @code{:tasks}                 @tab @code{org-export-with-tasks}
-@item @code{:priority}              @tab @code{org-export-with-priority}
-@item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
-@item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
-@item @code{:latex-listings}        @tab @code{org-export-latex-listings}
-@item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
-@item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
-@item @code{:timestamps}            @tab @code{org-export-with-timestamps}
-@item @code{:author}                @tab @code{user-full-name}
-@item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
-@item @code{:author-info}           @tab @code{org-export-author-info}
-@item @code{:email-info}            @tab @code{org-export-email-info}
-@item @code{:creator-info}          @tab @code{org-export-creator-info}
-@item @code{:tables}                @tab @code{org-export-with-tables}
-@item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
-@item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
-@item @code{:style-include-scripts} @tab @code{org-export-html-style-include-scripts}
-@item @code{:style}                 @tab @code{org-export-html-style}
-@item @code{:style-extra}           @tab @code{org-export-html-style-extra}
-@item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
-@item @code{:inline-images}         @tab @code{org-export-html-inline-images}
-@item @code{:html-extension}        @tab @code{org-export-html-extension}
-@item @code{:html-preamble}         @tab @code{org-export-html-preamble}
-@item @code{:html-postamble}        @tab @code{org-export-html-postamble}
-@item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
-@item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
-@item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
-@item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
+@item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
 @item @code{:select-tags}           @tab @code{org-export-select-tags}
-@item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
-@item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
+@item @code{:with-author}           @tab @code{org-export-with-author}
+@item @code{:with-creator}          @tab @code{org-export-with-creator}
+@item @code{:with-drawers}          @tab @code{org-export-with-drawers}
+@item @code{:with-email}            @tab @code{org-export-with-email}
+@item @code{:with-emphasize}        @tab @code{org-export-with-emphasize}
+@item @code{:with-fixed-width}      @tab @code{org-export-with-fixed-width}
+@item @code{:with-footnotes}        @tab @code{org-export-with-footnotes}
+@item @code{:with-latex}            @tab @code{org-export-with-latex}
+@item @code{:with-planning}         @tab @code{org-export-with-planning}
+@item @code{:with-priority}         @tab @code{org-export-with-priority}
+@item @code{:with-special-strings}  @tab @code{org-export-with-special-strings}
+@item @code{:with-sub-superscript}  @tab @code{org-export-with-sub-superscripts}
+@item @code{:with-tables}           @tab @code{org-export-with-tables}
+@item @code{:with-tags}             @tab @code{org-export-with-tags}
+@item @code{:with-tasks}            @tab @code{org-export-with-tasks}
+@item @code{:with-timestamps}       @tab @code{org-export-with-timestamps}
+@item @code{:with-toc}              @tab @code{org-export-with-toc}
+@item @code{:with-todo-keywords}    @tab @code{org-export-with-todo-keywords}
 @end multitable
 
-Most of the @code{org-export-with-*} variables have the same effect in
-both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
-@code{:LaTeX-fragments} options, respectively @code{nil} and @code{t} in the
-@LaTeX{} export.  See @code{org-export-plist-vars} to check this list of
-options.
-
+@vindex org-html-doctype
+@vindex org-html-xml-declaration
+@vindex org-html-link-up
+@vindex org-html-link-home
+@vindex org-html-link-org-files-as-html
+@vindex org-html-head
+@vindex org-html-head-extra
+@vindex org-html-inline-images
+@vindex org-html-extension
+@vindex org-html-preamble
+@vindex org-html-postamble
+@vindex org-html-table-default-attributes
+@vindex org-html-head-include-default-style
+@vindex org-html-head-include-scripts
+@multitable @columnfractions 0.32 0.68
+@item @code{:html-doctype}          @tab @code{org-html-doctype}
+@item @code{:html-xml-declaration}  @tab @code{org-html-xml-declaration}
+@item @code{:html-link-up}          @tab @code{org-html-link-up}
+@item @code{:html-link-home}        @tab @code{org-html-link-home}
+@item @code{:html-link-org-as-html} @tab @code{org-html-link-org-files-as-html}
+@item @code{:html-head}             @tab @code{org-html-head}
+@item @code{:html-head-extra}       @tab @code{org-html-head-extra}
+@item @code{:html-inline-images}    @tab @code{org-html-inline-images}
+@item @code{:html-extension}        @tab @code{org-html-extension}
+@item @code{:html-preamble}         @tab @code{org-html-preamble}
+@item @code{:html-postamble}        @tab @code{org-html-postamble}
+@item @code{:html-table-attributes}        @tab @code{org-html-table-default-attributes}
+@item @code{:html-head-include-default-style} @tab @code{org-html-head-include-default-style}
+@item @code{:html-head-include-scripts} @tab @code{org-html-head-include-scripts}
+@end multitable
 
+Most of the @code{org-export-with-*} variables have the same effect in each
+exporter.
 
 @vindex org-publish-project-alist
-When a property is given a value in @code{org-publish-project-alist},
-its setting overrides the value of the corresponding user variable (if
-any) during publishing.  Options set within a file (@pxref{Export
-options}), however, override everything.
+When a property is given a value in @code{org-publish-project-alist}, its
+setting overrides the value of the corresponding user variable (if any)
+during publishing.  Options set within a file (@pxref{Export settings}),
+however, override everything.
 
 @node Publishing links, Sitemap, Publishing options, Configuration
 @subsection Links between published files
 @cindex links, publishing
 
-To create a link from one Org file to another, you would use
-something like @samp{[[file:foo.org][The foo]]} or simply
-@samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
-becomes a link to @file{foo.html}.  In this way, you can interlink the
-pages of your "org web" project and the links will work as expected when
-you publish them to HTML@.  If you also publish the Org source file and want
-to link to that, use an @code{http:} link instead of a @code{file:} link,
-because @code{file:} links are converted to link to the corresponding
-@file{html} file.
+To create a link from one Org file to another, you would use something like
+@samp{[[file:foo.org][The foo]]} or simply @samp{file:foo.org.}
+(@pxref{Hyperlinks}).  When published, this link becomes a link to
+@file{foo.html}.  You can thus interlink the pages of your "org web" project
+and the links will work as expected when you publish them to HTML@.  If you
+also publish the Org source file and want to link to it, use an @code{http:}
+link instead of a @code{file:} link, because @code{file:} links are converted
+to link to the corresponding @file{html} file.
 
 You may also link to related files, such as images.  Provided you are careful
 with relative file names, and provided you have also configured Org to upload
 the related files, these links will work too.  See @ref{Complex example}, for
 an example of this usage.
 
-Sometimes an Org file to be published may contain links that are
-only valid in your production environment, but not in the publishing
-location.  In this case, use the property
-
-@multitable @columnfractions 0.4 0.6
-@item @code{:link-validation-function}
-@tab Function to validate links
-@end multitable
-
-@noindent
-to define a function for checking link validity.  This function must
-accept two arguments, the file name and a directory relative to which
-the file name is interpreted in the production environment.  If this
-function returns @code{nil}, then the HTML generator will only insert a
-description into the HTML file, but no link.  One option for this
-function is @code{org-publish-validate-link} which checks if the given
-file is part of any project in @code{org-publish-project-alist}.
-
 @node Sitemap, Generating an index, Publishing links, Configuration
 @subsection Generating a sitemap
 @cindex sitemap, of published pages
@@ -12480,7 +13378,7 @@ a map of files for a given project.
 
 @multitable @columnfractions 0.35 0.65
 @item @code{:auto-sitemap}
-@tab When non-nil, publish a sitemap during @code{org-publish-current-project}
+@tab When non-@code{nil}, publish a sitemap during @code{org-publish-current-project}
 or @code{org-publish-all}.
 
 @item @code{:sitemap-filename}
@@ -12525,7 +13423,7 @@ a sitemap entry's date is to be formatted.  This property bypasses
 @code{org-publish-sitemap-date-format} which defaults to @code{%Y-%m-%d}.
 
 @item @code{:sitemap-sans-extension}
-@tab When non-nil, remove filenames' extensions from the generated sitemap.
+@tab When non-@code{nil}, remove filenames' extensions from the generated sitemap.
 Useful to have cool URIs (see @uref{http://www.w3.org/Provider/Style/URI}).
 Defaults to @code{nil}.
 
@@ -12539,7 +13437,7 @@ Org mode can generate an index across the files of a publishing project.
 
 @multitable @columnfractions 0.25 0.75
 @item @code{:makeindex}
-@tab When non-nil, generate in index in the file @file{theindex.org} and
+@tab When non-@code{nil}, generate in index in the file @file{theindex.org} and
 publish it as @file{theindex.html}.
 @end multitable
 
@@ -12605,10 +13503,10 @@ directory on the local machine.
          :base-directory "~/org/"
          :publishing-directory "~/public_html"
          :section-numbers nil
-         :table-of-contents nil
-         :style "<link rel=\"stylesheet\"
-                href=\"../other/mystyle.css\"
-                type=\"text/css\"/>")))
+         :with-toc nil
+         :html-head "<link rel=\"stylesheet\"
+                    href=\"../other/mystyle.css\"
+                    type=\"text/css\"/>")))
 @end lisp
 
 @node Complex example,  , Simple example, Sample configuration
@@ -12638,12 +13536,12 @@ right place on the web server, and publishing images to it.
           :base-directory "~/org/"
           :base-extension "org"
           :publishing-directory "/ssh:user@@host:~/html/notebook/"
-          :publishing-function org-publish-org-to-html
+          :publishing-function org-html-publish-to-html
           :exclude "PrivatePage.org"   ;; regexp
           :headline-levels 3
           :section-numbers nil
-          :table-of-contents nil
-          :style "<link rel=\"stylesheet\"
+          :with-toc nil
+          :html-head "<link rel=\"stylesheet\"
                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
           :html-preamble t)
 
@@ -12667,13 +13565,13 @@ right place on the web server, and publishing images to it.
 Once properly configured, Org can publish with the following commands:
 
 @table @kbd
-@orgcmd{C-c C-e X,org-publish}
+@orgcmd{C-c C-e P x,org-publish}
 Prompt for a specific project and publish all files that belong to it.
-@orgcmd{C-c C-e P,org-publish-current-project}
+@orgcmd{C-c C-e P p,org-publish-current-project}
 Publish the project containing the current file.
-@orgcmd{C-c C-e F,org-publish-current-file}
+@orgcmd{C-c C-e P f,org-publish-current-file}
 Publish only the current file.
-@orgcmd{C-c C-e E,org-publish-all}
+@orgcmd{C-c C-e P a,org-publish-all}
 Publish every project.
 @end table
 
@@ -12770,7 +13668,7 @@ src_<language>[<header arguments>]@{<body>@}
 @table @code
 @item <#+NAME: name>
 This line associates a name with the code block.  This is similar to the
-@code{#+TBLNAME: NAME} lines that can be used to name tables in Org mode
+@code{#+NAME: Name} lines that can be used to name tables in Org mode
 files.  Referencing the name of a code block makes it possible to evaluate
 the block from other places in the file, from other files, or from Org mode
 table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
@@ -12802,11 +13700,16 @@ Source code in the specified language.
 @cindex code block, editing
 @cindex source code, editing
 
+@vindex org-edit-src-auto-save-idle-delay
+@vindex org-edit-src-turn-on-auto-save
 @kindex C-c '
-Use @kbd{C-c '} to edit the current code block.  This brings up
-a language major-mode edit buffer containing the body of the code
-block.  Saving this buffer will write the new contents back to the Org
-buffer.  Use @kbd{C-c '} again to exit.
+Use @kbd{C-c '} to edit the current code block.  This brings up a language
+major-mode edit buffer containing the body of the code block.  Manually
+saving this buffer with @key{C-x C-s} will write the contents back to the Org
+buffer.  You can also set @code{org-edit-src-auto-save-idle-delay} to save the
+base buffer after some idle delay, or @code{org-edit-src-turn-on-auto-save}
+to auto-save this buffer into a separate file using @code{auto-save-mode}.
+Use @kbd{C-c '} again to exit.
 
 The @code{org-src-mode} minor mode will be active in the edit buffer.  The
 following variables can be used to configure the behavior of the edit
@@ -12826,7 +13729,7 @@ This variable is especially useful for tangling languages such as
 Python, in which whitespace indentation in the output is critical.
 @item org-src-ask-before-returning-to-edit-buffer
 By default, Org will ask before returning to an open edit buffer.  Set this
-variable to nil to switch without asking.
+variable to @code{nil} to switch without asking.
 @end table
 
 To turn on native code fontification in the @emph{Org} buffer, configure the
@@ -12851,6 +13754,7 @@ The @code{:exports} header argument can be used to specify export
 behavior:
 
 @subsubheading Header arguments:
+
 @table @code
 @item :exports code
 The default in most languages.  The body of the code block is exported, as
@@ -12872,7 +13776,12 @@ Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
 ensure that no code blocks are evaluated as part of the export process.  This
 can be useful in situations where potentially untrusted Org mode files are
 exported in an automated fashion, for example when Org mode is used as the
-markup language for a wiki.
+markup language for a wiki.  It is also possible to set this variable to
+@code{‘inline-only}.  In that case, only inline code blocks will be
+evaluated, in order to insert their results.  Non-inline code blocks are
+assumed to have their results already inserted in the buffer by manual
+evaluation.  This setting is useful to avoid expensive recalculations during
+export, not to provide security.
 
 @comment  node-name,  next,  previous,  up
 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
@@ -12889,6 +13798,7 @@ using @code{org-babel-expand-src-block} which can expand both variable and
 ``noweb'' style references  (see @ref{Noweb reference syntax}).
 
 @subsubheading Header arguments
+
 @table @code
 @item :tangle no
 The default.  The code block is not included in the tangled output.
@@ -12902,14 +13812,18 @@ Include the code block in the tangled output to file @samp{filename}.
 
 @kindex  C-c C-v t
 @subsubheading Functions
+
 @table @code
 @item org-babel-tangle
 Tangle the current file.  Bound to @kbd{C-c C-v t}.
+
+With prefix argument only tangle the current code block.
 @item org-babel-tangle-file
 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
 @end table
 
 @subsubheading Hooks
+
 @table @code
 @item org-babel-post-tangle-hook
 This hook is run from within code files tangled by @code{org-babel-tangle}.
@@ -12917,6 +13831,21 @@ Example applications could include post-processing, compilation or evaluation
 of tangled code files.
 @end table
 
+@subsubheading Jumping between code and Org
+
+When tangling code from an Org-mode buffer to a source code file, you'll
+frequently find yourself viewing the file of tangled source code (e.g., many
+debuggers point to lines of the source code file).  It is useful to be able
+to navigate from the tangled source to the Org-mode buffer from which the
+code originated.
+
+The @code{org-babel-tangle-jump-to-org} function provides this jumping from
+code to Org-mode functionality.  Two header arguments are required for
+jumping to work, first the @code{padline} (@ref{padline}) option must be set
+to true (the default setting), second the @code{comments} (@ref{comments})
+header argument must be set to @code{links}, which will insert comments into
+the source code buffer which point back to the original Org-mode file.
+
 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
 @section Evaluating code blocks
 @cindex code block, evaluating
@@ -12943,7 +13872,7 @@ used to define a code block).
 @kindex C-c C-c
 There are a number of ways to evaluate code blocks.  The simplest is to press
 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
-@code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
+option @code{org-babel-no-eval-on-ctrl-c-ctrl-c} can be used to remove code
 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
 @code{org-babel-execute-src-block} function to evaluate the block and insert
 its results into the Org mode buffer.
@@ -13054,10 +13983,10 @@ Language-specific documentation is available for some languages.  If
 available, it can be found at
 @uref{http://orgmode.org/worg/org-contrib/babel/languages.html}.
 
-The @code{org-babel-load-languages} controls which languages are enabled for
-evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
-be set using the customization interface or by adding code like the following
-to your emacs configuration.
+The option @code{org-babel-load-languages} controls which languages are
+enabled for evaluation (by default only @code{emacs-lisp} is enabled).  This
+variable can be set using the customization interface or by adding code like
+the following to your emacs configuration.
 
 @quotation
 The following disables @code{emacs-lisp} evaluation and enables evaluation of
@@ -13099,13 +14028,16 @@ describes each header argument in detail.
 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
 @subsection Using header arguments
 
-The values of header arguments can be set in six different ways, each more
-specific (and having higher priority) than the last.
+The values of header arguments can be set in several way.  When the header
+arguments in each layer have been determined, they are combined in order from
+the first, least specific (having the lowest priority) up to the last, most
+specific (having the highest priority).  A header argument with a higher
+priority replaces the same header argument specified at lower priority.
 @menu
 * System-wide header arguments::  Set global default values
 * Language-specific header arguments::  Set default values by language
-* Buffer-wide header arguments::  Set default values for a specific buffer
 * Header arguments in Org mode properties::  Set default values for a buffer or heading
+* Language-specific header arguments in Org mode properties::  Set language-specific default values for a buffer or heading
 * Code block specific header arguments::  The most common way to set values
 * Header arguments in function calls::  The most specific level
 @end menu
@@ -13114,7 +14046,7 @@ specific (and having higher priority) than the last.
 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
 @subsubheading System-wide header arguments
 @vindex org-babel-default-header-args
-System-wide values of header arguments can be specified by customizing the
+System-wide values of header arguments can be specified by adapting the
 @code{org-babel-default-header-args} variable:
 
 @example
@@ -13125,20 +14057,6 @@ System-wide values of header arguments can be specified by customizing the
 :noweb      => "no"
 @end example
 
-@c @example
-@c   org-babel-default-header-args is a variable defined in `org-babel.el'.
-@c   Its value is
-@c   ((:session . "none")
-@c    (:results . "replace")
-@c    (:exports . "code")
-@c    (:cache . "no")
-@c    (:noweb . "no"))
-
-
-@c   Documentation:
-@c   Default arguments to use when evaluating a code block.
-@c @end example
-
 For example, the following example could be used to set the default value of
 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
 expanding @code{:noweb} references by default when evaluating source code
@@ -13147,64 +14065,88 @@ blocks.
 @lisp
 (setq org-babel-default-header-args
       (cons '(:noweb . "yes")
-           (assq-delete-all :noweb org-babel-default-header-args)))
+            (assq-delete-all :noweb org-babel-default-header-args)))
 @end lisp
 
-@node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
+@node Language-specific header arguments, Header arguments in Org mode properties, System-wide header arguments, Using header arguments
 @subsubheading Language-specific header arguments
-Each language can define its own set of default header arguments.  See the
-language-specific documentation available online at
+Each language can define its own set of default header arguments in variable
+@code{org-babel-default-header-args:<lang>}, where @code{<lang>} is the name
+of the language.  See the language-specific documentation available online at
 @uref{http://orgmode.org/worg/org-contrib/babel}.
 
-@node Buffer-wide header arguments, Header arguments in Org mode properties, Language-specific header arguments, Using header arguments
-@subsubheading Buffer-wide header arguments
+@node Header arguments in Org mode properties, Language-specific header arguments in Org mode properties, Language-specific header arguments, Using header arguments
+@subsubheading Header arguments in Org mode properties
+
 Buffer-wide header arguments may be specified as properties through the use
 of @code{#+PROPERTY:} lines placed anywhere in an Org mode file (see
 @ref{Property syntax}).
 
-For example the following would set @code{session} to @code{*R*}, and
-@code{results} to @code{silent} for every code block in the buffer, ensuring
-that all execution took place in the same session, and no results would be
-inserted into the buffer.
+For example the following would set @code{session} to @code{*R*} (only for R
+code blocks), and @code{results} to @code{silent} for every code block in the
+buffer, ensuring that all execution took place in the same session, and no
+results would be inserted into the buffer.
 
 @example
-#+PROPERTY: session *R*
-#+PROPERTY: results silent
-@end example
-
-@node Header arguments in Org mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
-@subsubheading Header arguments in Org mode properties
-
-Header arguments are also read from Org mode properties (see @ref{Property
-syntax}), which can be set on a buffer-wide or per-heading basis.  An example
-of setting a header argument for all code blocks in a buffer is
-
-@example
-#+PROPERTY: tangle yes
+#+PROPERTY: header-args:R  :session *R*
+#+PROPERTY: header-args    :results silent
 @end example
 
+Header arguments read from Org mode properties can also be set on a
+per-subtree basis using property drawers (see @ref{Property syntax}).
 @vindex org-use-property-inheritance
-When properties are used to set default header arguments, they are looked up
-with inheritance, regardless of the value of
-@code{org-use-property-inheritance}.  In the following example the value of
+When properties are used to set default header arguments, they are always
+looked up with inheritance, regardless of the value of
+@code{org-use-property-inheritance}.  Properties are evaluated as seen by the
+outermost call or source block.@footnote{The deprecated syntax for default
+header argument properties, using the name of the header argument as a
+property name directly, evaluates the property as seen by the corresponding
+source block definition.  This behaviour has been kept for backwards
+compatibility.}
+
+In the following example the value of
 the @code{:cache} header argument will default to @code{yes} in all code
 blocks in the subtree rooted at the following heading:
 
 @example
 * outline header
   :PROPERTIES:
-  :cache:    yes
+  :header-args:    :cache yes
   :END:
 @end example
 
 @kindex C-c C-x p
 @vindex org-babel-default-header-args
 Properties defined in this way override the properties set in
-@code{org-babel-default-header-args}.  It is convenient to use the
-@code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
-in Org mode documents.
+@code{org-babel-default-header-args} and are applied for all activated
+languages.  It is convenient to use the @code{org-set-property} function
+bound to @kbd{C-c C-x p} to set properties in Org mode documents.
+
+@node Language-specific header arguments in Org mode properties, Code block specific header arguments, Header arguments in Org mode properties, Using header arguments
+@subsubheading Language-specific header arguments in Org mode properties
+
+Language-specific header arguments are also read from properties
+@code{header-args:<lang>} where @code{<lang>} is the name of the language
+targeted.  As an example
+
+@example
+* Heading
+  :PROPERTIES:
+  :header-args:clojure:    :session *clojure-1*
+  :header-args:R:          :session *R*
+  :END:
+** Subheading
+  :PROPERTIES:
+  :header-args:clojure:    :session *clojure-2*
+  :END:
+@end example
+
+would independently set a default session header argument for R and clojure
+for calls and source blocks under subtree ``Heading'' and change to a
+different clojure setting for evaluations under subtree ``Subheading'', while
+the R session is inherited from ``Heading'' and therefore unchanged.
 
-@node Code block specific header arguments, Header arguments in function calls, Header arguments in Org mode properties, Using header arguments
+@node Code block specific header arguments, Header arguments in function calls, Language-specific header arguments in Org mode properties, Using header arguments
 @subsubheading Code block specific header arguments
 
 The most common way to assign values to header arguments is at the
@@ -13318,8 +14260,12 @@ argument in lowercase letters.  The following header arguments are defined:
 * colnames::                    Handle column names in tables
 * rownames::                    Handle row names in tables
 * shebang::                     Make tangled files executable
+* tangle-mode::                 Set permission of tangled files
 * eval::                        Limit evaluation of specific code blocks
 * wrap::                        Mark source block evaluation results
+* post::                        Post processing of code block results
+* prologue::                    Text to prepend to code block body
+* epilogue::                    Text to append to code block body
 @end menu
 
 Additional header arguments are defined on a language-specific basis, see
@@ -13334,11 +14280,13 @@ syntax used to specify arguments is the same across all languages.  In every
 case, variables require a default value when they are declared.
 
 The values passed to arguments can either be literal values, references, or
-Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}).  References
-include anything in the Org mode file that takes a @code{#+NAME:},
-@code{#+TBLNAME:}, or @code{#+RESULTS:} line.  This includes tables, lists,
-@code{#+BEGIN_EXAMPLE} blocks, other code blocks, and the results of other
-code blocks.
+Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}).
+References include anything in the Org mode file that takes a @code{#+NAME:}
+or @code{#+RESULTS:} line: tables, lists, @code{#+BEGIN_EXAMPLE} blocks,
+other code blocks and the results of other code blocks.
+
+Note: When a reference is made to another code block, the referenced block
+will be evaluated unless it has current cached results (see @ref{cache}).
 
 Argument values can be indexed in a manner similar to arrays (see @ref{var,
 Indexable variable values}).
@@ -13360,10 +14308,10 @@ Here are examples of passing values by reference:
 @table @dfn
 
 @item table
-an Org mode table named with either a @code{#+NAME:} or @code{#+TBLNAME:} line
+an Org mode table named with either a @code{#+NAME:} line
 
 @example
-#+TBLNAME: example-table
+#+NAME: example-table
 | 1 |
 | 2 |
 | 3 |
@@ -13456,19 +14404,6 @@ on two lines
 
 @end table
 
-@subsubheading Alternate argument syntax
-It is also possible to specify arguments in a potentially more natural way
-using the @code{#+NAME:} line of a code block.  As in the following
-example, arguments can be packed inside of parentheses, separated by commas,
-following the source name.
-
-@example
-#+NAME: double(input=0, x=2)
-#+BEGIN_SRC emacs-lisp
-(* 2 (+ input x))
-#+END_SRC
-@end example
-
 @subsubheading Indexable variable values
 It is possible to reference portions of variable values by ``indexing'' into
 the variables.  Indexes are 0 based with negative values counting back from
@@ -13593,7 +14528,7 @@ Emacs Lisp, as shown in the following example.
 @node results, file, var, Specific header arguments
 @subsubsection @code{:results}
 
-There are three classes of @code{:results} header argument.  Only one option
+There are four classes of @code{:results} header argument.  Only one option
 per class may be supplied per code block.
 
 @itemize @bullet
@@ -13602,6 +14537,10 @@ per class may be supplied per code block.
 from the code block
 @item
 @b{type} header arguments specify what type of result the code block will
+return---which has implications for how they will be processed before
+insertion into the Org mode buffer
+@item
+@b{format} header arguments specify what type of result the code block will
 return---which has implications for how they will be inserted into the
 Org mode buffer
 @item
@@ -13647,6 +14586,15 @@ buffer as quoted text.  E.g., @code{:results value verbatim}.
 @item @code{file}
 The results will be interpreted as the path to a file, and will be inserted
 into the Org mode buffer as a file link.  E.g., @code{:results value file}.
+@end itemize
+
+@subsubheading Format
+
+The following options are mutually exclusive and specify what type of results
+the code block will return.  By default, results are inserted according to the
+type as specified above.
+
+@itemize @bullet
 @item @code{raw}
 The results are interpreted as raw Org mode code and are inserted directly
 into the buffer.  If the results look like a table they will be aligned as
@@ -13728,7 +14676,7 @@ While the @code{:file} header argument can be used to specify the path to the
 output file, @code{:dir} specifies the default directory during code block
 execution.  If it is absent, then the directory associated with the current
 buffer is used.  In other words, supplying @code{:dir path} temporarily has
-the same effect as changing the current directory with @kbd{M-x cd path}, and
+the same effect as changing the current directory with @kbd{M-x cd path RET}, and
 then not supplying @code{:dir}.  Under the surface, @code{:dir} simply sets
 the value of the Emacs variable @code{default-directory}.
 
@@ -13853,7 +14801,6 @@ original Org file from which the code was tangled.
 A synonym for ``link'' to maintain backwards compatibility.
 @item @code{org}
 Include text from the Org mode file as a comment.
-
 The text is picked from the leading context of the tangled code and is
 limited by the nearest headline or source block as the case may be.
 @item @code{both}
@@ -13925,7 +14872,7 @@ references will not be expanded when the code block is exported.
 @item @code{strip-export}
 ``Noweb'' syntax references in the body of the code block will be expanded
 before the block is evaluated or tangled.  However, ``noweb'' syntax
-references will not be removed when the code block is exported.
+references will be removed when the code block is exported.
 @item @code{eval}
 ``Noweb'' syntax references in the body of the code block will only be
 expanded before the block is evaluated.
@@ -14085,7 +15032,7 @@ variable and raises an error.  Setting @code{:hlines no} or relying on the
 default value yields the following results.
 
 @example
-#+TBLNAME: many-cols
+#+NAME: many-cols
 | a | b | c |
 |---+---+---|
 | d | e | f |
@@ -14107,7 +15054,7 @@ default value yields the following results.
 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
 
 @example
-#+TBLNAME: many-cols
+#+NAME: many-cols
 | a | b | c |
 |---+---+---|
 | d | e | f |
@@ -14134,9 +15081,7 @@ Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
 The @code{:colnames} header argument accepts the values @code{yes},
 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
 Note that the behavior of the @code{:colnames} header argument may differ
-across languages.  For example Emacs Lisp code blocks ignore the
-@code{:colnames} header argument entirely given the ease with which tables
-with column names may be handled directly in Emacs Lisp.
+across languages.
 
 @itemize @bullet
 @item @code{nil}
@@ -14146,7 +15091,7 @@ names will be removed from the table before
 processing, then reapplied to the results.
 
 @example
-#+TBLNAME: less-cols
+#+NAME: less-cols
 | a |
 |---|
 | b |
@@ -14179,8 +15124,10 @@ hline)
 @node rownames, shebang, colnames, Specific header arguments
 @subsubsection @code{:rownames}
 
-The @code{:rownames} header argument can take on the values @code{yes}
-or @code{no}, with a default value of @code{no}.
+The @code{:rownames} header argument can take on the values @code{yes} or
+@code{no}, with a default value of @code{no}.  Note that Emacs Lisp code
+blocks ignore the @code{:rownames} header argument entirely given the ease
+with which tables with row names may be handled directly in Emacs Lisp.
 
 @itemize @bullet
 @item @code{no}
@@ -14191,7 +15138,7 @@ The first column of the table is removed from the table before processing,
 and is then reapplied to the results.
 
 @example
-#+TBLNAME: with-rownames
+#+NAME: with-rownames
 | one | 1 | 2 | 3 | 4 |  5 |
 | two | 6 | 7 | 8 | 9 | 10 |
 
@@ -14210,7 +15157,7 @@ variable indexing @xref{var, Indexable variable values}.
 
 @end itemize
 
-@node shebang, eval, rownames, Specific header arguments
+@node shebang, tangle-mode, rownames, Specific header arguments
 @subsubsection @code{:shebang}
 
 Setting the @code{:shebang} header argument to a string value
@@ -14218,7 +15165,21 @@ Setting the @code{:shebang} header argument to a string value
 first line of any tangled file holding the code block, and the file
 permissions of the tangled file are set to make it executable.
 
-@node eval, wrap, shebang, Specific header arguments
+
+@node tangle-mode, eval, shebang, Specific header arguments
+@subsubsection @code{:tangle-mode}
+
+The @code{tangle-mode} header argument controls the permission set on tangled
+files.  The value of this header argument will be passed to
+@code{set-file-modes}.  For example, to set a tangled file as read only use
+@code{:tangle-mode (identity #o444)}, or to set a tangled file as executable
+use @code{:tangle-mode (identity #o755)}.  Blocks with @code{shebang}
+(@ref{shebang}) header arguments will automatically be made executable unless
+the @code{tangle-mode} header argument is also used.  The behavior is
+undefined if multiple code blocks with different values for the
+@code{tangle-mode} header argument are tangled to the same file.
+
+@node eval, wrap, tangle-mode, Specific header arguments
 @subsubsection @code{:eval}
 The @code{:eval} header argument can be used to limit the evaluation of
 specific code blocks.  The @code{:eval} header argument can be useful for
@@ -14243,7 +15204,7 @@ If this header argument is not set then evaluation is determined by the value
 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
 security}.
 
-@node wrap,  , eval, Specific header arguments
+@node wrap, post, eval, Specific header arguments
 @subsubsection @code{:wrap}
 The @code{:wrap} header argument is used to mark the results of source block
 evaluation.  The header argument can be passed a string that will be appended
@@ -14251,6 +15212,59 @@ to @code{#+BEGIN_} and @code{#+END_}, which will then be used to wrap the
 results.  If not string is specified then the results will be wrapped in a
 @code{#+BEGIN/END_RESULTS} block.
 
+@node post, prologue, wrap, Specific header arguments
+@subsubsection @code{:post}
+The @code{:post} header argument is used to post-process the results of a
+code block execution.  When a post argument is given, the results of the code
+block will temporarily be bound to the @code{*this*} variable.  This variable
+may then be included in header argument forms such as those used in @ref{var}
+header argument specifications allowing passing of results to other code
+blocks, or direct execution via Emacs Lisp.
+
+The following example illustrates the usage of the @code{:post} header
+argument.
+
+@example
+#+name: attr_wrap
+#+begin_src sh :var data="" :var width="\\textwidth" :results output
+  echo "#+ATTR_LATEX :width $width"
+  echo "$data"
+#+end_src
+
+#+header: :file /tmp/it.png
+#+begin_src dot :post attr_wrap(width="5cm", data=*this*) :results drawer
+  digraph@{
+          a -> b;
+          b -> c;
+          c -> a;
+  @}
+#+end_src
+
+#+RESULTS:
+:RESULTS:
+#+ATTR_LATEX :width 5cm
+[[file:/tmp/it.png]]
+:END:
+@end example
+
+@node prologue, epilogue, post, Specific header arguments
+@subsubsection @code{:prologue}
+The value of the @code{prologue} header argument will be prepended to the
+code block body before execution.  For example, @code{:prologue "reset"} may
+be used to reset a gnuplot session before execution of a particular code
+block, or the following configuration may be used to do this for all gnuplot
+code blocks.  Also see @ref{epilogue}.
+
+@lisp
+(add-to-list 'org-babel-default-header-args:gnuplot
+             '((:prologue . "reset")))
+@end lisp
+
+@node epilogue, , prologue, Specific header arguments
+@subsubsection @code{:epilogue}
+The value of the @code{epilogue} header argument will be appended to the code
+block body before execution.  Also see @ref{prologue}.
+
 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
 @section Results of evaluation
 @cindex code block, results of evaluation
@@ -14380,7 +15394,7 @@ syntactically valid in languages that you use, then please consider setting
 the default value.
 
 Note: if noweb tangling is slow in large Org mode files consider setting the
-@code{*org-babel-use-quick-and-dirty-noweb-expansion*} variable to true.
+@code{org-babel-use-quick-and-dirty-noweb-expansion} variable to @code{t}.
 This will result in faster noweb reference resolution at the expense of not
 correctly resolving inherited values of the @code{:noweb-ref} header
 argument.
@@ -14540,7 +15554,7 @@ emacs -Q --batch \
 * Clean view::                  Getting rid of leading stars in the outline
 * TTY keys::                    Using Org on a tty
 * Interaction::                 Other Emacs packages
-* org-crypt.el::                Encrypting Org files
+* org-crypt::                   Encrypting Org files
 @end menu
 
 
@@ -14694,19 +15708,19 @@ which take off the default security brakes.
 
 @defopt org-confirm-babel-evaluate
 When t (the default), the user is asked before every code block evaluation.
-When nil, the user is not asked.  When set to a function, it is called with
+When @code{nil}, the user is not asked.  When set to a function, it is called with
 two arguments (language and body of the code block) and should return t to
-ask and nil not to ask.
+ask and @code{nil} not to ask.
 @end defopt
 
 For example, here is how to execute "ditaa" code (which is considered safe)
 without asking:
 
-@example
+@lisp
 (defun my-org-confirm-babel-evaluate (lang body)
   (not (string= lang "ditaa")))  ; don't ask for ditaa
 (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
-@end example
+@end lisp
 
 @item Following @code{shell} and @code{elisp} links
 Org has two link types that can directly evaluate code (@pxref{External
@@ -14734,7 +15748,7 @@ either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
 There are more than 500 variables that can be used to customize
 Org.  For the sake of compactness of the manual, I am not
 describing the variables here.  A structured overview of customization
-variables is available with @kbd{M-x org-customize}.  Or select
+variables is available with @kbd{M-x org-customize RET}.  Or select
 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
 settings can also be activated on a per-file basis, by putting special
 lines into the buffer (@pxref{In-buffer settings}).
@@ -14809,7 +15823,7 @@ as if they had been included in the buffer.  In particular, the file can be
 any other Org mode file with internal setup.  You can visit the file the
 cursor is in the line with @kbd{C-c '}.
 @item #+STARTUP:
-@cindex #+STARTUP:
+@cindex #+STARTUP
 This line sets options to be used at startup of Org mode, when an
 Org file is being visited.
 
@@ -14862,6 +15876,18 @@ inlineimages   @r{show inline images}
 noinlineimages @r{don't show inline images on startup}
 @end example
 
+@vindex org-startup-with-latex-preview
+When visiting a file, @LaTeX{} fragments can be converted to images
+automatically.  The variable @code{org-startup-with-latex-preview} which
+controls this behavior, is set to @code{nil} by default to avoid delays on
+startup.
+@cindex @code{latexpreview}, STARTUP keyword
+@cindex @code{nolatexpreview}, STARTUP keyword
+@example
+latexpreview   @r{preview @LaTeX{} fragments}
+nolatexpreview @r{don't preview @LaTeX{} fragments}
+@end example
+
 @vindex org-log-done
 @vindex org-log-note-clock-out
 @vindex org-log-repeat
@@ -14885,25 +15911,34 @@ configured using these options (see variables @code{org-log-done},
 @cindex @code{logrefile}, STARTUP keyword
 @cindex @code{lognoterefile}, STARTUP keyword
 @cindex @code{nologrefile}, STARTUP keyword
-@example
-logdone            @r{record a timestamp when an item is marked DONE}
-lognotedone        @r{record timestamp and a note when DONE}
-nologdone          @r{don't record when items are marked DONE}
-logrepeat          @r{record a time when reinstating a repeating item}
-lognoterepeat      @r{record a note when reinstating a repeating item}
-nologrepeat        @r{do not record when reinstating repeating item}
-lognoteclock-out   @r{record a note when clocking out}
-nolognoteclock-out @r{don't record a note when clocking out}
-logreschedule      @r{record a timestamp when scheduling time changes}
-lognotereschedule  @r{record a note when scheduling time changes}
-nologreschedule    @r{do not record when a scheduling date changes}
-logredeadline      @r{record a timestamp when deadline changes}
-lognoteredeadline  @r{record a note when deadline changes}
-nologredeadline    @r{do not record when a deadline date changes}
-logrefile          @r{record a timestamp when refiling}
-lognoterefile      @r{record a note when refiling}
-nologrefile        @r{do not record when refiling}
+@cindex @code{logdrawer}, STARTUP keyword
+@cindex @code{nologdrawer}, STARTUP keyword
+@cindex @code{logstatesreversed}, STARTUP keyword
+@cindex @code{nologstatesreversed}, STARTUP keyword
+@example
+logdone             @r{record a timestamp when an item is marked DONE}
+lognotedone         @r{record timestamp and a note when DONE}
+nologdone           @r{don't record when items are marked DONE}
+logrepeat           @r{record a time when reinstating a repeating item}
+lognoterepeat       @r{record a note when reinstating a repeating item}
+nologrepeat         @r{do not record when reinstating repeating item}
+lognoteclock-out    @r{record a note when clocking out}
+nolognoteclock-out  @r{don't record a note when clocking out}
+logreschedule       @r{record a timestamp when scheduling time changes}
+lognotereschedule   @r{record a note when scheduling time changes}
+nologreschedule     @r{do not record when a scheduling date changes}
+logredeadline       @r{record a timestamp when deadline changes}
+lognoteredeadline   @r{record a note when deadline changes}
+nologredeadline     @r{do not record when a deadline date changes}
+logrefile           @r{record a timestamp when refiling}
+lognoterefile       @r{record a note when refiling}
+nologrefile         @r{do not record when refiling}
+logdrawer           @r{store log into drawer}
+nologdrawer         @r{store log outside of drawer}
+logstatesreversed   @r{reverse the order of states notes}
+nologstatesreversed @r{do not reverse the order of states notes}
 @end example
+
 @vindex org-hide-leading-stars
 @vindex org-odd-levels-only
 Here are the options for hiding leading stars in outline headings, and for
@@ -14922,6 +15957,7 @@ noindent   @r{no virtual indentation according to outline level}
 odd        @r{allow only odd outline levels (1,3,...)}
 oddeven    @r{allow all outline levels}
 @end example
+
 @vindex org-put-time-stamp-overlays
 @vindex org-time-stamp-overlay-formats
 To turn on custom format overlays over timestamps (variables
@@ -14931,6 +15967,7 @@ To turn on custom format overlays over timestamps (variables
 @example
 customtime @r{overlay custom time format}
 @end example
+
 @vindex constants-unit-system
 The following options influence the table spreadsheet (variable
 @code{constants-unit-system}).
@@ -14940,6 +15977,7 @@ The following options influence the table spreadsheet (variable
 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
 constSI    @r{@file{constants.el} should use the SI unit system}
 @end example
+
 @vindex org-footnote-define-inline
 @vindex org-footnote-auto-label
 @vindex org-footnote-auto-adjust
@@ -14966,6 +16004,7 @@ fnplain     @r{create @code{[1]}-like labels automatically}
 fnadjust    @r{automatically renumber and sort footnotes}
 nofnadjust  @r{do not renumber and sort automatically}
 @end example
+
 @cindex org-hide-block-startup
 To hide blocks on startup, use these keywords.  The corresponding variable is
 @code{org-hide-block-startup}.
@@ -14975,6 +16014,7 @@ To hide blocks on startup, use these keywords.  The corresponding variable is
 hideblocks   @r{Hide all begin/end blocks on startup}
 nohideblocks @r{Do not hide blocks on startup}
 @end example
+
 @cindex org-pretty-entities
 The display of entities as UTF-8 characters is governed by the variable
 @code{org-pretty-entities} and the keywords
@@ -14984,20 +16024,29 @@ The display of entities as UTF-8 characters is governed by the variable
 entitiespretty  @r{Show entities as UTF-8 characters where possible}
 entitiesplain   @r{Leave entities plain}
 @end example
+
 @item #+TAGS:  TAG1(c1) TAG2(c2)
 @vindex org-tag-alist
 These lines (several such lines are allowed) specify the valid tags in
 this file, and (potentially) the corresponding @emph{fast tag selection}
 keys.  The corresponding variable is @code{org-tag-alist}.
+@cindex #+TBLFM
 @item #+TBLFM:
 This line contains the formulas for the table directly above the line.
-@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
-@itemx #+OPTIONS:, #+BIND:, #+XSLT:,
+
+Table can have multiple lines containing @samp{#+TBLFM:}.  Note
+that only the first line of @samp{#+TBLFM:} will be applied when
+you recalculate the table.  For more details see @ref{Using
+multiple #+TBLFM lines} in @ref{Editing and debugging formulas}.
+
+@item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+DATE:,
+@itemx #+OPTIONS:, #+BIND:,
 @itemx #+DESCRIPTION:, #+KEYWORDS:,
-@itemx #+LaTeX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
-@itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
+@itemx #+LaTeX_HEADER:, #+LaTeX_HEADER_EXTRA:,
+@itemx #+HTML_HEAD:, #+HTML_HEAD_EXTRA:, #+HTML_LINK_UP:, #+HTML_LINK_HOME:,
+@itemx #+SELECT_TAGS:, #+EXCLUDE_TAGS:
 These lines provide settings for exporting files.  For more details see
-@ref{Export options}.
+@ref{Export settings}.
 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
 @vindex org-todo-keywords
 These lines set the TODO keywords and their interpretation in the
@@ -15042,7 +16091,7 @@ If the cursor is in a property line or at the start or end of a property
 drawer, offer property commands.
 @item
 If the cursor is at a footnote reference, go to the corresponding
-definition, and vice versa.
+definition, and @emph{vice versa}.
 @item
 If the cursor is on a statistics cookie, update it.
 @item
@@ -15221,7 +16270,7 @@ tty you would rather use @kbd{C-c .} to re-insert the timestamp.
 @end multitable
 
 
-@node Interaction, org-crypt.el, TTY keys, Miscellaneous
+@node Interaction, org-crypt, TTY keys, Miscellaneous
 @section Interaction with other packages
 @cindex packages, interaction with other
 Org lives in the world of GNU Emacs and interacts in various ways
@@ -15367,6 +16416,18 @@ Yes, these are unfortunately more difficult to remember.  If you want
 to have other replacement keys, look at the variable
 @code{org-disputed-keys}.
 
+@item @file{ecomplete.el} by Lars Magne Ingebrigtsen @email{larsi@@gnus.org}
+@cindex @file{ecomplete.el}
+
+Ecomplete provides ``electric'' address completion in address header
+lines in message buffers.  Sadly Orgtbl mode cuts ecompletes power
+supply: No completion happens when Orgtbl mode is enabled in message
+buffers while entering text in address header lines.  If one wants to
+use ecomplete one should @emph{not} follow the advice to automagically
+turn on Orgtbl mode in message buffers (see @ref{Orgtbl mode}), but
+instead---after filling in the message headers---turn on Orgtbl mode
+manually when needed in the messages body.
+
 @item @file{filladapt.el} by Kyle Jones
 @cindex @file{filladapt.el}
 
@@ -15381,7 +16442,7 @@ this:
 
 @item @file{yasnippet.el}
 @cindex @file{yasnippet.el}
-The way Org mode binds the TAB key (binding to @code{[tab]} instead of
+The way Org mode binds the @key{TAB} key (binding to @code{[tab]} instead of
 @code{"\t"}) overrules YASnippet's access to this key.  The following code
 fixed this problem:
 
@@ -15406,10 +16467,10 @@ Then, tell Org mode what to do with the new function:
 @lisp
 (add-hook 'org-mode-hook
           (lambda ()
-           (make-variable-buffer-local 'yas/trigger-key)
-           (setq yas/trigger-key [tab])
-           (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
-           (define-key yas/keymap [tab] 'yas/next-field)))
+            (make-variable-buffer-local 'yas/trigger-key)
+            (setq yas/trigger-key [tab])
+            (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
+            (define-key yas/keymap [tab] 'yas/next-field)))
 @end lisp
 
 @item @file{windmove.el} by Hovav Shacham
@@ -15440,9 +16501,11 @@ another key for this command, or override the key in
 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
 @end lisp
 
+
+
 @end table
 
-@node org-crypt.el,  , Interaction, Miscellaneous
+@node org-crypt,  , Interaction, Miscellaneous
 @section org-crypt.el
 @cindex @file{org-crypt.el}
 @cindex @code{org-decrypt-entry}
@@ -15458,7 +16521,7 @@ customize the @code{org-crypt-tag-matcher} setting.
 To use org-crypt it is suggested that you have the following in your
 @file{.emacs}:
 
-@example
+@lisp
 (require 'org-crypt)
 (org-crypt-use-before-save-magic)
 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
@@ -15476,7 +16539,7 @@ To use org-crypt it is suggested that you have the following in your
   ;; To turn it off only locally, you can insert this:
   ;;
   ;; # -*- buffer-auto-save-file-name: nil; -*-
-@end example
+@end lisp
 
 Excluding the crypt tag from inheritance prevents already encrypted text
 being encrypted again.
@@ -15492,11 +16555,13 @@ Org.
 * Hooks::                       How to reach into Org's internals
 * Add-on packages::             Available extensions
 * Adding hyperlink types::      New custom link types
+* Adding export back-ends::     How to write new export back-ends
 * Context-sensitive commands::  How to add functionality to such commands
 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
 * Dynamic blocks::              Automatically filled blocks
 * Special agenda views::        Customized views
-* Extracting agenda information::  Postprocessing of agenda information
+* Speeding up your agendas::    Tips on how to speed up your agendas
+* Extracting agenda information::  Post-processing of agenda information
 * Using the property API::      Writing programs that use entry properties
 * Using the mapping API::       Mapping over all or selected entries
 @end menu
@@ -15516,15 +16581,14 @@ maintained by the Worg project and can be found at
 @cindex add-on packages
 
 A large number of add-on packages have been written by various authors.
+
 These packages are not part of Emacs, but they are distributed as contributed
-packages with the separate release available at the Org mode home page at
-@uref{http://orgmode.org}.  The list of contributed packages, along with
-documentation about each package, is maintained by the Worg project at
+packages with the separate release available at @uref{http://orgmode.org}.
+See the @file{contrib/README} file in the source code directory for a list of
+contributed files.  You may also find some more information on the Worg page:
 @uref{http://orgmode.org/worg/org-contrib/}.
 
-
-
-@node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
+@node Adding hyperlink types, Adding export back-ends, Add-on packages, Hacking
 @section Adding hyperlink types
 @cindex hyperlinks, adding new types
 
@@ -15627,7 +16691,37 @@ When it makes sense for your new link type, you may also define a function
 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
 not accept any arguments, and return the full link with prefix.
 
-@node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
+@node Adding export back-ends, Context-sensitive commands, Adding hyperlink types, Hacking
+@section Adding export back-ends
+@cindex Export, writing back-ends
+
+Org 8.0 comes with a completely rewritten export engine which makes it easy
+to write new export back-ends, either from scratch, or from deriving them
+from existing ones.
+
+Your two entry points are respectively @code{org-export-define-backend} and
+@code{org-export-define-derived-backend}.  To grok these functions, you
+should first have a look at @file{ox-latex.el} (for how to define a new
+back-end from scratch) and @file{ox-beamer.el} (for how to derive a new
+back-end from an existing one.
+
+When creating a new back-end from scratch, the basic idea is to set the name
+of the back-end (as a symbol) and an an alist of elements and export
+functions.  On top of this, you will need to set additional keywords like
+@code{:menu-entry} (to display the back-end in the export dispatcher),
+@code{:export-block} (to specify what blocks should not be exported by this
+back-end), and @code{:options-alist} (to let the user set export options that
+are specific to this back-end.)
+
+Deriving a new back-end is similar, except that you need to set
+@code{:translate-alist} to an alist of export functions that should be used
+instead of the parent back-end functions.
+
+For a complete reference documentation, see
+@url{http://orgmode.org/worg/dev/org-export-reference.html, the Org Export
+Reference on Worg}.
+
+@node Context-sensitive commands, Tables in arbitrary syntax, Adding export back-ends, Hacking
 @section Context-sensitive commands
 @cindex context-sensitive commands, hooks
 @cindex add-ons, context-sensitive commands
@@ -15696,7 +16790,7 @@ can use Org's facilities to edit and structure lists by turning
 * Radio tables::                Sending and receiving radio tables
 * A @LaTeX{} example::          Step by step, almost a tutorial
 * Translator functions::        Copy and modify
-* Radio lists::                 Doing the same for lists
+* Radio lists::                 Sending and receiving lists
 @end menu
 
 @node Radio tables, A @LaTeX{} example, Tables in arbitrary syntax, Tables in arbitrary syntax
@@ -15704,9 +16798,10 @@ can use Org's facilities to edit and structure lists by turning
 @cindex radio tables
 
 To define the location of the target table, you first need to create two
-lines that are comments in the current mode, but contain magic words for
-Orgtbl mode to find.  Orgtbl mode will insert the translated table
-between these lines, replacing whatever was there before.  For example:
+lines that are comments in the current mode, but contain magic words
+@code{BEGIN/END RECEIVE ORGTBL} for Orgtbl mode to find.  Orgtbl mode will
+insert the translated table between these lines, replacing whatever was there
+before.  For example in C mode where comments are between @code{/* ... */}:
 
 @example
 /* BEGIN RECEIVE ORGTBL table_name */
@@ -15744,8 +16839,8 @@ removal of these columns, the function never knows that there have been
 additional columns.
 
 @item :no-escape t
-When non-nil, do not escape special characters @code{&%#_^} when exporting
-the table.  The default value is nil.
+When non-@code{nil}, do not escape special characters @code{&%#_^} when exporting
+the table.  The default value is @code{nil}.
 @end table
 
 @noindent
@@ -15766,7 +16861,7 @@ in @LaTeX{}.
 @item
 You can just comment the table line-by-line whenever you want to process
 the file, and uncomment it whenever you need to edit the table.  This
-only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
+only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment RET}
 makes this comment-toggling very easy, in particular if you bind it to a
 key.
 @end itemize
@@ -15780,8 +16875,8 @@ The best way to wrap the source table in @LaTeX{} is to use the
 activated by placing @code{\usepackage@{comment@}} into the document
 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
 default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
-variable @code{orgtbl-radio-tables} to install templates for other
-modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
+variable @code{orgtbl-radio-table-templates} to install templates for other
+modes.}  with the command @kbd{M-x orgtbl-insert-radio-table RET}.  You will
 be prompted for a table name, let's say we use @samp{salesfigures}.  You
 will then get the following template:
 
@@ -15860,7 +16955,7 @@ interprets the following parameters (see also @pxref{Translator functions}):
 @table @code
 @item :splice nil/t
 When set to t, return only table body lines, don't wrap them into a
-tabular environment.  Default is nil.
+tabular environment.  Default is @code{nil}.
 
 @item :fmt fmt
 A format to be used to wrap each field, it should contain @code{%s} for the
@@ -16052,7 +17147,7 @@ The corresponding block writer function could look like this:
 (defun org-dblock-write:block-update-time (params)
   (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
     (insert "Last block update at: "
-           (format-time-string fmt (current-time)))))
+            (format-time-string fmt (current-time)))))
 @end lisp
 
 If you want to make sure that all dynamic blocks are always up-to-date,
@@ -16064,21 +17159,25 @@ written in a way such that it does nothing in buffers that are not in
 You can narrow the current buffer to the current dynamic block (like any
 other block) with @code{org-narrow-to-block}.
 
-@node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
+@node Special agenda views, Speeding up your agendas, Dynamic blocks, Hacking
 @section Special agenda views
 @cindex agenda views, user-defined
 
 @vindex org-agenda-skip-function
 @vindex org-agenda-skip-function-global
 Org provides a special hook that can be used to narrow down the selection
-made by these agenda views: @code{agenda}, @code{todo}, @code{alltodo},
-@code{tags}, @code{tags-todo}, @code{tags-tree}.  You may specify a function
-that is used at each match to verify if the match should indeed be part of
-the agenda view, and if not, how much should be skipped.  You can specify a
-global condition that will be applied to all agenda views, this condition
-would be stored in the variable @code{org-agenda-skip-function-global}.  More
-commonly, such a definition is applied only to specific custom searches,
-using @code{org-agenda-skip-function}.
+made by these agenda views: @code{agenda}, @code{agenda*}@footnote{The
+@code{agenda*} view is the same than @code{agenda} except that it only
+considers @emph{appointments}, i.e., scheduled and deadline items that have a
+time specification @code{[h]h:mm} in their time-stamps.}, @code{todo},
+@code{alltodo}, @code{tags}, @code{tags-todo}, @code{tags-tree}.  You may
+specify a function that is used at each match to verify if the match should
+indeed be part of the agenda view, and if not, how much should be skipped.
+You can specify a global condition that will be applied to all agenda views,
+this condition would be stored in the variable
+@code{org-agenda-skip-function-global}.  More commonly, such a definition is
+applied only to specific custom searches, using
+@code{org-agenda-skip-function}.
 
 Let's say you want to produce a list of projects that contain a WAITING
 tag anywhere in the project tree.  Let's further assume that you have
@@ -16165,7 +17264,48 @@ like this, even without defining a special function:
     (org-agenda-overriding-header "Projects waiting for something: "))))
 @end lisp
 
-@node Extracting agenda information, Using the property API, Special agenda views, Hacking
+@node Speeding up your agendas, Extracting agenda information, Special agenda views, Hacking
+@section Speeding up your agendas
+@cindex agenda views, optimization
+
+When your Org files grow in both number and size, agenda commands may start
+to become slow.  Below are some tips on how to speed up the agenda commands.
+
+@enumerate
+@item
+Reduce the number of Org agenda files: this will reduce the slowness caused
+by accessing a hard drive.
+@item
+Reduce the number of DONE and archived headlines: this way the agenda does
+not need to skip them.
+@item
+@vindex org-agenda-dim-blocked-tasks
+Inhibit the dimming of blocked tasks:
+@lisp
+(setq org-agenda-dim-blocked-tasks nil)
+@end lisp
+@item
+@vindex org-startup-folded
+@vindex org-agenda-inhibit-startup
+Inhibit agenda files startup options:
+@lisp
+(setq org-agenda-inhibit-startup nil)
+@end lisp
+@item
+@vindex org-agenda-show-inherited-tags
+@vindex org-agenda-use-tag-inheritance
+Disable tag inheritance in agenda:
+@lisp
+(setq org-agenda-use-tag-inheritance nil)
+@end lisp
+@end enumerate
+
+You can set these options for specific agenda views only.  See the docstrings
+of these variables for details on why they affect the agenda generation, and
+this @uref{http://orgmode.org/worg/agenda-optimization.html, dedicated Worg
+page} for further explanations.
+
+@node Extracting agenda information, Using the property API, Speeding up your agendas, Hacking
 @section Extracting agenda information
 @cindex agenda, pipe
 @cindex Scripts, for agenda processing
@@ -16282,27 +17422,27 @@ This includes the TODO keyword, the tags, time strings for deadline,
 scheduled, and clocking, and any additional properties defined in the
 entry.  The return value is an alist.  Keys may occur multiple times
 if the property key was used several times.@*
-POM may also be nil, in which case the current entry is used.
-If WHICH is nil or `all', get all properties.  If WHICH is
+POM may also be @code{nil}, in which case the current entry is used.
+If WHICH is @code{nil} or `all', get all properties.  If WHICH is
 `special' or `standard', only get that subclass.
 @end defun
 @vindex org-use-property-inheritance
 @findex org-insert-property-drawer
 @defun org-entry-get pom property &optional inherit
-Get value of PROPERTY for entry at point-or-marker POM@.  By default,
-this only looks at properties defined locally in the entry.  If INHERIT
-is non-nil and the entry does not have the property, then also check
-higher levels of the hierarchy.  If INHERIT is the symbol
+Get value of @code{PROPERTY} for entry at point-or-marker @code{POM}@.  By default,
+this only looks at properties defined locally in the entry.  If @code{INHERIT}
+is non-@code{nil} and the entry does not have the property, then also check
+higher levels of the hierarchy.  If @code{INHERIT} is the symbol
 @code{selective}, use inheritance if and only if the setting of
-@code{org-use-property-inheritance} selects PROPERTY for inheritance.
+@code{org-use-property-inheritance} selects @code{PROPERTY} for inheritance.
 @end defun
 
 @defun org-entry-delete pom property
-Delete the property PROPERTY from entry at point-or-marker POM.
+Delete the property @code{PROPERTY} from entry at point-or-marker POM.
 @end defun
 
 @defun org-entry-put pom property value
-Set PROPERTY to VALUE for entry at point-or-marker POM.
+Set @code{PROPERTY} to @code{VALUE} for entry at point-or-marker POM.
 @end defun
 
 @defun org-buffer-property-keys &optional include-specials
@@ -16314,28 +17454,29 @@ Insert a property drawer for the current entry.  Also
 @end defun
 
 @defun org-entry-put-multivalued-property pom property &rest values
-Set PROPERTY at point-or-marker POM to VALUES@.  VALUES should be a list of
-strings.  They will be concatenated, with spaces as separators.
+Set @code{PROPERTY} at point-or-marker @code{POM} to @code{VALUES}@.
+@code{VALUES} should be a list of strings.  They will be concatenated, with
+spaces as separators.
 @end defun
 
 @defun org-entry-get-multivalued-property pom property
-Treat the value of the property PROPERTY as a whitespace-separated list of
-values and return the values as a list of strings.
+Treat the value of the property @code{PROPERTY} as a whitespace-separated
+list of values and return the values as a list of strings.
 @end defun
 
 @defun org-entry-add-to-multivalued-property pom property value
-Treat the value of the property PROPERTY as a whitespace-separated list of
-values and make sure that VALUE is in this list.
+Treat the value of the property @code{PROPERTY} as a whitespace-separated
+list of values and make sure that @code{VALUE} is in this list.
 @end defun
 
 @defun org-entry-remove-from-multivalued-property pom property value
-Treat the value of the property PROPERTY as a whitespace-separated list of
-values and make sure that VALUE is @emph{not} in this list.
+Treat the value of the property @code{PROPERTY} as a whitespace-separated
+list of values and make sure that @code{VALUE} is @emph{not} in this list.
 @end defun
 
 @defun org-entry-member-in-multivalued-property pom property value
-Treat the value of the property PROPERTY as a whitespace-separated list of
-values and check if VALUE is in this list.
+Treat the value of the property @code{PROPERTY} as a whitespace-separated
+list of values and check if @code{VALUE} is in this list.
 @end defun
 
 @defopt org-property-allowed-value-functions
@@ -16359,30 +17500,29 @@ functions for each or selected entries.  The main entry point for this API
 is:
 
 @defun org-map-entries func &optional match scope &rest skip
-Call FUNC at each headline selected by MATCH in SCOPE.
+Call @code{FUNC} at each headline selected by @code{MATCH} in @code{SCOPE}.
 
-FUNC is a function or a Lisp form.  The function will be called without
-arguments, with the cursor positioned at the beginning of the headline.
-The return values of all calls to the function will be collected and
-returned as a list.
+@code{FUNC} is a function or a Lisp form.  The function will be called
+without arguments, with the cursor positioned at the beginning of the
+headline.  The return values of all calls to the function will be collected
+and returned as a list.
 
-The call to FUNC will be wrapped into a save-excursion form, so FUNC
-does not need to preserve point.  After evaluation, the cursor will be
-moved to the end of the line (presumably of the headline of the
-processed entry) and search continues from there.  Under some
-circumstances, this may not produce the wanted results.  For example,
-if you have removed (e.g., archived) the current (sub)tree it could
-mean that the next entry will be skipped entirely.  In such cases, you
-can specify the position from where search should continue by making
-FUNC set the variable `org-map-continue-from' to the desired buffer
-position.
+The call to @code{FUNC} will be wrapped into a save-excursion form, so
+@code{FUNC} does not need to preserve point.  After evaluation, the cursor
+will be moved to the end of the line (presumably of the headline of the
+processed entry) and search continues from there.  Under some circumstances,
+this may not produce the wanted results.  For example, if you have removed
+(e.g., archived) the current (sub)tree it could mean that the next entry will
+be skipped entirely.  In such cases, you can specify the position from where
+search should continue by making @code{FUNC} set the variable
+@code{org-map-continue-from} to the desired buffer position.
 
-MATCH is a tags/property/todo match as it is used in the agenda match view.
-Only headlines that are matched by this query will be considered during
-the iteration.  When MATCH is nil or t, all headlines will be
-visited by the iteration.
+@code{MATCH} is a tags/property/todo match as it is used in the agenda match
+view.  Only headlines that are matched by this query will be considered
+during the iteration.  When @code{MATCH} is @code{nil} or @code{t}, all
+headlines will be visited by the iteration.
 
-SCOPE determines the scope of this command.  It can be any of:
+@code{SCOPE} determines the scope of this command.  It can be any of:
 
 @example
 nil     @r{the current buffer, respecting the restriction if any}
@@ -16420,17 +17560,18 @@ Here are a couple of functions that might be handy:
 
 @defun org-todo &optional arg
 Change the TODO state of the entry.  See the docstring of the functions for
-the many possible values for the argument ARG.
+the many possible values for the argument @code{ARG}.
 @end defun
 
 @defun org-priority &optional action
 Change the priority of the entry.  See the docstring of this function for the
-possible values for ACTION.
+possible values for @code{ACTION}.
 @end defun
 
 @defun org-toggle-tag tag &optional onoff
-Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
-or @code{off} will not toggle tag, but ensure that it is either on or off.
+Toggle the tag @code{TAG} in the current entry.  Setting @code{ONOFF} to
+either @code{on} or @code{off} will not toggle tag, but ensure that it is
+either on or off.
 @end defun
 
 @defun org-promote
@@ -16466,10 +17607,10 @@ The following example counts the number of entries with TODO keyword
 @i{MobileOrg} is the name of the mobile companion app for Org mode, currently
 available for iOS and for Android.  @i{MobileOrg} offers offline viewing and
 capture support for an Org mode system rooted on a ``real'' computer.  It
-does also allow you to record changes to existing entries.
-The @uref{http://mobileorg.ncogni.to/, iOS implementation} for the
-@i{iPhone/iPod Touch/iPad} series of devices, was developed by Richard
-Moreland.  Android users should check out
+does also allow you to record changes to existing entries.  The
+@uref{https://github.com/MobileOrg/, iOS implementation} for the
+@i{iPhone/iPod Touch/iPad} series of devices, was started by Richard Moreland
+and is now in the hands Sean Escriva.  Android users should check out
 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
 by Matt Jones.  The two implementations are not identical but offer similar
 features.
@@ -16479,7 +17620,7 @@ format that can be displayed by @i{MobileOrg}, and for integrating notes
 captured and changes made by @i{MobileOrg} into the main system.
 
 For changing tags and TODO states in MobileOrg, you should have set up the
-customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
+customization variables @code{org-todo-keywords} and @code{org-tag-alist} to
 cover all important tags and TODO keywords, even if individual files use only
 part of these.  MobileOrg will also offer you states and tags set up with
 in-buffer settings, but it will understand the logistics of TODO state
@@ -16580,6 +17721,7 @@ should then go through these entries and do whatever actions are necessary.
 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
 will be displayed in the echo area when the cursor is on the corresponding
 agenda line.
+
 @table @kbd
 @kindex ?
 @item ?
@@ -16596,11 +17738,11 @@ this flagged entry is finished.
 @kindex C-c a ?
 If you are not able to process all flagged entries directly, you can always
 return to this agenda view@footnote{Note, however, that there is a subtle
-difference.  The view created automatically by @kbd{M-x org-mobile-pull
-@key{RET}} is guaranteed to search all files that have been addressed by the
-last pull.  This might include a file that is not currently in your list of
-agenda files.  If you later use @kbd{C-c a ?} to regenerate the view, only
-the current agenda files will be searched.} using @kbd{C-c a ?}.
+difference.  The view created automatically by @kbd{M-x org-mobile-pull RET}
+is guaranteed to search all files that have been addressed by the last pull.
+This might include a file that is not currently in your list of agenda files.
+If you later use @kbd{C-c a ?} to regenerate the view, only the current
+agenda files will be searched.} using @kbd{C-c a ?}.
 
 @node History and Acknowledgments, GNU Free Documentation License, MobileOrg, Top
 @appendix History and acknowledgments
@@ -16660,7 +17802,7 @@ of his great @file{remember.el}.
 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
-webpages derived from Org using an Info-like or a folding interface with
+web pages derived from Org using an Info-like or a folding interface with
 single-key navigation.
 @end table
 
@@ -16674,8 +17816,8 @@ would not be complete without adding a few more acknowledgements and thanks
 to Carsten's ones above.
 
 I am first grateful to Carsten for his trust while handing me over the
-maintainership of Org.  His support as been great since day one of this new
-adventure, and it helped a lot.
+maintainership of Org.  His unremitting support is what really helped me
+getting more confident over time, with both the community and the code.
 
 When I took over maintainership, I knew I would have to make Org more
 collaborative than ever, as I would have to rely on people that are more
@@ -16689,15 +17831,13 @@ Eric is maintaining the Babel parts of Org.  His reactivity here kept me away
 from worrying about possible bugs here and let me focus on other parts.
 
 @item Nicolas Goaziou
-Nicolas is maintaining the consistency of the deepest parts of Org.  His work
-on @file{org-element.el} and @file{org-export.el} has been outstanding, and
-opened the doors for many new ideas and features.
-
-@item Jambunathan K
-Jambunathan contributed the ODT exporter, definitely a killer feature of
-Org mode.  He also contributed the new HTML exporter, which is another core
-feature of Org.  Here too, I knew I could rely on him to fix bugs in these
-areas and to patiently explain the users what was the problems and solutions.
+Nicolas is maintaining the consistency of the deepest parts of Org.  His
+work on @file{org-element.el} and @file{ox.el} has been outstanding, and
+opened the doors for many new ideas and features.  He rewrote many of the
+old exporters to use the new export engine, and helped with documenting
+this major change.  More importantly (if that's possible), he has been more
+than reliable during all the work done for Org 8.0, and always very
+reactive on the mailing list.
 
 @item Achim Gratz
 Achim rewrote the building process of Org, turning some @emph{ad hoc} tools
@@ -16721,8 +17861,17 @@ complete if the ones above were not mentioned in this manual.
 @item
 @i{Russel Adams} came up with the idea for drawers.
 @item
+@i{Suvayu Ali} has steadily helped on the mailing list, providing useful
+feedback on many features and several patches.
+@item
+@i{Luis Anaya} wrote @file{ox-man.el}.
+@item
 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
 @item
+@i{Michael Brand} helped by reporting many bugs and testing many features.
+He also implemented the distinction between empty fields and 0-value fields
+in Org's spreadsheets.
+@item
 @i{Christophe Bataillon} created the great unicorn logo that we use on the
 Org mode website.
 @item
@@ -16746,7 +17895,11 @@ calculations and improved XEmacs compatibility, in particular by porting
 @item
 @i{Sacha Chua} suggested copying some linking code from Planner.
 @item
-@i{Baoqiu Cui} contributed the DocBook exporter.
+@i{Toby S. Cubitt} contributed to the code for clock formats.
+@item
+@i{Baoqiu Cui} contributed the DocBook exporter.  It has been deleted from
+Org 8.0: you can now export to Texinfo and export the @file{.texi} file to
+DocBook using @code{makeinfo}.
 @item
 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
 came up with the idea of properties, and that there should be an API for
@@ -16758,16 +17911,23 @@ them.
 inspired some of the early development, including HTML export.  He also
 asked for a way to narrow wide table columns.
 @item
+@i{Jason Dunsmore} has been maintaining the Org-Mode server at Rackspace for
+several years now.  He also sponsored the hosting costs until Rackspace
+started to host us for free.
+@item
 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
 the Org-Babel documentation into the manual.
 @item
 @i{Christian Egli} converted the documentation into Texinfo format, inspired
 the agenda, patched CSS formatting into the HTML exporter, and wrote
-@file{org-taskjuggler.el}.
+@file{org-taskjuggler.el}, which has been rewritten by Nicolas Goaziou as
+@file{ox-taskjuggler.el} for Org 8.0.
 @item
 @i{David Emery} provided a patch for custom CSS support in exported
 HTML agendas.
 @item
+@i{Sean Escriva} took over MobileOrg development on the iPhone platform.
+@item
 @i{Nic Ferrier} contributed mailcap and XOXO support.
 @item
 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
@@ -16789,7 +17949,9 @@ publication through Network Theory Ltd.
 @item
 @i{Niels Giesen} had the idea to automatically archive DONE trees.
 @item
-@i{Nicolas Goaziou} rewrote much of the plain list code.
+@i{Nicolas Goaziou} rewrote much of the plain list code.  He also wrote
+@file{org-element.el} and @file{org-export.el}, which was a huge step forward
+in implementing a clean framework for Org exporters.
 @item
 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
 @item
@@ -16812,6 +17974,8 @@ folded entries, and column view for properties.
 @item
 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
 @item
+@i{Jonathan Leech-Pepin} wrote @file{ox-texinfo.el}.
+@item
 @i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
 provided frequent feedback and some patches.
 @item
@@ -16824,7 +17988,7 @@ small fixes and patches.
 @item
 @i{Jason F. McBrayer} suggested agenda export to CSV format.
 @item
-@i{Max Mikhanosha} came up with the idea of refiling.
+@i{Max Mikhanosha} came up with the idea of refiling and sticky agendas.
 @item
 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
 basis.
@@ -16858,9 +18022,14 @@ links, among other things.
 @i{Pete Phillips} helped during the development of the TAGS feature, and
 provided frequent feedback.
 @item
+@i{Francesco Pizzolante} provided patches that helped speeding up the agenda
+generation.
+@item
 @i{Martin Pohlack} provided the code snippet to bundle character insertion
 into bundles of 20 for undo.
 @item
+@i{Rackspace.com} is hosting our website for free.  Thank you Rackspace!
+@item
 @i{T.V. Raman} reported bugs and suggested improvements.
 @item
 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
@@ -16883,6 +18052,9 @@ of feedback, developed and applied standards to the Org documentation.
 @i{Christian Schlauer} proposed angular brackets around links, among
 other things.
 @item
+@i{Christopher Schmidt} reworked @code{orgstruct-mode} so that users can
+enjoy folding in non-org buffers by using Org headlines in comments.
+@item
 @i{Paul Sexton} wrote @file{org-ctags.el}.
 @item
 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
@@ -16914,7 +18086,7 @@ with links transformation to Org syntax.
 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
 chapter about publishing.
 @item
-@i{Jambunathan K} contributed the ODT exporter.
+@i{Jambunathan K} contributed the ODT exporter and rewrote the HTML exporter.
 @item
 @i{Sebastien Vauban} reported many issues with @LaTeX{} and BEAMER export and
 enabled source code highlighting in Gnus.
index 1276eb95aa889479a0244bb51e858efb0f09333e..11123f977a0f5f0680ed8135b2d8b66481ec771a 100644 (file)
@@ -176,18 +176,18 @@ PCL-CVS as well as all the documentation.
 Inge Wallin wrote the skeleton of
 @file{pcl-cvs.texi}, and gave useful comments on it.  He also wrote
 the files @file{elib-node.el} and @file{compile-all.el}.  The file
-@file{cookie.el} was inspired by Inge.@refill
+@file{cookie.el} was inspired by Inge.
 
 @item
 @c linus@@lysator.liu.se
 Linus Tolke contributed useful comments
-on both the functionality and the documentation.@refill
+on both the functionality and the documentation.
 
 @item
 @c jwz@@jwz.com
 Jamie Zawinski contributed
 @file{pcl-cvs-lucid.el}, which was later renamed to
-@file{pcl-cvs-xemacs.el}.@refill
+@file{pcl-cvs-xemacs.el}.
 
 @item
 Leif Lonnblad contributed RCVS support (since superseded by the new
@@ -297,7 +297,7 @@ You can move the cursor up and down in the buffer with @kbd{C-n} and
 repository. @xref{Committing changes}.  You can also press @kbd{O} to
 update any of the files that are marked @samp{Need-Update}.  You can
 also run @kbd{M-x cvs-update @key{RET}} (bound to @kbd{M-u} in the
-@samp{*cvs*} buffer) to update all the files.@refill
+@samp{*cvs*} buffer) to update all the files.
 
 You can then press @kbd{=} to easily get a @samp{diff} between your
 modified file and the base version that you started from, or you can
@@ -324,7 +324,7 @@ how we got to the current state, for example @samp{patched},
 
 @item
 An asterisk when the file is @dfn{marked} (@pxref{Selected
-files}).@refill
+files}).
 
 @item
 The actual status of the file wrt the repository.  See below.
@@ -350,7 +350,7 @@ the following substatus:
 @item merged
 The file was modified in your working directory, and there were
 modifications in the repository as well, but they were merged
-successfully, without conflict, in your working directory.@refill
+successfully, without conflict, in your working directory.
 @end table
 
 @item Conflict
@@ -360,7 +360,7 @@ working directory) is now the output of the @code{rcsmerge} command on
 the two versions; an unmodified copy of your file is also in your
 working directory, with the name @file{.#@var{file}.@var{version}},
 where @var{version} is the RCS revision that your modified file started
-from.  @xref{Viewing differences}, for more details.@refill
+from.  @xref{Viewing differences}, for more details.
 
 A conflict can also come from a disagreement on the existence of the file
 rather than on its content.  This case is indicated by the following
@@ -382,17 +382,17 @@ repository.
 
 @item Added
 The file has been added by you, but it still needs to be checked in to
-the repository.@refill
+the repository.
 
 @item Removed
 The file has been removed by you, but it still needs to be checked in to
 the repository.  You can resurrect it by typing @kbd{a} (@pxref{Adding
-and removing files}).@refill
+and removing files}).
 
 @item Unknown
 A file that was detected in your directory, but that neither appears in
 the repository, nor is present on the list of files that CVS should
-ignore.@refill
+ignore.
 
 @item Up-to-date
 The file is up to date with respect to the version in the repository.
@@ -400,29 +400,29 @@ This status can have a substatus of:
 
 @table @samp
 @item added
-You have just added the file to the repository.@refill
+You have just added the file to the repository.
 
 @item updated
 The file was brought up to date with respect to the repository.  This is
 done for any file that exists in the repository but not in your source,
 and for files that you haven't changed but are not the most recent
-versions available in the repository.@refill
+versions available in the repository.
 
 @item patched
 The file was brought up to date with respect to the remote repository by
 way of fetching and applying a patch to the file in your source.  This
 is equivalent to @samp{updated} except that CVS decided to use a hopefully
-more efficient method.@refill
+more efficient method.
 
 @item committed
-You just committed the file.@refill
+You just committed the file.
 @end table
 
 @item Need-Update
 Either a newer version than the one in your source is available in the
 repository and you have not modified your checked out version, or the
 file exists in the repository but not in your source.  Use
-@samp{cvs-mode-update} bound to @kbd{O} to update the file.@refill
+@samp{cvs-mode-update} bound to @kbd{O} to update the file.
 
 @item Need-Merge
 You have modified the checked out version of the file, and a newer
@@ -610,11 +610,11 @@ explicitly.  The special prefixes are:
 
 @table @kbd
 @item T
-Toggles whether or not marks will be active in the next command.@refill
+Toggles whether or not marks will be active in the next command.
 
 @item b
 Provide the next command with a branch (can be any version
-specifier) to work on.@refill
+specifier) to work on.
 
 @item B
 Secondary branch argument.  Only meaningful if @kbd{b} is also used.
@@ -640,13 +640,13 @@ to update the display:
 
 @table @kbd
 @item M-u
-Runs the command @samp{cvs-update}.@refill
+Runs the command @samp{cvs-update}.
 
 @item M-e
-Runs the command @samp{cvs-examine}.@refill
+Runs the command @samp{cvs-examine}.
 
 @item M-s
-Runs the command @samp{cvs-status}.@refill
+Runs the command @samp{cvs-status}.
 @end table
 
 In addition to the above commands which operate on the whole module,
@@ -656,18 +656,18 @@ files/directories with these keys:
 @table @kbd
 @item O
 Runs @code{cvs-mode-update} on the selected files.  When run on the
-top-level directory, this is equivalent to @kbd{M-u}.@refill
+top-level directory, this is equivalent to @kbd{M-u}.
 
 @item e
 Runs @code{cvs-mode-examine} on the selected files.  When run on the
-top-level directory, this is equivalent to @kbd{M-e}.@refill
+top-level directory, this is equivalent to @kbd{M-e}.
 
 @findex cvs-status-mode
 @item s
 Runs @code{cvs-mode-status} on the selected files.  When run on the
 top-level directory, this is equivalent to @kbd{M-s}, except that
 CVS output will be shown in a @samp{*cvs-info*} buffer that will be
-put in @samp{cvs-status-mode}.@refill
+put in @samp{cvs-status-mode}.
 @end table
 
 
@@ -689,7 +689,7 @@ the fact that the buffer is a PCL-CVS buffer:
 @item @key{SPC}
 @itemx n
 These keys move the cursor one file forward, towards the end of the
-buffer (@code{cvs-mode-next-line}).@refill
+buffer (@code{cvs-mode-next-line}).
 
 @item p
 This key moves one file backward, towards the beginning of the buffer
@@ -725,12 +725,12 @@ You can mark and unmark files with these commands:
 @item m
 This marks the file that the cursor is positioned on.  If the cursor is
 positioned on a directory all files in that directory are marked
-(@code{cvs-mode-mark}).@refill
+(@code{cvs-mode-mark}).
 
 @item u
 Unmark the file that the cursor is positioned on. If the cursor is on a
 directory, all files in that directory are unmarked
-(@code{cvs-mode-unmark}).@refill
+(@code{cvs-mode-unmark}).
 
 @item M
 Mark @emph{all} files in the buffer (@code{cvs-mode-mark-all-files}).
@@ -774,7 +774,7 @@ Committing changes basically works as follows:
 @item
 After having selected the files you want to commit, you type either
 @kbd{c} or @kbd{C} which brings up a special buffer
-@samp{*cvs-commit*}.@refill
+@samp{*cvs-commit*}.
 
 @item
 You type in the log message describing the changes you're about to
@@ -782,7 +782,7 @@ commit (@pxref{Log Edit Mode}).
 
 @item
 When you're happy with it, you type @kbd{C-c C-c} to do the actual
-commit.@refill
+commit.
 @end enumerate
 
 There's no hidden state, so you can abort the process or pick it up
@@ -841,13 +841,13 @@ the cursor points to a directory, run @code{dired} on that directory;
 
 @item o
 Like @kbd{f}, but use another window
-(@code{cvs-mode-find-file-other-window}).@refill
+(@code{cvs-mode-find-file-other-window}).
 
 @item A
 Invoke @samp{add-change-log-entry-other-window} to edit a
 @file{ChangeLog} file.  The @file{ChangeLog} file will be found in the
 directory of the file the cursor points to, or in a parent of that
-directory (@code{cvs-mode-add-change-log-entry-other-window}).@refill
+directory (@code{cvs-mode-add-change-log-entry-other-window}).
 @end table
 
 
@@ -897,7 +897,7 @@ Add all selected files.  This command can be used on @samp{Unknown}
 files (@pxref{Buffer contents}).  The status of the file will change to
 @samp{Added}, and you will have to use @kbd{c} (@samp{cvs-mode-commit}
 @pxref{Committing changes}), to really add the file to the
-repository.@refill
+repository.
 
 This command can also be used on @samp{Removed} files (before you commit
 them) to resurrect them.
@@ -911,7 +911,7 @@ confirmation).  The files are deleted from your directory and
 also be @samp{cvs remove}d.  If the files' status was @samp{Unknown}
 they will disappear from the buffer.  Otherwise their status will change to
 @samp{Removed}, and you must use @kbd{c} (@samp{cvs-mode-commit},
-@pxref{Committing changes}) to commit the removal.@refill
+@pxref{Committing changes}) to commit the removal.
 
 The command that is run is @code{cvs-mode-remove-file}.
 @end table
@@ -957,7 +957,7 @@ get an overview of what needs to be done.
 @vindex cvs-mode-remove-handled@r{ (variable)}
 @kbd{x} invokes @code{cvs-mode-remove-handled}.  If
 @samp{cvs-auto-remove-handled} is set to non-@code{nil}, this will
-automatically be performed after every commit.@refill
+automatically be performed after every commit.
 
 @item C-k
 This command can be used for lines that @samp{cvs-mode-remove-handled} would
@@ -1008,22 +1008,22 @@ This runs @code{cvs-mode-ignore}.
 @item =
 @itemx d =
 Display a @samp{cvs diff} between the selected files and the version
-that they are based on (@code{cvs-mode-diff}).@refill
+that they are based on (@code{cvs-mode-diff}).
 
 @item d b
 If CVS finds a conflict while merging two versions of a file (during a
 @samp{cvs update}, @pxref{Updating the buffer}) it will save the
 original file in a file called @file{.#@var{file}.@var{version}} where
 @var{file} is the name of the file, and @var{version} is the revision
-number that @var{file} was based on.@refill
+number that @var{file} was based on.
 
 With the @kbd{d b} command you can run a @samp{diff} on the files
-@file{.#@var{file}.@var{version}} and @file{@var{file}}.@refill
+@file{.#@var{file}.@var{version}} and @file{@var{file}}.
 
 @item d h
 Display a @samp{cvs diff} between the selected files and the head
 revision (the most recent version on the current
-branch) in the repository (@code{cvs-mode-diff-head}).@refill
+branch) in the repository (@code{cvs-mode-diff-head}).
 
 @item d r
 Display a @samp{cvs diff} between the base revision of the selected
@@ -1035,12 +1035,12 @@ a checkout, update or commit operation
 @item d v
 Display a @samp{cvs diff} between the selected files and the head
 revision of the vendor branch in the repository
-(@code{cvs-mode-diff-vendor}).@refill
+(@code{cvs-mode-diff-vendor}).
 
 @item d y
 Display a @samp{cvs diff} between the selected files and yesterday's
 head revision in the repository
-(@code{cvs-mode-diff-yesterday}).@refill
+(@code{cvs-mode-diff-yesterday}).
 @end table
 
 By default, @samp{diff} commands ignore the marks.  This can be changed
@@ -1075,7 +1075,7 @@ to do an interactive 3-way merge.
 CVS has already performed a merge.  The resulting file is not used in
 any way if you use this command.  If you use the @kbd{q} command inside
 @samp{ediff} (to successfully terminate a merge) the file that CVS
-created will be overwritten.@refill
+created will be overwritten.
 @end table
 
 @node Updating files
@@ -1247,24 +1247,24 @@ argument, these commands move that many messages of files.
 
 If you have an idea about any customization that would be handy but
 isn't present in this list, please tell us!
-For info on how to reach us, see @ref{Bugs}.@refill
+For info on how to reach us, see @ref{Bugs}.
 
 @table @samp
 @item cvs-auto-remove-handled
 If this variable is set to any non-@code{nil} value,
 @samp{cvs-mode-remove-handled} will be called every time you check in
 files, after the check-in is ready.  @xref{Removing handled
-entries}.@refill
+entries}.
 
 @item cvs-auto-remove-directories
 If this variable is set to any non-@code{nil} value, directories that do
 not contain any files to be checked in will not be listed in the
-@samp{*cvs*} buffer.@refill
+@samp{*cvs*} buffer.
 
 @item cvs-auto-revert
 If this variable is set to any non-@samp{nil} value any buffers you have
 that visit a file that is committed will be automatically reverted.
-This variable defaults to @samp{t}. @xref{Committing changes}.@refill
+This variable defaults to @samp{t}. @xref{Committing changes}.
 
 @item cvs-update-prog-output-skip-regexp
 The @samp{-u} flag in the @file{modules} file can be used to run a command
index aa0752c80cd4ce506f5415b8e0415f83bfd9f76b..11dbf2eda5e154045d7ffcde53816717de30cd63 100644 (file)
@@ -146,7 +146,7 @@ Supercite should provide them.  For example, many people would like to
 be able to yank (and cite) only a portion of the original message.
 Since Supercite only modifies the text it finds in the reply buffer as
 set up by the MUA, it is the MUA's responsibility to do partial yanking.
-@xref{Reply Buffer Initialization}.@refill
+@xref{Reply Buffer Initialization}.
 
 @vindex mail-header-separator
 Another potentially useful thing would be for Supercite to set up the
@@ -156,7 +156,7 @@ But by previously agreed upon convention, any text above the
 bodies cannot be modified by Supercite.  Supercite, in fact, doesn't
 know anything about the meaning of these headers, and never ventures
 outside the designated region. @xref{Hints to MUA Authors}, for more
-details.@refill
+details.
 
 @node  What Supercite Does
 @section What Supercite Does
@@ -168,14 +168,14 @@ by calling a hook variable to which Supercite's top-level function
 @code{sc-cite-original} has been added.  When @code{sc-cite-original} is
 executed, the original message must be set up in a very specific way,
 but this is handled automatically by the MUA@.  @xref{Hints to MUA
-Authors}.@refill
+Authors}.
 
 @cindex info alist
 The first thing Supercite does, via @code{sc-cite-original}, is to parse
 through the original message's mail headers.  It saves this data in an
 @dfn{information association list}, or @dfn{info alist}.  The information
 in this list is used in a number of places throughout Supercite.
-@xref{Information Keys and the Info Alist}.@refill
+@xref{Information Keys and the Info Alist}.
 
 @cindex nuking mail headers
 @cindex reference header
@@ -207,7 +207,7 @@ Supercited text and will fill them appropriately.  Emacs's built-in
 filling routines, e.g., @code{fill-paragraph}, do not recognize cited
 text and will not re-fill them properly because it cannot guess the
 @code{fill-prefix} being used.
-@xref{Post-yank Formatting Commands}, for details.@refill
+@xref{Post-yank Formatting Commands}, for details.
 
 As mentioned above, Supercite provides commands to recite or uncite
 regions of text in the reply buffer, and commands to perform other
@@ -216,7 +216,7 @@ informative citations throughout.  Supercite tries to be as configurable
 as possible to allow for a wide range of personalized citation styles,
 but it is also immediately useful with the default configuration, once
 it has been properly connected to your MUA@.  @xref{Getting Connected},
-for more details.@refill
+for more details.
 
 @node  Citations
 @chapter Citations
@@ -304,7 +304,7 @@ string containing four spaces.
 The @dfn{attribution string}.  This element is supplied automatically by
 Supercite, based on your preferences and the original message's mail
 headers, though you may be asked to confirm Supercite's choice.
-@xref{Selecting an Attribution}, for more details.@refill
+@xref{Selecting an Attribution}, for more details.
 
 @cindex citation delimiter
 @vindex sc-citation-delimiter
@@ -330,7 +330,7 @@ In this case, the composed, non-nested citation string used might be
 something like
 @code{@asis{"    Jane> "}}.
 This citation string will be inserted in front of
-every line in the original message that is not already cited.@refill
+every line in the original message that is not already cited.
 
 Nested citations, being simpler than non-nested citations, are composed
 of the same elements, sans the attribution string.  Supercite is smart
@@ -379,7 +379,7 @@ non-nested citation.  Thus the variable
 @code{sc-citation-nonnested-root-regexp} is used to describe only
 non-nested citation roots.  It is important to remember that if you
 change @code{sc-citation-root-regexp} you should always also change
-@code{sc-citation-nonnested-root-regexp}.@refill
+@code{sc-citation-nonnested-root-regexp}.
 
 @node  Information Keys and the Info Alist
 @chapter Information Keys and the Info Alist
@@ -400,7 +400,7 @@ In the case of mail fields, the key is the name of the field, omitting
 the trailing colon.  Info keys are always case insensitive (as are
 mail headers), and the value for a corresponding key can be retrieved
 from the alist with the @code{sc-mail-field} function.  Thus, if the
-following fields were present in the original article:@refill
+following fields were present in the original article:
 
 @example
 Date:@: 08 April 1991, 17:32:09 EST
@@ -489,7 +489,7 @@ the author's first middle name.
 
 If the author's name has more than one middle name, they will appear as
 info keys with the appropriate index (e.g., @code{"sc-middlename-2"},
-@dots{}).  @xref{Selecting an Attribution}.@refill
+@dots{}).  @xref{Selecting an Attribution}.
 
 @node  Reference Headers
 @chapter Reference Headers
@@ -540,7 +540,7 @@ examples below as @var{infokey} indicates that the corresponding value
 of the info key from the info alist will be inserted there.
 (@pxref{Information Keys and the Info Alist}).  For example, in @code{sc-header-on-said}
 below, @var{date} and @var{from} correspond to the values of the
-@samp{Date:@:} and @samp{From:@:} mail headers respectively.@refill
+@samp{Date:@:} and @samp{From:@:} mail headers respectively.
 
 @vindex sc-reference-tag-string
 @vindex reference-tag-string (sc-)
@@ -650,7 +650,7 @@ The following commands are available while in electric reference mode
 Displays the next reference header in the electric reference buffer.  If
 the variable @code{sc-electric-circular-p} is non-@code{nil}, invoking
 @code{sc-eref-next} while viewing the last reference header in the list
-will wrap around to the first header.@refill
+will wrap around to the first header.
 
 @item @code{sc-eref-prev} (@kbd{p})
 @findex sc-eref-prev
@@ -658,7 +658,7 @@ will wrap around to the first header.@refill
 @kindex p
 Displays the previous reference header in the electric reference buffer.
 If the variable @code{sc-electric-circular-p} is non-@code{nil},
-invoking @code{sc-eref-prev} will wrap around to the last header.@refill
+invoking @code{sc-eref-prev} will wrap around to the last header.
 
 @item @code{sc-eref-goto} (@kbd{g})
 @findex sc-eref-goto
@@ -667,7 +667,7 @@ invoking @code{sc-eref-prev} will wrap around to the last header.@refill
 Goes to a specified reference header.  The index (into the
 @code{sc-rewrite-header-list}) can be specified as a numeric argument to
 the command.  Otherwise, Supercite will query you for the index in the
-minibuffer.@refill
+minibuffer.
 
 @item @code{sc-eref-jump} (@kbd{j})
 @findex sc-eref-jump
@@ -681,7 +681,7 @@ value of @code{sc-preferred-header-style}.
 @findex eref-setn (sc-)
 @kindex s
 Set the preferred reference header (i.e.,
-@code{sc-preferred-header-style}) to the currently displayed header.@refill
+@code{sc-preferred-header-style}) to the currently displayed header.
 
 @item @code{sc-eref-exit} (@kbd{C-j}, @key{RET}, and @key{ESC C-c})
 @kindex RET
@@ -690,7 +690,7 @@ Set the preferred reference header (i.e.,
 @findex sc-eref-exit
 @findex eref-exit (sc-)
 Exit from electric reference mode and insert the current header into the
-reply buffer.@refill
+reply buffer.
 
 @item @code{sc-eref-abort} (@kbd{q}, @kbd{x})
 @findex sc-eref-abort
@@ -729,7 +729,7 @@ hook variable has a @code{nil} value, which the MUA recognizes to mean,
 ``use your default citation function.''  When you add Supercite's
 citation function to the hook, thereby giving the variable a
 non-@code{nil} value, it tells the MUA to run the hook via
-@code{run-hooks} instead of using the default citation.@refill
+@code{run-hooks} instead of using the default citation.
 
 Early in Supercite's development, the Supercite author, a few MUA
 authors, and some early Supercite users got together and agreed upon a
@@ -767,7 +767,7 @@ expects the original article's mail headers to be present within this
 region.  Note that Supercite @emph{never} touches any text outside this
 region.  Note further that the region need not be active
 for @code{sc-cite-original} to do its job.
-@xref{Hints to MUA Authors}.@refill
+@xref{Hints to MUA Authors}.
 
 The other step in the getting connected process is to make sure your
 MUA calls @code{sc-cite-original} at the right time.  As mentioned
@@ -784,7 +784,7 @@ this hook since it is only run once.  This will not work, however, if
 your Emacs maintainer has put Supercite into your dumped Emacs image.
 In that case, you can use the @code{sc-pre-hook} variable, but this will
 get executed every time @code{sc-cite-original} is called.  @xref{Reply
-Buffer Initialization}.@refill
+Buffer Initialization}.
 
 @node  Replying and Yanking
 @chapter Replying and Yanking
@@ -814,7 +814,7 @@ This hook variable is run before @code{sc-cite-original} does any other
 work.  You could conceivably use this hook to set certain Supercite
 variables based on the reply buffer's mode or name (i.e., to do
 something different based on whether you are replying or following up to
-an article).@refill
+an article).
 
 @item
 @emph{Inserts Supercite's keymap.}
@@ -942,7 +942,7 @@ there as people on the net, or just about!  It would be impossible for
 Supercite to anticipate every style in existence, and you probably
 wouldn't encounter them all anyway.  But you can configure Supercite to
 recognize those styles you see often.
-@xref{Configuring the Citation Engine}, for details.@refill
+@xref{Configuring the Citation Engine}, for details.
 
 @item
 @emph{Runs @code{sc-post-hook}.}
@@ -951,7 +951,7 @@ recognize those styles you see often.
 This variable is very similar to @code{sc-pre-hook}, except that it runs
 after @code{sc-cite-original} is finished.  This hook is provided mostly
 for completeness and backward compatibility.  Perhaps it could be used to
-reset certain variables set in @code{sc-pre-hook}.@refill
+reset certain variables set in @code{sc-pre-hook}.
 @end enumerate
 
 @node  Filling Cited Text
@@ -987,7 +987,7 @@ setup.
 Also, Supercite will collapse leading whitespace between the citation
 string and the text on a line when the variable
 @code{sc-fixup-whitespace-p} is non-@code{nil}.  The default value for
-this variable is @code{nil}.@refill
+this variable is @code{nil}.
 
 @vindex fill-prefix
 Its important to understand that Supercite's automatic filling (during
@@ -1005,7 +1005,7 @@ When Supercite's automatic filling breaks on a particular message, I
 will use Emacs's undo feature to undo back before the citation was
 applied to the original message.  Then I'll toggle the variables and
 manually cite those paragraphs that I don't want to fill or collapse
-whitespace on.  @xref{Variable Toggling Shortcuts}.@refill
+whitespace on.  @xref{Variable Toggling Shortcuts}.
 
 @kindex C-c C-p C-p
 If you find that Supercite's automatic filling is just too fragile for
@@ -1013,7 +1013,7 @@ your tastes, you might consider one of these alternate approaches.
 Also, to make life easier, a shortcut function to toggle the state of
 both of these variables is provided on the key binding
 @kbd{C-c C-p C-p} (with the default value of @code{sc-mode-map-prefix};
-@pxref{Post-yank Formatting Commands}).@refill
+@pxref{Post-yank Formatting Commands}).
 
 You will noticed that the minor mode string will
 show the state of these variables as qualifier characters.  When both
@@ -1025,7 +1025,7 @@ string will display @samp{SC:f}, and when just
 display @samp{SC:fw}.  Note that the qualifiers chosen are mnemonics for
 the default bindings of the toggling function for each respective
 variable.
-@xref{Variable Toggling Shortcuts}.@refill
+@xref{Variable Toggling Shortcuts}.
 
 Why are these variables not set to @code{nil} by default?  It is because
 many users won't manually fill paragraphs that are Supercited, and there
@@ -1088,7 +1088,7 @@ the author's first middle name.
 
 @item "sc-lastchoice"
 the last attribution string you have selected.  This is useful when you
-recite paragraphs in the reply.@refill
+recite paragraphs in the reply.
 
 @item "sc-consult"
 @vindex sc-attrib-selection-list
@@ -1099,7 +1099,7 @@ key.  See below for details.
 
 @item "x-attribution"
 the original author's suggestion for attribution string choice.  See below
-for details.@refill
+for details.
 @end table
 
 Middle name indexes can be any positive integer greater than zero,
@@ -1184,7 +1184,7 @@ case.  If the variable's value is non-@code{nil}, then
 @code{sc-default-author-name} and @code{sc-default-attribution} are
 used, otherwise, the following steps are taken to find a valid
 attribution string, and the first step to return a non-@code{nil},
-non-empty string becomes the attribution:@refill
+non-empty string becomes the attribution:
 
 @enumerate
 @item
@@ -1244,7 +1244,7 @@ variables in your hook functions, you change the attribution and
 citation strings used by Supercite.  One possible use of this would be
 to override any automatically derived attribution string when it is only
 one character long; e.g., you prefer to use @code{"initials"} but the
-author only has one name.@refill
+author only has one name.
 
 @node  Author Names
 @section Author Names
@@ -1376,7 +1376,7 @@ matched against the current line, from the beginning, using
 @code{looking-at}.  This match folds case if the optional
 @var{case-fold-search} is non-@code{nil}.  If @var{pred} is not a
 string, or does not @code{eval}uate to a string, it is interpreted as a
-binary value (@code{nil} or non-@code{nil}).@refill
+binary value (@code{nil} or non-@code{nil}).
 
 The four special symbol values for @var{pred} are recognized:
 
@@ -1405,7 +1405,7 @@ processing.  By default, if your @var{func} returns @code{nil} (as it
 should be careful to do explicitly), Regi will reset the frame to the
 first entry, and advance @samp{point} to the beginning of the next line.
 If a list is returned from your function, it can contain any combination
-of the following elements:@refill
+of the following elements:
 
 @table @asis
 @item the symbol @code{continue}
@@ -1422,16 +1422,16 @@ entry is still processed.
 This tells Regi to substitute @var{newframe} as the frame it is
 interpreting.  In other words, your @var{func} can modify the Regi frame
 on the fly.  @var{newframe} can be a variable containing a frame, or it
-can be the frame in-lined.@refill
+can be the frame in-lined.
 
 @item the list @code{(step . @var{step})}
 Tells Regi to move @var{step} number of lines forward as it continues
 processing.  By default, Regi moves forward one line.  @var{step} can be
-zero or negative of course, but watch out for infinite loops.@refill
+zero or negative of course, but watch out for infinite loops.
 @end table
 
 During execution of your @var{func}, the following variables will be
-temporarily bound to some useful information:@refill
+temporarily bound to some useful information:
 
 @table @code
 @item curline
@@ -1471,7 +1471,7 @@ preferred style.
 In a similar vein, there are default frames for @dfn{unciting} and
 @dfn{reciting}, contained in the variables
 @code{sc-default-uncite-frame} and @code{sc-default-recite-frame}
-respectively.@refill
+respectively.
 
 As mentioned earlier (@pxref{Recognizing Citations}), citations are
 recognized through the values of the regular expressions
@@ -1500,7 +1500,7 @@ Where @var{infokey} is a key suitable for @code{sc-mail-field},
 @var{regexp} is a regular expression which is @code{string-match}'d
 against the value of the @code{sc-mail-field} key, and @var{frame} is
 the frame to use if a match occurred.  @var{frame} can be a variable
-containing a frame or a frame in-lined.@refill
+containing a frame or a frame in-lined.
 
 When Supercite is about to cite, uncite, or recite a region, it consults
 the appropriate alist and attempts to find a frame to use.  If one
@@ -1524,7 +1524,7 @@ variable @code{sc-mode-map-prefix}.  By default, the
 @code{sc-mode-map-prefix} is @kbd{C-c C-p}; granted, not a great choice,
 but unfortunately the best general solution so far.  In the rest of this
 chapter, we'll assume you've installed Supercite's keymap on the default
-prefix.@refill
+prefix.
 
 @menu
 * Citing Commands::
@@ -1546,7 +1546,7 @@ paragraph to use a nickname, or manually cite a message when setting
 perform these functions on the region of text between @samp{point} and
 @samp{mark}.  Each of them sets the @dfn{undo boundary} before modifying
 the region so that the command can be undone in the standard Emacs
-way.@refill
+way.
 
 Here is the list of Supercite citing commands:
 
@@ -1567,7 +1567,7 @@ frame @code{sc-default-cite-frame}.  It runs the hook
 universal argument (@kbd{C-u}), it temporarily sets
 @code{sc-confirm-always-p} to @code{t} so you can confirm the
 attribution string for a single manual citing.
-@xref{Configuring the Citation Engine}.@refill
+@xref{Configuring the Citation Engine}.
 
 @findex sc-uncite-region
 @findex uncite-region (sc-)
@@ -1578,7 +1578,7 @@ cited line in the region by interpreting the selected frame from
 @code{sc-uncite-frame-alist}, or the default unciting frame
 @code{sc-default-uncite-frame}.  It runs the hook
 @code{sc-pre-uncite-hook} before interpreting the frame.
-@xref{Configuring the Citation Engine}.@refill
+@xref{Configuring the Citation Engine}.
 
 @findex sc-recite-region
 @findex recite-region (sc-)
@@ -1588,7 +1588,7 @@ This command recites each line the region by interpreting the selected
 frame from @code{sc-recite-frame-alist}, or the default reciting frame
 @code{sc-default-recite-frame}.  It runs the hook
 @code{sc-pre-recite-hook} before interpreting the frame.
-@xref{Configuring the Citation Engine}.@refill
+@xref{Configuring the Citation Engine}.
 
 @vindex sc-confirm-always-p
 @vindex confirm-always-p (sc-)
@@ -1612,7 +1612,7 @@ Inserts a reference header into the reply buffer at @samp{point}.  With
 no arguments, the header indexed by @code{sc-preferred-header-style} is
 inserted.  An optional numeric argument is the index into
 @code{sc-rewrite-header-list} indicating which reference header to
-write.@refill
+write.
 
 With just the universal argument (@kbd{C-u}), electric reference mode is
 entered, regardless of the value of @code{sc-electric-references-p}.
@@ -1640,7 +1640,7 @@ this easy to do.
 Like Supercite commands in general, the toggling commands are placed on
 a keymap prefix within the greater Supercite keymap.  For the default
 value of @code{sc-mode-map-prefix}, this will be
-@kbd{C-c C-p C-t}.@refill
+@kbd{C-c C-p C-t}.
 
 The following commands toggle the value of certain Supercite variables
 which take only a binary value:
@@ -1700,7 +1700,7 @@ One special command is provided to toggle both
 @code{sc-auto-fill-region-p} and @code{sc-fixup-whitespace-p} together.
 This is because you typically want to run Supercite with either variable
 as @code{nil} or non-@code{nil}.  The command to toggle these variables
-together is bound on @kbd{C-c C-p C-p}.@refill
+together is bound on @kbd{C-c C-p C-p}.
 
 Finally, the command @kbd{C-c C-p C-t h} (also @kbd{C-c C-p C-t ?})
 brings up a Help message on the toggling keymap.
@@ -1711,7 +1711,7 @@ brings up a Help message on the toggling keymap.
 
 These commands allow you to view, modify, add, and delete various bits
 of information from the info alist.
-@xref{Information Keys and the Info Alist}.@refill
+@xref{Information Keys and the Info Alist}.
 
 @table @asis
 @kindex C-c C-p f
@@ -1753,7 +1753,7 @@ This function is especially useful for replying to digest messages where
 Supercite will initially set up its information for the digest
 originator, but you want to cite each component article with the real
 message author.  Note that unless an error during processing occurs, any
-old information is lost.@refill
+old information is lost.
 @end table
 
 @node  Miscellaneous Commands
@@ -1767,7 +1767,7 @@ old information is lost.@refill
 @item @code{sc-open-line} (@kbd{C-c C-p o})
 Similar to Emacs's standard @code{open-line} commands, but inserts the
 citation string in front of the new line.  As with @code{open-line},
-an optional numeric argument inserts that many new lines.@refill
+an optional numeric argument inserts that many new lines.
 @end table
 
 @node  Hints to MUA Authors
@@ -1810,7 +1810,7 @@ the release of Emacs 19.  Instead of the variable
 @code{mail-yank-hooks}, the hook variable that the MUA should provide is
 @code{mail-citation-hook}.  Richard Stallman suggests that the MUAs
 should @code{defvar} @code{mail-citation-hook} to @code{nil} and perform
-some default citing when that is the case.@refill
+some default citing when that is the case.
 
 If you are writing a new MUA package, or maintaining an existing MUA
 package, you should make it conform to this interface so that your users
@@ -1826,7 +1826,7 @@ buffer.  At this point you should not modify the raw text in any way
 you should place all the original headers into the body of the reply.
 This means that many of the mail headers will be duplicated, one copy
 above the @code{mail-header-separator} line and one copy below, however
-there will probably be more headers below this line.@refill
+there will probably be more headers below this line.
 
 @item
 Set @samp{point} to the beginning of the line containing the first mail
@@ -1835,7 +1835,7 @@ message text.  It is very important that the region be set around the
 text Supercite is to modify and that the mail headers are within this
 region.  Supercite will not venture outside the region for any reason,
 and anything within the region is fair game, so don't put anything that
-@strong{must} remain unchanged inside the region.@refill
+@strong{must} remain unchanged inside the region.
 
 @item
 Run the hook @code{mail-citation-hook}.  You will probably want to
@@ -1846,7 +1846,7 @@ yanking function, check its value.  If it finds
 @code{mail-citation-hook} to be @code{nil}, it should perform some
 default citing behavior.  User who want to connect to Supercite then
 need only add @code{sc-cite-original} to this list of hooks using
-@code{add-hook}.@refill
+@code{add-hook}.
 @end enumerate
 
 If you do all this your MUA will join the ranks of those that conform to
index d76f9e091844e6a9b615fe84d4f0f47cac30334f..2a3cfdf09933dfdbed622f12ecbcae6249ff13e5 100644 (file)
@@ -247,7 +247,6 @@ features of the current file name, user name, time, etc.
 
 Some arguments are major-mode specific, such as the @code{:el} or
 @code{:cpp} arguments.
-@refill
 
 @section Template Insertion Context
 A context can be provided for templates in a file.  This helps
@@ -257,7 +256,6 @@ contexts to have the same name.  Some standard contexts are
 
 A context can be automatically derived as well based on the parsing
 state from @i{Semantic}.  @inforef{Top, Semantic Manual, semantic}.
-@refill
 
 @section Applications
 Commands that do a particular user task which involves also writing
@@ -781,7 +779,6 @@ All the text and macros within a section are either not shown at all
 (if that section is not 'visible') or the section is shown one time
 for each dictionary added to that symbol.
 @xref{Developing Template Functions}.
-@refill
 
 Macros prefixed with ``>'' will include another template.  Include
 macros would look like this:
index 7c998b37010098df63d35a651d8ee3c351a7cb89..28e78f5d381275d0bd974eedcf16148a8cf2a235 100644 (file)
@@ -56,7 +56,7 @@ you start using VIP@.  Other nodes may be visited as needed.
 
 Comments and bug reports are welcome.  Please send messages to
 @code{ms@@Sail.Stanford.Edu} if you are outside of Japan and to
-@code{masahiko@@sato.riec.tohoku.junet} if you are in Japan.@refill
+@code{masahiko@@sato.riec.tohoku.junet} if you are in Japan.
 
 @insertcopying
 
@@ -128,14 +128,13 @@ the character; otherwise we say that point is @dfn{at the end of buffer}.
 @key{PNT} and @key{MRK} are used
 to indicate positions in a buffer and they are not part of the text of the
 buffer.  If a buffer contains a @key{MRK} then the text between @key{MRK}
-and @key{PNT} is called the @dfn{region} of the buffer.@refill
+and @key{PNT} is called the @dfn{region} of the buffer.
 
 @cindex window
 
 Emacs provides (multiple) @dfn{windows} on the screen, and you can see the
 content of a buffer through the window associated with the buffer.  The
 cursor of the screen is always positioned on the character after @key{PNT}.
-@refill
 
 @cindex mode
 @cindex keymap
@@ -149,7 +148,7 @@ buffers.  Each buffer has its @dfn{local keymap} that determines the
 a function is bound to some key in the local keymap then that function will
 be executed when you type the key.  If no function is bound to a key in the
 local map, however, the function bound to the key in the global map becomes
-in effect.@refill
+in effect.
 
 @node Loading VIP
 @section Loading VIP
@@ -187,7 +186,7 @@ Loading VIP has the effect of globally binding @kbd{C-z} (@kbd{Control-z})
 to the function @code{vip-change-mode-to-vi}. The default binding of @kbd{C-z}
 in GNU Emacs is @code{suspend-emacs}, but, you can also call
 @code{suspend-emacs} by typing @kbd{C-x C-z}.  Other than this, all the
-key bindings of Emacs remain the same after loading VIP.@refill
+key bindings of Emacs remain the same after loading VIP.
 
 @cindex vi mode
 
@@ -198,12 +197,12 @@ called and you will be in @dfn{vi mode}.  (Some major modes may locally bind
 invoked by @kbd{M-x}.  Here @kbd{M-x} means @kbd{Meta-x}, and if your
 terminal does not have a @key{META} key you can enter it by typing
 @kbd{@key{ESC} x}.  The same effect can also be achieve by typing
-@kbd{M-x vip-mode}.)@refill
+@kbd{M-x vip-mode}.)
 
 @cindex mode line
 
 You can observe the change of mode by looking at the @dfn{mode line}.  For
-instance, if the mode line is:@refill
+instance, if the mode line is:
 @example
 -----Emacs: *scratch*              (Lisp Interaction)----All------------
 @end example
@@ -219,7 +218,7 @@ Thus the word @samp{Emacs} in the mode line will change to @samp{Vi}.
 @cindex emacs mode
 
 You can go back to the original @dfn{emacs mode} by typing @kbd{C-z} in
-vi mode.  Thus @kbd{C-z} toggles between these two modes.@refill
+vi mode.  Thus @kbd{C-z} toggles between these two modes.
 
 Note that modes in VIP exist orthogonally to modes in Emacs.  This means
 that you can be in vi mode and at the same time, say, shell mode.
@@ -265,7 +264,7 @@ emacs mode             vi mode                 insert mode
 You will be in this mode just after you loaded VIP@.  You can do all
 normal Emacs editing in this mode.  Note that the key @kbd{C-z} is globally
 bound to @code{vip-change-mode-to-vi}.  So, if you type @kbd{C-z} in this mode
-then you will be in vi mode.@refill
+then you will be in vi mode.
 
 @node Vi Mode
 @subsection Vi Mode
@@ -332,7 +331,7 @@ The major differences from Vi are explained below.
 You can repeat undoing by the @kbd{.} key.  So, @kbd{u} will undo
 a single change, while @kbd{u .@: .@: .@:}, for instance, will undo 4 previous
 changes.  Undo is undoable as in Vi.  So the content of the buffer will
-be the same before and after @kbd{u u}.@refill
+be the same before and after @kbd{u u}.
 
 @node Changing
 @subsection Changing
@@ -345,7 +344,7 @@ then VIP will prompt you for a new word in the minibuffer by the prompt
 @key{ESC} to complete the command.  Before you enter @key{RET} or
 @key{ESC} you can abort the command by typing @kbd{C-g}.  In general,
 @kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})
-you can abort a partially formed command by typing @kbd{C-g}.@refill
+you can abort a partially formed command by typing @kbd{C-g}.
 
 @node Searching
 @subsection Searching
@@ -361,7 +360,7 @@ A search for empty string will toggle the search mode between vanilla
 search and regular expression search.  You cannot give an offset to the
 search string.  (It is a limitation.)  By default, search will wrap around
 the buffer as in Vi.  You can change this by rebinding the variable
-@code{vip-search-wrap-around}.  @xref{Customization}, for how to do this.@refill
+@code{vip-search-wrap-around}.  @xref{Customization}, for how to do this.
 
 @node z Command
 @subsection z Command
@@ -376,7 +375,7 @@ the buffer as in Vi.  You can change this by rebinding the variable
 For those of you who cannot remember which of @kbd{z} followed by @key{RET},
 @kbd{.}@: and @kbd{-} do what.  You can also use @kbd{z} followed by @kbd{H},
 @kbd{M} and @kbd{L} to place the current line in the Home (Middle, and
-Last) line of the window.@refill
+Last) line of the window.
 
 @node Counts
 @subsection Counts
@@ -436,7 +435,7 @@ delimited by point and mark.)  The key @kbd{r} is used for this purpose.
 Thus @kbd{d r} will delete the current region.  If @kbd{R} is used instead
 of @kbd{r} the region will first be enlarged so that it will become the
 smallest region containing the original region and consisting of whole
-lines.  Thus @kbd{m .@: d R} will have the same effect as @kbd{d d}.@refill
+lines.  Thus @kbd{m .@: d R} will have the same effect as @kbd{d d}.
 
 @node New Commands
 @subsection Some New Commands
@@ -478,7 +477,7 @@ can execute a single Emacs command.  After executing the Emacs command you
 will be in vi mode again.  You can give a count before typing @kbd{\}.
 Thus @kbd{5 \ *}, as well as @kbd{\ C-u 5 *}, will insert @samp{*****}
 before point.  Similarly @kbd{1 0 \ C-p} will move the point 10 lines above
-the current line.@refill
+the current line.
 @item K
 @kindex 113 @kbd{K} (@code{vip-kill-buffer})
 Kill current buffer if it is not modified.  Useful when you selected a
@@ -504,7 +503,7 @@ similar, but will use window different from the current window.
 If followed by a certain character @var{ch}, it becomes an operator whose
 argument is the region determined by the motion command that follows.
 Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q} and
-@kbd{s}.@refill
+@kbd{s}.
 @item # c
 @kindex 0432 @kbd{# c} (@code{downcase-region})
 Change upper-case characters in the region to lower case
@@ -517,7 +516,7 @@ Change lower-case characters in the region to upper case. For instance,
 @item # g
 @kindex 0432 @kbd{# g} (@code{vip-global-execute})
 Execute last keyboard macro for each line in the region
-(@code{vip-global-execute}).@refill
+(@code{vip-global-execute}).
 @item # q
 @kindex 0432 @kbd{# q} (@code{vip-quote-region})
 Insert specified string at the beginning of each line in the region
@@ -577,7 +576,7 @@ mode.  You get the same effect by typing @kbd{C-x C-s} in vi mode, but
 the idea here is that you can execute useful Emacs commands without typing
 control characters. For example, if you hit @kbd{X} (or @kbd{C-x}) followed
 by @kbd{2}, then the current window will be split into 2 and you will be in
-vi mode again.@refill
+vi mode again.
 @end table
 
 In addition to these, @code{ctl-x-map} is slightly modified:
@@ -723,7 +722,7 @@ Most Vi commands accept a @dfn{numeric argument} which can be supplied as
 a prefix to the commands.  A numeric argument is also called a @dfn{count}.
 In many cases, if a count is given, the command is executed that many times.
 For instance, @kbd{5 d d} deletes 5 lines while simple @kbd{d d} deletes a
-line.  In this manual the metavariable @var{n} will denote a count.@refill
+line.  In this manual the metavariable @var{n} will denote a count.
 
 @node Important Keys
 @section Important Keys
@@ -742,7 +741,7 @@ Clear the screen and reprint everything (@code{recenter}).
 
 In Emacs many commands are bound to the key strokes that start with
 @kbd{C-x}, @kbd{C-c} and @key{ESC}.  These commands can be
-accessed from vi mode as easily as from emacs mode.@refill
+accessed from vi mode as easily as from emacs mode.
 
 @table @kbd
 @item C-x
@@ -772,7 +771,7 @@ Escape to emacs mode.  Hitting the @kbd{\} key will take you to emacs mode,
 and you can execute a single Emacs command.  After executing the
 Emacs command you will be in vi mode again.  You can give a count before
 typing @kbd{\}.  Thus @kbd{5 \ +}, as well as @kbd{\ C-u 5 +}, will insert
-@samp{+++++} before point.@refill
+@samp{+++++} before point.
 @end table
 
 @node Buffers and Windows
@@ -784,7 +783,7 @@ typing @kbd{\}.  Thus @kbd{5 \ +}, as well as @kbd{\ C-u 5 +}, will insert
 
 In Emacs the text you edit is stored in a @dfn{buffer}.
 See GNU Emacs Manual, for details.  There is always one @dfn{current}
-buffer, also called the @dfn{selected buffer}.@refill
+buffer, also called the @dfn{selected buffer}.
 
 @cindex window
 @cindex modified (buffer)
@@ -883,7 +882,7 @@ file in the current window, you can just type @kbd{v}.  Emacs maintains the
 @dfn{default directory} which is specific to each buffer.  Suppose, for
 instance, that the default directory of the current buffer is
 @file{/usr/masahiko/lisp/}.  Then you will get the following prompt in the
-minibuffer.@refill
+minibuffer.
 @example
 visit file: /usr/masahiko/lisp/
 @end example
@@ -911,7 +910,7 @@ window.
 
 You can verify which file you are editing by typing @kbd{g}.  (You can also
 type @kbd{X B} to get information on other buffers too.)  If you type
-@kbd{g} you will get an information like below in the echo area:@refill
+@kbd{g} you will get an information like below in the echo area:
 @example
 "/usr/masahiko/man/vip.texinfo" line 921 of 1949
 @end example
@@ -921,7 +920,7 @@ you may wish to save it in a file.  If you wish to save it in the file
 associated with the buffer (@file{/usr/masahiko/man/vip.texinfo}, in this
 case), you can just say @kbd{X S}.  If you wish to save it in another file,
 you can type @kbd{X W}.  You will then get a similar prompt as you get for
-@kbd{v}, to which you can enter the file name.@refill
+@kbd{v}, to which you can enter the file name.
 
 @node Viewing the Buffer
 @section Viewing the Buffer
@@ -1453,7 +1452,7 @@ For example, if point is at the beginning of a word @samp{foo} and you
 wish to change it to @samp{bar}, you can type @kbd{c w}.  Then, as @kbd{w}
 is a point command, you will get the prompt @samp{foo =>} in the
 minibuffer, for which you can type @kbd{b a r @key{RET}} to complete the change
-command.@refill
+command.
 
 @table @kbd
 @item c c
index 8b4c9e93f7c27a1c2dcd15246d0c0ddce47d128c..db5a5736888665b69b3b7f8c57a9b28af4456b64 100644 (file)
@@ -88,7 +88,7 @@ be visited as needed.
 
 Comments and bug reports are welcome.
 @code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
-Please use the Ex command @kbd{:submitReport} for this purpose.@refill
+Please use the Ex command @kbd{:submitReport} for this purpose.
 
 @insertcopying
 @end ifnottex
@@ -147,7 +147,7 @@ comes with Emacs.  This manual can be read as an Info file.  Try the command
 
 Comments and bug reports are welcome.
 @code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
-Please use the Ex command @kbd{:submitReport} for this purpose.@refill
+Please use the Ex command @kbd{:submitReport} for this purpose.
 
 @end iftex
 
@@ -197,21 +197,21 @@ Emacs can edit several files at once.  A file in Emacs is placed in a
 @dfn{buffer} that usually has the same name as the file.  Buffers are also used
 for other purposes, such as shell interfaces, directory editing, etc.
 @xref{Dired,,Directory Editor,emacs,The
-GNU Emacs Manual}, for an example.@refill
+GNU Emacs Manual}, for an example.
 
 A buffer has a distinguished position called the @dfn{point}.
 A @dfn{point} is always between 2 characters, and is @dfn{looking at}
 the right hand character.  The cursor is positioned on the right hand
 character.  Thus, when the @dfn{point} is looking at the end-of-line,
 the cursor is on the end-of-line character, i.e., beyond the last
-character on the line.  This is the default Emacs behavior.@refill
+character on the line.  This is the default Emacs behavior.
 
 The default settings of Viper try to mimic the behavior of Vi, preventing
 the cursor from going beyond the last character on the line.  By using
 Emacs commands directly (such as those bound to arrow keys), it is possible
 to get the cursor beyond the end-of-line.  However, this won't (or
 shouldn't) happen if you restrict yourself to standard Vi keys, unless you
-modify the default editing style.  @xref{Customization}.@refill
+modify the default editing style.  @xref{Customization}.
 
 In addition to the @dfn{point}, there is another distinguished buffer
 position called the @dfn{mark}.  @xref{Mark,,Mark,emacs,The GNU Emacs
@@ -232,7 +232,7 @@ assuming that the current region starts at line 123 and ends at line
 135.  There is no need to type the line numbers, since Viper inserts them
 automatically in front of the Ex command.
 
-@xref{Basics}, for more info.@refill
+@xref{Basics}, for more info.
 
 @cindex window
 @cindex mode line
@@ -255,7 +255,7 @@ show the buffer name and current major and minor modes (see below).
 A special buffer called @dfn{Minibuffer} is displayed as the last line
 in a minibuffer window.  The minibuffer window is used for command input
 output.  Viper uses minibuffer window for @kbd{/} and @kbd{:}
-commands.@refill
+commands.
 
 @cindex mode
 @cindex keymap
@@ -275,7 +275,7 @@ keymap then that function will be executed when you type the key.
 If no function is bound to a key in the
 local map, however, the function bound to the key in the global map
 will be executed.  @xref{Major Modes,Major Modes,Major Modes,emacs,The
-GNU Emacs Manual}, for more information.@refill
+GNU Emacs Manual}, for more information.
 
 A buffer can also have a @dfn{minor mode}.  Minor modes are options that
 you can use or not.  A buffer in @code{text-mode} can have
@@ -283,7 +283,7 @@ you can use or not.  A buffer in @code{text-mode} can have
 any time.  In Emacs, a minor mode may have it own keymap,
 which overrides the local keymap when the minor mode is turned on.  For
 more information, @pxref{Minor Modes,Minor Modes,Minor Modes,emacs,The
-GNU Emacs Manual} @refill
+GNU Emacs Manual}.
 
 @cindex Viper as minor mode
 @cindex Control keys
@@ -293,7 +293,7 @@ Viper is implemented as a collection of minor modes.  Different minor modes
 are involved when Viper emulates Vi command mode, Vi insert mode, etc.
 You can also turn Viper on and off at any time while in Vi command mode.
 @xref{States in Viper}, for
-more information.@refill
+more information.
 
 Emacs uses Control and Meta modifiers.  These are denoted as C and M,
 e.g., @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}.  The Meta key is
@@ -303,7 +303,7 @@ holding the Meta key down.  For keyboards that do not have a Meta key,
 @key{ESC} is used as Meta.  Thus @kbd{M-x} is typed as @kbd{@key{ESC}
 x}.  Viper uses @key{ESC} to switch from Insert state to Vi state.  Therefore
 Viper defines @kbd{C-\} as its Meta key in Vi state.  @xref{Vi State}, for
-more info.@refill
+more info.
 
 Emacs is structured as a Lisp interpreter around a C core.  Emacs keys
 cause Lisp functions to be called.  It is possible to call these
@@ -357,7 +357,7 @@ command line, it will show the @samp{*scratch*} buffer, in the
 editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands.
 (@xref{File and Buffer Handling}, for more information on @kbd{v} and other
 new commands that, in many cases, are more convenient than @kbd{:e},
-@kbd{:vi}, and similar old-style Vi commands.)@refill
+@kbd{:vi}, and similar old-style Vi commands.)
 
 Finally, if at some point you would want to de-Viperize your running
 copy of Emacs after Viper has been loaded, the command @kbd{M-x
@@ -386,7 +386,7 @@ This is the state plain vanilla Emacs is normally in.  After you have loaded
 Viper, @kbd{C-z} will normally take you to Vi command state.  Another
 @kbd{C-z} will take you back to Emacs state.  This toggle key can be
 changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to
-change to Vi state.@refill
+change to Vi state.
 
 
 For users who chose to set their user level to 1 at Viper setup time,
@@ -424,7 +424,7 @@ boundary of a replacement region (usually designated via a @samp{$} sign),
 it will automatically change to Insert state.  You do not have to worry
 about it.  The key bindings remain practically the same as in Insert
 state.  If you type @key{ESC}, Viper will switch to Vi command mode, terminating the
-replacement state.@refill
+replacement state.
 @end table
 
 @cindex mode line
@@ -488,7 +488,7 @@ for editing LaTeX documents, Dired for directory editing, etc.  These are
 major modes, each with a different set of key-bindings.  Viper states are
 orthogonal to these Emacs major modes.  The presence of these language
 sensitive and other modes is a major win over Vi.  @xref{Improvements over
-Vi}, for more.@refill
+Vi}, for more.
 
 The bindings for these modes can be made available in the Viper Insert state
 as well as in Emacs state.  Unless you specify your user level as 1 (a
@@ -541,7 +541,6 @@ functionality and no key-binding.  Recursive edits are indicated by
 Edit,Recursive Edit,emacs,The GNU Emacs Manual}.
 At user level 1, @kbd{C-g} is bound to @code{viper-info-on-file}
 function instead.
-@refill
 @item C-\
 @kindex @kbd{C-\}
 @cindex Meta key
@@ -652,7 +651,6 @@ In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire
 command will appear in the history list.  This is because having @kbd{:r}
 alone as a default is meaningless, since this command requires a file
 argument.
-@refill
 @end table
 @noindent
 As in Vi, Viper's destructive commands can be re-executed by typing `@kbd{.}'.
@@ -673,7 +671,7 @@ Emacs major modes cannot be used in Insert state.
 It is strongly recommended that as soon as you are comfortable, make the
 Emacs state bindings visible (by changing your user level to 3 or higher).
 @xref{Customization},
-to see how to do this.@refill
+to see how to do this.
 
 Once this is done, it is possible to do quite a bit of editing in
 Insert state.  For instance, Emacs has a @dfn{yank} command, @kbd{C-y},
@@ -823,13 +821,13 @@ If you set marker @samp{a} in
 file @file{foo}, start editing file @file{bar} and type @kbd{'a}, then
 @emph{YOU WILL SWITCH TO FILE @file{foo}}.  You can see the contents of a
 textmarker using the Viper command @kbd{[<a-z>} where <a-z> are the
-textmarkers, e.g., @kbd{[a} to view marker @samp{a} .@refill
+textmarkers, e.g., @kbd{[a} to view marker @samp{a} .
 @item Repeated Commands
 Command repetitions are common over files.  Typing @kbd{!!} will repeat the
 last @kbd{!} command whichever file it was issued from.
 Typing @kbd{.} will repeat the last command from any file, and
 searches will repeat the last search.  Ex commands can be repeated by typing
-@kbd{: @key{RET}}.@refill
+@kbd{: @key{RET}}.
 Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous.
 However, usually its effect can be undone by typing @kbd{u}.
 @item Registers
@@ -897,7 +895,7 @@ more powerful facilities for defining abbreviations.
 it is not implemented.
 A useful alternative is @code{cat -t -e file}.  Unfortunately, it cannot
 be used directly inside Emacs, since Emacs will obdurately change @samp{^I}
-back to normal tabs.@refill
+back to normal tabs.
 @end itemize
 
 @node Improvements over Vi
@@ -928,7 +926,7 @@ The Vi command set is based on the idea of combining motion commands
 with other commands.  The motion command is used as a text region
 specifier for other commands.
 We classify motion commands into @dfn{point commands} and
-@dfn{line commands}.@refill
+@dfn{line commands}.
 
 @cindex point commands
 
@@ -1010,7 +1008,7 @@ direction.
 Since the undo size is limited, Viper can create backup files and
 auto-save files.  It will normally do this automatically.  It is possible
 to have numbered backups, etc.  For details, @pxref{Backup,,Backup and
-Auto-Save,emacs,The GNU Emacs Manual} @refill
+Auto-Save,emacs,The GNU Emacs Manual}.
 
 @comment [ balance parens
 @cindex viewing registers and markers
@@ -1083,7 +1081,7 @@ where @samp{register} is any character from @samp{a} through @samp{z}.  Then
 you can execute this macro using @kbd{@@register}.  It is, of course,
 possible to yank some text into a register and execute it using
 @kbd{@@register}.  Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will
-execute the last macro that was executed using @kbd{@@register}.@refill
+execute the last macro that was executed using @kbd{@@register}.
 
 Viper will automatically lowercase the register, so that pressing the
 @kbd{SHIFT} key for @kbd{@@} will not create problems.  This is for
@@ -1105,7 +1103,7 @@ The last keyboard macro can also be executed using
 This is useful for Emacs style keyboard macros defined using @kbd{C-x(}
 and @kbd{C-x)}.  Emacs keyboard macros have more capabilities.
 @xref{Keyboard Macros,,Keyboard Macros,emacs, The GNU Emacs Manual}, for
-details.@refill
+details.
 
 Keyboard Macros allow an interesting form of Query-Replace:
 @kbd{/pattern} or @kbd{n} to go to the next pattern (the query), followed by a
@@ -1161,7 +1159,7 @@ as you go along.  Incremental Search is normally bound to @kbd{C-s} and
 @kbd{C-r}.  @xref{Customization}, to find out how to change the bindings
 of @kbd{C-r or C-s}.
 For details, @pxref{Incremental Search,,Incremental
-Search,emacs,The GNU Emacs Manual} @refill
+Search,emacs,The GNU Emacs Manual}.
 
 @cindex query replace
 
@@ -1308,7 +1306,7 @@ into 2.  Except for novice users, @kbd{C-c} is also set to execute an Emacs
 command from the current major mode.  @key{ESC} will do the same, if you
 configure @key{ESC} as Meta by setting @code{viper-no-multiple-ESC} to @code{nil}
 in @file{.viper}.  @xref{Customization}.  @kbd{C-\} in Insert, Replace, or Vi
-states will make Emacs think @kbd{Meta} has been hit.@refill
+states will make Emacs think @kbd{Meta} has been hit.
 @item \
 @kindex @kbd{\}
 Escape to Emacs to execute a single Emacs command.  For instance,
@@ -1339,7 +1337,7 @@ argument is the region determined by the motion command that follows
 (indicated as <move>).
 Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q}, and
 @kbd{s}.  For instance, @kbd{#qr} will prompt you for a string and then
-prepend this string to each line in the buffer.@refill
+prepend this string to each line in the buffer.
 @item # c
 @kindex @kbd{#c<move>}
 @cindex changing case
@@ -1355,7 +1353,7 @@ Emacs command @kbd{M-u} does the same for words.
 @item # g
 @kindex @kbd{#g<move>}
 Execute last keyboard macro for each line in the region
-(@code{viper-global-execute}).@refill
+(@code{viper-global-execute}).
 @item # q
 @kindex @kbd{#q<move>}
 Insert specified string at the beginning of each line in the region
@@ -1401,7 +1399,7 @@ Go to end of heading.
 @item g <@emph{movement command}>
 Search buffer for text delimited by movement command.  The canonical
 example is @kbd{gw} to search for the word under the cursor.
-@xref{Improved Search}, for details.@refill
+@xref{Improved Search}, for details.
 @item C-g and C-]
 @kindex @kbd{C-g}
 @kindex @kbd{C-]}
@@ -1560,7 +1558,7 @@ patches.
 @noindent
 Emacs Lisp archives exist on
 @samp{archive.cis.ohio-state.edu}
-and @samp{wuarchive.wustl.edu}@refill
+and @samp{wuarchive.wustl.edu}
 
 
 @node Customization
@@ -1583,7 +1581,7 @@ Elisp code in your @file{.emacs} file before and after the @code{(require
 'viper)} line.  This method is @emph{not} recommended, unless you know what
 you are doing.  Only two variables, @code{viper-mode} and
 @code{viper-custom-file-name}, are supposed to be customized in @file{.emacs},
-prior to loading Viper (i.e., prior to @code{(require 'viper)} command.@refill
+prior to loading Viper (i.e., prior to @code{(require 'viper)} command.
 @item
 @cindex :customize
 By executing the @kbd{:customize} Ex command. This takes you to the Emacs
@@ -2780,7 +2778,7 @@ macros) lets the user define keyboard macros that ask for confirmation or
 even prompt the user for input and then continue.  To do this, one should
 type @kbd{C-x q} (for confirmation) or @kbd{C-u C-x q} (for prompt).
 For details, @pxref{Keyboard Macro Query,,Customization,emacs,The GNU Emacs
-Manual} @refill
+Manual}.
 
 When the user finishes defining a macro (which is done by typing @kbd{C-x)},
 a departure from Vi), you will be asked whether you want this
@@ -2994,7 +2992,7 @@ currently defined.  To see all macros along with their definitions, type
 
 This section is a semi-automatically bowdlerized version of the Vi
 reference created by @* @samp{maart@@cs.vu.nl} and others.  It can be
-found on the Vi archives.  This reference has been adapted for Viper.@refill
+found on the Vi archives.  This reference has been adapted for Viper.
 
 @menu
 * Groundwork::                  Textual Conventions and Viper basics
@@ -3015,7 +3013,7 @@ The VI command set is based on the idea of combining motion commands
 with other commands.  The motion command is used as a text region
 specifier for other commands.
 We classify motion commands into @dfn{point commands} and
-@dfn{line commands}.@refill
+@dfn{line commands}.
 
 @cindex point commands
 
@@ -4187,7 +4185,7 @@ the whole file.
 @cindex @samp{#} (Previous file)
 Similarly, @samp{#} expands to the previous file.  The previous file is the
 first file in @kbd{:args} listing.  This defaults to the previous file in
-the VI sense if you have one window.@refill
+the VI sense if you have one window.
 
 Symbols @samp{%} and @samp{#} are also used in the Ex commands @kbd{:e} and
 @kbd{:r <shell-cmd>}.  The commands @kbd{:w} and the regular @kbd{:r
@@ -4425,7 +4423,7 @@ a region under the mouse pointer.
 This command can take a prefix argument.  Note: Viper sets this
 binding only if this mouse action is not
 already bound to something else.
-@xref{Viper Specials}, for more information.@refill
+@xref{Viper Specials}, for more information.
 
 @item S-Mouse-2
 Holding Shift and clicking button 2 of the mouse will
@@ -4433,7 +4431,7 @@ insert a region surrounding the mouse pointer.
 This command can also take a prefix argument.
 Note: Viper sets this binding only if this mouse action is not
 already bound to something else.
-@xref{Viper Specials}, for more details.@refill
+@xref{Viper Specials}, for more details.
 @end table
 @kindex @kbd{S-Mouse-1}
 @kindex @kbd{S-Mouse-2}
index f2c403a2c14593727afcd5a95c3a7bfb51861a07..2fe247dd7503a13128cb01d361dd48c24997ef77 100644 (file)
@@ -431,7 +431,6 @@ Set up a buffer to support widgets.
 
 This should be called after creating all the widgets and before allowing
 the user to edit them.
-@refill
 @end defun
 
 If you want to insert text outside the widgets in the form, the
@@ -450,7 +449,7 @@ There is a standard widget keymap which you might find useful.
 @key{TAB} and @kbd{C-@key{TAB}} are bound to @code{widget-forward} and
 @code{widget-backward}, respectively.  @key{RET} and @kbd{Mouse-2}
 are bound to @code{widget-button-press} and
-@code{widget-button-click}.@refill
+@code{widget-button-click}.
 @end defvr
 
 @defvar widget-global-map
@@ -1718,7 +1717,7 @@ Keymap used in @code{widget-minor-mode}.
 @defun widget-prompt-value widget prompt [ value unbound ]
 Prompt for a value matching @var{widget}, using @var{prompt}.
 The current value is assumed to be @var{value}, unless @var{unbound} is
-non-@code{nil}.@refill
+non-@code{nil}.
 @end defun
 
 @defun widget-get-sibling widget
index 6527a7ab365c836765ac0ba2d7390eb28bb8f386..120f4d4db1caa1b949005841a608332fe947f874 100644 (file)
@@ -1,3 +1,11 @@
+2013-11-18  Leo Liu  <sdl.web@gmail.com>
+
+       * NEWS: Mention new features for Octave mode.
+
+2013-11-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * NEWS: Mention :distant-foreground.
+
 2013-10-16  Dmitry Gutov  <dgutov@yandex.ru>
 
        * NEWS: Mention the homepage-related changes in package.el.
index 247da3f9a1ada65ee8639c6405f55fbb9ce47c20..132c461b25821876c4ad521e2a13de7c667ca215 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -62,6 +62,10 @@ To use the old backend by default, do on the command line:
 \f
 * Startup Changes in Emacs 24.4
 
++++
+** The -L option, which normally prepends its argument to load-path,
+will instead append, if the argument begins with `:'.
+
 \f
 * Changes in Emacs 24.4
 
@@ -176,9 +180,18 @@ some enhancements, like the ability to restore deleted frames.  Command
 ** The default value of `comment-use-global-state' is changed to t,
 and this variable has been marked obsolete.
 
+** `fill-single-char-nobreak-p' prevents fill from breaking a line after
+a 1-letter word, which is an error according to Polish and
+Czech typography rules.  To globally enable this feature, evaluate:
+
+  (add-hook 'fill-nobreak-predicate 'fill-single-char-nobreak-p)
+
 \f
 * Editing Changes in Emacs 24.4
 
+** Command `rectangle-mark-mode' bound to C-x SPC makes a rectangular region.
+Most commands are still unaware of it, but kill/yank do work on the rectangle.
+
 ** C-x TAB enters a transient interactive mode.
 You can then use the left/right cursor keys to move the block of text.
 
@@ -216,6 +229,14 @@ You can pick the name of the function and the variables with `C-x 4 a'.
 \f
 * Changes in Specialized Modes and Packages in Emacs 24.4
 
+** prolog-use-smie has been removed, along with the non-SMIE indentation code.
+
+** SMIE indentation can be customized via `smie-config'.
+The customization can be guessed by Emacs by providing a sample indented
+file and letting SMIE learn from it.
+
+** sh-script now uses its SMIE indentation algorithm by default.
+
 ** The debugger's `e' command evaluates the code in the context at point.
 This includes using the lexical environment at point, which means that
 `e' now lets you access lexical variables as well.
@@ -387,6 +408,14 @@ This is useful to avoid a query when you have no key for that name.
 will revert to the old behavior.
 
 
+** New features for Octave mode:
+*** Font locking for texinfo comments and new keywords
+*** Completion in Octave file buffers
+*** Eldoc support
+*** Jump to definition
+*** Documentation lookup/search
+*** Code cleanup and various bug fixes
+
 ** Ido
 *** Ido has a manual now.
 *** `ido-use-virtual-buffers' takes a new value 'auto.
@@ -566,6 +595,8 @@ display a `Homepage' header, if it's present.
 
 ** Obsolete packages:
 
+*** Iswitchb is made obsolete by icomplete-mode.
+
 *** longlines.el is obsolete; use visual-line-mode instead.
 
 +++
@@ -591,6 +622,9 @@ During initialization, Emacs no longer expends a process to decide
 whether it is safe to use Bash's --noediting option.  These days
 --noediting is ubiquitous; it was introduced in 1996 in Bash version 2.
 
++++
+** There is a new macro `skip-unless' for skipping ERT tests.  See the manual.
+
 \f
 * New Modes and Packages in Emacs 24.4
 
@@ -620,6 +654,8 @@ low-level libraries gfilenotify.c, inotify.c or w32notify.c.
 \f
 * Incompatible Lisp Changes in Emacs 24.4
 
+** `kill-region' lost its `yank-handler' optional argument.
+
 ** `(input-pending-p)' no longer runs other timers which are ready to
 run.  The new optional CHECK-TIMERS param allows for the prior behavior.
 
@@ -681,6 +717,8 @@ for something (not just adding elements to it), it ought not to affect you.
 \f
 * Lisp Changes in Emacs 24.4
 
+** New hook `pre-redisplay-function'.
+
 +++
 ** Functions that pop up menus and dialogs now work on all terminal types,
 including TTYs.
@@ -714,6 +752,10 @@ frame.
 +++
 ** New macro with-eval-after-load.  Like eval-after-load, but better behaved.
 
+** New library helpers.el for misc helper functions
+*** `hash-table-keys'
+*** `hash-table-values'
+
 ** Obsoleted functions:
 *** `log10'
 *** `dont-compile'
@@ -770,6 +812,10 @@ rather than inheriting from it (as do face specs set via Customize).
 *** New face characteristic (supports :underline (:style wave))
 specifies whether or not the terminal can display a wavy line.
 
+*** New face spec attribute :distant-foreground
+specifies foreground to use if background color is near the foreground
+color that would otherwise have been used.
+
 ** Image API
 
 +++
index 4d16d1925ebc7d47682a28b9bbd2a7542bf355c8..c02213623fd4d8c82f0d0c7032de407904bf43c8 100644 (file)
 ORG NEWS -- history of user-visible changes.           -*- org -*-
 
 #+LINK: doc http://orgmode.org/worg/doc.html#%s
+#+LINK: git http://orgmode.org/w/?p=org-mode.git;a=commit;h=%s
 
 Copyright (C) 2012-2013 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Org bug reports to emacs-orgmode@gnu.org.
 
+* Version 8.2.3
+
+** Incompatible changes
+
+*** Combine org-mac-message.el and org-mac-link-grabber into org-mac-link.el
+
+Please remove calls to =(require 'org-mac-message)= and =(require
+'org-mac-link-grabber)= in your =.emacs= initialization file.  All you
+need now is =(require 'org-mac-link)=.
+
+Additionally, replace any calls to =ogml-grab-link= to
+=org-mac-grab-link=.  For example, replace this line:
+
+: (define-key org-mode-map (kbd "C-c g") 'omgl-grab-link)
+
+with this:
+
+: (define-key org-mode-map (kbd "C-c g") 'org-mac-grab-link)
+
+*** HTML export: Replace =HTML_HTML5_FANCY= by =:html-html5-fancy= (...)
+
+Some of the HTML specific export options in Org <8.1 are either nil or
+t, like =#+HTML_INCLUDE_STYLE=.  We replaced these binary options with
+option keywords like :html-include-style.
+
+So you need to replace
+
+: #+HTML_INCLUDE_STYLE: t
+
+by
+
+: #+OPTIONS: :html-include-style t
+
+Options affected by this change: =HTML5_FANCY=, =HTML_INCLUDE_SCRIPTS=
+and =HTML_INCLUDE_STYLE=.
+
+*** Add an argument to ~org-export-to-file~ and ~org-export-to-buffer~
+
+~org-export-to-file~ and ~org-export-to-file~ can run in a different
+process when provided a non-nil =ASYNC= optional argument, without
+relying on ~org-export-async-start~ macro.
+
+Since =ASYNC= is the first of optional arguments, you have to shift
+the other optional arguments accordingly.
+
+*** Export back-ends are now structures
+
+Export back-ends are now structures, and stored as such in the
+communication channel during an export process.  In other words, from
+now on, ~(plist-get info :back-end)~ will return a structure instead
+of a symbol.
+
+Arguments in hooks and in filters are still symbols, though.
+
+** Important bugfixes
+
+*** [[doc:org-insert-heading][org-insert-heading]] has been rewritten and bugs are now fixed
+*** The replacement of disputed keys is now turned of when reading a date
+
+*** Match string for sparse trees can now contain a slash in a property value
+
+    You can now have searches like SOMEPROP="aaa/bbb".  Until now,
+    this would break because the slash would be interpreted as the
+    separator starting a TOTO match string.
+** New features
+
+*** =C-c ^ x= will now sort checklist items by their checked status
+
+See [[doc:org-sort-list][org-sort-list]]: hitting =C-c ^ x= will put checked items at the end
+of the list.
+*** Various LaTeX export enhancements
+
+- Support SVG images
+- Support for .pgf files
+- LaTeX Babel blocks can now be exported as =.tikz= files
+- Allow =latexmk= as an option for [[doc:org-latex-pdf-process][org-latex-pdf-process]]
+- When using =\usepackage[AUTO]{babel}=, AUTO will automatically be
+  replaced with a value compatible with ~org-export-default-language~
+  or ~LANGUAGE~ keyword.
+- The dependency on the =latexsym= LaTeX package has been removed, we
+  now use =amssymb= symbols by default instead.
+
+*** New functions for paragraph motion
+
+    The commands =C-down= and =C-up= now invoke special commands
+    that use knowledge from the org-elements parser to move the cursor
+    in a paragraph-like way.
+
+*** New entities in =org-entities.el=
+
+Add support for ell, imath, jmath, varphi, varpi, aleph, gimel, beth,
+dalet, cdots, S (§), dag, ddag, colon, therefore, because, triangleq,
+leq, geq, lessgtr, lesseqgtr, ll, lll, gg, ggg, prec, preceq,
+preccurlyeq, succ, succeq, succurlyeq, setminus, nexist(s), mho,
+check, frown, diamond.  Changes loz, vert, checkmark, smile and tilde.
+
+*** Anonymous export back-ends
+
+~org-export-create-backend~ can create anonymous export back-ends,
+which can then be passed to export functions like
+~org-export-to-file~, ~org-export-to-buffer~ or ~org-export-as~.
+
+It allows for quick translation of Org syntax without the overhead of
+registering a new back-end.
+
+*** New agenda fortnight view
+
+    The agenda has not, in addition to day, week, month, and year
+    views, also a fortnight view covering 14 days.
+** New options
+
+*** New option [[doc:org-bookmark-names-plist][org-bookmark-names-plist]]
+
+This allows to specify the names of automatic bookmarks.
+*** New option [[doc:org-agenda-ignore-drawer-properties][org-agenda-ignore-drawer-properties]]
+
+This allows more flexibility when optimizing the agenda generation.
+See http://orgmode.org/worg/agenda-optimization.html for details.
+*** New option: [[doc:org-html-link-use-abs-url][org-html-link-use-abs-url]] to force using absolute URLs
+
+This is an export/publishing option, and should be used either within
+the =#+OPTIONS= line(s) or within a [[doc:org-publish-project-alist][org-publish-project-alist]].
+
+Setting this option to =t= is needed when the HTML output does not
+allow relative URLs.  For example, the =contrib/lisp/ox-rss.el=
+library produces a RSS feed, and RSS feeds need to use absolute URLs,
+so a combination of =:html-link-home "..." and :html-link-use-abs-url
+t= is required---see the configuration example in the comment section
+of =ox-rss.el=.
+
+*** New option [[doc:org-babel-ditaa-java-cmd][org-babel-ditaa-java-cmd]]
+
+This makes java executable configurable for ditaa blocks.
+
+*** New options [[doc:org-babel-latex-htlatex][org-babel-latex-htlatex]] and [[doc:org-babel-latex-htlatex-packages][org-babel-latex-htlatex-packages]]
+
+This enables SVG generation from latex code blocks.
+
+*** New option: [[doc:org-habit-show-done-always-green][org-habit-show-done-always-green]]
+
+See [[http://lists.gnu.org/archive/html/emacs-orgmode/2013-05/msg00214.html][this message]] from Max Mikhanosha.
+
+*** New option: [[doc:org-babel-inline-result-wrap][org-babel-inline-result-wrap]]
+
+If you set this to the following
+
+: (setq org-babel-inline-result-wrap "$%s$")
+
+then inline code snippets will be wrapped into the formatting string.
+
+*** New option: [[doc:org-special-ctrl-o][org-special-ctrl-o]]
+
+    This variable can be used to turn off the special behavior of
+    =C-o= in tables.
+** New contributed packages
+
+- =ox-bibtex.el= by Nicolas Goaziou :: an utility to handle BibTeX
+     export to both LaTeX and HTML exports.  It uses the [[http://www.lri.fr/~filliatr/bibtex2html/][bibtex2html]]
+     software.
+
+- =org-screenshot.el= by Max Mikhanosha :: an utility to handle
+     screenshots easily from Org, using the external tool [[http://freecode.com/projects/scrot][scrot]].
+
+* Version 8.0.1
+
+** Installation
+
+Installation instructions have been updated and simplified.
+
+If you have troubles installing or updating Org, focus on these
+instructions:
+
+- when updating via a =.zip/.tar.gz= file, you only need to set the
+  =load-path= in your =.emacs=.  Set it before any other Org
+  customization that would call autoloaded Org functions.
+
+- when updating by pulling Org's Git repository, make sure to create the
+  correct autoloads.  You can do this by running =~$ make autoloads= (to
+  only create the autoloads) or by running =~$ make= (to also compile
+  the Emacs lisp files.)  =~$ make help= and =~$ make helpall= gives you
+  detailed explanations.
+
+- when updating through ELPA (either from GNU ELPA or from Org ELPA),
+  you have to install Org's ELPA package in a session where no Org
+  function has been called already.
+
+When in doubt, run =M-x org-version RET= and see if you have a mixed-up
+installation.
+
+See http://orgmode.org/org.html#Installation for details.
+
+** Incompatible changes
+
+Org 8.0 is the most disruptive major version of Org.
+
+If you configured export options, you will have to update some of them.
+
+If you used =#+ATTR_*= keywords, the syntax of the attributes changed and
+you will have to update them.
+
+Below is a list of changes for which you need to take action.
+
+See http://orgmode.org/worg/org-8.0.html for the most recent version of
+this list and for detailed instructions on how to migrate.
+
+**** New export engine
+
+Org 8.0 comes with a new export engine written by Nicolas Goaziou.  This
+export engine relies on ~org-element.el~ (Org's syntax parser), which was
+already in Org's core.  This new export engine triggered the rewriting of
+/all/ export back-ends.
+
+The most visible change is the export dispatcher, accessible through the
+keybinding =C-c C-e=.  By default, this menu only shows some of the
+built-in export formats, but you can add more formats by loading them
+directly (e.g., =(require 'ox-texinfo)= or by configuring the option
+[[doc:org-export-backends][org-export-backends]].
+
+More contributed back-ends are available from the =contrib/= directory, the
+corresponding files start with the =ox-= prefix.
+
+If you customized an export back-end (like HTML or LaTeX), you will need to
+rename some options so that your customization is not lost.  Typically, an
+option starting with =org-export-html-= is now named =org-html-=.  See the
+manual for details and check [[http://orgmode.org/worg/org-8.0.html][this Worg page]] for directions.
+
+**** New syntax for #+ATTR_HTML/LaTeX/... options
+
+     : #+ATTR_HTML width="200px"
+
+     should now be written
+
+     : #+ATTR_HTML :width 200px
+
+     Keywords like =#+ATTR_HTML= and =#+ATTR_LaTeX= are defined in their
+     respective back-ends, and the list of supported parameters depends on
+     each backend.  See Org's manual for details.
+
+**** ~org-remember.el~ has been removed
+
+     You cannot use =remember.el= anymore to capture notes.
+
+     Support for remember templates has been obsoleted since long, it is
+     now fully removed.
+
+     Use =M-x org-capture-import-remember-templates RET= to import your
+     remember templates into capture templates.
+
+**** ~org-jsinfo.el~ has been merged into ~ox-html.el~
+
+     If you were requiring ~ox-jsinfo.el~ in your ~.emacs.el~ file, you
+     will have to remove this requirement from your initialization file.
+
+**** Note for third-party developers
+
+     The name of the files for export back-end have changed: we now use the
+     prefix =ox-= for those files (like we use the =ob-= prefix for Babel
+     files.)  For example ~org-html.el~ is now ~ox-html.el~.
+
+     If your code relies on these files, please update the names in your
+     code.
+
+**** Packages moved from core to contrib
+
+     Since packages in Org's core are meant to be part of GNU Emacs, we try
+     to be minimalist when it comes to adding files into core.  For 8.0, we
+     moved some contributions into the =contrib/= directory.
+
+     The rationale for deciding that these files should live in =contrib/=
+     is either because they rely on third-party software that is not
+     included in Emacs, or because they are not targeting a significant
+     user-base.
+
+     - org-colview-xemacs.el
+     - org-mac-message.el
+     - org-mew.el
+     - org-wl.el
+     - ox-freedmind.el
+     - ox-taskjuggler.el
+
+     Note that ~ox-freedmind.el~ has been rewritten by Jambunathan,
+     ~org-mew.el~ has been enhanced by Tokuya Kameshima and
+     ~ox-taskjuggler.el~ by Nicolas Goaziou and others.
+
+     Also, the Taskjuggler exporter now uses TJ3 by default.  John Hendy
+     wrote [[http://orgmode.org/worg/org-tutorials/org-taskjuggler3.html][a tutorial on Worg]] for the TJ3 export.
+
+** New packages in core
+
+*** ~ob-makefile.el~ by Eric Schulte and Thomas S. Dye
+
+    =ob-makefile.el= implements Org Babel support for Makefile tangling.
+
+*** ~ox-man.el~ by Luis Anaya
+
+    =ox-man.el= allows you to export Org files to =man= pages.
+
+*** ~ox-md.el~ by Nicolas Goaziou
+
+    =ox-md.el= allows you to export Org files to Markdown files, using the
+    vanilla [[http://daringfireball.net/projects/markdown/][Markdown syntax]].
+
+*** ~ox-texinfo.el~ by Jonathan Leech-Pepin
+
+    =ox-texinfo.el= allows you to export Org files to [[http://www.gnu.org/software/texinfo/][Texinfo]] files.
+
+** New packages in contrib
+
+*** ~ob-julia.el~ by G. Jay Kerns
+
+    [[http://julialang.org/][Julia]] is a new programming language.
+
+    =ob-julia.el= provides Org Babel support for evaluating Julia source
+    code.
+
+*** ~ob-mathomatic.el~ by Luis Anaya
+
+    [[http://www.mathomatic.org/][mathomatic]] a portable, command-line, educational CAS and calculator
+    software, written entirely in the C programming language.
+
+    ~ob-mathomatic.el~ provides Org Babel support for evaluating mathomatic
+    entries.
+
+*** ~ob-tcl.el~ by Luis Anaya
+
+    ~ob-tcl.el~ provides Org Babel support for evaluating [[http://www.tcl.tk/][Tcl]] source code.
+
+*** ~org-bullets.el~ by Evgeni Sabof
+
+    Display bullets instead of stars for headlines.
+
+    Also see [[http://orgmode.org/worg/org-faq.html#sec-8-12][this updated FAQ]] on how to display another character than "*"
+    for starting headlines.
+
+*** ~org-favtable.el~ by Marc-Oliver Ihm
+
+    ~org-favtable.el~ helps you to create and update a table of favorite
+    locations in org, keeping the most frequently visited lines right at
+    the top.  This table is called "favtable".  See the documentation on
+    [[http://orgmode.org/worg/org-contrib/org-favtable.html][Worg]].
+
+*** ~ox-confluence.el~ by Sébastien Delafond
+
+    ~ox-confluence.el~ lets you convert Org files to [[https://confluence.atlassian.com/display/DOC/Confluence%2BWiki%2BMarkup][Confluence Wiki]] files.
+
+*** ~ox-deck.el~ and ~ox-s5.el~ by Rick Frankel
+
+    [[http://imakewebthings.com/deck.js/][deck.js]] is a javascript library for displaying HTML ages as
+    presentations.  ~ox-deck.el~ exports Org files to HTML presentations
+    using =deck.js=.
+
+    [[http://meyerweb.com/eric/tools/s5/][s5]] is a set of scripts which also allows to display HTML pages as
+    presentations.  ~ox-s5.el~ exports Org files to HTML presentations
+    using =s5=.
+
+*** ~ox-groff.el~ by Luis Anaya and Nicolas Goaziou
+
+    The [[http://www.gnu.org/software/groff/][groff]] (GNU troff) software is a typesetting package which reads
+    plain text mixed with formatting commands and produces formatted
+    output.
+
+    Luis Anaya and Nicolas Goaziou implemented ~ox-groff.el~ to allow
+    conversion from Org files to groff.
+
+*** ~ox-koma-letter.el~ by Nicolas Goaziou and Alan Schmitt
+
+    This back-end allow to export Org pages to the =KOMA Scrlttr2= format.
+
+*** ~ox-rss.el~ by Bastien
+
+    This back-end lets you export Org pages to RSS 2.0 feeds.  Combined
+    with the HTML publishing feature, this allows you to build a blog
+    entirely with Org.
+
+** New features
+
+*** Export
+
+**** New export generic options
+
+If you use Org exporter, we advise you to re-read [[http://orgmode.org/org.html#Exporting][the manual section about
+it]].  It has been updated and includes new options.
+
+Among the new/updated export options, three are of particular importance:
+
+- [[doc:org-export-allow-bind-keywords][org-export-allow-bind-keywords]] :: This option replaces the old option
+     =org-export-allow-BIND= and the default value is =nil=, not =confirm=.
+     You will need to explicitly set this to =t= in your initialization
+     file if you want to allow =#+BIND= keywords.
+
+- [[doc:org-export-with-planning][org-export-with-planning]] :: This new option controls the export of
+     =SCHEDULED:, DEADLINE:, CLOSED:= lines, and planning information is
+     now skipped by default during export.  This use to be the job of
+     [[doc:org-export-with-timestamps][org-export-with-timestamps]], but this latter option has been given a
+     new role: it controls the export of /standalone time-stamps/.  When
+     set to =nil=, Org will not export active and inactive time-stamps
+     standing on a line by themselves or within a paragraph that only
+     contains time-stamps.
+
+To check if an option has been introduced or its default value changed in
+Org 8.0, do =C-h v [option] RET= and check if the documentation says that
+the variable has been introduced (or changed) in version 24.4 of Emacs.
+
+**** Enhanced default stylesheet for the HTML exporter
+
+See the new default value of [[doc:org-html-style-default][org-html-style-default]].
+
+**** New tags, classes and ids for the HTML exporter
+
+See the new default value of [[doc:org-html-divs][org-html-divs]].
+
+**** Support for tikz pictures in LaTeX export
+**** ~org-man.el~: New export function for "man" links
+**** ~org-docview.el~: New export function for docview links
+*** Structure editing
+
+**** =C-u C-u M-RET= inserts a heading at the end of the parent subtree
+**** Cycling to the =CONTENTS= view keeps inline tasks folded
+
+[[doc:org-cycle-hook][org-cycle-hook]] as a new function [[doc:org-cycle-hide-inline-tasks][org-cycle-hide-inline-tasks]] which
+prevents the display of inline tasks when showing the content of a subtree.
+
+**** =C-c -= in a region makes a list item for each line
+
+This is the opposite of the previous behavior, where =C-c -= on a region
+would create one item for the whole region, and where =C-u C-c -= would
+create an item for each line.  Now =C-c -= on the selected region creates
+an item per line, and =C-u C-c -= creates a single item for the whole
+region.
+
+**** When transposing words, markup characters are now part of the words
+
+In Emacs, you can transpose words with =M-t=.  Transposing =*these*
+_words__= will preserve markup.
+
+**** New command [[doc:org-set-property-and-value][org-set-property-and-value]] bound to =C-c C-x P=
+
+This command allows you to quickly add both the property and its value.  It
+is useful in buffers where there are many properties and where =C-c C-x p=
+can slow down the flow of editing too much.
+
+**** New commands [[doc:org-next-block][org-next-block]] and [[doc:org-previous-block][org-previous-block]]
+
+These commands allow you to go to the previous block (=C-c M-b= or the
+speedy key =B=) or to the next block (=C-c M-f= or the speedy key =F=.)
+
+**** New commands [[doc:org-drag-line-forward][org-drag-line-forward]] and [[doc:org-drag-line-backward][org-drag-line-backward]]
+
+These commands emulate the old behavior of =M-<down>= and =M-<up>= but are
+now bound to =S-M-<down>= and =S-M-<up>= respectively, since =M-<down>= and
+=M-<up>= now drag the whole element at point (a paragraph, a table, etc.)
+forward and backward.
+
+**** When a list item has a checkbox, inserting a new item uses a checkbox too
+**** When sorting entries/items, only the description of links is considered
+
+Now Org will sort this list
+
+: - [[http://abc.org][B]]
+: - [[http://def.org][A]]
+
+like this:
+
+: - [[http://def.org][A]]
+: - [[http://abc.org][B]]
+
+by comparing the descriptions, not the links.
+Same when sorting headlines instead of list items.
+**** New option =orgstruct-heading-prefix-regexp=
+
+For example, setting this option to "^;;; " in Emacs lisp files and using
+=orgstruct-mode= in those files will allow you to cycle through visibility
+states as if lines starting with ";;; *..." where headlines.
+
+In general, you want to set =orgstruct-heading-prefix-regexp= as a file
+local variable.
+
+**** New behavior of [[doc:org-clone-subtree-with-time-shift][org-clone-subtree-with-time-shift]]
+
+The default is now to ask for a time-shift only when there is a time-stamp.
+When called with a universal prefix argument =C-u=, it will not ask for a
+time-shift even if there is a time-stamp.
+
+**** New option [[doc:org-agenda-restriction-lock-highlight-subtree][org-agenda-restriction-lock-highlight-subtree]]
+
+This defaults to =t= so that the whole subtree is highlighted when you
+restrict the agenda view to it with =C-c C-x <= (or the speed command =<=).
+The default setting helps ensuring that you are not adding tasks after the
+restricted region.  If you find this highlighting too intrusive, set this
+option to =nil=.
+**** New option [[doc:org-closed-keep-when-no-todo][org-closed-keep-when-no-todo]]
+
+When switching back from a =DONE= keyword to a =TODO= keyword, Org now
+removes the =CLOSED= planning information, if any.  It also removes this
+information when going back to a non-TODO state (e.g., with =C-c C-t SPC=).
+If you want to keep the =CLOSED= planning information when removing the
+TODO keyword, set [[doc:org-closed-keep-when-no-todo][org-closed-keep-when-no-todo]] to =t=.
+
+**** New option [[doc:org-image-actual-width][org-image-actual-width]]
+
+This option allows you to change the width of in-buffer displayed images.
+The default is to use the actual width of the image, but you can use a
+fixed value for all images, or fall back on an attribute like
+
+: #+attr_html: :width 300px
+*** Scheduled/deadline
+
+**** Implement "delay" cookies for scheduled items
+
+If you want to delay the display of a scheduled task in the agenda, you can
+now use a delay cookie like this: =SCHEDULED: <2004-12-25 Sat -2d>=.  The
+task is still scheduled on the 25th but will appear in your agenda starting
+from two days later (i.e. from March 27th.)
+
+Imagine for example that your co-workers are not done in due time and tell
+you "we need two more days".  In that case, you may want to delay the
+display of the task in your agenda by two days, but you still want the task
+to appear as scheduled on March 25th.
+
+In case the task contains a repeater, the delay is considered to affect all
+occurrences; if you want the delay to only affect the first scheduled
+occurrence of the task, use =--2d= instead.  See [[doc:org-scheduled-delay-days][org-scheduled-delay-days]]
+and [[doc:org-agenda-skip-scheduled-delay-if-deadline][org-agenda-skip-scheduled-delay-if-deadline]] for details on how to
+control this globally or per agenda.
+
+**** Use =C-u C-u C-c C-s= will insert a delay cookie for scheduled tasks
+
+See the previous section for why delay cookies may be useful.
+
+**** Use =C-u C-u C-c C-d= will insert a warning delay for deadline tasks
+
+=C-u C-u C-c C-d= now inserts a warning delay to deadlines.
+*** Calendar, diary and appts
+
+**** New variable [[doc:org-read-date-minibuffer-local-map][org-read-date-minibuffer-local-map]]
+
+By default, this new local map uses "." to go to today's date, like in the
+normal =M-x calendar RET=.  If you want to deactivate this and to reassign
+the "@" key to =calendar-goto-today=, use this:
+
+#+BEGIN_SRC emacs-lisp
+  ;; Unbind "." in Org's calendar:
+  (define-key org-read-date-minibuffer-local-map (kbd ".") nil)
+
+  ;; Bind "@" to `calendar-goto-today':
+  (define-key org-read-date-minibuffer-local-map
+              (kbd "@")
+              (lambda () (interactive) (org-eval-in-calendar '(calendar-goto-today))))
+#+END_SRC
+
+**** In Org's calendar, =!= displays diary entries of the date at point
+
+This is useful when you want to check if you don't already have an
+appointment when setting new ones with =C-c .= or =C-c s=.  =!= will
+call =diary-view-entries= and display the diary in a separate buffer.
+
+**** [[doc:org-diary][org-diary]]: only keep the descriptions of links
+
+[[doc:org-diary][org-diary]] returns diary information from Org files, but it returns it
+in a diary buffer, not in an Org mode buffer.  When links are displayed,
+only show their description, not the full links.
+*** Agenda
+
+**** New agenda type =agenda*= and entry types =:scheduled* :deadline*=
+
+When defining agenda custom commands, you can now use =agenda*=: this will
+list entries that have both a date and a time.  This is useful when you
+want to build a list of appointments.
+
+You can also set [[doc:org-agenda-entry-types][org-agenda-entry-types]] either globally or locally in
+each agenda custom command and use =:timestamp*= and/or =:deadline*= there.
+
+Another place where this is useful is your =.diary= file:
+
+: %%(org-diary :scheduled*) ~/org/rdv.org
+
+This will list only entries from =~/org/rdv.org= that are scheduled with a
+time value (i.e. appointments).
+
+**** New agenda sorting strategies
+
+[[doc:org-agenda-sorting-strategy][org-agenda-sorting-strategy]] allows these new sorting strategies:
+
+| Strategy       | Explanations                             |
+|----------------+------------------------------------------|
+| timestamp-up   | Sort by any timestamp, early first       |
+| timestamp-down | Sort by any timestamp, late first        |
+| scheduled-up   | Sort by scheduled timestamp, early first |
+| scheduled-down | Sort by scheduled timestamp, late first  |
+| deadline-up    | Sort by deadline timestamp, early first  |
+| deadline-down  | Sort by deadline timestamp, late first   |
+| ts-up          | Sort by active timestamp, early first    |
+| ts-down        | Sort by active timestamp, late first     |
+| tsia-up        | Sort by inactive timestamp, early first  |
+| tsia-down      | Sort by inactive timestamp, late first   |
+
+**** New options to limit the number of agenda entries
+
+You can now limit the number of entries in an agenda view.  This is
+different from filters: filters only /hide/ the entries in the agenda,
+while limits are set while generating the list of agenda entries.
+
+These new options are available:
+
+- [[doc:org-agenda-max-entries][org-agenda-max-entries]] :: limit by number of entries.
+- [[doc:org-agenda-max-todos][org-agenda-max-todos]] :: limit by number of TODOs.
+- [[doc:org-agenda-max-tags][org-agenda-max-tags]] :: limit by number of tagged entries.
+- [[doc:org-agenda-max-effort][org-agenda-max-effort]] :: limit by effort (minutes).
+
+For example, if you locally set [[doc:org-agenda-max-todos][org-agenda-max-todos]] to 3 in an agenda
+view, the agenda will be limited to the first three todos.  Other entries
+without a TODO keyword or beyond the third TODO headline will be ignored.
+
+When setting a limit (e.g. about an effort's sum), the default behavior is
+to exclude entries that cannot be checked against (e.g. entries that have
+no effort property.)  To include other entries too, you can set the limit
+to a negative number.  For example =(setq org-agenda-max-tags -3)= will not
+show the fourth tagged headline (and beyond), but it will also show
+non-tagged headlines.
+
+**** =~= in agenda view sets temporary limits
+
+You can hit =~= in the agenda to temporarily set limits: this will
+regenerate the agenda as if the limits were set.  This is useful for
+example when you want to only see a list of =N= tasks, or a list of tasks
+that take only =N= minutes.
+
+**** "=" in agenda view filters by regular expressions
+
+You can now filter agenda entries by regular expressions using ~=~.  =C-u
+== will filter entries out.  Regexp filters are cumulative.  You can set
+[[doc:org-agenda-regexp-filter-preset][org-agenda-regexp-filter-preset]] to suit your needs in each agenda view.
+
+**** =|= in agenda view resets all filters
+
+Since it's common to combine tag filters, category filters, and now regexp
+filters, there is a new command =|= to reset all filters at once.
+
+**** Allow writing an agenda to an =.org= file
+
+You can now write an agenda view to an =.org= file.  It copies the
+headlines and their content (but not subheadings) into the new file.
+
+This is useful when you want to quickly share an agenda containing the full
+list of notes.
+
+**** New commands to drag an agenda line forward (=M-<down>=) or backward (=M-<up>=)
+
+It sometimes handy to move agenda lines around, just to quickly reorganize
+your tasks, or maybe before saving the agenda to a file.  Now you can use
+=M-<down>= and =M-<up>= to move the line forward or backward.
+
+This does not persist after a refresh of the agenda, and this does not
+change the =.org= files who contribute to the agenda.
+
+**** Use =%b= for displaying "breadcrumbs" in the agenda view
+
+[[doc:org-agenda-prefix-format][org-agenda-prefix-format]] now allows to use a =%b= formatter to tell Org
+to display "breadcrumbs" in the agenda view.
+
+This is useful when you want to display the task hierarchy in your agenda.
+
+**** Use =%l= for displaying the headline's level in the agenda view
+
+[[doc:org-agenda-prefix-format][org-agenda-prefix-format]] allows to use a =%l= formatter to tell Org to
+display entries with additional spaces corresponding to their level in the
+outline tree.
+
+**** [[doc:org-agenda-write][org-agenda-write]] will ask before overwriting an existing file
+
+=M-x org-agenda-write RET= (or =C-c C-w= from an agenda buffer) used to
+overwrite preexisting file with the same name without confirmation.  It now
+asks for a confirmation.
+
+**** New commands =M-m= and =M-*= to toggle (all) mark(s) for bulk action
+
+- [[doc:org-agenda-bulk-toggle][org-agenda-bulk-toggle]] :: this command is bound to =M-m= and toggles
+     the mark of the entry at point.
+
+- [[doc:org-agenda-bulk-toggle-all][org-agenda-bulk-toggle-all]] :: this command is bound to =M-*= and
+     toggles all the marks in the current agenda.
+
+**** New option [[doc:org-agenda-search-view-max-outline-level][org-agenda-search-view-max-outline-level]]
+
+This option sets the maximum outline level to display in search view.
+E.g. when this is set to 1, the search view will only show headlines of
+level 1.
+
+**** New option [[doc:org-agenda-todo-ignore-time-comparison-use-seconds][org-agenda-todo-ignore-time-comparison-use-seconds]]
+
+This allows to compare times using seconds instead of days when honoring
+options like =org-agenda-todo-ignore-*= in the agenda display.
+
+**** New option [[doc:org-agenda-entry-text-leaders][org-agenda-entry-text-leaders]]
+
+This allows you to get rid of the ">" character that gets added in front of
+entries excerpts when hitting =E= in the agenda view.
+
+**** New formatting string for past deadlines in [[doc:org-agenda-deadline-leaders][org-agenda-deadline-leaders]]
+
+The default formatting for past deadlines is ="%2d d. ago: "=, which makes
+it explicit that the deadline is in the past.  You can configure this via
+[[doc:org-agenda-deadline-leaders][org-agenda-deadline-leaders]].  Note that the width of the formatting
+string is important to keep the agenda alignment clean.
+
+**** New allowed value =repeated-after-deadline= for [[doc:org-agenda-skip-scheduled-if-deadline-is-shown][org-agenda-skip-scheduled-if-deadline-is-shown]]
+
+When [[doc:org-agenda-skip-scheduled-if-deadline-is-shown][org-agenda-skip-scheduled-if-deadline-is-shown]] is set to
+=repeated-after-deadline=, the agenda will skip scheduled items if they are
+repeated beyond the current deadline.
+
+**** New option for [[doc:org-agenda-skip-deadline-prewarning-if-scheduled][org-agenda-skip-deadline-prewarning-if-scheduled]]
+
+This variable may be set to nil, t, the symbol `pre-scheduled', or a number
+which will then give the number of days before the actual deadline when the
+prewarnings should resume.  The symbol `pre-scheduled' eliminates the
+deadline prewarning only prior to the scheduled date.
+
+Read the full docstring for details.
+
+**** [[doc:org-class][org-class]] now supports holiday strings in the skip-weeks parameter
+
+For example, this task will now be skipped only on new year's day:
+
+    : * Task
+    :   <%%(org-class 2012 1 1 2013 12 12 2 "New Year's Day")>
+*** Capture
+
+**** Allow =C-1= as a prefix for [[doc:org-agenda-capture][org-agenda-capture]] and [[doc:org-capture][org-capture]]
+
+With a =C-1= prefix, the capture mechanism will use the =HH:MM= value at
+point (if any) or the current =HH:MM= time as the default time for the
+capture template.
+
+**** Expand keywords within %(sexp) placeholder in capture templates
+
+If you use a =%:keyword= construct within a =%(sexp)= construct, Org will
+expand the keywords before expanding the =%(sexp)=.
+
+**** Allow to contextualize capture (and agenda) commands by checking the name of the buffer
+
+[[doc:org-capture-templates-contexts][org-capture-templates-contexts]] and [[doc:org-agenda-custom-commands-contexts][org-agenda-custom-commands-contexts]]
+allow you to define what capture templates and what agenda commands should
+be available in various contexts.  It is now possible for the context to
+check against the name of the buffer.
+*** Tag groups
+
+Using =#+TAGS: { Tag1 : Tag2 Tag3 }= will define =Tag1= as a /group tag/
+(note the colon after =Tag1=).  If you search for =Tag1=, it will return
+headlines containing either =Tag1=, =Tag2= or =Tag3= (or any combination
+of those tags.)
+
+You can use group tags for sparse tree in an Org buffer, for creating
+agenda views, and for filtering.
+
+See http://orgmode.org/org.html#Tag-groups for details.
+
+*** Links
+
+**** =C-u C-u M-x org-store-link RET= will ignore non-core link functions
+
+Org knows how to store links from Org buffers, from info files and from
+other Emacs buffers.  Org can be taught how to store links from any buffer
+through new link protocols (see [[http://orgmode.org/org.html#Adding-hyperlink-types]["Adding hyperlink types"]] in the manual.)
+
+Sometimes you want Org to ignore added link protocols and store the link
+as if the protocol was not known.
+
+You can now do this with =C-u C-u M-x org-store-link RET=.
+
+**** =C-u C-u C-u M-x org-store-link RET= on an active region will store links for each lines
+
+Imagine for example that you want to store a link for every message in a
+Gnus summary buffer.  In that case =C-x h C-u C-u C-u M-x org-store-link
+RET= will store a link for every line (i.e. message) if the region is
+active.
+
+**** =C-c C-M-l= will add a default description for links which don't have one
+
+=C-c C-M-l= inserts all stored links.  If a link does not have a
+description, this command now adds a default one, so that we are not mixing
+with-description and without-description links when inserting them.
+
+**** No curly braces to bracket links within internal links
+
+When storing a link to a headline like
+
+: * See [[http://orgmode.org][Org website]]
+
+[[doc:org-store-link][org-store-link]] used to convert the square brackets into curly brackets.
+It does not anymore, taking the link description or the link path, when
+there is no description.
+*** Table
+
+**** Switching between #+TBLFM lines
+
+If you have several =#+TBLFM= lines below a table, =C-c C-c= on a line will
+apply the formulas from this line, and =C-c C-c= on another line will apply
+those other formulas.
+
+**** You now use "nan" for empty fields in Calc formulas
+
+If empty fields are of interest, it is recommended to reread the section
+[[http://orgmode.org/org.html#Formula-syntax-for-Calc][3.5.2 Formula syntax for Calc]] of the manual because the description for the
+mode strings has been clarified and new examples have been added towards
+the end.
+
+**** Handle localized time-stamps in formulas evaluation
+
+If your =LOCALE= is set so that Org time-stamps use another language than
+english, and if you make time computations in Org's table, it now works by
+internally converting the time-stamps with a temporary =LOCALE=C= before
+doing computation.
+
+**** New lookup functions
+
+There are now three lookup functions:
+
+- [[doc:org-loopup-first][org-loopup-first]]
+- [[doc:org-loopup-last][org-loopup-last]]
+- [[doc:org-loopup-all][org-loopup-all]]
+
+See [[http://orgmode.org/org.html#Lookup-functions][the manual]] for details.
+*** Startup keywords
+
+These new startup keywords are now available:
+
+| Startup keyword                  | Option                                      |
+|----------------------------------+---------------------------------------------|
+| =#+STARTUP: logdrawer=           | =(setq org-log-into-drawer t)=              |
+| =#+STARTUP: nologdrawer=         | =(setq org-log-into-drawer nil)=            |
+|----------------------------------+---------------------------------------------|
+| =#+STARTUP: logstatesreversed=   | =(setq org-log-states-order-reversed t)=    |
+| =#+STARTUP: nologstatesreversed= | =(setq org-log-states-order-reversed nil)=  |
+|----------------------------------+---------------------------------------------|
+| =#+STARTUP: latexpreview=        | =(setq org-startup-with-latex-preview t)=   |
+| =#+STARTUP: nolatexpreview=      | =(setq org-startup-with-latex-preview nil)= |
+
+*** Clocking
+
+**** New option [[doc:org-clock-rounding-minutes][org-clock-rounding-minutes]]
+
+E.g. if [[doc:org-clock-rounding-minutes][org-clock-rounding-minutes]] is set to 5, time is 14:47 and you
+clock in: then the clock starts at 14:45.  If you clock out within the next
+5 minutes, the clock line will be removed; if you clock out 8 minutes after
+your clocked in, the clock out time will be 14:50.
+
+**** New option [[doc:org-time-clocksum-use-effort-durations][org-time-clocksum-use-effort-durations]]
+
+When non-nil, =C-c C-x C-d= uses effort durations.  E.g., by default, one
+day is considered to be a 8 hours effort, so a task that has been clocked
+for 16 hours will be displayed as during 2 days in the clock display or in
+the clocktable.
+
+See [[doc:org-effort-durations][org-effort-durations]] on how to set effort durations and
+[[doc:org-time-clocksum-format][org-time-clocksum-format]] for more on time clock formats.
+
+**** New option [[doc:org-clock-x11idle-program-name][org-clock-x11idle-program-name]]
+
+This allows to set the name of the program which prints X11 idle time in
+milliseconds.  The default is to use =x11idle=.
+
+**** New option [[doc:org-use-last-clock-out-time-as-effective-time][org-use-last-clock-out-time-as-effective-time]]
+
+When non-nil, use the last clock out time for [[doc:org-todo][org-todo]].  Note that this
+option has precedence over the combined use of [[doc:org-use-effective-time][org-use-effective-time]] and
+[[doc:org-extend-today-until][org-extend-today-until]].
+
+**** =S-<left/right>= on a clocksum column will update the sum by updating the last clock
+**** =C-u 3 C-S-<up/down>= will update clock timestamps synchronously by 3 units
+**** New parameter =:wstart= for clocktables to define the week start day
+**** New parameter =:mstart= to state the starting day of the month
+**** Allow relative times in clocktable tstart and tend options
+**** The clocktable summary is now a caption
+**** =:tstart= and =:tend= and friends allow relative times like "<-1w>" or "<now>"
+*** Babel
+
+**** You can now use =C-c C-k= for [[doc:org-edit-src-abort][org-edit-src-abort]]
+
+This allows you to quickly cancel editing a source block.
+
+**** =C-u C-u M-x org-babel-tangle RET= tangles by the target file of the block at point
+
+This is handy if you want to tangle all source code blocks that have the
+same target than the block at point.
+
+**** New options for auto-saving the base buffer or the source block editing buffer
+
+When [[doc:org-edit-src-turn-on-auto-save][org-edit-src-turn-on-auto-save]] is set to =t=, editing a source block
+in a new window will turn on =auto-save-mode= and save the code in a new
+file under the same directory than the base Org file.
+
+When [[doc:org-edit-src-auto-save-idle-delay][org-edit-src-auto-save-idle-delay]] is set to a number of minutes =N=,
+the base Org buffer will be saved after this number of minutes of idle
+time.
+
+**** New =:post= header argument post-processes results
+
+     This header argument may be used to pass the results of the current
+     code block through another code block for post-processing.  See the
+     manual for a usage example.
+
+**** Commented out heading are ignored when collecting blocks for tangling
+
+If you comment out a heading (with =C-c ;= anywhere on the heading or in
+the subtree), code blocks from within this heading are now ignored when
+collecting blocks for tangling.
+
+**** New option [[doc:org-babel-hash-show-time][org-babel-hash-show-time]] to show a time-stamp in the result hash
+**** Do not ask for confirmation if cached value is current
+
+Do not run [[doc:org-babel-confirm-evaluate][org-babel-confirm-evaluate]] if source block has a cache and the
+cache value is current as there is no evaluation involved in this case.
+**** =ob-sql.el= and =ob-python.el= have been improved.
+**** New Babel files only need to =(require 'ob)=
+
+When writing a new Babel file, you now only need to use =(require 'ob)=
+instead of requiring each Babel library one by one.
+*** Faces
+
+- Org now fontifies radio link targets by default
+- In the agenda, use [[doc:org-todo-keyword-faces][org-todo-keyword-faces]] to highlight selected TODO keywords
+- New face [[doc:org-priority][org-priority]], enhanced fontification of priority cookies in agenda
+- New face [[doc:org-tag-group][org-tag-group]] for group tags
+
+** Miscellaneous
+
+- New speedy key =s= pour [[doc:org-narrow-to-subtree][org-narrow-to-subtree]]
+- Handling of [[doc:org-html-table-row][org-html-table-row]] has been updated (incompatible change)
+- [[doc:org-export-html-table-tag][org-export-html-table-tag]] is replaced by [[doc:org-html-table-default-attributes][org-html-table-default-attributes]]
+- Support using =git-annex= with Org attachments
+- org-protocol: Pass optional value using query in url to capture from protocol
+- When the refile history is empty, use the current filename as default
+- When you cannot change the TODO state of a task, Org displays the blocking task
+- New option [[doc:org-mobile-allpriorities][org-mobile-allpriorities]]
+- org-bibtex.el now use =visual-line-mode= instead of the deprecated =longlines-mode=
+- [[doc:org-format-latex-options][org-format-latex-options]] allows to set the foreground/background colors automatically
+- New option [[doc:org-archive-file-header-format][org-archive-file-header-format]]
+- New "neg" entity in [[doc:org-entities][org-entities]]
+- New function [[doc:org-docview-export][org-docview-export]] to export docview links
+- New =:eps= header argument for ditaa code blocks
+- New option [[doc:org-gnus-no-server][org-gnus-no-server]] to start Gnus with =gnus-no-server=
+- Org is now distributed with =htmlize.el= version 1.43
+- ~org-drill.el~ has been updated to version 2.3.7
+- ~org-mac-iCal.el~ now supports MacOSX version up to 10.8
+- Various improvements to ~org-contacts.el~ and =orgpan.el=
+
+** Outside Org
+
+*** Spanish translation of the Org guide by David Arroyo Menéndez
+
+David (and others) translated the Org compact guide in spanish:
+
+You can read the [[http://orgmode.org/worg/orgguide/orgguide.es.pdf][PDF guide]].
+
+*** ~poporg.el~ and ~outorg.el~
+
+Two new libraries (~poporg.el~ by François Pinard and ~outorg.el~ by
+Thorsten Jolitz) now enable editing of comment-sections from source-code
+buffers in temporary Org-mode buffers, making the full editing power of
+Org-mode available.  ~outorg.el~ comes together with ~outshine.el~ and
+~navi-mode.el~, two more libraries by Thorsten Jolitz with the goal to give
+source-code buffers the /look & feel/ of Org-mode buffers while greatly
+improving navigation and structure editing.  A detailed description can be
+found here: http://orgmode.org/worg/org-tutorials/org-outside-org.html
+
+Here are two screencasts demonstrating Thorsten's tools:
+
+- [[http://youtu.be/nqE6YxlY0rw]["Modern conventions for Emacs Lisp files"]]
+- [[http://www.youtube.com/watch?v%3DII-xYw5VGFM][Exploring Bernt Hansen's Org-mode tutorial with 'navi-mode']]
+
+*** MobileOrg for iOS
+
+MobileOrg for iOS back in the App Store The 1.6.0 release was focused on
+the new Dropbox API and minor bug fixes but also includes a new ability to
+launch in Capture mode.  Track development and contribute [[https://github.com/MobileOrg/mobileorg/issues][on github]].
+
 * Version 7.9.3
 
 ** New option [[doc::org-agenda-use-tag-inheritance][org-agenda-use-tag-inheritance]]
index 3bdb82aa4d4e3c0c59b670889358cc55e6af9d32..d798adb143664369d41a015a781d5784980a44a6 100644 (file)
--- a/etc/TODO
+++ b/etc/TODO
@@ -199,6 +199,14 @@ dired buffers and DTRT WRT `auto-revert-mode'.
 http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00456.html
 
 * Important features:
+
+** "Emacs as word processor"
+http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00515.html
+    rms writes:
+    25 years ago I hoped we would extend Emacs to do WYSIWG word
+    processing.  That is why we added text properties and variable
+    width fonts.  However, more features are still needed to achieve this.
+
 ** Extended text-properties (to make overlays "obsolete")
 *** Several text-property planes
 This would get us rid of font-lock-face property (and I'd be happy to
@@ -221,6 +229,9 @@ never really made it work for this.
 
 Perspectives also need to interact with the tabs.
 
+** FFI (foreign function interface)
+See eg http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00246.html
+
 ** Imenu could be extended into a file-structure browsing mechanism
 using code like that of customize-groups.
 
@@ -442,6 +453,8 @@ rather than interactively.  This a trivial one-liner in easy-mode.el.
 
 ** Highlight rectangles (`mouse-track-rectangle-p' in XEmacs).  Already in CUA,
   but it's a valuable feature worth making more general.
+  [Basic support added 2013/10:
+  http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00904.html ]
 
 ** Eliminate the storm of warnings concerning char/unsigned char
   mismatches that we get with GCC 4.x and proprietary compilers on
index 651d7dd08eb9e50d36698d9bc380a75fef37b024..0e19d32a1a7d3dde72c1460083c695be0f1a8240 100644 (file)
@@ -1,5 +1,5 @@
 % Reference Card for Org Mode
-\def\orgversionnumber{7.9.3}
+\def\orgversionnumber{8.2.3}
 \def\versionyear{2013}          % latest update
 \input emacsver.tex
 
index 11186603df8f460bed4cc3e2383afb3430c3cf10..6b16d71c21542c03abb24f407f6cdd2b1dd28a33 100644 (file)
@@ -1,3 +1,31 @@
+2013-11-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * Makefile.in (RUN_EMACS): Don't set LC_ALL=C.  (Bug#15260)
+
+2013-11-03  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_srcdir): Remove.
+       (RUN_EMACS): Unset EMACSLOADPATH.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (buildlisppath): Remove.
+       (RUN_EMACS): Use abs_srcdir directly.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (.el.elc, changed.tit, changed.misc, leim-list.el)
+       ($(srcdir)/ja-dic/ja-dic.el, check-declare): Remove unnecessary
+       path in -l argument (RUN_EMACS sets EMACSLOADPATH).
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_srcdir): New, set by configure.
+       (buildlisppath): Use abs_srcdir.
+       (RUN_EMACS, .el.elc, changed.tit, changed.misc, leim-list.el)
+       ($(srcdir)/ja-dic/ja-dic.el, setwins, distclean, check-declare):
+       Quote entities that might contain whitespace.
+
 2013-09-05  Jean Haidouk  <haidouk@yandex.com>  (tiny change)
 
        * quail/latin-alt.el ("french-alt-postfix", "latin-alt-postfix"):
index 7c3f3ca47e1934c704d8559c08b712a89036c2c0..a5c05d567ec4f2bac889964adc6ea4ae5afba3f4 100644 (file)
@@ -30,11 +30,10 @@ srcdir=@srcdir@
 # byte-compile Emacs Lisp files, and generate the file leim-list.el.
 EMACS = ../src/emacs
 
-buildlisppath=${srcdir}/../lisp
-
 # How to run Emacs.
-RUN_EMACS = EMACSLOADPATH=$(buildlisppath) LC_ALL=C \
-       ${EMACS} -batch --no-site-file --no-site-lisp
+# Prevent any setting of EMACSLOADPATH in user environment causing problems.
+RUN_EMACS = unset EMACSLOADPATH; "${EMACS}" -batch \
+       --no-site-file --no-site-lisp
 
 MKDIR_P = @MKDIR_P@
 
@@ -76,7 +75,7 @@ TIT_MISC=${CHINESE_TIT} ${MISC}
 
 .el.elc:
        @echo Compiling $<
-       @${RUN_EMACS} -l ${buildlisppath}/international/quail -f batch-byte-compile $<
+       @${RUN_EMACS} -l international/quail -f batch-byte-compile $<
 
 all: leim-list.el compile-main
 .PHONY: all
@@ -109,7 +108,7 @@ ${CHINESE_TIT}: changed.tit
 ## It doesn't seem possible to do this with VPATH and suffix rules.
 changed.tit: ${TIT_SOURCES}
        @${MKDIR_P} quail
-       ${RUN_EMACS} -l ${buildlisppath}/international/titdic-cnv \
+       ${RUN_EMACS} -l titdic-cnv \
          -f batch-titdic-convert -dir quail ${srcdir}/CXTERM-DIC; \
          echo "changed" > $@
 
@@ -126,30 +125,30 @@ ${MISC}: changed.misc
 
 changed.misc: ${MISC_SOURCES}
        @${MKDIR_P} quail
-       ${RUN_EMACS} -l ${buildlisppath}/international/titdic-cnv \
+       ${RUN_EMACS} -l titdic-cnv \
          -f batch-miscdic-convert -dir quail ${srcdir}/MISC-DIC; \
          echo "changed" > $@
 
 leim-list.el: ${TIT_MISC} ${srcdir}/leim-ext.el
        rm -f leim-list.el
-       if [ x`cd ${srcdir} && /bin/pwd` = x`/bin/pwd` ] ; then \
-         ${RUN_EMACS} -l ${buildlisppath}/international/quail \
+       if [ "`cd ${srcdir} && /bin/pwd`" = "`/bin/pwd`" ] ; then \
+         ${RUN_EMACS} -l international/quail \
            --eval "(update-leim-list-file \".\")" ; \
        else \
-         ${RUN_EMACS} -l ${buildlisppath}/international/quail \
+         ${RUN_EMACS} -l international/quail \
            --eval "(update-leim-list-file \".\" (unmsys--file-name \"${srcdir}\"))" ; \
        fi
        sed -n '/^[^;]/ p' < ${srcdir}/leim-ext.el >> $@
 
 $(srcdir)/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L
        @$(MKDIR_P) $(srcdir)/ja-dic
-       $(RUN_EMACS) -batch -l $(buildlisppath)/international/ja-dic-cnv \
+       $(RUN_EMACS) -batch -l ja-dic-cnv \
          -f batch-skkdic-convert -dir "$(srcdir)/ja-dic" \
          "$(srcdir)/SKK-DIC/SKK-JISYO.L"
 
 ## Following adapted from lisp/Makefile.in.
 setwins=wins="${srcdir}/ja-dic quail"; \
-       [ `cd ${srcdir} && /bin/pwd` != `/bin/pwd` ] && \
+       [ "`cd ${srcdir} && /bin/pwd`" != "`/bin/pwd`" ] && \
        wins="$$wins ${srcdir}/quail"
 
 .PHONY: compile-targets
@@ -184,7 +183,7 @@ bootstrap-clean: clean
        $(setwins); for w in $$wins; do rm -f $$w/*.elc; done
 
 distclean: clean
-       -[ `cd ${srcdir} && /bin/pwd` != `/bin/pwd` ] && rm -rf quail
+       -[ "`cd ${srcdir} && /bin/pwd`" != "`/bin/pwd`" ] && rm -rf quail
        rm -f Makefile
 
 maintainer-clean: distclean bootstrap-clean
@@ -195,5 +194,5 @@ extraclean: maintainer-clean
 .PHONY: check-declare
 
 check-declare:
-       $(RUN_EMACS) -l $(buildlisppath)/emacs-lisp/check-declare \
+       $(RUN_EMACS) -l check-declare \
          --eval '(check-declare-directory (unmsys--file-name "$(srcdir)"))'
index 0b91cc4887f71d29e97bd62b1e8fe4779e696e08..2010444743a1597b53ef90486ae98564f6278f2f 100644 (file)
@@ -1,3 +1,21 @@
+2013-11-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * ebrowse.c (xstrdup):
+       * etags.c (savenstr): Prefer tail calls.
+       * etags.c (concat): Omit unnecessary assignment.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in ($(DESTDIR)${archlibdir}):
+       Avoid non-portable "`\" nesting.
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in ($(DESTDIR)${archlibdir}, need-blessmail, install)
+       (uninstall): Quote entities that might contain whitespace.
+
 2013-10-10  Glenn Morris  <rgm@gnu.org>
 
        * make-docfile.c (search_lisp_doc_at_eol):
index 994eb2bb266acd5c4b88b2abd6116beaf5e0ac43..b765668aebca4978578db9bcbe018b34500cb934 100644 (file)
@@ -84,6 +84,8 @@ VPATH=@srcdir@
 
 # The top-level source directory, also set by configure.
 top_srcdir=@top_srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 
 # ==================== Emacs-specific directories ====================
 
@@ -214,10 +216,10 @@ blessmail:
 need-blessmail: blessmail
        @if [ `wc -l <blessmail` != 2 ] ; then \
          dir=`sed -n -e 's/echo mail directory = \(.*\)/\1/p' blessmail`; \
-         echo Assuming $$dir is really the mail spool directory, you should; \
-         echo run  lib-src/blessmail $(DESTDIR)${archlibdir}/movemail${EXEEXT}; \
-         echo as root, to give  movemail${EXEEXT}  appropriate permissions.; \
-         echo Do that after running  make install.; \
+         echo "Assuming $$dir is really the mail spool directory, you should"; \
+         echo "run  lib-src/blessmail $(DESTDIR)${archlibdir}/movemail${EXEEXT}"; \
+         echo "as root, to give  movemail${EXEEXT}  appropriate permissions."; \
+         echo "Do that after running  make install."; \
        fi
 
 ## This is the target invoked by the top-level Makefile.
@@ -231,23 +233,24 @@ maybe-blessmail: $(BLESSMAIL_TARGET)
 $(DESTDIR)${archlibdir}: all
        @echo
        @echo "Installing utilities run internally by Emacs."
-       umask 022; ${MKDIR_P} $(DESTDIR)${archlibdir}
-       if [ `cd $(DESTDIR)${archlibdir} && /bin/pwd` != `/bin/pwd` ]; then \
+       umask 022; ${MKDIR_P} "$(DESTDIR)${archlibdir}"
+       exp_archlibdir=`cd "$(DESTDIR)${archlibdir}" && /bin/pwd`; \
+       if [ "$$exp_archlibdir" != "`/bin/pwd`" ]; then \
          for file in ${UTILITIES}; do \
-           $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \
+           $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file "$(DESTDIR)${archlibdir}/$$file" ; \
          done ; \
         fi
-       umask 022; ${MKDIR_P} $(DESTDIR)${gamedir}; \
-       touch $(DESTDIR)${gamedir}/snake-scores; \
-       touch $(DESTDIR)${gamedir}/tetris-scores
-       -if chown ${gameuser} $(DESTDIR)${archlibdir}/update-game-score${EXEEXT} && chmod u+s $(DESTDIR)${archlibdir}/update-game-score${EXEEXT}; then \
-         chown ${gameuser} $(DESTDIR)${gamedir}; \
-         chmod u=rwx,g=rwx,o=rx $(DESTDIR)${gamedir}; \
+       umask 022; ${MKDIR_P} "$(DESTDIR)${gamedir}"; \
+       touch "$(DESTDIR)${gamedir}/snake-scores"; \
+       touch "$(DESTDIR)${gamedir}/tetris-scores"
+       -if chown ${gameuser} "$(DESTDIR)${archlibdir}/update-game-score${EXEEXT}" && chmod u+s "$(DESTDIR)${archlibdir}/update-game-score${EXEEXT}"; then \
+         chown ${gameuser} "$(DESTDIR)${gamedir}"; \
+         chmod u=rwx,g=rwx,o=rx "$(DESTDIR)${gamedir}"; \
        fi
-       if [ `cd $(DESTDIR)${archlibdir} && /bin/pwd` \
-             != `cd ${srcdir} && /bin/pwd` ]; then \
+       if [ "`cd \"$(DESTDIR)${archlibdir}\" && /bin/pwd`" \
+             != "`cd ${srcdir} && /bin/pwd`" ]; then \
          for file in ${SCRIPTS}; do \
-           $(INSTALL_SCRIPT) ${srcdir}/$$file $(DESTDIR)${archlibdir}/$$file; \
+           $(INSTALL_SCRIPT) ${srcdir}/$$file "$(DESTDIR)${archlibdir}/$$file"; \
          done ; \
        fi
 
@@ -257,23 +260,23 @@ $(DESTDIR)${archlibdir}: all
 install: $(DESTDIR)${archlibdir}
        @echo
        @echo "Installing utilities for users to run."
-       umask 022; ${MKDIR_P} $(DESTDIR)${bindir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
        for file in ${INSTALLABLES} ; do \
-         $(INSTALL_PROGRAM) $(INSTALL_STRIP) $${file} $(DESTDIR)${bindir}/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
+         $(INSTALL_PROGRAM) $(INSTALL_STRIP) $${file} "$(DESTDIR)${bindir}"/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
        done
        for file in ${INSTALLABLE_SCRIPTS} ; do \
-         $(INSTALL_SCRIPT) ${srcdir}/$${file} $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'`  ; \
+         $(INSTALL_SCRIPT) ${srcdir}/$${file} "$(DESTDIR)${bindir}"/`echo $${file} | sed '$(TRANSFORM)'`  ; \
        done
 
 uninstall:
        for file in ${INSTALLABLES}; do \
-         rm -f $(DESTDIR)${bindir}/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
+         rm -f "$(DESTDIR)${bindir}"/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
        done
        for file in ${INSTALLABLE_SCRIPTS}; do \
-         rm -f $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'` ; \
+         rm -f "$(DESTDIR)${bindir}"/`echo $${file} | sed '$(TRANSFORM)'` ; \
        done
-       if [ -d $(DESTDIR)${archlibdir} ]; then \
-         (cd $(DESTDIR)${archlibdir} && rm -f ${UTILITIES} ${SCRIPTS}) \
+       if [ -d "$(DESTDIR)${archlibdir}" ]; then \
+         (cd "$(DESTDIR)${archlibdir}" && rm -f ${UTILITIES} ${SCRIPTS}) \
        fi
 
 mostlyclean:
index 216865c38003f87aaa5a4ea44cf6521cbdbf46d3..971f74e7fee112b5c10d6242584a35f6306889b4 100644 (file)
@@ -514,7 +514,7 @@ static char *
 xstrdup (char *s)
 {
   if (s)
-    s = strcpy (xmalloc (strlen (s) + 1), s);
+    return strcpy (xmalloc (strlen (s) + 1), s);
   return s;
 }
 
index aa8c773e357ec26073e9d0c5112f62dec996e6bc..21cf3654b9edb78baf6c99ed2329128bd0dc1751 100644 (file)
@@ -6243,12 +6243,9 @@ savestr (const char *cp)
 static char *
 savenstr (const char *cp, int len)
 {
-  register char *dp;
-
-  dp = xnew (len + 1, char);
-  memcpy (dp, cp, len);
+  char *dp = xnew (len + 1, char);
   dp[len] = '\0';
-  return dp;
+  return memcpy (dp, cp, len);
 }
 
 /*
@@ -6362,7 +6359,6 @@ concat (const char *s1, const char *s2, const char *s3)
   strcpy (result, s1);
   strcpy (result + len1, s2);
   strcpy (result + len1 + len2, s3);
-  result[len1 + len2 + len3] = '\0';
 
   return result;
 }
index 4eca3f18e17087803ac4fd729b6883e0329f1c36..306a083e34ace20c713b43ef89f11a1783c78473 100644 (file)
@@ -24,6 +24,6 @@
 # include <stdio_ext.h>
 #endif
 
-#ifndef __fpending
-size_t __fpending (FILE *);
+#if !HAVE_DECL___FPENDING
+size_t __fpending (FILE *) _GL_ATTRIBUTE_PURE;
 #endif
index f57f9b4ddab25cf228f3c736e05cda6a6690c86d..1d2deb7fc2523dee4565330fa643d167a5126ed2 100644 (file)
@@ -89,7 +89,8 @@
 
 /* Return 1 if the __typeof__ keyword works.  This could be done by
    'configure', but for now it's easier to do it by hand.  */
-#if 2 <= __GNUC__ || defined __IBM__TYPEOF__ || 0x5110 <= __SUNPRO_C
+#if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
+     || (0x5110 <= __SUNPRO_C && !__STDC__))
 # define _GL_HAVE___TYPEOF__ 1
 #else
 # define _GL_HAVE___TYPEOF__ 0
index 8407e160bb50ccc5ea14030e344457c6714e2350..f0ea7a93526a564b75c34b8d625cec2a89127b7b 100644 (file)
+2013-11-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * electric.el (electric-indent-mode-map): Remove.
+       (electric-indent-mode): Change the global-map instead (bug#15915).
+
+       * textmodes/text-mode.el (paragraph-indent-minor-mode):
+       Use add-function.
+
+2013-11-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/nadvice.el (remove-function): Align with
+       add-function's behavior.
+
+       * progmodes/gdb-mi.el: Avoid backtracking in regexp matcher.
+       (gdb--string-regexp): New constant.
+       (gdb-tooltip-print, gdb-var-evaluate-expression-handler)
+       (gdbmi-bnf-stream-record, gdb-jsonify-buffer): Use it.
+       (gdb-source-file-regexp, gdb-prompt-name-regexp): Use it and change
+       submatch 1.
+       (gdb-get-source-file-list, gdb-get-prompt, gdb-get-source-file):
+       Adjust use accordingly.
+       (gdb-breakpoints-list-handler-custom): Pre-build the y/n string.
+
+2013-11-17  Adam Sokolnicki  <adam.sokolnicki@gmail.com>  (tiny change)
+
+       * progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at
+       interpolation curlies (Bug#15914).
+
+2013-11-17  Jay Belanger  <jay.p.belanger@gmail.com>
+
+       * calc/calc.el (calc-context-sensitive-enter): New variable.
+       (calc-enter): Use `calc-context-sensitive-enter'.
+
+2013-11-16  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * progmodes/cfengine.el: Version bump.
+       (cfengine-cf-promises): New defcustom to locate cf-promises.
+       (cfengine3-vartypes): Add new "data" type.
+       (cfengine3--current-word): New function to get current name-like
+       word or its bounds.
+       (cfengine3--current-function): New function to look up a CFEngine
+       function's definition.
+       (cfengine3-format-function-docstring): New function.
+       (cfengine3-make-syntax-cache): New function.
+       (cfengine3-documentation-function): New function: ElDoc glue.
+       (cfengine3-completion-function): New function: completion glue.
+       (cfengine3-mode): Set `compile-command',
+       `eldoc-documentation-function', and add to
+       `completion-at-point-functions'.
+
+2013-11-16  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-cmds.el (tramp-cleanup-connection): Clean up
+       `tramp-current-connection'.
+
+2013-11-15  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-font-lock-keywords): End regexp for
+       nil/self/true/false with "end of symbol".
+
+2013-11-15  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * subr.el (version-regexp-alist): Fix a typo.
+
+2013-11-15  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-sh.el (tramp-remote-process-environment): Set "LC_ALL" to
+       "en_US.utf8" and "LC_CTYPE" to "".
+       (tramp-maybe-open-connection): Set "LC_ALL" to "en_US.utf8".
+       (tramp-sh-handle-insert-directory): Don't set "LC_ALL" and "LC_CTYPE".
+
+2013-11-15  Leo Liu  <sdl.web@gmail.com>
+
+       * loadhist.el (read-feature): Get rid of fake feature nil.  (Bug#15889)
+
+2013-11-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/gud.el (ctl-x-map):
+       Remove C-x SPC binding.  (Bug#12342)
+       (gud-jdb-find-source-using-classpath): Remove ((lambda (..)..)..).
+
+2013-11-14  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * subr.el (version-regexp-alist):
+       Recognize hg, svn and darcs versions as snapshot versions.
+
+       * progmodes/ruby-mode.el (ruby-mode-set-encoding):
+       Add the ability to always insert an utf-8 encoding comment.
+       Fix and simplify coding comment update logic.
+
+2013-11-14  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-gvfs.el (top): Run init code only when
+       `tramp-gvfs-enabled' is not nil.
+       (tramp-gvfs-enabled): Check also :system bus.
+
+2013-11-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       Sync with upstream verilog-mode revision 78e66ba.
+       * progmodes/verilog-mode.el (verilog-end-of-defun)
+       (verilog-type-completion, verilog-get-list): Remove unused funcs.
+       (verilog-get-end-of-defun): Remove unused argument.
+       (verilog-comment-depth): Remove unused local `e'.
+       (verilog-read-decls, verilog-read-sub-decls, verilog-read-instants):
+       Don't pass arg to verilog-get-end-of-defun.
+
+2013-11-14  Glenn Morris  <rgm@gnu.org>
+
+       * obsolete/assoc.el (aget): Prefix dynamic variable.
+
+       * allout-widgets.el (allout-widgets): No need to autoload defgroup.
+
+2013-11-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * widget.el, hfy-cmap.el: Remove bogus package version number.
+
+2013-11-13  Glenn Morris  <rgm@gnu.org>
+
+       * replace.el (replace-eval-replacement):
+       Try to give more helpful error message.  (Bug#15836)
+
+       * arc-mode.el (archive-7z-extract, archive-7z-expunge)
+       (archive-7z-update): Avoid custom type mismatches.
+
+       * vc/vc.el (vc-diff-knows-L): Remove; unused since 2007-10-10.
+
+2013-11-13  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-remote-file-name-spec-regexp): An IPv6
+       address can be empty.
+
+       * net/tramp-gvfs.el (tramp-gvfs-handle-insert-directory):
+       Accept nil SWITCHES.
+       (tramp-gvfs-handle-write-region): Implement APPEND.
+
+2013-11-12  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie-grammar): Disambiguate between
+       binary "|" operator and closing block args delimiter.
+       Remove FIXME comment referring to Ruby 1.8-only syntax.
+       (ruby-smie--implicit-semi-p): Not after "|" operator.
+       (ruby-smie--closing-pipe-p): New function.
+       (ruby-smie--forward-token, ruby-smie--backward-token): Use it.
+       (ruby-smie-rules): Indent after "|".
+
+2013-11-12  Glenn Morris  <rgm@gnu.org>
+
+       * ps-print.el (ps-face-attribute-list):
+       Handle anonymous faces.  (Bug#15827)
+
+2013-11-12  Martin Rudalics  <rudalics@gmx.at>
+
+       * window.el (display-buffer-other-frame): Fix doc-string.
+       (Bug#15868)
+
+2013-11-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * subr.el (force-mode-line-update): Delete, move to buffer.c.
+
+2013-11-11  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-sh.el (tramp-do-copy-or-rename-file-via-buffer)
+       (tramp-sh-handle-file-local-copy): Don't write a message when
+       saving temporary files.
+
+       * net/tramp-smb.el (tramp-smb-handle-copy-directory): Fix bug when
+       both directories are remote.
+       (tramp-smb-handle-directory-files): Do not return double entries.
+       Do not expand full file names.
+       (tramp-smb-handle-insert-directory): Accept nil SWITCHES.
+       (tramp-smb-handle-write-region): Implement APPEND.
+       (tramp-smb-get-stat-capability): Fix a stupid bug.
+
+2013-11-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * bindings.el (ctl-x-map): Bind C-x SPC to rectangle-mark-mode.
+
+2013-11-11  Nathan Trapuzzano  <nbtrap@nbtrap.com>  (tiny change)
+
+       * emacs-lisp/cconv.el (cconv-convert): Print warning instead of
+       throwing error over malformed let/let* (bug#15814).
+
+2013-11-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * iswitchb.el (iswitchb-mode): Mark obsolete.
+
+2013-11-11  Glenn Morris  <rgm@gnu.org>
+
+       * international/uni-bidi.el, international/uni-category.el:
+       * international/uni-name.el, international/uni-numeric.el:
+       Regenerate for Unicode 6.3.0.
+
+2013-11-10  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-methods):
+       * net/tramp-sh.el (tramp-compute-multi-hops): Revert change of
+       2013-10-29 (2013-10-29T02:50:24Z!dancol@dancol.org).
+
+2013-11-09  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * progmodes/sh-script.el (sh-font-lock-keywords-var):
+       Force highlighting text after Summary keyword in doc face for rpm.
+
+2013-11-09  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * textmodes/ispell.el (ispell-lookup-words): When `look' is not
+       available and the word has no wildcards, append one to the grep pattern.
+       http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00258.html
+       (ispell-complete-word): Call `ispell-lookup-words' with the value
+       independent of `ispell-look-p'.
+
+2013-11-08  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--implicit-semi-p):
+       Not after "||".
+       (ruby-smie-rules): Indent non-hanging "begin" blocks as part of
+       their parent.
+
+2013-11-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/ruby-mode.el: Don't require cl any more.  Use pcase instead.
+       (ruby-font-lock-keywords): Use backquote.
+
+2013-11-08  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--forward-token)
+       (ruby-smie--backward-token): Only consider full-string matches.
+
+2013-11-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * faces.el (describe-face): Add distant-foreground.
+
+2013-11-08  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/ruby-mode.el (ruby-mode-set-encoding):
+       Use `ruby-encoding-magic-comment-style' to control the
+       style of the auto-inserted encoding comment.
+
+2013-11-08  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--indent-to-stmt):
+       Use `smie-backward-sexp' with token argument.
+
+2013-11-08  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-sh.el (tramp-set-remote-path, tramp-get-ls-command):
+       Remove instrumentation code.
+
+2013-11-08  Glenn Morris  <rgm@gnu.org>
+
+       * progmodes/autoconf.el (autoconf-mode):
+       Tweak comment-start-skip.  (Bug#15822)
+
+2013-11-08  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/sh-script.el (sh-smie--sh-keyword-in-p): Don't inf-loop
+       at bobp (bug#15826).
+       (sh-smie--sh-keyword-in-p): Recognize keywords at bobp.
+
+2013-11-08  Darren Hoo  <darren.hoo@gmail.com>
+
+       * man.el (Man-start-calling): New macro, extracted from
+       Man-getpage-in-background.
+       (Man-getpage-in-background): Use it.
+       (Man-update-manpage): New command.
+       (Man-mode-map): Bind it.
+
+2013-11-08  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie-grammar): Improve precedences
+       of "and", "or", "&&" and "||".
+       (ruby-smie--args-separator-p): Prohibit keyword "do" as the first
+       argument.  Prohibit opening curly brace because it could only be a
+       block opener in that position.
+       (ruby-smie--forward-token, ruby-smie--backward-token):
+       Separate "|" from "&" or "*" going after it.  That can happen in block
+       arguments.
+       (ruby-smie--indent-to-stmt): New function, seeks the end of
+       previous statement or beginning of buffer.
+       (ruby-smie-rules): Use it.
+       (ruby-smie-rules): Check if there's a ":" before a curly block
+       opener candidate; if there is, it's a hash.
+
+2013-11-07  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/cl-macs.el (cl-symbol-macrolet): Use macroexp-progn.
+       (cl--block-wrapper): Fix last accidental change.
+
+2013-11-07  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-sh.el (tramp-set-remote-path, tramp-get-ls-command):
+       Instrument, in order to hunt failure on hydra.
+
+2013-11-05  Nathan Trapuzzano  <nbtrap@nbtrap.com>  (tiny change)
+
+       * emacs-lisp/cl-macs.el (cl-symbol-macrolet): Print warning for
+       malformed bindings form (bug#15814).
+
+2013-11-07  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie-grammar): Lower priority of
+       "." compared to " @ ".  This incidentally fixes some indentation
+       examples with "do".
+       (ruby-smie--implicit-semi-p): No implicit semi after "^", "and" or "or".
+       (ruby-smie-grammar): New tokens: "and" and "or".
+       (ruby-smie--args-separator-p): Fix the check for tokens at POS.
+       Exclude "and" and "or".  Remove "do" in order to work around token
+       priorities.
+       (ruby-smie-rules): Add all infix tokens.  Handle the case of
+       beginning-of-buffer.
+
+2013-11-06  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (setwins_almost, setwins_for_subdirs):
+       Avoid accidental matches.
+
+2013-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * menu-bar.el (popup-menu): Use key-binding.
+
+2013-11-06  Eli Zaretskii  <eliz@gnu.org>
+
+       * menu-bar.el (popup-menu, menu-bar-open): When displaying TTY
+       menus, support also the menus produced by minor modes.
+       (Bug#15817)
+
+2013-11-06  Leo Liu  <sdl.web@gmail.com>
+
+       * thingatpt.el (thing-at-point-looking-at): Add optional arg
+       DISTANCE to bound the search. All uses changed.  (Bug#15808)
+
+2013-11-06  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (setwins, setwins_almost, setwins_for_subdirs): Simplify.
+       (setwins_almost, setwins_for_subdirs): Don't assume called from srcdir.
+       (custom-deps, finder-data, autoloads, update-subdirs): No need to cd.
+
+2013-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * electric.el (electric-indent-just-newline): New command.
+       (electric-indent-mode-map): New keymap.
+       (electric-indent-mode, electric-pair-mode, electric-layout-mode):
+       Re-add :group which weren't redundant.
+
+       * electric.el (electric-indent-local-mode): New minor mode.
+       (electric-indent-functions-without-reindent): New var.
+       (electric-indent-post-self-insert-function): Use it.
+       * emacs-lisp/gv.el (buffer-local-value): Add setter.
+
+2013-11-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * international/quail.el (quail-help): Be more explicit about the
+       meaning of the labels shown on the keys.  (Bug#15800)
+
+       * startup.el (normal-top-level): Load the subdirs.el files before
+       setting the locale environment.  (Bug#15805)
+
+2013-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * vc/vc-rcs.el (vc-rcs-parse): Make `gather' get e, b, and @-holes
+       via arguments so as to get the right ones (bug#15418).
+
+       * net/rcirc.el (rcirc-record-activity): Don't abuse add-to-list.
+
+2013-11-05  Michael Albinus  <michael.albinus@gmx.de>
+
+       Fix problems found while writing a test suite.
+
+       * net/tramp-compat.el (tramp-compat-load): New defun.
+       * net/tramp.el (tramp-handle-load): Use it.
+
+       * net/tramp-sh.el (tramp-sh-handle-add-name-to-file): Handle the case
+       "(numberp ok-if-already-exists)" correctly.
+
+2013-11-05  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * international/characters.el (glyphless-char-display-control):
+       Add usage note.
+
+2013-11-05  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/python.el (python-mode):
+       * progmodes/scheme.el (scheme-mode):
+       * progmodes/prolog.el (prolog-mode):
+       * progmodes/ruby-mode.el (ruby-mode):
+       * emacs-lisp/lisp-mode.el (lisp-mode, lisp-interaction-mode)
+       (emacs-lisp-mode): Remove incorrect and redundant text from docstring.
+
+2013-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * rect.el (rectangle--highlight-for-redisplay):
+       * emacs-lisp/smie.el (smie--next-indent-change):
+       Use buffer-chars-modified-tick.
+
+       * emacs-lisp/byte-run.el (defmacro, defun): Set their `indent' property.
+
+       * electric.el (electric-indent-post-self-insert-function):
+       Only delete trailing whitepsace if it is indeed trailing (bug#15767).
+
+2013-11-04  Helmut Eller  <eller.helmut@gmail.com>
+
+       * emacs-lisp/cl-indent.el (with-compilation-unit): Add rule (bug#15782).
+
+2013-11-04  Nathan Trapuzzano  <nbtrap@nbtrap.com>  (tiny change)
+
+       * emacs-lisp/cconv.el (cconv-convert): Check form of let binding
+       (bug#15786).
+
+2013-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/helpers.el: Move from helpers.el.  Use lexical-binding.
+
+       * progmodes/python.el: Fix up last change.
+       (python-shell--save-temp-file): New function.
+       (python-shell-send-string): Use it.  Remove `msg' arg.  Don't assume
+       `string' comes from the current buffer.
+       (python-shell-send-string-no-output): Remove `msg' arg.
+       (python--use-fake-loc): New var.
+       (python-shell-buffer-substring): Obey it.  Try to compensate for the
+       extra coding line added by python-shell--save-temp-file.
+       (python-shell-send-region): Use python-shell--save-temp-file and
+       python-shell-send-file directly.  Add `nomain' argument.
+       (python-shell-send-buffer): Use python-shell-send-region.
+       (python-electric-pair-string-delimiter): New function.
+       (python-mode): Use it.
+
+2013-11-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * startup.el (normal-top-level): Move setting eol-mnemonic-unix,
+       eol-mnemonic-mac, eol-mnemonic-dos, and also setup of the locale
+       environment and decoding all of the default-directory's to here
+       from command-line.
+       (command-line): Decode also argv[0].
+
+       * loadup.el: Error out if default-directory is a multibyte string
+       when we are dumping.
+
+       * Makefile.in (emacs): Don't set LC_ALL=C.  (Bug#15260)
+
+2013-11-04  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * emacs-lisp/package.el (package-menu-mode)
+       (package-menu--print-info, package-menu--archive-predicate):
+       Add Archive column to package list.
+
+2013-11-04  Michael Albinus  <michael.albinus@gmx.de>
+
+       Fix problems found while writing a test suite.
+
+       * net/tramp.el (tramp-file-name-regexp-unified): Simplify.
+       (tramp-file-name-for-operation): Use `tramp-tramp-file-p'.
+       (tramp-handle-substitute-in-file-name): Let-bind `process-environment'
+       to nil when running original file name handler.  Otherwise,
+       there are problems with constructs like "$$FOO".
+
+       * net/tramp-sh.el (tramp-do-copy-or-rename-file): Use correct prefix
+       for `localname'.
+
+2013-11-04  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/ruby-mode.el (ruby-mode): Clean up docstring.
+
+       * subr.el (version<, version<=, version=):
+       Update docstrings with information for snapshot versions.
+
+       * helpers.el: New library for misc helper functions.
+       (hash-table-keys): New function returning a list of hash keys.
+       (hash-table-values): New function returning a list of hash values.
+
+2013-11-04  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--forward-token)
+       (ruby-smie--backward-token): Tokenize heredocs as semicolons.
+
+2013-11-04  Michal Nazarewicz  <mina86@mina86.com>
+
+       * textmodes/fill.el (fill-single-char-nobreak-p): New function
+       checking whether point is after a 1-letter word.
+
+2013-11-04  Nathan Trapuzzano  <nbtrap@nbtrap.com>  (tiny change)
+
+       * progmodes/cperl-mode.el (cperl-font-lock-fontify-region-function):
+       Don't infloop when expanding region over `multiline' syntax-type that
+       begins a line (bug#15778).
+
+2013-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * rect.el (rectangle-mark-mode): Rename from rectangle-mark.
+       Make it into a proper minor mode.
+       (rectangle--region): (implicitly) rename to rectangle-mark-mode.
+       (rectangle-mark-mode-map): New keymap.
+       (rectangle--highlight-for-redisplay): Fix some corner cases (bug#15796).
+
+2013-11-04  Glenn Morris  <rgm@gnu.org>
+
+       * startup.el (command-line-1): Allow `-L :...' to append to load-path.
+
+2013-11-03  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): Remove.
+       (ruby-smie-rules): Use smie-rule-parent instead.
+
+       * emacs-lisp/smie.el (smie-rule-parent): Always call
+       smie-indent-virtual rather than only for hanging tokens.
+       (smie--next-indent-change): New helper command.
+
+2013-11-03  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_srcdir): Remove.
+       (emacs): Unset EMACSLOADPATH.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (EMACS): Use a relative filename.
+       (abs_top_builddir): Remove.
+       (custom-deps, finder-data, autoloads): Use --chdir.
+
+       * Makefile.in (abs_lisp): Remove, replace by abs_srcdir.
+
+       Use relative filenames in TAGS files.
+       * Makefile.in (lisptagsfiles1, lisptagsfiles2, lisptagsfiles3)
+       (lisptagsfiles4, TAGS): Use relative file names.
+       (TAGS-LISP): Remove.
+       (maintainer-clean): No more TAGS-LISP file.
+
+       * Makefile.in (lisptagsfiles1, lisptagsfiles2, lisptagsfiles3)
+       (lisptagsfiles4): Use absolute filenames again.
+       (TAGS, TAGS-LISP): Not everything needs to run in one line.
+       Remove all *loaddefs files, not just the first.  Remove esh-groups.
+       (maintainer-clean): Delete TAGS, TAGS-LISP.
+
+2013-11-02  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * emacs-lisp/package.el (package-version-join):
+       Recognize snapshot versions.
+
+2013-11-02  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * subr.el (version-regexp-alist): Add support for snapshot versions.
+
+2013-11-02  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign):
+       New function, replacement for `smie-rule-parent' for when we want to
+       skip over our direct parent if it's an assignment token..
+       (ruby-smie-rules): Use it.
+
+2013-11-02  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el Use `syntax-propertize-function'
+       unconditionally.  Remove now unnecessary forward declarations.
+       Remove XEmacs-specific setup.
+       (ruby-here-doc-end-re, ruby-here-doc-beg-match)
+       (ruby-font-lock-syntactic-keywords)
+       (ruby-comment-beg-syntax, ruby-in-here-doc-p)
+       (ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
+       (ruby-here-doc-end-syntax): Remove.
+       (ruby-mode): Don't check whether `syntax-propertize-rules' is
+       defined as function.
+
+2013-11-02  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/ruby-mode.el (ruby-mode-variables, ruby-mode): Use `setq-local'.
+
+2013-11-01  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/ruby-mode.el (ruby-mode-variables): Don't set syntax
+       table and abbrev table, `define-derived-mode' does that for us
+       anyway.
+
+2013-11-01  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in: Remove manual mh-e dependencies (writing .elc
+       files is atomic for some time, so no parallel compilation issues).
+
+2013-11-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * faces.el (face-x-resources): Add :distant-foreground.
+       (region): Use :distant-foreground for gtk and ns.
+
+2013-11-01  Tassilo Horn  <tsdh@gnu.org>
+
+       Allow multiple bibliographies when BibLaTeX is used rather than
+       BibTeX.
+       * textmodes/reftex-parse.el (reftex-using-biblatex-p): New function.
+       (reftex-locate-bibliography-files): Us it.
+
+2013-11-01  Claudio Bley  <claudio.bley@googlemail.com>
+
+       * image.el (image-type-header-regexps): Fix the 'pbm' part to
+       allow comments in pbm files.
+
+       * term/w32-win.el (dynamic-library-alist): Support newer versions
+       of libjpeg starting with v7: look only for the DLL from the
+       version against which Emacs was built.
+       Support versions of libpng beyond 1.4.x.
+       Support libtiff v4.x.
+
+2013-11-01  Bozhidar Batsov  <bozhidar@batsov.com>
+
+       * progmodes/ruby-mode.el (ruby-indent-tabs-mode)
+       (ruby-indent-level, ruby-comment-column, ruby-deep-arglist):
+       Add property :safe.
+       (ruby-deep-arglist): Add property :type.
+
+2013-10-31  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (custom-deps, finder-data): No need to setq the target
+       variables, we are in the right directory and the defaults work fine.
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (autoloads): Do not use abs_lisp.
+
+       * emacs-lisp/autoload.el (autoload-generate-file-autoloads):
+       `newline' does not respect `standard-output', so use `princ'.
+
+2013-10-30  Alp Aker  <alp.tekin.aker@gmail.com>
+
+       Ensure unmarking in buffer menu clears 'S' marks.  (Bug#15761)
+       * buff-menu.el (Buffer-menu--unmark): New function.
+       (Buffer-menu-unmark, Buffer-menu-backup-unmark): Use it.
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (AUTOGENEL): Add org/org-loaddefs.el.
+
+       * emacs-lisp/package.el (lm-homepage): Declare.
+
+       * eshell/em-ls.el (eshell-ls-directory, eshell-ls-symlink):
+       Fix doc typos.
+
+       * vc/pcvs.el (cvs-status-cvstrees): Autoload to silence compiler.
+
+       * Makefile.in (finder-data, autoloads, update-subdirs)
+       (compile-main, compile-clean, compile-always, bootstrap-clean):
+       Check return value of cd.
+       (compile-calc): Remove.
+
+2013-10-30  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * simple.el (copy-region-as-kill): Fix call to region-extract-function.
+
+       * emacs-lisp/bytecomp.el (byte-defop-compiler): Add new `2-and' handler.
+       (byte-compile-and-folded): New function.
+       (=, <, >, <=, >=): Use it.
+
+       * dos-w32.el (minibuffer-history-case-insensitive-variables)
+       (path-separator, null-device, buffer-file-coding-system)
+       (lpr-headers-switches): Check system-type before modifying them.
+       (find-buffer-file-type-coding-system): Mark obsolete.
+       (w32-find-file-not-found-set-buffer-file-coding-system): Rename from
+       find-file-not-found-set-buffer-file-coding-system.
+       (w32-untranslated-filesystem-list, w32-untranslated-canonical-name):
+       (w32-add-untranslated-filesystem, w32-remove-untranslated-filesystem)
+       (w32-direct-print-region-use-command-dot-com, w32-untranslated-file-p):
+       (w32-direct-print-region-helper, w32-direct-print-region-function)
+       (w32-direct-ps-print-region-function): Rename by adding a "w32-" prefix.
+       * startup.el (normal-top-level-add-subdirs-to-load-path):
+       * ps-print.el (ps-print-region-function):
+       * lpr.el (print-region-function): Use new name.
+
+       * subr.el (custom-declare-variable-early): Remove function.
+       (custom-declare-variable-list): Remove var.
+       (error, user-error): Remove `while' loop.
+       (read-quoted-char-radix, read-quoted-char): Move to simple.el.
+       (user-emacs-directory-warning, locate-user-emacs-file):
+       Move to files.el.
+       * simple.el (read-quoted-char-radix, read-quoted-char):
+       * files.el (user-emacs-directory-warning, locate-user-emacs-file):
+       Move from subr.el.
+       * custom.el (custom-declare-variable-list): Don't process
+       custom-declare-variable-list.
+
+       * progmodes/python.el (python-shell-get-buffer): New function.
+       (python-shell-get-process): Use it.
+       (python-shell-send-string): Always use utf-8 and add a cookie to tell
+       Python which encoding was used.  Don't split-string since we only care
+       about the first line.  Return the temp-file, if applicable.
+       (python-shell-send-region): Tell compile.el how to turn locations in
+       the temp-file into locations in the source buffer.
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * subr.el (undefined): Add missing behavior from the C code for
+       unbound keys.
+
+       * rect.el: Use lexical-binding.  Add new rectangular region support.
+       (rectangle-mark): New command.
+       (rectangle--region): New var.
+       (deactivate-mark-hook): Reset rectangle--region.
+       (rectangle--extract-region, rectangle--insert-for-yank)
+       (rectangle--highlight-for-redisplay)
+       (rectangle--unhighlight-for-redisplay): New functions.
+       (region-extract-function, redisplay-unhighlight-region-function)
+       (redisplay-highlight-region-function): Use them to handle
+       rectangular region.
+       * simple.el (region-extract-function): New var.
+       (delete-backward-char, delete-forward-char, deactivate-mark): Use it.
+       (kill-new, kill-append): Remove obsolete `yank-handler' argument.
+       (kill-region): Replace obsolete `yank-handler' arg with `region'.
+       (copy-region-as-kill, kill-ring-save): Add `region' argument.
+       (redisplay-unhighlight-region-function)
+       (redisplay-highlight-region-function): New vars.
+       (redisplay--update-region-highlight): New function.
+       (pre-redisplay-function): Use it.
+       (exchange-point-and-mark): Don't deactivate the mark before
+       reactivate-it anyway.
+       * comint.el (comint-kill-region): Remove yank-handler argument.
+       * delsel.el (delete-backward-char, backward-delete-char-untabify)
+       (delete-char): Remove property, since it's now part of their
+       default behavior.
+       (self-insert-iso): Remove property since this command doesn't exist.
+
+       * emacs-lisp/package.el (package--download-one-archive)
+       (describe-package-1): Don't query the user about final newline.
+
+2013-10-29  Daniel Colascione  <dancol@dancol.org>
+
+       * net/tramp.el (tramp-methods): Document new functionality.
+       * net/tramp-sh.el (tramp-compute-multi-hops): Punt to
+       tramp-hostname-checker if method provides one instead of scanning
+       argument list for "%h" to decide hostname acceptability.
+
+2013-10-28  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp-sh.el (tramp-sh-handle-copy-directory):
+       * net/tramp-smb.el (tramp-smb-handle-copy-directory):
+       Handle COPY-CONTENTS.  (Bug#15737)
+
+2013-10-28  Daiki Ueno  <ueno@gnu.org>
+
+       * epa-file.el
+       (epa-file-cache-passphrase-for-symmetric-encryption):
+       Document that this option has no effect with GnuPG 2.0 (bug#15552).
+
+2013-10-27  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * image.el (defimage):
+       (image-load-path): Doc fixes.
+
+2013-10-27  Alan Mackenzie  <acm@muc.de>
+
+       Indent statements in macros following "##" correctly.
+       * progmodes/cc-engine.el (c-crosses-statement-barrier-p):
+       Modify the "#" arm of a cond form to handle "#" and "##" operators.
+
+2013-10-27  Nathan Trapuzzano  <nbtrap@nbtrap.com>  (tiny change)
+
+       * linum.el (linum-update-window): Fix boundary test (bug#13446).
+
+2013-10-27  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--bosp): Anything that goes
+       after `=' is probably a new expression.
+
+2013-10-27  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+       * man.el (man-imenu-title): New option.
+       (Man-mode-map): Add menu.  (Bug#15722)
+       (Man-mode): Add imenu to menu.
+
+2013-10-26  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--args-separator-p): Be more
+       specific in what the first arg can be: a non-keyword word,
+       string/regexp/percent literal opener, opening paren, or unary
+       operator followed directly by word.
+
+2013-10-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/prolog.el: Remove old indent; use post-self-insert-hook.
+       (prolog-align-comments-flag, prolog-indent-mline-comments-flag)
+       (prolog-object-end-to-0-flag, prolog-electric-newline-flag)
+       (prolog-electric-tab-flag, prolog-use-prolog-tokenizer-flag):
+       Remove vars, they do not apply any more.
+       (prolog-mode-abbrev-table): Remove redundant declaration.
+       (prolog-upper-case-string, prolog-lower-case-string): Remove.
+       (prolog-use-smie): Remove.
+       (prolog-smie-rules): Add indentation rule for the if-then-else layout
+       supported by prolog-electric-if-then-else-flag.
+       (prolog-mode-variables, prolog-menu): Use setq-local.
+       (prolog-mode-keybindings-edit): Don't rebind M-C-p and M-C-n.
+       Remove binding to `Backspace' since this key doesn't exist anyway.
+       Remove bindings for electric self-inserting keys.
+       (prog-mode): Assume it's defined.
+       (prolog-post-self-insert): New function.
+       (prolog-mode): Use it.
+       (prolog-indent-line, prolog-indent-level)
+       (prolog-find-indent-of-matching-paren)
+       (prolog-indentation-level-of-line, prolog-goto-comment-column)
+       (prolog-paren-is-the-first-on-line-p, prolog-region-paren-balance)
+       (prolog-goto-next-paren, prolog-in-string-or-comment)
+       (prolog-tokenize, prolog-inside-mline-comment)
+       (prolog-find-start-of-mline-comment): Remove functions.
+       (prolog-find-unmatched-paren, prolog-clause-end)
+       (prolog-guess-fill-prefix, prolog-get-predspec): Use syntax-ppss.
+       (prolog-electric--if-then-else): Rename from
+       prolog-insert-spaces-after-paren; use prolog-electric-if-then-else-flag.
+       (prolog-tokenize-searchkey): Remove const.
+       (prolog-clause-info): Use forward-sexp.
+       (prolog-forward-list, prolog-backward-list, prolog-electric-delete)
+       (prolog-electric-if-then-else): Remove commands.
+       (prolog-electric--colon): Rename from prolog-electric-colon; adapt it
+       for use in post-self-insert-hook.
+       (prolog-electric--dash): Rename from prolog-electric-dash; adapt it
+       for use in post-self-insert-hook.
+       (prolog-electric--dot): Rename from prolog-electric-dot; adapt it
+       for use in post-self-insert-hook.
+       (prolog-electric--underscore): Rename from prolog-electric--underscore;
+       adapt it for use in post-self-insert-hook.
+
+2013-10-25  Michael Albinus  <michael.albinus@gmx.de>
+
+       * emacs-lisp/ert.el (ert-run-tests-interactively):
+       Use `completing-read'.  (Bug#9756)
+
+2013-10-25  Eli Zaretskii  <eliz@gnu.org>
+
+       * simple.el (line-move): Call line-move-1 instead of
+       line-move-visual when the current window hscroll is zero, but
+       temporary-goal-column indicates we will need to hscroll as result
+       of the movement.  (Bug#15712)
+
+2013-10-25  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-mode-menu): Use proper
+       capitalization.  Use :visible instead of :active.
+       Fix `ruby-indent-exp' reference.  Add menu items for the generic
+       commands that are used with SMIE.
+       (ruby-do-end-to-brace): Insert space after `{'.
+
+2013-10-25  John Anthony  <john@jo.hnanthony.com>
+
+       * progmodes/ruby-mode.el (ruby-mode-menu): Add a menu.  (Bug#15600)
+
+       * progmodes/inf-lisp.el (inferior-lisp-menu): Add a menu.  (Bug#15599)
+
+2013-10-25  Glenn Morris  <rgm@gnu.org>
+
+       * vc/vc.el (vc-print-log): Don't use a working revision unless
+       one was explicitly specified.  (Bug#15322)
+
+2013-10-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * subr.el (add-to-list): Preserve return value in compiler-macro
+       (bug#15692).
+
+2013-10-25  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+       * progmodes/octave.el (octave-lookfor): Handle empty lookfor
+       result.  Ask user to retry using '-all' flag.  (Bug#15701)
+
+2013-10-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/smie.el: New smie-config system.
+       (smie-config): New defcustom.
+       (smie-edebug, smie-config-show-indent, smie-config-set-indent)
+       (smie-config-guess, smie-config-save): New commands.
+       (smie-config--mode-local, smie-config--buffer-local)
+       (smie-config--trace, smie-config--modefuns): New vars.
+       (smie-config--advice, smie-config--mode-hook)
+       (smie-config--setter, smie-config-local, smie-config--get-trace)
+       (smie-config--guess-value, smie-config--guess): New functions.
+       (smie-indent-forward-token, smie-indent-backward-token): Don't copy
+       text properties.  Treat "string fence" syntax like string syntax.
+
+       * progmodes/sh-script.el (sh-use-smie): Change default.
+       (sh-smie-sh-rules, sh-smie-rc-rules): Obey legacy sh-indent-* vars.
+       (sh-var-value): Simplify by CSE.
+       (sh-show-indent, sh-set-indent, sh-learn-line-indent)
+       (sh-learn-buffer-indent): Redirect to their SMIE equivalent when SMIE
+       is used.
+       (sh-guess-basic-offset): Use cl-incf.
+       (sh-guess-basic-offset): Use push+nreverse to avoid O(n^2).
+
+2013-10-24  Helmut Eller  <eller.helmut@gmail.com>
+
+       * emacs-lisp/lisp-mode.el (lisp-cl-font-lock-keywords-2): Fix cut&paste
+       (bug#15699).
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_top_srcdir): Remove.
+       (update-subdirs): Use relative path to update-subdirs.
+
+2013-10-24  Eli Zaretskii  <eliz@gnu.org>
+
+       * Makefile.in ($(MH_E_DIR)/mh-loaddefs.el)
+       ($(TRAMP_DIR)/tramp-loaddefs.el, $(CAL_DIR)/cal-loaddefs.el)
+       ($(CAL_DIR)/diary-loaddefs.el, $(CAL_DIR)/hol-loaddefs.el):
+       Call unmsys--file-name before expand-file-name, not after it.
+
+2013-10-24  Michael Albinus  <michael.albinus@gmx.de>
+
+       * emacs-lisp/ert.el (ert-deftest): Bind macro `skip-unless'.
+       (ert-test-skipped): New error.
+       (ert-skip, ert-stats-skipped): New defuns.
+       (ert--skip-unless): New macro.
+       (ert-test-skipped): New struct.
+       (ert--run-test-debugger, ert-test-result-type-p)
+       (ert-test-result-expected-p, ert--stats, ert-stats-completed)
+       (ert--stats-set-test-and-result, ert-char-for-test-result)
+       (ert-string-for-test-result, ert-run-tests-batch)
+       (ert--results-update-ewoc-hf, ert-run-tests-interactively):
+       Handle skipped tests.  (Bug#9803)
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (check-declare): Remove unnecessary path in -l argument.
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+       (update-subdirs): Correct build-aux location.
+
+2013-10-24  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * vc/vc.el (vc-print-root-log): Always set `default-directory'
+       value, whether we could auto-deduce `backend', or not.
+
+       * progmodes/ruby-mode.el (ruby-smie-rules): Fix the "curly block
+       with parameters" example.  Simplify the "is it block or is it
+       hash" check, but also make it more thorough.
+
+2013-10-23  Masashi Fujimoto  <masfj.dev@gmail.com>  (tiny change)
+
+       * battery.el (battery-pmset): Handle OS X Mavericks.  (Bug#15694)
+
+2013-10-23  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/ruby-mode.el (ruby-smie-rules): Only align with parent of
+       { if it is hanging.
+
+       * progmodes/ruby-mode.el (ruby-smie-rules): Don't return 0 for
+       :before ";".
+
+2013-10-23  Jed Brown  <jed@59A2.org>  (tiny change)
+
+       * progmodes/compile.el (compilation-directory-matcher)
+       (compilation-page-delimiter):
+       Support GNU Make-4.0 directory quoting.  (Bug#15678)
+
+2013-10-23  Leo Liu  <sdl.web@gmail.com>
+
+       * ido.el (ido-tidy): Handle read-only text.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_srcdir, abs_lisp): New, set by configure.
+       (emacs, compile, compile-always):
+       Quote entities that might contain whitespace.
+       (custom-deps, finder-data, autoloads): Use abs_lisp.
+       ($(MH_E_DIR)/mh-loaddefs.el, $(TRAMP_DIR)/tramp-loaddefs.el)
+       ($(CAL_DIR)/cal-loaddefs.el, $(CAL_DIR)/diary-loaddefs.el)
+       ($(CAL_DIR)/hol-loaddefs.el): Manually expand target file name.
+
+2013-10-23  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie--at-dot-call):
+       Use `following-char'.
+
+2013-10-22  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/smie.el (smie-rule-parent): Fix opener-test.
+       * progmodes/ruby-mode.el (ruby-smie-rules):
+       Remove corresponding workaround.  Fix indentation rule of ";" so it
+       also applies when ";" is the parent.
+
+2013-10-22  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * frame.el (display-screens, display-pixel-height)
+       (display-pixel-width, display-mm-width, display-backing-store)
+       (display-save-under, display-planes, display-color-cells)
+       (display-visual-class, display-monitor-attributes-list):
+       Mention the optional ‘display’ argument in doc strings.
+
+2013-10-22  Michael Gauland  <mikelygee@amuri.net>
+
+       * progmodes/ebnf2ps.el (ebnf-prologue): Avoid PS error with some
+       viewers such as evince when ebnf-production-name-p is nil.  (Bug#15625)
+
+2013-10-21  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie-grammar): Remove outdated
+       TODO.  Add "." after " @ ".
+       (ruby-smie--at-dot-call): New function.  Checks if point at method
+       call with explicit target.
+       (ruby-smie--forward-token, ruby-smie--backward-token): Prepend "."
+       to the method name tokens when it precedes them.
+       (ruby-smie--backward-id, ruby-smie--forward-id): Remove.
+       (ruby-smie-rules): Add rule for indentation before and after "."
+       token.
+
+2013-10-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * textmodes/remember.el (remember-diary-extract-entries):
+       Avoid add-to-list.
+
+       * progmodes/ruby-mode.el (ruby-smie-rules): Indent after + used as
+       an instruction.
+
+2013-10-21  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/ruby-mode.el (ruby-smie-grammar): Add (almost) all infix operators.
+       (ruby-smie--implicit-semi-p): Add new operator chars.
+
+       * progmodes/ruby-mode.el (ruby-mode-map): Add binding for
+       `smie-down-list'.
+       (ruby-smie--args-separator-p): Check that there's no newline
+       between method call and its arguments.
+
+2013-10-20  Alan Mackenzie  <acm@muc.de>
+
+       Allow comma separated lists after Java "implements".
+
+       * progmodes/cc-engine.el (c-backward-over-enum-header):
+       Parse commas.
+       * progmodes/cc-fonts.el (c-basic-matchers-after): Remove comma
+       from a "disallowed" list in enum fontification.
+
+2013-10-20  Johan Bockgård  <bojohan@gnu.org>
+
+       * startup.el (default-frame-background-mode): Remove unused defvar.
+
+       * progmodes/verilog-mode.el (verilog-mode): Don't set
+       comment-indent-function globally.
+
+2013-10-20  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * menu-bar.el: Put help-menu in menu-bar-final-items unconditionally.
+       Move Info menu item creation to ns-win.el.
+
+       * term/ns-win.el (ns-initialize-window-system): Rename Help to Info
+       in menu bar.
+
+       * menu-bar.el: Move GNUStep specific menus...
+
+       * term/ns-win.el (ns-initialize-window-system): ... to here.
+
+2013-10-19  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * simple.el (newline): Only run post-self-insert-hook when
+       called interactively.
+
 2013-10-19  Johan Bockgård  <bojohan@gnu.org>
 
        * icomplete.el (icomplete-with-completion-tables): Add :version.
        * ielm.el (ielm-map): Bind M-RET to ielm-return-for-effect.
        (ielm-return-for-effect): New command.
        (ielm-send-input): Accept optional `for-effect' parameter.
-       (ielm-eval-input): Accept optional `for-effect' parameter.  Bind
-       `standard-output' to stream we create using
+       (ielm-eval-input): Accept optional `for-effect' parameter.
+       Bind `standard-output' to stream we create using
        `ielm-standard-output-impl'.  Suppress printing result when
        `for-effect'.
        (ielm-standard-output-impl): New function.
        * textmodes/text-mode.el (text-mode-map):
        Use auto-fill help text from menu-bar.el.
 
-2013-10-10  John Anthony  <john@jo.hnanthony.com>  (tiny change)
+2013-10-10  John Anthony  <john@jo.hnanthony.com>
 
        * textmodes/text-mode.el (text-mode-map): Add a menu.  (Bug#15562)
 
        * emacs-lisp/macroexp.el (macroexp--compiling-p): New function.
        (macroexp--warn-and-return): Use it.
 
+2013-06-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * lisp/subr.el: Convert to lexical binding.
+       (overriding-local-map): Make obsolete.
+       (add-to-list): Doc fix.  Add compiler macro.
+       (read-key): Swap values of local maps.
+
 2013-06-05  Leo Liu  <sdl.web@gmail.com>
 
        * eshell/esh-mode.el (eshell-mode): Fix key bindings.
index 4fba1053dfad61c2668a2fd9cb6299233664a646..d00330c3a9b53112a29bd242b3efc41c4c2457de 100644 (file)
@@ -21,7 +21,6 @@ SHELL = @SHELL@
 
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
-abs_top_builddir = @abs_top_builddir@
 lisp = $(srcdir)
 VPATH = $(srcdir)
 
@@ -32,10 +31,10 @@ XARGS_LIMIT = @XARGS_LIMIT@
 # You can specify a different executable on the make command line,
 # e.g. "make EMACS=../src/emacs ...".
 
-# We sometimes change directory before running Emacs (typically when
-# building out-of-tree, we chdir to the source directory), so we need
-# to use an absolute file name.
-EMACS = ${abs_top_builddir}/src/emacs
+# We never change directory before running Emacs, so a relative file
+# name is fine, and makes life easier.  If we need to change
+# directory, we can use emacs --chdir.
+EMACS = ../src/emacs
 
 # Command line flags for Emacs.
 
@@ -47,12 +46,6 @@ BYTE_COMPILE_EXTRA_FLAGS =
 # BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
 # The example above is just for developers, it should not be used by default.
 
-lisptagsfiles1 = $(lisp)/*.el
-lisptagsfiles2 = $(lisp)/*/*.el
-lisptagsfiles3 = $(lisp)/*/*/*.el
-lisptagsfiles4 = $(lisp)/*/*/*/*.el
-ETAGS = ../lib-src/etags
-
 # Automatically generated autoload files, apart from lisp/loaddefs.el.
 # Note this includes only those files that need special rules to
 # build; ie it does not need to include things created via
@@ -74,7 +67,8 @@ AUTOGENEL = loaddefs.el \
        eshell/esh-groups.el \
        cedet/semantic/loaddefs.el \
        cedet/ede/loaddefs.el \
-       cedet/srecode/loaddefs.el
+       cedet/srecode/loaddefs.el \
+       org/org-loaddefs.el
 
 # Versioned files that are the value of someone's `generated-autoload-file'.
 # Note that update_loaddefs parses this.
@@ -111,29 +105,26 @@ COMPILE_FIRST = \
        $(lisp)/emacs-lisp/autoload.elc
 
 # The actual Emacs command run in the targets below.
-
-emacs = EMACSLOADPATH=$(lisp) LC_ALL=C $(EMACS) $(EMACSOPT)
+# Prevent any setting of EMACSLOADPATH in user environment causing problems.
+emacs = unset EMACSLOADPATH; "$(EMACS)" $(EMACSOPT)
 
 # Common command to find subdirectories
-setwins=subdirs=`find . -type d -print`; \
-       for file in $$subdirs; do \
-          case $$file in */.* | */.*/* | */=* ) ;; \
+setwins=for file in `find . -type d -print`; do \
+          case $$file in */.* ) ;; \
                *) wins="$$wins$${wins:+ }$$file" ;; \
           esac; \
-        done
+       done
 
 # Find all subdirectories except `obsolete' and `term'.
-setwins_almost=subdirs=`find . -type d -print`; \
-       for file in $$subdirs; do \
-          case $$file in */.* | */.*/* | */=* | */obsolete | */term ) ;; \
+setwins_almost=for file in `find ${srcdir} -type d -print`; do \
+          case $$file in ${srcdir}*/obsolete | ${srcdir}*/term ) ;; \
                *) wins="$$wins$${wins:+ }$$file" ;; \
           esac; \
         done
 
-# Find all subdirectories in which we might want to create subdirs.el
-setwins_for_subdirs=subdirs=`find . -type d -print`; \
-       for file in $$subdirs; do \
-          case $$file in */.* | */.*/* | */=* | */cedet* ) ;; \
+# Find all subdirectories in which we might want to create subdirs.el.
+setwins_for_subdirs=for file in `find ${srcdir} -type d -print`; do \
+          case $$file in ${srcdir}*/cedet* ) ;; \
                *) wins="$$wins$${wins:+ }$$file" ;; \
           esac; \
         done
@@ -163,25 +154,31 @@ doit:
 $(lisp)/cus-load.el:
        $(MAKE) $(MFLAGS) custom-deps
 custom-deps: doit
-       cd $(lisp); $(setwins_almost); \
+       $(setwins_almost); \
        echo Directories: $$wins; \
-       $(emacs) -l cus-dep --eval '(setq generated-custom-dependencies-file (unmsys--file-name "$(lisp)/cus-load.el"))' -f custom-make-dependencies $$wins
+       $(emacs) -l cus-dep \
+         --eval '(setq generated-custom-dependencies-file "$(srcdir)/cus-load.el")' \
+         -f custom-make-dependencies $$wins
 
 $(lisp)/finder-inf.el:
        $(MAKE) $(MFLAGS) finder-data
 finder-data: doit
-       cd $(lisp); $(setwins_almost); \
+       $(setwins_almost); \
        echo Directories: $$wins; \
-       $(emacs) -l finder --eval '(setq generated-finder-keywords-file (unmsys--file-name "$(lisp)/finder-inf.el"))' -f finder-compile-keywords-make-dist $$wins
+       $(emacs) -l finder \
+         --eval '(setq generated-finder-keywords-file "$(srcdir)/finder-inf.el")' \
+         -f finder-compile-keywords-make-dist $$wins
 
 # The chmod +w is to handle env var CVSREAD=1.
+# Use expand-file-name rather than $abs_scrdir so that Emacs does not
+# get confused when it compares file-names for equality.
 autoloads: $(LOADDEFS) doit
        cd $(lisp) && chmod +w $(AUTOGEN_VCS)
-       cd $(lisp); $(setwins_almost); \
+       $(setwins_almost); \
        echo Directories: $$wins; \
        $(emacs) -l autoload \
            --eval '(setq autoload-builtin-package-versions t)' \
-           --eval '(setq generated-autoload-file (unmsys--file-name "$(lisp)/loaddefs.el"))' \
+           --eval '(setq generated-autoload-file (expand-file-name "$(srcdir)/loaddefs.el"))' \
            -f batch-update-autoloads $$wins
 
 # This is required by the bootstrap-emacs target in ../src/Makefile, so
@@ -189,9 +186,9 @@ autoloads: $(LOADDEFS) doit
 $(lisp)/subdirs.el:
        $(MAKE) $(MFLAGS) update-subdirs
 update-subdirs: doit
-       cd $(lisp); $(setwins_for_subdirs); \
+       $(setwins_for_subdirs); \
        for file in $$wins; do \
-          $(top_srcdir)/build-aux/update-subdirs $$file; \
+          $(srcdir)/../build-aux/update-subdirs $$file; \
        done;
 
 .PHONY: updates bzr-update update-authors
@@ -212,10 +209,28 @@ bzr-update: compile finder-data custom-deps
 update-authors:
        $(emacs) -l authors -f batch-update-authors $(top_srcdir)/etc/AUTHORS $(top_srcdir)
 
-TAGS TAGS-LISP: $(lisptagsfiles1) $(lisptagsfiles2) $(lisptagsfiles3) $(lisptagsfiles4)
-       rm -f $@; touch $@; \
-        echo $(lisptagsfiles1) $(lisptagsfiles2) $(lisptagsfiles3) $(lisptagsfiles4) | sed -e "s,$(lisp)/[^ ]*loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,," | \
-       xargs $(XARGS_LIMIT) ${ETAGS} -a -o $@
+
+ETAGS = ../lib-src/etags
+
+lisptagsfiles1 = $(srcdir)/*.el
+lisptagsfiles2 = $(srcdir)/*/*.el
+lisptagsfiles3 = $(srcdir)/*/*/*.el
+lisptagsfiles4 = $(srcdir)/*/*/*/*.el
+
+## The echo | sed | xargs is to stop the command line getting too long
+## on MS Windows, when the MSYS Bash passes it to a MinGW compiled
+## etags.  It might be better to use find in a similar way to
+## compile-main.  But maybe this is not even necessary any more now
+## that this uses relative filenames.
+TAGS: $(lisptagsfiles1) $(lisptagsfiles2) $(lisptagsfiles3) $(lisptagsfiles4)
+       rm -f $@
+       touch $@
+       echo $(lisptagsfiles1) $(lisptagsfiles2) $(lisptagsfiles3) $(lisptagsfiles4) | \
+         sed -e 's,$(srcdir)/[^ ]*loaddefs[^ ]*,,g' \
+           -e 's,$(srcdir)/ldefs-boot[^ ]*,,' \
+           -e 's,$(srcdir)/[^ ]*esh-groups.el[^ ]*,,' | \
+           xargs $(XARGS_LIMIT) "$(ETAGS)" -a -o $@
+
 
 # The src/Makefile.in has its own set of dependencies and when they decide
 # that one Lisp file needs to be re-compiled, we had better recompile it as
@@ -263,7 +278,7 @@ compile-first: $(COMPILE_FIRST)
 # In `compile-main' we could directly do
 #    ... | xargs $(MAKE) $(MFLAGS) EMACS="$(EMACS)"
 # and it works, but it generates a lot of messages like
-#    make[2]: « gnus/gnus-mlspl.elc » is up to date.
+#    make[2]: gnus/gnus-mlspl.elc is up to date.
 # so instead, we use "xargs echo" to split the list of file into manageable
 # chunks and then use an intermediate `compile-targets' target so the
 # actual targets (the .elc files) are not mentioned as targets on the
@@ -277,7 +292,7 @@ compile-targets: $(TARGETS)
 # Compile all the Elisp files that need it.  Beware: it approximates
 # `no-byte-compile', so watch out for false-positives!
 compile-main: compile-clean
-       @(cd $(lisp); $(setwins); \
+       @(cd $(lisp) && $(setwins); \
        els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
        for el in $$els; do \
          test -f $$el || continue; \
@@ -291,7 +306,7 @@ compile-main: compile-clean
 .PHONY: compile-clean
 # Erase left-over .elc files that do not have a corresponding .el file.
 compile-clean:
-       @cd $(lisp); $(setwins); \
+       @cd $(lisp) && $(setwins); \
        elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
        for el in `echo $$elcs | sed -e 's/\.elc/\.el/g'`; do \
          if test -f "$$el" -o \! -f "$${el}c"; then :; else \
@@ -307,22 +322,16 @@ compile-clean:
 # Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
 # sub-makes that run rules that use it, for the sake of some non-GNU makes.
 compile: $(LOADDEFS) autoloads compile-first
-       $(MAKE) $(MFLAGS) compile-main EMACS=$(EMACS)
+       $(MAKE) $(MFLAGS) compile-main EMACS="$(EMACS)"
 
 # Compile all Lisp files.  This is like `compile' but compiles files
 # unconditionally.  Some files don't actually get compiled because they
 # set the local variable no-byte-compile.
 compile-always: doit
-       cd $(lisp); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
-       $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
+       cd $(lisp) && rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
+       $(MAKE) $(MFLAGS) compile EMACS="$(EMACS)"
 
-.PHONY: compile-calc backup-compiled-files compile-after-backup
-
-compile-calc:
-       for el in $(lisp)/calc/*.el; do \
-         echo Compiling $$el; \
-         $(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $$el || exit 1;\
-       done
+.PHONY: backup-compiled-files compile-after-backup
 
 # Backup compiled Lisp files in elc.tar.gz.  If that file already
 # exists, make a backup of it.
@@ -378,7 +387,7 @@ mh-autoloads: $(MH_E_DIR)/mh-loaddefs.el
 $(MH_E_DIR)/mh-loaddefs.el: $(MH_E_SRC)
        $(emacs) -l autoload \
           --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \
-          --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \
+          --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \
           --eval "(setq make-backup-files nil)" \
           -f batch-update-autoloads $(MH_E_DIR)
 
@@ -396,7 +405,7 @@ TRAMP_SRC = $(TRAMP_DIR)/tramp.el    $(TRAMP_DIR)/tramp-adb.el      \
 $(TRAMP_DIR)/tramp-loaddefs.el: $(TRAMP_SRC)
        $(emacs) -l autoload \
           --eval "(setq generate-autoload-cookie \";;;###tramp-autoload\")" \
-          --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \
+          --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \
           --eval "(setq make-backup-files nil)" \
           -f batch-update-autoloads $(TRAMP_DIR)
 
@@ -418,42 +427,49 @@ CAL_SRC = $(CAL_DIR)/cal-bahai.el $(CAL_DIR)/cal-china.el  \
 $(CAL_DIR)/cal-loaddefs.el: $(CAL_SRC)
        $(emacs) -l autoload \
           --eval "(setq generate-autoload-cookie \";;;###cal-autoload\")" \
-          --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \
+          --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \
           --eval "(setq make-backup-files nil)" \
           -f batch-update-autoloads $(CAL_DIR)
 
 $(CAL_DIR)/diary-loaddefs.el: $(CAL_SRC)
        $(emacs) -l autoload \
           --eval "(setq generate-autoload-cookie \";;;###diary-autoload\")" \
-          --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \
+          --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \
           --eval "(setq make-backup-files nil)" \
           -f batch-update-autoloads $(CAL_DIR)
 
 $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC)
        $(emacs) -l autoload \
           --eval "(setq generate-autoload-cookie \";;;###holiday-autoload\")" \
-          --eval "(setq generated-autoload-file (unmsys--file-name \"$@\"))" \
+          --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \
           --eval "(setq make-backup-files nil)" \
           -f batch-update-autoloads $(CAL_DIR)
 
 .PHONY: bootstrap-clean distclean maintainer-clean
 
 bootstrap-clean:
-       cd $(lisp); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc $(AUTOGENEL)
+       -cd $(lisp) && rm -f *.elc */*.elc */*/*.elc */*/*/*.elc $(AUTOGENEL)
 
 distclean:
        -rm -f ./Makefile $(lisp)/loaddefs.el~
 
 maintainer-clean: distclean bootstrap-clean
+       rm -f TAGS
 
 .PHONY: check-declare
 
 check-declare:
-       $(emacs) -l $(lisp)/emacs-lisp/check-declare \
-         --eval '(check-declare-directory "$(lisp)")'
+       $(emacs) -l check-declare --eval '(check-declare-directory "$(lisp)")'
 
 # Dependencies
 
+## None of the following matters for bootstrap, which is the only way
+## to ensure a correct compilation of all lisp files.
+## Manually specifying dependencies of a handful of lisp files, (and
+## ones that don't change very often at that) seems pretty pointless
+## to me.
+
+# http://debbugs.gnu.org/1004
 # CC Mode uses a compile time macro system which causes a compile time
 # dependency in cc-*.elc files on the macros in other cc-*.el and the
 # version string in cc-defs.el.
@@ -498,59 +514,4 @@ $(lisp)/progmodes/cc-styles.elc: $(lisp)/progmodes/cc-vars.elc \
 
 $(lisp)/progmodes/cc-vars.elc: $(lisp)/custom.elc $(lisp)/widget.elc
 
-# MH-E dependencies, mainly to prevent failures with parallel
-# compilation, due to race conditions between writing a given FOO.elc
-# file and another file being compiled that says "(require FOO)",
-# which causes Emacs to try to read FOO.elc.
-$(MH_E_DIR)/mh-alias.elc $(MH_E_DIR)/mh-comp.elc $(MH_E_DIR)/mh-folder.elc\
- $(MH_E_DIR)/mh-funcs.elc $(MH_E_DIR)/mh-identity.elc $(MH_E_DIR)/mh-inc.elc\
- $(MH_E_DIR)/mh-junk.elc $(MH_E_DIR)/mh-letter.elc $(MH_E_DIR)/mh-limit.elc\
- $(MH_E_DIR)/mh-mime.elc $(MH_E_DIR)/mh-print.elc $(MH_E_DIR)/mh-scan.elc\
- $(MH_E_DIR)/mh-search.elc $(MH_E_DIR)/mh-seq.elc $(MH_E_DIR)/mh-show.elc\
- $(MH_E_DIR)/mh-speed.elc $(MH_E_DIR)/mh-thread.elc $(MH_E_DIR)/mh-tool-bar.elc\
- $(MH_E_DIR)/mh-utils.elc $(MH_E_DIR)/mh-xface.elc:\
-   $(MH_E_DIR)/mh-e.elc
-
-$(MH_E_DIR)/mh-alias.elc $(MH_E_DIR)/mh-e.elc $(MH_E_DIR)/mh-folder.elc\
- $(MH_E_DIR)/mh-inc.elc $(MH_E_DIR)/mh-junk.elc $(MH_E_DIR)/mh-limit.elc\
- $(MH_E_DIR)/mh-search.elc $(MH_E_DIR)/mh-seq.elc $(MH_E_DIR)/mh-speed.elc\
- $(MH_E_DIR)/mh-utils.elc $(MH_E_DIR)/mh-xface.elc:\
-   $(lisp)/emacs-lisp/cl.elc
-
-$(MH_E_DIR)/mh-comp.elc $(MH_E_DIR)/mh-folder.elc $(MH_E_DIR)/mh-funcs.elc\
- $(MH_E_DIR)/mh-junk.elc $(MH_E_DIR)/mh-limit.elc $(MH_E_DIR)/mh-print.elc\
- $(MH_E_DIR)/mh-seq.elc $(MH_E_DIR)/mh-show.elc $(MH_E_DIR)/mh-thread.elc:\
-   $(MH_E_DIR)/mh-scan.elc
-
-$(MH_E_DIR)/mh-folder.elc $(MH_E_DIR)/mh-letter.elc $(MH_E_DIR)/mh-mime.elc\
- $(MH_E_DIR)/mh-search.elc $(MH_E_DIR)/mh-show.elc $(MH_E_DIR)/mh-speed.elc:\
-   $(lisp)/gnus/gnus-util.elc
-
-$(MH_E_DIR)/mh-folder.elc $(MH_E_DIR)/mh-search.elc:\
-   $(lisp)/progmodes/which-func.elc
-
-$(MH_E_DIR)/mh-letter.elc $(MH_E_DIR)/mh-seq.elc $(MH_E_DIR)/mh-show.elc\
- $(MH_E_DIR)/mh-utils.elc:\
-   $(lisp)/font-lock.elc
-
-$(MH_E_DIR)/mh-alias.elc $(MH_E_DIR)/mh-show.elc: $(lisp)/net/goto-addr.elc
-
-$(MH_E_DIR)/mh-comp.elc: $(lisp)/mail/sendmail.elc
-
-$(MH_E_DIR)/mh-e.elc: $(MH_E_DIR)/mh-buffers.elc $(lisp)/gnus/gnus.elc \
-   $(lisp)/cus-face.elc
-
-$(MH_E_DIR)/mh-letter.elc: $(lisp)/gnus/mailcap.elc $(lisp)/gnus/mm-decode.elc \
-   $(lisp)/gnus/mm-view.elc  $(lisp)/gnus/mml.elc $(lisp)/gnus/message.elc
-
-$(MH_E_DIR)/mh-print.elc:  $(lisp)/ps-print.elc
-
-$(MH_E_DIR)/mh-search.elc: $(lisp)/imenu.elc
-
-$(MH_E_DIR)/mh-show.elc: $(lisp)/gnus/gnus-cite.elc
-
-$(MH_E_DIR)/mh-speed.elc: $(lisp)/speedbar.elc $(lisp)/emacs-lisp/timer.elc
-
-$(MH_E_DIR)/mh-tool-bar.elc: $(lisp)/tool-bar.elc
-
 # Makefile ends here.
index 1c76156b91a6c6dd20fe305c04c9f6cf84888217..8bc3eb5a979339bb1671220fc8051bed43811fbb 100644 (file)
@@ -90,7 +90,6 @@
 
 ;;;_ : USER CUSTOMIZATION VARIABLES and incidental functions:
 ;;;_  > defgroup allout-widgets
-;;;###autoload
 (defgroup allout-widgets nil
   "Allout extension that highlights outline structure graphically.
 
index c22205d563459a839f0d38813ed0840e98dee081..57a030bbf4495ef1e9bb0a62644aceb4d1f2d24f 100644 (file)
@@ -1,7 +1,6 @@
 ;;; arc-mode.el --- simple editing of archives
 
-;; Copyright (C) 1995, 1997-1998, 2001-2013 Free Software Foundation,
-;; Inc.
+;; Copyright (C) 1995, 1997-1998, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Morten Welinder <terra@gnu.org>
 ;; Keywords: files archives msdog editing major-mode
@@ -326,7 +325,7 @@ Archive and member name will be added."
 ;; 7z archive configuration
 
 (defcustom archive-7z-extract
-  `(,archive-7z-program "x" "-so")
+  `(,(or archive-7z-program "7z") "x" "-so")
   "Program and its options to run in order to extract a 7z file member.
 Extraction should happen to standard output.  Archive and member name will
 be added."
@@ -338,7 +337,7 @@ be added."
   :group 'archive-7z)
 
 (defcustom archive-7z-expunge
-  `(,archive-7z-program "d")
+  `(,(or archive-7z-program "7z") "d")
   "Program and its options to run in order to delete 7z file members.
 Archive and member names will be added."
   :version "24.1"
@@ -349,7 +348,7 @@ Archive and member names will be added."
   :group 'archive-7z)
 
 (defcustom archive-7z-update
-  `(,archive-7z-program "u")
+  `(,(or archive-7z-program "7z") "u")
   "Program and its options to run in order to update a 7z file member.
 Options should ensure that specified directory will be put into the 7z
 file.  Archive and member name will be added."
index d4e4d8b3a31340f4a861b0a4dc661e1793ee1fc3..780278fc091d5787a809b00d92768420a34bc03f 100644 (file)
@@ -615,7 +615,7 @@ The following %-sequences are provided:
     (with-temp-buffer
       (ignore-errors (call-process "pmset" nil t nil "-g" "ps"))
       (goto-char (point-min))
-      (when (re-search-forward "Currentl?y drawing from '\\(AC\\|Battery\\) Power'" nil t)
+      (when (re-search-forward "\\(?:Currentl?y\\|Now\\) drawing from '\\(AC\\|Battery\\) Power'" nil t)
        (setq power-source (match-string 1))
        (when (re-search-forward "^ -InternalBattery-0[ \t]+" nil t)
          (when (looking-at "\\([0-9]\\{1,3\\}\\)%")
index 2ea6713216d443f7973295fea84ece97f4d26290..b3b4f76b5558a692440a1f747bb5d07fca407429 100644 (file)
@@ -891,6 +891,7 @@ if `inhibit-field-text-motion' is non-nil."
 
 (define-key ctl-x-map "\C-x" 'exchange-point-and-mark)
 (define-key ctl-x-map "\C-@" 'pop-global-mark)
+(define-key ctl-x-map " " 'rectangle-mark-mode)
 (define-key ctl-x-map [?\C- ] 'pop-global-mark)
 
 (define-key global-map "\C-n" 'next-line)
index 58fde695b39f9c7b79a3cd959c674c98534606e5..627c02f6e624dca3a79e15568d84af2922850d95 100644 (file)
@@ -353,14 +353,22 @@ It will be displayed by the \\<Buffer-menu-mode-map>\\[Buffer-menu-select] comma
   "Cancel all requested operations on buffer on this line and move down.
 Optional prefix arg means move up."
   (interactive "P")
-  (tabulated-list-set-col 0 " " t)
+  (Buffer-menu--unmark)
   (forward-line (if backup -1 1)))
 
 (defun Buffer-menu-backup-unmark ()
   "Move up and cancel all requested operations on buffer on line above."
   (interactive)
   (forward-line -1)
-  (tabulated-list-set-col 0 " " t))
+  (Buffer-menu--unmark))
+
+(defun Buffer-menu--unmark ()
+  (tabulated-list-set-col 0 " " t)
+  (let ((buf (Buffer-menu-buffer)))
+    (when buf
+      (if (buffer-modified-p buf)
+          (tabulated-list-set-col 2 "*" t)
+        (tabulated-list-set-col 2 " " t)))))
 
 (defun Buffer-menu-delete (&optional arg)
   "Mark the buffer on this Buffer Menu buffer line for deletion.
index 2795a177a414b8b928c4b9bb38d6e08a7480b930..72d456957c7cf6f981c21be44e14b564e0b691c5 100644 (file)
 (declare-function calc-set-language "calc-lang" (lang &optional option no-refresh))
 (declare-function calc-edit-finish "calc-yank" (&optional keep))
 (declare-function calc-edit-cancel "calc-yank" ())
+(declare-function calc-locate-cursor-element "calc-yank" (pt))
 (declare-function calc-do-quick-calc "calc-aent" ())
 (declare-function calc-do-calc-eval "calc-aent" (str separator args))
 (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive))
@@ -426,6 +427,13 @@ when converting units."
   :version "24.3"
   :type 'boolean)
 
+(defcustom calc-context-sensitive-enter
+  nil
+  "If non-nil, the stack element under the cursor will be copied by `calc-enter'."
+  :group 'calc
+  :version "24.4"
+  :type 'boolean)
+
 (defcustom calc-undo-length
   100
   "The number of undo steps that will be preserved when Calc is quit."
@@ -2257,8 +2265,10 @@ the United States."
         ((= n 0)
          (calc-push-list (calc-top-list (calc-stack-size))))
         (t
-         (calc-push-list (calc-top-list n))))))
-
+          (if (not calc-context-sensitive-enter)
+              (calc-push-list (calc-top-list n))
+            (let ((num (max 1 (calc-locate-cursor-element (point)))))
+              (calc-push-list (calc-top-list n num))))))))
 
 (defun calc-pop (n)
   (interactive "P")
index 4a017644c84c09d9bcb950f6ef0af90f7d5f1bf8..ecdebe0363cb2e5c7b2fca563730927a3b0e27a3 100644 (file)
@@ -1,7 +1,39 @@
+2013-11-16  Barry O'Reilly  <gundaetiapo@gmail.com>
+
+       * semantic/fw.el (semantic-exit-on-input)
+       (semantic-throw-on-input): Restore point before
+       accept-process-output because timers which redisplay can run.
+       (Bug#15045)
+
+2013-11-03  Johan Bockgård  <bojohan@gnu.org>
+
+       * semantic/lex.el (semantic-lex-start-block)
+       (semantic-lex-end-block): Move after definition of
+       semantic-lex-token macro.
+
+2013-10-28  Barry O'Reilly  <gundaetiapo@gmail.com>
+
+       * semantic/idle.el (semantic-idle-symbol-highlight)
+       (semantic-idle-symbol-highlight-face): Define face with defface
+       and obsolete the replaced one defined with defvar.  (Bug#15745)
+       * pulse.el (pulse-momentary-highlight-overlay)
+       (pulse-momentary-highlight-region): Fix typo in doc
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * semantic/grammar.el (semantic-grammar-mode-keywords-2)
+       (semantic-grammar-mode-keywords-3): Handle renamed font-lock vars.
+
+2013-10-20  Johan Bockgård  <bojohan@gnu.org>
+
+       * semantic/db-mode.el (global-semanticdb-minor-mode):
+       Remove hooks correctly.
+       (semanticdb-toggle-global-mode): Pass `toggle' to minor mode function.
+
 2013-09-28  Leo Liu  <sdl.web@gmail.com>
 
-       * semantic/texi.el (semantic-analyze-possible-completions): Use
-       ispell-lookup-words instead.  (Bug#15460)
+       * semantic/texi.el (semantic-analyze-possible-completions):
+       Use ispell-lookup-words instead.  (Bug#15460)
 
 2013-09-20  Glenn Morris  <rgm@gnu.org>
 
index d7720f25681ee3a442399c591030a85e81a212a6..72b225622c945cea021ffbbf6a55d891d5082a54 100644 (file)
@@ -255,7 +255,7 @@ is found, such as a `-version' variable, or the standard header."
       (save-excursion
        (if (file-symlink-p ec)
            (progn
-             ;; Desymlinkify
+             ;; Change symlinks to copies.
              (rename-file ec (concat ec ".tmp"))
              (copy-file (concat ec ".tmp") ec)
              (delete-file (concat ec ".tmp"))))
index 268beed8b1a6260f8bca5e65ad79acf47a462c75..4a3b5011617744eeeb0f9ed4cf54354dfc9abdfe 100644 (file)
@@ -180,7 +180,7 @@ Be sure to call `pulse-reset-face' after calling pulse."
 
 (defun pulse-momentary-highlight-overlay (o &optional face)
   "Pulse the overlay O, unhighlighting before next command.
-Optional argument FACE specifies the fact to do the highlighting."
+Optional argument FACE specifies the face to do the highlighting."
   (overlay-put o 'original-face (overlay-get o 'face))
   (add-to-list 'pulse-momentary-overlay o)
   (if (eq pulse-flag 'never)
@@ -237,7 +237,7 @@ Optional argument FACE specifies the face to do the highlighting."
 
 (defun pulse-momentary-highlight-region (start end &optional face)
   "Highlight between START and END, unhighlighting before next command.
-Optional argument FACE specifies the fact to do the highlighting."
+Optional argument FACE specifies the face to do the highlighting."
   (let ((o (make-overlay start end)))
     ;; Mark it for deletion
     (overlay-put o 'pulse-delete t)
index 7d147113a92939c70faff6de48acc8ed89f317b1..e0cb370845439600030654f2956059366747b509 100644 (file)
@@ -66,7 +66,7 @@ database, which can be saved for future Emacs sessions."
        (add-hook (cadr elt) (car elt)))
     ;; Disable
     (dolist (elt semanticdb-hooks)
-      (add-hook (cadr elt) (car elt)))))
+      (remove-hook (cadr elt) (car elt)))))
 
 (defvaralias 'semanticdb-mode-hook 'global-semanticdb-minor-mode-hook)
 (defvaralias 'semanticdb-global-mode 'global-semanticdb-minor-mode)
@@ -82,7 +82,7 @@ Update the environment of Semantic enabled buffers accordingly."
       ;; Save databases before disabling semanticdb.
       (semanticdb-save-all-db))
   ;; Toggle semanticdb minor mode.
-  (global-semanticdb-minor-mode))
+  (global-semanticdb-minor-mode 'toggle))
 
 ;;; Hook Functions:
 ;;
index 825cdc9f0a414a31e8ed8681a359f1af6c392b74..869d183514d2b089510a4b774a278867e55c6bfc 100644 (file)
@@ -369,6 +369,8 @@ later installation should be done in MODE hook."
 ;;
 (defvar semantic-current-input-throw-symbol nil
   "The current throw symbol for `semantic-exit-on-input'.")
+(defvar semantic--on-input-start-marker nil
+  "The marker when starting a semantic-exit-on-input form.")
 
 (defmacro semantic-exit-on-input (symbol &rest forms)
   "Using SYMBOL as an argument to `throw', execute FORMS.
@@ -376,7 +378,8 @@ If FORMS includes a call to `semantic-throw-on-input', then
 if a user presses any key during execution, this form macro
 will exit with the value passed to `semantic-throw-on-input'.
 If FORMS completes, then the return value is the same as `progn'."
-  `(let ((semantic-current-input-throw-symbol ,symbol))
+  `(let ((semantic-current-input-throw-symbol ,symbol)
+         (semantic--on-input-start-marker (point-marker)))
      (catch ,symbol
        ,@forms)))
 (put 'semantic-exit-on-input 'lisp-indent-function 1)
@@ -387,7 +390,16 @@ FROM is an indication of where this function is called from as a value
 to pass to `throw'.  It is recommended to use the name of the function
 calling this one."
   `(when (and semantic-current-input-throw-symbol
-              (or (input-pending-p) (accept-process-output)))
+              (or (input-pending-p)
+                  (save-excursion
+                    ;; Timers might run during accept-process-output.
+                    ;; If they redisplay, point must be where the user
+                    ;; expects. (Bug#15045)
+                    (set-buffer (marker-buffer
+                                 semantic--on-input-start-marker))
+                    (goto-char (marker-position
+                                semantic--on-input-start-marker))
+                    (accept-process-output))))
      (throw semantic-current-input-throw-symbol ,from)))
 
 \f
index 60c4ccadf65d88f7b5ae73b53c118afb6d1112ab..a545fcaee46091c35dfb0644ef389e31bc10f911 100644 (file)
@@ -1160,12 +1160,16 @@ END is the limit of the search."
 
 (defvar semantic-grammar-mode-keywords-2
   (append semantic-grammar-mode-keywords-1
-          lisp-font-lock-keywords-1)
+         (if (boundp 'lisp-font-lock-keywords-1)
+             lisp-font-lock-keywords-1
+           lisp-el-font-lock-keywords-1))
   "Font Lock keywords used to highlight Semantic grammar buffers.")
 
 (defvar semantic-grammar-mode-keywords-3
   (append semantic-grammar-mode-keywords-1
-          lisp-font-lock-keywords-2)
+         (if (boundp 'lisp-font-lock-keywords-2)
+             lisp-font-lock-keywords-2
+           lisp-el-font-lock-keywords-2))
   "Font Lock keywords used to highlight Semantic grammar buffers.")
 
 (defvar semantic-grammar-mode-keywords
index d024e5d823773a703c83c0691b8396467c80b99c..c15b6bf8bb45cb93a2d7584100c197bea9c4eaf2 100644 (file)
@@ -830,8 +830,14 @@ turned on in every Semantic-supported buffer."
 ;; of all uses of the symbol that is under the cursor.
 ;;
 ;; This is to mimic the Eclipse tool of a similar nature.
-(defvar semantic-idle-symbol-highlight-face 'region
+(defface semantic-idle-symbol-highlight
+  '((t :inherit region))
+  "Face used for highlighting local symbols."
+  :group 'semantic-faces)
+(defvar semantic-idle-symbol-highlight-face 'semantic-idle-symbol-highlight
   "Face used for highlighting local symbols.")
+(make-obsolete-variable 'semantic-idle-symbol-highlight-face
+    "customize the face `semantic-idle-symbol-highlight' instead" "24.4" 'set)
 
 (defun semantic-idle-symbol-maybe-highlight (tag)
   "Perhaps add highlighting to the symbol represented by TAG.
index feead78985c1a128a3c17f8755508a2878d7f407..1e571377b060b637a02e94764481c9395e269e8a 100644 (file)
@@ -831,63 +831,6 @@ analyzer which might mistake a number for as a symbol."
        ;; Return the token stream
        (nreverse semantic-lex-token-stream))))
 \f
-;;; Collapsed block tokens delimited by any tokens.
-;;
-(defun semantic-lex-start-block (syntax)
-  "Mark the last read token as the beginning of a SYNTAX block."
-  (if (or (not semantic-lex-maximum-depth)
-          (< semantic-lex-current-depth semantic-lex-maximum-depth))
-      (setq semantic-lex-current-depth (1+ semantic-lex-current-depth))
-    (push (list syntax (car semantic-lex-token-stream))
-          semantic-lex-block-stack)))
-
-(defun semantic-lex-end-block (syntax)
-  "Process the end of a previously marked SYNTAX block.
-That is, collapse the tokens inside that block, including the
-beginning and end of block tokens, into a high level block token of
-class SYNTAX.
-The token at beginning of block is the one marked by a previous call
-to `semantic-lex-start-block'.  The current token is the end of block.
-The collapsed tokens are saved in `semantic-lex-block-streams'."
-  (if (null semantic-lex-block-stack)
-      (setq semantic-lex-current-depth (1- semantic-lex-current-depth))
-    (let* ((stream semantic-lex-token-stream)
-           (blk (pop semantic-lex-block-stack))
-           (bstream (cdr blk))
-           (first (car bstream))
-           (last (pop stream)) ;; The current token mark the EOBLK
-           tok)
-      (if (not (eq (car blk) syntax))
-          ;; SYNTAX doesn't match the syntax of the current block in
-          ;; the stack. So we encountered the end of the SYNTAX block
-          ;; before the end of the current one in the stack which is
-          ;; signaled unterminated.
-          (semantic-lex-unterminated-syntax-detected (car blk))
-        ;; Move tokens found inside the block from the main stream
-        ;; into a separate block stream.
-        (while (and stream (not (eq (setq tok (pop stream)) first)))
-          (push tok bstream))
-        ;; The token marked as beginning of block was not encountered.
-        ;; This should not happen!
-        (or (eq tok first)
-            (error "Token %S not found at beginning of block `%s'"
-                   first syntax))
-        ;; Save the block stream for future reuse, to avoid to redo
-        ;; the lexical analysis of the block content!
-        ;; Anchor the block stream with its start position, so we can
-        ;; use: (cdr (assq start semantic-lex-block-streams)) to
-        ;; quickly retrieve the lexical stream associated to a block.
-        (setcar blk (semantic-lex-token-start first))
-        (setcdr blk (nreverse bstream))
-        (push blk semantic-lex-block-streams)
-        ;; In the main stream, replace the tokens inside the block by
-        ;; a high level block token of class SYNTAX.
-        (setq semantic-lex-token-stream stream)
-        (semantic-lex-push-token
-         (semantic-lex-token
-          syntax (car blk) (semantic-lex-token-end last)))
-        ))))
-\f
 ;;; Lexical token API
 ;;
 ;; Functions for accessing parts of a token.  Use these functions
@@ -1049,6 +992,63 @@ Optional argument DEPTH is the depth to scan into lists."
                 (semantic-lex-token-end   semlist)
                 depth))
 \f
+;;; Collapsed block tokens delimited by any tokens.
+;;
+(defun semantic-lex-start-block (syntax)
+  "Mark the last read token as the beginning of a SYNTAX block."
+  (if (or (not semantic-lex-maximum-depth)
+          (< semantic-lex-current-depth semantic-lex-maximum-depth))
+      (setq semantic-lex-current-depth (1+ semantic-lex-current-depth))
+    (push (list syntax (car semantic-lex-token-stream))
+          semantic-lex-block-stack)))
+
+(defun semantic-lex-end-block (syntax)
+  "Process the end of a previously marked SYNTAX block.
+That is, collapse the tokens inside that block, including the
+beginning and end of block tokens, into a high level block token of
+class SYNTAX.
+The token at beginning of block is the one marked by a previous call
+to `semantic-lex-start-block'.  The current token is the end of block.
+The collapsed tokens are saved in `semantic-lex-block-streams'."
+  (if (null semantic-lex-block-stack)
+      (setq semantic-lex-current-depth (1- semantic-lex-current-depth))
+    (let* ((stream semantic-lex-token-stream)
+           (blk (pop semantic-lex-block-stack))
+           (bstream (cdr blk))
+           (first (car bstream))
+           (last (pop stream)) ;; The current token mark the EOBLK
+           tok)
+      (if (not (eq (car blk) syntax))
+          ;; SYNTAX doesn't match the syntax of the current block in
+          ;; the stack. So we encountered the end of the SYNTAX block
+          ;; before the end of the current one in the stack which is
+          ;; signaled unterminated.
+          (semantic-lex-unterminated-syntax-detected (car blk))
+        ;; Move tokens found inside the block from the main stream
+        ;; into a separate block stream.
+        (while (and stream (not (eq (setq tok (pop stream)) first)))
+          (push tok bstream))
+        ;; The token marked as beginning of block was not encountered.
+        ;; This should not happen!
+        (or (eq tok first)
+            (error "Token %S not found at beginning of block `%s'"
+                   first syntax))
+        ;; Save the block stream for future reuse, to avoid to redo
+        ;; the lexical analysis of the block content!
+        ;; Anchor the block stream with its start position, so we can
+        ;; use: (cdr (assq start semantic-lex-block-streams)) to
+        ;; quickly retrieve the lexical stream associated to a block.
+        (setcar blk (semantic-lex-token-start first))
+        (setcdr blk (nreverse bstream))
+        (push blk semantic-lex-block-streams)
+        ;; In the main stream, replace the tokens inside the block by
+        ;; a high level block token of class SYNTAX.
+        (setq semantic-lex-token-stream stream)
+        (semantic-lex-push-token
+         (semantic-lex-token
+          syntax (car blk) (semantic-lex-token-end last)))
+        ))))
+\f
 ;;; Analyzer creation macros
 ;;
 ;; An individual analyzer is a condition and code that goes with it.
index 7572e8baabc6ba60590f03c2eef1ac3a7a3b59c2..8e1b2105de3ca23b54d6d6c3169b82e3ae804899 100644 (file)
@@ -2679,7 +2679,7 @@ if necessary."
     (kill-whole-line count)
     (when (>= count 0) (comint-update-fence))))
 
-(defun comint-kill-region (beg end &optional yank-handler)
+(defun comint-kill-region (beg end)
   "Like `kill-region', but ignores read-only properties, if safe.
 This command assumes that the buffer contains read-only
 \"prompts\" which are regions with front-sticky read-only
@@ -2693,7 +2693,6 @@ prompts should stay at the beginning of a line.  If this is not
 the case, this command just calls `kill-region' with all
 read-only properties intact.  The read-only status of newlines is
 updated using `comint-update-fence', if necessary."
-  (declare (advertised-calling-convention (beg end) "23.3"))
   (interactive "r")
   (save-excursion
     (let* ((true-beg (min beg end))
@@ -2708,9 +2707,9 @@ updated using `comint-update-fence', if necessary."
                         (if (listp end-lst) (memq 'read-only end-lst) t))))
       (if (or (and (not beg-bolp) (or beg-bad end-bad))
              (and (not end-bolp) end-bad))
-         (kill-region beg end yank-handler)
+         (kill-region beg end)
        (let ((inhibit-read-only t))
-         (kill-region beg end yank-handler)
+         (kill-region beg end)
          (comint-update-fence))))))
 \f
 ;; Support for source-file processing commands.
index e0585f808803235e09724309a8b4117ae2f4d2b4..f2f4437cadb652807e7b21a855a47605f3c5feb2 100644 (file)
@@ -630,14 +630,14 @@ All non-spacing characters have this function in
                   ((and (= class 0)
                         (eq (get-char-code-property (lglyph-char glyph)
                                                     'general-category) 'Me))
-                   ;; Artificially layouting glyphs in an enclosing
+                   ;; Artificially laying out glyphs in an enclosing
                    ;; mark is difficult.  All we can do is to adjust
                    ;; the x-offset and width of the base glyph to
                    ;; align it at the center of the glyph of the
                    ;; enclosing mark hoping that the enclosing mark
                    ;; is big enough.  We also have to adjust the
                    ;; x-offset and width of the mark ifself properly
-                   ;; depending on how the glyph is designed
+                   ;; depending on how the glyph is designed.
 
                    ;; (non-spacing or not).  For instance, when we
                    ;; have these glyphs:
index d721198da0bb1b7eb537e157a6bf5fca94ba0308..0df22a8b895cd1f51a1375b7cf3eb259dc658d01 100644 (file)
@@ -1489,11 +1489,6 @@ This means reset VARIABLE.  (The argument IGNORED is ignored)."
 
 ;;; The End.
 
-;; Process the defcustoms for variables loaded before this file.
-(while custom-declare-variable-list
-  (apply 'custom-declare-variable (car custom-declare-variable-list))
-  (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
-
 (provide 'custom)
 
 ;;; custom.el ends here
index 672c93443d8d5087defbbfd45236e8e65eee89ff..07a7a37db34a054ff690dc3966ae77e5fa4594f1 100644 (file)
@@ -165,16 +165,10 @@ See `delete-selection-helper'."
        (not (run-hook-with-args-until-success
              'self-insert-uses-region-functions))))
 
-(put 'self-insert-iso 'delete-selection t)
-
 (put 'yank 'delete-selection 'yank)
 (put 'clipboard-yank 'delete-selection 'yank)
 (put 'insert-register 'delete-selection t)
 
-(put 'delete-backward-char 'delete-selection 'supersede)
-(put 'backward-delete-char-untabify 'delete-selection 'supersede)
-(put 'delete-char 'delete-selection 'supersede)
-
 (put 'newline-and-indent 'delete-selection t)
 (put 'newline 'delete-selection t)
 (put 'open-line 'delete-selection 'kill)
index 0573caa6c23c1f721662d1c50fbcf64713ca987a..a556d30dc1275fd42951a13d822a209bb2f2edd3 100644 (file)
 ;;; Code:
 
 ;; Use ";" instead of ":" as a path separator (from files.el).
-(setq path-separator ";")
-
-(setq minibuffer-history-case-insensitive-variables
-      (cons 'file-name-history minibuffer-history-case-insensitive-variables))
-
-;; Set the null device (for compile.el).
-(setq null-device "NUL")
+(when (memq system-type '(ms-dos windows-nt))
+  (setq path-separator ";")
+  (push 'file-name-history minibuffer-history-case-insensitive-variables)
+  ;; Set the null device (for compile.el).
+  (setq null-device "NUL")
+  (setq-default buffer-file-coding-system 'undecided-dos))
 
 ;; For distinguishing file types based upon suffixes.  DEPRECATED, DO NOT USE!
 (defcustom file-name-buffer-file-type-alist
@@ -67,18 +66,16 @@ This variable is deprecated, not used anywhere, and will soon be deleted."
                        'file-coding-system-alist
                        "24.4")
 
-(setq-default buffer-file-coding-system 'undecided-dos)
-
 (defun find-buffer-file-type-coding-system (command)
   "Choose a coding system for a file operation in COMMAND.
 COMMAND is a list that specifies the operation, an I/O primitive, as its
 CAR, and the arguments that might be given to that operation as its CDR.
 If operation is `insert-file-contents', the coding system is chosen based
 upon the filename (the CAR of the arguments beyond the operation), the contents
-of `untranslated-filesystem-list' and `file-name-buffer-file-type-alist',
+of `w32-untranslated-filesystem-list' and `file-name-buffer-file-type-alist',
 and whether the file exists:
 
-  If it matches in `untranslated-filesystem-list':
+  If it matches in `w32-untranslated-filesystem-list':
     If the file exists:                                        `undecided'
     If the file does not exist:                                `undecided-unix'
   Otherwise:
@@ -95,7 +92,7 @@ upon the value of `buffer-file-coding-system'.  If
 Otherwise, it is `undecided-dos'.
 
 The most common situation is when DOS and Unix files are read and
-written, and their names do not match in `untranslated-filesystem-list'.
+written, and their names do not match in `w32-untranslated-filesystem-list'.
 In these cases, the coding system initially will be `undecided'.
 As the file is read in the DOS case, the coding system will be
 changed to `undecided-dos' as CR/LFs are detected.  As the file
@@ -135,7 +132,7 @@ when writing the file."
                                           (file-name-directory target)))))
                  (setq undecided t))
                 ;; Next check for a non-DOS file system.
-                ((untranslated-file-p target)
+                ((w32-untranslated-file-p target)
                  (setq undecided-unix t)))
           (cond (undecided-unix '(undecided-unix . undecided-unix))
                 (undecided '(undecided . undecided))
@@ -149,11 +146,14 @@ when writing the file."
             ;; buffer, because normally buffer-file-coding-system is non-nil
             ;; in a file-visiting buffer.
             '(undecided-dos . undecided-dos))))))
+(make-obsolete 'find-buffer-file-type-coding-system nil "24.4")
 
 (defun find-file-binary (filename)
   "Visit file FILENAME and treat it as binary."
+  ;; FIXME: Why here rather than in files.el?
+  ;; FIXME: Can't we use find-file-literally for the same purposes?
   (interactive "FFind file binary: ")
-  (let ((coding-system-for-read 'no-conversion))
+  (let ((coding-system-for-read 'no-conversion))  ;; FIXME: undecided-unix?
     (find-file filename)))
 
 (defun find-file-text (filename)
@@ -162,7 +162,7 @@ when writing the file."
   (let ((coding-system-for-read 'undecided-dos))
     (find-file filename)))
 
-(defun find-file-not-found-set-buffer-file-coding-system ()
+(defun w32-find-file-not-found-set-buffer-file-coding-system ()
   (with-current-buffer (current-buffer)
     (let ((coding buffer-file-coding-system))
       ;; buffer-file-coding-system is already set by
@@ -171,49 +171,50 @@ when writing the file."
       ;; the EOL conversion, if required by the user.
       (when (and (null coding-system-for-read)
                 (or inhibit-eol-conversion
-                    (untranslated-file-p (buffer-file-name))))
+                    (w32-untranslated-file-p (buffer-file-name))))
        (setq coding (coding-system-change-eol-conversion coding 0))
        (setq buffer-file-coding-system coding))
       nil)))
 
-;;; To set the default coding system on new files.
+;; To set the default coding system on new files.
 (add-hook 'find-file-not-found-functions
-         'find-file-not-found-set-buffer-file-coding-system)
+         'w32-find-file-not-found-set-buffer-file-coding-system)
 
 ;;; To accommodate filesystems that do not require CR/LF translation.
-(defvar untranslated-filesystem-list nil
+(define-obsolete-variable-alias 'untranslated-filesystem-list
+  'w32-untranslated-filesystem-list "24.4")
+(defvar w32-untranslated-filesystem-list nil
   "List of filesystems that require no CR/LF translation when reading
 and writing files.  Each filesystem in the list is a string naming
 the directory prefix corresponding to the filesystem.")
 
-(defun untranslated-canonical-name (filename)
+(defun w32-untranslated-canonical-name (filename)
   "Return FILENAME in a canonicalized form for use with the functions
 dealing with untranslated filesystems."
   (if (memq system-type '(ms-dos windows-nt cygwin))
       ;; The canonical form for DOS/W32 is with A-Z downcased and all
       ;; directory separators changed to directory-sep-char.
-      (let ((name nil))
-       (setq name (mapconcat
-                   (lambda (char)
-                      (if (and (<= ?A char) (<= char ?Z))
-                          (char-to-string (+ (- char ?A) ?a))
-                        (char-to-string char)))
-                   filename nil))
+      (let ((name
+             (mapconcat (lambda (char)
+                          (char-to-string (if (and (<= ?A char ?Z))
+                                              (+ (- char ?A) ?a)
+                                            char)))
+                        filename nil)))
        ;; Use expand-file-name to canonicalize directory separators, except
        ;; with bare drive letters (which would have the cwd appended).
        ;; Avoid expanding names that could trigger ange-ftp to prompt
        ;; for passwords, though.
-       (if (or (string-match-p "^.:$" name)
+       (if (or (string-match-p "^.:\\'" name)
                (string-match-p "^/[^/:]+:" name))
            name
          (expand-file-name name)))
     filename))
 
-(defun untranslated-file-p (filename)
+(defun w32-untranslated-file-p (filename)
   "Return t if FILENAME is on a filesystem that does not require
 CR/LF translation, and nil otherwise."
-  (let ((fs (untranslated-canonical-name filename))
-       (ufs-list untranslated-filesystem-list)
+  (let ((fs (w32-untranslated-canonical-name filename))
+       (ufs-list w32-untranslated-filesystem-list)
        (found nil))
     (while (and (not found) ufs-list)
       (if (string-match-p (concat "^" (car ufs-list)) fs)
@@ -221,7 +222,9 @@ CR/LF translation, and nil otherwise."
        (setq ufs-list (cdr ufs-list))))
     found))
 
-(defun add-untranslated-filesystem (filesystem)
+(define-obsolete-function-alias 'add-untranslated-filesystem
+  'w32-add-untranslated-filesystem "24.4")
+(defun w32-add-untranslated-filesystem (filesystem)
   "Add FILESYSTEM to the list of filesystems that do not require
 CR/LF translation.  FILESYSTEM is a string containing the directory
 prefix corresponding to the filesystem.  For example, for a Unix
@@ -230,25 +233,29 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
   ;; with a directory, but RET returns the current buffer's file, not
   ;; its directory.
   (interactive "DUntranslated file system: ")
-  (let ((fs (untranslated-canonical-name filesystem)))
-    (if (member fs untranslated-filesystem-list)
-       untranslated-filesystem-list
-      (setq untranslated-filesystem-list
-           (cons fs untranslated-filesystem-list)))))
+  (let ((fs (w32-untranslated-canonical-name filesystem)))
+    (if (member fs w32-untranslated-filesystem-list)
+       w32-untranslated-filesystem-list
+      (push fs w32-untranslated-filesystem-list))))
+
 
-(defun remove-untranslated-filesystem (filesystem)
+(define-obsolete-function-alias 'remove-untranslated-filesystem
+  'w32-remove-untranslated-filesystem "24.4")
+(defun w32-remove-untranslated-filesystem (filesystem)
   "Remove FILESYSTEM from the list of filesystems that do not require
 CR/LF translation.  FILESYSTEM is a string containing the directory
 prefix corresponding to the filesystem.  For example, for a Unix
 filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
   (interactive "fUntranslated file system: ")
-  (setq untranslated-filesystem-list
-       (delete (untranslated-canonical-name filesystem)
-               untranslated-filesystem-list)))
+  (setq w32-untranslated-filesystem-list
+       (delete (w32-untranslated-canonical-name filesystem)
+               w32-untranslated-filesystem-list)))
 
 ;;; Support for printing under DOS/Windows, see lpr.el and ps-print.el.
 
-(defcustom direct-print-region-use-command-dot-com t
+(define-obsolete-variable-alias 'direct-print-region-use-command-dot-com
+  'w32-direct-print-region-use-command-dot-com "24.4")
+(defcustom w32-direct-print-region-use-command-dot-com t
   "If non-nil, use command.com to print on Windows 9x."
   :type 'boolean
   :group 'dos-fns
@@ -256,7 +263,7 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
 
 ;; Function to actually send data to the printer port.
 ;; Supports writing directly, and using various programs.
-(defun direct-print-region-helper (printer
+(defun w32-direct-print-region-helper (printer
                                    start end
                                    lpr-prog
                                    _delete-text _buf _display
@@ -332,7 +339,7 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
         ((and (eq system-type 'windows-nt)
               (getenv "winbootdir")
               ;; Allow cop-out so command.com isn't invoked
-              direct-print-region-use-command-dot-com
+              w32-direct-print-region-use-command-dot-com
               ;; file-attributes fails on LPT ports on Windows 9x but
               ;; not on NT, so handle both cases for safety.
               (eq (or (nth 7 (file-attributes printer)) 0) 0))
@@ -351,10 +358,12 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
 
 (declare-function default-printer-name "w32fns.c")
 
-(defun direct-print-region-function (start end
-                                     &optional lpr-prog
-                                     delete-text buf display
-                                     &rest rest)
+(define-obsolete-function-alias 'direct-print-region-function
+  'w32-direct-print-region-function "24.4")
+(defun w32-direct-print-region-function (start end
+                                               &optional lpr-prog
+                                               delete-text buf display
+                                               &rest rest)
   "DOS/Windows-specific function to print the region on a printer.
 Writes the region to the device or file which is a value of
 `printer-name' (which see), unless the value of `lpr-command'
@@ -382,8 +391,8 @@ indicates a specific program should be invoked."
     (or (eq coding-system-for-write 'no-conversion)
        (setq coding-system-for-write
              (aref eol-type 1)))       ; force conversion to DOS EOLs
-    (direct-print-region-helper printer start end lpr-prog
-                               delete-text buf display rest)))
+    (w32-direct-print-region-helper printer start end lpr-prog
+                                    delete-text buf display rest)))
 
 (defvar lpr-headers-switches)
 
@@ -395,14 +404,17 @@ indicates a specific program should be invoked."
 ;; then requests to print page headers will be silently
 ;; ignored, and `print-buffer' and `print-region' produce
 ;; the same output as `lpr-buffer' and `lpr-region', accordingly.
-(setq lpr-headers-switches "(page headers are not supported)")
+(when (memq system-type '(ms-dos windows-nt))
+  (setq lpr-headers-switches "(page headers are not supported)"))
 
 (defvar ps-printer-name)
 
-(defun direct-ps-print-region-function (start end
-                                             &optional lpr-prog
-                                             delete-text buf display
-                                             &rest rest)
+(define-obsolete-function-alias 'direct-ps-print-region-function
+  'w32-direct-ps-print-region-function "24.4")
+(defun w32-direct-ps-print-region-function (start end
+                                                  &optional lpr-prog
+                                                  delete-text buf display
+                                                  &rest rest)
   "DOS/Windows-specific function to print the region on a PostScript printer.
 Writes the region to the device or file which is a value of
 `ps-printer-name' (which see), unless the value of `ps-lpr-command'
@@ -413,8 +425,8 @@ indicates a specific program should be invoked."
                          (symbol-value 'dos-ps-printer))
                     ps-printer-name
                     (default-printer-name))))
-    (direct-print-region-helper printer start end lpr-prog
-                               delete-text buf display rest)))
+    (w32-direct-print-region-helper printer start end lpr-prog
+                                    delete-text buf display rest)))
 
 ;(setq ps-lpr-command "gs")
 
index b62de874b9383750c2f7c9ca6460267af8a3835b..04d0bd3e935c3bc5cb244e964d646e2f82a6dc8e 100644 (file)
@@ -207,6 +207,15 @@ point right after that char, and it should return t to cause indentation,
 This should be set by major modes such as `python-mode' since
 Python does not lend itself to fully automatic indentation.")
 
+(defvar electric-indent-functions-without-reindent
+  '(indent-relative indent-to-left-margin indent-relative-maybe
+    py-indent-line coffee-indent-line org-indent-line
+    haskell-indentation-indent-line haskell-indent-cycle haskell-simple-indent)
+  "List of indent functions that can't reindent.
+If `line-indent-function' is one of those, then `electric-indent-mode' will
+not try to reindent lines.  It is normally better to make the major
+mode set `electric-indent-inhibit', but this can be used as a workaround.")
+
 (defun electric-indent-post-self-insert-function ()
   ;; FIXME: This reindents the current line, but what we really want instead is
   ;; to reindent the whole affected text.  That's the current line for simple
@@ -238,8 +247,7 @@ Python does not lend itself to fully automatic indentation.")
         (let ((before (copy-marker (1- pos) t)))
           (save-excursion
             (unless (or (memq indent-line-function
-                              '(indent-relative indent-to-left-margin
-                                                indent-relative-maybe))
+                              electric-indent-functions-without-reindent)
                         electric-indent-inhibit)
               ;; Don't reindent the previous line if the indentation function
               ;; is not a real one.
@@ -251,14 +259,20 @@ Python does not lend itself to fully automatic indentation.")
             ;; whereas we need `move after insertion', so we do the
             ;; save/restore by hand.
             (goto-char before)
-            ;; Remove the trailing whitespace after indentation because
-            ;; indentation may (re)introduce the whitespace.
-            (delete-horizontal-space t))))
-      (unless (or (memq indent-line-function '(indent-to-left-margin))
-                  (and electric-indent-inhibit
-                       (> pos (line-beginning-position))))
+           (when (eolp)
+             ;; Remove the trailing whitespace after indentation because
+             ;; indentation may (re)introduce the whitespace.
+             (delete-horizontal-space t)))))
+      (unless (and electric-indent-inhibit
+                   (> pos (line-beginning-position)))
         (indent-according-to-mode)))))
 
+(defun electric-indent-just-newline (arg)
+  "Insert just a newline, without any auto-indentation."
+  (interactive "*P")
+  (let ((electric-indent-mode nil))
+    (newline arg 'interactive)))
+
 ;;;###autoload
 (define-minor-mode electric-indent-mode
   "Toggle on-the-fly reindentation (Electric Indent mode).
@@ -269,11 +283,16 @@ the mode if ARG is omitted or nil.
 This is a global minor mode.  When enabled, it reindents whenever
 the hook `electric-indent-functions' returns non-nil, or you
 insert a character from `electric-indent-chars'."
-  :global t
-  :group 'electricity
+  :global t :group 'electricity
   (if (not electric-indent-mode)
-      (remove-hook 'post-self-insert-hook
-                   #'electric-indent-post-self-insert-function)
+      (progn
+        (when (eq (lookup-key global-map [?\C-j])
+                  'electric-indent-just-newline)
+          (define-key global-map [?\C-j] 'newline-and-indent))
+        (remove-hook 'post-self-insert-hook
+                     #'electric-indent-post-self-insert-function))
+    (when (eq (lookup-key global-map [?\C-j]) 'newline-and-indent)
+      (define-key global-map [?\C-j] 'electric-indent-just-newline))
     ;; post-self-insert-hooks interact in non-trivial ways.
     ;; It turns out that electric-indent-mode generally works better if run
     ;; late, but still before blink-paren.
@@ -289,12 +308,24 @@ insert a character from `electric-indent-chars'."
                          (delq #'electric-indent-post-self-insert-function
                                (cdr bp))))))))
 
+;;;###autoload
+(define-minor-mode electric-indent-local-mode
+  "Toggle `electric-indent-mode' only in this buffer."
+  :variable (buffer-local-value 'electric-indent-mode (current-buffer))
+  (cond
+   ((eq electric-indent-mode (default-value 'electric-indent-mode))
+    (kill-local-variable 'electric-indent-mode))
+   ((not (default-value 'electric-indent-mode))
+    ;; Locally enabled, but globally disabled.
+    (electric-indent-mode 1)                ; Setup the hooks.
+    (setq-default electric-indent-mode nil) ; But keep it globally disabled.
+    )))
+
 ;;; Electric pairing.
 
 (defcustom electric-pair-pairs
   '((?\" . ?\"))
   "Alist of pairs that should be used regardless of major mode."
-  :group 'electricity
   :version "24.1"
   :type '(repeat (cons character character)))
 
@@ -304,7 +335,6 @@ When inserting a closing paren character right before the same character,
 just skip that character instead, so that hitting ( followed by ) results
 in \"()\" rather than \"())\".
 This can be convenient for people who find it easier to hit ) than C-f."
-  :group 'electricity
   :version "24.1"
   :type 'boolean)
 
@@ -409,8 +439,7 @@ an open parenthesis automatically inserts the corresponding
 closing parenthesis.  \(Likewise for brackets, etc.)
 
 See options `electric-pair-pairs' and `electric-pair-skip-self'."
-  :global t
-  :group 'electricity
+  :global t :group 'electricity
   (if electric-pair-mode
       (progn
        (add-hook 'post-self-insert-hook
@@ -462,8 +491,7 @@ With a prefix argument ARG, enable Electric Layout mode if ARG is
 positive, and disable it otherwise.  If called from Lisp, enable
 the mode if ARG is omitted or nil.
 The variable `electric-layout-rules' says when and how to insert newlines."
-  :global t
-  :group 'electricity
+  :global t :group 'electricity
   (if electric-layout-mode
       (add-hook 'post-self-insert-hook
                 #'electric-layout-post-self-insert-function)
index e531bc0bdae5ec943f6a54063f7cbb8b91ce8b5d..f94f74a565221a6db7c5f0523a4759a46bf5fbe3 100644 (file)
@@ -528,6 +528,9 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
                (if (stringp generated-autoload-load-name)
                    generated-autoload-load-name
                  (autoload-file-load-name absfile)))
+          ;; FIXME? Comparing file-names for equality with just equal
+          ;; is fragile, eg if one has an automounter prefix and one
+          ;; does not, but both refer to the same physical file.
           (when (and outfile
                      (not
                      (if (memq system-type '(ms-dos windows-nt))
@@ -553,7 +556,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
                           (princ `(push (purecopy
                                              ',(cons (intern package) version))
                                         package--builtin-versions))
-                         (newline)))))
+                         (princ "\n")))))
 
               (goto-char (point-min))
               (while (not (eobp))
index 0bb04950dfdeb76b7f223e57a31dedc37aff75f8..7ec24cc2aadd4793bafcb33dfc490c989e224a90 100644 (file)
@@ -118,6 +118,7 @@ the FUN corresponding to PROP is called with the function name
 and the VALUES and should return the code to use to set this property.")
 
 (put 'defmacro 'doc-string-elt 3)
+(put 'defmacro 'lisp-indent-function 2)
 (defalias 'defmacro
   (cons
    'macro
@@ -179,7 +180,7 @@ The return value is undefined.
   ;;    (defun foo (arg) (toto) nil)
   ;; from
   ;;    (defun foo (arg) (toto)).
-  (declare (doc-string 3))
+  (declare (doc-string 3) (indent 2))
   (let ((decls (cond
                 ((eq (car-safe docstring) 'declare)
                  (prog1 (cdr docstring) (setq docstring nil)))
index 35c7c39187055d390067319d94a7f7f28f83952e..e0d474bbb9f2f639737bc7b6df16bf05cf271cd7 100644 (file)
@@ -3175,6 +3175,7 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
                                      '((0 . byte-compile-no-args)
                                        (1 . byte-compile-one-arg)
                                        (2 . byte-compile-two-args)
+                                       (2-and . byte-compile-and-folded)
                                        (3 . byte-compile-three-args)
                                        (0-1 . byte-compile-zero-or-one-arg)
                                        (1-2 . byte-compile-one-or-two-args)
@@ -3256,11 +3257,11 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
 (byte-defop-compiler cons              2)
 (byte-defop-compiler aref              2)
 (byte-defop-compiler set               2)
-(byte-defop-compiler (= byte-eqlsign)  2)
-(byte-defop-compiler (< byte-lss)      2)
-(byte-defop-compiler (> byte-gtr)      2)
-(byte-defop-compiler (<= byte-leq)     2)
-(byte-defop-compiler (>= byte-geq)     2)
+(byte-defop-compiler (= byte-eqlsign)  2-and)
+(byte-defop-compiler (< byte-lss)      2-and)
+(byte-defop-compiler (> byte-gtr)      2-and)
+(byte-defop-compiler (<= byte-leq)     2-and)
+(byte-defop-compiler (>= byte-geq)     2-and)
 (byte-defop-compiler get               2)
 (byte-defop-compiler nth               2)
 (byte-defop-compiler substring         2-3)
@@ -3324,6 +3325,16 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\""
     (byte-compile-form (nth 2 form))
     (byte-compile-out (get (car form) 'byte-opcode) 0)))
 
+(defun byte-compile-and-folded (form)
+  "Compile calls to functions like `<='.
+These implicitly `and' together a bunch of two-arg bytecodes."
+  (let ((l (length form)))
+    (cond
+     ((< l 3) (byte-compile-form `(progn ,(nth 1 form) t)))
+     ((= l 3) (byte-compile-two-args form))
+     (t (byte-compile-form `(and (,(car form) ,(nth 1 form) ,(nth 2 form))
+                                (,(car form) ,@(nthcdr 2 form))))))))
+
 (defun byte-compile-three-args (form)
   (if (not (= (length form) 4))
       (byte-compile-subr-wrong-args form 3)
index f24e503fd6d80b5a1da370ed6aaa279b2ff140d9..f4f55667729e7a5a5eb8f0dc128d78f380e6f672 100644 (file)
@@ -289,12 +289,15 @@ places where they originally did not directly appear."
 
        (dolist (binder binders)
          (let* ((value nil)
-                (var (if (not (consp binder))
-                         (prog1 binder (setq binder (list binder)))
-                       (setq value (cadr binder))
-                       (car binder)))
-                (new-val
-                 (cond
+               (var (if (not (consp binder))
+                        (prog1 binder (setq binder (list binder)))
+                       (when (cddr binder)
+                         (byte-compile-log-warning
+                          (format "Malformed `%S' binding: %S" letsym binder)))
+                      (setq value (cadr binder))
+                      (car binder)))
+               (new-val
+                (cond
                   ;; Check if var is a candidate for lambda lifting.
                   ((and (member (cons binder form) cconv-lambda-candidates)
                         (progn
index bbfe9ec642416b8fb46e434401648e53aeb77151..cc7d2a88e6156c507336a57d0bcfa6521067a9d7 100644 (file)
@@ -756,6 +756,7 @@ optional\\|rest\\|key\\|allow-other-keys\\|aux\\|whole\\|body\\|environment\
            (when 1)
            (with-accessors . multiple-value-bind)
            (with-condition-restarts . multiple-value-bind)
+          (with-compilation-unit (&lambda &body))
            (with-output-to-string (4 2))
            (with-slots . multiple-value-bind)
            (with-standard-io-syntax (2)))))
index 60fdc09c053191527304a086779ec7bfec6d1acc..2209297d553c6663f3eae6d67ed1687d6b2476c6 100644 (file)
@@ -1992,11 +1992,18 @@ by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...).
       (unwind-protect
           (progn
             (fset 'macroexpand #'cl--sm-macroexpand)
-            ;; FIXME: For N bindings, this will traverse `body' N times!
-            (macroexpand-all (cons 'progn body)
-                             (cons (list (symbol-name (caar bindings))
-                                         (cl-cadar bindings))
-                                   macroexpand-all-environment)))
+            (let ((expansion
+                   ;; FIXME: For N bindings, this will traverse `body' N times!
+                   (macroexpand-all (macroexp-progn body)
+                                    (cons (list (symbol-name (caar bindings))
+                                                (cl-cadar bindings))
+                                          macroexpand-all-environment))))
+              (if (or (null (cdar bindings)) (cl-cddar bindings))
+                  (macroexp--warn-and-return
+                   (format "Malformed `cl-symbol-macrolet' binding: %S"
+                           (car bindings))
+                   expansion)
+                expansion)))
         (fset 'macroexpand previous-macroexpand))))))
 
 ;;; Multiple values.
@@ -2726,12 +2733,12 @@ macro that returns its `&whole' argument."
   (let* ((cl-entry (cons (nth 1 (nth 1 cl-form)) nil))
          (cl--active-block-names (cons cl-entry cl--active-block-names))
          (cl-body (macroexpand-all      ;Performs compiler-macro expansions.
-                   (cons 'progn (cddr cl-form))
+                   (macroexp-progn (cddr cl-form))
                    macroexpand-all-environment)))
     ;; FIXME: To avoid re-applying macroexpand-all, we'd like to be able
     ;; to indicate that this return value is already fully expanded.
     (if (cdr cl-entry)
-        `(catch ,(nth 1 cl-form) ,@(cdr cl-body))
+        `(catch ,(nth 1 cl-form) ,@(macroexp-unprogn cl-body))
       cl-body)))
 
 (cl-define-compiler-macro cl--block-throw (cl-tag cl-value)
index 409e4faf4d5e67717d8b4a0ae2407c030380217c..a131f48c488f8d578c2d7435598fcb8a15eb5407 100644 (file)
 ;; `ert-run-tests-batch-and-exit' for non-interactive use.
 ;;
 ;; The body of `ert-deftest' forms resembles a function body, but the
-;; additional operators `should', `should-not' and `should-error' are
-;; available.  `should' is similar to cl's `assert', but signals a
-;; different error when its condition is violated that is caught and
-;; processed by ERT.  In addition, it analyzes its argument form and
-;; records information that helps debugging (`assert' tries to do
-;; something similar when its second argument SHOW-ARGS is true, but
-;; `should' is more sophisticated).  For information on `should-not'
-;; and `should-error', see their docstrings.
+;; additional operators `should', `should-not', `should-error' and
+;; `skip-unless' are available.  `should' is similar to cl's `assert',
+;; but signals a different error when its condition is violated that
+;; is caught and processed by ERT.  In addition, it analyzes its
+;; argument form and records information that helps debugging
+;; (`assert' tries to do something similar when its second argument
+;; SHOW-ARGS is true, but `should' is more sophisticated).  For
+;; information on `should-not' and `should-error', see their
+;; docstrings.  `skip-unless' skips the test immediately without
+;; processing further, this is useful for checking the test
+;; environment (like availability of features, external binaries, etc).
 ;;
 ;; See ERT's info manual as well as the docstrings for more details.
 ;; To compile the manual, run `makeinfo ert.texinfo' in the ERT
@@ -174,8 +177,8 @@ and the body."
 BODY is evaluated as a `progn' when the test is run.  It should
 signal a condition on failure or just return if the test passes.
 
-`should', `should-not' and `should-error' are useful for
-assertions in BODY.
+`should', `should-not', `should-error' and `skip-unless' are
+useful for assertions in BODY.
 
 Use `ert' to run tests interactively.
 
@@ -200,7 +203,7 @@ description of valid values for RESULT-TYPE.
                (tags nil tags-supplied-p))
          body)
         (ert--parse-keys-and-body docstring-keys-and-body)
-      `(progn
+      `(cl-macrolet ((skip-unless (form) `(ert--skip-unless ,form)))
          (ert-set-test ',name
                        (make-ert-test
                         :name ',name
@@ -237,6 +240,7 @@ description of valid values for RESULT-TYPE.
 
 
 (define-error 'ert-test-failed "Test failed")
+(define-error 'ert-test-skipped "Test skipped")
 
 (defun ert-pass ()
   "Terminate the current test and mark it passed.  Does not return."
@@ -247,6 +251,11 @@ description of valid values for RESULT-TYPE.
 DATA is displayed to the user and should state the reason of the failure."
   (signal 'ert-test-failed (list data)))
 
+(defun ert-skip (data)
+  "Terminate the current test and mark it skipped.  Does not return.
+DATA is displayed to the user and should state the reason for skipping."
+  (signal 'ert-test-skipped (list data)))
+
 
 ;;; The `should' macros.
 
@@ -425,6 +434,15 @@ failed."
                        (list
                         :fail-reason "did not signal an error")))))))))
 
+(cl-defmacro ert--skip-unless (form)
+  "Evaluate FORM.  If it returns nil, skip the current test.
+Errors during evaluation are caught and handled like nil."
+  (declare (debug t))
+  (ert--expand-should `(skip-unless ,form) form
+                      (lambda (inner-form form-description-form _value-var)
+                        `(unless (ignore-errors ,inner-form)
+                           (ert-skip ,form-description-form)))))
+
 
 ;;; Explanation of `should' failures.
 
@@ -644,6 +662,7 @@ and is displayed in front of the value of MESSAGE-FORM."
   (infos (cl-assert nil)))
 (cl-defstruct (ert-test-quit (:include ert-test-result-with-condition)))
 (cl-defstruct (ert-test-failed (:include ert-test-result-with-condition)))
+(cl-defstruct (ert-test-skipped (:include ert-test-result-with-condition)))
 (cl-defstruct (ert-test-aborted-with-non-local-exit
                (:include ert-test-result)))
 
@@ -728,6 +747,7 @@ run.  ARGS are the arguments to `debugger'."
        (let* ((condition (car more-debugger-args))
               (type (cl-case (car condition)
                       ((quit) 'quit)
+                     ((ert-test-skipped) 'skipped)
                       (otherwise 'failed)))
               (backtrace (ert--record-backtrace))
               (infos (reverse ert--infos)))
@@ -737,6 +757,10 @@ run.  ARGS are the arguments to `debugger'."
                   (make-ert-test-quit :condition condition
                                       :backtrace backtrace
                                       :infos infos))
+                 (skipped
+                  (make-ert-test-skipped :condition condition
+                                        :backtrace backtrace
+                                        :infos infos))
                  (failed
                   (make-ert-test-failed :condition condition
                                         :backtrace backtrace
@@ -862,7 +886,7 @@ Valid result types:
 
 nil -- Never matches.
 t -- Always matches.
-:failed, :passed -- Matches corresponding results.
+:failed, :passed, :skipped -- Matches corresponding results.
 \(and TYPES...\) -- Matches if all TYPES match.
 \(or TYPES...\) -- Matches if some TYPES match.
 \(not TYPE\) -- Matches if TYPE does not match.
@@ -875,6 +899,7 @@ t -- Always matches.
     ((member t) t)
     ((member :failed) (ert-test-failed-p result))
     ((member :passed) (ert-test-passed-p result))
+    ((member :skipped) (ert-test-skipped-p result))
     (cons
      (cl-destructuring-bind (operator &rest operands) result-type
        (cl-ecase operator
@@ -899,7 +924,9 @@ t -- Always matches.
 
 (defun ert-test-result-expected-p (test result)
   "Return non-nil if TEST's expected result type matches RESULT."
-  (ert-test-result-type-p result (ert-test-expected-result-type test)))
+  (or
+   (ert-test-result-type-p result :skipped)
+   (ert-test-result-type-p result (ert-test-expected-result-type test))))
 
 (defun ert-select-tests (selector universe)
   "Return a list of tests that match SELECTOR.
@@ -1085,6 +1112,7 @@ contained in UNIVERSE."
   (passed-unexpected 0)
   (failed-expected 0)
   (failed-unexpected 0)
+  (skipped 0)
   (start-time nil)
   (end-time nil)
   (aborted-p nil)
@@ -1103,10 +1131,15 @@ contained in UNIVERSE."
   (+ (ert--stats-passed-unexpected stats)
      (ert--stats-failed-unexpected stats)))
 
+(defun ert-stats-skipped (stats)
+  "Number of tests in STATS that have skipped."
+  (ert--stats-skipped stats))
+
 (defun ert-stats-completed (stats)
   "Number of tests in STATS that have run so far."
   (+ (ert-stats-completed-expected stats)
-     (ert-stats-completed-unexpected stats)))
+     (ert-stats-completed-unexpected stats)
+     (ert-stats-skipped stats)))
 
 (defun ert-stats-total (stats)
   "Number of tests in STATS, regardless of whether they have run yet."
@@ -1138,6 +1171,8 @@ Also changes the counters in STATS to match."
                        (cl-incf (ert--stats-passed-expected stats) d))
                       (ert-test-failed
                        (cl-incf (ert--stats-failed-expected stats) d))
+                     (ert-test-skipped
+                       (cl-incf (ert--stats-skipped stats) d))
                       (null)
                       (ert-test-aborted-with-non-local-exit)
                       (ert-test-quit))
@@ -1146,6 +1181,8 @@ Also changes the counters in STATS to match."
                      (cl-incf (ert--stats-passed-unexpected stats) d))
                     (ert-test-failed
                      (cl-incf (ert--stats-failed-unexpected stats) d))
+                    (ert-test-skipped
+                     (cl-incf (ert--stats-skipped stats) d))
                     (null)
                     (ert-test-aborted-with-non-local-exit)
                     (ert-test-quit)))))
@@ -1240,6 +1277,7 @@ EXPECTEDP specifies whether the result was expected."
   (let ((s (cl-etypecase result
              (ert-test-passed ".P")
              (ert-test-failed "fF")
+             (ert-test-skipped "sS")
              (null "--")
              (ert-test-aborted-with-non-local-exit "aA")
              (ert-test-quit "qQ"))))
@@ -1252,6 +1290,7 @@ EXPECTEDP specifies whether the result was expected."
   (let ((s (cl-etypecase result
              (ert-test-passed '("passed" "PASSED"))
              (ert-test-failed '("failed" "FAILED"))
+             (ert-test-skipped '("skipped" "SKIPPED"))
              (null '("unknown" "UNKNOWN"))
              (ert-test-aborted-with-non-local-exit '("aborted" "ABORTED"))
              (ert-test-quit '("quit" "QUIT")))))
@@ -1318,8 +1357,9 @@ Returns the stats object."
        (run-ended
         (cl-destructuring-bind (stats abortedp) event-args
           (let ((unexpected (ert-stats-completed-unexpected stats))
-                (expected-failures (ert--stats-failed-expected stats)))
-            (message "\n%sRan %s tests, %s results as expected%s (%s)%s\n"
+                (skipped (ert-stats-skipped stats))
+               (expected-failures (ert--stats-failed-expected stats)))
+            (message "\n%sRan %s tests, %s results as expected%s%s (%s)%s\n"
                      (if (not abortedp)
                          ""
                        "Aborted: ")
@@ -1328,6 +1368,9 @@ Returns the stats object."
                      (if (zerop unexpected)
                          ""
                        (format ", %s unexpected" unexpected))
+                     (if (zerop skipped)
+                         ""
+                       (format ", %s skipped" skipped))
                      (ert--format-time-iso8601 (ert--stats-end-time stats))
                      (if (zerop expected-failures)
                          ""
@@ -1340,6 +1383,15 @@ Returns the stats object."
                          (message "%9s  %S"
                                   (ert-string-for-test-result result nil)
                                   (ert-test-name test))))
+              (message "%s" ""))
+            (unless (zerop skipped)
+              (message "%s skipped results:" skipped)
+              (cl-loop for test across (ert--stats-tests stats)
+                       for result = (ert-test-most-recent-result test) do
+                       (when (ert-test-result-type-p result :skipped)
+                         (message "%9s  %S"
+                                  (ert-string-for-test-result result nil)
+                                  (ert-test-name test))))
               (message "%s" "")))))
        (test-started
         )
@@ -1562,15 +1614,17 @@ Also sets `ert--results-progress-bar-button-begin'."
        (ert--insert-human-readable-selector (ert--stats-selector stats))
        (insert "\n")
        (insert
-        (format (concat "Passed: %s\n"
-                        "Failed: %s\n"
-                        "Total:  %s/%s\n\n")
+        (format (concat "Passed:  %s\n"
+                        "Failed:  %s\n"
+                        "Skipped: %s\n"
+                        "Total:   %s/%s\n\n")
                 (ert--results-format-expected-unexpected
                  (ert--stats-passed-expected stats)
                  (ert--stats-passed-unexpected stats))
                 (ert--results-format-expected-unexpected
                  (ert--stats-failed-expected stats)
                  (ert--stats-failed-unexpected stats))
+                (ert-stats-skipped stats)
                 run-count
                 (ert-stats-total stats)))
        (insert
@@ -1827,11 +1881,11 @@ and how to display message."
                             ;; defined without cl.
                             (car ert--selector-history)
                           "t")))
-           (read-from-minibuffer (if (null default)
-                                     "Run tests: "
-                                   (format "Run tests (default %s): " default))
-                                 nil nil t 'ert--selector-history
-                                 default nil))
+           (completing-read (if (null default)
+                               "Run tests: "
+                             (format "Run tests (default %s): " default))
+                           obarray #'ert-test-boundp nil nil
+                           'ert--selector-history default nil))
          nil))
   (unless message-fn (setq message-fn 'message))
   (let ((output-buffer-name output-buffer-name)
@@ -1850,7 +1904,7 @@ and how to display message."
               (run-ended
                (cl-destructuring-bind (stats abortedp) event-args
                  (funcall message-fn
-                          "%sRan %s tests, %s results were as expected%s"
+                          "%sRan %s tests, %s results were as expected%s%s"
                           (if (not abortedp)
                               ""
                             "Aborted: ")
@@ -1860,7 +1914,12 @@ and how to display message."
                                  (ert-stats-completed-unexpected stats)))
                             (if (zerop unexpected)
                                 ""
-                              (format ", %s unexpected" unexpected))))
+                              (format ", %s unexpected" unexpected)))
+                          (let ((skipped
+                                 (ert-stats-skipped stats)))
+                            (if (zerop skipped)
+                                ""
+                              (format ", %s skipped" skipped))))
                  (ert--results-update-stats-display (with-current-buffer buffer
                                                       ert--results-ewoc)
                                                     stats)))
index 8a5841a5fadff2a23f74afbd2dd6c10ecc9aa9c9..1a3800597a67a39a2fbd8bad0cb6ed715dee83f2 100644 (file)
@@ -346,6 +346,10 @@ The return value is the last VAL in the list.
 (gv-define-simple-setter window-point set-window-point)
 (gv-define-simple-setter window-start set-window-start)
 
+(gv-define-setter buffer-local-value (val var buf)
+  (macroexp-let2 nil v val
+    `(with-current-buffer ,buf (set (make-local-variable ,var) ,v))))
+
 ;;; Some occasionally handy extensions.
 
 ;; While several of the "places" below are not terribly useful for direct use,
diff --git a/lisp/emacs-lisp/helpers.el b/lisp/emacs-lisp/helpers.el
new file mode 100644 (file)
index 0000000..73c2ff1
--- /dev/null
@@ -0,0 +1,42 @@
+;;; helpers.el --- Some non-essential library extensions  -*- lexical-binding:t -*-
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Maintainer: FSF
+;; Keywords: convenience
+;; Package: emacs
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(defsubst hash-table-keys (hash-table)
+  "Return a list of keys in HASH-TABLE."
+  (let ((keys '()))
+    (maphash (lambda (k _v) (push k keys)) hash-table)
+    keys))
+
+(defsubst hash-table-values (hash-table)
+  "Return a list of values in HASH-TABLE."
+  (let ((values '()))
+    (maphash (lambda (_k v) (push v values)) hash-table)
+    values))
+
+(provide 'helpers)
+
+;;; helpers.el ends here
index 0b82efab122d6a8de0467cd8741dcfccfff52be8..f4e9b311acce991fb18957747cbc34634a0fdcee 100644 (file)
@@ -251,9 +251,7 @@ It has `lisp-mode-abbrev-table' as its parent."
                              (cons "go" (mapcar (lambda (s) (concat "cl-" s))
                                                 (remove "go" cl-lib-kw))))
                             t)
-                (regexp-opt (append lisp-kw el-kw eieio-kw
-                                    (cons "go" (mapcar (lambda (s) (concat "cl-" s))
-                                                       (remove "go" cl-kw))))
+                (regexp-opt (append lisp-kw cl-kw eieio-kw cl-lib-kw)
                             t)
 
                 ;; Elisp and Common Lisp "errors".
@@ -360,7 +358,7 @@ It has `lisp-mode-abbrev-table' as its parent."
        ;; Control structures.  Common Lisp forms.
        (,(concat "(" cl-kws-re "\\_>") . 1)
        ;; Exit/Feature symbols as constants.
-       (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\_>"
+       (,(concat "(\\(catch\\|throw\\|provide\\|require\\)\\_>"
                  "[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?")
         (1 font-lock-keyword-face)
         (2 font-lock-constant-face nil t))
@@ -702,9 +700,7 @@ Commands:
 Delete converts tabs to spaces as it moves back.
 Blank lines separate paragraphs.  Semicolons start comments.
 
-\\{emacs-lisp-mode-map}
-Entry to this mode calls the value of `emacs-lisp-mode-hook'
-if that value is non-nil."
+\\{emacs-lisp-mode-map}"
   :group 'lisp
   (lisp-mode-variables nil nil 'elisp)
   (setq imenu-case-fold-search nil)
@@ -794,10 +790,7 @@ Blank lines separate paragraphs.  Semicolons start comments.
 
 \\{lisp-mode-map}
 Note that `run-lisp' may be used either to start an inferior Lisp job
-or to switch back to an existing one.
-
-Entry to this mode calls the value of `lisp-mode-hook'
-if that value is non-nil."
+or to switch back to an existing one."
   (lisp-mode-variables nil t)
   (setq-local find-tag-default-function 'lisp-find-tag-default)
   (setq-local comment-start-skip
@@ -862,9 +855,7 @@ Delete converts tabs to spaces as it moves back.
 Paragraphs are separated only by blank lines.
 Semicolons start comments.
 
-\\{lisp-interaction-mode-map}
-Entry to this mode calls the value of `lisp-interaction-mode-hook'
-if that value is non-nil."
+\\{lisp-interaction-mode-map}"
   :abbrev-table nil)
 
 (defun eval-print-last-sexp ()
index 576e72088e9760390bc30d043e1b48b07de82e64..0352164caf5f0706196bdac1ede81b9e585f36f5 100644 (file)
@@ -284,7 +284,7 @@ of the piece of advice."
   (cond ((eq 'local (car-safe place))
          (setq place `(advice--buffer-local ,@(cdr place))))
         ((symbolp place)
-         (error "Use (default-value '%S) or (local '%S)" place place)))
+         (setq place `(default-value ',place))))
   (gv-letplace (getter setter) place
     (macroexp-let2 nil new `(advice--remove-function ,getter ,function)
       `(unless (eq ,new ,getter) ,(funcall setter new)))))
index cdf210498cead6edaa68fcb3329a1071c5f7685d..e8768ea6ac969ea0c5c43bfaf3d84a71b16e0bbc 100644 (file)
@@ -429,7 +429,7 @@ This is, approximately, the inverse of `version-to-list'.
         ((>= num 0)
          (push (int-to-string num) str-list)
          (push "." str-list))
-        ((< num -3)
+        ((< num -4)
          (error "Invalid version list `%s'" vlist))
         (t
          ;; pre, or beta, or alpha
@@ -439,7 +439,8 @@ This is, approximately, the inverse of `version-to-list'.
                 (error "Invalid version list `%s'" vlist)))
          (push (cond ((= num -1) "pre")
                      ((= num -2) "beta")
-                     ((= num -3) "alpha"))
+                     ((= num -3) "alpha")
+                      ((= num -4) "snapshot"))
                str-list))))
       (if (equal "." (car str-list))
          (pop str-list))
@@ -1101,6 +1102,8 @@ Otherwise return nil."
            str)
       (error nil))))
 
+(declare-function lm-homepage "lisp-mnt" (&optional file))
+
 (defun package-buffer-info ()
   "Return a `package-desc' describing the package in the current buffer.
 
@@ -1238,7 +1241,8 @@ similar to an entry in `package-alist'.  Save the cached copy to
       (when (listp (read buffer))
        (make-directory dir t)
        (setq buffer-file-name (expand-file-name file dir))
-       (let ((version-control 'never))
+       (let ((version-control 'never)
+              (require-final-newline nil))
          (save-buffer))))
     (when good-signatures
       ;; Write out good signatures into archive-contents.signed file.
@@ -1472,15 +1476,17 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
        ;; For elpa packages, try downloading the commentary.  If that
        ;; fails, try an existing readme file in `package-user-dir'.
        (cond ((condition-case nil
-                  (package--with-work-buffer
-                       (package-archive-base desc)
-                       (format "%s-readme.txt" name)
-                    (setq buffer-file-name
-                          (expand-file-name readme package-user-dir))
-                    (let ((version-control 'never))
-                      (save-buffer))
-                    (setq readme-string (buffer-string))
-                    t)
+                   (save-excursion
+                     (package--with-work-buffer
+                         (package-archive-base desc)
+                         (format "%s-readme.txt" name)
+                       (setq buffer-file-name
+                             (expand-file-name readme package-user-dir))
+                       (let ((version-control 'never)
+                             (require-final-newline t))
+                         (save-buffer))
+                       (setq readme-string (buffer-string))
+                       t))
                 (error nil))
               (insert readme-string))
              ((file-readable-p readme)
@@ -1575,6 +1581,7 @@ Letters do not insert themselves; instead, they are commands.
   (setq tabulated-list-format [("Package" 18 package-menu--name-predicate)
                               ("Version" 12 nil)
                               ("Status"  10 package-menu--status-predicate)
+                              ("Archive" 10 package-menu--archive-predicate)
                               ("Description" 0 nil)])
   (setq tabulated-list-padding 2)
   (setq tabulated-list-sort-key (cons "Status" nil))
@@ -1697,6 +1704,8 @@ Return (PKG-DESC [NAME VERSION STATUS DOC])."
                                (package-desc-version pkg-desc))
                              'font-lock-face face)
                  (propertize status 'font-lock-face face)
+                 (propertize (or (package-desc-archive pkg-desc) "")
+                              'font-lock-face face)
                  (propertize (package-desc-summary pkg-desc)
                               'font-lock-face face)))))
 
@@ -1913,6 +1922,10 @@ Optional argument NOQUERY non-nil means do not ask the user to confirm."
   (string< (symbol-name (package-desc-name (car A)))
           (symbol-name (package-desc-name (car B)))))
 
+(defun package-menu--archive-predicate (A B)
+  (string< (or (package-desc-archive (car A)) "")
+          (or (package-desc-archive (car B)) "")))
+
 ;;;###autoload
 (defun list-packages (&optional no-fetch)
   "Display a list of packages.
index ebb82f4bf54a44ba7e03c0fd51db85b73aae509b..f025a8b400be25ec25362b22c4e50de8b026eca3 100644 (file)
@@ -1236,14 +1236,7 @@ Only meaningful when called from within `smie-rules-function'."
     (goto-char (cadr (smie-indent--parent)))
     (cons 'column
           (+ (or offset 0)
-             ;; Use smie-indent-virtual when indenting relative to an opener:
-             ;; this will also by default use current-column unless
-             ;; that opener is hanging, but will additionally consult
-             ;; rules-function, so it gives it a chance to tweak
-             ;; indentation (e.g. by forcing indentation relative to
-             ;; its own parent, as in fn a => fn b => fn c =>).
-             (if (or (listp (car smie--parent)) (smie-indent--hanging-p))
-                 (smie-indent-virtual) (current-column))))))
+             (smie-indent-virtual)))))
 
 (defvar smie-rule-separator-outdent 2)
 
@@ -1369,9 +1362,9 @@ BASE-POS is the position relative to which offsets should be applied."
      ((< 0 (length tok)) (assoc tok smie-grammar))
      ((looking-at "\\s(\\|\\s)\\(\\)")
       (forward-char 1)
-      (cons (buffer-substring (1- (point)) (point))
+      (cons (buffer-substring-no-properties (1- (point)) (point))
             (if (match-end 1) '(0 nil) '(nil 0))))
-     ((looking-at "\\s\"")
+     ((looking-at "\\s\"\\|\\s|")
       (forward-sexp 1)
       nil)
      ((eobp) nil)
@@ -1386,9 +1379,9 @@ BASE-POS is the position relative to which offsets should be applied."
      ;; 4 == open paren syntax, 5 == close.
      ((memq (setq class (syntax-class (syntax-after (1- (point))))) '(4 5))
       (forward-char -1)
-      (cons (buffer-substring (point) (1+ (point)))
+      (cons (buffer-substring-no-properties (point) (1+ (point)))
             (if (eq class 4) '(nil 0) '(0 nil))))
-     ((eq class 7)
+     ((memq class '(7 15))
       (backward-sexp 1)
       nil)
      ((bobp) nil)
@@ -1828,6 +1821,361 @@ KEYWORDS are additional arguments, which can use the following keywords:
                     (append smie-blink-matching-triggers
                             (delete-dups triggers)))))))
 
+(defun smie-edebug ()
+  "Instrument the `smie-rules-function' for Edebug."
+  (interactive)
+  (require 'edebug)
+  (if (symbolp smie-rules-function)
+      (edebug-instrument-function smie-rules-function)
+    (error "Sorry, don't know how to instrument a lambda expression")))
+
+(defun smie--next-indent-change ()
+  "Go to the next line that needs to be reindented (and reindent it)."
+  (interactive)
+  (while
+      (let ((tick (buffer-chars-modified-tick)))
+        (indent-according-to-mode)
+        (eq tick (buffer-chars-modified-tick)))
+    (forward-line 1)))
+
+;;; User configuration
+
+;; This is designed to be a completely independent "module", so we can play
+;; with various kinds of smie-config modules without having to change the core.
+
+;; This smie-config module is fairly primitive and suffers from serious
+;; restrictions:
+;; - You can only change a returned offset, so you can't change the offset
+;;   passed to smie-rule-parent, nor can you change the object with which
+;;   to align (in general).
+;; - The rewrite rule can only distinguish cases based on the kind+token arg
+;;   and smie-rules-function's return value, so you can't distinguish cases
+;;   where smie-rules-function returns the same value.
+;; - Since config-rules depend on the return value of smie-rules-function, any
+;;   config change that modifies this return value (e.g. changing
+;;   foo-indent-basic) ends up invalidating config-rules.
+;; This last one is a serious problem since it means that file-local
+;; config-rules will only work if the user hasn't changed foo-indent-basic.
+;; One possible way to change it is to modify smie-rules-functions so they can
+;; return special symbols like +, ++, -, etc.  Or make them use a new
+;; smie-rule-basic function which can then be used to know when a returned
+;; offset was computed based on foo-indent-basic.
+
+(defvar-local smie-config--mode-local nil
+  "Indentation config rules installed for this major mode.
+Typically manipulated from the major-mode's hook.")
+(defvar-local smie-config--buffer-local nil
+  "Indentation config rules installed for this very buffer.
+E.g. provided via a file-local call to `smie-config-local'.")
+(defvar smie-config--trace nil
+  "Variable used to trace calls to `smie-rules-function'.")
+
+(defun smie-config--advice (orig kind token)
+  (let* ((ret (funcall orig kind token))
+         (sig (list kind token ret))
+         (brule (rassoc sig smie-config--buffer-local))
+         (mrule (rassoc sig smie-config--mode-local)))
+    (when smie-config--trace
+      (setq smie-config--trace (or brule mrule)))
+    (cond
+     (brule (car brule))
+     (mrule (car mrule))
+     (t ret))))
+
+(defun smie-config--mode-hook (rules)
+  (setq smie-config--mode-local
+        (append rules smie-config--mode-local))
+  (add-function :around (local 'smie-rules-function) #'smie-config--advice))
+
+(defvar smie-config--modefuns nil)
+
+(defun smie-config--setter (var value)
+  (setq-default var value)
+  (let ((old-modefuns smie-config--modefuns))
+    (setq smie-config--modefuns nil)
+    (pcase-dolist (`(,mode . ,rules) value)
+      (let ((modefunname (intern (format "smie-config--modefun-%s" mode))))
+        (fset modefunname (lambda () (smie-config--mode-hook rules)))
+        (push modefunname smie-config--modefuns)
+        (add-hook (intern (format "%s-hook" mode)) modefunname)))
+    ;; Neuter any left-over previously installed hook.
+    (dolist (modefun old-modefuns)
+      (unless (memq modefun smie-config--modefuns)
+        (fset modefun #'ignore)))))
+
+(defcustom smie-config nil
+  ;; FIXME: there should be a file-local equivalent.
+  "User configuration of SMIE indentation.
+This is a list of elements (MODE . RULES), where RULES is a list
+of elements describing when and how to change the indentation rules.
+Each RULE element should be of the form (NEW KIND TOKEN NORMAL),
+where KIND and TOKEN are the elements passed to `smie-rules-function',
+NORMAL is the value returned by `smie-rules-function' and NEW is the
+value with which to replace it."
+  :set #'smie-config--setter)
+
+(defun smie-config-local (rules)
+  "Add RULES as local indentation rules to use in this buffer.
+These replace any previous local rules, but supplement the rules
+specified in `smie-config'."
+  (setq smie-config--buffer-local rules)
+  (add-function :around (local 'smie-rules-function) #'smie-config--advice))
+
+;; Make it so we can set those in the file-local block.
+;; FIXME: Better would be to be able to write "smie-config-local: (...)" rather
+;; than "eval: (smie-config-local '(...))".
+(put 'smie-config-local 'safe-local-eval-function t)
+
+(defun smie-config--get-trace ()
+  (save-excursion
+    (forward-line 0)
+    (skip-chars-forward " \t")
+    (let* ((trace ())
+           (srf-fun (lambda (orig kind token)
+                      (let* ((pos (point))
+                             (smie-config--trace t)
+                             (res (funcall orig kind token)))
+                        (push (if (consp smie-config--trace)
+                                  (list pos kind token res smie-config--trace)
+                                (list pos kind token res))
+                              trace)
+                        res))))
+      (unwind-protect
+          (progn
+            (add-function :around (local 'smie-rules-function) srf-fun)
+            (cons (smie-indent-calculate)
+                  trace))
+        (remove-function (local 'smie-rules-function) srf-fun)))))
+
+(defun smie-config-show-indent (&optional arg)
+  "Display the SMIE rules that are used to indent the current line.
+If prefix ARG is given, then move briefly point to the buffer
+position corresponding to each rule."
+  (interactive "P")
+  (let ((trace (cdr (smie-config--get-trace))))
+    (cond
+     ((null trace) (message "No SMIE rules involved"))
+     ((not arg)
+      (message "Rules used: %s"
+               (mapconcat (lambda (elem)
+                            (pcase-let ((`(,_pos ,kind ,token ,res ,rewrite)
+                                         elem))
+                              (format "%S %S -> %S%s" kind token res
+                                      (if (null rewrite) ""
+                                        (format "(via %S)" (nth 3 rewrite))))))
+                          trace
+                          ", ")))
+     (t
+      (save-excursion
+        (pcase-dolist (`(,pos ,kind ,token ,res ,rewrite) trace)
+          (message "%S %S -> %S%s" kind token res
+                   (if (null rewrite) ""
+                     (format "(via %S)" (nth 3 rewrite))))
+          (goto-char pos)
+          (sit-for blink-matching-delay)))))))
+
+(defun smie-config--guess-value (sig)
+  (add-function :around (local 'smie-rules-function) #'smie-config--advice)
+  (let* ((rule (cons 0 sig))
+         (smie-config--buffer-local (cons rule smie-config--buffer-local))
+         (goal (current-indentation))
+         (cur (smie-indent-calculate)))
+    (cond
+     ((and (eq goal
+               (progn (setf (car rule) (- goal cur))
+                      (smie-indent-calculate))))
+      (- goal cur)))))
+
+(defun smie-config-set-indent ()
+  "Add a rule to adjust the indentation of current line."
+  (interactive)
+  (let* ((trace (cdr (smie-config--get-trace)))
+         (_ (unless trace (error "No SMIE rules involved")))
+         (sig (if (null (cdr trace))
+                  (pcase-let* ((elem (car trace))
+                               (`(,_pos ,kind ,token ,res ,rewrite) elem))
+                    (list kind token (or (nth 3 rewrite) res)))
+                (let* ((choicestr
+                        (completing-read
+                         "Adjust rule: "
+                         (mapcar (lambda (elem)
+                                   (format "%s %S"
+                                           (substring (symbol-name (cadr elem))
+                                                      1)
+                                           (nth 2 elem)))
+                                 trace)
+                         nil t nil nil
+                         nil)) ;FIXME: Provide good default!
+                       (choicelst (car (read-from-string
+                                        (concat "(:" choicestr ")")))))
+                  (catch 'found
+                    (pcase-dolist (`(,_pos ,kind ,token ,res ,rewrite) trace)
+                      (when (and (eq kind (car choicelst))
+                                 (equal token (nth 1 choicelst)))
+                        (throw 'found (list kind token
+                                            (or (nth 3 rewrite) res)))))))))
+         (default-new (smie-config--guess-value sig))
+         (newstr (read-string (format "Adjust rule (%S %S -> %S) to%s: "
+                                      (nth 0 sig) (nth 1 sig) (nth 2 sig)
+                                      (if (not default-new) ""
+                                        (format " (default %S)" default-new)))
+                              nil nil (format "%S" default-new)))
+         (new (car (read-from-string newstr))))
+    (let ((old (rassoc sig smie-config--buffer-local)))
+      (when old
+        (setq smie-config--buffer-local
+              (remove old smie-config--buffer-local))))
+    (push (cons new sig) smie-config--buffer-local)
+    (message "Added rule %S %S -> %S (via %S)"
+             (nth 0 sig) (nth 1 sig) new (nth 2 sig))
+    (add-function :around (local 'smie-rules-function) #'smie-config--advice)))
+
+(defun smie-config--guess (beg end)
+  (let ((otraces (make-hash-table :test #'equal))
+        (smie-config--buffer-local nil)
+        (smie-config--mode-local nil)
+        (pr (make-progress-reporter "Analyzing the buffer" beg end)))
+
+    ;; First, lets get the indentation traces and offsets for the region.
+    (save-excursion
+      (goto-char beg)
+      (forward-line 0)
+      (while (< (point) end)
+        (skip-chars-forward " \t")
+        (unless (eolp)                  ;Skip empty lines.
+          (progress-reporter-update pr (point))
+          (let* ((itrace (smie-config--get-trace))
+                 (nindent (car itrace))
+                 (trace (mapcar #'cdr (cdr itrace)))
+                 (cur (current-indentation)))
+            (when (numberp nindent)     ;Skip `noindent' and friends.
+              (cl-incf (gethash (cons (- cur nindent) trace) otraces 0)))))
+        (forward-line 1)))
+    (progress-reporter-done pr)
+
+    ;; Second, compile the data.  Our algorithm only knows how to adjust rules
+    ;; where the smie-rules-function returns an integer.  We call those
+    ;; "adjustable sigs".  We build a table mapping each adjustable sig
+    ;; to its data, describing the total number of times we encountered it,
+    ;; the offsets found, and the traces in which it was found.
+    (message "Guessing...")
+    (let ((sigs (make-hash-table :test #'equal)))
+      (maphash (lambda (otrace count)
+                 (let ((offset (car otrace))
+                       (trace (cdr otrace))
+                       (double nil))
+                   (let ((sigs trace))
+                     (while sigs
+                       (let ((sig (pop sigs)))
+                         (if (and (integerp (nth 2 sig)) (member sig sigs))
+                             (setq double t)))))
+                   (if double
+                       ;; Disregard those traces where an adjustable sig
+                       ;; appears twice, because the rest of the code assumes
+                       ;; that adding a rule to add an offset N will change the
+                       ;; end result by N rather than 2*N or more.
+                       nil
+                     (dolist (sig trace)
+                       (if (not (integerp (nth 2 sig)))
+                           ;; Disregard those sigs that return nil or a column,
+                           ;; because our algorithm doesn't know how to adjust
+                           ;; them anyway.
+                           nil
+                         (let ((sig-data (or (gethash sig sigs)
+                                             (let ((data (list 0 nil nil)))
+                                               (puthash sig data sigs)
+                                               data))))
+                           (cl-incf (nth 0 sig-data) count)
+                           (push (cons count otrace) (nth 2 sig-data))
+                           (let ((sig-off-data
+                                  (or (assq offset (nth 1 sig-data))
+                                      (let ((off-data (cons offset 0)))
+                                        (push off-data (nth 1 sig-data))
+                                        off-data))))
+                             (cl-incf (cdr sig-off-data) count))))))))
+               otraces)
+
+      ;; Finally, guess the indentation rules.
+      (let ((ssigs nil)
+            (rules nil))
+        ;; Sort the sigs by frequency of occurrence.
+        (maphash (lambda (sig sig-data) (push (cons sig sig-data) ssigs)) sigs)
+        (setq ssigs (sort ssigs (lambda (sd1 sd2) (> (cadr sd1) (cadr sd2)))))
+        (while ssigs
+          (pcase-let ((`(,sig ,total ,off-alist ,cotraces) (pop ssigs)))
+            (cl-assert (= total (apply #'+ (mapcar #'cdr off-alist))))
+            (let* ((sorted-off-alist
+                    (sort off-alist (lambda (x y) (> (cdr x) (cdr y)))))
+                   (offset (caar sorted-off-alist)))
+              (if (zerop offset)
+                  ;; Nothing to do with this sig; indentation is
+                  ;; correct already.
+                  nil
+                (push (cons (+ offset (nth 2 sig)) sig) rules)
+                ;; Adjust the rest of the data.
+                (pcase-dolist ((and cotrace `(,count ,toffset ,trace))
+                               cotraces)
+                  (setf (nth 1 cotrace) (- toffset offset))
+                  (dolist (sig trace)
+                    (let ((sig-data (cdr (assq sig ssigs))))
+                      (when sig-data
+                        (let* ((ooff-data (assq toffset (nth 1 sig-data)))
+                               (noffset (- toffset offset))
+                               (noff-data
+                                (or (assq noffset (nth 1 sig-data))
+                                    (let ((off-data (cons noffset 0)))
+                                      (push off-data (nth 1 sig-data))
+                                      off-data))))
+                          (cl-assert (>= (cdr ooff-data) count))
+                          (cl-decf (cdr ooff-data) count)
+                          (cl-incf (cdr noff-data) count))))))))))
+        (message "Guessing...done")
+        rules))))
+
+(defun smie-config-guess ()
+  "Try and figure out this buffer's indentation settings."
+  (interactive)
+  (let ((config (smie-config--guess (point-min) (point-max))))
+    (cond
+     ((null config) (message "Nothing to change"))
+     ((null smie-config--buffer-local)
+      (message "Local rules set")
+      (setq smie-config--buffer-local config))
+     ((y-or-n-p "Replace existing local config? ")
+      (message "Local rules replaced")
+      (setq smie-config--buffer-local config))
+     ((y-or-n-p "Merge with existing local config? ")
+      (message "Local rules adjusted")
+      (setq smie-config--buffer-local
+            (append config smie-config--buffer-local)))
+     (t
+      (message "Rules guessed: %S" config)))))
+
+(defun smie-config-save ()
+  "Save local rules for use with this major mode."
+  (interactive)
+  (cond
+   ((null smie-config--buffer-local)
+    (message "No local rules to save"))
+   (t
+    (let* ((existing (assq major-mode smie-config))
+           (config
+            (cond ((null existing)
+                   (message "Local rules saved in `smie-config'")
+                   smie-config--buffer-local)
+                  ((y-or-n-p "Replace the existing mode's config? ")
+                   (message "Mode rules replaced in `smie-config'")
+                   smie-config--buffer-local)
+                  ((y-or-n-p "Merge with existing mode's config? ")
+                   (message "Mode rules adjusted in `smie-config'")
+                   (append smie-config--buffer-local (cdr existing)))
+                  (t (error "Abort")))))
+      (if existing
+          (setcdr existing config)
+        (push (cons major-mode config) smie-config))
+      (setq smie-config--mode-local config)
+      (kill-local-variable smie-config--buffer-local)
+      (customize-mark-as-set 'smie-config)))))
 
 (provide 'smie)
 ;;; smie.el ends here
index 5de768b426e363fffcfb305aa9ae1df71a8550ed..e3a91ac7c2511bf2e8e7503af5d4a2b1bba80e42 100644 (file)
   "If non-nil, cache passphrase for symmetric encryption.
 
 For security reasons, this option is turned off by default and
-not recommended to use.  Instead, consider using public-key
-encryption with gpg-agent which does the same job in a safer
-way."
+not recommended to use.  Instead, consider using gpg-agent which
+does the same job in a safer way.  See Info node `(epa) Caching
+Passphrases' for more information.
+
+Note that this option has no effect if you use GnuPG 2.0."
   :type 'boolean
   :group 'epa-file)
 
index ec154fb7efabe6909dc205cb784975e1a373f603..5856a592ebf2c3f19db659855c9b431bd55d77cc 100644 (file)
@@ -1,3 +1,7 @@
+2013-11-04  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * erc-pcomplete.el (erc-pcomplete): Set this-command.
+
 2013-09-21  Glenn Morris  <rgm@gnu.org>
 
        * erc.el (erc-invite-only-mode, erc-toggle-channel-mode):
index 410a3c6d04cdf12db58c4a6b29ecbab8f72bea43..67eb381e75f62630e87363285f6e62b4ed023fde 100644 (file)
@@ -82,10 +82,8 @@ for use on `completion-at-point-function'."
   "Complete the nick before point."
   (interactive)
   (when (> (point) (erc-beg-of-input-line))
-    (let ((last-command (if (eq last-command 'erc-complete-word)
-                            'pcomplete
-                          last-command)))
-      (call-interactively 'pcomplete))
+    (setq this-command 'pcomplete)
+    (call-interactively 'pcomplete)
     t))
 
 ;;; Setup function
index 16cc6a22008b75cf0f4499f801e259eb830e028b..06c519c104b1d1ec7002f0bc12f0e20e0aa95aa6 100644 (file)
@@ -100,14 +100,14 @@ faster and conserves more memory."
   '((((class color) (background light)) (:foreground "Blue" :weight bold))
     (((class color) (background dark)) (:foreground "SkyBlue" :weight bold))
     (t (:weight bold)))
-  "The face used for highlight directories.")
+  "The face used for highlighting directories.")
 (define-obsolete-face-alias 'eshell-ls-directory-face
   'eshell-ls-directory "22.1")
 
 (defface eshell-ls-symlink
   '((((class color) (background light)) (:foreground "Dark Cyan" :weight bold))
     (((class color) (background dark)) (:foreground "Cyan" :weight bold)))
-  "The face used for highlight symbolic links.")
+  "The face used for highlighting symbolic links.")
 (define-obsolete-face-alias 'eshell-ls-symlink-face 'eshell-ls-symlink "22.1")
 
 (defface eshell-ls-executable
index 9aef744b03732d9c3d00aa180b5d1beaca0335a3..0e965a89ba73fa4eb13e3e4c71658872a4768230 100644 (file)
@@ -274,6 +274,8 @@ If FRAME is omitted or nil, use the selected frame."
     (:weight (".attributeWeight" . "Face.AttributeWeight"))
     (:slant (".attributeSlant" . "Face.AttributeSlant"))
     (:foreground (".attributeForeground" . "Face.AttributeForeground"))
+    (:distant-foreground
+     (".attributeDistantForeground" . "Face.AttributeDistantForeground"))
     (:background (".attributeBackground" . "Face.AttributeBackground"))
     (:overline (".attributeOverline" . "Face.AttributeOverline"))
     (:strike-through (".attributeStrikeThrough" . "Face.AttributeStrikeThrough"))
@@ -1348,6 +1350,7 @@ If FRAME is omitted or nil, use the selected frame."
                  (:weight . "Weight")
                  (:slant . "Slant")
                  (:foreground . "Foreground")
+                 (:distant-foreground . "DistantForeground")
                  (:background . "Background")
                  (:underline . "Underline")
                  (:overline . "Overline")
@@ -2255,10 +2258,10 @@ terminal type to a different value."
   '((((class color) (min-colors 88) (background dark))
      :background "blue3")
     (((class color) (min-colors 88) (background light) (type gtk))
-     :foreground "gtk_selection_fg_color"
+     :distant-foreground "gtk_selection_fg_color"
      :background "gtk_selection_bg_color")
     (((class color) (min-colors 88) (background light) (type ns))
-     :foreground "ns_selection_fg_color"
+     :distant-foreground "ns_selection_fg_color"
      :background "ns_selection_bg_color")
     (((class color) (min-colors 88) (background light))
      :background "lightgoldenrod2")
index cf3356014a17e0f3c4cdb21fb98f325685eb70b8..d44401b4302e51ffe9100e7aac720adc220b6125 100644 (file)
@@ -916,6 +916,57 @@ which we're looking."
              (setq file nil))))
     (if root (file-name-as-directory root))))
 
+(defcustom user-emacs-directory-warning t
+  "Non-nil means warn if cannot access `user-emacs-directory'.
+Set this to nil at your own risk..."
+  :type 'boolean
+  :group 'initialization
+  :version "24.4")
+
+(defun locate-user-emacs-file (new-name &optional old-name)
+  "Return an absolute per-user Emacs-specific file name.
+If NEW-NAME exists in `user-emacs-directory', return it.
+Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
+Else return NEW-NAME in `user-emacs-directory', creating the
+directory if it does not exist."
+  (convert-standard-filename
+   (let* ((home (concat "~" (or init-file-user "")))
+         (at-home (and old-name (expand-file-name old-name home)))
+          (bestname (abbreviate-file-name
+                     (expand-file-name new-name user-emacs-directory))))
+     (if (and at-home (not (file-readable-p bestname))
+              (file-readable-p at-home))
+        at-home
+       ;; Make sure `user-emacs-directory' exists,
+       ;; unless we're in batch mode or dumping Emacs.
+       (or noninteractive
+          purify-flag
+          (let (errtype)
+            (if (file-directory-p user-emacs-directory)
+                (or (file-accessible-directory-p user-emacs-directory)
+                    (setq errtype "access"))
+              (let ((umask (default-file-modes)))
+                (unwind-protect
+                    (progn
+                      (set-default-file-modes ?\700)
+                      (condition-case nil
+                          (make-directory user-emacs-directory)
+                        (error (setq errtype "create"))))
+                  (set-default-file-modes umask))))
+            (when (and errtype
+                       user-emacs-directory-warning
+                       (not (get 'user-emacs-directory-warning 'this-session)))
+              ;; Only warn once per Emacs session.
+              (put 'user-emacs-directory-warning 'this-session t)
+              (display-warning 'initialization
+                               (format "\
+Unable to %s `user-emacs-directory' (%s).
+Any data that would normally be written there may be lost!
+If you never want to see this message again,
+customize the variable `user-emacs-directory-warning'."
+                                       errtype user-emacs-directory)))))
+       bestname))))
+
 
 (defun executable-find (command)
   "Search for COMMAND in `exec-path' and return the absolute file name.
index 70a0189effe703d7bb9c2b0cf38bbca985e3eb2e..87756f78f1ca0033aa82f94fb27f7860a6fbba59 100644 (file)
@@ -1358,7 +1358,8 @@ frame's display)."
 (declare-function x-display-screens "xfns.c" (&optional terminal))
 
 (defun display-screens (&optional display)
-  "Return the number of screens associated with DISPLAY."
+  "Return the number of screens associated with DISPLAY.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1374,7 +1375,8 @@ For character terminals, each character counts as a single pixel.
 For graphical terminals, note that on \"multi-monitor\" setups this
 refers to the pixel height for all physical monitors associated
 with DISPLAY.  To get information for each physical monitor, use
-`display-monitor-attributes-list'."
+`display-monitor-attributes-list'.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1390,7 +1392,8 @@ For character terminals, each character counts as a single pixel.
 For graphical terminals, note that on \"multi-monitor\" setups this
 refers to the pixel width for all physical monitors associated
 with DISPLAY.  To get information for each physical monitor, use
-`display-monitor-attributes-list'."
+`display-monitor-attributes-list'.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1425,7 +1428,8 @@ If the information is unavailable, value is nil.
 For graphical terminals, note that on \"multi-monitor\" setups this
 refers to the height in millimeters for all physical monitors
 associated with DISPLAY.  To get information for each physical
-monitor, use `display-monitor-attributes-list'."
+monitor, use `display-monitor-attributes-list'.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (and (memq (framep-on-display display) '(x w32 ns))
        (or (cddr (assoc (or display (frame-parameter nil 'display))
                        display-mm-dimensions-alist))
@@ -1441,7 +1445,8 @@ If the information is unavailable, value is nil.
 For graphical terminals, note that on \"multi-monitor\" setups this
 refers to the width in millimeters for all physical monitors
 associated with DISPLAY.  To get information for each physical
-monitor, use `display-monitor-attributes-list'."
+monitor, use `display-monitor-attributes-list'.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (and (memq (framep-on-display display) '(x w32 ns))
        (or (cadr (assoc (or display (frame-parameter nil 'display))
                        display-mm-dimensions-alist))
@@ -1455,7 +1460,8 @@ monitor, use `display-monitor-attributes-list'."
 (defun display-backing-store (&optional display)
   "Return the backing store capability of DISPLAY's screen.
 The value may be `always', `when-mapped', `not-useful', or nil if
-the question is inapplicable to a certain kind of display."
+the question is inapplicable to a certain kind of display.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1466,7 +1472,8 @@ the question is inapplicable to a certain kind of display."
 (declare-function x-display-save-under "xfns.c" (&optional terminal))
 
 (defun display-save-under (&optional display)
-  "Return non-nil if DISPLAY's screen supports the SaveUnder feature."
+  "Return non-nil if DISPLAY's screen supports the SaveUnder feature.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1477,7 +1484,8 @@ the question is inapplicable to a certain kind of display."
 (declare-function x-display-planes "xfns.c" (&optional terminal))
 
 (defun display-planes (&optional display)
-  "Return the number of planes supported by DISPLAY."
+  "Return the number of planes supported by DISPLAY.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1490,7 +1498,8 @@ the question is inapplicable to a certain kind of display."
 (declare-function x-display-color-cells "xfns.c" (&optional terminal))
 
 (defun display-color-cells (&optional display)
-  "Return the number of color cells supported by DISPLAY."
+  "Return the number of color cells supported by DISPLAY.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1505,7 +1514,8 @@ the question is inapplicable to a certain kind of display."
 (defun display-visual-class (&optional display)
   "Return the visual class of DISPLAY.
 The value is one of the symbols `static-gray', `gray-scale',
-`static-color', `pseudo-color', `true-color', or `direct-color'."
+`static-color', `pseudo-color', `true-color', or `direct-color'.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((memq frame-type '(x w32 ns))
@@ -1550,7 +1560,8 @@ is the closest to the frame if the frame does not intersect any
 physical monitors.  Every non-tip frame (including invisible one)
 in a graphical display is dominated by exactly one physical
 monitor at a time, though it can span multiple (or no) physical
-monitors."
+monitors.
+If DISPLAY is omitted or nil, it defaults to the selected frame's display."
   (let ((frame-type (framep-on-display display)))
     (cond
      ((eq frame-type 'x)
index 54bc1d03a00bdcd651626fff33a6d0f9ce9599d9..9a6ea14975328880f6da74ad6e3517073bedbfb9 100644 (file)
@@ -1,3 +1,61 @@
+2013-11-15  Jan Tatarik  <jan.tatarik@gmail.com>
+
+       * gnus-icalendar.el (gnus-icalendar-event->gnus-calendar)
+       (gnus-icalendar-event-from-ical)
+       (gnus-icalendar-event->org-entry)
+       (gnus-icalendar--update-org-event): Required/optional participation,
+       list of attendees synced to org.
+
+2013-11-13  Jan Tatarik  <jan.tatarik@gmail.com>
+
+       * gnus-icalendar.el (gnus-icalendar-event:sync-to-org)
+       (gnus-icalendar-event:inline-org-buttons): Allow for appointment
+       cancellations to be synced to org if the original appt has an org
+       outline.
+
+2013-11-13  Jan Tatarik  <jan.tatarik@gmail.com>
+
+       * gnus-icalendar.el (gnus-icalendar--format-summary-line)
+       (gnus-icalendar-event->org-entry)
+       (gnus-icalendar--update-org-event)
+       (gnus-icalendar-event->gnus-calendar): Fix empty location handling.
+
+2013-11-12  Jan Tatarik  <jan.tatarik@gmail.com>
+
+       * gnus-icalendar.el (gnus-icalendar-event-from-ical):
+       Fix timezone handling in gnus-icalendar export to org.
+
+2013-11-05  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * gnus-cite.el (gnus-cite-add-face): Make non-sticky overlays.
+
+2013-10-30  Glenn Morris  <rgm@gnu.org>
+
+       * gnus-group.el (gnus-group-browse-foreign-server):
+       * gnus-int.el (gnus-start-news-server):
+       Silence compiler obsolescence warning.
+
+2013-10-29  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * nnimap.el (nnimap-open-connection-1): `auth-source-search' for the
+       `nnoo-current-server' first, then for the actual `nnimap-address' to
+       allow netrc entries for the nnoo server to coexist with netrc entries
+       for the `nnimap-address'.
+
+2013-10-23  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * mm-decode.el (mm-dissect-buffer): Revert last change.
+       * nndoc.el (nndoc-dissect-mime-parts-sub): Ditto.
+       The problem that motivated those changes was attributed to a broken
+       mail sender, and has been fixed.
+
+2013-10-22  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * mm-decode.el (mm-dissect-buffer): Guess content-type if the first
+       token is missing in the Content-Type header.
+
+       * nndoc.el (nndoc-dissect-mime-parts-sub): Ditto.
+
 2013-09-18  Glenn Morris  <rgm@gnu.org>
 
        * gnus-util.el (image-size): Declare.
index 22e97cd8f4fab623ea6542ad5edac5f3fb72f5a3..0ea7e2e3f7de1dfe031d723273c72352a9a873a2 100644 (file)
@@ -1096,7 +1096,7 @@ See also the documentation for `gnus-article-highlight-citation'."
        (skip-chars-backward " \t")
        (setq to (point))
        (when (< from to)
-         (push (setq overlay (gnus-make-overlay from to))
+         (push (setq overlay (gnus-make-overlay from to nil t))
                gnus-cite-overlay-list)
          (gnus-overlay-put overlay 'evaporate t)
          (gnus-overlay-put overlay 'face face))))))
index c8945e57531bcc85f170113464811667a7032610..a1bc62fb18e3dbbdf2da533e7fe5c92594eee203 100644 (file)
@@ -4398,7 +4398,12 @@ and the second element is the address."
                     ;; Suggested by mapjph@bath.ac.uk.
                     (gnus-completing-read
                      "Address"
-                     gnus-secondary-servers))
+                     ;; FIXME? gnus-secondary-servers is obsolete,
+                     ;; and it is not obvious that there is anything
+                     ;; sensible to use instead in this particular case.
+                     (if (boundp 'gnus-secondary-servers)
+                         gnus-secondary-servers
+                       (cdr gnus-select-method))))
             ;; We got a server name.
             how))))
   (gnus-browse-foreign-server method))
index 969c868b5647158922f9873a49425678c45fd42f..a8277635f3e1571722a01cb4b0fe4452ca7d2434 100644 (file)
              :accessor gnus-icalendar-event:location
              :initform ""
              :type (or null string))
-   (start :initarg :start
-          :accessor gnus-icalendar-event:start
+   (start-time :initarg :start-time
+          :accessor gnus-icalendar-event:start-time
           :initform ""
-          :type (or null string))
-   (end :initarg :end
-        :accessor gnus-icalendar-event:end
+          :type (or null t))
+   (end-time :initarg :end-time
+        :accessor gnus-icalendar-event:end-time
         :initform ""
-        :type (or null string))
+        :type (or null t))
    (recur :initarg :recur
           :accessor gnus-icalendar-event:recur
           :initform ""
    (rsvp :initarg :rsvp
          :accessor gnus-icalendar-event:rsvp
          :initform nil
-         :type (or null boolean)))
+         :type (or null boolean))
+   (participation-required :initarg :participation-required
+         :accessor gnus-icalendar-event:participation-required
+         :initform t
+         :type (or null boolean))
+   (req-participants :initarg :req-participants
+         :accessor gnus-icalendar-event:req-participants
+         :initform nil
+         :type (or null t))
+   (opt-participants :initarg :opt-participants
+         :accessor gnus-icalendar-event:opt-participants
+         :initform nil
+         :type (or null t)))
   "generic iCalendar Event class")
 
 (defclass gnus-icalendar-event-request (gnus-icalendar-event)
     (or (match-string 1 rrule)
         default-interval)))
 
-(defmethod gnus-icalendar-event:start-time ((event gnus-icalendar-event))
-  "Return time value of the EVENT start date."
-  (date-to-time (gnus-icalendar-event:start event)))
-
-(defmethod gnus-icalendar-event:end-time ((event gnus-icalendar-event))
-  "Return time value of the EVENT end date."
-  (date-to-time (gnus-icalendar-event:end event)))
-
+(defmethod gnus-icalendar-event:start ((event gnus-icalendar-event))
+  (format-time-string "%Y-%m-%d %H:%M" (gnus-icalendar-event:start-time event)))
 
-(defun gnus-icalendar-event--decode-datefield (ical field zone-map &optional date-style)
-  (let* ((calendar-date-style (or date-style 'european))
-         (date (icalendar--get-event-property ical field))
-         (date-zone (icalendar--find-time-zone
-                     (icalendar--get-event-property-attributes
-                      ical field)
-                     zone-map))
-         (date-decoded (icalendar--decode-isodatetime date nil date-zone)))
+(defun gnus-icalendar-event--decode-datefield (ical field)
+  (let* ((date (icalendar--get-event-property ical field))
+         (date-props (icalendar--get-event-property-attributes ical field))
+         (tz (plist-get date-props 'TZID)))
 
-    (concat (icalendar--datetime-to-iso-date date-decoded "-")
-            " "
-            (icalendar--datetime-to-colontime date-decoded))))
+    (date-to-time (timezone-make-date-arpa-standard date nil tz))))
 
 (defun gnus-icalendar-event--find-attendee (ical name-or-email)
   (let* ((event (car (icalendar--all-events ical)))
 
       (gnus-icalendar-find-if #'attendee-prop-matches-p event-props))))
 
+(defun gnus-icalendar-event--get-attendee-names (ical)
+  (let* ((event (car (icalendar--all-events ical)))
+         (attendee-props (gnus-remove-if-not
+                          (lambda (p) (eq (car p) 'ATTENDEE))
+                          (caddr event))))
+
+    (gmm-labels ((attendee-role (prop) (plist-get (cadr prop) 'ROLE))
+                 (attendee-name (prop) (plist-get (cadr prop) 'CN))
+                 (attendees-by-type (type)
+                   (gnus-remove-if-not
+                    (lambda (p) (string= (attendee-role p) type))
+                    attendee-props))
+                 (attendee-names-by-type (type)
+                    (mapcar #'attendee-name (attendees-by-type type))))
+
+      (list
+       (attendee-names-by-type "REQ-PARTICIPANT")
+       (attendee-names-by-type "OPT-PARTICIPANT")))))
 
 (defun gnus-icalendar-event-from-ical (ical &optional attendee-name-or-email)
   (let* ((event (car (icalendar--all-events ical)))
-         (zone-map (icalendar--convert-all-timezones ical))
          (organizer (replace-regexp-in-string
                      "^.*MAILTO:" ""
                      (or (icalendar--get-event-property event 'ORGANIZER) "")))
          (method (caddr (assoc 'METHOD (caddr (car (nreverse ical))))))
          (attendee (when attendee-name-or-email
                      (gnus-icalendar-event--find-attendee ical attendee-name-or-email)))
+         (attendee-names (gnus-icalendar-event--get-attendee-names ical))
          (args (list :method method
                      :organizer organizer
-                     :start (gnus-icalendar-event--decode-datefield event 'DTSTART zone-map)
-                     :end (gnus-icalendar-event--decode-datefield event 'DTEND zone-map)
+                     :start-time (gnus-icalendar-event--decode-datefield event 'DTSTART)
+                     :end-time (gnus-icalendar-event--decode-datefield event 'DTEND)
                      :rsvp (string= (plist-get (cadr attendee) 'RSVP)
-                                    "TRUE")))
+                                    "TRUE")
+                     :participation-required (string= (plist-get (cadr attendee) 'ROLE)
+                                                      "REQ-PARTICIPANT")
+                     :req-participants (cdar attendee-names)
+                     :opt-participants (cadr attendee-names)))
          (event-class (cond
                        ((string= method "REQUEST") 'gnus-icalendar-event-request)
                        ((string= method "CANCEL") 'gnus-icalendar-event-cancel)
@@ -363,10 +385,10 @@ Return nil for non-recurring EVENT."
   "Build `org-mode' timestamp from EVENT start/end dates and recurrence info."
   (let* ((start (gnus-icalendar-event:start-time event))
          (end (gnus-icalendar-event:end-time event))
-         (start-date (format-time-string "%Y-%m-%d %a" start t))
-         (start-time (format-time-string "%H:%M" start t))
-         (end-date (format-time-string "%Y-%m-%d %a" end t))
-         (end-time (format-time-string "%H:%M" end t))
+         (start-date (format-time-string "%Y-%m-%d %a" start))
+         (start-time (format-time-string "%H:%M" start))
+         (end-date (format-time-string "%Y-%m-%d %a" end))
+         (end-time (format-time-string "%H:%M" end))
          (org-repeat (gnus-icalendar-event:org-repeat event))
          (repeat (if org-repeat (concat " " org-repeat) "")))
 
@@ -374,6 +396,15 @@ Return nil for non-recurring EVENT."
         (format "<%s %s-%s%s>" start-date start-time end-time repeat)
       (format "<%s %s>--<%s %s>" start-date start-time end-date end-time))))
 
+(defun gnus-icalendar--format-summary-line (summary &optional location)
+  (if location
+      (format "%s (%s)" summary location)
+    (format "%s" summary)))
+
+
+(defun gnus-icalendar--format-participant-list (participants)
+  (mapconcat #'identity participants ", "))
+
 ;; TODO: make the template customizable
 (defmethod gnus-icalendar-event->org-entry ((event gnus-icalendar-event) reply-status)
   "Return string with new `org-mode' entry describing EVENT."
@@ -388,10 +419,14 @@ Return nil for non-recurring EVENT."
                       ("DT" . ,(gnus-icalendar-event:org-timestamp event))
                       ("ORGANIZER" . ,(gnus-icalendar-event:organizer event))
                       ("LOCATION" . ,(gnus-icalendar-event:location event))
+                      ("PARTICIPATION_REQUIRED" . ,(when (gnus-icalendar-event:participation-required event) "t"))
+                      ("REQ_PARTICIPANTS" . ,(gnus-icalendar--format-participant-list (gnus-icalendar-event:req-participants event)))
+                      ("OPT_PARTICIPANTS" . ,(gnus-icalendar--format-participant-list (gnus-icalendar-event:opt-participants event)))
                       ("RRULE" . ,(gnus-icalendar-event:recur event))
                       ("REPLY" . ,reply))))
 
-        (insert (format "* %s (%s)\n\n" summary location))
+        (insert (format "* %s\n\n"
+                        (gnus-icalendar--format-summary-line summary location)))
         (mapc (lambda (prop)
                 (org-entry-put (point) (car prop) (cdr prop)))
               props))
@@ -445,7 +480,8 @@ is searched."
   (let ((file (gnus-icalendar-find-org-event-file event org-file)))
     (when file
       (with-current-buffer (find-file-noselect file)
-        (with-slots (uid summary description organizer location recur) event
+        (with-slots (uid summary description organizer location recur
+                         participation-required req-participants opt-participants) event
           (let ((event-pos (org-find-entry-with-id uid)))
             (when event-pos
               (goto-char event-pos)
@@ -456,7 +492,7 @@ is searched."
                        (headline (delq nil (list
                                             (org-entry-get (point) "TODO")
                                             (when priority (format "[#%s]" priority))
-                                            (format "%s (%s)" summary location)
+                                            (gnus-icalendar--format-summary-line summary location)
                                             (org-entry-get (point) "TAGS")))))
 
                   (re-search-forward "^\\*+ " (line-end-position))
@@ -487,6 +523,9 @@ is searched."
                 (org-entry-put event-pos "DT" (gnus-icalendar-event:org-timestamp event))
                 (org-entry-put event-pos "ORGANIZER" organizer)
                 (org-entry-put event-pos "LOCATION" location)
+                (org-entry-put event-pos "PARTICIPATION_REQUIRED" (when participation-required "t"))
+                (org-entry-put event-pos "REQ_PARTICIPANTS" (gnus-icalendar--format-participant-list req-participants))
+                (org-entry-put event-pos "OPT_PARTICIPANTS" (gnus-icalendar--format-participant-list opt-participants))
                 (org-entry-put event-pos "RRULE" recur)
                 (when reply-status (org-entry-put event-pos "REPLY"
                                                   (capitalize (symbol-name reply-status))))
@@ -553,7 +592,7 @@ is searched."
       (gnus-icalendar--update-org-event event reply-status)
     (gnus-icalendar:org-event-save event reply-status)))
 
-(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-cancel))
+(defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-cancel) reply-status)
   (when (gnus-icalendar-find-org-event-file event)
     (gnus-icalendar--cancel-org-event event)))
 
@@ -602,11 +641,13 @@ is searched."
                     (propertize (concat (car x) ":") 'face 'bold)
                     (cadr x))))
 
-    (with-slots (organizer summary description location recur uid method rsvp) event
+    (with-slots (organizer summary description location recur uid
+                           method rsvp participation-required) event
       (let ((headers `(("Summary" ,summary)
-                      ("Location" ,location)
+                      ("Location" ,(or location ""))
                       ("Time" ,(gnus-icalendar-event:org-timestamp event))
                       ("Organizer" ,organizer)
+                      ("Attendance" ,(if participation-required "Required" "Optional"))
                       ("Method" ,method))))
 
        (when (and (not (gnus-icalendar-event-reply-p event)) rsvp)
@@ -730,6 +771,18 @@ is searched."
                (when org-entry-exists-p
                  `("Show Org Entry" gnus-icalendar--show-org-event ,event))))))
 
+
+(defmethod gnus-icalendar-event:inline-org-buttons ((event gnus-icalendar-event-cancel))
+  (let ((org-entry-exists-p (gnus-icalendar-find-org-event-file event)))
+
+    (delq nil (list
+               `("Show Agenda" gnus-icalendar-show-org-agenda ,event)
+               (when org-entry-exists-p
+                 `("Update Org Entry" gnus-icalendar-sync-event-to-org ,event))
+               (when org-entry-exists-p
+                 `("Show Org Entry" gnus-icalendar--show-org-event ,event))))))
+
+
 (defun gnus-icalendar-mm-inline (handle)
   (let ((event (gnus-icalendar-event-from-handle handle gnus-icalendar-identities)))
 
index 2de6ce0fce11db5d77b7ccd326314c481af115e6..d0aca8fde36639b9db82c493ef1ccc3d553d5854 100644 (file)
@@ -113,7 +113,8 @@ If CONFIRM is non-nil, the user will be asked for an NNTP server."
        (setq gnus-nntp-server
              (gnus-completing-read "NNTP server"
                                     (cons gnus-nntp-server
-                                          gnus-secondary-servers)
+                                         (if (boundp 'gnus-secondary-servers)
+                                             gnus-secondary-servers))
                                     nil gnus-nntp-server)))
 
       (when (and gnus-nntp-server
index 941849da18347eedaa1ee7f1edb3559e1b2a6e06..26d18fc678e18bd789647c5bea9e9a445e18364c 100644 (file)
@@ -672,9 +672,9 @@ MIME-Version header before proceeding."
                                 description)))))
       (if (or (not ctl)
              (not (string-match "/" (car ctl))))
-         (mm-dissect-singlepart
+           (mm-dissect-singlepart
           (list mm-dissect-default-type)
-          (and cte (intern (downcase (mail-header-strip cte))))
+            (and cte (intern (downcase (mail-header-strip cte))))
           no-strict-mime
           (and cd (mail-header-parse-content-disposition cd))
           description)
index f8c2b24cc9f860d6608ba6573575d7c6fe790576..2220c81e7750513faaf67ab2f50197e93e21c71d 100644 (file)
@@ -456,8 +456,8 @@ textual parts.")
                                (nnimap-credentials
                                (gnus-delete-duplicates
                                 (list
-                                 nnimap-address
-                                 (nnoo-current-server 'nnimap)))
+                                  (nnoo-current-server 'nnimap)
+                                 nnimap-address))
                                 ports
                                 nnimap-user))))
                  (setq nnimap-object nil)
index bc4f89955bc226b772c0a3e329c5f0633d64f50a..fc50cf19bf10a20fe4b7ef2f428704a4998b6f74 100644 (file)
@@ -5,7 +5,6 @@
 ;; Emacs Lisp Archive Entry
 ;; Package: htmlfontify
 ;; Filename: hfy-cmap.el
-;; Version: 0.20
 ;; Keywords: colour, rgb
 ;; Author: Vivek Dasmohapatra <vivek@etla.org>
 ;; Maintainer: Vivek Dasmohapatra <vivek@etla.org>
@@ -13,7 +12,6 @@
 ;; Description: fallback code for colour name -> rgb mapping
 ;; URL: http://rtfm.etla.org/emacs/htmlfontify/
 ;; Last-Updated: Sat 2003-02-15 03:49:32 +0000
-;; Package: htmlfontify
 
 ;; This file is part of GNU Emacs.
 
index 3de2b1a65e616f0868cddfd116ab73d3abbeaeef..8629c36431c4b850861500632b2d95349765b89e 100644 (file)
@@ -15,7 +15,6 @@
 ;; Compatibility: Emacs23, Emacs22
 ;; Incompatibility: Emacs19, Emacs20, Emacs21
 ;; Last Updated: Thu 2009-11-19 01:31:21 +0000
-;; Version: 0.21
 
 ;; This file is part of GNU Emacs.
 
@@ -2411,8 +2410,7 @@ You may also want to set `hfy-page-header' and `hfy-page-footer'."
     (load file 'NOERROR nil nil) ))
 
 \f
-;;;### (autoloads (hfy-fallback-colour-values htmlfontify-load-rgb-file)
-;;;;;;  "hfy-cmap" "hfy-cmap.el" "3f97eeabe72027099da579f6ef9ae0bd")
+;;;### (autoloads nil "hfy-cmap" "hfy-cmap.el" "8a7794fa69a9dfec65d63d17db83b5b0")
 ;;; Generated autoloads from hfy-cmap.el
 
 (autoload 'htmlfontify-load-rgb-file "hfy-cmap" "\
index e7216f595eae7654db84d204b4b1176fa05c0601..42b36077bf88c66da09d467b3b0f0c9d784a10e5 100644 (file)
@@ -797,7 +797,7 @@ remaining completion.  If absent, elements 5 and 6 are used instead."
 The value can be one of the following:
 
   nil:  No virtual buffers are used.
-  auto: Use virtual bufferw when the current input matches no
+  auto: Use virtual buffers when the current input matches no
         existing buffers.
   t:    Always use virtual buffers.
 
@@ -4707,19 +4707,18 @@ Modified from `icomplete-completions'."
     (cancel-timer ido-auto-merge-timer)
     (setq ido-auto-merge-timer nil))
 
-  (if (ido-active)
-      (if (and (boundp 'ido-eoinput)
-              ido-eoinput)
-
-         (if (> ido-eoinput (point-max))
-             ;; Oops, got rug pulled out from under us - reinit:
-             (setq ido-eoinput (point-max))
-           (let ((buffer-undo-list t))
-             (delete-region ido-eoinput (point-max))))
-
-       ;; Reestablish the local variable 'cause minibuffer-setup is weird:
-       (make-local-variable 'ido-eoinput)
-       (setq ido-eoinput 1))))
+  (when (ido-active)
+    (if (bound-and-true-p ido-eoinput)
+       (if (> ido-eoinput (point-max))
+           ;; Oops, got rug pulled out from under us - reinit:
+           (setq ido-eoinput (point-max))
+         (let ((inhibit-read-only t)
+               (buffer-undo-list t))
+           (delete-region ido-eoinput (point-max))))
+
+      ;; Reestablish the local variable 'cause minibuffer-setup is weird:
+      (make-local-variable 'ido-eoinput)
+      (setq ido-eoinput 1))))
 
 (defun ido-summary-buffers-to-end ()
   ;; Move the summaries to the end of the buffer list.
index 91cc3addb067e9601b92dee29c41269c6e99ff1d..69d890719d228ad68161bf20320352d638ab604f 100644 (file)
 
 (defconst image-type-header-regexps
   `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm)
-    ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm)
+    ("\\`P[1-6]\\\(?:\
+\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[[:space:]]\\)+\
+\\(?:\\(?:#[^\r\n]*[\r\n]\\)?[0-9]\\)+\
+\\)\\{2\\}" . pbm)
     ("\\`GIF8[79]a" . gif)
     ("\\`\x89PNG\r\n\x1a\n" . png)
     ("\\`[\t\n\r ]*#define \\([a-z0-9_]+\\)_width [0-9]+\n\
@@ -115,7 +118,9 @@ If an element is a string, it defines a directory to search.
 If an element is a variable symbol whose value is a string, that
 value defines a directory to search.
 If an element is a variable symbol whose value is a list, the
-value is used as a list of directories to search."
+value is used as a list of directories to search.
+
+Subdirectories are not automatically included in the search."
   :type '(repeat (choice directory variable))
   :initialize 'custom-initialize-delay)
 
@@ -591,7 +596,7 @@ Image files should not be larger than specified by `max-image-size'."
 
 ;;;###autoload
 (defmacro defimage (symbol specs &optional doc)
-  "Define SYMBOL as an image.
+  "Define SYMBOL as an image, and return SYMBOL.
 
 SPECS is a list of image specifications.  DOC is an optional
 documentation string.
index 59923b456b98a1c70f5a85af8a6634ccc40e5a75..5d08e8ac3246b89a37f410c2ff1b5506efca4cc6 100644 (file)
@@ -1,22 +1,19 @@
 The following files in this directory are derived from the Unicode
-Data File at http://www.unicode.org/Public/UNIDATA/UnicodeData.txt,
-downloaded on 2006-05-23:
+Data File at http://www.unicode.org/Public/UNIDATA/UnicodeData.txt:
 
   charprop.el uni-bidi.el uni-category.el uni-combining.el
   uni-comment.el uni-decimal.el uni-decomposition.el uni-digit.el
   uni-lowercase.el uni-mirrored.el uni-name.el uni-numeric.el
   uni-old-name.el uni-titlecase.el uni-uppercase.el
 
-These files were generated from UnicodeData.txt using unidata-gen.el,
-which is not included in the Emacs distribution; it can be found in
-the admin/unidata directory of the Emacs source repository at
-https://savannah.gnu.org/projects/emacs/
+These files were generated from the version admin/unidata/UnicodeData.txt
+in the Emacs sources, using the file unidata-gen.el in the same directory.
 
 The file UnicodeData.txt is used under the terms of the following
 Copyright and Permission Notice:
 
 
-Copyright (C) 1991-2009 Unicode, Inc. All rights reserved. Distributed
+Copyright (C) 1991-2013 Unicode, Inc. All rights reserved. Distributed
 under the Terms of Use in http://www.unicode.org/copyright.html.
 
 Permission is hereby granted, free of charge, to any person obtaining
index ab83ff0034a76abc7b017e4c0774d1078de3ca42..2195308737c88394a0c1cf859bd583944c554c18 100644 (file)
@@ -1485,7 +1485,12 @@ METHOD must be one of these symbols:
   `empty-box':  display an empty box.
   `acronym':    display an acronym of the character in a box.  The
                 acronym is taken from `char-acronym-table', which see.
-  `hex-code':   display the hexadecimal character code in a box."
+  `hex-code':   display the hexadecimal character code in a box.
+
+Do not set its value directly from Lisp; the value takes effect
+only via a custom `:set'
+function (`update-glyphless-char-display'), which updates
+`glyphless-char-display'."
   :version "24.1"
   :type '(alist :key-type (symbol :tag "Character Group")
                :value-type (symbol :tag "Display Method"))
index 50226b1b7736c634d374fd1605fcebf0fd2a93ab..514428d0dc4d155d4e62a73bc81c95a550c4ee34 100644 (file)
@@ -81,6 +81,7 @@ The value nil means that the actual property value of a character
 is the character itself.")
 ;; Local Variables:
 ;; coding: utf-8
+;; version-control: never
 ;; no-byte-compile: t
 ;; End:
 
index f2df229e349a9745b5971bf66d1f66dc5a4000c6..0598545b377e86b870991b208b0f951187415580 100644 (file)
@@ -2542,7 +2542,9 @@ Assuming that your actual keyboard has the `")
           'quail-keyboard-layout-button
           quail-keyboard-layout-type)
          (insert "' layout,
-translation results in the following \"virtual\" keyboard layout:
+translation results in the following \"virtual\" keyboard layout
+\(the labels on the keys indicate what character will be produced
+by each key, with and without holding Shift):
 ")
          (setq done-list
                (quail-insert-kbd-layout quail-keyboard-layout))
index ba1bd436b230fa6bcfa19396f5dbff754a80bdbc..2fc5d2bfc6734d4697c7340a0ba0c00411d052e4 100644 (file)
@@ -1,22 +1,25 @@
-;; Copyright (C) 1991-2009 Unicode, Inc.
+;; Copyright (C) 1991-2013 Unicode, Inc.
 ;; This file was generated from the Unicode data files at
 ;; http://www.unicode.org/Public/UNIDATA/.
 ;; See lisp/international/README for the copyright and permission notice.
-(define-char-code-property 'bidi-class #^[1 nil char-code-property-table 
+(define-char-code-property 'bidi-class
+  #^[1 nil char-code-property-table 
 #^^[3 0 5 5 5 5 5 5 5 5 5 17 6 17 18 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 17 18 19 19 14 14 14 19 19 19 19 19 13 15 13 15 15 3 3 3 3 3 3 3 3 3 3 15 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 5] #^^[1 0 #^^[2 0 
-#^^[3 0 5 5 5 5 5 5 5 5 5 17 6 17 18 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 17 18 19 19 14 14 14 19 19 19 19 19 13 15 13 15 15 3 3 3 3 3 3 3 3 3 3 15 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 5] "\ 2\ 5\85\ 6\ 5\9a\ f\13\ e\84\13\84\ 1\13\13\ 5\13\13\ e\ e\ 3\ 3\13\ 1\13\83\ 3\ 1\13\85\ 1\97\13\ 1\9f\13\ 1\88" 1 1 1 "\ 2\ 1¹\13\13\ 1\87\13\8e\ 1\ 1\13\8e\ 1\85\13\89\ 1\13\91" "\ 2\10ð\ 1\84\13\13\ 1\88\13\ 1" "\ 2\ 1\84\13\13\ 1\13\ 1î\13\ 1\89" 1 "\ 2\ 1\83\10\87\ 1ö" 1 "\ 2\ 1\8a\13\ 1\84\ e\ 2\10­\ 2\10\ 2\10\10\ 2\10\10\ 2\10\ 2¸" "\ 2\ 4\85\a\13\13\a\ e\ e\a\ f\a\13\13\10\8b\a°\10\95\ 4\8a\ e\ 4\ 4\a\83\10\a\8f" "\ 2\aÖ\10\87\ 4\13\10\86\a\a\10\10\13\10\84\a\a\ 3\8a\a\86" "\ 2\a\8e\ 1\a\a\10\a\9e\10\9b\ 1\ 1\a³" "\ 2\a¦\10\8b\a\ 1\8e\ 2«\10\89\ 2\ 2\13\84\ 2\86" "\ 2\ 2\96\10\84\ 2\10\89\ 2\10\83\ 2\10\85\ 2«\10\83\ 2¤" "\ 2\ 2 \a\ 2\a\8b\ 2·\10\9b\ 2" "\ 2\10\83\ 1·\10\ 1\10\ 1\84\10\88\ 1\84\10\ 1\83\10\87\ 1\8a\10\10\ 1\9c" "\ 2\ 1\10\ 1º\10\ 1\84\10\84\ 1\88\10\ 1\94\10\10\ 1\8e\ e\ e\ 1\87\ e\ 1\84" "\ 2\ 1\10\10\ 1¹\10\ 1\84\10\10\ 1\84\10\10\ 1\ 1\10\83\ 1\83\10\ 1\9e\10\10\ 1\83\10\ 1\8a" "\ 2\ 1\10\10\ 1¹\10\ 1\84\10\85\ 1\10\10\ 1\84\10\ 1\94\10\10\ 1\8d\ e\ 1\8e" "\ 2\ 1\10\ 1º\10\ 1\ 1\10\ 1\10\84\ 1\88\10\ 1\88\10\ 1\8b\10\10\ 1\9c" "\ 2\ 1\ 1\10\ 1½\10\ 1\8c\10\ 1¥\13\86\ e\13\ 1\85" "\ 2\ 1¾\10\83\ 1\85\10\83\ 1\10\84\ 1\87\10\10\ 1\8b\10\10\ 1\94\13\87\ 1" "\ 2\ 1¼\10\ 1\8f\10\10\ 1\94\10\10\ 1\9c" "\ 2\ 1Á\10\84\ 1\88\10\ 1\94\10\10\ 1\9c" "\ 2\ 1Ê\10\ 1\87\10\83\ 1\10\ 1©" "\ 2\ 1±\10\ 1\ 1\10\87\ 1\84\ e\ 1\87\10\88\ 1±" "\ 2\ 1±\10\ 1\ 1\10\86\ 1\10\10\ 1\8b\10\86\ 1²" "\ 2\ 1\98\10\10\ 1\9b\10\ 1\10\ 1\10\13\84\ 1³\10\8e\ 1" "\ 2\10\85\ 1\10\10\ 1\85\10\8b\ 1\10¤\ 1\89\10\ 1¹"] #^^[2 4096 "\ 2\ 1­\10\84\ 1\10\86\ 1\10\10\ 1\ 1\10\10\ 1\99\10\10\ 1\84\10\83\ 1\90\10\84\ 1\8b" "\ 2\ 1\ 1\10\ 1\ 1\10\10\ 1\86\10\ 1\8f\10\ 1â" 1 1 1 1 "\ 2\ 1Ý\10\83\ 1 " "\ 2\ 1\90\13\8a\ 1æ" "\ 2\13\ 1ÿ" 1 1 1 1 "\ 2\12\ 1\9a\13\13\ 1ã" "\ 2\ 1\92\10\83\ 1\9d\10\83\ 1\9d\10\10\ 1\9e\10\10\ 1\8c" "\ 2\ 1´\10\10\ 1\10\87\ 1\88\10\ 1\ 1\10\8b\ 1\87\ e\ 1\10\ 1\92\13\8a\ 1\86" "\ 2\13\8b\10\83\12\ 1ñ" "\ 2\ 1©\10\ 1Ö" "\ 2\ 1 \10\83\ 1\84\10\10\ 1\89\10\ 1\86\10\83\ 1\84\13\ 1\83\13\13\ 1º" "\ 2\ 1Þ\13¢" "\ 2\ 1\97\10\10\ 1½\10\ 1\10\87\ 1\10\ 1\10\ 1\ 1\10\88\ 1\86\10\8a\ 1\ 1\10" 1 "\ 2\10\84\ 1°\10\ 1\10\85\ 1\10\ 1\85\10\ 1¨\10\89\ 1\8c" "\ 2\10\10\ 1 \10\84\ 1\ 1\10\10\ 1\10\ 1º\10\ 1\10\10\ 1\83\10\ 1\10\83\ 1\8e" "\ 2\ 1¬\10\88\ 1\ 1\10\10\ 1È" "\ 2\ 1Ð\10\83\ 1\10\8d\ 1\10\87\ 1\84\10\ 1\86\10\ 1\8b" 1 "\ 2\ 1À\10§\ 1\95\10\84" 1 1 1 "\ 2\ 1½\13\ 1\13\83\ 1\8b\13\83\ 1\8d\13\83\ 1\8d\13\83\ 1\8d\13\13\ 1"] #^^[2 8192 "\ 2\12\8b\ 5\83\ 1\ 2\13\98\12\ 6\b
-\f      \v\ f\ e\85\13\8f\ f\13\9a\12\ 5\85\ 1\85\ 5\86\ 3\ 1\83\ 3\86\r\r\13\83\ 1" "\ 2\ 3\8a\r\r\13\83\ 1\91\ e\9b\ 1\95\10¡\ 1\8f" "\ 2\13\13\ 1\13\84\ 1\13\13\ 1\8a\13\ 1\13\83\ 1\85\13\86\ 1\13\ 1\13\ 1\13\ 1\84\ e\ 1\8b\13\13\ 1\84\13\85\ 1\85\13\84\ 1\ 1\13\90\ 1 " "\ 2\ 1\89\13\ 1\86\13ð" "\ 2\13\92\r\ e\13ì" 19 "\ 2\13\ 1Å\13\85" "\ 2\13\95\ 1\13Þ\ 1\8c" "\ 2\13§\ 1\99\13\8b\ 1\95\13 " "\ 2\13\88\ 3\94\ 1Î\13\96" 19 19 19 "\ 2\13¬\ 1\13Ó" "\ 2\ 1\13ÿ" 19 1 1 19 19 19 19 "\ 2\13Í\ 1\83\13\8a\ 1¦" 1 1 "\ 2\ 1å\13\86\ 1\84\10\83\ 1\87\13\87" "\ 2\ 1ÿ\10" "\ 2\ 1à\10 " "\ 2\13¼\ 1Ä" "\ 2\13\9a\ 1\13Ù\ 1\8c" 19 "\ 2\13Ö\ 1\9a\13\8c\ 1\84"] #^^[2 12288 "\ 2\12\13\84\ 1\83\13\99\ 1\89\10\84\ 1\ 1\13\ 1\85\13\13\ 1\85\13\83\ 1À" "\ 2\ 1\99\10\10\13\13\ 1\83\13\ 1Ú\13\ 1\84" 1 "\ 2\ 1À\13¤\ 1\9c" "\ 2\ 1\9d\13\13\ 1±\13\90\ 1\9c\13\83\ 1" "\ 2\ 1±\13\8f\ 1\8c\13\84\ 1°" "\ 2\ 1÷\13\84\ 1\85" "\ 2\ 1Þ\13\13\ 1\9f\13" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 16384 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "\ 2\ 1À\13À" 1 1 1 1] 1 1 1 1 #^^[2 36864 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
+#^^[3 0 5 5 5 5 5 5 5 5 5 17 6 17 18 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 17 18 19 19 14 14 14 19 19 19 19 19 13 15 13 15 15 3 3 3 3 3 3 3 3 3 3 15 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 19 19 19 19 5] "\ 2\ 5\85\ 6\ 5\9a\ f\13\ e\84\13\84\ 1\13\13\ 5\13\13\ e\ e\ 3\ 3\13\ 1\13\83\ 3\ 1\13\85\ 1\97\13\ 1\9f\13\ 1\88" 1 1 1 "\ 2\ 1¹\13\13\ 1\87\13\8e\ 1\ 1\13\8e\ 1\85\13\89\ 1\13\91" "\ 2\10ð\ 1\84\13\13\ 1\88\13\ 1" "\ 2\ 1\84\13\13\ 1\13\ 1î\13\ 1\89" 1 "\ 2\ 1\83\10\87\ 1ö" 1 "\ 2\ 1\8a\13\ 1\84\ e\ 2\10­\ 2\10\ 2\10\10\ 2\10\10\ 2\10\ 2¸" "\ 2\ 4\85\a\13\13\a\ e\ e\a\ f\a\13\13\10\8b\a°\10\95\ 4\8a\ e\ 4\ 4\a\83\10\a\8f" "\ 2\aÖ\10\87\ 4\13\10\86\a\a\10\10\13\10\84\a\a\ 3\8a\a\86" "\ 2\a\8e\ 1\a\a\10\a\9e\10\9b\ 1\ 1\a³" "\ 2\a¦\10\8b\a\ 1\8e\ 2«\10\89\ 2\ 2\13\84\ 2\86" "\ 2\ 2\96\10\84\ 2\10\89\ 2\10\83\ 2\10\85\ 2«\10\83\ 2¤" "\ 2\ 2 \a\ 2\a\8b\ 2·\10\9b\ 2" "\ 2\10\83\ 1·\10\ 1\10\ 1\84\10\88\ 1\84\10\ 1\83\10\87\ 1\8a\10\10\ 1\9c" "\ 2\ 1\10\ 1º\10\ 1\84\10\84\ 1\88\10\ 1\94\10\10\ 1\8e\ e\ e\ 1\87\ e\ 1\84" "\ 2\ 1\10\10\ 1¹\10\ 1\84\10\10\ 1\84\10\10\ 1\ 1\10\83\ 1\83\10\ 1\9e\10\10\ 1\83\10\ 1\8a" "\ 2\ 1\10\10\ 1¹\10\ 1\84\10\85\ 1\10\10\ 1\84\10\ 1\94\10\10\ 1\8d\ e\ 1\8e" "\ 2\ 1\10\ 1º\10\ 1\ 1\10\ 1\10\84\ 1\88\10\ 1\88\10\ 1\8b\10\10\ 1\9c" "\ 2\ 1\ 1\10\ 1½\10\ 1\8c\10\ 1¥\13\86\ e\13\ 1\85" "\ 2\ 1¾\10\83\ 1\85\10\83\ 1\10\84\ 1\87\10\10\ 1\8b\10\10\ 1\94\13\87\ 1" "\ 2\ 1¼\10\ 1\8f\10\10\ 1\94\10\10\ 1\9c" "\ 2\ 1Á\10\84\ 1\88\10\ 1\94\10\10\ 1\9c" "\ 2\ 1Ê\10\ 1\87\10\83\ 1\10\ 1©" "\ 2\ 1±\10\ 1\ 1\10\87\ 1\84\ e\ 1\87\10\88\ 1±" "\ 2\ 1±\10\ 1\ 1\10\86\ 1\10\10\ 1\8b\10\86\ 1²" "\ 2\ 1\98\10\10\ 1\9b\10\ 1\10\ 1\10\13\84\ 1³\10\8e\ 1" "\ 2\10\85\ 1\10\10\ 1\85\10\8b\ 1\10¤\ 1\89\10\ 1¹"] #^^[2 4096 "\ 2\ 1­\10\84\ 1\10\86\ 1\10\10\ 1\ 1\10\10\ 1\99\10\10\ 1\84\10\83\ 1\90\10\84\ 1\8b" "\ 2\ 1\ 1\10\ 1\ 1\10\10\ 1\86\10\ 1\8f\10\ 1â" 1 1 1 1 "\ 2\ 1Ý\10\83\ 1 " "\ 2\ 1\90\13\8a\ 1æ" "\ 2\13\ 1ÿ" 1 1 1 1 "\ 2\12\ 1\9a\13\13\ 1ã" "\ 2\ 1\92\10\83\ 1\9d\10\83\ 1\9d\10\10\ 1\9e\10\10\ 1\8c" "\ 2\ 1´\10\10\ 1\10\87\ 1\88\10\ 1\ 1\10\8b\ 1\87\ e\ 1\10\ 1\92\13\8a\ 1\86" "\ 2\13\8b\10\83\ 5\ 1ñ" "\ 2\ 1©\10\ 1Ö" "\ 2\ 1 \10\83\ 1\84\10\10\ 1\89\10\ 1\86\10\83\ 1\84\13\ 1\83\13\13\ 1º" "\ 2\ 1Þ\13¢" "\ 2\ 1\97\10\10\ 1\ 1\10\ 1º\10\ 1\10\87\ 1\10\ 1\10\ 1\ 1\10\88\ 1\86\10\8a\ 1\ 1\10" 1 "\ 2\10\84\ 1°\10\ 1\10\85\ 1\10\ 1\85\10\ 1¨\10\89\ 1\8c" "\ 2\10\10\ 1 \10\84\ 1\ 1\10\10\ 1\10\ 1º\10\ 1\10\10\ 1\83\10\ 1\10\83\ 1\8e" "\ 2\ 1¬\10\88\ 1\ 1\10\10\ 1È" "\ 2\ 1Ð\10\83\ 1\10\8d\ 1\10\87\ 1\84\10\ 1\86\10\ 1\8b" 1 "\ 2\ 1À\10§\ 1\95\10\84" 1 1 1 "\ 2\ 1½\13\ 1\13\83\ 1\8b\13\83\ 1\8d\13\83\ 1\8d\13\83\ 1\8d\13\13\ 1"] #^^[2 8192 "\ 2\12\8b\ 5\83\ 1\ 2\13\98\12\ 6\b
+\f      \v\ f\ e\85\13\8f\ f\13\9a\12\ 5\85\ 1\14\15\16\17\ 5\86\ 3\ 1\83\ 3\86\r\r\13\83\ 1" "\ 2\ 3\8a\r\r\13\83\ 1\91\ e\9b\ 1\95\10¡\ 1\8f" "\ 2\13\13\ 1\13\84\ 1\13\13\ 1\8a\13\ 1\13\83\ 1\85\13\86\ 1\13\ 1\13\ 1\13\ 1\84\ e\ 1\8b\13\13\ 1\84\13\85\ 1\85\13\84\ 1\ 1\13\90\ 1 " "\ 2\ 1\89\13\ 1\86\13ð" "\ 2\13\92\r\ e\13ì" 19 "\ 2\13\ 1Å\13\85" "\ 2\13\95\ 1\13Þ\ 1\8c" "\ 2\13§\ 1\99\13\8b\ 1\95\13 " "\ 2\13\88\ 3\94\ 1Î\13\96" 19 19 19 "\ 2\13¬\ 1\13Ó" "\ 2\ 1\13ÿ" 19 1 1 19 19 19 19 "\ 2\13Í\ 1\83\13\8a\ 1¦" 1 1 "\ 2\ 1å\13\86\ 1\84\10\83\ 1\87\13\87" "\ 2\ 1ÿ\10" "\ 2\ 1à\10 " "\ 2\13¼\ 1Ä" "\ 2\13\9a\ 1\13Ù\ 1\8c" 19 "\ 2\13Ö\ 1\9a\13\8c\ 1\84"] #^^[2 12288 "\ 2\12\13\84\ 1\83\13\99\ 1\89\10\84\ 1\ 1\13\ 1\85\13\13\ 1\85\13\83\ 1À" "\ 2\ 1\99\10\10\13\13\ 1\83\13\ 1Ú\13\ 1\84" 1 "\ 2\ 1À\13¤\ 1\9c" "\ 2\ 1\9d\13\13\ 1±\13\90\ 1\9c\13\83\ 1" "\ 2\ 1±\13\8f\ 1\8c\13\84\ 1°" "\ 2\ 1÷\13\84\ 1\85" "\ 2\ 1Þ\13\13\ 1\9f\13" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 16384 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "\ 2\ 1À\13À" 1 1 1 1] 1 1 1 1 #^^[2 36864 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
 #^^[3 40832 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]] #^^[2 40960 1 1 1 1 1 1 1 1 1 "\ 2\ 1\90\13·\ 1¹" 1 1 "\ 2\ 1\8d\13\83\ 1ß\10\84\13\10\8a\13\13" "\ 2\ 1\9f\10\ 1Ð\10\10\ 1\8e" "\ 2\13¢\ 1Þ" "\ 2\ 1\88\13\ 1÷" "\ 2\ 1\ 1\10\ 1\83\10\ 1\84\10\ 1\99\10\10\ 1\13\84\ 1\8c\ e\ e\ 1º\13\84\ 1\88" "\ 2\ 1Ä\10\ 1\9b\10\92\ 1\8e" "\ 2\ 1¦\10\88\ 1\99\10\8b\ 1®" "\ 2\10\83\ 1°\10\ 1\ 1\10\84\ 1\ 1\10\ 1Ã" "\ 2\ 1©\10\86\ 1\ 1\10\10\ 1\ 1\10\10\ 1\8c\10\ 1\88\10\ 1³" "\ 2\ 1°\10\ 1\10\83\ 1\ 1\10\10\ 1\85\10\10\ 1\10\ 1ª\10\10\ 1\88\10\ 1\89" 1 "\ 2\ 1å\10\ 1\ 1\10\ 1\84\10\ 1\92" 1 1 1 1 1 1 1 1] 1 1 #^^[2 53248 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 #^^[2 61440 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "\ 2\ 1\9d\ 2\10\ 2\8a\r\ 2¦\a°" 7 7 7 "\ 2\a¾\13\13\aÀ" "\ 2\aý\13\a\a" "\ 2\10\90\13\8a\ 1\86\10\87\ 1\89\13 \ f\13\ f\ 1\13\ f\13\89\ e\13\13\r\r\13\83\ 1\13\ e\ e\13\ 1\84\a\90" "\ 2\aÿ\ 5" "\ 2\ 1\13\13\ e\83\13\85\r\ f\r\ f\ f\ 3\8a\ f\13\86\ 1\9a\13\86\ 1\9a\13\8b\ 1\9a" "\ 2\ 1à\ e\ e\13\83\ e\ e\ 1\13\87\ 1\8a\13\85\ 1\ 1"]] #^^[1 65536 #^^[2 65536 1 1 "\ 2\ 1\13\ 1¾\13À" "\ 2\13\8b\ 1\85\13\8c\ 1á\10\ 1\ 1" 1 1 1 1 1 1 1 1 1 1 1 1 2 2 "\ 2\ 2\9f\13\ 2à" 2 "\ 2\ 2\10\83\ 2\10\10\ 2\85\10\84\ 2¨\10\83\ 2\84\10\ 2À" 2 "\ 2\ 2¹\13\87\ 2À" 2 2 2 2 2 "\ 2\ 2à\ 4\9f\ 2" 2 2 2] #^^[2 69632 "\ 2\ 1\10\ 1\10\8f\ 1\8b\13\94\ 1\9a" "\ 2\10\10\ 1±\10\84\ 1\ 1\10\10\ 1Å" "\ 2\10\83\ 1¤\10\85\ 1\10\88\ 1Ë" "\ 2\10\10\ 1´\10\89\ 1Á" 1 1 1 1 1 1 1 1 1 "\ 2\ 1«\10\ 1\10\ 1\ 1\10\86\ 1\10\ 1È" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 73728 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 77824 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 #^^[2 90112 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "\ 2\ 1\8f\10\84\ 1í"] 1 1 1 1 #^^[2 110592 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 #^^[2 118784 1 1 "\ 2\ 1ç\10\83\ 1\89\ 5\88\10\85" "\ 2\10\83\ 1\ 1\10\87\ 1\9e\10\84\ 1Ò" "\ 2\13Â\10\83\13\ 1º" 1 "\ 2\13×\ 1©" 1 1 1 1 1 1 "\ 2\ 1Û\13\ 1¤" "\ 2\ 1\95\13\ 1¹\13\ 1°" "\ 2\ 1\89\13\ 1¹\13\ 1\8a\ 3²" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 122880 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 "\ 2\a\84\ 2\a\9b\ 2\a\a\ 2\a\ 2\ 2\a\ 2\a\8a\ 2\a\84\ 2\a\ 2\a\ 2\86\a\ 2\84\a\ 2\a\ 2\a\ 2\a\83\ 2\a\a\ 2\a\ 2\ 2\a\ 2\a\ 2\a\ 2\a\ 2\a\ 2\a\a\ 2\a\ 2\ 2\a\84\ 2\a\87\ 2\a\84\ 2\a\84\ 2\a\ 2" "\ 2\a\8a\ 2\a\91\ 2\85\a\83\ 2\a\85\ 2\a\91\ 2´\13\13\ 2\8e" 2 2] #^^[2 126976 "\ 2\13¬\ 1\84\13Ð" "\ 2\13\94\ 1\8c\13\8f\ 1\ 1\13\8e\ 1\ 1\13\8f\ 1\13\8f\ 1 " "\ 2\ 3\8b\ 1ß\13\13\ 1\94" 1 1 1 "\ 2\13¡\ 1\8f\13\86\ 1\13Æ\ 1\83" "\ 2\13\94\ 1\8c\13¥\ 1\13\85\ 1\95\13\91\ 1\8f" "\ 2\13¿\ 1\13\ 1\13¾" "\ 2\13ø\ 1\13\84\ 1\83" "\ 2\13¾\ 1\ 1\13\84\ 1\8c\13\98\ 1\98" "\ 2\ 1û\13\85" "\ 2\13Á\ 1\84\13\8b\ 1°" "\ 2\13Æ\ 1º" "\ 2\13ô\ 1\8c" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]] #^^[1 131072 1 1 1 1 1 1 1 1 1 1 #^^[2 172032 1 1 1 1 1 1 1 1 1 1 1 1 1 
 #^^[3 173696 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[2 176128 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
 #^^[3 177920 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 
 #^^[3 178176 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 #^^[2 192512 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]] 1 1 1 1 1 1 1 1 1 1 1 #^^[1 917504 #^^[2 917504 "\ 2\ 1\ 5\ 1\9e\ 5à" 1 16 "\ 2\10ð\ 1\90" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[1 983040 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #^^[2 1044480 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
 #^^[3 1048448 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] #^^[1 1048576 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #^^[2 1110016 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
-#^^[3 1113984 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 bidi-class 0 1 #[(val) "\b\301\236A\207" [val ((L . "Left-to-Right") (LRE . "Left-to-Right Embedding") (LRO . "Left-to-Right Override") (R . "Right-to-Left") (AL . "Right-to-Left Arabic") (RLE . "Right-to-Left Embedding") (RLO . "Right-to-Left Override") (PDF . "Pop Directional Format") (EN . "European Number") (ES . "European Number Separator") (ET . "European Number Terminator") (AN . "Arabic Number") (CS . "Common Number Separator") (NSM . "Non-Spacing Mark") (BN . "Boundary Neutral") (B . "Paragraph Separator") (S . "Segment Separator") (WS . "Whitespace") (ON . "Other Neutrals"))] 2] [nil L R EN AN BN B AL LRE LRO RLE RLO PDF ES ET CS NSM S WS ON]] "Unicode bidi class.
+#^^[3 1113984 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 bidi-class 0 1 #[(val) "\b\301\236A\207" [val ((L . "Left-to-Right") (LRE . "Left-to-Right Embedding") (LRO . "Left-to-Right Override") (R . "Right-to-Left") (AL . "Right-to-Left Arabic") (RLE . "Right-to-Left Embedding") (RLO . "Right-to-Left Override") (PDF . "Pop Directional Format") (EN . "European Number") (ES . "European Number Separator") (ET . "European Number Terminator") (AN . "Arabic Number") (CS . "Common Number Separator") (NSM . "Non-Spacing Mark") (BN . "Boundary Neutral") (B . "Paragraph Separator") (S . "Segment Separator") (WS . "Whitespace") (ON . "Other Neutrals"))] 2] [nil L R EN AN BN B AL LRE LRO RLE RLO PDF ES ET CS NSM S WS ON LRI RLI FSI PDI]]
+  "Unicode bidi class.
 Property value is one of the following symbols:
   L, LRE, LRO, R, AL, RLE, RLO, PDF, EN, ES, ET,
   AN, CS, NSM, BN, B, S, WS, ON")
 ;; Local Variables:
 ;; coding: utf-8
+;; version-control: never
 ;; no-byte-compile: t
 ;; End:
 
index 75ebc04c98feab4214710b4dd62bf6ac6d1b758c..45148c91746f03910c3fd0cd275678e4b0adb555 100644 (file)
@@ -1,14 +1,15 @@
-;; Copyright (C) 1991-2009 Unicode, Inc.
+;; Copyright (C) 1991-2013 Unicode, Inc.
 ;; This file was generated from the Unicode data files at
 ;; http://www.unicode.org/Public/UNIDATA/.
 ;; See lisp/international/README for the copyright and permission notice.
-(define-char-code-property 'general-category #^[30 nil char-code-property-table 
+(define-char-code-property 'general-category
+  #^[30 nil char-code-property-table 
 #^^[3 0 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 23 18 18 18 20 18 18 18 14 15 18 19 18 13 18 18 9 9 9 9 9 9 9 9 9 9 18 18 19 19 19 18 18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 18 15 21 12 21 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 14 19 15 19 26] #^^[1 0 #^^[2 0 
-#^^[3 0 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 23 18 18 18 20 18 18 18 14 15 18 19 18 13 18 18 9 9 9 9 9 9 9 9 9 9 18 18 19 19 19 18 18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 18 15 21 12 21 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 14 19 15 19 26] "\ 2\1a \17\12\14\84\16\12\15\16\ 5\10\13\e\16\15\16\13\v\v\15\ 2\12\12\15\v\ 5\11\v\83\12\ 1\97\13\ 1\87\ 2\98\13\ 2\88" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 2" "\ 2\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\83\ 2\ 2\ 1\84\ 2\ 1\ 1\ 2\ 1\83\ 2\83\ 1\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 1\ 2\ 1\83\ 2\ 1\ 2\ 1\ 1\ 2\ 2\ 5\ 1\ 2\83\ 5\84\ 1\ 3\ 2\ 1\ 3\ 2\ 1\ 3\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 3\ 2\ 1\ 2\ 1\83\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\87\ 1\ 1\ 2\ 1\ 1\ 2\ 2\ 1\ 2\ 1\84\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2±" "\ 2\ 2\94\ 5\ 2\9b\ 4\92\15\84\ 4\8c\15\8e\ 4\85\15\87\ 4\15\ 4\15\91" "\ 2\ 6ð\ 1\ 2\ 1\ 2\ 4\15\ 1\ 2\1e\1e\ 4\ 2\83\12\1e" "\ 2\1e\84\15\15\ 1\12\ 1\83\1e\ 1\1e\ 1\ 1\ 2\ 1\91\1e\ 1\89\ 2£\ 1\ 2\ 2\ 1\83\ 2\83\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\85\ 1\ 2\13\ 1\ 2\ 1\ 1\ 2\ 2\ 1\83" "\ 2\ 1°\ 2°\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\16\ 6\85\b\b\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\1e\89\ 1¦\1e\1e\ 4\12\86\1e\ 2\9f" "\ 2\ 2\88\1e\12\r\1e\84\14\1e\ 6­\r\ 6\12\ 6\ 6\12\ 6\ 6\12\ 6\1e\88\ 5\9b\1e\85\ 5\83\12\12\1e\8b" "\ 2\e\85\1e\13\83\12\12\14\12\12\16\16\ 6\8b\12\1e\1e\12\12\ 5 \ 4\ 5\8a\ 6\95   \8a\12\84\ 5\ 5\ 6\ 5\8f" "\ 2\ 5Ô\12\ 5\ 6\87\e\16\ 6\86\ 4\ 4\ 6\ 6\16\ 6\84\ 5\ 5  \8a\ 5\83\16\16\ 5" "\ 2\12\8e\1e\e\ 5\ 6\ 5\9e\ 6\9b\1e\1e\ 5³" "\ 2\ 5¦\ 6\8b\ 5\1e\8e    \8a\ 5¡\ 6\89\ 4\ 4\16\12\83\ 4\1e\85" "\ 2\ 5\96\ 6\84\ 4\ 6\89\ 4\ 6\83\ 4\ 6\85\1e\1e\12\8f\1e\ 5\99\ 6\83\1e\1e\12\1e¡" "\ 2\1e \ 5\1e\ 5\8b\1e·\ 6\9b\1e" "\ 2\ 6\83\a\ 5\ 6\a\ 6\ 5\a\83\ 6\88\a\84\ 6\a\a\ 5\ 6\87\ 5\8a\ 6\ 6\12\12     \8a\12\ 4\ 5\86\1e\ 5\87" "\ 2\1e\ 6\a\a\1e\ 5\88\1e\1e\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\1e\83\ 5\84\1e\1e\ 6\ 5\a\83\ 6\84\1e\1e\a\a\1e\1e\a\a\ 6\ 5\1e\88\a\1e\84\ 5\ 5\1e\ 5\83\ 6\ 6\1e\1e       \8a\ 5\ 5\14\14\v\86\16\14\1e\84" "\ 2\1e\ 6\ 6\a\1e\ 5\86\1e\84\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\ 5\1e\ 5\ 5\1e\1e\ 6\1e\a\83\ 6\ 6\1e\84\ 6\ 6\1e\1e\ 6\83\1e\83\ 6\1e\87\ 5\84\1e\ 5\1e\87     \8a\ 6\ 6\ 5\83\ 6\1e\8a" "\ 2\1e\ 6\ 6\a\1e\ 5\89\1e\ 5\83\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\85\1e\1e\ 6\ 5\a\83\ 6\85\1e\ 6\ 6\a\1e\a\a\ 6\1e\1e\ 5\1e\8f\ 5\ 5\ 6\ 6\1e\1e        \8a\12\14\1e\8e" "\ 2\1e\ 6\a\a\1e\ 5\88\1e\1e\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\85\1e\1e\ 6\ 5\a\ 6\a\ 6\84\1e\1e\a\a\1e\1e\a\a\ 6\1e\88\ 6\a\1e\84\ 5\ 5\1e\ 5\83\ 6\ 6\1e\1e    \8a\16\ 5\v\86\1e\88" "\ 2\1e\1e\ 6\ 5\1e\ 5\86\1e\83\ 5\83\1e\ 5\84\1e\83\ 5\ 5\1e\ 5\1e\ 5\ 5\1e\83\ 5\ 5\1e\83\ 5\83\1e\83\ 5\8c\1e\84\a\a\ 6\a\a\1e\83\a\83\1e\a\83\ 6\1e\1e\ 5\1e\86\a\1e\8e        \8a\v\83\16\86\14\16\1e\85" "\ 2\1e\a\83\1e\ 5\88\1e\ 5\83\1e\ 5\97\1e\ 5\8a\1e\ 5\85\1e\83\ 5\ 6\83\a\84\1e\ 6\83\1e\ 6\84\1e\87\ 6\ 6\1e\ 5\ 5\1e\86\ 5\ 5\ 6\ 6\1e\1e    \8a\1e\88\v\87\16" "\ 2\1e\1e\a\a\1e\ 5\88\1e\ 5\83\1e\ 5\97\1e\ 5\8a\1e\ 5\85\1e\1e\ 6\ 5\a\ 6\a\85\1e\ 6\a\a\1e\a\a\ 6\ 6\1e\87\a\a\1e\87\ 5\1e\ 5\ 5\ 6\ 6\1e\1e \8a\1e\ 5\ 5\1e\8d" "\ 2\1e\1e\a\a\1e\ 5\88\1e\ 5\83\1e\ 5©\1e\1e\ 5\a\83\ 6\84\1e\a\83\1e\a\83\ 6\ 5\1e\88\a\1e\88\ 5\ 5\ 6\ 6\1e\1e    \8a\v\86\1e\83\16\ 5\86" "\ 2\1e\1e\a\a\1e\ 5\92\1e\83\ 5\98\1e\ 5\89\1e\ 5\1e\1e\ 5\87\1e\83\ 6\1e\84\a\83\ 6\83\1e\ 6\1e\a\88\1e\92\a\a\12\1e\8b" "\ 2\1e\ 5°\ 6\ 5\ 5\ 6\87\1e\84\14\ 5\86\ 4\ 6\88\12 \8a\12\12\1e¤" "\ 2\1e\ 5\ 5\1e\ 5\1e\1e\ 5\ 5\1e\ 5\1e\1e\ 5\1e\86\ 5\84\1e\ 5\87\1e\ 5\83\1e\ 5\1e\ 5\1e\1e\ 5\ 5\1e\ 5\84\ 6\ 5\ 5\ 6\86\1e\ 6\ 6\ 5\1e\1e\ 5\85\1e\ 4\1e\ 6\86\1e\1e      \8a\1e\1e\ 5\84\1e " "\ 2\ 5\16\83\12\8f\16\12\16\83\ 6\ 6\16\86 \8a\v\8a\16\ 6\16\ 6\16\ 6\ e\ f\ e\ f\a\a\ 5\88\1e\ 5¤\1e\84\ 6\8e\a" "\ 2\ 6\85\12\ 6\ 6\ 5\85\ 6\8b\1e\ 6¤\1e\16\88\ 6\16\86\1e\16\16\12\85\16\84\12\12\1e¥"] #^^[2 4096 "\ 2\ 5«\a\a\ 6\84\a\ 6\86\a\ 6\ 6\a\a\ 6\ 6\ 5   \8a\12\86\ 5\86\a\a\ 6\ 6\ 5\84\ 6\83\ 5\a\83\ 5\ 5\a\87\ 5\83\ 6\84\ 5\8b" "\ 2\ 5\ 5\ 6\a\a\ 6\ 6\a\86\ 6\ 5\a   \8a\a\83\ 6\16\16\ 1¦\1e\ 1\1e\85\ 1\1e\1e\ 5«\12\ 4\ 5\83" 5 5 "\ 2\ 5É\1e\ 5\84\1e\1e\ 5\87\1e\ 5\1e\ 5\84\1e\1e\ 5 " "\ 2\ 5\89\1e\ 5\84\1e\1e\ 5¡\1e\ 5\84\1e\1e\ 5\87\1e\ 5\1e\ 5\84\1e\1e\ 5\8f\1e\ 5¨" "\ 2\ 5\91\1e\ 5\84\1e\1e\ 5Ã\1e\1e\ 6\83\12\89\v\94\1e\83" "\ 2\ 5\90\16\8a\1e\86\ 5Õ\1e\8b" "\ 2\r\ 5ÿ" 5 5 5 "\ 2\ 5í\12\12\ 5\91" "\ 2\17\ 5\9a\ e\ f\1e\83\ 5Ë\12\83
-\83\1e\8f" "\ 2\ 5\8d\1e\ 5\84\ 6\83\1e\8b\ 5\92\ 6\83\12\12\1e\89\ 5\92\ 6\ 6\1e\8c\ 5\8d\1e\ 5\83\1e\ 6\ 6\1e\8c" "\ 2\ 5´\ 6\ 6\a\ 6\87\a\88\ 6\a\a\ 6\8b\12\83\ 4\12\83\14\ 5\ 6\1e\1e       \8a\1e\86\v\8a\1e\86" "\ 2\12\86\r\12\84\ 6\83\17\1e     \8a\1e\86\ 5£\ 4\ 5´\1e\88" "\ 2\ 5©\ 6\ 5\1e\85\ 5Æ\1e\8a" "\ 2\ 5\9d\1e\83\ 6\83\a\84\ 6\ 6\a\83\1e\84\a\a\ 6\a\86\ 6\83\1e\84\16\1e\83\12\12     \8a\ 5\9e\1e\1e\ 5\85\1e\8b" "\ 2\ 5¬\1e\84\a\91\ 5\87\a\a\1e\86      \8a\v\1e\83\16¢" "\ 2\ 5\97\ 6\ 6\a\83\1e\1e\12\12\ 5µ\a\ 6\a\ 6\87\1e\ 6\a\ 6\a\a\ 6\88\a\86\ 6\8a\1e\1e\ 6" "\ 2        \8a\1e\86   \8a\1e\86\12\87\ 4\12\86\1eÒ" "\ 2\ 6\84\a\ 5¯\ 6\a\ 6\85\a\ 6\a\85\ 6\a\a\ 5\87\1e\84   \8a\12\87\16\8a\ 6\89\16\89\1e\83" "\ 2\ 6\ 6\a\ 5\9e\a\ 6\84\a\a\ 6\ 6\a\ 6\a\a\ 5\ 5       \8a\ 5¬\ 6\a\ 6\ 6\a\83\ 6\a\ 6\83\a\a\1e\88\12\84" "\ 2\ 5¤\a\88\ 6\88\a\a\ 6\ 6\1e\83\12\85        \8a\1e\83\ 5\83        \8a\ 5\9e\ 4\86\12\12" "\ 2\1eÀ\12\88\1e\88\ 6\83\12\ 6\8d\a\ 6\87\ 5\84\ 6\ 5\84\a\a\ 6\ 5\ 5\1e\89" "\ 2\ 2¬\ 4¿\ 2\8d\ 4\ 2\87" "\ 2\ 2\9b\ 4¥\ 6§\1e\95\ 6\84" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\89\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 2\88\ 1\88\ 2\86\1e\1e\ 1\86\1e\1e\ 2\88\ 1\88\ 2\88\ 1\88\ 2\86\1e\1e\ 1\86\1e\1e\ 2\88\1e\ 1\1e\ 1\1e\ 1\1e\ 1\ 2\88\ 1\88\ 2\8e\1e\1e" "\ 2\ 2\88\ 3\88\ 2\88\ 3\88\ 2\88\ 3\88\ 2\85\1e\ 2\ 2\ 1\84\ 3\15\ 2\15\83\ 2\83\1e\ 2\ 2\ 1\84\ 3\15\83\ 2\84\1e\1e\ 2\ 2\ 1\84\1e\15\83\ 2\88\ 1\85\15\83\1e\1e\ 2\83\1e\ 2\ 2\ 1\84\ 3\15\15\1e"] #^^[2 8192 "\ 2\17\8b\e\85\r\86\12\12\10\11\ e\10\10\11\ e\10\12\88\18\19\e\85\17\12\89\10\11\12\84\f\f\12\83\13\ e\ f\12\8b\13\12\f\12\8a\17\e\85\1e\85\e\86\v\ 4\1e\1e\v\86\13\83\ e\ f\ 4" "\ 2\v\8a\13\83\ e\ f\1e\ 4\8d\1e\83\14\9b\1e\95\ 6\8d\b\84\ 6\b\83\ 6\8c\1e\8f" "\ 2\16\16\ 1\16\84\ 1\16\16\ 2\ 1\83\ 2\ 2\ 1\83\ 2\16\ 1\16\16\13\ 1\85\16\86\ 1\16\ 1\16\ 1\16\ 1\84\16\ 2\ 1\84\ 2\ 5\84\ 2\16\16\ 2\ 2\ 1\ 1\13\85\ 1\ 2\84\16\13\16\16\ 2\16\v\90
+#^^[3 0 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 23 18 18 18 20 18 18 18 14 15 18 19 18 13 18 18 9 9 9 9 9 9 9 9 9 9 18 18 19 19 19 18 18 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 18 15 21 12 21 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 14 19 15 19 26] "\ 2\1a \17\12\14\84\16\12\15\16\ 5\10\13\e\16\15\16\13\v\v\15\ 2\12\12\15\v\ 5\11\v\83\12\ 1\97\13\ 1\87\ 2\98\13\ 2\88" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 2" "\ 2\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\83\ 2\ 2\ 1\84\ 2\ 1\ 1\ 2\ 1\83\ 2\83\ 1\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 1\ 2\ 1\83\ 2\ 1\ 2\ 1\ 1\ 2\ 2\ 5\ 1\ 2\83\ 5\84\ 1\ 3\ 2\ 1\ 3\ 2\ 1\ 3\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 3\ 2\ 1\ 2\ 1\83\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\87\ 1\ 1\ 2\ 1\ 1\ 2\ 2\ 1\ 2\ 1\84\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2±" "\ 2\ 2\94\ 5\ 2\9b\ 4\92\15\84\ 4\8c\15\8e\ 4\85\15\87\ 4\15\ 4\15\91" "\ 2\ 6ð\ 1\ 2\ 1\ 2\ 4\15\ 1\ 2\1e\1e\ 4\ 2\83\12\1e" "\ 2\1e\84\15\15\ 1\12\ 1\83\1e\ 1\1e\ 1\ 1\ 2\ 1\91\1e\ 1\89\ 2£\ 1\ 2\ 2\ 1\83\ 2\83\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\85\ 1\ 2\13\ 1\ 2\ 1\ 1\ 2\ 2\ 1\83" "\ 2\ 1°\ 2°\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\16\ 6\85\b\b\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\1e\89\ 1¦\1e\1e\ 4\12\86\1e\ 2\9f" "\ 2\ 2\88\1e\12\r\1e\84\14\1e\ 6­\r\ 6\12\ 6\ 6\12\ 6\ 6\12\ 6\1e\88\ 5\9b\1e\85\ 5\83\12\12\1e\8b" "\ 2\e\85\1e\13\83\12\12\14\12\12\16\16\ 6\8b\12\e\1e\12\12\ 5 \ 4\ 5\8a\ 6\95   \8a\12\84\ 5\ 5\ 6\ 5\8f" "\ 2\ 5Ô\12\ 5\ 6\87\e\16\ 6\86\ 4\ 4\ 6\ 6\16\ 6\84\ 5\ 5  \8a\ 5\83\16\16\ 5" "\ 2\12\8e\1e\e\ 5\ 6\ 5\9e\ 6\9b\1e\1e\ 5³" "\ 2\ 5¦\ 6\8b\ 5\1e\8e    \8a\ 5¡\ 6\89\ 4\ 4\16\12\83\ 4\1e\85" "\ 2\ 5\96\ 6\84\ 4\ 6\89\ 4\ 6\83\ 4\ 6\85\1e\1e\12\8f\1e\ 5\99\ 6\83\1e\1e\12\1e¡" "\ 2\1e \ 5\1e\ 5\8b\1e·\ 6\9b\1e" "\ 2\ 6\83\a\ 5\ 6\a\ 6\ 5\a\83\ 6\88\a\84\ 6\a\a\ 5\ 6\87\ 5\8a\ 6\ 6\12\12     \8a\12\ 4\ 5\86\1e\ 5\87" "\ 2\1e\ 6\a\a\1e\ 5\88\1e\1e\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\1e\83\ 5\84\1e\1e\ 6\ 5\a\83\ 6\84\1e\1e\a\a\1e\1e\a\a\ 6\ 5\1e\88\a\1e\84\ 5\ 5\1e\ 5\83\ 6\ 6\1e\1e       \8a\ 5\ 5\14\14\v\86\16\14\1e\84" "\ 2\1e\ 6\ 6\a\1e\ 5\86\1e\84\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\ 5\1e\ 5\ 5\1e\1e\ 6\1e\a\83\ 6\ 6\1e\84\ 6\ 6\1e\1e\ 6\83\1e\83\ 6\1e\87\ 5\84\1e\ 5\1e\87     \8a\ 6\ 6\ 5\83\ 6\1e\8a" "\ 2\1e\ 6\ 6\a\1e\ 5\89\1e\ 5\83\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\85\1e\1e\ 6\ 5\a\83\ 6\85\1e\ 6\ 6\a\1e\a\a\ 6\1e\1e\ 5\1e\8f\ 5\ 5\ 6\ 6\1e\1e        \8a\12\14\1e\8e" "\ 2\1e\ 6\a\a\1e\ 5\88\1e\1e\ 5\ 5\1e\1e\ 5\96\1e\ 5\87\1e\ 5\ 5\1e\ 5\85\1e\1e\ 6\ 5\a\ 6\a\ 6\84\1e\1e\a\a\1e\1e\a\a\ 6\1e\88\ 6\a\1e\84\ 5\ 5\1e\ 5\83\ 6\ 6\1e\1e    \8a\16\ 5\v\86\1e\88" "\ 2\1e\1e\ 6\ 5\1e\ 5\86\1e\83\ 5\83\1e\ 5\84\1e\83\ 5\ 5\1e\ 5\1e\ 5\ 5\1e\83\ 5\ 5\1e\83\ 5\83\1e\83\ 5\8c\1e\84\a\a\ 6\a\a\1e\83\a\83\1e\a\83\ 6\1e\1e\ 5\1e\86\a\1e\8e        \8a\v\83\16\86\14\16\1e\85" "\ 2\1e\a\83\1e\ 5\88\1e\ 5\83\1e\ 5\97\1e\ 5\8a\1e\ 5\85\1e\83\ 5\ 6\83\a\84\1e\ 6\83\1e\ 6\84\1e\87\ 6\ 6\1e\ 5\ 5\1e\86\ 5\ 5\ 6\ 6\1e\1e    \8a\1e\88\v\87\16" "\ 2\1e\1e\a\a\1e\ 5\88\1e\ 5\83\1e\ 5\97\1e\ 5\8a\1e\ 5\85\1e\1e\ 6\ 5\a\ 6\a\85\1e\ 6\a\a\1e\a\a\ 6\ 6\1e\87\a\a\1e\87\ 5\1e\ 5\ 5\ 6\ 6\1e\1e \8a\1e\ 5\ 5\1e\8d" "\ 2\1e\1e\a\a\1e\ 5\88\1e\ 5\83\1e\ 5©\1e\1e\ 5\a\83\ 6\84\1e\a\83\1e\a\83\ 6\ 5\1e\88\a\1e\88\ 5\ 5\ 6\ 6\1e\1e    \8a\v\86\1e\83\16\ 5\86" "\ 2\1e\1e\a\a\1e\ 5\92\1e\83\ 5\98\1e\ 5\89\1e\ 5\1e\1e\ 5\87\1e\83\ 6\1e\84\a\83\ 6\83\1e\ 6\1e\a\88\1e\92\a\a\12\1e\8b" "\ 2\1e\ 5°\ 6\ 5\ 5\ 6\87\1e\84\14\ 5\86\ 4\ 6\88\12 \8a\12\12\1e¤" "\ 2\1e\ 5\ 5\1e\ 5\1e\1e\ 5\ 5\1e\ 5\1e\1e\ 5\1e\86\ 5\84\1e\ 5\87\1e\ 5\83\1e\ 5\1e\ 5\1e\1e\ 5\ 5\1e\ 5\84\ 6\ 5\ 5\ 6\86\1e\ 6\ 6\ 5\1e\1e\ 5\85\1e\ 4\1e\ 6\86\1e\1e      \8a\1e\1e\ 5\84\1e " "\ 2\ 5\16\83\12\8f\16\12\16\83\ 6\ 6\16\86 \8a\v\8a\16\ 6\16\ 6\16\ 6\ e\ f\ e\ f\a\a\ 5\88\1e\ 5¤\1e\84\ 6\8e\a" "\ 2\ 6\85\12\ 6\ 6\ 5\85\ 6\8b\1e\ 6¤\1e\16\88\ 6\16\86\1e\16\16\12\85\16\84\12\12\1e¥"] #^^[2 4096 "\ 2\ 5«\a\a\ 6\84\a\ 6\86\a\ 6\ 6\a\a\ 6\ 6\ 5   \8a\12\86\ 5\86\a\a\ 6\ 6\ 5\84\ 6\83\ 5\a\83\ 5\ 5\a\87\ 5\83\ 6\84\ 5\8b" "\ 2\ 5\ 5\ 6\a\a\ 6\ 6\a\86\ 6\ 5\a   \8a\a\83\ 6\16\16\ 1¦\1e\ 1\1e\85\ 1\1e\1e\ 5«\12\ 4\ 5\83" 5 5 "\ 2\ 5É\1e\ 5\84\1e\1e\ 5\87\1e\ 5\1e\ 5\84\1e\1e\ 5 " "\ 2\ 5\89\1e\ 5\84\1e\1e\ 5¡\1e\ 5\84\1e\1e\ 5\87\1e\ 5\1e\ 5\84\1e\1e\ 5\8f\1e\ 5¨" "\ 2\ 5\91\1e\ 5\84\1e\1e\ 5Ã\1e\1e\ 6\83\12\89\v\94\1e\83" "\ 2\ 5\90\16\8a\1e\86\ 5Õ\1e\8b" "\ 2\r\ 5ÿ" 5 5 5 "\ 2\ 5í\12\12\ 5\91" "\ 2\17\ 5\9a\ e\ f\1e\83\ 5Ë\12\83
+\83\1e\8f" "\ 2\ 5\8d\1e\ 5\84\ 6\83\1e\8b\ 5\92\ 6\83\12\12\1e\89\ 5\92\ 6\ 6\1e\8c\ 5\8d\1e\ 5\83\1e\ 6\ 6\1e\8c" "\ 2\ 5´\ 6\ 6\a\ 6\87\a\88\ 6\a\a\ 6\8b\12\83\ 4\12\83\14\ 5\ 6\1e\1e       \8a\1e\86\v\8a\1e\86" "\ 2\12\86\r\12\84\ 6\83\e\1e     \8a\1e\86\ 5£\ 4\ 5´\1e\88" "\ 2\ 5©\ 6\ 5\1e\85\ 5Æ\1e\8a" "\ 2\ 5\9d\1e\83\ 6\83\a\84\ 6\ 6\a\83\1e\84\a\a\ 6\a\86\ 6\83\1e\84\16\1e\83\12\12     \8a\ 5\9e\1e\1e\ 5\85\1e\8b" "\ 2\ 5¬\1e\84\a\91\ 5\87\a\a\1e\86      \8a\v\1e\83\16¢" "\ 2\ 5\97\ 6\ 6\a\a\ 6\1e\1e\12\12\ 5µ\a\ 6\a\ 6\87\1e\ 6\a\ 6\a\a\ 6\88\a\86\ 6\8a\1e\1e\ 6" "\ 2        \8a\1e\86   \8a\1e\86\12\87\ 4\12\86\1eÒ" "\ 2\ 6\84\a\ 5¯\ 6\a\ 6\85\a\ 6\a\85\ 6\a\a\ 5\87\1e\84   \8a\12\87\16\8a\ 6\89\16\89\1e\83" "\ 2\ 6\ 6\a\ 5\9e\a\ 6\84\a\a\ 6\ 6\a\ 6\a\a\ 5\ 5       \8a\ 5¬\ 6\a\ 6\ 6\a\83\ 6\a\ 6\83\a\a\1e\88\12\84" "\ 2\ 5¤\a\88\ 6\88\a\a\ 6\ 6\1e\83\12\85        \8a\1e\83\ 5\83        \8a\ 5\9e\ 4\86\12\12" "\ 2\1eÀ\12\88\1e\88\ 6\83\12\ 6\8d\a\ 6\87\ 5\84\ 6\ 5\84\a\a\ 6\ 5\ 5\1e\89" "\ 2\ 2¬\ 4¿\ 2\8d\ 4\ 2\87" "\ 2\ 2\9b\ 4¥\ 6§\1e\95\ 6\84" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\89\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2" "\ 2\ 2\88\ 1\88\ 2\86\1e\1e\ 1\86\1e\1e\ 2\88\ 1\88\ 2\88\ 1\88\ 2\86\1e\1e\ 1\86\1e\1e\ 2\88\1e\ 1\1e\ 1\1e\ 1\1e\ 1\ 2\88\ 1\88\ 2\8e\1e\1e" "\ 2\ 2\88\ 3\88\ 2\88\ 3\88\ 2\88\ 3\88\ 2\85\1e\ 2\ 2\ 1\84\ 3\15\ 2\15\83\ 2\83\1e\ 2\ 2\ 1\84\ 3\15\83\ 2\84\1e\1e\ 2\ 2\ 1\84\1e\15\83\ 2\88\ 1\85\15\83\1e\1e\ 2\83\1e\ 2\ 2\ 1\84\ 3\15\15\1e"] #^^[2 8192 "\ 2\17\8b\e\85\r\86\12\12\10\11\ e\10\10\11\ e\10\12\88\18\19\e\85\17\12\89\10\11\12\84\f\f\12\83\13\ e\ f\12\8b\13\12\f\12\8a\17\e\85\1e\e\8a\v\ 4\1e\1e\v\86\13\83\ e\ f\ 4" "\ 2\v\8a\13\83\ e\ f\1e\ 4\8d\1e\83\14\9b\1e\95\ 6\8d\b\84\ 6\b\83\ 6\8c\1e\8f" "\ 2\16\16\ 1\16\84\ 1\16\16\ 2\ 1\83\ 2\ 2\ 1\83\ 2\16\ 1\16\16\13\ 1\85\16\86\ 1\16\ 1\16\ 1\16\ 1\84\16\ 2\ 1\84\ 2\ 5\84\ 2\16\16\ 2\ 2\ 1\ 1\13\85\ 1\ 2\84\16\13\16\16\ 2\16\v\90
  " "\ 2
 \83\ 1\ 2
-\84\v\1e\86\13\85\16\85\13\13\16\84\13\16\16\13\16\16\13\16\87\13\16\9f\13\13\16\16\13\16\13\16\9f\13\8c" 19 19 "\ 2\16\88\13\84\16\94\13\13\16\87\ e\ f\16Ñ\13\16\83" "\ 2\16\9b\13\99\16¨\13\86\16\92\1e\8c" "\ 2\16§\1e\99\16\8b\1e\95\v " "\ 2\v\9c\16Î\v\96" 22 "\ 2\16·\13\16\89\13\16\13\88" "\ 2\16ï\13\16\90" 22 "\ 2\1e\16ç\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\v\8a" "\ 2\v\94\16¬\13\85\ e\ f\13\9f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\13\90" 22 22 19 "\ 2\13\83\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\13¿\ e\ f\ e\ f\13 \ e\ f\13\13" 19 19 "\ 2\16°\13\95\16\16\13\86\1e\83\16\8a\1e¦" 30 "\ 2\ 1¯\1e\ 2¯\1e\ 1\ 2\ 1\83\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\84\ 2\ 1\ 2\ 2\ 1\ 2\86\ 4\ 4\ 1\ 1" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\16\86\ 1\ 2\ 1\ 2\ 6\83\ 1\ 2\1e\85\12\84\v\12\12" "\ 2\ 2¦\1e\ 2\1e\85\ 2\1e\1e\ 5¸\1e\87\ 4\12\1e\8e\ 6" "\ 2\ 5\97\1e\89\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 6 " "\ 2\12\12\10\11\10\11\12\83\10\11\12\10\11\12\89\r\12\12\r\12\10\11\12\12\10\11\ e\ f\ e\ f\ e\ f\ e\ f\12\85\ 4\12\8a\r\r\1eÄ" "\ 2\16\9a\1e\16Ù\1e\8c" 22 "\ 2\16Ö\1e\9a\16\8c\1e\84"] #^^[2 12288 "\ 2\17\12\83\16\ 4\ 5
+\84\v\1e\86\13\85\16\85\13\13\16\84\13\16\16\13\16\16\13\16\87\13\16\9f\13\13\16\16\13\16\13\16\9f\13\8c" 19 19 "\ 2\16\88\ e\ f\ e\ f\16\94\13\13\16\87\ e\ f\16Ñ\13\16\83" "\ 2\16\9b\13\99\16¨\13\86\16\92\1e\8c" "\ 2\16§\1e\99\16\8b\1e\95\v " "\ 2\v\9c\16Î\v\96" 22 "\ 2\16·\13\16\89\13\16\13\88" "\ 2\16ï\13\16\90" 22 "\ 2\1e\16ç\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\v\8a" "\ 2\v\94\16¬\13\85\ e\ f\13\9f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\13\90" 22 22 19 "\ 2\13\83\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\13¿\ e\ f\ e\ f\13 \ e\ f\13\13" 19 19 "\ 2\16°\13\95\16\16\13\86\1e\83\16\8a\1e¦" 30 "\ 2\ 1¯\1e\ 2¯\1e\ 1\ 2\ 1\83\ 2\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\84\ 2\ 1\ 2\ 2\ 1\ 2\86\ 4\ 4\ 1\ 1" "\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 1\ 2\ 2\16\86\ 1\ 2\ 1\ 2\ 6\83\ 1\ 2\1e\85\12\84\v\12\12" "\ 2\ 2¦\1e\ 2\1e\85\ 2\1e\1e\ 5¸\1e\87\ 4\12\1e\8e\ 6" "\ 2\ 5\97\1e\89\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 5\87\1e\ 6 " "\ 2\12\12\10\11\10\11\12\83\10\11\12\10\11\12\89\r\12\12\r\12\10\11\12\12\10\11\ e\ f\ e\ f\ e\ f\ e\ f\12\85\ 4\12\8a\r\r\1eÄ" "\ 2\16\9a\1e\16Ù\1e\8c" 22 "\ 2\16Ö\1e\9a\16\8c\1e\84"] #^^[2 12288 "\ 2\17\12\83\16\ 4\ 5
 \ e\ f\ e\ f\ e\ f\ e\ f\ e\ f\16\16\ e\ f\ e\ f\ e\ f\ e\ f\r\ e\ f\ f\16
 \89\ 6\84\a\a\r\ 4\85\16\16
 \83\ 4\ 5\12\16\16\1e\ 5¿" "\ 2\ 5\97\1e\1e\ 6\ 6\15\15\ 4\ 4\ 5\r\ 5Ú\12\ 4\83\ 5" "\ 2\1e\85\ 5©\1e\83\ 5Ï" "\ 2\ 5\8f\1e\16\16\v\84\16\8a\ 5\9b\1e\85\16¤\1e\8c\ 5\90" "\ 2\16\9f\1e\v\8a\16\9e\v\88\16\v\8f\16 " "\ 2\v\8a\16§\v\8f\16¿\1e" 22 22 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5] #^^[2 16384 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 "\ 2\ 5\1e\8a\16À" 5 5 5 5] 5 5 5 5 #^^[2 36864 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 
 #^^[3 177920 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 30 30 30 30 30 30 30 30 30 30 30 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5] 5 
 #^^[3 178176 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30] 30 30 30 #^^[2 192512 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 5 5 5 5 "\ 2\ 5\9e\1eâ" 30 30 30 30 30 30 30 30 30 30 30]] 30 30 30 30 30 30 30 30 30 30 30 #^^[1 917504 #^^[2 917504 "\ 2\1e\e\1e\9e\eà" 30 6 "\ 2\ 6ð\1e\90" 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30] #^^[1 983040 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #^^[2 1044480 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 
 #^^[3 1048448 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 30 30]]] #^^[1 1048576 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 #^^[2 1110016 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 
-#^^[3 1113984 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 30 30]]] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 general-category 0 1 #[(val) "\b\301\236A\207" [val ((nil . "Uknown") (Lu . "Letter, Uppercase") (Ll . "Letter, Lowercase") (Lt . "Letter, Titlecase") (Lm . "Letter, Modifier") (Lo . "Letter, Other") (Mn . "Mark, Nonspacing") (Mc . "Mark, Spacing Combining") (Me . "Mark, Enclosing") (Nd . "Number, Decimal Digit") (Nl . "Number, Letter") (No . "Number, Other") (Pc . "Punctuation, Connector") (Pd . "Punctuation, Dash") (Ps . "Punctuation, Open") (Pe . "Punctuation, Close") (Pi . "Punctuation, Initial quote") (Pf . "Punctuation, Final quote") (Po . "Punctuation, Other") (Sm . "Symbol, Math") (Sc . "Symbol, Currency") (Sk . "Symbol, Modifier") (So . "Symbol, Other") (Zs . "Separator, Space") (Zl . "Separator, Line") (Zp . "Separator, Paragraph") (Cc . "Other, Control") (Cf . "Other, Format") (Cs . "Other, Surrogate") (Co . "Other, Private Use") (Cn . "Other, Not Assigned"))] 2] [nil Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po Sm Sc Sk So Zs Zl Zp Cc Cf Cs Co Cn]] "Unicode general category.
+#^^[3 1113984 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 30 30]]] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 general-category 0 1 #[(val) "\b\301\236A\207" [val ((nil . "Uknown") (Lu . "Letter, Uppercase") (Ll . "Letter, Lowercase") (Lt . "Letter, Titlecase") (Lm . "Letter, Modifier") (Lo . "Letter, Other") (Mn . "Mark, Nonspacing") (Mc . "Mark, Spacing Combining") (Me . "Mark, Enclosing") (Nd . "Number, Decimal Digit") (Nl . "Number, Letter") (No . "Number, Other") (Pc . "Punctuation, Connector") (Pd . "Punctuation, Dash") (Ps . "Punctuation, Open") (Pe . "Punctuation, Close") (Pi . "Punctuation, Initial quote") (Pf . "Punctuation, Final quote") (Po . "Punctuation, Other") (Sm . "Symbol, Math") (Sc . "Symbol, Currency") (Sk . "Symbol, Modifier") (So . "Symbol, Other") (Zs . "Separator, Space") (Zl . "Separator, Line") (Zp . "Separator, Paragraph") (Cc . "Other, Control") (Cf . "Other, Format") (Cs . "Other, Surrogate") (Co . "Other, Private Use") (Cn . "Other, Not Assigned"))] 2] [nil Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po Sm Sc Sk So Zs Zl Zp Cc Cf Cs Co Cn]]
+  "Unicode general category.
 Property value is one of the following symbols:
   Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No, Pc, Pd, Ps, Pe, Pi, Pf, Po,
   Sm, Sc, Sk, So, Zs, Zl, Zp, Cc, Cf, Cs, Co, Cn")
 ;; Local Variables:
 ;; coding: utf-8
+;; version-control: never
 ;; no-byte-compile: t
 ;; End:
 
index 3863f95f8812ff13d952f3e335bd2ae98a9c65d8..a98d8fbd8de48db0a6c3d5221a4ebc8941381840 100644 (file)
@@ -1,8 +1,9 @@
-;; Copyright (C) 1991-2009 Unicode, Inc.
+;; Copyright (C) 1991-2013 Unicode, Inc.
 ;; This file was generated from the Unicode data files at
 ;; http://www.unicode.org/Public/UNIDATA/.
 ;; See lisp/international/README for the copyright and permission notice.
-(define-char-code-property 'canonical-combining-class #^[1 nil char-code-property-table 1 #^^[1 0 #^^[2 0 1 1 1 1 1 1 "\ 2\ 2\95\ 3\ 4\84\ 3\ 5\ 4\85\ 6\ 6\ 4\84\ 6\ 6\ 4\8b\a\85\ 4\84\ 2\88\b\ 2\ 4\83\ 2\83\ 4\ 4\ 1\ 2\83\ 4\84\ 2\ 3\ 4\ 4\ 2  
+(define-char-code-property 'canonical-combining-class
+  #^[1 nil char-code-property-table 1 #^^[1 0 #^^[2 0 1 1 1 1 1 1 "\ 2\ 2\95\ 3\ 4\84\ 3\ 5\ 4\85\ 6\ 6\ 4\84\ 6\ 6\ 4\8b\a\85\ 4\84\ 2\88\b\ 2\ 4\83\ 2\83\ 4\ 4\ 1\ 2\83\ 4\84\ 2\ 3\ 4\ 4\ 2      
 
        
 
 #^^[3 177920 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 
 #^^[3 178176 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 #^^[2 192512 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]] 1 1 1 1 1 1 1 1 1 1 1 #^^[1 917504 #^^[2 917504 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] #^^[1 983040 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #^^[2 1044480 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
 #^^[3 1048448 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] #^^[1 1048576 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 #^^[2 1110016 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
-#^^[3 1113984 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 canonical-combining-class 0 1 #[(val) "\b\301\236A\207" [val ((0 . "Spacing, split, enclosing, reordrant, and Tibetan subjoined") (1 . "Overlays and interior") (7 . "Nuktas") (8 . "Hiragana/Katakana voicing marks") (9 . "Viramas") (10 . "Start of fixed position classes") (199 . "End of fixed position classes") (200 . "Below left attached") (202 . "Below attached") (204 . "Below right attached") (208 . "Left attached (reordrant around single base character)") (210 . "Right attached") (212 . "Above left attached") (214 . "Above attached") (216 . "Above right attached") (218 . "Below left") (220 . "Below") (222 . "Below right") (224 . "Left (reordrant around single base character)") (226 . "Right") (228 . "Above left") (230 . "Above") (232 . "Above right") (233 . "Double below") (234 . "Double above") (240 . "Below (iota subscript)"))] 2] [nil 0 230 232 220 216 202 1 240 233 234 222 228 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 30 31 32 27 28 29 33 34 35 36 7 9 84 91 103 107 118 122 129 130 132 214 218 224 8 26 226]] "Unicode canonical combining class.
+#^^[3 1113984 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 canonical-combining-class 0 1 #[(val) "\b\301\236A\207" [val ((0 . "Spacing, split, enclosing, reordrant, and Tibetan subjoined") (1 . "Overlays and interior") (7 . "Nuktas") (8 . "Hiragana/Katakana voicing marks") (9 . "Viramas") (10 . "Start of fixed position classes") (199 . "End of fixed position classes") (200 . "Below left attached") (202 . "Below attached") (204 . "Below right attached") (208 . "Left attached (reordrant around single base character)") (210 . "Right attached") (212 . "Above left attached") (214 . "Above attached") (216 . "Above right attached") (218 . "Below left") (220 . "Below") (222 . "Below right") (224 . "Left (reordrant around single base character)") (226 . "Right") (228 . "Above left") (230 . "Above") (232 . "Above right") (233 . "Double below") (234 . "Double above") (240 . "Below (iota subscript)"))] 2] [nil 0 230 232 220 216 202 1 240 233 234 222 228 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 30 31 32 27 28 29 33 34 35 36 7 9 84 91 103 107 118 122 129 130 132 214 218 224 8 26 226]]
+  "Unicode canonical combining class.
 Property value is an integer.")
 ;; Local Variables:
 ;; coding: utf-8
+;; version-control: never
 ;; no-byte-compile: t
 ;; End:
 
index c9743064bd4751703bdd5e1a27e84305743e0f5f..ca1a4be2195a3598756f72a77b660467a5b24285 100644 (file)
Binary files a/lisp/international/uni-comment.el and b/lisp/international/uni-comment.el differ
index 1866e7c4354b26ccc45d8beeb3674cd806f67a57..d135ea1f93d32c1f1fee6c8f7b9f535c410ed490 100644 (file)
Binary files a/lisp/international/uni-decimal.el and b/lisp/international/uni-decimal.el differ
index 2bcca9e60fbc02a70ccf0440caf13c590ba19f5d..0c7dd10b4253bf4b8868eed0ab42a068148434d6 100644 (file)
Binary files a/lisp/international/uni-decomposition.el and b/lisp/international/uni-decomposition.el differ
index 405d59784a779b9a0ee1eafe3848aac3e3fde0f4..d4e06c6242c1a3607610fd2763bf731ec5e40018 100644 (file)
Binary files a/lisp/international/uni-digit.el and b/lisp/international/uni-digit.el differ
index 811964991506e75ebc63bef038cd0ae4ec325c2c..5ddac66707e38a59b7a88d31b3ef83976b54ed9f 100644 (file)
Binary files a/lisp/international/uni-lowercase.el and b/lisp/international/uni-lowercase.el differ
index c34184c0d6b2eaedb49e1110c24f938cf3c163ca..b7ebdbb729f8f8651de72eb7071ce55d4b97871b 100644 (file)
Binary files a/lisp/international/uni-mirrored.el and b/lisp/international/uni-mirrored.el differ
index cf37db39b4840b942bd3708415849db9565a9576..3444ba9db64b860b789002b6dac7e87fc50cf9d5 100644 (file)
Binary files a/lisp/international/uni-name.el and b/lisp/international/uni-name.el differ
index 7c0be5b438a70b1d90b689bd1886123d7974480a..9d88cf4ec89974c3a522cb92097b0030e08bffe7 100644 (file)
Binary files a/lisp/international/uni-numeric.el and b/lisp/international/uni-numeric.el differ
index 6165eba61cc10d6443bb26c7ea9bacc223b95fde..efc15c76a7a3b5b55d810060a720949bab90c628 100644 (file)
Binary files a/lisp/international/uni-old-name.el and b/lisp/international/uni-old-name.el differ
index e3454a4dd3d4f2fcfbb0a0b93c7f85fe3f9e1f81..2772457701765a34062f94b293bb7cace471bd70 100644 (file)
Binary files a/lisp/international/uni-titlecase.el and b/lisp/international/uni-titlecase.el differ
index 85112406d757b255b236d6e5b01eebf93f2dd9f7..9ce518abb5ec4edde6baf620eef50373454c1b6e 100644 (file)
Binary files a/lisp/international/uni-uppercase.el and b/lisp/international/uni-uppercase.el differ
index 07873db38e10358aa1c64d7dacba479279674a83..796420a2ede41ae9254473d23c68c2d370457947 100644 (file)
@@ -1427,6 +1427,8 @@ between buffers using substrings.  See `iswitchb' for details."
       (add-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)
     (remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))
 
+(make-obsolete 'iswitchb-mode 'icomplete-mode "24.4")
+
 (provide 'iswitchb)
 
 ;;; iswitchb.el ends here
index f0a08998d968c481eec3796ad1126eb53e4d5a10..64c3d565e9818deb8b318c670cca665079b7c1d9 100644 (file)
@@ -483,6 +483,7 @@ A replacement function for `newline-and-indent', aligning as it goes.
 ;;;### (autoloads nil "allout" "allout.el" (20996 49577 892030 0))
 ;;; Generated autoloads from allout.el
 (push (purecopy '(allout 2 3)) package--builtin-versions)
+
 (autoload 'allout-auto-activation-helper "allout" "\
 Institute `allout-auto-activation'.
 
@@ -843,6 +844,7 @@ for details on preparing Emacs for automatic allout activation.
 ;;;;;;  49577 892030 0))
 ;;; Generated autoloads from allout-widgets.el
 (push (purecopy '(allout-widgets 1 0)) package--builtin-versions)
+
 (let ((loads (get 'allout-widgets 'custom-loads))) (if (member '"allout-widgets" loads) nil (put 'allout-widgets 'custom-loads (cons '"allout-widgets" loads))))
 
 (autoload 'allout-widgets-setup "allout-widgets" "\
@@ -954,10 +956,11 @@ the buffer *Birthday-Present-for-Name*.
 
 ;;;***
 \f
-;;;### (autoloads nil "ansi-color" "ansi-color.el" (20975 43430 521692
+;;;### (autoloads nil "ansi-color" "ansi-color.el" (21086 26537 509049
 ;;;;;;  0))
 ;;; Generated autoloads from ansi-color.el
 (push (purecopy '(ansi-color 3 4 2)) package--builtin-versions)
+
 (autoload 'ansi-color-for-comint-mode-on "ansi-color" "\
 Set `ansi-color-for-comint-mode' to t.
 
@@ -984,6 +987,7 @@ This is a good function to put in `comint-output-filter-functions'.
 ;;;;;;  34805 522289 827000))
 ;;; Generated autoloads from progmodes/antlr-mode.el
 (push (purecopy '(antlr-mode 2 2 3)) package--builtin-versions)
+
 (autoload 'antlr-show-makefile-rules "antlr-mode" "\
 Show Makefile rules for all grammar files in the current directory.
 If the `major-mode' of the current buffer has the value `makefile-mode',
@@ -1250,6 +1254,7 @@ Entering array mode calls the function `array-mode-hook'.
 ;;;;;;  893295 0))
 ;;; Generated autoloads from textmodes/artist.el
 (push (purecopy '(artist 1 2 6)) package--builtin-versions)
+
 (autoload 'artist-mode "artist" "\
 Toggle Artist mode.
 With argument ARG, turn Artist mode on if ARG is positive.
@@ -1603,8 +1608,8 @@ insert a template for the file depending on the mode of the buffer.
 
 ;;;***
 \f
-;;;### (autoloads nil "autoload" "emacs-lisp/autoload.el" (20974
-;;;;;;  22577 548213 0))
+;;;### (autoloads nil "autoload" "emacs-lisp/autoload.el" (21105
+;;;;;;  27518 41539 966000))
 ;;; Generated autoloads from emacs-lisp/autoload.el
 
 (put 'generated-autoload-file 'safe-local-variable 'stringp)
@@ -1801,7 +1806,7 @@ Run script using `bat-run' and `bat-run-args'.
 
 ;;;***
 \f
-;;;### (autoloads nil "battery" "battery.el" (20791 9657 561026 0))
+;;;### (autoloads nil "battery" "battery.el" (21096 9821 480125 690000))
 ;;; Generated autoloads from battery.el
  (put 'battery-mode-line-string 'risky-local-variable t)
 
@@ -2634,6 +2639,7 @@ from `browse-url-elinks-wrapper'.
 ;;;### (autoloads nil "bs" "bs.el" (20992 52525 458637 0))
 ;;; Generated autoloads from bs.el
 (push (purecopy '(bs 1 17)) package--builtin-versions)
+
 (autoload 'bs-cycle-next "bs" "\
 Select next buffer defined by buffer cycling.
 The buffers taking part in buffer cycling are defined
@@ -2714,8 +2720,8 @@ Like `bug-reference-mode', but only buttonize in comments and strings.
 
 ;;;***
 \f
-;;;### (autoloads nil "bytecomp" "emacs-lisp/bytecomp.el" (21024
-;;;;;;  55496 462544 366000))
+;;;### (autoloads nil "bytecomp" "emacs-lisp/bytecomp.el" (21104
+;;;;;;  56491 538513 0))
 ;;; Generated autoloads from emacs-lisp/bytecomp.el
 (put 'byte-compile-dynamic 'safe-local-variable 'booleanp)
 (put 'byte-compile-disable-print-circle 'safe-local-variable 'booleanp)
@@ -3088,8 +3094,8 @@ Obsoletes `c-forward-into-nomenclature'.
 
 ;;;***
 \f
-;;;### (autoloads nil "cc-engine" "progmodes/cc-engine.el" (21063
-;;;;;;  65063 266334 0))
+;;;### (autoloads nil "cc-engine" "progmodes/cc-engine.el" (21102
+;;;;;;  14759 136845 0))
 ;;; Generated autoloads from progmodes/cc-engine.el
 
 (autoload 'c-guess-basic-syntax "cc-engine" "\
@@ -3678,8 +3684,8 @@ See the documentation of `define-ccl-program' for the detail of CCL program.
 
 ;;;***
 \f
-;;;### (autoloads nil "cconv" "emacs-lisp/cconv.el" (21032 23080
-;;;;;;  765139 0))
+;;;### (autoloads nil "cconv" "emacs-lisp/cconv.el" (21069 17449
+;;;;;;  167398 0))
 ;;; Generated autoloads from emacs-lisp/cconv.el
 
 (autoload 'cconv-closure-convert "cconv" "\
@@ -3702,12 +3708,14 @@ Add the warnings that closure conversion would encounter.
 ;;;;;;  0))
 ;;; Generated autoloads from cedet/cedet.el
 (push (purecopy '(cedet 2 0)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "cfengine" "progmodes/cfengine.el" (20958 34345
 ;;;;;;  952538 0))
 ;;; Generated autoloads from progmodes/cfengine.el
 (push (purecopy '(cfengine 1 2)) package--builtin-versions)
+
 (autoload 'cfengine3-mode "cfengine" "\
 Major mode for editing CFEngine3 input.
 There are no special keybindings by default.
@@ -3738,6 +3746,7 @@ on the buffer contents
 ;;;;;;  391345 0))
 ;;; Generated autoloads from emacs-lisp/chart.el
 (push (purecopy '(chart 0 2)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "check-declare" "emacs-lisp/check-declare.el"
@@ -3761,7 +3770,8 @@ Returns non-nil if any false statements are found.
 ;;;### (autoloads nil "checkdoc" "emacs-lisp/checkdoc.el" (20996
 ;;;;;;  49577 892030 0))
 ;;; Generated autoloads from emacs-lisp/checkdoc.el
-(push (purecopy '(checkdoc 0 6 2)) package--builtin-versions)(put 'checkdoc-force-docstrings-flag 'safe-local-variable #'booleanp)
+(push (purecopy '(checkdoc 0 6 2)) package--builtin-versions)
+(put 'checkdoc-force-docstrings-flag 'safe-local-variable #'booleanp)
 (put 'checkdoc-force-history-flag 'safe-local-variable #'booleanp)
 (put 'checkdoc-permit-comma-termination-flag 'safe-local-variable #'booleanp)
 (put 'checkdoc-spellcheck-documentation-flag 'safe-local-variable #'booleanp)
@@ -4119,6 +4129,7 @@ For example, the function `case' has an indent property
 ;;;;;;  952905 0))
 ;;; Generated autoloads from emacs-lisp/cl-lib.el
 (push (purecopy '(cl-lib 1 0)) package--builtin-versions)
+
 (define-obsolete-variable-alias 'custom-print-functions 'cl-custom-print-functions "24.3")
 
 (defvar cl-custom-print-functions nil "\
@@ -4145,8 +4156,8 @@ a future Emacs interpreter will be able to use it.")
 
 ;;;***
 \f
-;;;### (autoloads nil "cmacexp" "progmodes/cmacexp.el" (20709 26818
-;;;;;;  907104 0))
+;;;### (autoloads nil "cmacexp" "progmodes/cmacexp.el" (21082 29482
+;;;;;;  330637 0))
 ;;; Generated autoloads from progmodes/cmacexp.el
 
 (autoload 'c-macro-expand "cmacexp" "\
@@ -4206,7 +4217,7 @@ If FRAME cannot display COLOR, return nil.
 
 ;;;***
 \f
-;;;### (autoloads nil "comint" "comint.el" (21040 17194 398147 0))
+;;;### (autoloads nil "comint" "comint.el" (21104 56491 538513 0))
 ;;; Generated autoloads from comint.el
 
 (defvar comint-output-filter-functions '(ansi-color-process-output comint-postoutput-scroll-to-bottom comint-watch-for-password-prompt) "\
@@ -4339,8 +4350,8 @@ on third call it again advances points to the next difference and so on.
 
 ;;;***
 \f
-;;;### (autoloads nil "compile" "progmodes/compile.el" (21002 1963
-;;;;;;  769129 0))
+;;;### (autoloads nil "compile" "progmodes/compile.el" (21096 1265
+;;;;;;  644069 0))
 ;;; Generated autoloads from progmodes/compile.el
 
 (defvar compilation-mode-hook nil "\
@@ -5049,8 +5060,8 @@ INHERIT-INPUT-METHOD.
 
 ;;;***
 \f
-;;;### (autoloads nil "css-mode" "textmodes/css-mode.el" (21024 28968
-;;;;;;  738399 0))
+;;;### (autoloads nil "css-mode" "textmodes/css-mode.el" (21075 56234
+;;;;;;  349623 0))
 ;;; Generated autoloads from textmodes/css-mode.el
 
 (autoload 'css-mode "css-mode" "\
@@ -5472,6 +5483,7 @@ Mode used for cvs status output.
 ;;;;;;  0))
 ;;; Generated autoloads from progmodes/cwarn.el
 (push (purecopy '(cwarn 1 3 1)) package--builtin-versions)
+
 (autoload 'cwarn-mode "cwarn" "\
 Minor mode that highlights suspicious C and C++ constructions.
 
@@ -5816,6 +5828,7 @@ The most useful commands are:
 ;;;;;;  0))
 ;;; Generated autoloads from delim-col.el
 (push (purecopy '(delim-col 2 1)) package--builtin-versions)
+
 (autoload 'delimit-columns-customize "delim-col" "\
 Customization of `columns' group.
 
@@ -5837,7 +5850,7 @@ START and END delimits the corners of text rectangle.
 
 ;;;***
 \f
-;;;### (autoloads nil "delsel" "delsel.el" (20709 26818 907104 0))
+;;;### (autoloads nil "delsel" "delsel.el" (21104 56491 538513 0))
 ;;; Generated autoloads from delsel.el
 
 (defalias 'pending-delete-mode 'delete-selection-mode)
@@ -5968,7 +5981,7 @@ relevant to POS.
 
 ;;;***
 \f
-;;;### (autoloads nil "desktop" "desktop.el" (21005 64551 555603
+;;;### (autoloads nil "desktop" "desktop.el" (21082 29482 330637
 ;;;;;;  0))
 ;;; Generated autoloads from desktop.el
 
@@ -6327,7 +6340,7 @@ Optional arguments are passed to `dig-invoke'.
 
 ;;;***
 \f
-;;;### (autoloads nil "dired" "dired.el" (21044 14392 310114 433000))
+;;;### (autoloads nil "dired" "dired.el" (21105 26139 752484 0))
 ;;; Generated autoloads from dired.el
 
 (defvar dired-listing-switches (purecopy "-al") "\
@@ -6759,6 +6772,7 @@ strings when pressed twice.  See `double-map' for details.
 ;;;;;;  0))
 ;;; Generated autoloads from play/dunnet.el
 (push (purecopy '(dunnet 2 1)) package--builtin-versions)
+
 (autoload 'dunnet "dunnet" "\
 Switch to *dungeon* buffer and start game.
 
@@ -6906,8 +6920,8 @@ CSS contains a list of syntax specifications of the form (CHAR . SYNTAX).
 
 ;;;***
 \f
-;;;### (autoloads nil "easymenu" "emacs-lisp/easymenu.el" (20709
-;;;;;;  26818 907104 0))
+;;;### (autoloads nil "easymenu" "emacs-lisp/easymenu.el" (21074
+;;;;;;  35375 473679 0))
 ;;; Generated autoloads from emacs-lisp/easymenu.el
 
 (autoload 'easy-menu-define "easymenu" "\
@@ -7045,10 +7059,11 @@ To implement dynamic menus, either call this from
 
 ;;;***
 \f
-;;;### (autoloads nil "ebnf2ps" "progmodes/ebnf2ps.el" (20709 26818
-;;;;;;  907104 0))
+;;;### (autoloads nil "ebnf2ps" "progmodes/ebnf2ps.el" (21093 51745
+;;;;;;  752738 587000))
 ;;; Generated autoloads from progmodes/ebnf2ps.el
 (push (purecopy '(ebnf2ps 4 4)) package--builtin-versions)
+
 (autoload 'ebnf-customize "ebnf2ps" "\
 Customization for ebnf group.
 
@@ -7518,6 +7533,7 @@ With prefix arg NOCONFIRM, execute current line as-is without editing.
 ;;;### (autoloads nil "ede" "cedet/ede.el" (20908 27948 216644 0))
 ;;; Generated autoloads from cedet/ede.el
 (push (purecopy '(ede 1 2)) package--builtin-versions)
+
 (defvar global-ede-mode nil "\
 Non-nil if Global-Ede mode is enabled.
 See the command `global-ede-mode' for a description of this minor mode.
@@ -7544,12 +7560,14 @@ an EDE controlled project.
 ;;;;;;  907104 0))
 ;;; Generated autoloads from cedet/ede/dired.el
 (push (purecopy '(dired 0 4)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "ede/project-am" "cedet/ede/project-am.el"
 ;;;;;;  (20881 10343 547564 552000))
 ;;; Generated autoloads from cedet/ede/project-am.el
 (push (purecopy '(project-am 0 0 3)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "edebug" "emacs-lisp/edebug.el" (20996 49577
@@ -7620,6 +7638,7 @@ Toggle edebugging of all forms.
 ;;;### (autoloads nil "ediff" "vc/ediff.el" (21041 38058 75002 0))
 ;;; Generated autoloads from vc/ediff.el
 (push (purecopy '(ediff 2 81 4)) package--builtin-versions)
+
 (autoload 'ediff-files "ediff" "\
 Run Ediff on a pair of files, FILE-A and FILE-B.
 
@@ -7936,6 +7955,7 @@ To change the default, set the variable `ediff-use-toolbar-p', which see.
 ;;;;;;  446000))
 ;;; Generated autoloads from edmacro.el
 (push (purecopy '(edmacro 2 1)) package--builtin-versions)
+
 (autoload 'edit-kbd-macro "edmacro" "\
 Edit a keyboard macro.
 At the prompt, type any key sequence which is bound to a keyboard macro.
@@ -8039,12 +8059,14 @@ BUFFER is put back into its original major mode.
 ;;;;;;  730130 282000))
 ;;; Generated autoloads from emacs-lisp/eieio.el
 (push (purecopy '(eieio 1 4)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "eieio-core" "emacs-lisp/eieio-core.el" (20908
 ;;;;;;  27948 216644 0))
 ;;; Generated autoloads from emacs-lisp/eieio-core.el
 (push (purecopy '(eieio-core 1 4)) package--builtin-versions)
+
 (autoload 'eieio-defclass-autoload "eieio-core" "\
 Create autoload symbols for the EIEIO class CNAME.
 SUPERCLASSES are the superclasses that CNAME inherits from.
@@ -8159,7 +8181,7 @@ Emacs Lisp mode) that support ElDoc.")
 
 ;;;***
 \f
-;;;### (autoloads nil "electric" "electric.el" (21056 5418 85093
+;;;### (autoloads nil "electric" "electric.el" (21075 56234 349623
 ;;;;;;  0))
 ;;; Generated autoloads from electric.el
 
@@ -8658,7 +8680,7 @@ Encrypt marked files.
 
 ;;;***
 \f
-;;;### (autoloads nil "epa-file" "epa-file.el" (20709 26818 907104
+;;;### (autoloads nil "epa-file" "epa-file.el" (21102 14759 136845
 ;;;;;;  0))
 ;;; Generated autoloads from epa-file.el
 
@@ -8757,9 +8779,10 @@ if ARG is omitted or nil.
 
 ;;;***
 \f
-;;;### (autoloads nil "epg" "epg.el" (21034 64808 616539 0))
+;;;### (autoloads nil "epg" "epg.el" (21069 17449 167398 0))
 ;;; Generated autoloads from epg.el
 (push (purecopy '(epg 1 0 0)) package--builtin-versions)
+
 (autoload 'epg-make-context "epg" "\
 Return a context object.
 
@@ -8791,6 +8814,7 @@ Look at CONFIG and try to expand GROUP.
 ;;;### (autoloads nil "erc" "erc/erc.el" (21053 29224 547064 0))
 ;;; Generated autoloads from erc/erc.el
 (push (purecopy '(erc 5 3)) package--builtin-versions)
+
 (autoload 'erc-select-read-args "erc" "\
 Prompt the user for values of nick, server, port, and password.
 
@@ -9021,12 +9045,14 @@ system.
 ;;;;;;  0))
 ;;; Generated autoloads from erc/erc-lang.el
 (push (purecopy '(erc-lang 1 0 0)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "erc-list" "erc/erc-list.el" (21050 53033 774595
 ;;;;;;  0))
 ;;; Generated autoloads from erc/erc-list.el
-(push (purecopy '(erc-list 0 1)) package--builtin-versions) (autoload 'erc-list-mode "erc-list")
+(push (purecopy '(erc-list 0 1)) package--builtin-versions)
+ (autoload 'erc-list-mode "erc-list")
 
 ;;;***
 \f
@@ -9300,7 +9326,7 @@ Add a file to `erc-xdcc-files'.
 
 ;;;***
 \f
-;;;### (autoloads nil "ert" "emacs-lisp/ert.el" (21048 11307 937592
+;;;### (autoloads nil "ert" "emacs-lisp/ert.el" (21099 38568 469572
 ;;;;;;  0))
 ;;; Generated autoloads from emacs-lisp/ert.el
 
@@ -9310,8 +9336,8 @@ Define NAME (a symbol) as a test.
 BODY is evaluated as a `progn' when the test is run.  It should
 signal a condition on failure or just return if the test passes.
 
-`should', `should-not' and `should-error' are useful for
-assertions in BODY.
+`should', `should-not', `should-error' and `skip-unless' are
+useful for assertions in BODY.
 
 Use `ert' to run tests interactively.
 
@@ -9394,6 +9420,7 @@ Emacs shell interactive mode.
 ;;;;;;  0))
 ;;; Generated autoloads from eshell/eshell.el
 (push (purecopy '(eshell 2 4 2)) package--builtin-versions)
+
 (autoload 'eshell "eshell" "\
 Create an interactive Eshell buffer.
 The buffer used for Eshell sessions is determined by the value of
@@ -10048,7 +10075,7 @@ fourth arg NOSEP non-nil inhibits this.
 
 ;;;***
 \f
-;;;### (autoloads nil "eww" "net/eww.el" (21049 14338 391345 0))
+;;;### (autoloads nil "eww" "net/eww.el" (21086 26537 509049 0))
 ;;; Generated autoloads from net/eww.el
 
 (autoload 'eww "eww" "\
@@ -10229,7 +10256,7 @@ with no args, if that value is non-nil.
 
 ;;;***
 \f
-;;;### (autoloads nil "face-remap" "face-remap.el" (20928 40842 890989
+;;;### (autoloads nil "face-remap" "face-remap.el" (21082 29482 330637
 ;;;;;;  0))
 ;;; Generated autoloads from face-remap.el
 
@@ -10324,11 +10351,9 @@ key-binding used to invoke the command, with all modifiers removed:
    -      Decrease the default face height by one step
    0      Reset the default face height to the global default
 
-When adjusting with `+' or `-', continue to read input events and
-further adjust the face height as long as the input event read
-\(with all modifiers removed) is `+' or `-'.
-
-When adjusting with `0', immediately finish.
+After adjusting, continue to read input events and further adjust
+the face height as long as the input event read
+\(with all modifiers removed) is one of the above characters.
 
 Each step scales the height of the default face by the variable
 `text-scale-mode-step' (a negative number of steps decreases the
@@ -10395,6 +10420,7 @@ Besides the choice of face, it is the same as `buffer-face-mode'.
 ;;;;;;  0))
 ;;; Generated autoloads from mail/feedmail.el
 (push (purecopy '(feedmail 11)) package--builtin-versions)
+
 (autoload 'feedmail-send-it "feedmail" "\
 Send the current mail buffer using the Feedmail package.
 This is a suitable value for `send-mail-function'.  It can be used
@@ -10445,7 +10471,7 @@ you can set `feedmail-queue-reminder-alist' to nil.
 
 ;;;***
 \f
-;;;### (autoloads nil "ffap" "ffap.el" (20998 4934 952905 0))
+;;;### (autoloads nil "ffap" "ffap.el" (21090 23592 994673 0))
 ;;; Generated autoloads from ffap.el
 
 (autoload 'ffap-next "ffap" "\
@@ -10661,6 +10687,7 @@ Set up hooks, load the cache file -- if existing -- and build the menu.
 ;;;;;;  0))
 ;;; Generated autoloads from find-cmd.el
 (push (purecopy '(find-cmd 0 6)) package--builtin-versions)
+
 (autoload 'find-cmd "find-cmd" "\
 Initiate the building of a find command.
 For example:
@@ -10990,6 +11017,7 @@ Change the filter on a `find-lisp-find-dired' buffer to REGEXP.
 ;;;### (autoloads nil "finder" "finder.el" (21031 2230 839140 0))
 ;;; Generated autoloads from finder.el
 (push (purecopy '(finder 1 0)) package--builtin-versions)
+
 (autoload 'finder-list-keywords "finder" "\
 Display descriptions of the keywords in the Finder buffer.
 
@@ -11050,6 +11078,7 @@ to get the effect of a C-q.
 ;;;;;;  84796 0))
 ;;; Generated autoloads from progmodes/flymake.el
 (push (purecopy '(flymake 0 3)) package--builtin-versions)
+
 (autoload 'flymake-mode "flymake" "\
 Toggle on-the-fly syntax checking.
 With a prefix argument ARG, enable the mode if ARG is positive,
@@ -11150,6 +11179,7 @@ Flyspell whole buffer.
 ;;;;;;  0))
 ;;; Generated autoloads from foldout.el
 (push (purecopy '(foldout 1 10)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "follow" "follow.el" (21049 14338 391345 0))
@@ -11224,6 +11254,7 @@ selected if the original window is the first one in the frame.
 ;;;;;;  907104 0))
 ;;; Generated autoloads from mail/footnote.el
 (push (purecopy '(footnote 0 19)) package--builtin-versions)
+
 (autoload 'footnote-mode "footnote" "\
 Toggle Footnote mode.
 With a prefix argument ARG, enable Footnote mode if ARG is
@@ -11567,6 +11598,7 @@ Argument is a character, naming the register.
 ;;;;;;  124734 677000))
 ;;; Generated autoloads from play/gamegrid.el
 (push (purecopy '(gamegrid 1 2)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "gdb-mi" "progmodes/gdb-mi.el" (21042 58928
@@ -11800,7 +11832,8 @@ DEFAULT-MAP specifies the default key map for ICON-LIST.
 \f
 ;;;### (autoloads nil "gnus" "gnus/gnus.el" (21002 1963 769129 0))
 ;;; Generated autoloads from gnus/gnus.el
-(push (purecopy '(gnus 5 13)) package--builtin-versions)(when (fboundp 'custom-autoload)
+(push (purecopy '(gnus 5 13)) package--builtin-versions)
+(when (fboundp 'custom-autoload)
  (custom-autoload 'gnus-select-method "gnus"))
 
 (autoload 'gnus-slave-no-server "gnus" "\
@@ -12152,8 +12185,8 @@ If gravatars are already displayed, remove them.
 
 ;;;***
 \f
-;;;### (autoloads nil "gnus-group" "gnus/gnus-group.el" (21040 17194
-;;;;;;  398147 0))
+;;;### (autoloads nil "gnus-group" "gnus/gnus-group.el" (21104 56491
+;;;;;;  538513 0))
 ;;; Generated autoloads from gnus/gnus-group.el
 
 (autoload 'gnus-fetch-group "gnus-group" "\
@@ -13971,6 +14004,7 @@ See `highlight-changes-mode' for more information on Highlight-Changes mode.
 ;;;;;;  0))
 ;;; Generated autoloads from hippie-exp.el
 (push (purecopy '(hippie-exp 1 6)) package--builtin-versions)
+
 (defvar hippie-expand-try-functions-list '(try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-lisp-symbol-partially try-complete-lisp-symbol) "\
 The list of expansion functions tried in order by `hippie-expand'.
 To change the behavior of `hippie-expand', remove, change the order of,
@@ -14209,10 +14243,11 @@ Convert HTML to plain text in the current buffer.
 
 ;;;***
 \f
-;;;### (autoloads nil "htmlfontify" "htmlfontify.el" (20938 49065
-;;;;;;  383398 0))
+;;;### (autoloads nil "htmlfontify" "htmlfontify.el" (21105 28578
+;;;;;;  135432 0))
 ;;; Generated autoloads from htmlfontify.el
 (push (purecopy '(htmlfontify 0 21)) package--builtin-versions)
+
 (autoload 'htmlfontify-buffer "htmlfontify" "\
 Create a new buffer, named for the current buffer + a .html extension,
 containing an inline CSS-stylesheet and formatted CSS-markup HTML
@@ -14331,8 +14366,8 @@ bound to the current value of the filter.
 
 ;;;***
 \f
-;;;### (autoloads nil "ibuffer" "ibuffer.el" (21045 35440 130128
-;;;;;;  609000))
+;;;### (autoloads nil "ibuffer" "ibuffer.el" (21105 26139 752484
+;;;;;;  0))
 ;;; Generated autoloads from ibuffer.el
 
 (autoload 'ibuffer-list-buffers "ibuffer" "\
@@ -14371,10 +14406,11 @@ FORMATS is the value to use for `ibuffer-formats'.
 
 ;;;***
 \f
-;;;### (autoloads nil "icalendar" "calendar/icalendar.el" (20709
-;;;;;;  26818 907104 0))
+;;;### (autoloads nil "icalendar" "calendar/icalendar.el" (21077
+;;;;;;  65494 651556 676000))
 ;;; Generated autoloads from calendar/icalendar.el
 (push (purecopy '(icalendar 0 19)) package--builtin-versions)
+
 (autoload 'icalendar-export-file "icalendar" "\
 Export diary file to iCalendar format.
 All diary entries in the file DIARY-FILENAME are converted to iCalendar
@@ -14424,7 +14460,7 @@ buffer `*icalendar-errors*'.
 
 ;;;***
 \f
-;;;### (autoloads nil "icomplete" "icomplete.el" (21047 23047 743647
+;;;### (autoloads nil "icomplete" "icomplete.el" (21091 44456 774347
 ;;;;;;  0))
 ;;; Generated autoloads from icomplete.el
 
@@ -14518,6 +14554,7 @@ See also the variable `idlwave-shell-prompt-pattern'.
 ;;;;;;  117790 0))
 ;;; Generated autoloads from progmodes/idlwave.el
 (push (purecopy '(idlwave 6 1 22)) package--builtin-versions)
+
 (autoload 'idlwave-mode "idlwave" "\
 Major mode for editing IDL source files (version 6.1_em22).
 
@@ -14642,7 +14679,7 @@ The main features of this mode are
 
 ;;;***
 \f
-;;;### (autoloads nil "ido" "ido.el" (20996 49577 892030 0))
+;;;### (autoloads nil "ido" "ido.el" (21103 35626 321341 0))
 ;;; Generated autoloads from ido.el
 
 (defvar ido-mode nil "\
@@ -14901,12 +14938,13 @@ DEF, if non-nil, is the default value.
 
 ;;;***
 \f
-;;;### (autoloads nil "ielm" "ielm.el" (20903 10024 645978 0))
+;;;### (autoloads nil "ielm" "ielm.el" (21089 2732 351717 0))
 ;;; Generated autoloads from ielm.el
 
 (autoload 'ielm "ielm" "\
 Interactively evaluate Emacs Lisp expressions.
 Switches to the buffer `*ielm*', or creates it if it does not exist.
+See `inferior-emacs-lisp-mode' for details.
 
 \(fn)" t nil)
 
@@ -14928,7 +14966,7 @@ the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
 
 ;;;***
 \f
-;;;### (autoloads nil "image" "image.el" (21049 14338 391345 0))
+;;;### (autoloads nil "image" "image.el" (21107 32686 465643 0))
 ;;; Generated autoloads from image.el
 
 (autoload 'image-type-from-data "image" "\
@@ -15082,7 +15120,7 @@ Image files should not be larger than specified by `max-image-size'.
 \(fn SPECS)" nil nil)
 
 (autoload 'defimage "image" "\
-Define SYMBOL as an image.
+Define SYMBOL as an image, and return SYMBOL.
 
 SPECS is a list of image specifications.  DOC is an optional
 documentation string.
@@ -15125,6 +15163,7 @@ If Emacs is compiled without ImageMagick support, this does nothing.
 ;;;;;;  737658 0))
 ;;; Generated autoloads from image-dired.el
 (push (purecopy '(image-dired 0 4 11)) package--builtin-versions)
+
 (autoload 'image-dired-dired-toggle-marked-thumbs "image-dired" "\
 Toggle thumbnails in front of file names in the dired buffer.
 If no marked file could be found, insert or hide thumbnails on the
@@ -15538,8 +15577,8 @@ Convert old Emacs Devanagari characters to UCS.
 
 ;;;***
 \f
-;;;### (autoloads nil "inf-lisp" "progmodes/inf-lisp.el" (20774 53405
-;;;;;;  644725 888000))
+;;;### (autoloads nil "inf-lisp" "progmodes/inf-lisp.el" (21098 17703
+;;;;;;  588969 0))
 ;;; Generated autoloads from progmodes/inf-lisp.el
 
 (autoload 'inferior-lisp "inf-lisp" "\
@@ -15820,6 +15859,7 @@ Perform completion on file preceding point.
 ;;;;;;  0))
 ;;; Generated autoloads from info-xref.el
 (push (purecopy '(info-xref 3)) package--builtin-versions)
+
 (autoload 'info-xref-check "info-xref" "\
 Check external references in FILENAME, an info document.
 Interactively from an `Info-mode' or `texinfo-mode' buffer the
@@ -15949,6 +15989,7 @@ For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\"
 ;;;;;;  425822 0))
 ;;; Generated autoloads from cedet/inversion.el
 (push (purecopy '(inversion 1 3)) package--builtin-versions)
+
 (autoload 'inversion-require-emacs "inversion" "\
 Declare that you need either EMACS-VER, XEMACS-VER or SXEMACS-ver.
 Only checks one based on which kind of Emacs is being run.
@@ -15982,6 +16023,7 @@ Toggle input method in interactive search.
 ;;;;;;  0))
 ;;; Generated autoloads from isearchb.el
 (push (purecopy '(isearchb 1 5)) package--builtin-versions)
+
 (autoload 'isearchb-activate "isearchb" "\
 Active isearchb mode for subsequent alphanumeric keystrokes.
 Executing this command again will terminate the search; or, if
@@ -16456,6 +16498,7 @@ by `jka-compr-installed'.
 ;;;### (autoloads nil "js" "progmodes/js.el" (20998 4934 952905 0))
 ;;; Generated autoloads from progmodes/js.el
 (push (purecopy '(js 9)) package--builtin-versions)
+
 (autoload 'js-mode "js" "\
 Major mode for editing JavaScript.
 
@@ -16467,6 +16510,7 @@ Major mode for editing JavaScript.
 ;;;### (autoloads nil "json" "json.el" (20998 4934 952905 0))
 ;;; Generated autoloads from json.el
 (push (purecopy '(json 1 4)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "keypad" "emulation/keypad.el" (20709 26818
@@ -16863,9 +16907,10 @@ generations (this defaults to 1).
 
 ;;;***
 \f
-;;;### (autoloads nil "linum" "linum.el" (20709 26818 907104 0))
+;;;### (autoloads nil "linum" "linum.el" (21100 59431 520894 0))
 ;;; Generated autoloads from linum.el
 (push (purecopy '(linum 0 9 24)) package--builtin-versions)
+
 (autoload 'linum-mode "linum" "\
 Toggle display of line numbers in the left margin (Linum mode).
 With a prefix argument ARG, enable Linum mode if ARG is positive,
@@ -17026,7 +17071,7 @@ Major mode for browsing CVS log output.
 
 ;;;***
 \f
-;;;### (autoloads nil "lpr" "lpr.el" (20975 43430 521692 0))
+;;;### (autoloads nil "lpr" "lpr.el" (21104 56491 538513 0))
 ;;; Generated autoloads from lpr.el
 
 (defvar lpr-windows-system (memq system-type '(ms-dos windows-nt)) "\
@@ -17630,7 +17675,7 @@ Previous contents of that buffer are killed first.
 
 ;;;***
 \f
-;;;### (autoloads nil "man" "man.el" (21040 17194 398147 0))
+;;;### (autoloads nil "man" "man.el" (21100 59431 520894 0))
 ;;; Generated autoloads from man.el
 
 (defalias 'manual-entry 'man)
@@ -17687,6 +17732,7 @@ Default bookmark handler for Man buffers.
 ;;;### (autoloads nil "master" "master.el" (20884 7264 912957 506000))
 ;;; Generated autoloads from master.el
 (push (purecopy '(master 1 0 2)) package--builtin-versions)
+
 (autoload 'master-mode "master" "\
 Toggle Master mode.
 With a prefix argument ARG, enable Master mode if ARG is
@@ -17737,6 +17783,7 @@ recursion depth in the minibuffer prompt.  This is only useful if
 ;;;### (autoloads nil "md4" "md4.el" (20709 26818 907104 0))
 ;;; Generated autoloads from md4.el
 (push (purecopy '(md4 1 0)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "message" "gnus/message.el" (21048 11307 937592
@@ -17909,6 +17956,7 @@ which specify the range to operate on.
 ;;;;;;  62962 290468 0))
 ;;; Generated autoloads from progmodes/meta-mode.el
 (push (purecopy '(meta-mode 1 0)) package--builtin-versions)
+
 (autoload 'metafont-mode "meta-mode" "\
 Major mode for editing Metafont sources.
 
@@ -18059,6 +18107,7 @@ delete the draft message.
 ;;;### (autoloads nil "mh-e" "mh-e/mh-e.el" (20987 34598 970563 0))
 ;;; Generated autoloads from mh-e/mh-e.el
 (push (purecopy '(mh-e 8 5)) package--builtin-versions)
+
 (put 'mh-progs 'risky-local-variable t)
 
 (put 'mh-lib 'risky-local-variable t)
@@ -18325,6 +18374,7 @@ whose file names match the specified wildcard.
 ;;;;;;  1963 769129 0))
 ;;; Generated autoloads from progmodes/mixal-mode.el
 (push (purecopy '(mixal-mode 0 1)) package--builtin-versions)
+
 (autoload 'mixal-mode "mixal-mode" "\
 Major mode for the mixal asm language.
 
@@ -18611,7 +18661,7 @@ To test this function, evaluate:
 
 ;;;***
 \f
-;;;### (autoloads nil "mpc" "mpc.el" (21049 14338 391345 0))
+;;;### (autoloads nil "mpc" "mpc.el" (21075 56234 349623 0))
 ;;; Generated autoloads from mpc.el
 
 (autoload 'mpc "mpc" "\
@@ -19029,8 +19079,8 @@ listed in the PORTS list.
 
 ;;;***
 \f
-;;;### (autoloads nil "network-stream" "net/network-stream.el" (20984
-;;;;;;  58408 354075 0))
+;;;### (autoloads nil "network-stream" "net/network-stream.el" (21074
+;;;;;;  35375 473679 0))
 ;;; Generated autoloads from net/network-stream.el
 
 (autoload 'open-network-stream "network-stream" "\
@@ -19203,6 +19253,7 @@ Start newsticker treeview.
 ;;;;;;  907104 0))
 ;;; Generated autoloads from net/newsticker.el
 (push (purecopy '(newsticker 1 99)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "nndiary" "gnus/nndiary.el" (20709 26818 907104
@@ -19247,6 +19298,7 @@ This command does not work if you use short group names.
 ;;;;;;  907104 0))
 ;;; Generated autoloads from gnus/nnmairix.el
 (push (purecopy '(nnmairix 0 6)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "nnml" "gnus/nnml.el" (20955 58152 201869 0))
@@ -19309,6 +19361,7 @@ closing requests for requests that are used in matched pairs.
 ;;;### (autoloads nil "ntlm" "net/ntlm.el" (20709 26818 907104 0))
 ;;; Generated autoloads from net/ntlm.el
 (push (purecopy '(ntlm 1 0)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "nxml-glyph" "nxml/nxml-glyph.el" (20709 26818
@@ -19324,8 +19377,8 @@ Return nil if the face cannot display a glyph for N.
 
 ;;;***
 \f
-;;;### (autoloads nil "nxml-mode" "nxml/nxml-mode.el" (20884 6711
-;;;;;;  386198 0))
+;;;### (autoloads nil "nxml-mode" "nxml/nxml-mode.el" (21075 56234
+;;;;;;  349623 0))
 ;;; Generated autoloads from nxml/nxml-mode.el
 
 (autoload 'nxml-mode "nxml-mode" "\
@@ -19399,8 +19452,8 @@ the variable `nxml-enabled-unicode-blocks'.
 
 ;;;***
 \f
-;;;### (autoloads nil "octave" "progmodes/octave.el" (21065 20391
-;;;;;;  959557 0))
+;;;### (autoloads nil "octave" "progmodes/octave.el" (21098 17703
+;;;;;;  588969 0))
 ;;; Generated autoloads from progmodes/octave.el
 
 (autoload 'octave-mode "octave" "\
@@ -20153,10 +20206,11 @@ See the command `outline-mode' for more information on this mode.
 
 ;;;***
 \f
-;;;### (autoloads nil "package" "emacs-lisp/package.el" (21066 41257
-;;;;;;  365840 0))
+;;;### (autoloads nil "package" "emacs-lisp/package.el" (21104 56491
+;;;;;;  538513 0))
 ;;; Generated autoloads from emacs-lisp/package.el
 (push (purecopy '(package 1 0 1)) package--builtin-versions)
+
 (defvar package-enable-at-startup t "\
 Whether to activate installed packages when Emacs starts.
 If non-nil, packages are activated after reading the init file
@@ -20189,6 +20243,11 @@ The file can either be a tar file or an Emacs Lisp file.
 
 \(fn FILE)" t nil)
 
+(autoload 'package-import-keyring "package" "\
+Import keys from FILE.
+
+\(fn &optional FILE)" t nil)
+
 (autoload 'package-refresh-contents "package" "\
 Download the ELPA archive description if needed.
 This informs Emacs about the latest versions of all packages, and
@@ -20602,7 +20661,7 @@ Setup `shell-mode' to use pcomplete.
 
 ;;;***
 \f
-;;;### (autoloads nil "pcvs" "vc/pcvs.el" (21052 8364 417872 0))
+;;;### (autoloads nil "pcvs" "vc/pcvs.el" (21104 56491 538513 0))
 ;;; Generated autoloads from vc/pcvs.el
 
 (autoload 'cvs-checkout "pcvs" "\
@@ -20677,8 +20736,8 @@ The exact behavior is determined also by `cvs-dired-use-hook'." (when (stringp d
 
 ;;;***
 \f
-;;;### (autoloads nil "pcvs-defs" "vc/pcvs-defs.el" (20709 26818
-;;;;;;  907104 0))
+;;;### (autoloads nil "pcvs-defs" "vc/pcvs-defs.el" (21075 56234
+;;;;;;  349623 0))
 ;;; Generated autoloads from vc/pcvs-defs.el
 
 (defvar cvs-global-menu (let ((m (make-sparse-keymap "PCL-CVS"))) (define-key m [status] `(menu-item ,(purecopy "Directory Status") cvs-status :help ,(purecopy "A more verbose status of a workarea"))) (define-key m [checkout] `(menu-item ,(purecopy "Checkout Module") cvs-checkout :help ,(purecopy "Check out a module from the repository"))) (define-key m [update] `(menu-item ,(purecopy "Update Directory") cvs-update :help ,(purecopy "Fetch updates from the repository"))) (define-key m [examine] `(menu-item ,(purecopy "Examine Directory") cvs-examine :help ,(purecopy "Examine the current state of a workarea"))) (fset 'cvs-global-menu m)) "\
@@ -20686,8 +20745,8 @@ Global menu used by PCL-CVS.")
 
 ;;;***
 \f
-;;;### (autoloads nil "perl-mode" "progmodes/perl-mode.el" (20929
-;;;;;;  34089 117790 0))
+;;;### (autoloads nil "perl-mode" "progmodes/perl-mode.el" (21075
+;;;;;;  56234 349623 0))
 ;;; Generated autoloads from progmodes/perl-mode.el
 (put 'perl-indent-level 'safe-local-variable 'integerp)
 (put 'perl-continued-statement-offset 'safe-local-variable 'integerp)
@@ -20938,6 +20997,7 @@ Ignores leading comment characters.
 ;;;;;;  0))
 ;;; Generated autoloads from printing.el
 (push (purecopy '(printing 6 9 3)) package--builtin-versions)
+
 (autoload 'pr-interface "printing" "\
 Activate the printing interface buffer.
 
@@ -21540,7 +21600,7 @@ Proced buffers.
 
 ;;;***
 \f
-;;;### (autoloads nil "profiler" "profiler.el" (21040 17194 398147
+;;;### (autoloads nil "profiler" "profiler.el" (21077 11573 151993
 ;;;;;;  0))
 ;;; Generated autoloads from profiler.el
 
@@ -21569,8 +21629,8 @@ Open profile FILENAME.
 
 ;;;***
 \f
-;;;### (autoloads nil "prolog" "progmodes/prolog.el" (20919 46844
-;;;;;;  767888 0))
+;;;### (autoloads nil "prolog" "progmodes/prolog.el" (21099 38568
+;;;;;;  469572 0))
 ;;; Generated autoloads from progmodes/prolog.el
 
 (autoload 'prolog-mode "prolog" "\
@@ -21620,6 +21680,7 @@ The default value is '(\"/usr/local/share/emacs/fonts/bdf\").")
 ;;;;;;  848428 0))
 ;;; Generated autoloads from progmodes/ps-mode.el
 (push (purecopy '(ps-mode 1 1 9)) package--builtin-versions)
+
 (autoload 'ps-mode "ps-mode" "\
 Major mode for editing PostScript with GNU Emacs.
 
@@ -21663,10 +21724,11 @@ Typing \\<ps-run-mode-map>\\[ps-run-goto-error] when the cursor is at the number
 
 ;;;***
 \f
-;;;### (autoloads nil "ps-print" "ps-print.el" (20975 43430 521692
+;;;### (autoloads nil "ps-print" "ps-print.el" (21105 26139 752484
 ;;;;;;  0))
 ;;; Generated autoloads from ps-print.el
 (push (purecopy '(ps-print 7 3 5)) package--builtin-versions)
+
 (defvar ps-page-dimensions-database (purecopy (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54) "A4") (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54) "A3") (list 'letter (* 72 8.5) (* 72 11.0) "Letter") (list 'legal (* 72 8.5) (* 72 14.0) "Legal") (list 'letter-small (* 72 7.68) (* 72 10.16) "LetterSmall") (list 'tabloid (* 72 11.0) (* 72 17.0) "Tabloid") (list 'ledger (* 72 17.0) (* 72 11.0) "Ledger") (list 'statement (* 72 5.5) (* 72 8.5) "Statement") (list 'executive (* 72 7.5) (* 72 10.0) "Executive") (list 'a4small (* 72 7.47) (* 72 10.85) "A4Small") (list 'b4 (* 72 10.125) (* 72 14.33) "B4") (list 'b5 (* 72 7.16) (* 72 10.125) "B5") '(addresslarge 236.0 99.0 "AddressLarge") '(addresssmall 236.0 68.0 "AddressSmall") '(cuthanging13 90.0 222.0 "CutHanging13") '(cuthanging15 90.0 114.0 "CutHanging15") '(diskette 181.0 136.0 "Diskette") '(eurofilefolder 139.0 112.0 "EuropeanFilefolder") '(eurofoldernarrow 526.0 107.0 "EuroFolderNarrow") '(eurofolderwide 526.0 136.0 "EuroFolderWide") '(euronamebadge 189.0 108.0 "EuroNameBadge") '(euronamebadgelarge 223.0 136.0 "EuroNameBadgeLarge") '(filefolder 230.0 37.0 "FileFolder") '(jewelry 76.0 136.0 "Jewelry") '(mediabadge 180.0 136.0 "MediaBadge") '(multipurpose 126.0 68.0 "MultiPurpose") '(retaillabel 90.0 104.0 "RetailLabel") '(shipping 271.0 136.0 "Shipping") '(slide35mm 26.0 104.0 "Slide35mm") '(spine8mm 187.0 26.0 "Spine8mm") '(topcoated 425.19685 136.0 "TopCoatedPaper") '(topcoatedpaper 396.0 136.0 "TopcoatedPaper150") '(vhsface 205.0 127.0 "VHSFace") '(vhsspine 400.0 50.0 "VHSSpine") '(zipdisk 156.0 136.0 "ZipDisk"))) "\
 List associating a symbolic paper type to its width, height and doc media.
 See `ps-paper-type'.")
@@ -21860,16 +21922,18 @@ If EXTENSION is any other symbol, it is ignored.
 
 ;;;***
 \f
-;;;### (autoloads nil "pulse" "cedet/pulse.el" (20709 26818 907104
+;;;### (autoloads nil "pulse" "cedet/pulse.el" (21106 11815 370918
 ;;;;;;  0))
 ;;; Generated autoloads from cedet/pulse.el
 (push (purecopy '(pulse 1 0)) package--builtin-versions)
+
 ;;;***
 \f
-;;;### (autoloads nil "python" "progmodes/python.el" (21040 17194
-;;;;;;  398147 0))
+;;;### (autoloads nil "python" "progmodes/python.el" (21104 56491
+;;;;;;  538513 0))
 ;;; Generated autoloads from progmodes/python.el
 (push (purecopy '(python 0 24 2)) package--builtin-versions)
+
 (add-to-list 'auto-mode-alist (cons (purecopy "\\.py\\'") 'python-mode))
 
 (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode))
@@ -22320,7 +22384,7 @@ were operated on recently.
 
 ;;;***
 \f
-;;;### (autoloads nil "rect" "rect.el" (20709 26818 907104 0))
+;;;### (autoloads nil "rect" "rect.el" (21104 56491 538513 0))
 ;;; Generated autoloads from rect.el
 
 (autoload 'delete-rectangle "rect" "\
@@ -22452,6 +22516,11 @@ with a prefix argument, prompt for START-AT and FORMAT.
 
 \(fn START END START-AT &optional FORMAT)" t nil)
 
+(autoload 'rectangle-mark "rect" "\
+Toggle the region as rectangular.
+
+\(fn)" t nil)
+
 ;;;***
 \f
 ;;;### (autoloads nil "refill" "textmodes/refill.el" (20884 7264
@@ -22662,12 +22731,14 @@ This means the number of non-shy regexp grouping constructs
 ;;;;;;  0))
 ;;; Generated autoloads from emacs-lisp/regi.el
 (push (purecopy '(regi 1 8)) package--builtin-versions)
+
 ;;;***
 \f
-;;;### (autoloads nil "remember" "textmodes/remember.el" (20945 22315
-;;;;;;  8369 0))
+;;;### (autoloads nil "remember" "textmodes/remember.el" (21093 51772
+;;;;;;  844670 0))
 ;;; Generated autoloads from textmodes/remember.el
 (push (purecopy '(remember 2 0)) package--builtin-versions)
+
 (autoload 'remember "remember" "\
 Remember an arbitrary piece of data.
 INITIAL is the text to initially place in the *Remember* buffer,
@@ -22725,6 +22796,7 @@ preserve across Emacs restarts.  The notes will be stored in the
 ;;;### (autoloads nil "repeat" "repeat.el" (20709 26818 907104 0))
 ;;; Generated autoloads from repeat.el
 (push (purecopy '(repeat 0 51)) package--builtin-versions)
+
 (autoload 'repeat "repeat" "\
 Repeat most recently executed command.
 If REPEAT-ARG is non-nil (interactively, with a prefix argument),
@@ -22899,8 +22971,8 @@ variable.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmail" "mail/rmail.el" (21049 32304 81561
-;;;;;;  723000))
+;;;### (autoloads nil "rmail" "mail/rmail.el" (21105 26139 752484
+;;;;;;  0))
 ;;; Generated autoloads from mail/rmail.el
 
 (defvar rmail-file-name (purecopy "~/RMAIL") "\
@@ -23347,10 +23419,11 @@ for modes derived from Text mode, like Mail mode.
 
 ;;;***
 \f
-;;;### (autoloads nil "ruby-mode" "progmodes/ruby-mode.el" (21046
-;;;;;;  55978 585230 0))
+;;;### (autoloads nil "ruby-mode" "progmodes/ruby-mode.el" (21107
+;;;;;;  32686 465643 0))
 ;;; Generated autoloads from progmodes/ruby-mode.el
 (push (purecopy '(ruby-mode 1 2)) package--builtin-versions)
+
 (autoload 'ruby-mode "ruby-mode" "\
 Major mode for editing Ruby scripts.
 \\[ruby-indent-line] properly indents subexpressions of multi-line
@@ -23373,6 +23446,7 @@ The variable `ruby-indent-level' controls the amount of indentation.
 ;;;;;;  0))
 ;;; Generated autoloads from ruler-mode.el
 (push (purecopy '(ruler-mode 1 6)) package--builtin-versions)
+
 (defvar ruler-mode nil "\
 Non-nil if Ruler mode is enabled.
 Use the command `ruler-mode' to change this variable.")
@@ -23703,12 +23777,14 @@ enclosed in `(and ...)'.
 ;;;;;;  907104 0))
 ;;; Generated autoloads from net/sasl-ntlm.el
 (push (purecopy '(sasl 1 0)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "savehist" "savehist.el" (21040 42923 330142
 ;;;;;;  838000))
 ;;; Generated autoloads from savehist.el
 (push (purecopy '(savehist 24)) package--builtin-versions)
+
 (defvar savehist-mode nil "\
 Non-nil if Savehist mode is enabled.
 See the command `savehist-mode' for a description of this minor mode.
@@ -23836,7 +23912,7 @@ vertically fixed relative to window boundaries during scrolling.
 
 ;;;***
 \f
-;;;### (autoloads nil "secrets" "net/secrets.el" (20929 34089 117790
+;;;### (autoloads nil "secrets" "net/secrets.el" (21071 59176 747909
 ;;;;;;  0))
 ;;; Generated autoloads from net/secrets.el
 (when (featurep 'dbusbind)
@@ -23848,6 +23924,7 @@ vertically fixed relative to window boundaries during scrolling.
 ;;;;;;  690120 156000))
 ;;; Generated autoloads from cedet/semantic.el
 (push (purecopy '(semantic 2 2)) package--builtin-versions)
+
 (defvar semantic-default-submodes '(global-semantic-idle-scheduler-mode global-semanticdb-minor-mode) "\
 List of auxiliary Semantic minor modes enabled by `semantic-mode'.
 The possible elements of this list include the following:
@@ -24356,10 +24433,11 @@ To work around that, do:
 
 ;;;***
 \f
-;;;### (autoloads nil "sh-script" "progmodes/sh-script.el" (21039
-;;;;;;  31945 0 0))
+;;;### (autoloads nil "sh-script" "progmodes/sh-script.el" (21097
+;;;;;;  42046 44658 0))
 ;;; Generated autoloads from progmodes/sh-script.el
-(push (purecopy '(sh-script 2 0 6)) package--builtin-versions)(put 'sh-shell 'safe-local-variable 'symbolp)
+(push (purecopy '(sh-script 2 0 6)) package--builtin-versions)
+(put 'sh-shell 'safe-local-variable 'symbolp)
 
 (autoload 'sh-mode "sh-script" "\
 Major mode for editing shell scripts.
@@ -24420,8 +24498,8 @@ with your script for an edit-interpret-debug cycle.
 
 ;;;***
 \f
-;;;### (autoloads nil "shadow" "emacs-lisp/shadow.el" (20858 21542
-;;;;;;  723007 0))
+;;;### (autoloads nil "shadow" "emacs-lisp/shadow.el" (21082 29482
+;;;;;;  330637 0))
 ;;; Generated autoloads from emacs-lisp/shadow.el
 
 (autoload 'list-load-path-shadows "shadow" "\
@@ -24660,7 +24738,7 @@ with no arguments, if that value is non-nil.
 
 ;;;***
 \f
-;;;### (autoloads nil "skeleton" "skeleton.el" (20912 25000 802412
+;;;### (autoloads nil "skeleton" "skeleton.el" (21087 47399 892476
 ;;;;;;  0))
 ;;; Generated autoloads from skeleton.el
 
@@ -25255,10 +25333,11 @@ Return a vector containing the lines from `spook-phrases-file'.
 
 ;;;***
 \f
-;;;### (autoloads nil "sql" "progmodes/sql.el" (20975 10147 44538
+;;;### (autoloads nil "sql" "progmodes/sql.el" (21082 29482 330637
 ;;;;;;  0))
 ;;; Generated autoloads from progmodes/sql.el
 (push (purecopy '(sql 3 3)) package--builtin-versions)
+
 (autoload 'sql-add-product-keywords "sql" "\
 Add highlighting KEYWORDS for SQL PRODUCT.
 
@@ -25722,6 +25801,7 @@ buffer.
 ;;;;;;  0))
 ;;; Generated autoloads from cedet/srecode.el
 (push (purecopy '(srecode 1 2)) package--builtin-versions)
+
 ;;;***
 \f
 ;;;### (autoloads nil "srecode/srt-mode" "cedet/srecode/srt-mode.el"
@@ -25895,8 +25975,8 @@ Studlify-case the current buffer.
 
 ;;;***
 \f
-;;;### (autoloads nil "subword" "progmodes/subword.el" (20974 22577
-;;;;;;  548213 0))
+;;;### (autoloads nil "subword" "progmodes/subword.el" (21086 26537
+;;;;;;  509049 0))
 ;;; Generated autoloads from progmodes/subword.el
 
 (autoload 'subword-mode "subword" "\
@@ -26845,6 +26925,7 @@ Start coverage on function under point.
 ;;;;;;  217000))
 ;;; Generated autoloads from play/tetris.el
 (push (purecopy '(tetris 2 1)) package--builtin-versions)
+
 (autoload 'tetris "tetris" "\
 Play the Tetris game.
 Shapes drop from the top of the screen, and the user has to move and
@@ -27498,6 +27579,7 @@ See also docstring of the function tibetan-compose-region.
 ;;;;;;  561026 0))
 ;;; Generated autoloads from textmodes/tildify.el
 (push (purecopy '(tildify 4 5)) package--builtin-versions)
+
 (autoload 'tildify-region "tildify" "\
 Add hard spaces in the region between BEG and END.
 See variables `tildify-pattern-alist', `tildify-string-alist', and
@@ -27737,6 +27819,7 @@ With ARG, turn time stamping on if and only if arg is positive.
 ;;;;;;  58662 278539 0))
 ;;; Generated autoloads from calendar/timeclock.el
 (push (purecopy '(timeclock 2 6 1)) package--builtin-versions)
+
 (defvar timeclock-mode-line-display nil "\
 Non-nil if Timeclock-Mode-Line-Display mode is enabled.
 See the command `timeclock-mode-line-display' for a description of this minor mode.
@@ -27865,7 +27948,7 @@ To get complete usage, invoke \"emacs -batch -f batch-titdic-convert -h\".
 
 ;;;***
 \f
-;;;### (autoloads nil "tmm" "tmm.el" (20764 51137 83502 0))
+;;;### (autoloads nil "tmm" "tmm.el" (21086 55571 430148 991000))
 ;;; Generated autoloads from tmm.el
  (define-key global-map "\M-`" 'tmm-menubar)
  (define-key global-map [menu-bar mouse-1] 'tmm-menubar-mouse)
@@ -27876,6 +27959,10 @@ See the documentation for `tmm-prompt'.
 X-POSITION, if non-nil, specifies a horizontal position within the menu bar;
 we make that menu bar item (the one at that position) the default choice.
 
+Note that \\[menu-bar-open] by default drops down TTY menus; if you want it
+to invoke `tmm-menubar' instead, customize the variable
+`tty-menu-open-use-tmm' to a non-nil value.
+
 \(fn &optional X-POSITION)" t nil)
 
 (autoload 'tmm-menubar-mouse "tmm" "\
@@ -28021,10 +28108,11 @@ holds a keymap.
 
 ;;;***
 \f
-;;;### (autoloads nil "tpu-edt" "emulation/tpu-edt.el" (21041 38058
-;;;;;;  75002 0))
+;;;### (autoloads nil "tpu-edt" "emulation/tpu-edt.el" (21105 26139
+;;;;;;  752484 0))
 ;;; Generated autoloads from emulation/tpu-edt.el
 (push (purecopy '(tpu-edt 4 5)) package--builtin-versions)
+
 (defvar tpu-edt-mode nil "\
 Non-nil if Tpu-Edt mode is enabled.
 See the command `tpu-edt-mode' for a description of this minor mode.
@@ -28086,7 +28174,7 @@ your local X guru can try to figure out why the key is being ignored.
 
 ;;;***
 \f
-;;;### (autoloads nil "tq" "emacs-lisp/tq.el" (20709 26818 907104
+;;;### (autoloads nil "tq" "emacs-lisp/tq.el" (21074 35375 473679
 ;;;;;;  0))
 ;;; Generated autoloads from emacs-lisp/tq.el
 
@@ -28139,7 +28227,8 @@ changing the window configuration.
 
 ;;;***
 \f
-;;;### (autoloads nil "tramp" "net/tramp.el" (21042 58928 39127 0))
+;;;### (autoloads nil "tramp" "net/tramp.el" (21103 35626 321341
+;;;;;;  0))
 ;;; Generated autoloads from net/tramp.el
 
 (defvar tramp-mode t "\
@@ -28262,8 +28351,8 @@ Discard Tramp from loading remote files.
 
 ;;;***
 \f
-;;;### (autoloads nil "tramp-ftp" "net/tramp-ftp.el" (21008 40741
-;;;;;;  120196 0))
+;;;### (autoloads nil "tramp-ftp" "net/tramp-ftp.el" (21089 2732
+;;;;;;  351717 0))
 ;;; Generated autoloads from net/tramp-ftp.el
 
 (autoload 'tramp-ftp-enable-ange-ftp "tramp-ftp" "\
@@ -28490,7 +28579,7 @@ FRAC should be the inverse of the fractional value; for example, a value of
 
 ;;;***
 \f
-;;;### (autoloads nil "uce" "mail/uce.el" (20709 26818 907104 0))
+;;;### (autoloads nil "uce" "mail/uce.el" (21082 29482 330637 0))
 ;;; Generated autoloads from mail/uce.el
 
 (autoload 'uce-reply-to-uce "uce" "\
@@ -29346,7 +29435,7 @@ If FILE-NAME is non-nil, save the result to FILE-NAME.
 
 ;;;***
 \f
-;;;### (autoloads nil "vc" "vc/vc.el" (21053 29224 547064 0))
+;;;### (autoloads nil "vc" "vc/vc.el" (21098 17703 588969 0))
 ;;; Generated autoloads from vc/vc.el
 
 (defvar vc-checkout-hook nil "\
@@ -29665,7 +29754,7 @@ mode-specific menu.  `vc-annotate-color-map' and
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-arch" "vc/vc-arch.el" (21031 51082 798722
+;;;### (autoloads nil "vc-arch" "vc/vc-arch.el" (21071 59176 747909
 ;;;;;;  0))
 ;;; Generated autoloads from vc/vc-arch.el
  (defun vc-arch-registered (file)
@@ -29693,7 +29782,7 @@ Name of the format file in a .bzr directory.")
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-cvs" "vc/vc-cvs.el" (21052 8364 417872
+;;;### (autoloads nil "vc-cvs" "vc/vc-cvs.el" (21071 59176 747909
 ;;;;;;  0))
 ;;; Generated autoloads from vc/vc-cvs.el
 (defun vc-cvs-registered (f)
@@ -29754,7 +29843,7 @@ case, and the process object in the asynchronous case.
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-git" "vc/vc-git.el" (21041 38058 75002
+;;;### (autoloads nil "vc-git" "vc/vc-git.el" (21067 62128 15681
 ;;;;;;  0))
 ;;; Generated autoloads from vc/vc-git.el
  (defun vc-git-registered (file)
@@ -29777,7 +29866,7 @@ case, and the process object in the asynchronous case.
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-mtn" "vc/vc-mtn.el" (21031 51082 798722
+;;;### (autoloads nil "vc-mtn" "vc/vc-mtn.el" (21071 59176 747909
 ;;;;;;  0))
 ;;; Generated autoloads from vc/vc-mtn.el
 
@@ -29794,7 +29883,7 @@ Name of the monotone directory's format file.")
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-rcs" "vc/vc-rcs.el" (21031 51082 798722
+;;;### (autoloads nil "vc-rcs" "vc/vc-rcs.el" (21071 59176 747909
 ;;;;;;  0))
 ;;; Generated autoloads from vc/vc-rcs.el
 
@@ -29827,8 +29916,8 @@ find any project directory." (let ((project-dir (getenv "PROJECTDIR")) dirs dir)
 
 ;;;***
 \f
-;;;### (autoloads nil "vc-svn" "vc/vc-svn.el" (21041 38058 75002
-;;;;;;  0))
+;;;### (autoloads nil "vc-svn" "vc/vc-svn.el" (21077 42241 670130
+;;;;;;  556000))
 ;;; Generated autoloads from vc/vc-svn.el
  (defun vc-svn-registered (f)
   (let ((admin-dir (cond ((and (eq system-type 'windows-nt)
@@ -29844,7 +29933,8 @@ find any project directory." (let ((project-dir (getenv "PROJECTDIR")) dirs dir)
 ;;;### (autoloads nil "vera-mode" "progmodes/vera-mode.el" (20893
 ;;;;;;  60586 188550 0))
 ;;; Generated autoloads from progmodes/vera-mode.el
-(push (purecopy '(vera-mode 2 28)) package--builtin-versions) (add-to-list 'auto-mode-alist (cons (purecopy "\\.vr[hi]?\\'")  'vera-mode))
+(push (purecopy '(vera-mode 2 28)) package--builtin-versions)
+ (add-to-list 'auto-mode-alist (cons (purecopy "\\.vr[hi]?\\'")  'vera-mode))
 
 (autoload 'vera-mode "vera-mode" "\
 Major mode for editing Vera code.
@@ -29900,7 +29990,7 @@ Key bindings:
 ;;;***
 \f
 ;;;### (autoloads nil "verilog-mode" "progmodes/verilog-mode.el"
-;;;;;;  (20992 52525 458637 0))
+;;;;;;  (21091 44456 774347 0))
 ;;; Generated autoloads from progmodes/verilog-mode.el
 
 (autoload 'verilog-mode "verilog-mode" "\
@@ -30008,7 +30098,8 @@ Some other functions are:
     \\[verilog-sk-fork]  Insert a fork begin .. end .. join block.
     \\[verilog-sk-module]  Insert a module .. (/*AUTOARG*/);.. endmodule block.
     \\[verilog-sk-ovm-class]  Insert an OVM Class block.
-    \\[verilog-sk-uvm-class]  Insert an UVM Class block.
+    \\[verilog-sk-uvm-object]  Insert an UVM Object block.
+    \\[verilog-sk-uvm-component]  Insert an UVM Component block.
     \\[verilog-sk-primitive]  Insert a primitive .. (.. );.. endprimitive block.
     \\[verilog-sk-repeat]  Insert a repeat (..) begin .. end block.
     \\[verilog-sk-specify]  Insert a specify .. endspecify block.
@@ -30967,6 +31058,7 @@ Turn on VIP emulation of VI.
 ;;;;;;  0))
 ;;; Generated autoloads from emulation/viper.el
 (push (purecopy '(viper 3 14 1)) package--builtin-versions)
+
 (autoload 'toggle-viper-mode "viper" "\
 Toggle Viper on/off.
 If Viper is enabled, turn it off.  Otherwise, turn it on.
@@ -31073,6 +31165,7 @@ this is equivalent to `display-warning', using
 ;;;### (autoloads nil "wdired" "wdired.el" (21049 14338 391345 0))
 ;;; Generated autoloads from wdired.el
 (push (purecopy '(wdired 2 0)) package--builtin-versions)
+
 (autoload 'wdired-change-to-wdired-mode "wdired" "\
 Put a Dired buffer in Writable Dired (WDired) mode.
 \\<wdired-mode-map>
@@ -31139,6 +31232,7 @@ in certain major modes.
 ;;;;;;  0))
 ;;; Generated autoloads from whitespace.el
 (push (purecopy '(whitespace 13 2 2)) package--builtin-versions)
+
 (autoload 'whitespace-mode "whitespace" "\
 Toggle whitespace visualization (Whitespace mode).
 With a prefix argument ARG, enable Whitespace mode if ARG is
@@ -31685,6 +31779,7 @@ the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
 ;;;### (autoloads nil "woman" "woman.el" (20999 25770 522517 0))
 ;;; Generated autoloads from woman.el
 (push (purecopy '(woman 0 551)) package--builtin-versions)
+
 (defvar woman-locale nil "\
 String specifying a manual page locale, or nil.
 If a manual page is available in the specified locale
@@ -31734,6 +31829,7 @@ Default bookmark handler for Woman buffers.
 ;;;;;;  398147 0))
 ;;; Generated autoloads from emulation/ws-mode.el
 (push (purecopy '(ws-mode 0 7)) package--builtin-versions)
+
 (autoload 'wordstar-mode "ws-mode" "\
 Major mode with WordStar-like key bindings.
 
@@ -31807,7 +31903,7 @@ Both features can be combined by providing a cons cell
 
 ;;;***
 \f
-;;;### (autoloads nil "xmltok" "nxml/xmltok.el" (20998 4934 952905
+;;;### (autoloads nil "xmltok" "nxml/xmltok.el" (21075 56234 349623
 ;;;;;;  0))
 ;;; Generated autoloads from nxml/xmltok.el
 
@@ -32087,7 +32183,7 @@ Zone out, completely.
 ;;;;;;  "vc/ediff-vers.el" "vc/ediff-wind.el" "vc/pcvs-info.el" "vc/pcvs-parse.el"
 ;;;;;;  "vc/pcvs-util.el" "vc/vc-dav.el" "vcursor.el" "vt-control.el"
 ;;;;;;  "vt100-led.el" "w32-common-fns.el" "w32-fns.el" "w32-vars.el"
-;;;;;;  "x-dnd.el") (21066 41280 469799 289000))
+;;;;;;  "x-dnd.el") (21107 32938 48648 817000))
 
 ;;;***
 \f
index d9d7e5ad120e5355d66b64eaee9dbbad620d96b9..c2bc2fd91e180a2aae8fe79152abb1fe8c0738cd 100644 (file)
@@ -152,7 +152,7 @@ Linum mode is a buffer-local minor mode."
     (run-hooks 'linum-before-numbering-hook)
     ;; Create an overlay (or reuse an existing one) for each
     ;; line visible in this window, if necessary.
-    (while (and (not (eobp)) (<= (point) limit))
+    (while (and (not (eobp)) (< (point) limit))
       (let* ((str (if fmt
                       (propertize (format fmt line) 'face 'linum)
                     (funcall linum-format line)))
index 620344734b36fb8a1c3f0d11b830591c769cd925..b8433e1cbaab31e5170c0baf37abfd65e22b55eb 100644 (file)
@@ -101,14 +101,10 @@ A library name is equivalent to the file name that `load-library' would load."
   "Read feature name from the minibuffer, prompting with string PROMPT.
 If optional second arg LOADED-P is non-nil, the feature must be loaded
 from a file."
-  (intern
-   (completing-read prompt
-                   (cons nil features)
-                   (and loaded-p
-                        #'(lambda (f)
-                            (and f     ; ignore nil
-                                 (feature-file f))))
-                   loaded-p)))
+  (intern (completing-read prompt
+                          features
+                          (and loaded-p #'feature-file)
+                          loaded-p)))
 
 (defvaralias 'loadhist-hook-functions 'unload-feature-special-hooks)
 (defvar unload-feature-special-hooks
index 27148ceea753432f0a7eff4417b315ab42668500..98e3b87714431477db8a1c8589b78173b0358b75 100644 (file)
 ;For other systems, you must edit ../src/Makefile.in.
 (load "site-load" t)
 
+;; Make sure default-directory is unibyte when dumping.  This is
+;; because we cannot decode and encode it correctly (since the locale
+;; environment is not, and should not be, set up).  default-directory
+;; is used every time we call expand-file-name, which we do in every
+;; file primitive.  So the only workable solution to support building
+;; in non-ASCII directories is to manipulate unibyte strings in the
+;; current locale's encoding.
+(if (and (or (equal (nth 3 command-line-args) "dump")
+            (equal (nth 4 command-line-args) "dump")
+            (equal (nth 3 command-line-args) "bootstrap")
+            (equal (nth 4 command-line-args) "bootstrap"))
+        (multibyte-string-p default-directory))
+    (error "default-directory must be unibyte when dumping Emacs!"))
+
 ;; Determine which last version number to use
 ;; based on the executables that now exist.
 (if (and (or (equal (nth 3 command-line-args) "dump")
index 5aed3bcc484ba3e74e422976248970fc1cf5269b..0e96051715905fdf70423eeef24be3f1d0b253aa 100644 (file)
@@ -132,7 +132,7 @@ and print the result."
 
 (defcustom print-region-function
   (if (memq system-type '(ms-dos windows-nt))
-      #'direct-print-region-function
+      #'w32-direct-print-region-function
     #'call-process-region)
   "Function to call to print the region on a printer.
 See definition of `print-region-1' for calling conventions."
index 56198035a222b4648a4e835e9884e1bf0c9b297d..a03fda5e6bd07214236f84c0728ec8afd4888d3e 100644 (file)
@@ -89,6 +89,7 @@
 ;;; Code:
 
 (require 'ansi-color)
+(require 'cl-lib)
 (require 'button)
 
 (defgroup man nil
@@ -368,6 +369,12 @@ specified subject, if your `man' program supports it."
 Otherwise, the value is whatever the function
 `Man-support-local-filenames' should return.")
 
+(defcustom man-imenu-title "Contents"
+  "The title to use if man adds a Contents menu to the menubar."
+  :version "24.4"
+  :type 'string
+  :group 'man)
+
 \f
 ;; other variables and keymap initializations
 (defvar Man-original-frame)
@@ -441,11 +448,34 @@ Otherwise, the value is whatever the function
     (define-key map "s"    'Man-goto-see-also-section)
     (define-key map "k"    'Man-kill)
     (define-key map "q"    'Man-quit)
+    (define-key map "u"    'Man-update-manpage)
     (define-key map "m"    'man)
     ;; Not all the man references get buttons currently.  The text in the
     ;; manual page can contain references to other man pages
     (define-key map "\r"   'man-follow)
     (define-key map "?"    'describe-mode)
+
+    (easy-menu-define nil map
+      "`Man-mode' menu."
+      '("Man"
+        ["Next Section" Man-next-section t]
+        ["Previous Section" Man-previous-section t]
+        ["Go To Section..." Man-goto-section t]
+        ["Go To \"SEE ALSO\" Section" Man-goto-see-also-section
+         :active (cl-member Man-see-also-regexp Man--sections
+                            :test #'string-match-p)]
+        ["Follow Reference..." Man-follow-manual-reference
+         :active Man--refpages
+         :help "Go to a manpage referred to in the \"SEE ALSO\" section"]
+        "--"
+        ["Next Manpage" Man-next-manpage
+         :active (> (length Man-page-list) 1)]
+        ["Previous Manpage" Man-previous-manpage
+         :active (> (length Man-page-list) 1)]
+        "--"
+        ["Man..." man t]
+        ["Kill Buffer" Man-kill t]
+        ["Quit" Man-quit t]))
     map)
   "Keymap for Man mode.")
 
@@ -971,6 +1001,52 @@ names or descriptions.  The pattern argument is usually an
       (error "No item under point")
     (man man-args)))
 
+(defmacro Man-start-calling (&rest body)
+  "Start the man command in `body' after setting up the environment"
+  `(let ((process-environment (copy-sequence process-environment))
+       ;; The following is so Awk script gets \n intact
+       ;; But don't prevent decoding of the outside.
+       (coding-system-for-write 'raw-text-unix)
+       ;; We must decode the output by a coding system that the
+       ;; system's locale suggests in multibyte mode.
+       (coding-system-for-read locale-coding-system)
+       ;; Avoid possible error by using a directory that always exists.
+       (default-directory
+         (if (and (file-directory-p default-directory)
+                  (not (find-file-name-handler default-directory
+                                               'file-directory-p)))
+             default-directory
+           "/")))
+    ;; Prevent any attempt to use display terminal fanciness.
+    (setenv "TERM" "dumb")
+    ;; In Debian Woody, at least, we get overlong lines under X
+    ;; unless COLUMNS or MANWIDTH is set.  This isn't a problem on
+    ;; a tty.  man(1) says:
+    ;;        MANWIDTH
+    ;;               If $MANWIDTH is set, its value is used as the  line
+    ;;               length  for which manual pages should be formatted.
+    ;;               If it is not set, manual pages  will  be  formatted
+    ;;               with  a line length appropriate to the current ter-
+    ;;               minal (using an ioctl(2) if available, the value of
+    ;;               $COLUMNS,  or falling back to 80 characters if nei-
+    ;;               ther is available).
+    (when (or window-system
+             (not (or (getenv "MANWIDTH") (getenv "COLUMNS"))))
+      ;; This isn't strictly correct, since we don't know how
+      ;; the page will actually be displayed, but it seems
+      ;; reasonable.
+      (setenv "COLUMNS" (number-to-string
+                        (cond
+                         ((and (integerp Man-width) (> Man-width 0))
+                          Man-width)
+                         (Man-width (frame-width))
+                         ((window-width))))))
+    ;; Since man-db 2.4.3-1, man writes plain text with no escape
+    ;; sequences when stdout is not a tty.     In 2.5.0, the following
+    ;; env-var was added to allow control of this (see Debian Bug#340673).
+    (setenv "MAN_KEEP_FORMATTING" "1")
+    ,@body))
+
 (defun Man-getpage-in-background (topic)
   "Use TOPIC to build and fire off the manpage and cleaning command.
 Return the buffer in which the manpage will appear."
@@ -986,51 +1062,8 @@ Return the buffer in which the manpage will appear."
        (setq buffer-undo-list t)
        (setq Man-original-frame (selected-frame))
        (setq Man-arguments man-args))
-      (let ((process-environment (copy-sequence process-environment))
-           ;; The following is so Awk script gets \n intact
-           ;; But don't prevent decoding of the outside.
-           (coding-system-for-write 'raw-text-unix)
-           ;; We must decode the output by a coding system that the
-           ;; system's locale suggests in multibyte mode.
-           (coding-system-for-read
-            (if (default-value 'enable-multibyte-characters)
-                locale-coding-system 'raw-text-unix))
-           ;; Avoid possible error by using a directory that always exists.
-           (default-directory
-             (if (and (file-directory-p default-directory)
-                      (not (find-file-name-handler default-directory
-                                                   'file-directory-p)))
-                 default-directory
-               "/")))
-       ;; Prevent any attempt to use display terminal fanciness.
-       (setenv "TERM" "dumb")
-       ;; In Debian Woody, at least, we get overlong lines under X
-       ;; unless COLUMNS or MANWIDTH is set.  This isn't a problem on
-       ;; a tty.  man(1) says:
-       ;;        MANWIDTH
-       ;;               If $MANWIDTH is set, its value is used as the  line
-       ;;               length  for which manual pages should be formatted.
-       ;;               If it is not set, manual pages  will  be  formatted
-       ;;               with  a line length appropriate to the current ter-
-       ;;               minal (using an ioctl(2) if available, the value of
-       ;;               $COLUMNS,  or falling back to 80 characters if nei-
-       ;;               ther is available).
-       (when (or window-system
-                  (not (or (getenv "MANWIDTH") (getenv "COLUMNS"))))
-         ;; This isn't strictly correct, since we don't know how
-         ;; the page will actually be displayed, but it seems
-         ;; reasonable.
-         (setenv "COLUMNS" (number-to-string
-                            (cond
-                             ((and (integerp Man-width) (> Man-width 0))
-                              Man-width)
-                             (Man-width (frame-width))
-                             ((window-width))))))
-       ;; Since man-db 2.4.3-1, man writes plain text with no escape
-       ;; sequences when stdout is not a tty.  In 2.5.0, the following
-       ;; env-var was added to allow control of this (see Debian Bug#340673).
-       (setenv "MAN_KEEP_FORMATTING" "1")
-       (if (fboundp 'start-process)
+      (Man-start-calling
+       (if (fboundp 'start-process)
            (set-process-sentinel
             (start-process manual-program buffer
                            (if (memq system-type '(cygwin windows-nt))
@@ -1052,7 +1085,34 @@ Return the buffer in which the manpage will appear."
                                   exit-status)))
                (setq msg exit-status))
            (Man-bgproc-sentinel bufname msg)))))
-    buffer))
+      buffer))
+
+(defun Man-update-manpage ()
+  "Reformat current manpage by calling the man command again synchronously."
+  (interactive)
+  (when (eq Man-arguments nil)
+    ;;this shouldn't happen unless it is not in a Man buffer."
+    (error "Man-arguments not initialized"))
+  (let ((old-pos (point))
+       (text (current-word))
+       (old-size (buffer-size))
+       (inhibit-read-only t)
+       (buffer-read-only nil))
+     (erase-buffer)
+     (Man-start-calling
+      (call-process shell-file-name nil (list (current-buffer) nil) nil
+                   shell-command-switch
+                   (format (Man-build-man-command) Man-arguments)))
+     (if Man-fontify-manpage-flag
+        (Man-fontify-manpage)
+       (Man-cleanup-manpage))
+     (goto-char old-pos)
+     ;;restore the point, not strictly right.
+     (unless (or (eq text nil) (= old-size (buffer-size)))
+       (let ((case-fold-search nil))
+        (if (> old-size (buffer-size))
+            (search-backward text nil t))
+        (search-forward text nil t)))))
 
 (defun Man-notify-when-ready (man-buffer)
   "Notify the user when MAN-BUFFER is ready.
@@ -1396,6 +1456,7 @@ The following key bindings are currently in effect in the buffer:
   (buffer-disable-undo)
   (auto-fill-mode -1)
   (setq imenu-generic-expression (list (list nil Man-heading-regexp 0)))
+  (imenu-add-to-menubar man-imenu-title)
   (set (make-local-variable 'outline-regexp) Man-heading-regexp)
   (set (make-local-variable 'outline-level) (lambda () 1))
   (set (make-local-variable 'bookmark-make-record-function)
index da80db00910cdd337a5f8930511d49f0c083b5b0..13c4c36be17e775fedcc1af977f5f85be4c9a1f8 100644 (file)
 (or (lookup-key global-map [menu-bar])
     (define-key global-map [menu-bar] (make-sparse-keymap "menu-bar")))
 
-(if (not (featurep 'ns))
-    ;; Force Help item to come last, after the major mode's own items.
-    ;; The symbol used to be called `help', but that gets confused with the
-    ;; help key.
-    (setq menu-bar-final-items '(help-menu))
-  (if (eq system-type 'darwin)
-      (setq menu-bar-final-items '(buffer services help-menu))
-    (setq menu-bar-final-items '(buffer services hide-app quit))
-    ;; Add standard top-level items to GNUstep menu.
-    (bindings--define-key global-map [menu-bar quit]
-      '(menu-item "Quit" save-buffers-kill-emacs
-                   :help "Save unsaved buffers, then exit"))
-    (bindings--define-key global-map [menu-bar hide-app]
-      '(menu-item "Hide" ns-do-hide-emacs
-                  :help "Hide Emacs"))))
+;; Force Help item to come last, after the major mode's own items.
+;; The symbol used to be called `help', but that gets confused with the
+;; help key.
+(setq menu-bar-final-items '(help-menu))
 
 ;; This definition is just to show what this looks like.
 ;; It gets modified in place when menu-bar-update-buffers is called.
@@ -1741,15 +1730,8 @@ key, a click, or a menu-item"))
   (cons "Edit" menu-bar-edit-menu))
 (bindings--define-key global-map [menu-bar file]
   (cons "File" menu-bar-file-menu))
-
-;; Put "Help" menu at the end, or Info at the front.
-;; If running under GNUstep, "Help" is moved and renamed "Info" (see below).
-(if (and (featurep 'ns)
-         (not (eq system-type 'darwin)))
-    (bindings--define-key global-map [menu-bar help-menu]
-      (cons "Info" menu-bar-help-menu))
-  (define-key-after global-map [menu-bar help-menu]
-    (cons (purecopy "Help") menu-bar-help-menu)))
+(bindings--define-key global-map [menu-bar help-menu]
+  (cons (purecopy "Help") menu-bar-help-menu))
 
 (defun menu-bar-menu-frame-live-and-visible-p ()
   "Return non-nil if the menu frame is alive and visible.
@@ -2207,10 +2189,7 @@ FROM-MENU-BAR, if non-nil, means we are dropping one of menu-bar's menus."
                (setq position (list menu-symbol (list frame '(menu-bar)
                                                 event 0)))
                (setq map
-                     (or
-                      (lookup-key global-map (vector 'menu-bar menu-symbol))
-                      (lookup-key (current-local-map) (vector 'menu-bar
-                                                              menu-symbol))))))
+                     (key-binding (vector 'menu-bar menu-symbol)))))
             ((and (not (keymapp map)) (listp map))
              ;; We were given a list of keymaps.  Search them all
              ;; in sequence until a first binding is found.
@@ -2296,7 +2275,8 @@ If FRAME is nil or not given, use the selected frame."
             (menu (menu-bar-menu-at-x-y x 0 frame)))
        (popup-menu (or
                     (lookup-key global-map (vector 'menu-bar menu))
-                    (lookup-key (current-local-map) (vector 'menu-bar menu)))
+                    (lookup-key (current-local-map) (vector 'menu-bar menu))
+                    (cdar (minor-mode-key-binding (vector 'menu-bar menu))))
                    (posn-at-x-y x 0 nil t) nil t)))
      (t (with-selected-frame (or frame (selected-frame))
           (tmm-menubar))))))
index 5e94265f67d30e1dd299119b270d2e3d66f59cc7..c3f2aff042edca7091bab05395211f91271a4f24 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * mh-print.el (mh-ps-print-preprint): Don't use dynamic-var
+       `prefix-arg' as function argument.
+
 2013-06-18  Juri Linkov  <juri@jurta.org>
 
        * mh-alias.el (mh-alias-local-users): Add non-nil arg REPLACE to
index f57ccf56d85d59d680dcee91ffa33daff4e6d3af..f5e5ab7776142e114facb75cb96a1c6643a48733 100644 (file)
@@ -139,11 +139,11 @@ commands \\[mh-ps-print-toggle-color] and
   (interactive (list (mh-interactive-range "Print") (mh-ps-print-preprint 1)))
   (mh-ps-print-range range file))
 
-(defun mh-ps-print-preprint (prefix-arg)
+(defun mh-ps-print-preprint (arg)
   "Provide a better default file name for `ps-print-preprint'.
-Pass along the PREFIX-ARG to it."
+Pass along the prefix ARG to it."
   (let ((buffer-file-name (format "mh-%s" (substring (buffer-name) 1))))
-    (ps-print-preprint prefix-arg)))
+    (ps-print-preprint arg)))
 
 ;;;###mh-autoload
 (defun mh-ps-print-toggle-faces ()
index 2d8da4152954e2fc7eddf3a96de9f2dbfd4f0056..f7d4398986894cfa3c31acb8951ad27d64a34615 100644 (file)
@@ -1950,7 +1950,8 @@ activity.  Only run if the buffer is not visible and
          (old-types rcirc-activity-types))
       (when (not (get-buffer-window (current-buffer) t))
        (setq rcirc-activity
-             (sort (add-to-list 'rcirc-activity (current-buffer))
+             (sort (if (memq (current-buffer) rcirc-activity) rcirc-activity
+                      (cons (current-buffer) rcirc-activity))
                    (lambda (b1 b2)
                      (let ((t1 (with-current-buffer b1 rcirc-last-post-time))
                            (t2 (with-current-buffer b2 rcirc-last-post-time)))
index 2f3dfa4fd7a87069fb966dea485d10128c40e965..35f23caa51ac805c6f7c67a93ea33e1be14c4957 100644 (file)
@@ -85,6 +85,10 @@ When called interactively, a Tramp connection has to be selected."
       ;; Nothing to do.
       (message "No Tramp connection found.")
 
+    ;; Cleanup `tramp-current-connection'.  Otherwise, we would be
+    ;; suppressed in the test suite.
+    (setq tramp-current-connection nil)
+
     ;; Flush password cache.
     (unless keep-password (tramp-clear-passwd vec))
 
index c5f1882931e35c6626d0ed03169ee2acc5418575..8322b7c085bb34ab2093e76210fe9da0aea5a41b 100644 (file)
@@ -416,6 +416,13 @@ Not actually used.  Use `(format \"%o\" i)' instead?"
                directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
      (delete-directory directory))))
 
+;; MUST-SUFFIX doesn't exist on XEmacs.
+(defun tramp-compat-load (file &optional noerror nomessage nosuffix must-suffix)
+  "Like `load' for Tramp files (compat function)."
+  (if must-suffix
+      (tramp-compat-funcall 'load file noerror nomessage nosuffix must-suffix)
+    (load file noerror nomessage nosuffix)))
+
 ;; `number-sequence' does not exist in XEmacs.  Implementation is
 ;; taken from Emacs 23.
 (defun tramp-compat-number-sequence (from &optional to inc)
index eb2a20d183dd703da7464bcc57d88a5161faf94e..9bb142bd50ae55fc1f247a0ade6339e4c6a8468a 100644 (file)
 (defconst tramp-gvfs-enabled
   (ignore-errors
     (and (featurep 'dbusbind)
+        (tramp-compat-funcall 'dbus-get-unique-name :system)
         (tramp-compat-funcall 'dbus-get-unique-name :session)
         (or (tramp-compat-process-running-p "gvfs-fuse-daemon")
             (tramp-compat-process-running-p "gvfsd-fuse"))))
@@ -1009,6 +1010,7 @@ is no information where to trace the message.")
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for Tramp files."
   ;; gvfs-* output is hard to parse.  So we let `ls-lisp' do the job.
+  (unless switches (setq switches ""))
   (with-parsed-tramp-file-name (expand-file-name filename) nil
     (with-tramp-progress-reporter v 0 (format "Opening directory %s" filename)
       (require 'ls-lisp)
@@ -1075,7 +1077,7 @@ is no information where to trace the message.")
          (tramp-flush-file-property v localname))))))
 
 (defun tramp-gvfs-handle-write-region
-  (start end filename &optional _append visit _lockname confirm)
+  (start end filename &optional append visit lockname confirm)
   "Like `write-region' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
@@ -1084,7 +1086,16 @@ is no information where to trace the message.")
        (tramp-error v 'file-error "File not overwritten")))
 
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
-      (write-region start end tmpfile)
+      (when (and append (file-exists-p filename))
+       (copy-file filename tmpfile 'ok))
+      ;; We say `no-message' here because we don't want the visited file
+      ;; modtime data to be clobbered from the temp file.  We call
+      ;; `set-visited-file-modtime' ourselves later on.
+      (tramp-run-real-handler
+       'write-region
+       (if confirm ; don't pass this arg unless defined for backward compat.
+          (list start end tmpfile append 'no-message lockname confirm)
+        (list start end tmpfile append 'no-message lockname)))
       (condition-case nil
          (rename-file tmpfile filename 'ok-if-already-exists)
        (error
@@ -1611,9 +1622,10 @@ be used."
        :system tramp-bluez-service (dbus-event-path-name last-input-event)
        tramp-bluez-interface-adapter "StopDiscovery")))))
 
-(dbus-register-signal
- :system nil nil tramp-bluez-interface-adapter "PropertyChanged"
- 'tramp-bluez-property-changed)
+(when tramp-gvfs-enabled
+  (dbus-register-signal
+   :system nil nil tramp-bluez-interface-adapter "PropertyChanged"
+   'tramp-bluez-property-changed))
 
 (defun tramp-bluez-device-found (device args)
   "Signal handler for the \"org.bluez.Adapter.DeviceFound\" signal."
@@ -1624,9 +1636,10 @@ be used."
     ;; device, and call also SDP in order to find the obex service.
     (add-to-list 'tramp-bluez-devices (list alias address))))
 
-(dbus-register-signal
- :system nil nil tramp-bluez-interface-adapter "DeviceFound"
- 'tramp-bluez-device-found)
+(when tramp-gvfs-enabled
+  (dbus-register-signal
+   :system nil nil tramp-bluez-interface-adapter "DeviceFound"
+   'tramp-bluez-device-found))
 
 (defun tramp-bluez-parse-device-names (_ignore)
   "Return a list of (nil host) tuples allowed to access."
@@ -1635,7 +1648,8 @@ be used."
    (tramp-bluez-list-devices)))
 
 ;; Add completion function for OBEX method.
-(when (member tramp-bluez-service (dbus-list-known-names :system))
+(when (and tramp-gvfs-enabled
+          (member tramp-bluez-service (dbus-list-known-names :system)))
   (tramp-set-completion-function
    "obex" '((tramp-bluez-parse-device-names ""))))
 
@@ -1668,7 +1682,8 @@ be used."
    (zeroconf-list-services "_webdav._tcp")))
 
 ;; Add completion function for DAV and DAVS methods.
-(when (member zeroconf-service-avahi (dbus-list-known-names :system))
+(when (and tramp-gvfs-enabled
+          (member zeroconf-service-avahi (dbus-list-known-names :system)))
   (zeroconf-init tramp-gvfs-zeroconf-domain)
   (tramp-set-completion-function
    "sftp" '((tramp-zeroconf-parse-workstation-device-names "")))
@@ -1708,8 +1723,9 @@ They are retrieved from the hal daemon."
    (tramp-synce-list-devices)))
 
 ;; Add completion function for SYNCE method.
-(tramp-set-completion-function
- "synce" '((tramp-synce-parse-device-names "")))
+(when tramp-gvfs-enabled
+  (tramp-set-completion-function
+   "synce" '((tramp-synce-parse-device-names ""))))
 
 (add-hook 'tramp-unload-hook
          (lambda ()
index 147113ba5a1e0e82ba5816bfa587ff90e927ec01..874e50fbfaabd7ea9c7e922754439239d35e3f3a 100644 (file)
@@ -419,7 +419,8 @@ as given in your `~/.profile'."
 
 ;;;###tramp-autoload
 (defcustom tramp-remote-process-environment
-  `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "TMOUT=0" "LC_ALL=C"
+  `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "TMOUT=0"
+    "LC_ALL=en_US.utf8" "LC_CTYPE=''"
     ,(format "TERM=%s" tramp-terminal-type)
     "EMACS=t" ;; Deprecated.
     ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
@@ -1784,21 +1785,21 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
   (with-parsed-tramp-file-name filename v1
     (with-parsed-tramp-file-name newname v2
       (let ((ln (when v1 (tramp-get-remote-ln v1))))
-       (when (and (not ok-if-already-exists)
+       (when (and (numberp ok-if-already-exists)
                   (file-exists-p newname)
-                  (not (numberp ok-if-already-exists))
-                  (y-or-n-p
+                  (yes-or-no-p
                    (format
                     "File %s already exists; make it a new name anyway? "
                     newname)))
          (tramp-error
-          v2 'file-error
-          "add-name-to-file: file %s already exists" newname))
+          v2 'file-error "add-name-to-file: file %s already exists" newname))
+       (when ok-if-already-exists (setq ln (concat ln " -f")))
        (tramp-flush-file-property v2 (file-name-directory v2-localname))
        (tramp-flush-file-property v2 v2-localname)
        (tramp-barf-unless-okay
         v1
-        (format "%s %s %s" ln (tramp-shell-quote-argument v1-localname)
+        (format "%s %s %s" ln
+                (tramp-shell-quote-argument v1-localname)
                 (tramp-shell-quote-argument v2-localname))
         "error with add-name-to-file, see buffer `%s' for details"
         (buffer-name))))))
@@ -1831,18 +1832,20 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
      'copy-file (list filename newname ok-if-already-exists keep-date)))))
 
 (defun tramp-sh-handle-copy-directory
-  (dirname newname &optional keep-date parents _copy-contents)
+  (dirname newname &optional keep-date parents copy-contents)
   "Like `copy-directory' for Tramp files."
   (let ((t1 (tramp-tramp-file-p dirname))
        (t2 (tramp-tramp-file-p newname)))
     (with-parsed-tramp-file-name (if t1 dirname newname) nil
-      (if (and (tramp-get-method-parameter method 'tramp-copy-recursive)
+      (if (and (not copy-contents)
+              (tramp-get-method-parameter method 'tramp-copy-recursive)
               ;; When DIRNAME and NEWNAME are remote, they must have
               ;; the same method.
               (or (null t1) (null t2)
                   (string-equal
                    (tramp-file-name-method (tramp-dissect-file-name dirname))
-                   (tramp-file-name-method (tramp-dissect-file-name newname)))))
+                   (tramp-file-name-method
+                    (tramp-dissect-file-name newname)))))
          ;; scp or rsync DTRT.
          (progn
            (setq dirname (directory-file-name (expand-file-name dirname))
@@ -1859,7 +1862,10 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
             'copy dirname newname keep-date))
        ;; We must do it file-wise.
        (tramp-run-real-handler
-        'copy-directory (list dirname newname keep-date parents)))
+        'copy-directory
+        (if copy-contents
+            (list dirname newname keep-date parents copy-contents)
+          (list dirname newname keep-date parents))))
 
       ;; When newname did exist, we have wrong cached values.
       (when t2
@@ -1983,14 +1989,14 @@ file names."
        ;; In case of `rename', we must flush the cache of the source file.
        (when (and t1 (eq op 'rename))
          (with-parsed-tramp-file-name filename v1
-           (tramp-flush-file-property v1 (file-name-directory localname))
-           (tramp-flush-file-property v1 localname)))
+           (tramp-flush-file-property v1 (file-name-directory v1-localname))
+           (tramp-flush-file-property v1 v1-localname)))
 
        ;; When newname did exist, we have wrong cached values.
        (when t2
          (with-parsed-tramp-file-name newname v2
-           (tramp-flush-file-property v2 (file-name-directory localname))
-           (tramp-flush-file-property v2 localname)))))))
+           (tramp-flush-file-property v2 (file-name-directory v2-localname))
+           (tramp-flush-file-property v2 v2-localname)))))))
 
 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
   "Use an Emacs buffer to copy or rename a file.
@@ -2008,7 +2014,7 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME."
     ;; `jka-compr-inhibit' to t.
     (let ((coding-system-for-write 'binary)
          (jka-compr-inhibit t))
-      (write-region (point-min) (point-max) newname)))
+      (write-region (point-min) (point-max) newname nil 'no-message)))
   ;; KEEP-DATE handling.
   (when keep-date (set-file-times newname (nth 5 (file-attributes filename))))
   ;; Set the mode.
@@ -2513,13 +2519,10 @@ This is like `dired-recursive-delete-directory' for Tramp files."
        (if full-directory-p "yes" "no"))
       ;; If `full-directory-p', we just say `ls -l FILENAME'.
       ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'.
-      ;; "--dired" returns byte positions.  Therefore, the file names
-      ;; must be encoded, which is guaranteed by "LC_ALL=en_US.utf8
-      ;; LC_CTYPE=''".
       (if full-directory-p
          (tramp-send-command
           v
-          (format "env LC_ALL=en_US.utf8 LC_CTYPE='' %s %s %s 2>/dev/null"
+          (format "%s %s %s 2>/dev/null"
                   (tramp-get-ls-command v)
                   switches
                   (if wildcard
@@ -2535,7 +2538,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
          (tramp-run-real-handler 'file-name-directory (list localname))))
        (tramp-send-command
         v
-        (format "env LC_ALL=en_US.utf8 LC_CTYPE='' %s %s %s 2>/dev/null"
+        (format "%s %s %s 2>/dev/null"
                 (tramp-get-ls-command v)
                 switches
                 (if (or wildcard
@@ -2927,7 +2930,8 @@ the result will be a local, non-Tramp, filename."
                      ;; epa-file gets confused.
                      (let (file-name-handler-alist
                            (coding-system-for-write 'binary))
-                       (write-region (point-min) (point-max) tmpfile)))
+                       (write-region
+                        (point-min) (point-max) tmpfile nil 'no-message)))
 
                  ;; If tramp-decoding-function is not defined for this
                  ;; method, we invoke tramp-decoding-command instead.
@@ -2937,7 +2941,8 @@ the result will be a local, non-Tramp, filename."
                    (let (file-name-handler-alist
                          (coding-system-for-write 'binary))
                      (with-current-buffer (tramp-get-buffer v)
-                       (write-region (point-min) (point-max) tmpfile2)))
+                       (write-region
+                        (point-min) (point-max) tmpfile2 nil 'no-message)))
                    (unwind-protect
                        (tramp-call-local-coding-command
                         loc-dec tmpfile2 tmpfile)
@@ -4362,7 +4367,7 @@ connection if a previous connection has died for some reason."
              (when (and p (processp p))
                (delete-process p))
              (setenv "TERM" tramp-terminal-type)
-             (setenv "LC_ALL" "C")
+             (setenv "LC_ALL" "en_US.utf8")
              (setenv "PROMPT_COMMAND")
              (setenv "PS1" tramp-initial-end-of-output)
              (let* ((target-alist (tramp-compute-multi-hops vec))
@@ -4472,7 +4477,7 @@ connection if a previous connection has died for some reason."
                          tramp-current-user   (or g-user   l-user)
                          tramp-current-host   (or g-host   l-host))
 
-                   ;; Replace login-args place holders.
+                   ;; Replace `login-args' place holders.
                    (setq
                     l-host (or l-host "")
                     l-user (or l-user "")
index fe7097edbde45e4972c1e2be55ff474f771b81a2..e322b6764a11d270acf45eb86e475f375a074ee9 100644 (file)
@@ -387,141 +387,152 @@ pass to the OPERATION."
        (throw 'tramp-action 'ok)))))
 
 (defun tramp-smb-handle-copy-directory
-  (dirname newname &optional keep-date parents _copy-contents)
+  (dirname newname &optional keep-date parents copy-contents)
   "Like `copy-directory' for Tramp files."
-  (setq dirname (expand-file-name dirname)
-       newname (expand-file-name newname))
-  (let ((t1 (tramp-tramp-file-p dirname))
-       (t2 (tramp-tramp-file-p newname)))
-    (with-parsed-tramp-file-name (if t1 dirname newname) nil
-      (with-tramp-progress-reporter
-         v 0 (format "Copying %s to %s" dirname newname)
-      (cond
-       ;; We must use a local temporary directory.
-       ((and t1 t2)
-       (let ((tmpdir
-              (make-temp-name
-               (expand-file-name
-                tramp-temp-name-prefix
-                (tramp-compat-temporary-file-directory)))))
-         (unwind-protect
-             (progn
-               (tramp-compat-copy-directory dirname tmpdir keep-date parents)
-               (tramp-compat-copy-directory tmpdir newname keep-date parents))
-           (tramp-compat-delete-directory tmpdir 'recursive))))
-
-       ;; We can copy recursively.
-       ((or t1 t2)
-       (when (and (file-directory-p newname)
-                  (not (string-equal (file-name-nondirectory dirname)
-                                     (file-name-nondirectory newname))))
-         (setq newname
-               (expand-file-name
-                (file-name-nondirectory dirname) newname))
-         (if t2 (setq v (tramp-dissect-file-name newname))))
-       (if (not (file-directory-p newname))
-           (make-directory newname parents))
-
-       (setq tramp-current-method (tramp-file-name-method v)
-             tramp-current-user (tramp-file-name-user v)
-             tramp-current-host (tramp-file-name-real-host v))
-
-       (let* ((real-user (tramp-file-name-real-user v))
-              (real-host (tramp-file-name-real-host v))
-              (domain    (tramp-file-name-domain v))
-              (port      (tramp-file-name-port v))
-              (share     (tramp-smb-get-share v))
-              (localname (file-name-as-directory
-                          (tramp-compat-replace-regexp-in-string
-                           "\\\\" "/" (tramp-smb-get-localname v))))
-              (tmpdir    (make-temp-name
-                          (expand-file-name
-                           tramp-temp-name-prefix
-                           (tramp-compat-temporary-file-directory))))
-              (args      (list tramp-smb-program
-                               (concat "//" real-host "/" share) "-E")))
-
-         (if (not (zerop (length real-user)))
-             (setq args (append args (list "-U" real-user)))
-           (setq args (append args (list "-N"))))
-
-         (when domain (setq args (append args (list "-W" domain))))
-         (when port   (setq args (append args (list "-p" port))))
-         (when tramp-smb-conf
-           (setq args (append args (list "-s" tramp-smb-conf))))
-         (setq args
-               (if t1
-                   ;; Source is remote.
-                   (append args
-                           (list "-D" (shell-quote-argument localname)
-                                 "-c" (shell-quote-argument "tar qc - *")
-                                 "|" "tar" "xfC" "-"
-                                 (shell-quote-argument tmpdir)))
-                 ;; Target is remote.
-                 (append (list "tar" "cfC" "-" (shell-quote-argument dirname)
-                               "." "|")
-                         args
-                         (list "-D" (shell-quote-argument localname)
-                               "-c" (shell-quote-argument "tar qx -")))))
-
-         (unwind-protect
-             (with-temp-buffer
-               ;; Set the transfer process properties.
-               (tramp-set-connection-property
-                v "process-name" (buffer-name (current-buffer)))
-               (tramp-set-connection-property
-                v "process-buffer" (current-buffer))
-
-               (when t1
-                 ;; The smbclient tar command creates always complete
-                 ;; paths.  We must emulate the directory structure,
-                 ;; and symlink to the real target.
-                 (make-directory
-                  (expand-file-name ".." (concat tmpdir localname)) 'parents)
-                 (make-symbolic-link
-                  newname (directory-file-name (concat tmpdir localname))))
-
-               ;; Use an asynchronous processes.  By this, password
-               ;; can be handled.
-               (let* ((default-directory tmpdir)
-                      (p (start-process-shell-command
-                          (tramp-get-connection-name v)
-                          (tramp-get-connection-buffer v)
-                          (mapconcat 'identity args " "))))
-
-                 (tramp-message
-                  v 6 "%s" (mapconcat 'identity (process-command p) " "))
-                 (tramp-set-connection-property p "vector" v)
-                 (tramp-compat-set-process-query-on-exit-flag p nil)
-                 (tramp-process-actions p v nil tramp-smb-actions-with-tar)
-
-                 (while (memq (process-status p) '(run open))
-                   (sit-for 0.1))
-                 (tramp-message v 6 "\n%s" (buffer-string))))
-
-           ;; Reset the transfer process properties.
-           (tramp-set-connection-property v "process-name" nil)
-           (tramp-set-connection-property v "process-buffer" nil)
-           (when t1 (delete-directory tmpdir 'recurse))))
-
-       ;; Handle KEEP-DATE argument.
-       (when keep-date
-         (set-file-times newname (nth 5 (file-attributes dirname))))
-
-       ;; Set the mode.
-       (unless keep-date
-         (set-file-modes newname (tramp-default-file-modes dirname)))
-
-       ;; When newname did exist, we have wrong cached values.
-       (when t2
-         (with-parsed-tramp-file-name newname nil
-           (tramp-flush-file-property v (file-name-directory localname))
-           (tramp-flush-file-property v localname))))
-
-       ;; We must do it file-wise.
-       (t
-       (tramp-run-real-handler
-        'copy-directory (list dirname newname keep-date parents))))))))
+  (if copy-contents
+      ;; We must do it file-wise.
+      (tramp-run-real-handler
+       'copy-directory (list dirname newname keep-date parents copy-contents))
+
+    (setq dirname (expand-file-name dirname)
+         newname (expand-file-name newname))
+    (let ((t1 (tramp-tramp-file-p dirname))
+         (t2 (tramp-tramp-file-p newname)))
+      (with-parsed-tramp-file-name (if t1 dirname newname) nil
+       (with-tramp-progress-reporter
+           v 0 (format "Copying %s to %s" dirname newname)
+         (cond
+          ;; We must use a local temporary directory.
+          ((and t1 t2)
+           (let ((tmpdir
+                  (make-temp-name
+                   (expand-file-name
+                    tramp-temp-name-prefix
+                    (tramp-compat-temporary-file-directory)))))
+             (unwind-protect
+                 (progn
+                   (make-directory tmpdir)
+                   (tramp-compat-copy-directory
+                    dirname tmpdir keep-date 'parents)
+                   (tramp-compat-copy-directory
+                    (expand-file-name (file-name-nondirectory dirname) tmpdir)
+                    newname keep-date parents))
+               (tramp-compat-delete-directory tmpdir 'recursive))))
+
+          ;; We can copy recursively.
+          ((or t1 t2)
+           (when (and (file-directory-p newname)
+                      (not (string-equal (file-name-nondirectory dirname)
+                                         (file-name-nondirectory newname))))
+             (setq newname
+                   (expand-file-name
+                    (file-name-nondirectory dirname) newname))
+             (if t2 (setq v (tramp-dissect-file-name newname))))
+           (if (not (file-directory-p newname))
+               (make-directory newname parents))
+
+           (setq tramp-current-method (tramp-file-name-method v)
+                 tramp-current-user (tramp-file-name-user v)
+                 tramp-current-host (tramp-file-name-real-host v))
+
+           (let* ((real-user (tramp-file-name-real-user v))
+                  (real-host (tramp-file-name-real-host v))
+                  (domain    (tramp-file-name-domain v))
+                  (port      (tramp-file-name-port v))
+                  (share     (tramp-smb-get-share v))
+                  (localname (file-name-as-directory
+                              (tramp-compat-replace-regexp-in-string
+                               "\\\\" "/" (tramp-smb-get-localname v))))
+                  (tmpdir    (make-temp-name
+                              (expand-file-name
+                               tramp-temp-name-prefix
+                               (tramp-compat-temporary-file-directory))))
+                  (args      (list tramp-smb-program
+                                   (concat "//" real-host "/" share) "-E")))
+
+             (if (not (zerop (length real-user)))
+                 (setq args (append args (list "-U" real-user)))
+               (setq args (append args (list "-N"))))
+
+             (when domain (setq args (append args (list "-W" domain))))
+             (when port   (setq args (append args (list "-p" port))))
+             (when tramp-smb-conf
+               (setq args (append args (list "-s" tramp-smb-conf))))
+             (setq args
+                   (if t1
+                       ;; Source is remote.
+                       (append args
+                               (list "-D" (shell-quote-argument localname)
+                                     "-c" (shell-quote-argument "tar qc - *")
+                                     "|" "tar" "xfC" "-"
+                                     (shell-quote-argument tmpdir)))
+                     ;; Target is remote.
+                     (append (list "tar" "cfC" "-"
+                                   (shell-quote-argument dirname) "." "|")
+                             args
+                             (list "-D" (shell-quote-argument localname)
+                                   "-c" (shell-quote-argument "tar qx -")))))
+
+             (unwind-protect
+                 (with-temp-buffer
+                   ;; Set the transfer process properties.
+                   (tramp-set-connection-property
+                    v "process-name" (buffer-name (current-buffer)))
+                   (tramp-set-connection-property
+                    v "process-buffer" (current-buffer))
+
+                   (when t1
+                     ;; The smbclient tar command creates always
+                     ;; complete paths.  We must emulate the
+                     ;; directory structure, and symlink to the real
+                     ;; target.
+                     (make-directory
+                      (expand-file-name
+                       ".." (concat tmpdir localname)) 'parents)
+                     (make-symbolic-link
+                      newname (directory-file-name (concat tmpdir localname))))
+
+                   ;; Use an asynchronous processes.  By this,
+                   ;; password can be handled.
+                   (let* ((default-directory tmpdir)
+                          (p (start-process-shell-command
+                              (tramp-get-connection-name v)
+                              (tramp-get-connection-buffer v)
+                              (mapconcat 'identity args " "))))
+
+                     (tramp-message
+                      v 6 "%s" (mapconcat 'identity (process-command p) " "))
+                     (tramp-set-connection-property p "vector" v)
+                     (tramp-compat-set-process-query-on-exit-flag p nil)
+                     (tramp-process-actions p v nil tramp-smb-actions-with-tar)
+
+                     (while (memq (process-status p) '(run open))
+                       (sit-for 0.1))
+                     (tramp-message v 6 "\n%s" (buffer-string))))
+
+               ;; Reset the transfer process properties.
+               (tramp-set-connection-property v "process-name" nil)
+               (tramp-set-connection-property v "process-buffer" nil)
+               (when t1 (delete-directory tmpdir 'recurse))))
+
+           ;; Handle KEEP-DATE argument.
+           (when keep-date
+             (set-file-times newname (nth 5 (file-attributes dirname))))
+
+           ;; Set the mode.
+           (unless keep-date
+             (set-file-modes newname (tramp-default-file-modes dirname)))
+
+           ;; When newname did exist, we have wrong cached values.
+           (when t2
+             (with-parsed-tramp-file-name newname nil
+               (tramp-flush-file-property v (file-name-directory localname))
+               (tramp-flush-file-property v localname))))
+
+          ;; We must do it file-wise.
+          (t
+           (tramp-run-real-handler
+            'copy-directory (list dirname newname keep-date parents)))))))))
 
 (defun tramp-smb-handle-copy-file
   (filename newname &optional ok-if-already-exists keep-date
@@ -631,7 +642,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
   (directory &optional full match nosort)
   "Like `directory-files' for Tramp files."
   (let ((result (mapcar 'directory-file-name
-                       (file-name-all-completions "" directory))))
+                       (file-name-all-completions "" directory)))
+       res)
     ;; Discriminate with regexp.
     (when match
       (setq result
@@ -642,12 +654,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
     (when full
       (setq result
            (mapcar
-            (lambda (x) (expand-file-name x directory))
+            (lambda (x) (format "%s/%s" directory x))
             result)))
     ;; Sort them if necessary.
     (unless nosort (setq result (sort result 'string-lessp)))
-    ;; That's it.
-    result))
+    ;; Remove double entries.
+    (dolist (elt result res)
+      (add-to-list 'res elt 'append))))
 
 (defun tramp-smb-handle-expand-file-name (name &optional dir)
   "Like `expand-file-name' for Tramp files."
@@ -915,6 +928,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for Tramp files."
   (setq filename (expand-file-name filename))
+  (unless switches (setq switches ""))
   (if full-directory-p
       ;; Called from `dired-add-entry'.
       (setq filename (file-name-as-directory filename))
@@ -1432,9 +1446,6 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
   "Like `write-region' for Tramp files."
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
-    (unless (eq append nil)
-      (tramp-error
-        v 'file-error "Cannot append to file using Tramp (`%s')" filename))
     ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
     (when (and (not (featurep 'xemacs))
               confirm (file-exists-p filename))
@@ -1447,6 +1458,8 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
     (tramp-flush-file-property v localname)
     (let ((curbuf (current-buffer))
          (tmpfile (tramp-compat-make-temp-file filename)))
+      (when (and append (file-exists-p filename))
+       (copy-file filename tmpfile 'ok))
       ;; We say `no-message' here because we don't want the visited file
       ;; modtime data to be clobbered from the temp file.  We call
       ;; `set-visited-file-modtime' ourselves later on.
@@ -1718,7 +1731,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
   ;; When we are not logged in yet, we return nil.
   (if (and (tramp-smb-get-share vec)
           (let ((p (tramp-get-connection-process vec)))
-            p (processp p) (memq (process-status p) '(run open))))
+            (and p (processp p) (memq (process-status p) '(run open)))))
       (with-tramp-connection-property
          (tramp-get-connection-process vec) "stat-capability"
        (tramp-smb-send-command vec "stat \"/\""))))
index 2cbaf4a1636228c2f52ecfdebf635dd50b7b1ce1..d0989e79cd3f35892dadf63426057a62fc623c27 100644 (file)
@@ -848,7 +848,7 @@ Derived from `tramp-postfix-host-format'.")
    "\\(?:" "\\("   tramp-method-regexp "\\)" tramp-postfix-method-regexp "\\)?"
    "\\(?:" "\\("   tramp-user-regexp   "\\)" tramp-postfix-user-regexp   "\\)?"
    "\\("   "\\(?:" tramp-host-regexp   "\\|"
-                  tramp-prefix-ipv6-regexp  tramp-ipv6-regexp
+                  tramp-prefix-ipv6-regexp  "\\(?:" tramp-ipv6-regexp "\\)?"
                                             tramp-postfix-ipv6-regexp "\\)"
           "\\(?:" tramp-prefix-port-regexp  tramp-port-regexp "\\)?" "\\)?")
 "Regular expression matching a Tramp file name between prefix and postfix.")
@@ -884,8 +884,8 @@ See also `tramp-file-name-regexp'.")
 ;;;###autoload
 (defconst tramp-file-name-regexp-unified
   (if (memq system-type '(cygwin windows-nt))
-      "\\`/\\([^[/|:]\\{2,\\}\\|[^/|]\\{2,\\}]\\):"
-    "\\`/\\([^[/|:]+\\|[^/|]+]\\):")
+      "\\`/[^/|:]\\{2,\\}[^/|]*:"
+    "\\`/[^/|:][^/|]*:")
   "Value for `tramp-file-name-regexp' for unified remoting.
 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
 Tramp.  See `tramp-file-name-structure' for more explanations.
@@ -2020,8 +2020,8 @@ ARGS are the arguments OPERATION has been called with."
                  'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail))
     (save-match-data
       (cond
-       ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args))
-       ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args))
+       ((tramp-tramp-file-p (nth 0 args)) (nth 0 args))
+       ((tramp-tramp-file-p (nth 1 args)) (nth 1 args))
        (t (buffer-file-name (current-buffer))))))
    ;; START END FILE.
    ((eq operation 'write-region)
@@ -3141,9 +3141,8 @@ User is always nil."
       (let ((tramp-message-show-message (not nomessage)))
        (with-tramp-progress-reporter v 0 (format "Loading %s" file)
          (let ((local-copy (file-local-copy file)))
-           ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil.
            (unwind-protect
-               (load local-copy noerror t t)
+               (tramp-compat-load local-copy noerror t nosuffix must-suffix)
              (delete-file local-copy)))))
       t)))
 
@@ -3249,7 +3248,9 @@ User is always nil."
       ;; "/m:h:~" does not work for completion.  We use "/m:h:~/".
       (when (string-match "~$" filename)
        (setq filename (concat filename "/"))))
-    (tramp-run-real-handler 'substitute-in-file-name (list filename))))
+    ;; We do not want to replace environment variables, again.
+    (let (process-environment)
+      (tramp-run-real-handler 'substitute-in-file-name (list filename)))))
 
 (defun tramp-handle-unhandled-file-name-directory (_filename)
   "Like `unhandled-file-name-directory' for Tramp files."
index 9d8ffed4c9c8f57ddd10df0b11a0e342caa72062..acf79a284c06e04221d696ed60e4f27c7ce8240a 100644 (file)
@@ -102,14 +102,14 @@ returned.
 
 If no key-value pair matching KEY could be found in ALIST, or ALIST is
 nil then nil is returned.  ALIST is not altered."
-  (defvar copy)
-  (let ((copy (copy-alist alist)))
+  (defvar assoc--copy)
+  (let ((assoc--copy (copy-alist alist)))
     (cond ((null alist) nil)
-         ((progn (asort 'copy key)
-                 (anot-head-p copy key)) nil)
-         ((cdr (car copy)))
+         ((progn (asort 'assoc--copy key) ; dynamic binding
+                 (anot-head-p assoc--copy key)) nil)
+         ((cdr (car assoc--copy)))
          (keynil-p nil)
-         ((car (car copy)))
+         ((car (car assoc--copy)))
          (t nil))))
 
 
index 019fa8a358d816ee09e259224e15f15b0c4b30d8..a9d2731892f870e942f22782e70fb28a81f6ddda 100644 (file)
+2013-11-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Spelling fixes.
+       * ob-python.el (org-babel-python-with-earmuffs):
+       Rename from org-babel-python-with-earmufs.  All uses changed.
+       (org-babel-python-without-earmuffs):
+       Rename from org-babel-python-without-earmufs.  All uses changed.
+
+2013-11-12  Bastien Guerry  <bzg@gnu.org>
+
+       * org-agenda.el (org-agenda-set-restriction-lock): Autoload.
+
+2013-11-12  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       Address some byte-compiler warnings.
+       * ob-abc.el (org-babel-expand-body:abc): Use dolist.
+       (org-babel-execute:abc): Fix regexp quoting.
+       * ob-calc.el (org--var-syms): Rename from `var-syms'.
+       * ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
+       * ob-table.el (sbe): Move debug declaration.
+       * org-clock.el (org--msg-extra): Rename from `msg-extra'.
+       * org.el (org-version): Avoid var name starting with _.
+       (org-inhibit-startup, org-called-with-limited-levels)
+       (org-link-search-inhibit-query, org-time-was-given)
+       (org-end-time-was-given, org-def, org-defdecode, org-with-time):
+       * org-colview.el (org-agenda-overriding-columns-format):
+       * org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
+       (org-agenda-show-log-scoped):
+       * ob-python.el (py-which-bufname, python-shell-buffer-name):
+       * ob-haskell.el (org-export-copy-to-kill-ring):
+       * ob-exp.el (org-link-search-inhibit-query):
+       * ob-R.el (ess-eval-visibly-p):
+       * ob-core.el (org-src-window-setup): Declare before use.
+       (org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
+       * ox-odt.el (org-odt-hfy-face-to-css):
+       * org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
+       * org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
+       (org-bibtex-check):
+       * ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
+       (org-babel-tangle-single-block, org-babel-tangle-comment-links):
+       * ob-table.el (sbe):
+       * ob-sqlite.el (org-babel-sqlite-expand-vars):
+       * ob-sql.el (org-babel-sql-expand-vars):
+       * ob-shen.el (org-babel-execute:shen):
+       * ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
+       * ob-scala.el (org-babel-scala-evaluate):
+       * ob-ruby.el (org-babel-ruby-table-or-string)
+       (org-babel-ruby-evaluate):
+       * ob-python.el (org-babel-python-table-or-string)
+       (org-babel-python-evaluate-external-process)
+       (org-babel-python-evaluate-session):
+       * ob-picolisp.el (org-babel-execute:picolisp):
+       * ob-perl.el (org-babel-perl-evaluate):
+       * ob-maxima.el (org-babel-execute:maxima):
+       * ob-lisp.el (org-babel-execute:lisp):
+       * ob-java.el (org-babel-execute:java):
+       * ob-io.el (org-babel-io-evaluate):
+       * ob-haskell.el (org-babel-execute:haskell):
+       * ob-fortran.el (org-babel-execute:fortran):
+       * ob-exp.el (org-babel-exp-code):
+       * ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
+       * ob-ditaa.el (org-babel-execute:ditaa):
+       * ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
+       (org-babel-parse-header-arguments, org-babel-reassemble-table)
+       (org-babel-goto-src-block-head, org-babel-mark-block)
+       (org-babel-expand-noweb-references, org-babel-script-escape)
+       (org-babel-process-file-name):
+       * ob-clojure.el (org-babel-execute:clojure):
+       * ob-calc.el (org-babel-execute:calc):
+       * ob-awk.el (org-babel-execute:awk):
+       * ob-abc.el (org-babel-execute:abc):
+       * ob-R.el (org-babel-expand-body:R):
+       * ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).
+
+2013-11-12  Glenn Morris  <rgm@gnu.org>
+
+       * ox-html.el (org-html-scripts): Add 2013 to copyright years.
+       (org-html-infojs-template): Copyright holder to FSF.
+
+2013-11-12  Aaron Ecay  <aaronecay@gmail.com>
+
+       * ox-latex.el (org-latex-inline-image-rules): Add "svg" to
+       supported filetypes.
+       (org-latex--inline-image): Implement SVG files inclusion.
+       (org-latex-headline): Don’t insert alternate title if identical to
+       regular one.
+
+       * ob-python.el: Update the arglist passed to `declare-function'
+       for `run-python'.
+
+       * ob-tangle.el (org-babel-tangle): Use `light' argument to
+       `org-babel-get-src-block-info'.
+
+       * ob-core.el (org-babel-execute-src-block): Return nil in case of
+       `:results none'.  Also run `org-babel-after-execute-hook' in this
+       circumstance.
+
+       * org-id.el (org-id-locations-save): Bind print-(level,length) to
+       nil in this function.
+
+       * ob-R.el (org-babel-R-graphics-devices): New defvar.
+       (org-babel-R-construct-graphics-device-call): Use it instead of a
+       hard-coded list of graphics devices.
+
+       * ob-core.el (org-babel-when-in-src-block): New macro.
+       (org-babel-execute-src-block-maybe)
+       (org-babel-expand-src-block-maybe)
+       (org-babel-load-in-session-maybe, org-babel-pop-to-session-maybe):
+       Use it.
+       (org-babel-execute-src-block): Use `copy-tree' to prevent setf
+       from modifying users variables withing let-bound `info' variable.
+
+       * ob-exp.el (org-export-babel-evaluate): Add a 'inline-only
+       option.
+       (org-babel-exp-results): Implement 'inline-only for
+       `org-export-babel-evaluate'.
+
+       * org.el (org-edit-special): Use prefix arg.
+
+       * ob-awk.el (org-babel-expand-body:awk, ob-picolisp.el)
+       (org-babel-expand-body:picolisp): Remove optional arg.
+
+       * ob-R.el (org-babel-R-initiate-session): Handle case where the
+       session buffer exists, but does not have a live process.
+       (org-babel-R-construct-graphics-device-call): Change file
+       extension of tikz graphics files to .tikz.
+
+       * org-src.el (org-edit-src-exit): Don't modify the undo list when
+       inserting the code.
+
+       * ox-latex.el (org-latex-plain-text): Properly escape "~" for
+       LaTeX export.
+       (org-latex-image-default-option): Change default value to "".
+       (org-latex-image-default-width, org-latex-image-default-height):
+       New variables.
+       (org-latex-inline-image-rules): Make .tikz files as exportable
+       with LaTeX.
+       (org-latex--inline-image): Support tikz images.  Also support
+       separate :width and :height parameters for images.
+
+       * org-bibtex.el (org-bibtex-ask): Use `visual-line-mode' instead
+       of longlines-mode.
+
+2013-11-12  Abdó Roig-Maranges  <abdo.roig@gmail.com>
+
+       * org.el (org-format-latex): Do not re-generate a LaTeX preview if
+       the image already exists.
+
+       * org-agenda.el (org-agenda-search-view-max-outline-level): New
+       option to define the max level for the entries shown by the search
+       view.  A value of 1 means to show the top parent of the entries.
+
+       * org.el (org-create-formula-image-with-dvipng): Fix bug that made
+       this function fail with no :foreground and :background attributes
+       set, due to bad handling of "Transparent" color.  Fix bug when
+       colors are not `default'.
+       (org-format-latex-options): Add `auto' to docstring.
+       (org-format-latex): Get face colors at point and put them inside
+       opt.
+       (org-create-formula-image-with-imagemagick): Fix bug when handling
+       "Transparent" bg color.
+       (org-dvipng-color-format): Same as `org-latex-color-format' for
+       dvipng-style color specification.
+
+2013-11-12  Achim Gratz  <Stromeko@Stromeko.DE>
+
+       * ob-core.el (org-babel-check-confirm-evaluate): Return result of
+       evaluating the function pointed to by `org-confirm-babel-evaluate'
+       when it is a functionp and its value as a variable otherwise.
+       (org-babel-get-rownames, org-table.el)
+       (org-table-transpose-table-at-point): Replace the inadvertent use
+       of mapcar* (from cl) by plain mapcar and direct cons manipulation.
+       (org-babel-params-from-properties): Use
+       `org-babel-current-src-block-location' for evaluating new-style
+       header-argument properties.  Remove superfluous save-match-data
+       clauses.  Comment which properties get evaluated where.
+       (org-babel-insert-header-arg, org-babel-parse-src-block-match):
+       Replace `if' with empty else part by `when' for readability.
+       (org-babel-params-from-properties): Inquire for language specific
+       and default header properties.  Language specific header
+       properties take precedence over default header properties and
+       old-style header property specifications.
+
+       * org.el (org-re-property): Re-implement using full regex for
+       `org-re-property'.  Add optional argument LITERAL to flag when
+       PROPERTY should to be regex-quoted.  Move before definition of
+       `org-re-property'.
+       (org-re-property-keyword): Remove, functionality is subsumed by
+       `org-re-property'.
+       (org-property-re): Define using `org-re-property'.  Improve
+       definition so that this regex can be
+       (org-entry-get, org-property-values): Adjust match number for
+       PROPVAL.  (org-entry-put): Use `org-re-property' instead of
+       `org-re-property-keyword'.
+       used in all situations.  Extend docstring with explanation of
+       matching groups.
+       (org-at-property-p): Implement using `org-element-at-point'.
+       (org-entry-properties, org-buffer-property-keys, org-indent-line):
+       Use `org-property-re' and adjust match group numbers accordingly.
+
+       * org-compat.el (define-obsolete-variable-alias)
+       (define-obsolete-function-alias): Actually remove the third (and
+       any following) argument from the argument list before calling the
+       advised function.  Extend eval-and-compile clause and add advices
+       for functions that have different parameter lists in XEmacs. Add
+       variable definitions that XEmacs lacks .
+
+       * ob-fortran.el (org-every): Declare.
+
+       * org-element.el (org-element-node-property-parser): Use
+       `org-property-re' and adjust match group numbers accordingly.
+       Move `looking-at' out of the let clause to not rely on the
+       unspecified evaluation order inside the let.
+
+       * ob-eval.el, ob.el, org-macro.el, org-mhe.el: Require org-macs
+       and org-compat as necessary.
+
+       * ob-tangle.el (org-edit-special, org-store-link)
+       (org-open-link-from-string): Declare functions.
+
+       * org-macs.el (declare-function): Define macro to use autoload
+       instead for XEmacs.
+
+       * ox-html.el, ox-odt.el: XEmacs does not have table.el, so use
+       'noerror on the require form.
+
+       * ox-texinfo.el (org-texinfo-table-column-widths): Fix spliced
+       argument list that XEmacs complains about by adding parenthesis.
+
+       * ob-octave.el (org-babel-octave-initiate-session): If octave-inf
+       can't be loaded, try octave instead before giving up.  Emacs
+       24.3.50 and upwards replaces octave-inf with just plain octave.
+
+       * org-id.el (org-id-update-id-locations): Autoload interactive
+       function.
+
+       * ob-core.el (org-babel-parse-inline-src-block-match):
+       * ob-exp.el (org-babel-exp-src-block): Give header arguments from
+       properties priority over default header arguments.
+
+       * ob-sh.el (org-babel-sh-var-to-sh): When detecting a table, the
+       first line could be the symbol `hline' rather than a list of table
+       cells, so check for that as well.
+
+       * org.el (org-table-clean-did-remove-column):
+       * org-table.el (org-table-clean-did-remove-column): Move defvar,
+       this dynamic variable is only used in org-table.
+
+       * org-table.el (org-table-colgroup-info): Remove unused defvar for
+       `org-table-colgroup-info'.
+       (org-table-clean-before-export): Let-bind regular expression
+       strings and remove unused matching group.  Use
+       `org-table-clean-did-remove-column' in cond statement rather than
+       branching via if to avoid code duplication.  Remove the code
+       associated with the removed `org-table-colgroup-info'.
+       (orgtbl-export): Remove unused internal function.
+
+       * org-macro.el (org-macro-expand): Do not try to interpret the
+       macro replacement text as a regex so that escaped backslashes and
+       commas in macro arguments will be interpreted correctly.
+
+       * ob-perl.el (org-babel-perl-wrapper-method): Select output handle
+       only after evaluation so that output is not mixed into results
+       eavaluation.
+       (org-babel-perl-evaluate): Fix the handling of results for
+       ":results output" to also parse tables.  Use the same lambda
+       construction as in ob-sh.el to avoid code duplication.
+
+       * ob-exp.el (org-babel-exp-results, org-babel-lob-execute):
+       Suppress user confirmation of the emacs-lisp wrapper execution
+       around a lob call.
+
+       * ob-perl.el (org-babel-perl-wrapper-method): Use TAB as separator
+       for table results as expected by
+       `org-babel-import-elisp-from-file´.
+
+       * ob-core.el (org-babel-number-p): String match for any number
+       moved first so that the match data for the length check does not
+       become corrupted.
+       (org-babel-confirm-evaluate-answer-no): Dynamically scoped
+       variable, if bound non-nil the confirmation dialog will not be
+       initiated and denial of evaluation is assumed.
+       (org-babel-check-confirm-evaluate): New macro to establish
+       bindings based on INFO.
+       (org-babel-check-evaluate): New defsubst that checks if the
+       evaluation of a code block is disabled.  Refactors the first part
+       of the original function `org-babel-confirm-evaluate´.
+       (org-babel-confirm-evaluate): New defsubst that checks if the user
+       should be queried and returns the answer.  Keeps the second part
+       of the original function `org-babel-confirm-evaluate´.
+       Re-implement using bindings for common subexpressions.
+       (org-babel-execute-src-block): Do not ask for confirmation if the
+       cached result is current.
+       (org-babel-call-process-region-original): Change declaration into
+       definition with nil initial value at the beginning of the file and
+       drop the later definition.  Add comment that the dynamic scoping
+       of this variable is done for tramp.
+
+       * org-table.el (org-table-eval-formula): The condition-case to
+       check for must be "error", not "user-error".
+
+       * ob-perl.el (org-babel-execute:perl): Pass `result-params´
+       through to `org-babel-perl-evaluate´.
+       (org-babel-variable-assignments:perl): Add "my" to variable
+       declaration so that it becomes compatible with "use strict;".  Use
+       new internal formatting function `org-babel-perl--var-to-perl´.
+       (org-babel-perl--var-to-perl): New internal function, uses Perl
+       non-interpolating quoting on the string that defines the variable
+       to suppress spurious interpretation of it as Perl syntax.
+       (org-babel-perl-wrapper-method): Use a block and declare all
+       variables as "my", also use Perl quoting throughout.  Redirect
+       STDOUT to the temporary file so that simply "print" will put the
+       results there.  Check the return value and output in table form if
+       it is an ARRAY ref, otherwise print it without a final newline.
+       (org-babel-perl-preface): Content of this variable is prepended to
+       body before invocation of perl.  Rename input parameter body to
+       ibody and let-bind body to concatentation of
+       `org-babel-perl-preface' and ibody.  Implement results
+       interpretation so that tables are easier to produce.
+
+       * ob-eval.el (org-babel-eval): Use simplified version of
+       `org-babel--shell-command-on-region´, we are the only caller of
+       this function.
+       (org-babel--shell-command-on-region): Replace
+       `org-babel-shell-command-on-region´ with a much more simplified
+       internal version, remove superfluous DOCSTRING and interactive
+       clause, strip out all conditionals which were never used.  Prevent
+       deletion of temporary input file to aid debugging when the symbol
+       `org-babel--debug-input´ is bound and has non-nil value.
+
+       * ob-tangle.el (org-babel-tangle): Do not change signature, a nil
+       arg is even documented in the manual.
+
+       * org-src.el: Change declaration of `org-babel-tangle´ to "arg"
+       for first argument.
+
+       * ob-core.el (org-babel-execute-src-block): Add binding for
+       merged-params to avoid multiple evaluation of
+       `org-babel-merge-params´.  Rename cache? to cache-p, add binding
+       for cache-current-p and use it.  Do not run
+       `org-babel-confirm-evaluate´ if source block has a cache and the
+       cache value is current (there is no evaluation involved in this
+       case).
+
+       * org.el (org-current-time): Replace call to obsolete function
+       `time-to-seconds´ with a call to compatibility function
+       `org-float-time´.
+
+       * org-compat.el (user-emacs-directory): If not bound, define as an
+       alias to `user-init-directory´ so that XEmacs continues to be
+       happy with Org.
+
+       * org-macs.el: New macro to allow the 5-argument form of load to
+       be used where possible without breaking compatibility with XEmacs.
+
+       * org.el (org-version, org-reload): Use
+       `org-load-noerror-mustsuffix´ instead of adding a fifth argument
+       to load directly.  Guard against undefined variable load-suffixes,
+       which doesn't exist in XEmacs.
+
+       * org.el: Use
+       `org-define-obsolete-{function,variable}-alias´instead of
+       `define-obsolate{function,variable}-alias´.
+
+       * org-compat.el (user-error): Defalias to `error´ for Emacsen that
+       don't have it.
+
+       * ob-python.el (org-babel-python-hline-to)
+       (org-babel-python-None-to): Specify customize group as 'org-babel
+       and widget type as 'string.
+
+       * ob.el (org-babel-result-cond): Macro expansion needs to unquote
+       formal parameter `result-params´.
+
+       * org.el (org-reload): Major rewrite.
+
+       * org.el (org-clock-get-last-clock-out-time): Declare function.
+
+2013-11-12  Alan Schmitt  <alan.schmitt@polytechnique.org>
+
+       * ob-ocaml.el (org-babel-prep-session:ocaml): Use
+       `save-window-excursion' around the code starting the tuareg
+       process.
+       (org-babel-ocaml-command): New option to specify the name of the
+       toplevel to run.
+       (org-babel-prep-session:ocaml): Directly call
+       `tuareg-run-process-if-needed' with `org-babel-ocaml-command' as
+       argument.
+       (org-babel-execute:ocaml): Always append ";;" at the end of the
+       expression before sending it to the toplevel.  Do not remove the
+       type information if "verbatim" is a results parameter of the code
+       block.
+       (org-babel-ocaml-parse-output): Make sure the complete type is
+       taken into account when matching against known types.
+
+       * org-faces.el (org-footnote): Fix docstring.
+
+2013-11-12  Andreas Leha  <andreas@lehas.net>
+
+       * ob-latex.el (org-babel-execute:latex): Add a tizk option that
+       copies the body of the block into a tikz file.
+
+2013-11-12  Arun Persaud  <apersaud@lbl.gov>
+
+       * org-agenda.el (org-agenda-prefix-format): Add documentation for
+       the new %b option.
+       (org-prefix-has-breadcrumbs): Add flag, `t' when %b is set.
+       (org-agenda-format-item): Add breadcrumbs if requested.
+       (org-compile-prefix-format): Add compiled information for
+       breadcrumbs, add %b option.
+
+2013-11-12  Aurélien Aptel  <aurelien.aptel@gmail.com>  (tiny change)
+
+       * ox-html.el (org-html-code, org-html-verbatim): Remove fancy
+       string replacements for code and verbatim text when exporting to
+       HTML.
+
+2013-11-12  Bastien Guerry  <bzg@gnu.org>
+
+       * org.el (org-align-tags-here): Fix bug: move to the correct
+       position.
+       (org-agenda-prepare-buffers): Restore the point position.
+       (org-insert-link): Don't remove brackets when they belong to a
+       timestamp in a headline.
+
+       * org-capture.el (org-capture-refile): Don't finalize prematurely.
+       (org-capture): Store :return-to-wconf earlier.
+       (org-capture-place-template): Don't store :return-to-wconf when
+       called from a capture template using `function', rely on the early
+       :return-to-wconf value store from `org-capture'.
+
+       * org-compat.el (org-move-to-column): New argument
+       `ignore-invisible' to turn on `buffer-invisibility-spec'.
+
+       * org-agenda.el (org-agenda-show-new-time): Ignore invisible text
+       when inserting the new time as a text property.
+       (org-agenda-filter-make-matcher): When filtering tags and hitting
+       space, filter out entries with tags, only keep those without tags.
+       (org-agenda-drag-line-forward, org-agenda-drag-line-backward): Fix
+       bugs: don't drag lines without text and don't drag lines
+       before/after hidden lines.
+
+       * ox-odt.el (org-odt-table-style-format): Use %s for inserting the
+       rel-width property as a string.
+       (org-odt-template): Fall back on a string for :rel-width.
+
+       * org.el (org-directory, org-default-notes-file)
+       (org-reverse-note-order): Don't use the `org-remember'
+       customization group.
+       (org-require-autoloaded-modules): Don't require
+       `org-remember'.
+
+       * org-capture.el: Update commentary section to reflect the fact
+       that org-remember.el is not used anymore.
+
+       * org.el (org-babel-load-file): Set `exported-file' correctly, in
+       case the file as been tangled using a buffer-local value.
+
+       * ob-tangle.el (org-babel-tangle-file): Return the list of tangled
+       files.
+
+       * ox-org.el (org-org-publish-to-org): When htmlizing an .org file,
+       ensure to show all headings and all blocks before fontifying.
+
+       * ob-shen.el (org-babel-ruby-var-to-ruby): Declare.
+
+       * ox.el: Fix comment: remove reference to the obsolete variable
+       `org-export-language-setup'.
+
+       * org.el (org-set-regexps-and-options-for-tags): Fix concatenation
+       of the tags list.
+
+       * ox-odt.el (org-odt-pixels-per-inch): Use 96.0 as the default.
+
+       * org.el (org-refile): With a numeric prefix argument of `3',
+       emulate (setq org-refile-keep t) and copy the subtree to the
+       target location, don't delete it.
+       (org-set-regexps-and-options-for-tags): Fix the setting of tag
+       groups when relying on `org-tag-alist', not on tags directly set
+       in the buffer with the #+TAGS option.
+
+       * org-agenda.el (org-agenda-archive-with): Save window excursion.
+
+       * org.el (org-forward-element, org-backward-element): Throw a
+       message instead of an error when trying to move from a position
+       where there is no element.
+       (org-clock-is-active): Fix docstring.
+
+       * org-list.el (org-sort-list): Use `x' instead of `c' for sorting
+       plain list by checked status.
+
+       * org.el (org-structure-template-alist): Fix custom type and
+       default value.
+       (org-set-regexps-and-options-for-tags): Enhance docstring.
+       (org-set-regexps-and-options): Make sure not to add
+       `org-tag-alist' twice when setting this variable through et
+       #+setupfile: directive.
+       (org-tags-expand): Use `with-syntax-table'.
+
+       * org-list.el (org-sort-list): Implement sorting by "checked"
+       status for check lists.
+
+       * org-table.el (org-table-sum): Fix rounding error when summing
+       times.
+
+       * ob-scheme.el (org-babel-scheme-execute-with-geiser): Fix code
+       typo.  Add declarations.
+
+       * ox-html.el (org-html-link-use-abs-url): New option.
+       (org-html-link): Use it to prepend relative links with the value
+       of HTML_LINK_HOME, when defined.
+
+       * org.el (org-refile): Fix refiling the active region within an
+       list.  Don't store the last refiled subtree in the kill ring.
+
+       * org.el (org-mode-map): Remap `forward-paragraph' and
+       `backward-paragraph' to `org-forward-element' and
+       `org-backward-element'.
+
+       * ox-html.el (org-html-begin-plain-list): New parameter
+       `ordered-num' to tell whether the list is ordered numerically.
+       (org-html-plain-list): Handle alphabetical ordered list.
+
+       * org-agenda.el (org-batch-agenda): Let-bind `org-agenda-sticky'
+       to nil during batch export.
+
+       * org.el (org-copy-subtree): Fix typo in docstring.
+       (org-scan-tags): Don't disable `case-fold-search' too early.
+
+       * org-agenda.el (org-agenda-skip-eval): Fix typo in docstring.
+
+       * org-capture.el (org-capture-set-target-location): Don't throw an
+       error when `org-time-was-given' is not bound.
+
+       * org-clock.el (org-clock-modify-effort-estimate): Clarify
+       docstring.
+
+       * org.el (org-set-regexps-and-options-for-tags): Return a list
+       with tag-related variables.
+       (org-set-regexps-and-options): Append tags from a setup file to
+       the local tags of the file.
+       (org-agenda-prepare-buffers): Set tags from a setup file by
+       calling `org-set-regexps-and-options' when necessary.
+       (org-set-regexps-and-options): Fix `org-deadline-time-hour-regexp'
+       and `org-scheduled-time-hour-regexp'.
+
+       * org-table.el (org-table-TBLFM-begin-regexp): Rename from
+       `org-TBLFM-begin-regexp'.
+       (org-table-calc-current-TBLFM): Rename from
+       `org-calc-current-TBLFM'.
+
+       * org.el (org-ctrl-c-ctrl-c): Require org-table if needed.
+       (org-refresh-properties): Put the text property on the whole
+       subtree, not just on the headline.
+       (org-get-outline-path): Remove statistical and checkboxes cookies.
+
+       * org-agenda.el (org-agenda, org-search-view, org-tags-view)
+       (org-agenda-get-day-entries, org-agenda-set-restriction-lock): Use
+       (current-buffer) as the value of `org-agenda-restrict'.  Fix a bug
+       about narrowing to wrong region boundaries when
+       `org-agenda-restrict' is non-nil.
+
+       * org.el (org-agenda-text-search-extra-files): Fix typos in
+       docstring.
+       (org-insert-heading): Fix case when there the first heading starts
+       at the beginning of the buffer.
+
+       * ob-core.el (org-babel-expand-src-block): Use
+       `org-called-interactively-p'.
+
+       * org.el (org-agenda-prepare-buffers): Avoid duplicates in
+       `org-tag-alist-for-agenda' correctly.
+       (org-read-date-minibuffer-local-map): Check if we are at the
+       beginning of the prompt, not if we are after a whitespace.  Bind
+       C-. to `calendar-goto-today'.
+
+       * org-clock.el (org-clock-in): Don't forward by one character when
+       setting the marker in the clock history.
+
+       * org.el (org-read-date-minibuffer-local-map): Call
+       `calendar-goto-today' only if there is a space before point in the
+       minibuffer prompt.
+       (org-insert-heading): Reveal context when called interactively.
+       Fix bug about wrong conversion of lines with :END: or #+end_ into
+       headlines.
+       (org-in-drawer-p): New function.
+       (org-meta-return): Use `org-catch-invisible-edits' and the
+       `org-in-drawer-p' to check whether we are within a drawer.
+
+       * org-list.el (org-sort-list): Fix infloop.
+
+       * org.el (org-clone-subtree-with-time-shift): Unconditionally ask
+       for a time shift if there is a time-stamp.  Don't ask for a time
+       shift when called with a universal prefix argument.
+
+       * ob-core.el (org-babel-insert-result): Fix bug when inserting
+       results as a list: ensure we split a string containing "\n".
+
+       * ox-html.el: Fix copyright header.
+
+       * org.el (org-store-link): Don't add a search string when storing
+       a link from a radio target.
+       (org-open-at-point): Jump to the radio link (<<<radio>>>), not to
+       the simple target (<<target>>).
+
+       * org-table.el (org-table-get-remote-range): Fix typo.
+
+       * org-datetree.el (org-datetree-find-month-create)
+       (org-datetree-find-day-create): Add a docstring.
+       (org-datetree-find-year-create): Only match headlines with a
+       year or a year and one or more tags.
+
+       * org-crypt.el (org-crypt-check-auto-save)
+       (org-crypt-use-before-save-magic): Use `org-add-hook' when the
+       hooks are local hooks.
+
+       * org-agenda.el (org-agenda-mode): Use `org-add-hook' and merge
+       upstream change from Emacs 2013-04-18T00:12:33Z!monnier@iro.umontreal.ca.
+
+       * ob-core.el (org-babel-pop-to-session-maybe): Fix docstring.
+       (org-babel-pop-to-session-maybe): Use true function's name,
+       not its alias.
+
+       * org-agenda.el (org-agenda-drag-line-forward)
+       (org-agenda-drag-line-backward): New commands.
+       (org-agenda-mode-map): Bind the new commands to M-<down> and
+       M-<up> respectively.
+
+       * org.el (org-insert-heading): Fix insertion of items.
+
+       * org-capture.el (org-capture-use-agenda-date): Fix docstring.
+
+       * org-agenda.el (org-agenda-bulk-toggle): Fix docstring.
+       (org-agenda-bulk-toggle-all): New command.
+       (org-agenda-mode-map): Bind `org-agenda-bulk-toggle' to `M-m'
+       and `org-agenda-bulk-toggle-all' to `M-*'.
+       (org-agenda-menu): Add `org-agenda-bulk-toggle' and
+       `org-agenda-bulk-toggle-all'.
+       (org-agenda-bulk-mark, org-agenda-bulk-unmark): Jump to the
+       next headline, not the next line.
+
+       * org-capture.el (org-mks): Fix bug: let-bind `case-fold-search'
+       to nil while matching the first letter of a multi-letters
+       template.
+
+       * org.el (org-store-link): When a bracket link is found in a
+       headline, use the link description or the link path.
+       (org-flag-drawer, org-hide-block-toggle)
+       (org-goto-left, org-goto-right, org-promote)
+       (org-paste-subtree, org-narrow-to-block, org-sort-entries)
+       (org-insert-link, org-offer-links-in-entry, org-open-file)
+       (org-refile, org-refile-get-location)
+       (org-refile-check-position, org-prepare-dblock, org-todo)
+       (org-auto-repeat-maybe, org-show-todo-tree, org-sparse-tree)
+       (org-occur, org-priority, org-scan-tags)
+       (org-get-tags-string, org-property-action, org-set-effort)
+       (org-entry-put, org-insert-drawer)
+       (org-compute-property-at-point)
+       (org-property-next-allowed-value, org-evaluate-time-range)
+       (org-closest-date, org-timestamp-change)
+       (org-revert-all-org-buffers, org-cycle-agenda-files)
+       (org-agenda-file-to-front, org-remove-file)
+       (org-preview-latex-fragment, org-format-latex)
+       (org-create-math-formula, org-create-formula-image)
+       (org-speed-command-help, org-check-before-invisible-edit)
+       (org-modifier-cursor-error, org-hidden-tree-error)
+       (org-mark-subtree, org-kill-line, org-first-sibling-p)
+       (org-up-element, org-down-element)
+       (org-drag-element-backward, org-drag-element-forward)
+       (org-unindent-buffer, org-speedbar-set-agenda-restriction): Use
+       `user-error' instead of `error'.
+
+       * ox-latex.el (latex): Don't force exporting with smart quotes.
+
+       * ox.el (org-export-with-smart-quotes): Mention the need to use
+       the relevant Babel package when setting this option to non-nil.
+
+       * org-src.el (org-edit-src-turn-on-auto-save): New option.
+       (org-edit-src-code): Use it.
+       (org-edit-src-auto-save-idle-delay): Enhance docstring.
+
+       * org-capture.el (org-mks): Make cursor invisible.
+
+       * org.el (org-link-expand-abbrev): Save match data before before
+       calling the replacement function.
+
+       * org-list.el (org-sort-list): Don't move point when matching time
+       values.
+
+       * org.el (org-shifttab): Show the correct number of empty
+       headlines when called with a numeric prefix argument.  Enhance
+       docstring.
+       (org-uniquify): Use `copy-sequence'.
+       (org-adaptive-fill-function, org-fill-paragraph): Throw a useful
+       error message when parse an element fails in the current buffer.
+
+       * ox.el (org-export-with-planning): Enhance docstring.
+
+       * org.el (org-closed-keep-when-no-todo): New option.
+       (org-todo): Use the new option.
+       (org-open-line): Rename from `org-ctrl-o'.
+       (org-mode-map): Use `remap'.
+       (org-cycle-emulate-tab, org-file-apps)
+       (org-set-font-lock-defaults)
+       (org-translate-link-from-planner, org-link-search)
+       (org-refile-get-targets, org-read-date-get-relative): Minor
+       code clean-up: fix dangling parentheses.
+
+       * org-agenda.el (org-agenda-entry-text-mode): Also check against
+       regexp filters.
+       (org-timeline): Handle `org-agenda-show-log'.
+
+       * org-clock.el (org-clock-select-task): Remove successive
+       duplicates in the clock history to consider.
+
+       * org.el (org-uniquify-alist): Improve docstring.
+       (org-make-tags-matcher, org-change-tag-in-region): Add buffer's
+       tags to the tags completion table.
+       (org-tags-expand): Prevent circular replacement of group tags.
+       Tiny docstring formatting.
+       (org-uniquify): Make a defsubst.  Use `delete-dups' instead of
+       `add-to-list'.
+       (org-todo): Also remove the CLOSED planning information when
+       removing the TODO keyword.
+       (org-forward-heading-same-level): Fix bug when forwarding
+       to a hidden subtree of the same level.
+       (org-tags-expand): Use word delimiters when building the tag
+       search regexp.
+
+       * org-clock.el (org-clock-insert-selection-line): Don't display
+       the clockout time.
+
+       * org.el (org-emphasis-regexp-components): Make a defvar.
+       (org-emphasis-alist): New default value: don't set HTML tags.
+       (org-emphasize, org-set-emph-re): Use the new value of
+       `org-emphasis-alist'.
+
+       * org-mobile.el (org-mobile-edit): Insert new headings at the end
+       of the parent subtree.  Use `org-at-heading-p' instead of the
+       obsolete `org-on-heading-p'.
+
+       * org.el (org-insert-heading): When called from a list item and
+       `org-insert-heading-respect-content' is non-nil, insert a heading,
+       not an item.
+       (org-insert-heading-respect-content): Fix docstring.
+       (org-insert-heading): When in a non-empty non-headline line,
+       convert the current line into a headline.
+
+       * org-table.el (org-table-copy-down): Don't move cursor when
+       getting the field.
+
+       * ox-icalendar.el (org-icalendar-export-current-agenda): Do not
+       evaluate babel code blocks.
+
+       * ox-html.el (html): Add more options.
+
+       * ox-publish.el (org-publish-project-alist): Add :with-planning in
+       docstring.
+
+       * ob-exp.el (org-babel-exp-src-block): Tiny docstring fix.
+
+       * ox-icalendar.el (org-icalendar--combine-files): Fix typo.
+
+       * org-mouse.el (org-mouse-agenda-context-menu): Fix a function's
+       name.
+
+       * ox.el (org-export-options-alist, org-export--skip-p): Use
+       `:with-planning' instead of `:with-plannings', to keep in sync
+       with the corresponding option's name.
+
+       * ob-core.el (org-babel-confirm-evaluate): Fix typo in docstring.
+
+       * org-agenda.el (org-agenda-undo, org-agenda)
+       (org-agenda-append-agenda)
+       (org-agenda-get-restriction-and-command, org-agenda-write)
+       (org-agenda-clock-cancel)
+       (org-agenda-diary-entry-in-org-file, org-agenda-diary-entry)
+       (org-agenda-execute-calendar-command)
+       (org-agenda-goto-calendar, org-agenda-convert-date)
+       (org-agenda-bulk-mark, org-agenda-bulk-action)
+       (org-agenda-show-the-flagging-note): Use `user-error' instead of
+       `error'.
+
+       * org-macs.el (org-with-remote-undo): Normalize argument names.
+
+       * org.el (org-store-log-note): Fix `buffer-undo-list' when called
+       after `org-agenda-todo'.
+       (org-add-log-note): Minor formatting fix.
+
+       * org-agenda.el (org-agenda-append-agenda): Set buffer read only.
+
+       * org-clock.el (org-clock-select-task): Throw a user error when
+       the clock history is empty.
+
+       * org-table.el (org-table-get-remote-range): Fix docstring: use
+       #+NAME instead of #+TBLNAME.
+
+       * ob-ref.el: Use #+NAME instead of #+TBLNAME in comment.
+
+       * ox-html.el (org-html-table-row-tags): Better example.
+
+       * org-clock.el (org-clock-select-task): Fix window to buffer.
+       Hide the cursor.
+       (org-clock-insert-selection-line): Add the clock-out time.
+
+       * ox-html.el (org-html-table-row-tags): Allow new dynamically
+       bound value `row-number'.
+       (org-html-table-row): Bind `row-number' to the number of the
+       row (first row is 0).
+
+       * org.el (org-minutes-to-clocksum-string): Round fractions of
+       minutes.
+
+       * ox-html.el (org-html-table-row-tags): Fix example in docstring.
+
+       * org-agenda.el (org-agenda-span-to-ndays): Enhance docstring.
+       (org-agenda-goto-date): Fix bug when going to a date in month
+       view.
+       (org-agenda-goto-date): Put the cursor on the agenda line with the
+       selected date.
+       (scheduled/deadline items with hour spec) then redo an agenda*.
+
+       * org-clock.el (org-clock-resolve): Enhance the content of the
+       help window.
+
+       * org-footnote.el (org-footnote-auto-label): Minor docstring fix.
+
+       * ox-odt.el (org-odt-link): Fix bug: convert & to &amp; in
+       links.
+
+       * ox-html.el (org-html-table-row): Dynamically bind
+       `rowgroup-number', `start-rowgroup-p', `end-rowgroup-p',
+       `top-row-p', `bottom-row-p'.
+       (org-html-table-row-tags): Update docstring: tell what variables
+       are dynamically bound.
+
+       * org-src.el (org-edit-src-code): Don't set
+       `buffer-auto-save-file-name' unless `auto-save-default' is
+       non-nil.
+
+       * ox.el (org-export-table-row-group): Fix typo in docstring.
+
+       * org-table.el (orgtbl-apply-fmt): Enhance docstring.
+
+       * org.el (org-file-contents): Make the message more prominent.
+
+       * ox.el (org-export-replace-region-by): New function.
+
+       * ox-texinfo.el (org-texinfo-convert-region-to-texinfo),
+       * ox-md.el (org-md-convert-region-to-md),
+       * ox-latex.el (org-latex-convert-region-to-latex),
+       * ox-html.el (org-html-convert-region-to-html): New functions to
+       replace the active region by its export into various backends.
+
+       * org-faces.el (org-agenda-restriction-lock): Use less flashy
+       colors.
+
+       * org-agenda.el
+       (org-agenda-restriction-lock-highlight-subtree): New option.
+       (org-agenda-top-headline-filter): Rename from
+       `org-agenda-top-headline-filter'.
+       (org-find-top-headline): Rename from `org-find-top-category'.
+       Add a docstring.
+       (org-agenda-filtered-by-top-headline): Rename from
+       `org-agenda-filtered-by-top-category'.
+       (org-agenda-filter-by-top-headline): Rename from
+       `org-agenda-filter-by-top-category'.  Fix docstring.
+       (org-agenda-filter-top-headline-apply): Rename from
+       `org-agenda-filter-top-category-apply'.  Fix docstring.
+       (org-agenda-mode-map): Update binding.
+       (org-agenda-get-todos): Set `todo-state' earlier so that we can
+       skip false-positives in time.
+
+       * org.el (org-get-todo-state): Add a docstring.
+       (org-ctrl-o): New command to insert a new row in tables
+       (like `M-S-<down>' does) and open a line elsewhere.
+       (org-mode-map): Bind the new command to `C-o'.
+       (org-set-regexps-and-options): Process tags from an external setup
+       file.
+
+       * org-agenda.el (org-agenda-dim-blocked-tasks): Enhance docstring.
+       (org-agenda-finalize-entries): Conditionally apply limits so
+       that we don't manipulate big lists uselessly.
+       (org-agenda-limit-entries): Limit exclusively.  E.g., when
+       limiting to a maximum of "2 tags", don't limit among tagged
+       entries only, but limit among all entries.
+       (org-agenda-limit-interactively): New command.
+       (org-agenda-mode-map): Bind the new command to "~".
+       (org-agenda-redo): Small fix: don't use `eval'.
+
+       * org.el (org-ctrl-c-ctrl-c): Fix bug wrt updating checkboxes: the
+       list beginning should be stored using a marker so that updating
+       [%0] to [%50] will not throw an error.
+       (org-babel-load-file): Move `org-babel-load-file' from
+       ob-tangle.el to here so that it is correctly autoloaded by Emacs
+       before Org is required.
+
+       * org-mac-message.el: Delete.
+
+       * org.el (org-modules): org-mac-message.el is not a core package
+       anymore.
+
+       * org-table.el (orgtbl-to-generic): Fix bug when exporting the
+       cells of radio tables with 'hline.
+
+       * org.el (org-speed-commands-default): Use ?s for
+       `org-narrow-to-subtree'.
+
+       * org-agenda.el (org-agenda-start-on-weekday): Fix typo.
+       (org-agenda-start-day): Enhance docstring.
+
+       * org-src.el (org-src-native-tab-command-maybe): Check that we are
+       in a source code block.
+
+       * org-mobile.el: Remove useless defvar.
+
+       * org.el (org-indent-line): A line just below a line with a list
+       item is now indented depending on the indentation of this list
+       item.
+
+       * org.el (org-options-keywords): Add #+TARGET.
+
+       * org-clock.el (org-resolve-clocks-if-idle): Only try to resolve
+       last clock if the clock buffer still exists.
+       (org-clock-out, org-clock-cancel): Set markers to nil.
+
+       * ox-org.el (org-org-publish-to-org):
+       * ox-html.el (org-html-publish-to-html): Use the custom extension.
+
+       * org.el (org-cycle-internal-local): Fix invalid search bound when
+       `org-cycle-include-plain-lists' is set to 'integrate.
+
+       * org.el (org-sparse-tree-default-date-type): Add an option for
+       closed time-stamps.
+       (org-sparse-tree): Allow to check against closed time-stamps.
+       (org-re-timestamp): Handle closed time-stamps.
+       (org-closed-in-range): Delete.
+
+       * org-capture.el (org-capture-import-remember-templates): Take
+       care of adding :jump-to-captured option if needed.
+
+       * org.el (org-toggle-pretty-entities): Enhance messages.
+       (org-raise-scripts): Handle scripts like "a_b^c".
+
+       * org-capture.el (org-capture-templates): Document new option
+       :jump-to-captured in the docstring.  Offer the complete list of
+       options when customizing.
+       (org-capture-finalize): Handle :jump-to-captured.
+
+       * org.el (org-agenda-prepare-buffers): Fix bugs: don't let-bind
+       `org-tag-alist' to nil and don't append duplicate tags to
+       `org-tag-alist-for-agenda'.
+       (org-store-link): Storing multiple links in the active region now
+       requires a triple prefix argument.
+       (org-store-link, org-link-search): Fix handling of links to #+NAME
+       and #+TARGET keywords.
+
+       * org-compat.el (org-ignore-region): Tiny docstring fix.
+
+       * org-capture.el (org-capture): Don't store multiple links over
+       lines in the active region.
+
+       * ox-odt.el (org-odt-special-block): Don't wrap annotations into
+       <text:p>...</text:p> at all.
+       (org-odt--fix-annotations): New function.
+       (org-odt--export-wrap): Use the new function to fix annotations
+       insertion in content.xml.
+
+       * org.el (org-mode-flyspell-verify): Require 'org-element so that
+       `org-element-affiliated-keywords' is defined.
+
+       * ox-odt.el (org-odt-special-block): Don't insert annotations
+       using style "Text_20_body".
+
+       * org.el (org-toggle-tags-groups): Correctly highlight group tags.
+       (org-tags-expand): Expand tags as words, with characters ?@
+       and ?_ being considered words constituents.
+       (org-set-regexps-and-options): Don't read setup files from
+       read-only buffers.
+       (org-file-contents): When no-error is non-nil, throw a less
+       intrusive message.
+
+       * org-agenda.el (org-agenda-scheduled-leaders)
+       (org-agenda-deadline-leaders): Re-align leaders to the left,
+       back to a 11 characters width.
+
+       * org.el (org-refile-cache-check-set): More informative message.
+
+       * org-agenda.el (org-tags-view): Set the matcher after preparing
+       the agenda, as `org-tag-groups-alist-for-agenda' might be needed.
+       (org-agenda-filter-make-matcher): New parameter `filter' and
+       `type'.  Handle group tags.
+       (org-agenda-filter-expand-tags): New function.
+       (org-agenda-filter-apply): Handle group tags.
+
+       * org.el (org-blank-before-new-entry): Tiny docstring fix.
+       (org-tag-alist-for-agenda): Add docstring.
+       (org-tag-groups-alist-for-agenda): New global variable.
+       (org-tag-groups-alist): New buffer-local variable.
+       (org-tag-alist, org-tag-persistent-alist): Handle :grouptags.
+       (org-group-tags): New option.
+       (org-toggle-group-tags): New command.
+       (org-mode-map): Bind `org-toggle-group-tags' to `C-c C-x q'.
+       (org-set-regexps-and-options-for-tags): New function, factored
+       out from `org-set-regexps-and-options'.
+       (org-set-regexps-and-options): Don't handle tags, they are now
+       handled separately by `org-set-regexps-and-options-for-tags'.
+       (org-assign-fast-keys): Handle :grouptags.
+       (org-mode): Use `org-set-regexps-and-options-for-tags' on top
+       of `org-set-regexps-and-options'.
+       (org-fontify-meta-lines-and-blocks-1): Fontify group tags.
+       (org-make-tags-matcher): Expand group tags in the matcher.
+       (org-tags-expand): New function.
+       (org-tags-completion-function): Tiny code clean up.
+       (org-set-current-tags-overlay): Add a docstring.
+       (org-fast-tag-selection): Highlight group tags.
+       (org-agenda-prepare-buffers): Set `org-tag-alist-for-agenda'
+       and `org-tag-groups-alist-for-agenda'.  Don't uniquify
+       `org-tag-alist-for-agenda' as we may need the grouping
+       information for filtering in the agenda buffer.
+       (org-uniquify-alist): New function.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option/tags): Handle
+       :grouptags.
+
+       * org-faces.el (mode-line): New face for group tags.
+
+       * ob-core.el (org-babel-hash-show-time): Tiny docstring
+       enhancement.
+
+       * org-element.el (org-element-paragraph-separate): Use new name
+       `org-list-allow-alphabetical'.
+
+       * org-list.el (org-list-allow-alphabetical): Rename from
+       `org-alphabetical-lists'.
+       (org-list-empty-line-terminates-plain-lists): Rename from
+       `org-empty-line-terminates-plain-lists'.
+       (org-checkbox-hierarchical-statistics): Rename from
+       `org-hierarchical-checkbox-statistics'.
+
+       * org.el (org-image-actual-width): Update docstring.
+       (org-display-inline-images): Use the #+attr_html: :width syntax.
+       (org-modules): Remove deleted libraries, add new ones.
+
+       * ox-html.el (org-html-indent): Default to nil, as non-nil can
+       break indentation of source code blocks.
+       (org-html-link): Don't insert nil if there is no attributes.
+       (org-html-link--inline-image): Use the correct syntax for image
+       attributes.  Allow :width :height and :alt as predefined
+       attributes for inline images.
+       (org-html-link, org-html-table): Use the standard syntax---
+       e.g. "#+attr_html: :options ..."--- to get attributes.
+
+       * ox.el (org-export-table-cell-alignment): Treat an empty cell as
+       a number if it follows a number.
+
+       * ox.el (org-export-as): Allow user functions in
+       `org-export-before-parsing-hook' to modify the point.
+
+       * org.el (org-entry-add-to-multivalued-property): Add the new
+       value by appending it at the end of the line.
+
+       * org-table.el (orgtbl-to-generic): New parameter `backend' to
+       export cells content using a specific backend.
+       (orgtbl-to-latex, orgtbl-to-texinfo): Export cells to LaTeX
+       and Texinfo before sending the table.
+
+       * ox.el (org-export-define-backend)
+       (org-export-define-derived-backend): Make defuns and update
+       docstrings.
+
+       * ox-texinfo.el (texinfo):
+       * ox-org.el (org):
+       * ox-odt.el (odt):
+       * ox-md.el (md):
+       * ox-man.el (man):
+       * ox-latex.el (latex):
+       * ox-icalendar.el (icalendar):
+       * ox-html.el (html):
+       * ox-beamer.el (beamer):
+       * ox-ascii.el (ascii): Use `org-export-define-backend' and
+       `org-export-define-derived-backend' as defuns, not macros.
+
+       * org.el (org-set-regexps-and-options): Use
+       `org-table-set-constants'.
+
+       * org-table.el (org-table-set-constants): New function.
+       (orgtbl-ctrl-c-ctrl-c): Use it.
+
+       * org-pcomplete.el
+       (pcomplete/org-mode/block-option/clocktable): Add parameters.
+
+       * org.el (org-options-keywords): Remove "INFOJS_OPT": it is added
+       through ox-html.el now.
+
+       * org-agenda.el (org-agenda-redo): Set filters after agenda has
+       been redone.
+
+       * org.el (org-store-link): When there is an active region, store
+       each line as a separate link.
+       (org-insert-all-links): Use a default description when links
+       do not have one already.
+
+       * org-agenda.el (org-agenda-redo): Fix code typo.
+
+       * org.el (org-link-display-format): Fix docstring.
+
+       * ox-publish.el (org-publish-org-to)
+       (org-publish-org-sitemap, org-publish-find-title)
+       (org-publish-find-date)
+       (org-publish-cache-file-needs-publishing): Set
+       `org-inhibit-startup' to t when visiting files for
+       publication.
+
+       * ox-org.el (org-org-publish-to-org): Kill buffers not visited at
+       publication time.
+
+       * org.el (org-set-font-lock-defaults): Set font-lock keywords
+       correctly for plain links.
+
+       * ox-texinfo.el (org-texinfo-logfiles-extensions)
+       (org-texinfo-remove-logfiles): New options.
+       (org-texinfo-compile): Use the new options to remove files
+       after compiling a Texinfo file.
+
+       * ox-texinfo.el (org-texinfo-coding-system): New option.
+       (org-texinfo-template): Add @documentlanguage and
+       @documentencoding.
+       (org-texinfo-headline): Add a space before tags.
+       (org-texinfo-export-to-texinfo, org-texinfo-export-to-info):
+       Use `org-texinfo-coding-system' as the coding system for
+       exported buffers.
+       (org-texinfo-publish-to-texinfo): New function.
+
+       * ox-texinfo.el (org-texinfo-filename)
+       (org-texinfo-info-process, org-texinfo-max-toc-depth)
+       (org-texinfo--sanitize-menu): Docstrings tiny fixes.
+
+       * org-agenda.el (org-agenda-dim-blocked-tasks): Only throw a
+       message when called interactively.  Fix docstring position in the
+       defun.
+
+       * ox-html.el (org-html--build-meta-info): Fix setting of
+       http-equiv="Content-Type".
+
+       * org-agenda.el (org-agenda-mode-map): Use ?= for filtering by
+       regexp and ?| for removing all filters.
+       (org-agenda-filter-remove-all): New command.
+       (org-agenda-filter-show-all-re): Rename from
+       `org-agenda-filter-show-all-regexp'.
+       (org-agenda-filter-by-regexp): Call
+       `org-agenda-filter-show-all-re'.
+
+       * org-list.el (org-insert-item): Don't ask for a definition term
+       when insert an item in a description list.
+
+       * org-agenda.el (org-agenda-Quit): Set `org-agenda-buffer' to nil.
+       This prevents bugs when calling e.g., `org-diary' after quitting
+       an agenda window.
+       (org-agenda-entry-types): Move earlier in the file.
+       (org-agenda-custom-commands-local-options, org-diary)
+       (org-agenda-get-day-entries): Don't hardcode the default agenda
+       entry types, use `org-agenda-entry-types'.
+       (org-agenda-custom-commands): Fix default setting so that the
+       customize interface does not complain about a mismatch.
+
+       * org.el (org-export-backends): Add new backends.
+
+       * ox-html.el (org-html-indent): New option.
+       (org-html-use-unicode-chars): New option.
+       (org-html-pretty-output): Delete.
+       (org-html-final-function): Use the new options.
+
+       * ox-html.el (org-html-link): Fix handling of abbreviated links
+       which include a file: protocol.
+       (org-html--build-postamble): Default to today's date.
+       (org-html--build-meta-info): When #+DATE contains a time stamp,
+       parse it as a RFC 822 time string, otherwise simply insert the
+       date as a string.
+
+       * ox.el (org-export--copy-to-kill-ring-p): New function.
+       (org-export-copy-to-kill-ring): Use 'if-interactive as the
+       default.
+       (org-export-to-buffer, org-export-to-file): Use
+       `org-export--copy-to-kill-ring-p' and fix docstrings.
+
+       * ox-odt.el (org-odt-export-as-odf): Use
+       `org-export--copy-to-kill-ring-p'.
+
+       * org.el (org-set-font-lock-defaults): Fontify macros.
+
+       * org-faces.el (org-macro): New face.
+
+       * org.el (org-clone-subtree-with-time-shift): Only prompt for a
+       time shift when the entry at point has a time stamp and when the
+       command is called with a universal prefix argument.
+       (org-execute-file-search-functions): Docstring fix.
+
+       * org-compat.el (org-defvaralias): Fix declare form.
+
+       * org-clock.el (org-clocktable-defaults): Add :mstart parameter.
+       (org-clock-special-range): New argument mstart.
+       (org-dblock-write:clocktable, org-dblock-write:clocktable)
+       (org-clocktable-write-default, org-clocktable-steps)
+       (org-clock-get-table-data): Handle the :mstart parameter.
+
+       * org.el (org-map-entries): Use `save-window-excursion'.
+
+       * org-compat.el (org-defvaralias): New compatibility function.
+
+       * org-list.el (org-cycle-include-plain-lists): Also add to the
+       'org-cycle customization group.
+       (org-list-allow-alphabetical)
+       (org-checkbox-hierarchical-statistics)
+       (org-list-empty-line-terminates-plain-lists)
+       (org-list-description-max-indent): Rename and add aliases to old
+       names.
+
+       * org-element.el (org-element-context): Prevent an error when
+       getting the context of a table rule.
+
+       * org.el (org-deadline-time-hour-regexp)
+       (org-scheduled-time-hour-regexp): New buffer local variables.
+       (org-set-regexps-and-options): Set the new variables.
+
+       * org-agenda.el (org-agenda-custom-commands-local-options): Add
+       :deadline* and :scheduled* to the list of possible agenda entry
+       types.
+       (org-agenda): Implement a new agenda type agenda* with :scheduled*
+       and :deadline* replacing :scheduled and :deadline respectively in
+       agenda entry types.  In such agenda, only scheduled and deadline
+       items with a time specification [h]h:mm will be considered.
+       (org-agenda-entry-types): Document the new agenda entry types
+       :scheduled* and :deadline*.
+       (org-agenda-list): New parameter `with-hour'.  Use :scheduled* and
+       :deadline*.
+       (org-agenda-get-day-entries): Handle :scheduled* and :deadline*.
+       (org-agenda-get-deadlines, org-agenda-get-scheduled): New
+       parameter `with-hour'.  Use `org-deadline-time-hour-regexp' or
+       `org-scheduled-time-hour-regexp' as the search string if needed.
+       (org-agenda-to-appt): Use :scheduled* and :deadline* by default,
+       as other scheduled and deadline items don't have a time spec and
+       cannot be turned into appointments.  Trim bracket links and use
+       only the description as the appointment text.
+       (org-agenda-get-restriction-and-command): Add
+       default description for the agenda* view.
+       (org-agenda-run-series): Handle agenda* views.
+
+       * org-faces.el (org-agenda-filter-tags)
+       (org-agenda-diary, org-agenda-calendar-event)
+       (org-agenda-calendar-sexp): Minor code clean up.
+       (org-agenda-filter-category): Docstring fix.
+       (org-agenda-filter-category): New face.
+
+       * org-agenda.el (org-agenda-local-vars): Add
+       `org-agenda-re-filter-overlays' and `org-agenda-regexp-filter'.
+       (org-agenda-mode-map): Use "|" for
+       `org-agenda-filtered-by-regexp'.
+       (org-agenda-re-filter-overlays): New variable.
+       (org-agenda-mark-filtered-text): Use
+       `org-agenda-re-filter-overlays'.
+       (org-agenda-finalize, org-agenda-redo): Allow regexp filtering.
+       (org-agenda-filter-by-category): Set `org-agenda-category-filter'
+       here instead of within `org-agenda-apply-filter'.
+       (org-agenda-regexp-filter): New variable.
+       (org-agenda-filter-by-regexp): New function to filter agenda
+       buffers by regexp.
+       (org-agenda-filter-make-matcher): Make matcher for regexp filters.
+       (org-agenda-filter-apply): Don't set `org-agenda-tag-filter' and
+       `org-agenda-category-filter'.  Maybe apply regexp filter.
+       (org-agenda-filter-hide-line): Add docstring.  Hide
+       regexp-filtered lines.
+       (org-agenda-filter-show-all-tag, org-agenda-filter-show-all-cat):
+       Add docstring.
+       (org-agenda-filter-show-all-regexp): New function.
+       (org-agenda-set-mode-name): Add regexp-filter information.
+       (org-agenda-custom-commands-local-options): Add regexp filter.
+       (org-agenda-regexp-filter-preset): New variable.
+       (org-agenda-prepare): Use the new variable.
+
+       * ox-odt.el (org-odt-code, org-odt-verbatim): Use
+       `org-odt--encode-plain-text'.
+
+       * ox-html.el (org-html-link): Minor code clean-up.
+
+       * org.el (org-insert-heading): DTRT when in a narrowed region.
+
+       * org-compat.el (org-buffer-narrowed-p): New compatibility
+       function.
+
+       * ox-html.el (org-html-format-inline-image): Fix missing string in
+       formatting string.
+
+       * org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown):
+       New allowed value `repeated-after-deadline' which will prevent the
+       display of scheduled items when repeated after the current
+       deadline.
+       (org-agenda-get-scheduled): Handle the new value.
+
+       * org.el (org-time-string-to-absolute): Tiny docstring fix.
+
+       * ox-html.el (org-html-style-default): New classes `footpara' and
+       `footdef' for the footnotes paragraphs and definitions.
+       (org-html-format-footnote-definition): Wrap the footnote
+       defintions into their own div.
+       (org-html-paragraph): Don't add extra <br/> after a paragraph in a
+       footnote.
+       (org-html-container-element, org-html-divs): Mention that
+       org-info.js will not work when changing the defaults.
+
+       * ox-md.el (md): Export underlined text as verbatim.
+
+       * ox-html.el (org-html-style-default): New CSS .underline and
+       #org-div-home-and-up.
+       (org-html-text-markup-alist): Don't hardcode the style, use the
+       new class .underline.
+       (org-html-home/up-format): Don't hardcode the style, use
+       #org-div-home-and-up.
+       (org-html-center-block): Use the .center class.
+
+       * ox-md.el (org-md-underline): New function.
+
+       * org-agenda.el (org-sorting-choice): Fix default value.
+
+       * ox-html.el (org-html-format-footnote-definition)
+       (org-html-footnote-section): Don't wrap footnote definitions into
+       tables.
+       (org-html-paragraph): Add HTML style and class parameter when the
+       paragraph is in a footnote definition.  Also allow to add an extra
+       string after the paragraph.  Further parameters can be added for
+       paragraphs in other environments.
+       (org-html-template): Always include the title as <h1
+       class="title"></h1>, even when there is no title, as org-info.js
+       needs it.
+
+       * org-element.el (org-element-map): Fix tiny typo in docstring.
+
+       * org-agenda.el (org-agenda-day-view): Fix parameter's name.
+
+       * ox-html.el (org-html-format-inline-image): Don't add superfluous
+       <p></p> when there is an empty caption.
+
+       * org-agenda.el (org-agenda-refile): Enhance docstring.  Allow to
+       clear the refile cache with C-0 or C-u C-u C-u.
+
+       * ox-md.el (org-md-export-as-markdown): Tiny docstring fix.  Fix a
+       library keyword in the comment section.
+
+       * org.el (org-toggle-item): Convert all normal lines as items when
+       there is a region, and only convert the first line when called
+       with a universal prefix argument.  This is consistent with the
+       behavior of `org-toggle-heading'.
+       (org-toggle-heading): When the region contains only normal lines,
+       a universal prefix arg will only convert the first line.  This is
+       more consistent with `org-toggle-item'.
+       (orgstruct-setup): Add `org-ctrl-c-minus' and `org-ctrl-c-star'.
+       (customize-package-emacs-version-alist): Update
+       `customize-package-emacs-version-alist'.
+
+       * ox-texinfo.el (org-export-texinfo)
+       (org-texinfo-filename, org-texinfo-classes)
+       (org-texinfo-format-headline-function)
+       (org-texinfo-node-description-column)
+       (org-texinfo-active-timestamp-format)
+       (org-texinfo-link-with-unknown-path-format)
+       (org-texinfo-tables-verbatim)
+       (org-texinfo-table-scientific-notation)
+       (org-texinfo-text-markup-alist)
+       (org-texinfo-format-drawer-function)
+       (org-texinfo-format-inlinetask-function)
+       (org-texinfo-info-process):
+       * ox-odt.el (org-odt-format-drawer-function)
+       (org-odt-format-headline-function)
+       (org-odt-format-inlinetask-function):
+       * ox-md.el (org-export-md, org-md-headline-style): Fix :version
+       and :package-version keywords.
+
+       * org.el (org-time-clocksum-use-effort-durations): Don't set to t
+       by default as it will change many clocktables out there.  Let the
+       user decides whether she wants to turn this on.
+
+       * org.el (org-agenda-inhibit-startup): Revert to nil as the default.
+
+       * org-agenda.el (org-agenda-dim-blocked-tasks): Revert to t as the
+       default.
+
+       * ox-html.el (org-html-style-default): More cosmetic tweaks.
+       (org-html-head-include-default-style): Minor docstring update.
+
+       * ox.el (org-export-snippet-translation-alist)
+       (org-export-coding-system, org-export-in-background)
+       (org-export-async-init-file, org-export-invisible-backends)
+       (org-export-dispatch-use-expert-ui):
+       * ox-texinfo.el (org-texinfo-filename, org-texinfo-classes)
+       (org-texinfo-format-headline-function)
+       (org-texinfo-node-description-column)
+       (org-texinfo-active-timestamp-format)
+       (org-texinfo-link-with-unknown-path-format)
+       (org-texinfo-tables-verbatim)
+       (org-texinfo-table-scientific-notation)
+       (org-texinfo-text-markup-alist)
+       (org-texinfo-format-drawer-function)
+       (org-texinfo-format-inlinetask-function)
+       (org-texinfo-info-process):
+       * ox-man.el (org-man-tables-centered)
+       (org-man-table-scientific-notation)
+       (org-man-source-highlight, org-man-source-highlight-langs)
+       (org-man-pdf-process, org-man-logfiles-extensions):
+       * ox-html.el (org-html-allow-name-attribute-in-anchors)
+       (org-html-coding-system, org-html-divs):
+       * ox-ascii.el (org-ascii-text-width)
+       (org-ascii-headline-spacing, org-ascii-indented-line-width)
+       (org-ascii-paragraph-spacing, org-ascii-charset)
+       (org-ascii-underline, org-ascii-bullets)
+       (org-ascii-links-to-notes)
+       (org-ascii-table-keep-all-vertical-lines)
+       (org-ascii-table-widen-columns)
+       (org-ascii-table-use-ascii-art)
+       (org-ascii-format-drawer-function)
+       (org-ascii-format-inlinetask-function):
+       * org.el (org-modules, org-export-backends)
+       (org-highlight-latex-and-related, orgstruct-setup-hook):
+       * org-attach.el (org-attach-git-annex-cutoff):
+       * org-archive.el (org-archive-file-header-format):
+       * org-agenda.el (org-agenda-todo-ignore-time-comparison-use-seconds):
+       * ob-python.el (org-babel-python-hline-to)
+       (org-babel-python-None-to):
+       * ob-ditaa.el (org-ditaa-eps-jar-path):
+       * ob-core.el (org-babel-results-keyword): Add :version and
+       :package-version.
+
+       * ox-ascii.el: Use utf-8-emacs as the file coding system.
+
+       * org-capture.el (org-capture-templates, org-capture-string)
+       (org-capture-steal-local-variables)
+       (org-capture-empty-lines-before)
+       (org-capture-empty-lines-after)
+       (org-capture-insert-template-here)
+       (org-capture-import-remember-templates): Fix or add docstring.
+
+       * ox-html.el (org-html-style-default): Cosmetic changes.
+       (org-html-postamble, org-html-preamble)
+       (org-html-preamble-format): Update docstring.
+
+       * org-agenda.el (org-agenda-format-date-aligned)
+       (org-agenda-time-of-day-to-ampm-maybe)
+       (org-scheduled-past-days)
+       (org-agenda-normalize-custom-commands)
+       (org-agenda-run-series, org-store-agenda-views): Fix or add
+       docstring.
+
+       * ox-latex.el:
+       (org-latex-table-scientific-notation, org-latex-verse-block): Fix
+       typos in docstrings.
+
+       * ox-html.el (org-html-text-markup-alist)
+       (org-html-pretty-output, org-html-link-org-files-as-html)
+       (org-html-postamble, org-html-preamble)
+       (org-html-format-inline-image, org-html-splice-attributes)
+       (org-export-splice-style, org-html-htmlize-region-for-paste)
+       (org-html-fix-class-name)
+       (org-html-format-footnote-reference)
+       (org-html-format-footnotes-section)
+       (org-html-footnote-section, org-html--anchor)
+       (org-html--todo, org-html--tags, org-html-format-headline)
+       (org-html-toc, org-html-format-section, org-html-checkbox)
+       (org-html-format-list-item, org-html-format-latex)
+       (org-html-encode-plain-text)
+       (org-html-table-first-row-data-cells)
+       (org-html-table--table.el-table, org-html-final-function): Fix
+       or add docstring.
+
+       * org.el (org-insert-heading): If the current item has a checkbox,
+       insert the new item with a checkbox.
+
+       * org.el (org-insert-heading): Don't delete spaces in empty
+       headlines.
+
+       * ox-odt.el (org-odt-keyword): Fix typo.
+
+       * ox-latex.el (org-latex-toc-command): Cosmetic docstring change.
+
+       * ox-html.el (org-html-encode-plain-text): Fix typo in docstring.
+
+       * org-faces.el (org-column): Update docstring.
+
+       * org-colview.el: Update error message.
+
+       * org.el (org-modules): Do not include org-mew.el, org-vm.el,
+       org-w3m.el, org-wl.el as these files are now part of contrib/.
+
+       * org-w3m.el:
+       * org-vm.el:
+       * org-w3m.el:
+       * org-wl.el: Delete (moved to Org's contrib/ directory.)
+
+       * org-capture.el (org-mks): Move from org-mks.el.
+
+       * org-mks.el: Delete.
+
+       * ox-html.el (html): Update HTML options names.
+
+       * org.el (org-show-context): Don't try to fix ellipsis when
+       showing a subtree in agenda.
+
+       * ox-html.el (html): Reintroduce #+HTML_HEAD_EXTRA, previously
+       known as HTML_STYLE_EXTRA.
+       (org-html-head): Enhance docstring.
+       (org-html-head-extra): Reintroduce.  Was `org-html-style-extra'.
+       (org-html--build-head): Rename from `org-html--build-head'.  Add
+       information from `org-html-head-extra'.
+       (org-html-template): Use `org-html--build-head'.
+
+       * ox-html.el (org-html-display-buffer-mode): Delete.
+       (org-html-export-as-html): Use `set-auto-mode' instead of
+       `org-html-display-buffer-mode'.
+
+       * org-agenda.el (org-agenda-write): Overwrite file when called
+       non-interactively.
+
+       * org-mobile.el (org-mobile-edit): Workaround a
+       `org-insert-heading-respect-content' bug which prevents correct
+       insertion when point is invisible
+
+       * org.el (org-previous-line-empty-p): New parameter to allow
+       checking next line.  Add a docstring.
+       (org-insert-heading): Handle two universal prefix arguments as
+       advertized in the docstring.  Don't insert new lines when
+       creating a heading after the first heading in the current
+       subtree.
+       (org-insert-heading-respect-content): New optional argument
+       arg, passed to `org-insert-heading'.
+
+       * org.el (org-mode): Remove syntax entries.  Use
+       `org-backward-element' and `org-forward-element' for
+       `beginning-of-defun-function' and `end-of-defun-function': this
+       allows using C-M-a and C-M-e before the first headline.
+
+       * ox-html.el (html): Remove :html-htmlized-css-url :options-alist.
+
+       * ox-org.el (org-org-htmlized-css-url): Rename from
+       `org-html-htmlized-org-css-url' and moved here from ox-html.el.
+       (org-org-publish-to-org): Handle :htmlized-source in
+       publishing projects.
+
+       * ox-html.el (org-html-style-default): Update docstring.
+       (org-html-infojs-install-script, org-html--build-style): Update
+       property names.
+       (org-html-head-include-scripts)
+       (org-html-head-include-default-style, org-html-head):
+       Respectively rename from `org-html-style-include-scripts',
+       `org-html-style-include-default' and `org-html-style', now
+       obsolete.
+       (org-html-style-extra): Delete.
+
+       * org-clock.el (org-clock-out): Fix bug: if a closing note needs
+       to be stored in the drawer where clocks are stored, let's
+       temporarily remove `org-clock-remove-empty-clock-drawer' from
+       `org-clock-out-hook'.
+
+       * ob-tangle.el (org-babel-tangle): Remove unused attempt of
+       prompting the user of the tangle file name since :tangle is always
+       set.  Don't prompt for a tangle file name when called with two
+       universal prefix arg outside of a src block.  Use
+       `org-babel-tangle-single-block'.
+       (org-babel-tangle-single-block): New function.
+       (org-babel-tangle-collect-blocks): Use the new function.
+
+       * org-table.el (org-table-convert-region, org-table-export)
+       (org-table-align, org-table-beginning-of-field)
+       (org-table-copy-down, org-table-check-inside-data-field)
+       (org-table-insert-column, org-table-find-dataline)
+       (org-table-delete-column, org-table-move-column)
+       (org-table-insert-row, org-table-insert-hline)
+       (org-table-kill-row, org-table-paste-rectangle)
+       (org-table-wrap-region, org-table-sum, org-table-get-formula)
+       (org-table-get-formula, org-table-get-stored-formulas)
+       (org-table-fix-formulas, org-table-maybe-eval-formula)
+       (org-table-rotate-recalc-marks, org-table-eval-formula)
+       (org-table-get-range, org-table-get-descriptor-line)
+       (org-table-find-row-type, org-table-recalculate)
+       (org-table-iterate, org-table-iterate-buffer-tables)
+       (org-table-formula-handle-first/last-rc)
+       (org-table-edit-formulas, org-table-fedit-shift-reference)
+       (org-rematch-and-replace, org-table-shift-refpart)
+       (org-table-fedit-finish, org-table-fedit-lisp-indent)
+       (org-table-show-reference, org-table-show-reference)
+       (org-table-show-reference, org-table-show-reference)
+       (org-table-force-dataline, orgtbl-error, orgtbl-export)
+       (orgtbl-send-replace-tbl, org-table-to-lisp)
+       (orgtbl-send-table, orgtbl-send-table, orgtbl-send-table)
+       (orgtbl-toggle-comment, orgtbl-insert-radio-table)
+       (orgtbl-to-unicode, org-table-get-remote-range)
+       (org-table-get-remote-range, org-table-copy-dow)
+       (org-table-check-inside-data-field, org-table-insert-colum)
+       (org-table-find-dataline, org-table-delete-colum)
+       (org-table-move-column, org-table-insert-ro)
+       (org-table-insert-hline, org-table-kill-ro)
+       (org-table-paste-rectangle, org-table-wrap-regio)
+       (org-table-sum, org-table-get-formul)
+       (org-table-get-stored-formulas, org-table-fix-formula)
+       (org-table-maybe-eval-formul, org-table-rotate-recalc-marks)
+       (org-table-eval-formul, org-table-get-range)
+       (org-table-get-descriptor-lin, org-table-find-row-type)
+       (org-table-recalculat, org-table-iterate)
+       (org-table-iterate-buffer-table)
+       (org-table-formula-handle-first/last-r)
+       (org-table-edit-formulas, org-table-fedit-shift-referenc)
+       (org-rematch-and-replace, org-table-shift-refpar)
+       (org-table-fedit-finish, org-table-fedit-lisp-inden)
+       (org-table-show-reference, org-table-force-datalin)
+       (orgtbl-error, orgtbl-export, orgtbl-send-replace-tb)
+       (org-table-to-lisp, orgtbl-send-tabl, orgtbl-toggle-comment)
+       (orgtbl-insert-radio-tabl, orgtbl-to-unicode)
+       (org-table-get-remote-range): Use `user-error' instead of
+       `error' for user errors.
+
+       * ob-core.el (org-babel-load-in-session): Throw a useful error
+       when there is no code block at point.
+
+       * ob-tangle.el (org-babel-tangle): Rename the ONLY-THIS-BLOCK
+       parameter to ARG.  Allow two universal prefix arguments to tangle
+       by the target file of the block at point.
+       (org-babel-tangle-collect-blocks): New parameter TANGLE-FILE
+       to restrict the collection of blocks to those who will be
+       tangled in TARGET-FILE.
+
+       * org-src.el (org-edit-src-auto-save-idle-delay): Use a delay of 0
+       by default (i.e., deactivate auto-saving.)
+       (org-edit-src-code): Set `buffer-auto-save-file-name' for
+       auto-saving with `auto-save-mode'.
+
+       * org.el (org-deadline, org-schedule): When called with two
+       universal prefix arguments, set the warning time or the delay
+       relatively to the current timestamp, not to today's date.
+
+       * org-agenda.el (org-agenda-filter-apply): Deactive
+       `org-agenda-entry-text-mode' when filtering.
+       (org-agenda-entry-text-mode): Don't allow in filtered views.
+       Don't show the maximum number of lines when turning off.
+
+       * ox-html.el (org-html-headline): Add comment.
+
+       * org.el (org-mode): Set `paragraph-start'.
+
+       * org-agenda.el (org-agenda-entry-text-leaders): New option.
+       (org-agenda-entry-text-show-here): Use it.
+
+       * ox-html.el (org-html-link--inline-image): Always retrieve
+       attributes for inline images.
+       (org-html-link): Fix trailing whitespace at the end of the opening
+       <a ...> HTML tag.
+       (org-html-headline): For headlines whose first element is a
+       headline and not a section, pretend there is an empty section (as
+       "") for the correct HTML div to be inserted.
+
+       * org-agenda.el (org-agenda-collect-markers)
+       (org-create-marker-find-array): Move to ox-icalendar.el.
+       (org-agenda-marker-table, org-check-agenda-marker-table):
+       Delete.
+
+       * ox-icalendar.el (org-icalendar-create-uid): New parameter
+       H-MARKERS to only update some headlines, not the whole file.
+       (org-icalendar--combine-files): When exporting to an .ics file
+       only add UID to the headlines shown in the agenda buffer.
+       (org-agenda-collect-markers, org-create-marker-find-array):
+       Move here.
+
+       * org-agenda.el (org-agenda-write): Ask before overwriting an
+       existing file.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option/infojs_opt):
+       Use `org-html-infojs-opts-table'.
+
+       * ox-html.el (org-html-infojs-opts-table):
+       (org-html-use-infojs, org-html-infojs-options)
+       (org-html-infojs-template): Move from ox-jsinfo.el.  Rename using
+       the org-html- prefix.
+       (org-html-infojs-install-script): Move from ox-infojs.el.
+
+       * ox-infojs.el: Delete.
+
+       * ox-html.el (org-html-section): Fix indentation.
+       (org-html-inner-template): Add the document title here, within the
+       "content" class, as the org-info.js needs it.
+       (org-html-template): Don't include the document's title here.
+       (org-html-format-inlinetask-function): Remove wrong example.
+
+       * ob-tangle.el (org-babel-tangle-collect-blocks): Don't collect
+       blocks in commented out headings.
+
+       * ox-latex.el (org-latex-logfiles-extensions)
+       (org-latex-remove-logfiles): Improve docstrings.
+
+       * org-capture.el (org-capture): Cosmetic fix.
+
+       * org-protocol.el (org-protocol-create-for-org)
+       (org-protocol-create): Small docstrings enhancements.
+
+       * org-protocol.el (org-protocol-capture): Small docstring fix.
+
+       * org.el (org-speed-command-activate): Only forbid in src code
+       blocks.
+
+       * org-indent.el
+       (org-indent-add-properties): Bugfix: prevent negative value for
+       `added-ind-per-lvl'.
+
+       * org.el (org-mode): Add `org-fix-ellipsis-at-bol' to
+       `isearch-mode-end-hook' so that any isearch fixes the problem with
+       ellipsis on the first line.
+       (org-fix-ellipsis-at-bol): New defsubst.
+       (org-show-context, org-isearch-end): Use it.
+
+       * org-agenda.el (org-agenda-deadline-leaders): New formatting
+       string for past deadlines.
+       (org-agenda-scheduled-leaders): Small change.
+       (org-agenda-get-deadlines): Use the new formatting string.
+
+       * ob-lob.el (org-babel-lob-execute): Rename cache? to cache-p.
+
+       * org.el (org-speed-command-activate): Don't activate speed
+       commands within blocks.
+
+       * org.el (org-show-context): Remove useless catch.  Make sure the
+       top of the window is a visible headline.
+       (org-activate-plain-links): Remove unused catch.
+
+       * org-macs.el (org-get-alist-option): Return nil, not (nil), so
+       that `org-show-context' DTRT.
+
+       * org.el (org-imenu-get-tree): Fix bug when matching against empty
+       headlines.
+       (org-overview): Stay on current line.
+       (org-map-entries): Fix docstring.
+
+       * org-macs.el (org-unmodified): Update comment.  Don't define
+       `with-silent-modifications' for emacsen that don't have it.
+
+       * org-compat.el (org-with-silent-modifications): New
+       compatibility macro.
+
+       * org.el (org-refresh-category-properties)
+       (org-refresh-properties, org-entry-blocked-p)
+       (org-agenda-prepare-buffers):
+
+       * org-indent.el (org-indent-remove-properties)
+       (org-indent-add-properties):
+
+       * org-colview.el (org-columns-display-here)
+       (org-columns-remove-overlays, org-columns-quit)
+       (org-columns-edit-value, org-columns-compute-all)
+       (org-columns-compute, org-agenda-colview-compute):
+
+       * org-clock.el (org-clock-sum): Use the compatibility macro
+       `org-with-silent-modifications' instead of
+       `with-silent-modifications'.
+
+       * org.el (org-sort-remove-invisible): Remove emphasis markers.
+
+       * org.el (org-sort-remove-invisible): Use defsust.  Do not only
+       check against invisible links, truly returns the visible part of
+       the string.
+       (org-sort-remove-invisible): Add a docstring.
+       (org-sort-entries): Remove hidden links when comparing entries.
+
+       * org-list.el (org-sort-list): Remove hidden links when comparing
+       list items.
+
+       * ox-html.el (org-html-headline): Fix typo.
+       (org-html-format-headline--wrap): Cosmetic change.
+
+       * org.el (org-at-clock-log-p): Delete.
+
+       * org-clock.el (org-at-clock-log-p): Move here.
+
+       * ox-html.el (org-html-format-headline-function): Fix docstring.
+
+       * ob-sql.el (org-babel-execute:sql): Add header row delimiter for
+       both mysql and postgresql.
+
+       * org.el (org-agenda-prepare-buffers): Don't use
+       `with-silent-modifications' too early.
+
+       * org-macs.el: Add a comment on when to use `org-unmodified' and
+       when to use `with-silent-modifications'.
+
+       * org-colview.el (org-columns-display-here)
+       (org-columns-remove-overlays, org-columns-quit)
+       (org-columns-edit-value, org-columns-compute-all)
+       (org-columns-compute, org-agenda-colview-compute):
+       * org-clock.el (org-clock-sum):
+       * org.el (org-refresh-category-properties)
+       (org-refresh-properties, org-entry-blocked-p)
+       (org-agenda-prepare-buffers): Use `with-silent-modifications'
+       instead of `org-unmodified'.
+
+       * ox-publish.el (org-publish-sitemap-date-format): Small docstring
+       enhancement.
+
+       * ox-latex.el (org-latex-format-headline-default-function): New
+       option.
+       (org-latex-format-headline-function): Use the new option as
+       the default value.
+       (org-latex-toc-command): Don't add vertical space after the table
+       of contents.
+
+       * org.el (org-entry-blocked-p): Use `org-unmodified' instead of
+       `org-with-buffer-modified-unmodified'.
+       (org-agenda-prepare-buffers): Fix indentation.
+
+       * org-macs.el (org-unmodified): Rename from
+       `org-with-buffer-modified-unmodified'.
+       (org-with-buffer-modified-unmodified): Delete.
+
+       * ob-python.el (org-babel-python-command): Use a defcustom.
+       (org-babel-python-mode): Use a defcustom and default to
+       'python-mode when featured.
+
+       * org-agenda.el (org-agenda-start-day): Refer to `org-read-date'
+       in the docstring.
+
+       * ox-org.el (org-org-publish-to-org): Autoload.
+
+       * org-protocol.el:
+       * org-bibtex.el: Remove remember support.
+
+       * org-clock.el (org-clock-heading-for-remember): Delete.
+       (org-clock-in): Do not set the heading for remember.
+
+       * org.el (org-move-subtree-down, org-forward-element)
+       (org-backward-element):
+
+       * org-table.el (org-table-previous-field)
+       (org-table-move-column, org-table-move-row):
+
+       * org-list.el (org-move-item-down, org-move-item-up)
+       (org-cycle-item-indentation): Use `user-error' when moving or
+       modifying the element at point is not possible.
+
+       * ox-html.el (org-html-table-header-tags)
+       (org-html-table-data-tags, org-html-table-row-tags)
+       (org-html-table-align-individual-fields): Use the
+       org-export-html group.
+       (org-html-inline-src-block, org-html-link): Fix error messages.
+       (org-html-begin-plain-list): Fix formatting, better FIXME
+       comment.
+
+       * org.el (org-fill-paragraph): Fill using
+       `org-mode-transpose-word-syntax-table'.
+
+       * ox-org.el (org-org-publish-to-org): New defun.
+
+       * ox-html.el (org-export-htmlize): Delete group.
+       (org-html-htmlize-output-type)
+       (org-html-htmlized-org-css-url)
+       (org-html-htmlize-region-for-paste): Rename from
+       org-export-htmlize-*.
+       (org-html-htmlize-generate-css, org-html-fontify-code): Use
+       the correct names.
+
+       * org-compat.el (org-file-equal-p): New compatibility function.
+
+       * ox.el (org-export-output-file-name): Use the new function.
+
+       * org-clock.el (org-clock-set-current)
+       (org-clock-delete-current): Delete.
+       (org-clock-in, org-clock-out): Set and delete
+       `org-clock-current-task'.  Minor code clean-up.
+
+       * org-clock.el (org-clock-in, org-clock-in-last): Tell
+       `org-current-time' to always return a past time.
+
+       * org.el (org-current-time): New argument `past' to force
+       returning a past time when rounding.
+
+       * org-agenda.el (org-agenda-unmark-clocking-task): New function.
+       (org-agenda-mark-clocking-task): Use it.
+       (org-agenda-clock-in): Let the cursor where it is.
+       (org-agenda-clock-out): Ditto.  Also remove the
+       `org-agenda-clocking' overlay.
+
+       * org-agenda.el (org-agenda-set-restriction-lock): Fix restriction
+       so that it ends at the beginning of the next headline at the same
+       level.
+
+       * org.el (org-set-effort, org-property-next-allowed-value):
+       When needed, update the current clock effort time.
+       (org-next-link): New parameter `search-backward'.  Fix bug when at
+       a link with no 'org-link face, e.g., in a DONE headline.  Throw a
+       message instead of an error.
+       (org-previous-link): Use `org-next-link'.
+
+       * org-agenda.el (org-agenda-format-item): Only set the breadcrumbs
+       when `org-prefix-has-breadcrumbs' is non-nil.
+
+       * org.el (org-mode): Don't make characters from
+       `org-emphasis-alist' word constituents.
+       (org-mode-transpose-word-syntax-table): Rename from
+       `org-syntax-table'.
+       (org-transpose-words): Use
+       `org-mode-transpose-word-syntax-table'.
+
+       * ox.el (org-export--dispatch-ui)
+       (org-export--dispatch-action): Use integers for control chars.
+
+       * org-agenda.el (org-agenda-set-restriction-lock): Put the
+       overlay until the end of the subtree, not the end of the
+       headline.
+
+       * org.el (org-entry-delete, org-delete-property): New optional
+       arg delete-empty-drawer, a string, to delete any empty drawer
+       with that name.
+       (org-toggle-ordered-property): Delete the drawer "PROPERTIES"
+       if empty.
+
+       * org-src.el (org-src-mode-map, org-edit-src-code)
+       (org-edit-fixed-width-region, org-edit-src-save): Use C-c C-k
+       for `org-edit-src-abort'.
+
+       * org.el (org-mode): Use org-unmodified during startup
+       initialization for functions that may be inhibited.
+
+       * org-table.el (org-table-align): Only set the window start
+       when table alignment is performed in the selected window.
+
+       * org-src.el (org-edit-src-auto-save-idle-delay): New option.
+       (org-src-ask-before-returning-to-edit-buffer): Make a defcustom.
+       (org-edit-src-code-timer): New timer variable.
+       (org-edit-src-code): Run the timer.
+       (org-edit-fixed-width-region): Enhance message.
+       (org-edit-src-exit): Cancel the timer.
+       (org-edit-src-save): Prevent saving when editing fixed-width
+       buffer, exiting will save already.
+       (org-edit-src-exit): Inconditionally kill the src/example
+       editing buffer.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option): Require
+       'org-element.  This fixes a bug about unbound variable
+       `org-element-affiliated-keywords' when trying to complete a
+       keyword before 'org-element was required.
+
+       * org-list.el (org-list-bullet-string): Replace match when there
+       is a match, otherwise just return the bullet.
+
+       * org-src.el (org-src-mode-map): New binding C-c k to abort
+       editing.
+       (org-edit-src-code): Mention the keybinding to abort editing
+       and go back to the correct position.
+       (org-edit-src-abort): New command to abort editing.
+
+       * ox-html.el (org-html--build-meta-info): Add a newline before
+       the title meta information.
+
+       * org.el (org-return-follows-link): Mention that this does not
+       affect the behavior of RET in tables.
+
+       * ox-html.el (org-html--build-mathjax-config): Only include
+       MathJax configuration if the resulting HTML contains LaTeX
+       fragments.
+
+       * org.el (org-syntax-table, org-transpose-words): Delete.
+       (org-mode): Syntactically Define {} and <> as parentheses.
+       (org-drag-line-forward, org-drag-line-backward): New
+       functions.
+       (org-shiftmetaup, org-shiftmetadown): Fall back on the new
+       functions instead of throwing an error.
+       (org-make-org-heading-search-string): Don't use statistic or [x/y]
+       cookies when creating a link.
+
+       * ox-html.el (org-html-table): Append #+attr_html attributes.
+
+       * org.el (org-emphasis-alist, org-protecting-blocks):
+       * org-src.el (org-edit-src-find-region-and-lang):
+       * org-list.el (org-list-forbidden-blocks):
+       * org-footnote.el (org-footnote-forbidden-blocks): Remove
+       references to the deleted DocBook exporter.
+
+       * org.el (org-end-of-line): Don't throw an error outside elements.
+
+       * ox-html.el (org-html-link): Don't throw an error if the value
+       of the :ID: property has not been generated by uuidgen.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option/x):
+       Resurrect.  Use `org-default-options' to initialize completion
+       fonctions for the most important keywords.
+
+       * org-macs.el (org-default-options): Rename and adapt from
+       `org-get-current-options'.
+
+       * org.el (org-options-keywords): Add keywords.
+
+       * ox-odt.el (org-odt-convert-read-params): Fix typo in prompt.
+
+       * ox-latex.el (org-latex-horizontal-rule): Fix typo in docstring.
+
+       * ox-html.el (org-html-display-buffer-mode): New option.
+       (org-html-export-as-html): Use it.
+
+       * ob-core.el (org-babel-insert-result): Fix bug when inserting
+       an empty string as the result.
+
+       * org.el (org-timestamp-change): New optional parameter
+       `suppress-tmp-delay' to suppress temporary delay like "--2d".
+       (org-auto-repeat-maybe): Suppress temporary delays.
+
+       * org-agenda.el (org-agenda-get-scheduled): When the delay is
+       of the form "--2d" and there is a repeater, ignore the delay
+       for further repeated occurrences.
+
+       * org-agenda.el (org-agenda-get-deadlines)
+       (org-agenda-get-scheduled): Minor refactoring.
+
+       * org.el (org-time-string-to-absolute): Tiny docstring enhancement.
+       (org-edit-special): Don't allow to edit when buffer is read only.
+
+       * ox-html.el (org-html-format-latex): Don't set `cache-relpath'
+       and `cache-dir' when `processing-type' is 'mathjax.
+       (org-html-format-latex): Fix conversion in non-file buffers.
+
+       * org.el (org-speed-commands-default): Bind `B' and `F' to
+       `org-previous-block' and `org-next-block'.
+       (org-read-date-minibuffer-local-map): Use "!" instead of "?" to
+       see today's diary as "?" is already bounded by Calendar.
+       (org-read-date-minibuffer-local-map): Use "." to go to today's
+       date.
+
+       * ob-core.el (org-babel-next-src-block)
+       (org-babel-previous-src-block): Rewrite using
+       `org-next-block'.
+
+       * org.el (org-next-block, org-previous-block): New navigation
+       commands.
+       (org-mode-map): Bind the new commands to C-c C-F and C-c C-B
+       respectively.
+
+       * org-agenda.el (org-agenda-write): Don't copy headlines' subtrees
+       when writing to an .org file.
+
+       * org.el (org-copy-subtree): New parameter `nosubtrees'.
+
+       * org-agenda.el (org-agenda-write): Allow writing to an .org file.
+
+       * org.el (org-paste-subtree): Fix typo in docstring.
+
+       * org-agenda.el (org-agenda-get-todos)
+       (org-agenda-get-timestamps): Use nil as `ts-date' for diary
+       sexpressions.
+       (org-agenda-get-todos): Skip diary sexps when trying to sort by
+       timestamp.
+       (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.
+
+       * 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 (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.
+
+       * 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.)
+
+       * ob-lilypond.el (ly-process-basic): Bugfix, don't use `pcase'.
+
+       * org.el (org-contextualize-validate-key): Check against two new
+       context predicates [not-]in-buffer.
+
+       * org-agenda.el (org-agenda-custom-commands-contexts):
+       Document the new [not-]in-buffer context predicates.
+
+       * ob-core.el (org-ts-regexp): Remove duplicate defconst'ing.
+       (org-babel-result-regexp): Don't use `org-ts-regexp', use a regexp
+       string directly.
+
+       * ob-lilypond.el (ly-process-basic): Don't use `ly-gen-png' and
+       friends, rely on the extension of the output file.
+
+       * org-archive.el (org-archive-file-header-format): New option.
+       (org-archive-subtree): Use it.
+
+       * ob-lilypond.el (ly-process-basic): Rely on ly-gen-png/pdf/eps to
+       set the output type.
+
+       * org.el (org-read-date-minibuffer-local-map): New variable.
+       (org-read-date): Use it.
+       (org-read-date-minibuffer-setup-hook): Mark as obsolete.
+       (org-read-date): Bind `!' to `diary-view-entries' in order to
+       check diary entries while setting an Org date.
+
+       * org-agenda.el (org-diary): Only keep the descriptions of the
+       links since Org links are not active in the diary buffer.
+
+       * org-faces.el (org-priority): New face.
+
+       * org.el (org-font-lock-add-priority-faces): Use the new face.
+
+       * org-agenda.el (org-agenda-fontify-priorities): Use the
+       org-priority face and add specific agenda face on top of it.
+
+       * org-agenda.el (org-agenda-show-clocking-issues)
+       (org-agenda-format-item): Let-bind
+       `org-time-clocksum-use-effort-durations' to nil.
+
+       * org.el (org-ctrl-c-ctrl-c): Only throw a message when using two
+       universal prefix arguments on a list where all items are already
+       in a transitory state.  Refine the error when the checkbox cannot
+       be toggled.
+
+       * org.el ("org-loaddefs.el"): Load org-loaddefs.el before
+       requiring any org library.  Also use `load', not
+       `org-load-noerror-mustsuffix'.
+       (org-effort-durations): Move up to fix a compiler warning.
+       (org-edit-special): Fix typo in docstring.
+       (org-time-clocksum-format): Add a version tag and add to the
+       'org-clock group.
+       (org-time-clocksum-use-fractional): Ditto.
+       (org-time-clocksum-use-effort-durations): New option to allow
+       using `org-effort-durations' when computing clocksum durations.
+       (org-minutes-to-clocksum-string): Use the new option.
+
+       * org-clock.el (org-clocktable-write-default): Let-bind
+       `org-time-clocksum-use-effort-durations' to a new clocktable
+       parameter ":effort-durations".
+
+       * org-entities.el (org-entities): "neg" should be used in LaTeX
+       math mode.  Add the "neg" entity.
+
+       * org-mobile.el (org-mobile-allpriorities): New option.
+       (org-mobile-create-index-file): Use the new option.
+
+       * org-latex.el (org-export-latex-inline-images): New option.
+
+       * org.el (org-forward-heading-same-level): Before the first
+       headline, go to the first headline.
+       (org-backward-heading-same-level): Before the first headline,
+       go to the beginning of the buffer, like
+       `outline-previous-visible-heading' does.
+
+       * org-exp.el (org-export-plist-vars): Don't use
+       `org-export-html-inline-images' to set the :inline-images
+       property, use distinct properties for the various backends.
+
+       * org-publish.el (org-publish-project-alist): Ditto.
+
+       * org-latex.el (org-export-latex-links): Use :latex-inline-images
+       instead of :inline-images.
+
+       * org-odt.el (org-compat): Require.
+
+       * org.el (org-parse-time-string): Allow strings supported by
+       tags/properties matcher (eg <now>, <yesterday>, <-7d>).
+
+       * org-clock.el (org-clock-rounding-minutes): New option to round
+       the time by N minutes in the past when clocking in or out.
+       (org-clock-in, org-clock-in-last, org-clock-out): Use the new
+       option.
+
+       * org.el (org-current-time): New optional parameter
+       `rounding-minutes' to override the use of
+       `org-time-stamp-rounding-minutes' for rounding.
+
+       * org-clock.el (org-clock-special-range): Small docstring fix.
+       New parameter 'weekstart to define the week start day.
+       (org-clock-special-range, org-dblock-write:clocktable)
+       (org-dblock-write:clocktable, org-clocktable-write-default)
+       (org-clocktable-steps, org-clock-get-table-data): Use the new
+       parameter.
+       (org-clocktable-defaults): Set monday as the starting day of the
+       week by setting :wstart to 1.
+
+       * org.el (org-store-link): Fix the naming of internal links to
+       lines starting with a keyword.
+
+       * org-agenda.el (org-agenda-Quit, org-agenda-quit)
+       (org-agenda-exit, org-agenda-kill-all-agenda-buffers):
+       Docstring fixes.
+
+       * org.el (org-last-set-property-value): New variable.
+       (org-read-property-name): Fix dangling parentheses.
+       (org-set-property-and-value): New command to manually set
+       both the property and the value.  A prefix arg will use the
+       last property-value pair set without prompting the user.
+       (org-set-property): Set `org-last-set-property-value'.
+       (org-mode-map): Bind the new command to `C-c C-x P'.
+       (org-find-invisible-foreground): Delete.
+       (org-mode): Use `face-background' instead of
+       `org-find-invisible-foreground'.
+       (org-startup-options): New startup keywords.
+       (org-log-into-drawer): Update docstring to explain how to set this
+       variable through the startup keyword "logdrawer" and "nologdrawer".
+       (org-log-states-order-reversed): Document the new startup keywords
+       "logstatesreversed" and "nologstatesreversed".
+       (org-mode-map): Use `org-remap' instead of binding `M-t' to
+       `org-transpose-words' directly.
+       (org-syntax-table): New variable.
+       (org-transpose-words): New command, simply wrapping the new
+       syntax table around `transpose-words'.
+       (org-mode-map): Bind `org-transpose-words' to `M-t'.
+       (org-store-link): Use keyword at point as the search string.  Use
+       `delq nil' instead of `delete nil'.
+       (org-make-org-heading-search-string): Rewrite using
+       org-element.el.  Not an interactive function anymore.
+
+       * org-pcomplete.el (pcomplete/org-mode/drawer): Ditto.
+
+       * org-mobile.el (org-mobile-files-alist): Ditto.
+
+       * org.el (org-store-link): When creating a link to a heading with
+       a bracket link, don't escape this link with curly braces as the
+       escaped link is not active anyway; use the description instead.
+       If the headline only consists of a bracket link, add a star to the
+       description so that the user knows this is an internal link.
+
+       * org-w3m.el (org-w3m-store-link): New function.
+
+       * org.el (org-store-link): Update the error message when no method
+       is available for storing a link.  Use `user-error' for this.
+       Remove handling w3m links from this function.
+       (org-insert-heading, org-insert-todo-heading): A double prefix arg
+       force the insertion of the subtree at the end of the parent
+       subtree.
+       (org-store-link): A double prefix argument now skips module
+       store-link functions to only use Org's core functions.  Also, when
+       several modular store-link functions match, ask for which one to
+       use.
+       (org-cycle, org-cycle-internal-global)
+       (org-cycle-internal-local, org-display-outline-path): Let-bind
+       `message-log-max' to nil so that messages don't populate the
+       *Messages* buffer.
+
+       * org-table.el (org-table-eval-formula): Handle localized
+       time-stamps by internally converting them to english during
+       formulas evaluation.
+
+       * org.el (org-clock-timestamps-up): Fix declarations.
+
+       * ob-core.el (org-split-string): Declare function.
+
+       * org-html.el (org-html-export-list-line): Add CSS classes to
+       these list HTML tags: <ul> <dl> and <ol>.
+
+       * org-clock.el (org-clock-timestamps-up)
+       (org-clock-timestamps-down, org-clock-timestamps-change): Add
+       an optional argument N to change timestamps by several units.
+
+       * org.el (org-shiftcontrolup, org-shiftcontroldown): Ditto.
+
+       * org-exp.el (org-export-copy-to-kill-ring): Add a new choice
+       'if-interactive and use it as the default.
+       (org-export-push-to-kill-ring): Use the new choice.
+
+       * org.el (org-block-entry-blocking): New variable.
+       (org-todo): Use it.  Also use `user-error' when a TODO state
+       change is blocked.
+       (org-block-todo-from-children-or-siblings-or-parent): Display
+       `org-block-entry-blocking' in the user-error message.
+
+       * org.el (org-get-cursor-date): New optional argument WITH-TIME to
+       add the time of the day.
+
+       * org-capture.el (org-capture): When capturing from the agenda and
+       with a non-nil value for `org-capture-use-agenda-date', a `C-1'
+       prefix will set the capture time to the HH:MM of the current line
+       or the current HH:MM.
+
+       * org-agenda.el (org-agenda-capture): New optional argument
+       WITH-TIME: when set to 1, the capture time will be set to the
+       HH:MM time of the current line, or the current HH:MM time.
+
+       * org.el (org-latex-preview-ltxpng-directory): Fix docstring
+       formatting.
+       (org-deadline-close): Use `org-time-stamp-to-now'.
+       (org-time-stamp-to-now): Use `org-float-time' instead of the
+       obsolete `time-to-seconds' function.
+       (org-format-outline-path): Fix bug: add the separator string after
+       the prefix.
+       (org-display-inline-images): Search for #+ATTR within the current
+       paragraph.
+       (org-days-to-time): Make obsolete.
+       (org-time-stamp-to-now): Rename from `org-days-to-time'.
+       Allow to compare time-stamps based on seconds.
+
+       * org-agenda.el (org-agenda-todo-ignore-time-comparison-use-seconds):
+       New option to compare time stamps using seconds, not days.
+       (org-agenda-todo-custom-ignore-p)
+       (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
+       Use the new function's name and the new option.
+
+       * org-clock.el (org-clock-sound): Enhance docstring.
+       (org-notify): Use the parameter `play-sound' as argument for
+       `org-clock-play-sound'.
+       (org-clock-play-sound): New optional argument `clock-sound' to
+       override `org-clock-sound'.
+
+       * org-agenda.el (org-agenda-format-item): Fix initialization
+       of the level text property.
+
+       * org.el (org-format-outline-path): Small docstring
+       enhancement.
+       (org-display-outline-path): Fix order or arguments.
+
+       * org.el (org-activate-plain-links)
+       (org-activate-bracket-links): Add a new 'htmlize-link text
+       property, so that htmlize (> version 1.42) can linkify the
+       links.
+       (org-display-outline-path): Allow a string value for the
+       `as-string' parameter.  Such a value will replace the "/"
+       separator in the output.  New argument `as-string'.
+       (org-refile-keep): New variable.
+       (org-copy): New command to copy notes.
+       (org-refile): New parameter msg to override the "Refile" string in
+       the default prompt.
+       (org-mode-map): Bind "C-c M-w" to `org-copy'.
+       (org-refile-get-location): Use the current file name as the
+       default target when there is no refile history.
+       (org-cycle-hide-inline-tasks): New function to hide inline tasks
+       when cycling.
+       (org-cycle-hook): Use the new function.
+       (org-entry-put): Fix bug when updating the last clock.
+       (org-use-last-clock-out-time-as-effective-time): New option.
+       (org-current-effective-time): Use the new option.
+
+       * org-clock.el (org-clock-get-last-clock-out-time): New
+       function.
+
+       * org.el (org-toggle-inline-images): Only send a message when
+       called interactively.
+       (org-scan-tags): Fix the declaration and the use of
+       `org-agenda-format-item'.
+
+       * org-agenda.el (org-agenda-add-time-grid-maybe): Use the
+       correct number of parameters for `org-agenda-format-item'.
+       Add a docstring.
+
+       * org.el (org-outline-level): Go at the beginning of the
+       headline first to always return a sensible result.
+
+       * org-agenda.el (org-search-view, org-agenda-get-todos)
+       (org-agenda-get-timestamps, org-agenda-get-sexps)
+       (org-agenda-get-progress, org-agenda-get-deadlines)
+       (org-agenda-get-scheduled, org-agenda-get-blocks): Return the
+       correct level depending on `org-odd-levels-only'.
+       (org-agenda-prefix-format): A new specifier `%l' allows to insert
+       X spaces when the item is of level X.
+       (org-search-view, org-get-entries-from-diary)
+       (org-agenda-get-todos, org-agenda-get-timestamps)
+       (org-agenda-get-sexps, org-agenda-get-progress)
+       (org-agenda-get-deadlines, org-agenda-get-scheduled)
+       (org-agenda-get-blocks, org-agenda-change-all-lines): Add a
+       new text property 'level, a string with as many whitespaces as
+       the level of the item.
+       (org-agenda-format-item, org-compile-prefix-format): Handle
+       the new `%l' specifier.
+
+       * org-colview.el (org-columns-next-allowed-value): Add the
+       CLOCKSUM property to the list of properties that can be
+       changed interactively from the column view.
+
+       * org.el (org-entry-put): Allow to set the CLOCKSUM property
+       by updating the most recent clock.  This is useful in the
+       column view when you want to use S-<left/right> to update the
+       last clock of the entry at point.
+       (org-image-actual-width): New choice: use #+ATTR* or fall back on
+       a number.
+       (org-display-inline-images): Implement the new choice.
+       (org-image-actual-width): Rename from `org-image-fixed-width'.
+       Update the docstring.  Give more choice.
+       (org-display-inline-images): Use the option new choices.
+       (org-image-fixed-width): New option to set a fixed width for
+       inline images.
+       (org-display-inline-images): Use the new option.
+
+       * org-agenda.el (org-class): Allow to use holiday strings for
+       the `skip-weeks' arguments.
+
+       * org.el (org-mode): Set the syntax of the " character to "string
+       quote".
+
+       * org-agenda.el (org-agenda-append-agenda): Bugfix: correctly
+       check whether we are in `org-agenda-mode'.
+       (org-agenda): Set `org-agenda-buffer-name' correctly with sticky
+       agendas and non-custom commands.
+
+2013-11-12  Carsten Dominik  <carsten.dominik@gmail.com>
+
+       * org-src.el (org-edit-src-exit): Let overlay survive after the
+       buffer has been saved.
+
+       * ox-texinfo.el (org-texinfo-export-to-texinfo): Use new style
+       backquoting.
+       (org-texinfo-export-to-info): Use new style backquoting.
+
+       * ob-latex.el (org-babel-execute:latex): Call `file-name-sans-extension'
+       instead of `file-base-name'.
+
+       * org.el (org-insert-heading): Improve whitespace behavior at
+       end of subtree.
+       (org-latex-default-packages-alist): Add the `rotating' package to
+       the list of default packages.  Improve docstring.
+       (org-insert-property-drawer): Insert only after space in current
+       line.
+       (org-forward-paragraph, org-backward-paragraph): Do not deactivate
+       the mark.
+       (org-special-ctrl-o): New option.
+       (org-open-line): Don't do anything special unless `org-special-ctrl-o'
+       is non-nil.
+
+       * org-agenda.el (org-agenda-custom-commands-local-options):
+       (org-agenda-span, org-agenda-ndays-to-span)
+       (org-agenda-span-to-ndays, org-agenda-list, org-agenda-later)
+       (org-agenda-change-time-span, org-agenda-compute-starting-span): Add
+       support for fortnight view.
+       (org-agenda-menu): Add fortnight view command.
+       (org-agenda-fortnight-view): New command.
+
+       * org-timer.el (org-clock-sound): Silence compiler.
+
+       * org.el (org-beginning-of-line, org-end-of-line): Bind
+       deactivate-mark to avoid that this command deactivates it.
+       (org-make-tags-matcher): Do not interpret / in property value as
+       starter of TODO match.
+       (org-overview): Preserve point.
+       (org-read-date-minibuffer-local-map): Don't replace disputed keys
+       when defining this keymap.
+       (org-read-date): Remove unnecessary binding of
+       `org-replace-disputed-keys'.
+       (org-insert-heading): Allow to remove blank lines if the user does
+       not want any.
+       (org-unlogged-message): Fix typo in dostring.
+
+       * ob-ruby.el: New customizations `org-babel-ruby-hline-to' and
+       `org-babel-ruby-nil-to'
+       (org-babel-ruby-var-to-ruby): Convert incoming 'hlines.
+       (org-babel-ruby-table-or-string): Convert outgoing nils.
+
+       * org.el (org-file-apps-defaults-gnu): Use `xdg-open' to open
+       files where available.
+
+       * org-table.el (orgtbl-radio-table-templates): Improve docstring.
+
+       * org.el (org-unlogged-message): New function.
+       (org-cycle, org-cycle-internal-global, org-cycle-internal-local)
+       (org-global-cycle, org-display-outline-path): Use
+       `org-unlogged-message'.
+
+       * org-pcomplete.el (org-make-org-heading-search-string): Fix
+       function declaration.
+       (pcomplete/org-mode/searchhead): Remove incorrect second arguments
+       to `org-make-org-heading-search-string'.
+
+       * org.el (org-read-date): Turn off replacing disputed keys when
+       defining the minibuffer keys during date selection.
+       (org-insert-heading): Improve the empty line insertion behavior.
+       Basically, never remove empty lines, only add them.
+
+       * org-attach.el (org-attach-commit): Use vc-git to find the git
+       repository.
+
+       * org-compat.el (org-move-to-column): Turn off invisibility stuff
+       for moving the cursor to a column.
+
+       * org.el (org-modules): Update with the new module org-mac-link.
+       (org-display-outline-path): Do not log outline path in Message
+       buffer.
+       (org-agenda-ignore-drawer-properties): New option.
+       (org-agenda-prepare-buffers): Honour
+       `org-agenda-ignore-drawer-properties'.
+
+       * org-clock.el (org-clock-goto): Recenter to thrd line
+
+       * org-table.el (orgtbl-send-replace-tbl): Allow multiple spaces
+       between keywords in RECEIVE ORGTBL lines.
+
+       * org.el (org-bookmark-names-plist): New user option.
+       (org-set-regexps-and-options-for-tags): Use `org-bookmark-names-plist'.
+       (org-refile): Use `org-bookmark-names-plist'.
+
+       * org-capture.el (org-capture-bookmark-last-stored-position): Use
+       `org-bookmark-names-plist'.
+
+       * org.el (org-insert-heading): Rewritten from scratch.
+       (org-N-empty-lines-before-current): New function
+       (org-insert-heading-respect-content): Set the correct argument to
+       force a heading even in lists.
+
+       * org-colview.el (org-columns-display-here): Enforce fixed width
+       font.
+
+       * org-faces.el (org-column): Setting font width has been shifted
+       to org-colview.el.
+
+       * org.el (org-mode-flyspell-verify): Check for src block.
+
+       * org-table.el (org-table-convert-region): Fix interactive
+       statement.
+
+       * org-ctags.el (org-ctags-path-to-ctags): Avoid usine `case'.
+
+       * org.el (org-beginning-of-line,org-end-of-line): Set
+       disable-point-adjustment when the command ends next to invisible
+       text.
+
+       * ob-lob.el (org-babel-lob-files): Fix custom type.
+
+       * org-agenda.el (org-agenda-export-html-style, org-agenda-ndays)
+       (org-agenda-inactive-leader, org-agenda-day-face-function)
+       (org-agenda-auto-exclude-function): Fix custom type.
+
+       * org-bibtex.el (org-bibtex-prefix): Fix custom type.
+
+       * org-clock.el (org-clock-heading-function):
+       (org-show-notification-handler): Fix custom type.
+
+       * org-footnote.el (org-footnote-auto-adjust): Fix custom type.
+
+       * org-protocol.el (org-protocol-default-template-key): Fix custom
+       type.
+
+       * org.el (org-make-link-description-function):
+       (org-link-translation-function):
+       (org-link-frame-setup):
+       (org-refile-target-verify-function):
+       (org-get-priority-function):
+       (org-use-fast-tag-selection):
+       (org-columns-modify-value-for-display-function):
+       (org-sparse-tree-default-date-type):
+       * ox-html.el (org-html-postamble):
+       (org-html-postamble-format):
+       (org-html-preamble-format):
+       * ox-odt.el (org-odt-content-template-file):
+       * ox.el (org-export-with-archived-trees):
+       (org-export-initial-scope): Fix custom type.
+
+       * org.el (org-insert-heading): Fix problem with inserting heading.
+       Check for checkbox at the beginning of the item, not just at the
+       beginning of the line.
+       (org-small-year-to-year): Fix docstring typo.
+       (org-show-siblings): By default, also show siblings from a
+       bookmark jump.
+
+       * org-agenda.el (org-agenda-set-restriction-lock): Highlight only
+       the headline when agenda is restricted to a subtree.  Do not
+       highlight the entire subtree.
+
+       * org-table.el (org-table-eval-formula): Work-around for calc-eval
+       regression.
+
+       * ox.el (org-export-dispatch): Make sure the last position marker
+       uses the base buffer if there is one.
+       (org-export-dispatch-last-position): New variable.
+       (org-export-dispatch): Save position of cursor at the moment when
+       the export command is called.  Restore that position temporarily
+       when repeating the previous export command.
+
+       * org.el (org-insert-heading): Shrink whitespace at end of subtree
+       when `org-insert-heading-respect-content' is on.
+
+       * org-list.el (org-sort-list): Respect sorting-type and
+       getkey-func when they are specified in the call.
+
+       * org.el (org-sort-entries): Respect sorting-type and getkey-func
+       when they are specified in the call.
+       (org-format-outline-path): New argument SEPARATOR to specify a
+       string that is inserted between parts of the outline path.
+       (org-display-outline-path): New argument SEPARATOR, to specify a
+       string that is inserted between parts of the outline path.
+
+       * org-colview.el (org-dblock-write:columnview): Change the capture
+       of pos to after inserting the original content
+
+2013-11-12  Christian Moe  <mail@christianmoe.com>
+
+       * ox-odt.el (org-odt-line-break, org-odt-plain-text): Remove
+       newline after line-break tag.
+
+2013-11-12  Christophe Junke  <christophe.junke@inria.fr>  (tiny change)
+
+       * org.el (org-set-font-lock-defaults): Let footnote fontifications
+       be done before other links' fontification.  This allows links
+       appearing inside footnotes to be both visible and active.
+
+2013-11-12  Christopher Schmidt  <christopher@ch.ristopher.com>
+
+       * org.el (orgstruct-setup): Major rewrite.
+       (orgstruct++-mode): Overwrite local non-org vars again.
+       (orgstruct-mode): Simplify implementation.  Emulate outline's
+       buffer-invisiblity-spec.
+       (orgstruct-heading-prefix-regexp): Change default value to nil.
+       (orgstruct-error): Use `user-error' if available.
+       {pro,de}motion commands if `orgstruct-heading-prefix-regexp' is
+       non-nil.  Always use `org-outline-level'.  Bind org-shift*.
+       (orgstruct-make-binding): Major rewrite.
+       (org-cycle-global-status, org-cycle-subtree-status): Set state
+       property.
+       (org-heading-components): Use `org-heading-regexp' in
+       orgstruct-mode.
+       (orgstruct-heading-prefix-regexp, orgstruct-setup-hook): New
+       options.
+       (orgstruct-initialized): New variable.
+       (org-get-local-variables): Honour state property.
+       (org-run-like-in-org-mode): Use `let' instead of `progv'.  Do not
+       override variables with non-default values.
+       (org-forward-heading-same-level): Do not skip to headlines on
+       another level.  Handle negative prefix argument correctly.
+       (org-backward-heading-same-level): Use
+       `org-forward-heading-same-level'.
+
+2013-11-12  Craig Tanis  <craig-tanis@utc.edu>  (tiny change)
+
+       * ox-latex (org-latex-src-block): Change format string to position
+       caption after figure content.
+
+2013-11-12  Eric Abrahamsen  <eric@ericabrahamsen.net>
+
+       * org.el (org-ctrl-c-ctrl-c): `C-c C-c' on a link is usually a
+       no-op.  If that link is in a headline, act as if the `C-c C-c' was
+       called on the headline, not the link.
+
+       * ox-html.el (org-html-doctype-alist): New variable holding an
+       alist of (X)HTML doctypes
+       (org-html-xhtml-p, org-html-html5-p, org-html-close-tag): New
+       function.
+       (org-html-html5-fancy): New export option, determining whether or
+       not to use HTML5-specific elements.
+       (org-html-html5-elements): New variable, new HTML5 elements.
+       (org-html-special-block): Export special blocks to new HTML5
+       elements.
+       (org-html-format-inline-image): Use <figure> and <figcaption> for
+       standalone images.
+       (org-html-format-inline-image, org-html--build-meta-info)
+       (org-html--build-head, org-html--build-pre/postable)
+       (org-html-template, org-html-horizontal-rule)
+       (org-html-format-list-item, org-html-line-break, org-html-table)
+       (org-html-verse-block): Changes to allow flavored export.
+
+       * ox-latex.el (org-latex--org-table, org-latex-table-row): Allow
+       use of the "tabu" and "longtabu" table environments.  New table
+       attribute :spread handles the width specification syntax of "tabu"
+       and "longtabu" table environments.
+
+2013-11-12  Eric Schulte  <eric.schulte@gmx.com>
+
+       * org-bibtex.el (org-bibtex-read-buffer): Reads all bibtex entries
+       in a buffer.
+       (org-bibtex-read-file): Read all bibtex entries in a file.
+       (org-bibtex-import-from-file): Import all bibtex entries from a
+       file into the current buffer.
+
+       * ob-tangle.el (org-babel-load-file): When called with a prefix
+       argument the tangled emacs-lisp file will be byte compiled.
+
+       * ob-tangle.el (org-babel-tangle): Tangled files should not be
+       writable.
+
+       * ob-emacs-lisp.el (org-babel-execute:emacs-lisp): Better about
+       when to fully escape the results or just print them close to
+       verbatim.
+
+       * ob.el (org-babel-result-cond): This function should now be used
+       by all language backends to handle the processing of raw code
+       block output into scalar results, table results, or ignored
+       results depending on the value of result-params.
+
+       * ob-C.el (org-babel-C-execute): Use org-babel-result-cond.
+
+       * ob-R.el (org-babel-R-evaluate-external-process)
+       (org-babel-R-evaluate-session):
+       * ob-awk.el (org-babel-execute:awk):
+       * ob-clojure.el (org-babel-execute:clojure):
+       * ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
+       * ob-fortran.el (org-babel-execute:fortran):
+       * ob-io.el (org-babel-io-evaluate):
+       * ob-java.el (org-babel-execute:java):
+       * ob-lisp.el (org-babel-execute:lisp):
+       * ob-maxima.el (org-babel-execute:maxima):
+       * ob-picolisp.el (org-babel-execute:picolisp):
+       * ob-python.el (org-babel-python-evaluate-external-process):
+       (org-babel-python-evaluate-session):
+       * ob-scala.el (org-babel-scala-evaluate):
+       * ob-sh.el (org-babel-sh-evaluate):
+       * ob-shen.el (org-babel-execute:shen):
+       * ob-sql.el (org-babel-execute:sql):
+       * ob-sqlite.el (org-babel-execute:sqlite): Use
+       `org-babel-result-cond'.
+
+       * ob.el (org-babel-common-header-args-w-values): Add a new "none"
+       header argument.
+       (org-babel-execute-src-block): Don't do *any* result processing if
+       the "none" header argument has been specified.
+       (org-babel-sha1-hash): Remove the none header argument from header
+       arg lists when calculating cache sums.
+       (org-babel-insert-result): Flesh out some documentation.
+
+       * ob.el (org-babel-insert-result): Don't escape results in
+       drawers.
+
+       * ob-python.el (org-babel-python-hline-to): Customize hline
+       conversion to python.
+       (org-babel-python-None-to): Customize none conversion from python.
+       (org-babel-python-var-to-python): Use new variable.
+       (org-babel-python-table-or-string): Use new variable.
+
+       * org.el (org-babel-load-languages): Add ob-makefile to
+       `org-babel-load-languages'.
+
+       * ob-makefile.el: New file.
+
+       * ob-sh.el (org-babel-sh-evaluate): Don't could 0-length shebangs.
+
+       * org.el (org-format-latex): Simplify and now make use of the new
+       `org-create-formula-image' function.
+       (org-create-formula-image): Provides a simpler interface to the
+       two backend-specific functions.
+
+       * ob-core.el (org-babel-default-header-args): It is likely that
+       someone meant to set :padlines to "yes", but accidentally set
+       :padnewlines to "yes".  Either way lets just remove this which
+       shouldn't have any functional effect.
+
+       * ob-haskell.el (org-babel-default-header-args:haskell): Set
+       :padlines to "no" by default.
+
+       * ob-exp.el (org-babel-exp-non-block-elements): Ignore inline
+       source block on #+ prefixed lines.
+
+       * ob-core.el (org-babel-merge-params): Replace `remove-if' with
+       `org-remove-if'.  More careful to check that the colname- and
+       rowname-names header arguments exist during merge.  When merging
+       parameters, if a variable is replaced with a new value, then
+       delete colnames/rownames for the original value of that variable.
+
+       * ob-ditaa.el (org-babel-ditaa-java-cmd): Make java executable
+       configurable for ditaa blocks.
+
+       * ob-sh.el (org-babel-sh-var-to-string): Fix bug in ob-sh when
+       dealing with list variables.
+
+       * ob-core.el (org-babel-demarcate-block): Include
+       `org-src-lang-modes' in block demarcation options.
+
+       * ob-C.el: Don't modify `org-babel-load-languages' from ob-*
+       files.
+
+       * ob-latex.el (org-babel-latex-htlatex): Set this variable to
+       "htlatex" (or path to said) to enable svg generation from latex
+       code blocks.
+       (org-babel-latex-htlatex-packages): Libraries required for
+       automatic svg generation.
+       (org-babel-execute:latex): Generate SVG images directly from latex
+       code blocks (assumes tikz).
+
+       * ob-exp.el (org-babel-exp-non-block-elements): Use lob call name
+       when exporting.
+
+       * ob-scheme.el (org-babel-scheme-get-repl)
+       (org-babel-scheme-make-session-name)
+       (org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
+       Fix whitespace and indentation.
+
+       * ob-core.el (org-babel-set-current-result-hash): Update the
+       match-string holding the hash data, and correct overlay
+       maintenance.
+       (org-babel-find-named-result): Call lines are not results.
+       (org-babel-where-is-src-block-result): Don't implicitly name the
+       results of call lines.
+       (org-babel-exp-non-block-elements): There is now another element
+       on the call line info list.
+
+       * ob-lob.el (org-babel-lob-get-info): Return the name (if any) at
+       the end of the info list.
+       (org-babel-lob-execute): Pass the name through to execution.
+
+       * ob-core.el (org-babel-execute-src-block): Ensure that the
+       location is set before anything else is done.
+
+       * ob-ref.el (org-babel-ref-parse): Evaluate Emacs Lisp values in
+       header arguments at the location of the original code block.
+
+       * ob-gnuplot.el (org-babel-expand-body:gnuplot): Use new header
+       arguments.
+
+       * ob-core.el (org-babel-common-header-args-w-values): Mention new
+       header arguments.
+       (org-babel-expand-body:generic): Use new header arguments.
+       (org-babel-read-result): More robust matching of examplized
+       ranges.
+       (org-babel-result-end): More robust matching of examplized ranges.
+
+       * ob-gnuplot.el (org-babel-expand-body:gnuplot): Gnuplot, close
+       output terminal when opened.
+       (org-babel-gnuplot-prefix): Customization variable prefix gnuplot
+       code blocks.
+       (org-babel-expand-body:gnuplot): Customization variable prefix
+       gnuplot code blocks.
+
+       * ob-core.el (org-babel-params-from-properties): Now returns a
+       list of alists and does *not* call `org-babel-merge-params'.
+       (org-babel-parse-src-block-match):
+       (org-babel-parse-inline-src-block-match):
+       * ob-exp.el (org-babel-exp-src-block):
+       (org-babel-exp-non-block-elements):
+       * ob-lob.el (org-babel-lob-execute): Handle new list of lists
+       output of `org-babel-params-from-properties'.
+
+       * ob-gnuplot.el (org-babel-header-args:gnuplot): Term is a gnuplot
+       header argument.
+
+       * ob-tangle.el (org-babel-tangle): Fixed bug in tangle-file.
+       Collect tangle modes, and only apply them to the file after all
+       tangling has completed, including the post-tangle-hook.
+
+       * ob-core.el (org-babel-read): Do not read #-prefix header-arg
+       value as emacs lisp.
+
+       * ob-core.el (org-babel-current-src-block-location):
+       (org-babel-execute-src-block):
+       * ob-exp.el (org-babel-exp-results):
+       * ob-lob.el (org-babel-lob-execute): Rename
+       `org-babel-current-exec-src-block-head' to
+       `org-babel-current-src-block-location'.
+
+       * ob-core.el (org-babel-common-header-args-w-values): Adding the
+       new :tangle-mode header argument.
+       (org-babel-read): Read values starting with a "#" character as
+       emacs lisp.
+
+       * ob-tangle.el (org-babel-tangle): Use the new :tangle-mode header
+       argument.
+
+       * org-pcomplete.el (pcomplete/org-mode/block-option/src): Use the
+       new :tangle-mode header argument.
+
+       * ob-exp.el (org-babel-exp-results): Save the code block location
+       into `org-babel-current-exec-src-block-head' during export.
+
+       * ob-comint.el (org-babel-comint-with-output): More robust edebug
+       spec.
+
+       * ob-lob.el (org-babel-lob-execute): Set the
+       `org-babel-current-exec-src-block-head' variable when executing
+       inline or lob style code.
+
+       * ob-core.el (org-babel-execute-src-block): The
+       `org-babel-current-exec-src-block-head' variable should point to
+       the outermost code block.
+
+       * org.el (org-some): An org-mode version of the cl some function.
+
+       * ob-fortran.el (org-babel-fortran-var-to-fortran): More careful
+       check if values are matrices.
+
+       * org.el (org-every): An Org-mode version of the cl every
+       function.
+
+       * ob-tangle.el (org-babel-tangle-jump-to-org): Use
+       `org-src-switch-to-buffer' to jump from src to org.  Use the
+       existing `org-edit-src' functionality to jump back to the correct
+       point in the code block in the original Org-mode buffer.
+
+       * ob-gnuplot.el (org-babel-gnuplot-quote-tsv-field): Only wrap
+       gnuplot data values in " when necessary.  Replace missing values
+       with blank space in gnuplot.
+       (org-babel-expand-body:gnuplot):
+       (org-babel-gnuplot-quote-timestamp-field): Fix indentation.
+       (org-babel-header-args:gnuplot): Declare the.
+       (org-babel-expand-body:gnuplot): Params is an alist not a plist.
+       (org-babel-header-args:gnuplot): Declare gnuplot-specific header
+       argument.
+       (*org-babel-gnuplot-missing*): Dynamic variable used to hold the
+       value of the missing header argument.
+       (org-babel-gnuplot-process-vars): Wrap in local binding for
+       missing value.
+       (org-babel-gnuplot-quote-tsv-field): Replace missing value with
+       the missing header argument value when present.
+
+       * ob-org.el (org-babel-expand-body:org): Allow insertion of
+       non-strings into Org code blocks.
+       (org-babel-inline-result-wrap): New option controlling the
+       wrapping of inline results.
+       (org-babel-examplize-region): Use the new defcustom.
+
+       * ox-beamer.el (org-beamer--format-frame): If contents is nil,
+       then replace it with an empty string.
+
+       * ob-core.el (org-babel-read): More restrictive elisp eval of
+       header arguments.
+
+       * ob-lob.el (org-babel-lob-execute): Include default elisp header
+       args in call lines.
+
+       * ob-core.el (org-babel-result-cond): Don't over-evaluate
+       result-params in macro.
+
+       * ob-ruby.el (org-babel-execute:ruby): Use `org-babel-result-cond'
+       in Ruby code blocks.
+       (org-babel-ruby-evaluate): Delay table processing.
+
+       * ob-js.el (org-babel-execute:js): Use `org-babel-result-cond' in
+       JavaScript code blocks.
+
+       * ob-scheme.el (org-babel-execute:scheme): Use
+       `org-babel-result-cond' in scheme code blocks.
+
+       * ob-ocaml.el (org-babel-execute:ocaml): Use
+       `org-babel-result-cond' in OCaml code blocks.
+
+       * ob-haskell.el (org-babel-execute:haskell): Use
+       `org-babel-result-cond' in Haskell code blocks.
+
+       * ob-core.el (org-babel-result-cond): The "raw", "org" and
+       "drawer" :results header argument values preclude table processing
+       unless the "table" argument is given as well.
+       (org-babel-execute-src-block): Make sure we process file results
+       before they are passed to the post-processing code block, and not
+       afterwards.  Tangles these two header arguments in the code, but
+       makes for more intuitive behavior and enables important use cases.
+       (org-babel-read): Read code block values with earmuffs as Emacs
+       Lisp.
+       (org-babel-common-header-args-w-values): Add :post to the list of
+       header arguments.
+       (org-babel-execute-src-block): Post process results when the :post
+       header argument has been supplied.
+
+       * ob-R.el (org-babel-R-initiate-session): Remove unnecessary
+       save-excursion nested inside a save-window-excursion.
+
+       * ob-core.el (org-babel-src-name-w-name-regexp): Update the regexp
+       used to match code block names.
+       (org-babel-get-src-block-info): Remove the code used to parse this
+       alternate variable specification syntax.
+       (org-babel-insert-result): Cycle tables for :results org and
+       :results wrap.
+
+       * ob-python.el (org-babel-python-initiate-session-by-key): Fixed a
+       bug pointed out by Gary Oberbrunner.
+       (org-babel-python-initiate-session-by-key): Add "-i" to the python
+       command on windows sessions.  Actually setting new session names.
+       Pass Python buffer names to the new `run-python' command.
+       (org-babel-python-with-earmufs): Add earmufs to a buffer name.
+       (org-babel-python-without-earmufs): Remove earmufs from a buffer name.
+       (org-babel-python-initiate-session-by-key): Set the buffer name in
+       a way which is understandable by the new python.el
+       (org-babel-python-buffers): Change the default python buffer name.
+
+       * ob-core.el (org-babel-number-p): Don't interpret single "-" as a
+       number.
+
+       * ob-perl.el (org-babel-perl--var-to-perl): Print Perl variables
+       with a format string.
+
+       * ob-core.el (org-babel-where-is-src-block-result): Allow comments
+       between code blocks and un-named results.
+
+       * ob-sqlite.el (org-babel-sqlite-table-or-scalar): Don't read
+       sqlite output as lisp.
+
+       * ob-core.el (org-babel-check-confirm-evaluate): Refactoring.
+       (org-babel-confirm-evaluate): Fix whitespaces.
+       (org-babel-execute-src-block): A cond makes it more clear that we
+       definitely do not execute without user confirmation.
+       (org-babel-call-process-region-original): Fixed line over 80 chars
+       long.
+
+       * ob-tangle.el (org-babel-tangle-collect-blocks): Update comment
+       to reflect changed variable name.
+
+       * ob-core.el (org-babel-expand-src-block): Return value of
+       expanded code block on non-interactive calls.
+
+       * ob-perl.el (org-babel-perl-var-wrap): Customizable wrapper for
+       variables in perl code.
+       (org-babel-perl-var-to-perl): Use said wrapper.
+
+       * ob-sql.el (org-babel-execute:sql): Use the org-babel-eval
+       command instead of shell-command.
+
+       * ob-ocaml.el (org-babel-prep-session:ocaml): Check that
+       `tuareg-run-caml' is defined before use.
+       (tuareg-run-ocaml): Declare for compiler.
+
+       * ob-core.el (org-babel-result-regexp): Simplify regexp given new
+       time hash layout.
+       (org-babel-current-result-hash): New match string.
+       (org-babel-hide-hash): New match string.
+       (org-babel-where-is-src-block-result): New match string, and
+       insert hashes in the new format.
+
+       * ob-core.el (org-ts-regexp): Declare.
+       (org-babel-result-regexp): Now matching time stamp as well.
+       (org-babel-hash-show-time): New variable controlling the display
+       of time stamps.
+       (org-babel-current-result-hash):
+       (org-babel-hide-all-hashes):
+       (org-babel-where-is-src-block-result): Use hash time stamps.
+
+       * ob-core.el: New file.
+
+       * org-macs.el: `org-load-noerror-mustsuffix' requires an autoload.
+
+2013-11-12  Feng Shu  <tumashu@gmail.com>
+
+       * ox-odt.el (org-odt--translate-latex-fragments):
+       * ox-html.el (org-html-latex-environment)
+       (org-html-latex-fragment): Fix imagemagick support.
+
+       * org.el (org-create-formula-image-with-imagemagick): Generate
+       correct size formula image.
+       (org-format-latex-header): Change pagestyle command position.
+
+       * ox-latex.el (org-latex--caption/label-string): Allow to build a
+       caption string from `:caption' attribute of #+ATTR_LATEX.
+
+       * ox.el (org-export-dictionary): Add Simplified Chinese
+       translations for `org-export-dictionary'.
+
+2013-11-12  Florian Beck  <fb@miszellen.de>  (tiny change)
+
+       * org.el (org-activate-bracket-links): Remove escapes from the
+       help string.
+
+2013-11-12  Francesco Pizzolante  <xxx@public.gmane.org>  (tiny change)
+
+       * ox-html.el (org-html-headline): Normalize the construction of
+       outline-container DIVs by always using the inner headline ID.
+
+       * org.el (org-agenda-prepare-buffers): Protect with
+       `org-unmodified'.
+
+2013-11-12  Gregor Kappler  <gregor@alcedo.(none)>  (tiny change)
+
+       * ox.el (org-export-as): Make sure org-export-babel-evaluate is
+       not nil before calling `org-export-execute-babel-code'.
+
+2013-11-12  Grégoire Jadi  <gregoire.jadi@gmail.com>
+
+       * org.el (org-reftex-citation): Fix contrib package name in the
+       docstring.
+       (org-preview-latex-fragment, org-display-inline-images): Detect
+       whether a graphic display is available before inlining images to
+       prevent an error.
+       (org-startup-with-latex-preview): New option.
+       (org-startup-options): New startup keywords for the new option.
+       (org-mode): Turn on/off LaTeX preview depending on the new option.
+       (org-reverse-string): Add `org-reverse-string' to reverse a
+       string.
+
+       * org-id.el (org-id-new, org-id-decode): Replace
+       `org-id-reverse-string' by `org-reverse-string'.
+
+       * ob-core.el (org-babel-trim): Replace `org-babel-reverse-string'
+       by `org-reverse-string' and declare it.
+
+2013-11-12  Gustav Wikström  <gustav.erik@gmail.com>  (tiny change)
+
+       * org-agenda.el (org-agenda-filter-by-category): Display all
+       filtered out categories.
+
+2013-11-12  Ilya Zonov  <izonov@gmail.com>  (tiny change)
+
+       * org-mode (org-mouse-context-menu): Add a correct newtext
+       parameter for "All Set" and "All Clear" menu items.
+
+2013-11-12  Ingo Lohmar  <i.lohmar@gmail.com>  (tiny change)
+
+       * org.el (org-insert-todo-heading-respect-content): Pass correct
+       prefix arg to always insert heading.
+
+       * org-agenda.el
+       (org-agenda-propertize-selected-todo-keywords): New function to
+       highlight the current agenda todo keywords depending on
+       `org-todo-keyword-faces'.
+       (org-todo-list): Use the new function.
+
+2013-11-12  Ippei FURUHASHI  <top.tuna+orgmode@gmail.com>
+
+       * org-table.el (org-calc-current-TBLFM): New function to
+       re-calculate the table by applying the #+TBLFM in the line where
+       the point is.  Ensure to remove the currently inserted TBLFM line,
+       when calling `org-table-recalculate' returns an error and the
+       processing stops.
+
+       * org.el (org-ctrl-c-ctrl-c): Call `org-calc-current-TBLFM' when
+       point is in the #+TBLFM line.
+
+       * org-table.el (org-TBLFM-begin): New function.
+       (org-TBLFM-begin-regexp): New variable.
+
+       * org.el (org-at-TBLFM-p): New function.
+       (org-TBLFM-regexp): New defconst.
+
+2013-11-12  Ivan Vilata i Balaguer  <ivan@selidor.net>  (tiny change)
+
+       * org-clock.el (org-clock-get-table-data): Pass tstart and tend
+       time strings through `org-matcher-time' to allow relative times
+       besides absolute ones, convert result to encoded time.
+
+2013-11-12  Jambunathan K  <kjambunathan@gmail.com>
+
+       * ox-html.el (org-html-code, org-html-verbatim): Transcode value.
+       (org-html--tags, org-html-format-headline)
+       (org-html--format-toc-headline, org-html-checkbox)
+       (org-html-table-cell, org-html-timestamp)
+       (org-html-verse-block, org-html-special-string-regexps): Replace
+       named HTML entities with their numeric counterparts.  This keeps
+       Freemind backend happy.
+
+       * org-odt.el (org-export-odt-schema-dir): Modify to accommodate
+       change in rnc file names.
+
+       * org-lparse.el (org-lparse-and-open)
+       (org-lparse-do-convert): Open exported files with system-specific
+       application.
+
+       * org-odt.el: Don't meddle with `org-file-apps'.
+
+2013-11-12  Jarmo Hurri  <jarmo.hurri@syk.fi>
+
+       * org-table.el (org-define-lookup-function): New macro.  Call it
+       to generate new lookup functions `org-lookup-first',
+       `org-lookup-last' and `org-lookup-all'.
+
+       * org-gnus.el (org-gnus-no-server): New option to start Gnus using
+       `gnus-no-server'.
+       (org-gnus-no-new-news): Use the new option.
+
+2013-11-12  Jonas Hoersch  <coroa@online.de>  (tiny change)
+
+       * org.el (org-cycle-hide-inline-tasks): Re-hide inline tasks when
+       switching to 'children visibility state.
+
+       * org-inlinetask.el (org-inlinetask-toggle-visibility): Don't use
+       `org-show-entry' as it cannot unfold an inlinetask properly.
+
+2013-11-12  Jonathan Leech-Pepin  <jonathan.leechpepin@gmail.com>
+
+       * ox-texinfo.el: New file.
+
+2013-11-12  Joost Diepenmaat  <joost@zeekat.nl>  (tiny change)
+
+       * org.el (org-indent-region): BEGIN_SRC and END_SRC lines should
+       not be considered part of the source block for the purposes of
+       indentation.
+
+2013-11-12  Justus Piater  <justus-dev@piater.name>
+
+       * org-agenda.el
+       (org-agenda-skip-deadline-prewarning-if-scheduled): Add an option
+       to skip the deadline prewarning if the scheduled date is in the
+       future.
+
+2013-11-12  Kodi Arfer  <git@arfer.net>  (tiny change)
+
+       * ox-html.el (org-html-toc): Use <nav> instead of <div> for the
+       root element when appropriate.
+       (org-html-paragraph): Wrap "Figure %d:" in <span
+       class="figure-number">.
+       (org-html-list-of-tables, org-html-table): Wrap "Table %d:" in
+       <span class="table-number">.
+       (org-html-list-of-listings): Wrap "Listing %d:" in
+       <span class="listing-number">.
+       (org-html-table): For HTML5, omit :html-table-attributes but not
+       :id or :attr_html.
+       (org-html--build-meta-info): Insert no timestamp when
+       :time-stamp-file is nil.
+
+2013-11-12  Lawrence Mitchell  <wence@gmx.li>
+
+       * ox-html.el (org-html-close-tag): Add space before attr.
+
+       * ox.el (org-export-resolve-fuzzy-link): Look for fuzzy link in a
+       cache before trying to resolve it in the parse tree.
+
+2013-11-12  Le Wang  <le.wang@agworld.com.au>
+
+       * org-src.el (org-edit-src-code): Use marker with insertion type t
+       to track end and remove hack requiring delete from beg to (1-
+       end).
+
+2013-11-12  Max Mikhanosha  <max@openchat.com>
+
+       * org-habit.el (org-habit-get-faces): Add show done days green
+       option.
+
+       * org-agenda.el (org-agenda-format-item): Ensure effort is "" when
+       unset
+
+2013-11-12  Michael Brand  <michael.ch.brand@gmail.com>
+
+       * org-table.el (org-table-eval-formula): Align the arrow pointing
+       to the error in a Calc formula to the other fomula debugger logs.
+
+       * org.el (org-link-escape-chars-browser): Add char double quote.
+       (org-open-at-point): Use the constant
+       `org-link-escape-chars-browser'.
+
+       * org-table.el (org-table-get-remote-range): Extend regexp to
+       match "#+NAME: table" additionally to "#+TBLNAME: table".
+
+       * org-table.el (org-table-eval-formula): Use `keep-empty' in more
+       places.  Keep empty fields during preprocessing.
+       (org-table-make-reference): Use nan (not a number) for empty
+       fields in Calc formulas.  A range with only empty fields should
+       not always return 0 but also empty string, consistent with field
+       reference of an empty field.  Use future design for nan but
+       replicate current behavior.
+       (org-table-number-regexp): Extend 0x hex to fixed-point number,
+       add <radix>#<number>, add Calc infinite numbers uinf, -inf and
+       inf.
+
+2013-11-12  Muchenxuan Tong  <demon386@gmail.com>  (tiny change)
+
+       * org-mobile.el (org-mobile-push): Add `save-restriction'.
+
+2013-11-12  Nicolas Goaziou  <n.goaziou@gmail.com>
+
+       * ox-latex.el (org-latex-compile): Remove all numbered temporary
+       files after compiling.
+
+       * org-element.el (org-element-headline-interpreter): Take into
+       consideration `org-odd-levels-only' when building a headline.
+
+       * ox-org.el (org-org-headline): Correctly set transcoded headline
+       level during subtree export.
+
+       * ox-html.el (org-html--format-toc-headline): TOC entries are
+       closer to regular headline formatting.
+
+       * org-element.el (org-element-context): Fix error when parsing
+       affiliated keywords, e.g. "caption".
+
+       * org.el (org-do-emphasis-faces): Look for verbatim status at
+       correct location.
+       (org-open-at-point): Check if link is non-nil before matching it.
+       (org-export-insert-default-template): Make sure strings are
+       properly quoted when inserting a template.  Specifically, default
+       value for drawers should be d:(not "LOGBOOK"), not d:(not
+       LOGBOOK).
+       (org-insert-heading): Do not error out when inserting is to be
+       done at one of the buffer's boundaries.
+
+       * ox-latex.el (org-latex-listings-options): Use correct number of
+       backslash characters in the example.
+
+       * org-element.el (org-element-latex-or-entity-successor)
+       (org-element-latex-fragment-parser): Use `org-latex-regexps'
+       instead of `org-format-latex-options'.
+
+       * ox-ascii.el:
+       * ox-beamer.el:
+       * ox-html.el:
+       * ox-icalendar.el:
+       * ox-md.el: Remove comments at the beginning of the file since
+       the library is documented in Org manual.
+
+       * org-element.el (org-element--list-struct): Use
+       `org-match-string-no-properties'.  Fix block parsing in lists.
+
+       * ox-publish.el (org-publish-all): Fix compilation problem.
+
+       * org-element.el (org-element-timestamp-interpreter): Correctly
+       interpret timestamps with delays.
+       (org-element-timestamp-parser)
+       (org-element-timestamp-interpreter): Parse warning delays.
+
+       * ox-beamer.el (org-beamer--format-section): Fix regression which
+       prevents frames from being propely exported.
+
+       * ox.el (org-export-with-backend): Ensure function will use
+       provided back-end.
+
+       * org-list.el (org-list-allow-alphabetical): Remove reference to
+       unused VALUE.
+
+       * ox-beamer.el (org-beamer--format-section): Protect fragile
+       commands in sections.
+
+       * org.el (org-ctrl-c-ctrl-c): When using C-c C-c at an item with
+       point on a link, make sure checkbox, if any, is toggled.
+
+       * ox-beamer.el (org-beamer--format-block): Return an error message
+       when using a special environment as a block type.  Also check for
+       incomplete environment definitions.
+
+       * org-element.el (org-element-at-point): If point is at the end of
+       the buffer, and that buffer ends with a list, and there's no final
+       newline, return last element in last item instead of plain list.
+       Fix infloop when called on a blank line at the end of the buffer
+       after a headline.
+
+       * org.el (org-forward-paragraph, org-backward-paragraph): New
+       functions.
+
+       * org.el (org-meta-return): Allow M-RET to insert items within
+       drawers.  Rewrite function.
+
+       * org-element.el (org-element-footnote-definition-parser): Fix
+       value for :contents-begin when first line of footnote definition
+       is empty besides the label.
+       (org-element-at-point): Return correct element when point is on a
+       blank line just below a headline.
+       (org-element-paragraph-parser): Use
+       `org-match-string-no-properties'.  Small fixes to paragraph
+       parsing.
+
+       * org.el (org-adaptive-fill-function): Do not handle
+       `adaptive-fill-regexp' in comments as the behaviour is not
+       satisfying.
+
+       * org-list.el (org-list-struct-apply-struct): Do not move item's
+       contents within a child above when repairing indentation.
+
+       * ox-html.el (org-html--build-meta-info): Fix output of meta tags
+       when properties are present.
+
+       * ox.el (org-export-collect-headlines): Do not build TOC for
+       headlines below H value.
+
+       * org-element.el (org-element-context): Modify misleading
+       comment.
+       (org-element-text-markup-successor)
+       (org-element-latex-or-entity-successor)
+       (org-element-export-snippet-successor)
+       (org-element-footnote-reference-successor)
+       (org-element-inline-babel-call-successor)
+       (org-element-inline-src-block-successor)
+       (org-element-line-break-successor, org-element-link-successor)
+       (org-element-plain-link-successor, org-element-macro-successor)
+       (org-element-radio-target-successor)
+       (org-element-statistics-cookie-successor)
+       (org-element-sub/superscript-successor)
+       (org-element-table-cell-successor, org-element-target-successor)
+       (org-element-timestamp-successor): Remove LIMIT argument.
+       (org-element--parse-objects, org-element--get-next-object-candidates):
+       Apply signature change to successors.
+       (org-element-context): Narrow buffer around object containers so
+       parsing of objects when using this function is done under the same
+       restrictions as in buffer parsing.
+
+       * ox.el (org-export-table-cell-alignment): Ensure required
+       variables are available.  Use correct :test.
+       (org-export-table-cell-width): Modify key (now an element) and
+       value structure (now a vector) of cache so it can use `eq' as
+       test. Elements are circular lists so `equal' cannot apply on them.
+
+       * ox-publish.el (project-plist): Remove variable.
+
+       * ox.el (org-export-to-buffer, org-export-to-file): Fix
+       docstrings.
+
+       * ox-org.el (org-export-as-org): Add missing BODY-ONLY argument,
+       which is always nil in this back-end.
+
+       * org.el (org-adaptive-fill-function): Look for a fill prefix at
+       the beginning of the paragraph and subsquently on its second line
+       instead of the current line.
+
+       * ob-core.el (org-babel-get-src-block-info): Look for indentation
+       value at the correct location.
+
+       * ox.el (org-export-data-with-backend): Set temporary back-end as
+       the new back-end in local communication channel.
+       (org-export-filter-apply-functions): Handle corner case where
+       back-end is nil.  Only provide back-end name (a symbol) as second
+       argument of filters, not the full back-end (a vector).
+
+       * ox-publish.el (org-publish-find-title): Fix title when no
+       #+TITLE property is provided.
+
+       * ox.el (org-export-store-default-title): Remove-function.
+       (org-export--default-title): Remove variable.
+       (org-export-options-alist): Do not use a default value.
+       (org-export--get-buffer-attributes): Store a default title.
+       (org-export-as): Apply function removal.
+       (org-export--get-global-options): Do not set a property with an
+       explicitly nil value.
+
+       * ox-publish.el (org-publish-sitemap-sort-files)
+       (org-publish-sitemap-sort-folders)
+       (org-publish-sitemap-ignore-case, org-publish-sitemap-requested)
+       (org-publish-sitemap-date-format)
+       (org-publish-sitemap-file-entry-format): Set prefix to
+       "org-publish-sitemap" instead of "org-sitemap".
+       (org-publish-compare-directory-files)
+       (org-publish-get-base-files-1, org-publish-projects)
+       (org-publish-format-file-entry): Use new prefix.
+
+       * org-clock.el (org-clock-total-time-cell-format)
+       (org-clock-file-time-cell-format): Use correct type.
+
+       * ob-haskell.el:
+       * ox-ascii.el (org-ascii-export-as-ascii)
+       (org-ascii-export-to-ascii):
+       * ox-beamer.el (org-beamer-export-as-latex)
+       (org-beamer-export-to-latex, org-beamer-export-to-pdf):
+       * ox-html.el (org-html-export-as-html, org-html-export-to-html):
+       * ox-icalendar.el (org-icalendar-export-to-ics):
+       * ox-latex.el (org-latex-export-as-latex)
+       (org-latex-export-to-pdf):
+       * ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
+       * ox-md.el (org-md-export-as-markdown, org-md-export-to-markdown):
+       * ox-odt.el (org-odt-export-to-odt):
+       * ox-org.el (org-org-export-as-org, org-org-export-to-org):
+       * ox-publish.el (org-publish-org-to):
+       * ox-texinfo.el (org-texinfo-export-to-texinfo)
+       (org-texinfo-export-to-info):
+       * ox.el (org-export-to-buffer): Add two arguments: one to trigger
+       asynchronous export and the other to do extra processing from
+       within the buffer.
+       (org-export-to-file): Add two arguments: one to trigger
+       asynchronous export and the other to do extra processing on the
+       output file.
+       (org-export-async-start): Small clean up.
+
+       * ox.el (org-export-as): Use new back-end structure.
+       (org-export-current-backend): New variable.
+       (org-export-as): Use new variable.
+
+       * ox-ascii.el (org-ascii-table): Remove spurious new line between
+       a table and the caption below.
+
+       * ox.el (org-export-to-file): Preserve coding system when writing
+       output.
+       (org-export-stack-mode-map): Fix compilation error with Emacs <
+       24.
+       (org-export--dispatch-action): Maintain compatibility with Emacs
+       23.
+
+       * org.el (org-adaptive-fill-function, org-fill-paragraph): Add
+       support for `adaptive-fill-regexp' in paragraphs and comments.
+       (org-indent-line): Fix indentation after a list.
+
+       * ox.el (org-export--get-inbuffer-options): Multiple options can
+       now be set through the same buffer keyword.
+
+       * org-element.el (org-element-plain-list-parser): Fix infloop when
+       parsing a list at the end of buffer, if buffer doesn't end at a
+       line beginning.
+       (org-element-link-parser): Do not url-decode parsed links.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option): Remove
+       spurious white spaces, excepted for source blocks' opening string.
+       Small refactoring.
+       (pcomplete/org-mode/file-option): Remove spurious colons from
+       block boundaries.
+
+       * ox-publish.el (org-publish-find-date): Also return date for
+       directories.
+       (org-publish-get-base-files-1): Fix :recursive parameter ignoring
+       extension restriction.
+
+       * ox-beamer.el: Remove strange indentation in default header.
+       (org-beamer-template): Fix missing newlines in header.
+
+       * ox-latex.el (org-latex-template): Fix missing newlines in
+       header.
+
+       * ox.el (org-export-insert-default-template): Fix
+       "wrong-type-argument" error in template insertion.
+
+       * org.el (org-fill-paragraph): Use empty commented lines as
+       separators when filling comments.  This mimics default behaviour
+       from "newcomment.el", which is not used in Org.
+
+       * ox-html.el (org-html-link): Add image attributes to "img" tag,
+       not to the "a" container.  Also fix spacing for attributes.
+
+       * org.el (org-fill-paragraph): Do not mix consecutive comments
+       when filling any of them.
+
+       * ox-html.el (org-html-format-headline--wrap): Fix number of
+       arguments when setting `org-html-format-headline-function'.
+
+       * org-element.el (org-element-item-interpreter): This patch fixes
+       "(wrong-type-argument arrayp nil)" error when trying to interpret
+       empty items.  Correctly interpret back plain lists with "*" items.
+       This fixes "This is not a list" error returned in this case.
+
+       * ox-latex.el (org-latex-listings): Update docstring.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option/options): Apply
+       changes to export back-end definiton.
+
+       * org.el (org-get-export-keywords): Apply changes to export
+       back-end definiton.
+
+       * ox-html.el (org-html--format-toc-headline): Make use of
+       anonymous back-ends.
+
+       * ox-odt.el (org-odt-footnote-reference): Make use of anonymous
+       back-ends.
+       (org-odt-format-label, org-odt-toc)
+       (org-odt-format-headline--wrap): Use `org-export-with-backend'
+       instead of `org-export-with-translations'.
+
+       * ox.el (org-export--registered-backends): Renamed from
+       `org-export-registered-backends'.
+       (org-export-invisible-backends): Removed variable.
+       (org-export-get-backend, org-export-get-all-transcoders
+       org-export-get-all-options, org-export-get-all-filters): New
+       functions.  It replaces `org-export-backend-translate-table'.
+       (org-export-barf-if-invalid-backend, org-export-derived-backend-p,
+       org-export-define-backend, org-export-define-derived-backend):
+       Rewrite functions using new representation.
+       (org-export-backend-translate-table): Remove function.
+       (org-export-get-environment): Use new function.
+       (org-export--get-subtree-options, org-export--parse-option-keyword,
+       org-export--get-inbuffer-options, org-export--get-global-options,
+       org-export-to-buffer org-export-to-file, org-export-string-as
+       org-export-replace-region-by): Update docstring.
+       (org-export-data-with-translations): Remove function.  Use
+       `org-export-data-with-backend' with a temporary back-end instead.
+       (org-export-data-with-backend, org-export-as): Reflect new definition
+       for back-ends.
+       (org-export--dispatch-action, org-export--dispatch-ui): Reflect new
+       definition for back-ends and variable removal.  Refactoring.
+       (org-export-filter-apply-functions): Call functions with
+       current back-end's name, not full back-end.
+
+       * org.el (org-export-backends, org-create-formula--latex-header):
+       Use new structure and variables.
+
+       * ox-html.el (org-html-inline-images): Change default value and
+       remove `maybe'.
+       (org-html-format-inline-image): Remove functions.
+       (org-html--wrap-image, org-html--format-image)
+       (org-html-inline-image-p): New functions.
+       (org-html-latex-environment, org-html-latex-fragment): Use new
+       functions.
+       (org-html-standalone-image-p): Use new functions.  Also remove an
+       unused optional argument.
+       (org-html-link, org-html-paragraph): Correctly export hyperlinked
+       images.
+
+       * ox.el (org-export-dictionary): Update some translations.
+
+       * ox-odt.el (org-odt-label-styles, org-odt-category-map-alist):
+       Fix docstring.
+       (org-odt-format-label): Add docstring.  Internationalize prefix.
+
+       * ox.el (org-export-dictionary): Add entry for colons.
+
+       * ox-odt.el (org-odt--suppress-some-translators): Remove function.
+
+       * ox-html.el (org-html-link): Remove left-over binding.
+
+       * ox-beamer.el (org-beamer-environments-extra): Allow to add raw
+       title in environment definition.
+       (org-beamer--format-block): Handle new placeholders.
+
+       * ox-html.el (org-html-link): Small refactoring.
+
+       * org-element.el (org-element--current-element): Fix
+       org-meta-return error at the end of buffer.
+
+       * ox-odt.el (org-odt-category-map-alist): Fix internationalization
+       of "Table" and "Listing".
+
+       * ox.el (org-export-dictionary): Remove useless dictionary
+       entries.
+
+       * ox-ascii.el (org-ascii--build-caption): Apply removal.
+
+       * ox.el (org-export-dictionary): Add spanish and german
+       translations.
+
+       * ox-odt.el (org-odt-link): Fuzzy links to an headline with a
+       description always use that description, even if the description
+       is the same as the headline title.
+       (org-odt-plain-text): Allow to turn smart quotes off.
+
+       * ox-latex.el (org-latex--get-footnote-counter): Remove function.
+
+       * org.el (org-setup-filling): Set `paragraph-start' and
+       `paragraph-separate'.
+       (org-fill-paragraph-separate-nobreak-p): Remove function.
+       (org-mode): Do not set `paragraph-start'.
+
+       * ox-html.el (html): Replace "HTML_HTML5_FANCY",
+       "HTML_INCLUDE_STYLE" and "HTML_INCLUDE_SCRIPTS" with,
+       respectively, ":html5-fancy", "html-style" and "html-scripts"
+       options.
+       (org-html-html5-fancy): Reformat docstring.
+       (org-html-template): Fix typo preventing insertion of link up/link
+       home anchors.
+
+       * org.el (org-create-formula--latex-header): Replace AUTO with
+       appropriate language when previewing snippets.
+
+       * ox-latex.el (org-latex-item): Allow hyperref and footnotemark in
+       items description tags.  Also remove a unnecessary hack allowing
+       footnotemark with an optional argument in the tag.
+
+       * ox.el (org-export-resolve-fuzzy-link): Fix link resolution when
+       link lives before the first headline.
+
+       * org-element.el (org-element-special-block-parser): Fix typo in
+       regexp matching block type.  Also quote the type so it can contain
+       special characters.
+
+       * ox-latex.el (org-latex-pdf-process): This argument can cause
+       problem with links with a relative path, since compilation happens
+       in a different directory.
+
+       * org.el (org-latex-default-packages-alist): Load "ulem" package
+       by default.  Use "[normalem]" option to preserve \emph definition.
+
+       * ox-latex.el (org-latex-text-markup-alist): Use "\uline" and
+       "\sout" commands from "ulem" package.
+
+       * org.el (org-latex-default-packages-alist): Document need for
+       "soul" package.
+
+       * ox-latex.el (org-latex-text-markup-alist): Use \ul (from "soul"
+       package) instead of \underline for underline text.
+
+       * ox.el (org-export-read-attribute): Fix "Wrong argument type"
+       error when attributes start with :key "".
+
+       * org.el (org-fill-paragraph-separate-nobreak-p)
+       (org-fill-line-break-nobreak-p)
+       (org-fill-paragraph-with-timestamp-nobreak-p): Fix docstrings.
+
+       * org-element.el (org-element--list-struct): Fix failing
+       "plain-list-parser" test.
+
+       * ox-latex.el (org-latex-src-block): Handle :float attribute. Its
+       value can be set to "t", "multicolumn" or "nil".  Also remove
+       :long-listing attribute, which is now replaced with :float nil.
+       (org-latex--org-table): Replace :float table with :float t.
+       (org-latex--inline-image): Replace :float figure with :float t.
+       (org-latex-long-listings): Remove variable.
+
+       * org-element.el (org-element--list-struct): New function.
+       (org-element-plain-list-parser, org-element--current-element): Use
+       new function.
+
+       * ox-man.el (org-man-compile):
+       * ox-texinfo.el (org-texinfo-compile): Use appropriate argument.
+
+       * ox-latex.el (org-latex-compile):
+       * ox-man.el (org-man-compile):
+       * ox-texinfo.el (org-texinfo-compile): Properly set working
+       directory.
+
+       * ox-latex.el (org-latex-compile):
+       * ox-texinfo.el (org-texinfo-compile): Make sure generated file
+       can be found by `file-exists-p'.
+
+       * ox-md.el (md): Delegate underscore transcoding to HTML back-end.
+
+       * org-element.el (org-element--remove-indentation): Small
+       optimization.
+       (org-element--remove-indentation): New function.
+       (org-element-example-block-parser, org-element-src-block-parser):
+       Use new function.
+       (org-element-src-block-interpreter): Update function according to
+       change.
+
+       * ox.el (org-export-unravel-code): Do not remove any indentation
+       since it now happens at the parser level.
+       (org-export-table-cell-width): Be sure to use cache even when
+       stored value is nil.
+       (org-export--default-title): Fix "Symbol's value as variable is
+       void: org-export--default-title".
+
+       * ox-ascii.el (org-ascii--table-cell-width): Cache results of this
+       internal function since it is called at each cell, though its
+       value only change column wise.
+
+       * ox.el (org-export-resolve-fuzzy-link): Change property name
+       holding cache.
+       (org-export-table-has-header-p, org-export-table-row-group)
+       (org-export-table-cell-width, org-export-table-cell-alignment):
+       Cache results.
+       (org-export-table-cell-address): Refactor.
+       (org-export-get-parent): Inline function.
+       (org-export-options-alist): Change default value for :title
+       property.
+       (org-export--default-title): New dynamically scoped variable.
+       (org-export-store-default-title): New function.
+       (org-export--get-buffer-attributes): Remove title handling.
+       (org-export--get-global-options): Revert "ox: Fix default title".
+       Refactor code.
+
+       * ox-html.el (org-html-format-latex): Provide a prefix for
+       temporary file when using dvipng, even if the current buffer isn't
+       associated to a file.
+
+       * ox.el (org-export-resolve-radio-link): Ignore whitespace
+       differences when resolving a radio link.
+       (org-export-resolve-radio-link): Fix radio target resolution.
+
+       * org-element.el (org-element--current-element): Be stricter when
+       matching arguments in LaTeX environments.  In particular, do not
+       allow anything else than options and arguments in the opening
+       line.
+
+       * ox-html.el (org-html-inner-template): Remove code relative to
+       bibliography.
+       (org-html-bibliography): Remove function.
+
+       * ox-latex.el (org-latex-plain-text): Protect ^ char with \^{},
+       not only \^, so it doesn't become a diacritic.
+
+       * ox-html.el (org-html--build-meta-info): Fix code typo.
+
+       * ox.el (org-export-expand-include-keyword): Avoid using `read' to
+       determine file name.
+       (org-export--get-global-options): Properly set default title,
+       i.e. when to TITLE keyword is provided.
+
+       * org-element.el (org-element--parse-elements): Also parse visible
+       headlines within an otherwise compacted headline.
+
+       * ox.el (org-export-expand-include-keyword): Tolerate included
+       file names without double quotes.
+       (org-export-resolve-fuzzy-link): Fix caching process.
+
+       * ox-publish.el (org-publish-find-date): Fix "Invalid time
+       specification" error with timestamps in DATE.
+
+       * org-element.el (org-element--current-element): Allow the opening
+       string of a LaTeX environment to contain additional arguments.
+
+       * org.el (org-insert-heading): Refactor to use `org-in-item-p'
+       only once.
+
+       * ox.el (org-export-expand): Optionally add affiliated keywords to
+       results.
+
+       * ox-org.el (org-org-identity): Use new argument for
+       `org-export-expand'.
+
+       * org.el (org-fill-paragraph): Move to table beginning before
+       aligning the table when M-q is called from an affiliated keyword.
+
+       * org-list.el (org-list-allow-alphabetical): Properly update
+       `org-list-allow-alphabetical' when changed after org.el has been
+       loaded.
+
+       * org-element.el (org-element-fixed-width-interpreter): Fix
+       interpretation of fixed-width elements with a nil or empty string
+       value.
+
+       * ox-html.el (org-html-link): Don't skip the link description when
+       it matches the name of the headline it targets.
+
+       * ox-html.el (org-html-link): Don't skip the link description when
+       it matches the name of the headline it targets.
+
+       * ox-ascii.el (ascii): Remove inexistant function.
+
+       * ox-icalendar.el (icalendar): Ignore footnotes.
+       (org-icalendar--combine-files): Small refactoring.
+
+       * ox.el (org-export--skip-p, org-export--interpret-p): When
+       `org-export-with-footnotes' is nil, ignore completely footnotes
+       references and definitions instead of exporting them verbatim.
+
+       * ox-beamer.el (org-beamer--frame-level): Small refactoring.
+       (org-beamer--format-block, org-beamer-headline): Do not systematically
+       downcase environment names as some require upper case in their
+       names (e.g. noteNH and CJK).
+
+       * ox.el (org-export-with-timestamps): Only applies to isolated
+       timestamps, i.e. timestamps in a paragraph containing only
+       timestamps and empty strings.
+       (org-export--skip-p): Skip timestamps according to new behaviour.
+
+       * ox-latex.el (org-latex--script-size): Handle consecutive
+       alterning sub and superscript.
+
+       * ox-org.el (org-org-identity): Fix docstring.  Tiny refactoring.
+       (org-org-headline, org-org-keyword): Fix docstring.
+
+       * ox-latex.el (org-latex--script-size): Use \text command for
+       subscript and superscript.  This is far superior to \mathrm, but
+       it requires "amstext" package.  In particular, accented characters
+       are now allowed within sub/superscript.
+
+       * org.el (org-latex-default-packages-alist): Add "amstext"
+       package.
+
+       * ox-latex.el (org-latex--script-size): Fix error when using
+       sub/superscript within sub/superscript.
+
+       * ox-latex.el (org-latex--script-size): New function.
+       (org-latex-subscript, org-latex-superscript): Use new function.
+       Remove instructions since everything is documented in Org manual.
+
+       * ox.el (org-export-with-smart-quotes): Use LATEX instead of LaTeX
+       for keywords, the latter being hard to type, somewhat difficult to
+       read, and overall just pedantic.
+
+       * ox-latex.el (org-latex-classes): Be more explicit about
+       LATEX_HEADER_EXTRA.
+
+       * ox-html.el (org-html--build-meta-info): Fix invalid characters
+       in html attributes.
+
+       * ox.el (org-export-filters-alist): Remove macro filter.
+       (org-export-filter-macro-functions): Remove variable.
+
+       * ox-beamer.el (beamer): Install a default class set-up when
+       loading library.
+
+       * ox-latex.el (org-latex-classes): Update docstring.
+
+       * ox-latex.el (org-latex--inline-image): Remove specific default
+       image width for floats.  If no width nor height is provided, it
+       should default to `org-latex-image-default-width' value.
+
+       * org.el (org-extract-attributes-from-string)
+       (org-attributes-to-string): Remove functions.
+
+       * ox-html.el (html): Rename :html-table-tag property into
+       :org-table-attributes.
+       (org-html-table-default-attributes): New variable.
+       (org-html-table-tag): Removed variable.
+       (org-html--make-attribute-string): New function.
+       (org-html-link--inline-image, org-html-table): Use new function.
+       (org-html-splice-attributes, org-export-splice-style): Remove
+       functions.
+       (org-html-inline-image-rules): Remove out of context part of the
+       docstring.
+
+       * ox.el (org-export-read-attribute): Allow to use empty strings in
+       attributes.
+
+       * ox-html.el (org-html-metadata-timestamp-format): New variable,
+       renamed from `org-html--timestamp-format'.
+       (org-html--build-meta-info, org-html-format-spec,
+       org-html--build-pre/postamble): Use new variable.
+
+       * ox.el (org-export-table-row-number): New function.
+       (org-export-table-cell-address): Use new function.
+
+       * org-element.el (org-element-table-cell-successor): Parse table
+       cells with missing ending space.
+
+       * ox-latex.el (org-latex--math-table): Fix inline-math table
+       environment.
+
+       * ox-html.el (org-html-doctype): Make value fit on a single line
+       so `org-export-insert-default-template' can handle it.
+       (org-html-creator-string): Change default value.
+
+       * ox.el (org-export-creator-string): Change default value.
+
+       * ox-html.el (org-html-postamble-format)
+       (org-html-preamble-format): Allow last modification time of source
+       in template.  Fix docstrings.
+       (org-html-format-spec): Produce last modification time when the source
+       is a file.
+
+       * ox.el (org-export-with-archived-trees, org-export-with-author)
+       (org-export-with-clocks, org-export-with-date)
+       (org-export-creator-string, org-export-with-drawers)
+       (org-export-with-email, org-export-with-emphasize)
+       (org-export-exclude-tags, org-export-with-fixed-width)
+       (org-export-with-footnotes, org-export-with-latex)
+       (org-export-headline-levels, org-export-default-language)
+       (org-export-preserve-breaks, org-export-with-entities)
+       (org-export-with-inlinetasks, org-export-with-planning)
+       (org-export-with-priority, org-export-with-section-numbers)
+       (org-export-select-tags, org-export-with-smart-quotes)
+       (org-export-with-special-strings)
+       (org-export-with-statistics-cookies)
+       (org-export-with-sub-superscripts, org-export-with-toc)
+       (org-export-with-tables, org-export-with-tags)
+       (org-export-with-tasks, org-export-time-stamp-file)
+       (org-export-with-timestamps, org-export-with-todo-keywords): Fix
+       docstrings.
+
+       * ox-html.el (org-html-postamble-format): Slightly change default
+       value so "Generated by" string doesn't get duplicated.
+       (org-html-creator-string): Fix docstring.
+
+       * ox.el (org-export--get-inbuffer-options)
+       (org-export--list-bound-variables)
+       (org-export--generate-copy-script, org-export-string-as)
+       (org-export-expand-include-keyword)
+       (org-export--prepare-file-contents): Inhibit startup process when
+       calling `org-mode'.
+
+       * ox-publish.el (org-publish-find-date): Fix "bad timestamp" error
+       with some DATE values: :date property in communication channel is
+       no longer a string.
+
+       * ox.el (org-export-insert-default-template): New function.
+       (org-export--dispatch-ui, org-export--dispatch-action): Access to
+       the function through the dispatcher.
+
+       * ox-icalendar.el (org-icalendar-convert-timestamp): Update
+       docstring.
+       (org-icalendar-dtstamp): New function.
+       (org-icalendar--vevent, org-icalendar--vtodo): Use new function.
+
+       * ox-ascii.el (org-ascii-link):
+       * ox-html.el (org-html-keyword):
+       * ox-latex.el (org-latex-keyword, org-latex-link):
+       * ox-man.el (org-man-keyword):
+       * ox-md.el (org-md-link):
+       * ox-odt.el (org-odt-keyword):
+       * org.el (org-store-link, org-link-search, org-options-keywords):
+       Remove reference to TARGET keyword.
+
+       * ox.el (org-export-resolve-fuzzy-link, org-export-get-ordinal):
+       Do not use TARGET as a destination for links anymore.
+
+       * ox-org.el (org): Add a menu entry for the back-end.
+       (org-org-export-as-org, org-org-export-to-org): New functions.
+
+       * org.el (org-export-backends): Accept `org' as a loadable
+       back-end.
+
+       * ox-ascii.el (org-ascii-template--document-title): Use new function.
+
+       * ox-beamer.el (org-beamer-template): Use new function.
+
+       * ox-html.el (org-html-format-spec): Use new function.
+
+       * ox-latex.el (org-latex-template): Use new function.
+       (org-latex-date-timestamp-format): Remove variable.
+
+       * ox.el (org-export-date-timestamp-format): New variable.
+       (org-export-get-date): New function.
+
+       * ox-odt.el (org-odt--format-paragraph): New function.
+       (org-odt-paragraph): Use new function to limit code duplication.
+       (org-odt-footnote-reference): Change default style for paragraphs
+       when transcoding a footnote definition.
+
+       * org-macro.el (org-macro--collect-macros): Fix a bug where
+       reading a macro in a setup file would remove other macros read so
+       far from template.  Change function signature.
+       (org-macro-initialize-templates): Apply signature change from function
+       above.
+
+       * ox.el (org-export--list-bound-variables): Renamed from
+       `org-export--install-letbind-maybe'.  Though, only return list of
+       bound variables instead of installing them as buffer-local
+       variables.
+       (org-export-get-environment): Use new function.  Take care of the
+       installation of bound variables.
+       (org-export--generate-copy-script): Make sure non-Org variables are
+       also installed in buffer copy.
+
+       * ox.el (org-export-get-environment): Update comment.
+       (org-export--install-letbind-maybe): Go into SETUPFILE files and
+       handle BIND keywords there.
+
+       * ox-latex.el (org-latex-link): Do not prefix relative paths with
+       "file://".
+
+       * org.el (org-link-search): Preserve priority of #+TARGET over
+       #+NAME when resolving a link.
+
+       * ox-latex.el (org-latex-long-listings): New variable.
+       (org-latex-src-block): Use new variable.
+
+       * ox.el (org-export-data): White spaces after export snippets are
+       never ignored.
+
+       * org-element.el (org-element-macro-parser): Allow to escape
+       escaping character before a comma.  Also do not trim spaces at
+       argument boundaries.
+
+       * ox.el (org-export-async-start): Use correct coding system so
+       unibyte characters do not appear in the resulting buffer or file.
+       (org-export--copy-to-kill-ring-p): Move function elsewhere in the
+       file.
+
+       * ox-latex.el (org-latex--inline-image): Fix error when no default
+       width, height and option are provided and no attribute is set for
+       the inline image.
+
+       * org.el (org-comment-or-uncomment-region): Fix commenting lines
+       beginning with a link.
+       (org-delete-char): Fix "Invalid use of `\\' in replacement text"
+       when deleting a character in a cell which contains "\"
+       (org-export-backends): Remove duplicates.  Reorder alphabetically.
+
+       * ox-texinfo.el (org-texinfo-plain-list): Use `member' instead of
+       `memq' when matching strings.
+
+       * ox.el (org-export-read-attribute): Do not use `read' to read
+       attributes.  Instead, extract keywords and values from it, which
+       means each value will be a string when non-nil.
+
+       * ox-beamer.el (org-beamer-plain-list): Use new attribute syntax.
+
+       * ox-html.el (org-html--textarea-block): Use new attribute syntax.
+
+       * ox-latex.el (org-latex--inline-image, org-latex--org-table)
+       (org-latex--math-table): Use new attribute syntax.
+
+       * ox-man.el (org-man-table--org-table): Use new attribute syntax.
+       Small refactoring.
+
+       * ox-odt.el (org-odt-link--inline-image, org-odt-table-cell): Use
+       new attribute syntax.
+
+       * ox.el (org-export-async-start): Remove code evaluation queries
+       from asynchronous export.
+
+       * ox-latex.el (latex): Activate smart quotes by default.
+       (org-latex--inline-image): Don't insert a default width when
+       height is provided in a figure environment.
+       (org-latex--inline-image): Do not use default width
+       (resp. height) when an user height (resp. width) is provided.
+       Also, default height is only used when image is not wrapped within
+       a figure or wrapfigure environment, in order to preserve ratio.
+       (org-latex-image-default-width, org-latex-image-default-height):
+       Update docstring.
+
+       * ox-icalendar.el (org-icalendar-create-uid): Fix error when
+       `org-icalendar-store-UID' is non-nil.
+
+       * ox-latex.el (latex): Introduce new buffer keyword.
+       (org-latex-template): Use new keyword.
+
+       * ox-beamer.el (org-beamer-template): Use new keyword.
+
+       * org.el (org-create-formula--latex-header): Use new keyword.
+
+       * ox-beamer.el (org-beamer-column-view-format, org-beamer-theme)
+       (org-beamer-environments-extra): Add :version and
+       :package-version.
+
+       * ox-html.el (org-html-with-latex, org-html-inline-image-rules):
+       Add :version and :package-version.
+
+       * ox-latex.el (org-latex-inline-image-rules)
+       (org-latex-default-table-environment)
+       (org-latex-default-table-mode, org-latex-tables-booktabs)
+       (org-latex-table-scientific-notation, org-latex-known-errors): Add
+       :version and :package-version.
+
+       * ox-md.el (org-md-headline-style): Add :version and
+       :package-version.
+
+       * ox-odt.el (org-odt-with-latex): Add :version
+       and :package-version.
+
+       * ox.el (org-export-with-drawers, org-export-with-latex)
+       (org-export-with-inlinetasks, org-export-with-planning)
+       (org-export-with-smart-quotes, org-export-with-statistics-cookies)
+       (org-export-allow-bind-keywords, org-export-async-init-file): Add
+       :version and :package-version.
+
+       * ox-icalendar.el (org-icalendar-export-to-ics): Change back-end
+       name from `e-ascii' to `ascii'.
+
+       * ox.el (org-export--generate-copy-script): Call `org-mode' when
+       duplicating a buffer.  It will properly set every variable, like
+       `comment-start'.
+       (org-export-async-start): Do not call `org-mode' since this is done
+       already in the previous function.
+
+       * ox-beamer.el (org-beamer-keyword): Remove frame arount toc when
+       generated from a TOC keyword.
+
+       * org.el (org-export-backends): Do not reset list of loaded
+       back-ends to variable's value after a reload.
+
+       * ox-latex.el (org-latex-src-block): Do not overwrite provided
+       numbering options in minted and listings.
+       (org-latex-headline): Don't add optional title on unnumbered
+       headlines.
+
+       * ox-html.el (html): Fix "HTML_HEAD" and "HTML_HEAD_EXTRA"
+       keywords.  Allow multiple #+LATEX_HEAD and #+LATEX_HEAD_EXTRA
+       again.
+
+       * org.el (org-fill-paragraph): Small refactoring to
+       `org-fill-paragraph'.  Do not look for table cells in a paragraph.
+
+       * org-element.el (org-element-object-restrictions): Simplify
+       restrictions within secondary strings and objects.
+
+       * org-list.el (org-list-send-list): Do not rely on
+       `org-list-parse-list'.
+       (org-list-to-latex, org-list-to-html, org-list-to-texinfo): Use
+       appropriate export back-end instead of using
+       `org-list-to-generic'.
+
+       * ox-html.el (org-html-inner-template): Remove contents div and
+       title.
+       (org-html-template): Add contents div and title.
+       (org-html-infojs-install-script): Can't activate jsinfo script
+       during a body-only export.
+
+       * ox.el (org-export-as): Store export options in :export-options
+       porperty within communication channel.
+
+       * ox-latex.el (org-latex-item): Fix wrong behaviour when a counter
+       is set in an ordered list while its parent is not ordered.
+
+       * ox.el (org-export-format-code-default): Handle empty source
+       blocks more gracefully.
+
+       * ox-ascii.el (org-ascii-src-block): Handle empty blocks more
+       gracefully.
+
+       * org.el (org-export-backends): Update variable.  `infojs' was
+       merged into ox-html and `freemind' was added.
+
+       * ox.el (org-export--selected-trees): Also mark inlinetasks with a
+       select tag.
+       (org-export--skip-p): Skip inlinetasks with a :noexport: tag.
+
+       * ob-tangle.el (org-babel-spec-to-string): Use dedicated function
+       for unescaping code.
+
+       * ox-html.el (org-html-link): Silence byte-compiler.
+       (html): Add infojs installation script in options filter.
+       (org-html-infojs-install-script): Remove check for back-end as we
+       can safely assume the function will be called from `html' back-end
+       or one of its derivative.
+
+       * ox-icalendar.el (org-agenda-collect-markers)
+       (org-create-marker-find-array): Remove functions.
+       (org-icalendar-export-current-agenda): Integrate previous
+       functions.
+
+       * ox-latex.el (org-latex-format-headline-default-function): Use
+       declarative shape to nest makup for TODO keywords.  Previous
+       syntax generated errors during export.
+
+       * ox.el (org-export-async-start): Ignore `org-mode-hook' and
+       `kill-emacs-hook'.  The first one has been run in the original
+       buffer.  The second is not necessary and can pollute output to a
+       temporary buffer (e.g. with `org-clock-persistence-insinuate').
+
+       * ox-html.el (org-html-inner-template): Remove title.
+       (org-html-template): Add title.
+
+       * ox.el (org-export--get-min-level): Ignore footnote section when
+       computing minimal headline level.
+
+       * org.el (org-do-latex-and-related): Fix infloop when user
+       provides a wrong value for `org-highlight-latex-and-related'. In
+       this case, `org-latex-and-related-regexp' is the empty string and
+       generates an infloop since matching it doesn't move point.
+
+       * org-element.el (org-element-headline-parser): Rename
+       :optional-title into :alt-title.
+
+       * ox.el (org-export-get-alt-title): Renamed from
+       `org-export-get-optional-title'.
+
+       * ox-ascii.el (org-ascii--build-title):
+       * ox-html.el (org-html--format-toc-headline):
+       * ox-latex.el (org-latex-headline):
+       * ox-texinfo.el (org-texinfo--get-node)
+       (org-texinfo--generate-menu-items): Apply name change.
+
+       * ox.el (org-export--get-inbuffer-options): Remove an optional
+       argument.  Rewrite function.  Properties read from a setupfile do
+       not overwrite anymore previously computed properties.
+       (org-export-get-environment): Apply changes to previous function.
+
+       * org.el (org-create-formula--latex-header): Apply arity change
+       from `org-export--get-inbuffer-options'.
+
+       * ox-latex.el (org-latex-compile): Add an optional argument for
+       latex snippet previewing.
+
+       * org.el (org-create-formula-image-with-imagemagick): Use
+       `org-latex-compile' instead of rewriting it.
+
+       * ox-html.el (org-html-fontify-code): Do not use [^\000] in
+       regexps that may match large strings.
+
+       * org.el (org-create-formula--latex-header): New function.
+       (org-create-formula-image-with-dvipng)
+       (org-create-formula-image-with-imagemagick): Use new function.
+
+       * ox.el (org-export-get-previous-element): Change order of retured
+       elements in `org-export-get-previous-element'.
+
+       * org-element.el (org-element-all-successors): Add `plain-link'
+       successor.
+       (org-element-object-restrictions): Remove `link' within `link'.
+       Allow `plain-link' instead.
+       (org-element-plain-link-successor): New function.
+
+       * org.el (org-match-substring-regexp)
+       (org-match-substring-with-braces-regexp): Update regexp.  A
+       sub/superscript cannot start anymore at the beginning of the line
+       or after a space.
+
+       * org-element.el (org-element--get-next-object-candidates):
+       Rewrite function to simplify algorithm.
+       (org-element-context, org-element--parse-elements): Apply changes.
+
+       * org.el (org-fill-paragraph): Apply changes.
+
+       * ox-html.el (org-html-link, org-html-link--inline-image):
+       Attributes specified to a paragraph only apply to first link
+       within.
+
+       * ox-latex.el (org-latex-headline): Do not add optional section
+       name when section is unnumbered.
+
+       * org.el (org-in-verbatim-emphasis): Fix false positive when point
+       is just after the closing emphasis marker.
+       (org-fill-paragraph): Do not move point when filling a table.
+
+       * ox-ascii.el (ascii): Add new filter.
+       (org-ascii-filter-comment-spacing): New function.
+       (org-latex-keyword): Remove "figures" value.
+
+       * ox-ascii.el (org-ascii--list-tables): Fix docstring.
+
+       * ox-html.el (org-html--format-toc-headline): Fix function name.
+       (org-html-toc, org-html--toc-text): Change to docstring.
+       (org-html-list-of-listings, org-html-list-of-tables): New
+       functions.
+       (org-html-keyword): Use new functions.
+       (org-html-src-block): Add an ID attribute when a name is given.
+
+       * org-element.el (org-element-footnote-definition-parser): Require
+       2 blank lines to separate footnote definition.
+
+       * org-footnote.el (org-footnote-at-definition-p): Require 2 blank
+       lines to separate footnote definition.
+
+       * ox.el (org-export-stack): Rewrite.
+       (org-export-stack-refresh): Refactor.
+       (org-export-stack-remove, org-export-stack-view): Apply renaming.
+       (org-export-stack-mode-map): Use tabulated list map as a basis.
+       (org-export-stack--generate, org-export-stack--num-predicate): New
+       function.
+       (org-export-get-optional-title): Return regular title when no
+       optional title is found.
+
+       * ox-ascii.el (org-ascii--build-title): Apply change to
+       `org-export-get-optional-title'.
+
+       * ox-html.el (org-html--format-toc-headline): Apply change to
+       `org-export-get-optional-title'.
+
+       * ox-latex.el (org-latex-headline): Apply change to
+       `org-export-get-optional-title'.
+
+       * ox-ascii.el (org-ascii--build-title): Add an argument.  Use
+       optional title when building a toc line.
+       (org-ascii--build-toc): Call `org-ascii--build-title' with
+       appropriate arguments.
+
+       * ox-latex.el (org-latex-headline): Use optional title for table
+       of contents.
+
+       * ox-html.el (org-html--toc-text): Renamed from
+       `org-html-toc-text'.  Add docstring.
+       (org-html--format-toc-headline): Renamed from
+       `org-html-format-toc-headline'.  Add docstring.  Use optional
+       title if possible.
+       (org-html-toc): Add docstring.
+
+       * org-element.el (org-element-headline-parser): Node property
+       :OPTIONAL_TITLE: in a headline will be parsed and stored under
+       :optional-title property.
+
+       * ox.el (org-export-get-optional-title): New function.
+
+       * ox-latex.el (org-latex-format-headline-default-function): Make
+       the variable a function.
+
+       * ox-publish.el (org-publish-resolve-external-fuzzy-link): No
+       error when resolving external fuzzy links outside publishing.
+       Though search option for these links will not be resolved.
+
+       * ox-latex.el (org-latex-guess-inputenc): Set inputenc option
+       according to `org-export-coding-system'.
+
+       * ox.el (org-export--generate-copy-script): Clone
+       `buffer-file-coding-system' when creating a buffer copy.
+
+       * ox-html.el (org-html-link): Resolve external links with search
+       options like [[file.org::#custom-id]] or
+       [[file.org::*headline-search]].
+
+       * ox-publish.el (org-publish-collect-numbering)
+       (org-publish-resolve-external-fuzzy-link): New functions.
+       (org-publish-org-to): Add new collecting function to final output
+       filter.  Move index collecting function to the same filter.
+       (org-publish-collect-index): Called from final output filter.
+
+       * ox-html.el (org-html-format-headline--wrap, org-html-headline):
+       Use :CUSTOM_ID, not :custom-id.
+
+       * org-element.el (org-element-latex-environment-parser): Fix wrong
+       value for :post-affiliated property when parsing a latex
+       environment.
+
+       * ox-latex.el (org-latex-property-drawer): Remove function.
+
+       * ox-ascii.el (org-ascii-filter-paragraph-spacing): Remove
+       reference to now renamed `e-ascii' back-end.
+
+       * ox-beamer.el (org-beamer-template): Allow to span documentclass
+       options accross multiple lines in template.
+
+       * ox-latex.el (org-latex-template): Allow to span documentclass
+       options accross multiple lines in template.
+
+       * ox-texinfo.el (org-texinfo--get-node): Upcase property name.
+       (org-texinfo--get-node): New function.
+       (org-texinfo-headline, org-texinfo-link): Use new function.
+
+       * ox-ascii.el (org-ascii-quote-block): Do not fill quote block
+       contents.  Just indent them.
+
+       * ox-publish.el (org-publish-index-generate-theindex): Do not
+       create an "* Index" headline in "theindex.inc".  Though, create an
+       "Index" title in fallback "theindex.org".
+
+       * ox-publish.el (org-publish-projects): Publish "theindex.org"
+       last, so that "theindex.inc" can be completed.
+
+       * ox-publish.el (org-publish-project-alist): Fix docstring.
+       (org-publish-collect-index): Fix typo.
+
+       * ox.el (org-export--dispatch-ui): Prevent invisible cursor from
+       highlighting brackets in UI
+
+       * org-element.el (org-element-headline-parser)
+       (org-element-inlinetask-parser): Fix docstring.
+
+       * org.el (org-export-backends): Add new back-end in customize
+       interface.
+
+       * ox-beamer.el (org-beamer--get-label, org-beamer--frame-level)
+       (org-beamer--format-section, org-beamer--format-frame)
+       (org-beamer--format-block, org-beamer-headline): Apply changes to
+       properties.
+
+       * ox-html.el (org-html-headline, org-html-link, org-html-section):
+       Apply changes to properties.
+
+       * ox-icalendar.el (org-icalendar-create-uid)
+       (org-icalendar-blocked-headline-p, org-icalendar-entry)
+       (org-icalendar--valarm): Apply changes to properties.
+
+       * ox-odt.el (org-odt-headline): Apply changes
+
+       * ox-publish.el (org-publish-collect-index): Apply changes to
+       properties.
+
+       * ox-texinfo.el (org-texinfo--generate-menu-list)
+       (org-texinfo--generate-menu-items, org-texinfo-template)
+       (org-texinfo-headline, org-texinfo-link): Apply changes to
+       properties.
+
+       * ox.el (org-export-resolve-id-link, org-export-get-category):
+       Apply changes to properties.
+       (org-export-get-node-property): Update docstring.
+
+       * org-element.el (org-element-headline-parser)
+       (org-element-inlinetask-parser): Upcase properties.  This is done
+       to avoid confusion between properties from parser (e.g. `:end')
+       and properties from the property drawer (e.g. :END:).
+
+       * ox-publish.el (org-publish-index-generate-theindex): Preserve
+       order in file.  Fix error when two index entries were identical.
+       Create again theindex.inc.
+
+       * org-element.el (org-element-map): Allow to map over any list.
+       Do not restrict mapping to object types.
+
+       * org-faces.el (org-latex-and-related): Renamed from
+       `org-latex-and-export-specials', which wasn't appropriate anymore.
+
+       * org.el (org-highlight-latex-and-related)
+       (org-latex-and-related-regexp): New variables.
+       (org-compute-latex-and-related-regexp, org-do-latex-and-related): New
+       function, revived from a previous commit.
+       (org-set-regexps-and-options, org-set-font-lock-defaults): Use new
+       functions.
+       (org-set-regexps-and-options): Remove reference to LATEX_CLASS and
+       beamer back-end.
+
+       * ox-publish.el (org-publish-org-to): Small refactoring.
+
+       * ox.el (org-export-install-filters): Properly install filters
+       send through ext-plist mechanism.
+
+       * ox-publish.el (org-publish-org-to): Small refactoring.
+
+       * ox-html.el (org-html-keyword): Remove INDEX keyword handling.
+       ox-publish.el takes care of it already.
+
+       * org-macro.el: New file.
+
+       * org.el: Remove macro code.
+
+       * ox.el: Require new library
+
+       * ox.el (org-export-resolve-fuzzy-link): Ignore statistics cookies
+       when matching an headline.
+       (org-export--dispatch-ui): Display a help message in header line
+       for scrolling dispatcher's buffer
+       (org-export-resolve-radio-link): Radio targets are
+       case-insensitive.
+
+       * ox-icalendar.el (org-export-icalendar): Fix docstring.
+
+       * ox.el (org-export-dispatch): Fix docstring.
+       (org-export--dispatch-action): Small improvement to line by line
+       scrolling.
+       (org-export-resolve-fuzzy-link): Refactor.  Whitespaces are not
+       significant when matching a fuzzy link.
+
+       * org-element.el (org-element-link-parser): Do not remove newlines
+       characters in paths anymore, since this is not required.
+
+       * ox.el (org-export--dispatch-ui): Renamed from
+       `org-export-dispatch-ui'.  Handle scrolling.
+       (org-export--dispatch-action): Renamed from
+       `org-export-dispatch-action'.  Implement scrolling.
+       (org-export-dispatch): Apply renaming.
+
+       * org.el (org-ctrl-c-ctrl-c): Do nothing when at a blank line,
+       but still run `org-ctrl-c-ctrl-c-final-hook'.
+       (org-end-of-line): Remove `ignore-error'.
+
+       * org-element.el (org-element-at-point): Return nil when in the
+       first empty lines of the buffer.  Return headline when in empty
+       lines just after the headline.
+
+       * ox.el (org-export-output-file-name): Add a protection when
+       output file name is the same as the original org.
+
+       * ox-beamer.el (org-beamer-template): Add missing `class' argument
+       for `format-string'.
+
+       * ox-latex.el (org-latex-template): Add missing `class' argument
+       for `format-string'.
+
+       * ox.el (org-export-stack-mode): Fix docstring.
+
+       * org-pcomplete.el (pcomplete/org-mode/file-option): Allow
+       completion for ATTR_ prefixed keywords.
+
+       * org.el (org-options-keywords): Add missing colons.
+
+       * org-macs.el (org-default-options): Removed function.
+
+       * org-pcomplete.el (org-command-at-point): Fix bug with some file
+       options.
+       (pcomplete/org-mode/file-option/x): Removed macro.
+       (pcomplete/org-mode/file-option): Refactor code.
+       (pcomplete/org-mode/file-option/author)
+       (pcomplete/org-mode/file-option/date)
+       (pcomplete/org-mode/file-option/title)
+       (pcomplete/org-mode/file-option/tags)
+       (pcomplete/org-mode/file-option/select_tags)
+       (pcomplete/org-mode/file-option/priorities)
+       (pcomplete/org-mode/file-option/language)
+       (pcomplete/org-mode/file-option/filetags)
+       (pcomplete/org-mode/file-option/exclude_tags)
+       (pcomplete/org-mode/file-option/email): New functions.
+
+       * ox.el (org-export--collect-headline-numbering): Remove footnote
+       section from TOC.
+       (org-export-collect-headlines): Do not count footnote section when
+       numbering a headline.
+
+       * ox-beamer.el (org-beamer-plain-list): Also read #+attr_latex
+       attributes in order to determine list's options.
+
+       * ox-ascii.el (org-ascii-inner-template): New function.
+       (org-ascii-template): Use new function.
+       (org-ascii-export-as-ascii, org-ascii-export-to-ascii): Update
+       docstring.
+
+       * org-element.el (org-element-link-parser): Take into
+       consideration links filled and indented.
+
+       * org-element.el (org-element-link-parser): Remove all newline
+       characters in path property.
+
+       * ox.el (org-export-as): Call `inner-template' function, if
+       available.
+
+       * ox-html.el (org-html-inner-template): New function.
+       (org-html-template): Move all parts that should be inserted even
+       in a body-only export into `org-html-inner-template'.
+
+       * org.el (org-forward-element, org-backward-element): When no
+       headline is found at the same level, still move forward or
+       backward.
+
+       * org-element.el (org-element--current-element): Add a limit
+       argument.
+       (org-element--collect-affiliated-keywords): Fix parsing of orphaned
+       keyword at the end of an element.
+
+       * ox-texinfo.el (org-texinfo-src-block): Remove spurious newline
+       character as `org-export-format-code-default' already makes sure
+       the string returned will end with a single one.
+
+       * ox-latex.el (org-latex-headline): When a function returns a
+       sectioning command, only one placeholder should be required.
+
+       * org-element.el (org-element-nested-p): Do not inline function.
+
+       * ox.el (org-export-copy-buffer, org-export-with-buffer-copy)
+       (org-export--generate-copy-script): Moved earlier in the file.
+
+       * ox-texinfo.el (org-texinfo-link): Do not transform path part of
+       internal links.
+
+       * org.el (org-org-menu): Small refactoring.
+
+       * ox-beamer.el (require):
+       * ox-icalendar.el (require):
+       * ox-jsinfo.el (require):
+       * ox-md.el (require): Require cl when compiling.
+
+       * org.el (org-export-backends):
+       * ox.el (org-export-dispatch): Fix docstring.
+
+       * ox.el (org-export-dispatch-ui): Widen UI by 2 characters.
+
+       * ox-latex.el (org-latex-special-block): Add :options attribute to
+       special blocks to specify options.
+
+       * ox-beamer.el (org-beamer-template): Add BEAMER_HEADER keywords
+       below LATEX_HEADER.
+
+       * ox-latex.el (org-latex-format-headline-function): Fix missing
+       parens in the docstring.
+
+       * org.el (org-export-backends): Remove `:initialize' function.
+
+       * org.el (org-reload): Also reload export back-ends in use.
+
+       * ox-latex.el (org-latex-example-block, org-latex-src-block):
+       Ignore element if it's empty.  This fixes error "apply: Wrong
+       number of arguments: max, 0".
+
+       * ox-beamer.el (org-beamer-template): Provide an error when LaTeX
+       class is invalid.
+
+       * ox-latex.el (org-latex-template): Provide an error when LaTeX
+       class is invalid.
+
+       * org.el (org-modules): Remove export back-ends from the list.
+       Update docstring.
+       (org-export-backends): New variable.
+
+       * ox.el (org-export-async-start): Make sure export framework is
+       required in the external process.
+
+       * 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.
+
+       * org-entities.el (org-entities-user): Update docstring.
+
+       * 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.
+
+       * ox-beamer.el (org-beamer-template): Apply renaming.
+
+       * 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.
+
+       * org-macs.el (org-if-unprotected, org-if-unprotected-1)
+       (org-if-unprotected-at): Removed macros.
+       (org-re-search-forward-unprotected): Removed function.
+
+       * org.el (org-format-latex):
+       * org-list.el (org-list-struct):
+       * org-footnote.el (org-footnote-at-reference-p):
+       * org-capture.el (org-capture-fill-template): Remove reference to
+       `org-protected'.
+
+       * ob-exp.el (org-babel-exp-process-buffer): Renamed from
+       `org-export-blocks-preprocess'.
+
+       * ox.el (org-export-execute-babel-code): Apply previous renaming.
+
+       * 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.
+
+       * org-clock.el (org-clocktable-defaults)
+       (org-clocktable-write-default): Avoid requiring the whole export
+       framework just to check one variable.
+
+       * org-footnote.el (org-footnote-section): Update docstring.
+       (org-footnote-normalize): Remove all export related part from the
+       function.
+
+       * org-inlinetask.el (org-inlinetask-export)
+       (org-inlinetask-export-templates): Removed variables.
+       (org-inlinetask-export-handler): Removed function.
+
+       * org-plot.el: Remove dependency on `org-exp' library.
+
+       * 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.
+
+       * ob-haskell.el (org-babel-haskell-export-to-lhs): Use new
+       exporter.
+
+       * ob-latex.el (org-babel-execute:latex): Use new exporter.
+
+       * ob-org.el (org-babel-execute:org): Use new exporter.
+
+       * org-agenda.el (org-agenda-menu, org-agenda-write): Use new
+       iCalendar export back-end.
+
+       * 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.
+
+       * 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.
+
+       * org-ascii.el:
+       * org-beamer.el:
+       * org-docbook.el:
+       * org-exp-blocks.el:
+       * org-exp.el:
+       * org-freemind.el:
+       * org-html.el:
+       * org-icalendar.el:
+       * org-jsinfo.el:
+       * org-latex.el:
+       * org-lparse.el:
+       * org-odt.el:
+       * org-publish.el:
+       * org-special-blocks.el:
+       * org-taskjuggler.el:
+       * org-xoxo.el: Remove
+
+       * ox-ascii.el:
+       * ox-beamer.el:
+       * ox-html.el:
+       * ox-icalendar.el:
+       * ox-jsinfo.el:
+       * ox-latex.el:
+       * ox-man.el:
+       * ox-md.el:
+       * ox-odt.el:
+       * ox-publish.el:
+       * ox-texinfo.el:
+       * ox.el: New file.
+
+       * ob-exp.el (org-export-blocks-preprocess): Do not use
+       `indent-code-rigidly' as it doesn't indent contents of strings.
+
+       * org-element.el (org-element-map): Change to function
+       indentation.  Also complete docstring.
+
+       * org.el (org-ctrl-c-ctrl-c): Major rewrite function using
+       Elements.
+
+       * org-element.el (org-element-at-point): When point is before any
+       element, in the first blank lines of the buffer, return nil.  When
+       point is within blank lines just after a headline, return that
+       headline.
+       (org-element-context): Return nil when point is within the blank at
+       the beginning of the buffer.
+
+       * org.el (org-edit-special): Fix regression.
+       (org-timestamp-has-time-p, org-timestamp-format)
+       (org-timestamp-split-range, org-timestamp-translate): New
+       functions.
+
+       * org-element.el (org-element-timestamp-interpreter): Interpret
+       timestamps ranges with repeaters.
+
+       * org.el (org-edit-special): Rewrite `org-edit-special' using Org
+       Elements tools.  Behaviour should be unchanged.
+
+       * org-element.el (org-element-context): Add an optional argument
+       so that (org-element-context) and (org-element-context
+       (org-element-at-point)) are equivalent.
+
+       * ob.el: Only use the :wrap argument up to the first space when
+       creating the #+END_ directive.
+
+       * org-element.el (org-element-object-variables): New variable.
+       (org-element-parse-secondary-string): Copy some buffer-local
+       variables to the temporary buffer created to parse the string so
+       links can still be properly expanded.
+       (org-element-link-parser): Link expansion and translation are applied
+       transparently for the parser.
+
+       * org-element.el (org-element-line-break-parser): Line break
+       includes the newline character following the backslashes.
+       (org-element-line-break-interpreter): Apply changes to line break
+       parsing.
+
+       * org.el (org-all-targets): Fix radio targets detection when
+       object is directly followed by a non-whitespace character.
+
+       * ob.el (org-babel-use-quick-and-dirty-noweb-expansion): Renamed
+       from `org-babel-use-quick-and-dirty-noweb-expansion'.
+       (org-babel-expand-noweb-references): Use new variable name.
+
+       * org-element.el (org-element-timestamp-interpreter): Fix
+       timestamp interpreter when raw value isn't available.
+
+       * ob-exp.el (org-babel-exp-non-block-elements): Make sure to parse
+       inline babel call or inline src block instead of the following
+       object.
+
+       * org-element.el (org-element-timestamp-parser): Timestamp with
+       time range has active/inactive-range type.
+       (org-element-block-name-alist): Do not reset
+       `org-element-block-name-alist' at each reload.
+       (org-element-object-restrictions): Allow timestamps in parsed
+       keywords (i.e. DATE).
+
+       * org-agenda.el (org-agenda-show-clocking-issues)
+       (org-agenda-format-item): Silence byte compiler.
+
+       * org-colview-xemacs.el (org-agenda-columns): Silence byte
+       compiler.
+
+       * org-colview.el (org-agenda-columns): Silence byte compiler.
+
+       * org.el (org-properties-postprocess-alist): Silence byte
+       compiler.
+
+       * org-element.el (org-element-timestamp-parser): Return nil for
+       unspecified :hour-end and :minute-end properties.
+       (org-element-object-restrictions): Add footnote references objects
+       in table cells.
+       (org-element-interpret-data): Clear text properties when
+       interpreting a string .
+
+       * org-capture.el (org-capture--expand-keyword-in-embedded-elisp):
+       Fix docstring.
+
+       * org.el (org-adaptive-fill-function): Items do not have
+       a :post-affiliated property. Use :begin property instead.
+
+       * org-element.el (org-element-headline-parser)
+       (org-element-inlinetask-parser): Remove :clockedp property.
+
+       * org.el (org-adaptive-fill-function): All elements do not have a
+       :post-affiliated property.
+       (org-macro-replace-all): Signal an error when a circular macro
+       expansion happens.
+       (org-macro-initialize-templates): Fix docstring.
+
+       * org-element.el (org-element-map): Fix docstring.
+       (org-element-contents, org-element-set-contents)
+       (org-element-adopt-elements): Fix accessors and setters wrt
+       secondary strings.
+       (org-element-headline-parser)
+       (org-element-inlinetask-parser): Fix void-function
+       `org-clocking-buffer' error.
+       (org-element-context): Fix org-element-context on parsed keywords.
+       (org-element-context): Find objects in document and parsable
+       affiliated keywords.
+       (org-element-center-block-parser)
+       (org-element-drawer-parser, org-element-dynamic-block-parser)
+       (org-element-footnote-definition-parser)
+       (org-element-plain-list-parser)
+       (org-element-property-drawer-parser)
+       (org-element-quote-block-parser, org-element-special-block-parser)
+       (org-element-babel-call-parser, org-element-comment-parser)
+       (org-element-comment-block-parser, org-element-diary-sexp-parser)
+       (org-element-example-block-parser)
+       (org-element-export-block-parser, org-element-fixed-width-parser)
+       (org-element-horizontal-rule-parser, org-element-keyword-parser)
+       (org-element-latex-environment-parser)
+       (org-element-paragraph-parser, org-element-src-block-parser)
+       (org-element-table-parser, org-element-verse-block-parser): Add
+       `:post-affiliated' property to elements.
+       (org-element-inlinetask-parser): Remove affilated keywords.
+
+       * org.el (org-adaptive-fill-function): Use new property.
+
+       * org-element.el (org-element--collect-affiliated-keywords):
+       Allow duals keywords with only secondary value.
+       (org-element-timestamp-parser): Modify timestamp objects
+       properties.
+       (org-element-headline-parser, org-element-inlinetask-parser): Remove
+       `:timestamp' and `:clock' property.  Add `:clockedp' property.  Also,
+       set `:closed', `:deadline' and `:scheduled' values to timestamp
+       objects, not strings.  Small refactoring.
+       (org-element-clock-parser): Rename `:time' property into `:duration'.
+       Also, set `:value' value as a timestamp object, not a string.
+       (org-element-planning-parser): Set `:closed', `:deadline' and
+       `:scheduled' values to timestamp objects, not strings.
+       (org-element-clock-interpreter, org-element-planning-interpreter)
+       (org-element-timestamp-interpreter): Update interpreters.
+       (org-element--current-element): Tiny refactoring.
+
+       * ob.el (org-babel-where-is-src-block-result): Insert new results
+       keyword in current narrowed part of buffer, if necessary. Small
+       refactoring.
+       (org-babel-insert-result): Do not widen buffer when new results have
+       to be inserted.  Therefore, results inserted after the last block of
+       a narrowed buffer still belong to the narrowed part of the buffer.
+
+       * org-agenda.el (org-agenda-get-deadlines): Tiny stylistic change.
+
+       * org-element.el (org-element-paragraph-separate): Diary-sexp
+       elements can separate paragraphs.
+       (org-element-all-elements): Install new `diary-sexp' type.
+       (org-element--current-element): Recognize new `diary-sexp' elements.
+       (org-element-diary-sexp-parser)
+       (org-element-diary-sexp-interpreter): New functions.
+       (org-element-horizontal-rule-parser)
+       (org-element-keyword-parser, org-element--current-element): Small
+       refactoring.
+       (org-element-property): Access to text properties when argument is
+       a string.
+       (org-element-put-property): Correctly set property when target is
+       a string.
+       (org-element-adopt-elements): Also put :parent properties on
+       strings.
+
+       * ob-exp.el (org-babel-exp-code): Escape code when re-creating a
+       src blocks.
+       (org-export-blocks-preprocess): Pos can sometimes be set to a
+       value greater than start, because of indentation, and lead to a
+       search bound error.
+       (org-babel-exp-code): Remove comma-escaping special rule for Org
+       blocks.
+       (org-export-blocks-preprocess): Results of an evaluated code block
+       can be inserted within the blank lines after the block.  Hence, if
+       the block has to be removed, delete everything down to the first
+       non-blank line after the end of block closing string, instead of
+       removing everything down to the very end of the block.
+
+       * org.el (org-all-targets): Make sure the regexp really matched a
+       radio target.
+       (org-macro-expand, org-macro-replace-all): Change signature.  The
+       function now accepts an alist of templates so it doesn't have to
+       rely only on `org-macro-templates'.
+       (org-macro-initialize-templates): {{{date}}} is not anymore an
+       alias for {{{time}}}.  During export, it will provide the value
+       stored in DATE keyword instead.
+
+       * org-element.el (org-element-object-restrictions): Allow links in
+       caption. Also allow inline-src-blocks and inline-babel-calls.
+       (org-element-map): Change signature.
+       (org-element-parsed-keywords): Remove document properties from the
+       value.
+       (org-element-dual-keywords): Fix docstring.
+       (org-element-document-properties): New variable
+       (org-element-all-elements): Add `node-property' as a new element
+       type.
+       (org-element-greater-elements): Add property-drawer element to
+       greater elements since they now contain node-property elements.
+       (org-element-drawer-parser): Small refactoring.
+       (org-element-property-drawer-parser): Move into Greater Elements
+       file section.
+       (org-element-node-property-parser,
+       org-element-node-property-interpreter): New functions.
+       (org-element--current-element, org-element-at-point)
+       (org-element--parse-elements): Handle new element type.
+       (org-element--collect-affiliated-keywords): Fix return value.
+       (org-element-center-block-parser)
+       (org-element-drawer-parser, org-element-dynamic-block-parser)
+       (org-element-footnote-definition-parser)
+       (org-element-plain-list-parser, org-element-quote-block-parser)
+       (org-element-special-block-parser, org-element-babel-call-parser)
+       (org-element-comment-parser, org-element-comment-block-parser)
+       (org-element-example-block-parser)
+       (org-element-export-block-parser, org-element-fixed-width-parser)
+       (org-element-horizontal-rule-parser, org-element-keyword-parser)
+       (org-element-latex-environment-parser)
+       (org-element-paragraph-parser, org-element-property-drawer-parser)
+       (org-element-src-block-parser, org-element-table-parser)
+       (org-element-verse-block-parser): Change signature. Now use an
+       additional argument: affiliated.
+       (org-element--current-element): Skip affiliated keywords and pass
+       them as an argument to parsers.  It prevents to walk through these
+       keywords twice: the first time to get to the first line of the
+       element, and a second time to collect the affiliated keywords.
+
+       * ob-exp.el (org-babel-exp-non-block-elements): More accurate
+       white space handling when evaluating inline-src-block, babel-call
+       and inline-babel-call elements or objects.  Also removed use of
+       `org-babel-examplize-region' since it would never be called
+       anyway; return value from `org-babel-exp-do-export' is never nil.
+       (org-export-blocks-preprocess): Preserve affiliated keywords when
+       replacing a code block.
+
+       * org-element.el (org-element-multiple-keywords): Allow multiple
+       caption keywords.
+
+       * ob-exp.el (org-export-blocks-preprocess): Fix block evaluation
+       when results are before the block.
+       (org-export-blocks-preprocess): Improve blank lines handling in
+       function. Add comments. Remove `org-export-blocks-postblock-hook'
+       since it's defined nowhere now
+       (and doesn't need to, there's `org-export-before-parsing-hook'
+       already).
+
+       * org-exp-blocks.el: Delete.
+
+       * ob-exp.el (org-export-blocks-preprocess):
+       * ob-ditaa.el (org-ditaa-jar-path): Moved from
+       "org-export-blocks.el".
+
+       * ob-exp.el (org-babel-exp-src-block): Remove unused argument.
+       (org-babel-exp-non-block-elements): Rewrite function using Org
+       Element.
+
+       * org-exp-blocks.el (org-export-blocks-preprocess): Rewrite
+       function using Org Element.
+
+       * org-element.el (org-element-recursive-objects)
+       (org-element-object-restrictions): Remove `macro' from recursive
+       object types.
+
+       * org.el (org-macro-initialize-templates): Small refactoring.
+       (org-mode): Initialize macros templates.
+       (org-macro-templates): New variable.
+       (org-macro-expand, org-macro-replace-all)
+       (org-macro-initialize-templates): New functions.
+
+       * org-element.el (org-element-link-type-is-file): New variable.
+       (org-element-link-parser): Extract search option and application
+       in "file"-type links.
+
+       * org.el (org-mode): Set back comment-start-skip so comment-dwin
+       can tell a keyword from a comment.
+
+2013-11-12  Nicolas Richard  <theonewiththeevillook@yahoo.fr>
+
+       * org.el (org-time-stamp): When INACTIVE is non-nil, insert an
+       inactive timestamp also with double universal argument.
+       (org-set-regexps-and-options): Don't set font-lock defaults here.
+       (org-mode): Set font-lock defaults here.
+       (org-insert-link): Call `org-link-try-special-completion' from the
+       original buffer.
+
+2013-11-12  Oleh  <oleh.krehel@gmail.com>
+
+       * org.el (org-open-at-point): The new code is being run in the
+       same spot as `org-open-link-functions'.  In case they failed,
+       check if link matches "^id:" and if so, load the id interface and
+       follwo the link.
+
+2013-11-12  Rasmus  <rasmus@gmx.us>  (tiny change)
+
+       * ox-latex.el (org-latex--inline-image): The pgf format is
+       associated to an inline image and treated like tikz files.
+
+2013-11-12  Richard Lawrence  <richard.lawrence@berkeley.edu>  (tiny change)
+
+       * org-agenda.el (org-cmp-ts): Avoid error when trying to
+       `string-match' against nil.
+
+2013-11-12  Rick Frankel  <rick@rickster.com>
+
+       * ox-html.el (org-html-doctype): New function.
+       (org-html-template): Use `org-html-doctype' instead of inline
+       code.
+       (org-html-headline): Use the new
+       `org-html--container' function to set container element.
+       (org-html--container): Returns appropriate element for headline
+       container.
+       (org-html-divs): Extra character in doc string.
+       (org-babel-execute:sql): Unquote cmdline argument in
+       format string, dbish requires three separate arguments. Add dbi to
+       the list of engines with automatically added header separator.
+       (org-html--build-pre/postamble): Add css class to wrapper div
+       (defaults to `org-pre/postamble-class').  Move spec building to
+       separate function (`org-html-format-spec').
+       (org-html-format-spec): New function.
+       (org-pre/postamble-class): New variable.
+       (org-html--timestamp-format): New variable used in the metadata
+       and the pre/postamble.
+       (org-html-style-default): Make the preamble and postamble use the
+       same style.  Make all anchors font-size %100.  Remove margin from
+       the content section.
+       (org-html-container-element): Fix docstring.
+       (org-html-postamble-format, org-html-preamble-format): Update
+       docstrings.
+       (org-html-template): Use `org-html--build-pre/postamble'.
+       (org-html--build-pre/postamble): New function, combining the
+       pre/postamble generator.  Merge lists of formatters from the
+       preamble and postamble.  Fix bug, using :time-stamp-file instead
+       of :with-date for auto display of date: this brings usage in-line
+       with the latex and beamer exporter.
+       (org-html--build-postamble, org-html--build-postamble): Delete.
+       (define-backend): Add :html-doctype and :html-container
+       parameters.
+       (org-html-doctype): New option for doctype declaration.
+       (org-html-container-elemnt): New option for specifying the wrapper
+       container element.
+       (org-html-divs): Change to alist of three entries each containing
+       a key ('preamble, 'content, 'postamble), an HTML element type and
+       an id to allow setting container elements.
+       (org-html--build-preamble, org-html--build-postamble): Modified to
+       use `org-html-divs'.
+       (org-html-template): Modified to use doctype and container-element
+       settings.
+       (org-export-define-backend): Add css url option.
+       (org-export-htmlized-org-css-url): Modify docstring and options.
+       (org-html--build-style): Include css-url if specified.
+
+2013-11-12  Roberto Huelga Díaz  <rhuelga@gmail.com>  (tiny change)
+
+       * org-timer.el (org-timer-set-timer): Use the variable
+       `org-clock-sound' when calling `org-notify'.
+
+2013-11-12  Ryo TAKAISHI  <ryo.takaishi.0@gmail.com>
+
+       * org-capture.el (org-capture--expand-keyword-in-embedded-elisp):
+       New function.
+       (org-capture-expand-embedded-elisp): Use the new function.
+
+       * ob-tangle.el (org-babel-tangle-collect-blocks): Change argument
+       name collid `org-babel-map-src-blocks' variable 'lang'.
+
+       * org-protocol.el (org-protocol-convert-query-to-plist): New
+       function.
+       (org-protocol-do-capture): Use new function.
+       (org-protocol-data-separator): Change default separator.
+
+2013-11-12  Rémi Vanicat  <vanicat@debian.org>  (tiny change)
+
+       * org-table.el (orgtbl-format-line): Fix bug when formatting line.
+
+2013-11-12  Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+       * ox-latex.el (org-latex-listings): Don't quote const value.
+
+       * ob-C.el (org-babel-C-var-to-C): Add list support
+       (org-babel-C-val-to-C-list-type, org-babel-C-val-to-C-type)
+       (org-babel-C-format-val): New functions.
+       (org-babel-C-ensure-main-wrap, org-babel-execute:C)
+       (org-babel-execute:C++, rg-babel-execute:cpp)
+       (org-babel-C++-compiler, org-babel-C-compiler): Improve docstring.
+
+       * org-entities.el (org-entities): Add support for hbar.
+
+2013-11-12  Sacha Chua  <sacha@sachachua.com>  (tiny change)
+
+       * org.el (org-read-date-get-relative): Handle positive and
+       negative weekday specifications so that they don't return today.
+       If today is Friday, "fri" should mean next Friday.  This changes
+       the previous behavior, which required you to specify "+2fri" in
+       order to mean next Friday if today was Friday.  If you want to
+       schedule something for today, you can use ".".
+
+2013-11-12  Samuel Loury  <konubinix@gmail.com>  (tiny change)
+
+       * org.el (org-open-at-point): Open a plain link even if the cursor
+       is before it, which is consistent with the behavior with respect
+       to bracket and angle links.
+
+2013-11-12  Sean O'Halpin  <sean.ohalpin@gmail.com>  (tiny change)
+
+       * ob.el (org-babel-expand-noweb-references): Capture current noweb
+       start and end patterns then use them to set buffer locals in a
+       (with-temp-buffer ...) form.
+
+2013-11-12  Sebastien Vauban  <xxx@public.gmane.org>
+
+       * ox-latex.el (org-latex-listings-langs): Update custom variable.
+
+       * ob-core.el (org-babel-parse-src-block-match): Fix order of list
+       of header arguments.
+
+       * org-clock.el (org-clock-goto-before-context): New option.
+       (org-clock-goto): Use the new option.
+       (org-clocktable-write-default): Insert the summary as a standard
+       #+CAPTION keyword for the (clock) table.
+
+2013-11-12  Stephen Eglen  <S.J.Eglen@damtp.cam.ac.uk>  (tiny change)
+
+       * org-agenda.el (org-agenda-prefix-format): Small docstring
+       enhancement.
+
+2013-11-12  Suhail Shergill  <suhailshergill@gmail.com>  (tiny change)
+
+       * ob-core.el (org-babel-temp-file): For remote hosts, modify the
+       prefix and leave `temporary-file-directory' unchanged.
+
+2013-11-12  Suvayu Ali  <fatkasuvayu+linux@gmail.com>  (tiny change)
+
+       * org.el (org-speed-commands-default): Change default binding for
+       org-mark-subtree from "." to "@" to be more consistent with "C-c
+       @".
+
+2013-11-12  Tim Burt  <tcburt@rochester.rr.com>  (tiny change)
+
+       * org-datetree.el (org-datetree-find-year-create): Also match
+       headlines with tags.
+
+2013-11-12  Toby S. Cubitt  <tsc25@cantab.net>
+
+       * org.el (org-time-clocksum-format)
+       (org-time-clocksum-fractional-format): In addition to a single
+       format string, the clocksum formats can now be plists specifying
+       separate formats for different time units.
+       (org-minutes-to-clocksum-string): New function to replace
+       `org-minutes-to-hh:mm-string', which converts a number of minutes
+       to a string according to the customization options.
+
+       * org-colview.el (org-columns-number-to-string): Use the new
+       `org-minutes-to-clocksum-string' function to format clocksum
+       durations.
+
+       * org-clock.el: Always call new `org-minutes-to-clocksum-string'
+       function when formatting time durations, instead of calling
+       `org-minutes-to-hh:mm-string' or passing
+       `org-time-clocksum-format' directly to format.
+
+2013-11-12  Tokuya Kameshima  <kametoku@gmail.com>
+
+       * org-mew.el (org-mew-inbox-folder, org-mew-use-id-db)
+       (org-mew-subject-alist, org-mew-capture-inbox-folders)
+       (org-mew-capture-guess-alist): New options.
+       (org-mew-store-link, org-mew-open): Rewrite.
+       (org-mew-folder-name, org-mew-follow-link)
+       (org-mew-folder-eixsts-p, org-mew-get-msgnum)
+       (org-mew-open-by-message-id, org-mew-search, org-mew-capture)
+       (org-mew-capture-guess-selection-keys): New functions.
+
+2013-11-12  Trevor Murphy  <trevor.m.murphy@gmail.com>  (tiny change)
+
+       * org.el (org-get-compact-tod): Always pad minutes to two places.
+
+2013-11-12  Viktor Rosenfeld  <listuser36@gmail.com>  (tiny change)
+
+       * org.el (org-agenda-prepare-buffers): Add tags defined in
+       `org-tag-persistent-alist' to `org-tag-alist-for-agenda'.
+
+2013-11-12  Vitalie Spinu  <spinuvit@gmail.com>
+
+       * ob-tangle.el (org-babel-find-file-noselect-refresh): Call
+       `find-file-noselect' with 'nowarn argument to surpress
+       `yes-or-no-p' reversion message.
+
+       * ob-core.el (org-babel-where-is-src-block-head): Return
+       `point-marker' instead of `point'.
+
+2013-11-12  Yann Hodique  <yann.hodique@gmail.com>
+
+       * org-publish.el (org-publish-org-to-taskjuggler): New function to
+       publish taskjuggler projects.
+
+2013-11-12  Yasushi Shoji  <yashi@atmark-techno.com>
+
+       * org-clock.el (org-clock-x11idle-program-name): New option.
+       (org-x11idle-exists-p, org-x11-idle-seconds): Use it.
+
+2013-11-12  Yoshinari Nomura  <nom@quickhack.net>
+
+       * ox-html.el (org-html--has-caption-p): New function.
+       (org-html-link--inline-image, org-html-table): Prepend ordinal
+       number to caption.
+       (org-html-link): Make numbered link by counting captioned figures
+       and tables.
+
+       * ox.el (org-export-dictionary): Add Japanese translations for
+       figures and tables.  Add "Figure %d:" entry in the same manner
+       with "Table %d:".
+
+2013-11-12  Nicolas Richard  <nrichard@ulb.ac.be>
+
+       * ob.el (org-babel-edit-distance): When insertion or deletion are
+       needed, make sure the distance is incremented.  In addition, the
+       now obsolete mmin function was removed.
+
+2013-11-12  Oleh Krehel <wave@mail.ua>
+
+       * org-capture.el (org-capture-expand-embedded-elisp): Throw error
+       if result is not a string and not nil.  If the result is nil,
+       treat it as if it was the empty string.
+
+       * org-clock.el (org-clock-notify-once-if-expired): Honor
+       `org-clock-sound'.
+
+2013-11-12  Rasmus Pank  <rasmus.pank@gmail.com>
+
+       * org.el (org-format-latex-header): Remove eucal and amsmath.
+       (org-latex-default-packages-alist): Remove amstext and add
+       amsmath.
+
+       * ox-latex.el (org-latex-item): Use square as unchecked symbol.
+
+       * org.el (org-latex-default-packages-alist): Remove latexsym.
+
+       * org-entities.el (org-entities): Add support for ell, imath,
+       jmath, varphi, varpi, aleph, gimel, beth, dalet, cdots, S (§),
+       dag, ddag, colon, therefore, because, triangleq, leq, geq,
+       lessgtr, lesseqgtr, ll, lll, gg, ggg, prec, preceq, preccurlyeq,
+       succ, succeq, succurlyeq, setminus, nexist(s), mho, check, frown,
+       diamond.  Changes loz, vert, checkmark, smile and tilde.
+
+       * ob-C.el: Added C++ to `org-babel-load-languages' automatically
+       after loading C.
+
+       * org-src.el (org-src-lang-modes): Added association between
+       language C++ and `c++-mode'.
+
+       * ox.el (org-export-smart-quotes-alist): Added ("da" "no" "nb"
+       "nn" "sv").
+       (org-export-dictionary): Added some entries ("da" "no" "nb" "nn"
+       "sv").
+       (org-export-default-language): Mention other variables affected by
+       language.
+
+       * ox-latex.el (org-latex-babel-language-alist): Added 'nb', 'nn',
+       and 'no' for Norwegian.  Removed 'no-no'.
+       (org-latex-pdf-process): let `latexmk' be a preconfigured choice
+       and change the wording of the docstring.
+       (org-latex-guess-babel-language): Replace AUTO with language if
+       AUTO is the option of the LaTeX package Babel.
+       (org-latex-classes): updated documentation with respect
+       to `org-latex-guess-babel-language'.
+
+2013-11-12  Дядов Васил Стоянов  <vdyadov@elvees.com>  (tiny change)
+
+       * org-docview.el (org-docview-export): New function to export
+       docview links.
+
 2013-04-18  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * org-agenda.el (org-agenda-mode):
 
        * org.el (org-reload): Simplify file-re (orgtbl-*.el files do not
        exist anymore).  Keep org-*.el at the end of the files list.
-       Explicitely load org-version.el (since it doesn't provide feature
+       Explicitly load org-version.el (since it doesn't provide feature
        'org-version) at the very end, but ignore errors when it doesn't
        exist.  Add parameters 'full and 'message to the call of
        (org-version) so that after reload the full version information is
        * org.el (org-read-date): Set cursor-type to nil in the calendar.
 
        * org-faces.el (org-date-selected): Use inverse video.
-       Don't explicitely set bold to nil as it causes `customize-face' to show
+       Don't explicitly set bold to nil as it causes `customize-face' to show
        the weight property and thus encourage the user to change it.
        Warn in the docstring that using bold might cause problems when
        displaying the calendar.
        * org-agenda.el (org-agenda-skip-timestamp-if-deadline-is-shown):
        Skip timestamp items in agenda view if item is already shown as a
        deadline item.
-       (org-agenda-skip-dealine-if-done): Pass deadline results to
+       (org-agenda-skip-deadline-if-done): Pass deadline results to
        org-agenda-get-timestamps.
        (org-agenda-get-timestamps): Optionally take list of deadline
        results, so that timestamp results can be skipped if already
 2012-01-03  Nicolas Goaziou  <n.goaziou@gmail.com>
 
        * org-footnote.el (org-footnote-create-definition):
-       Explicitely move point after tag, if it has just been
+       Explicitly move point after tag, if it has just been
        inserted.
 
 2012-01-03  Eric Schulte  <schulte.eric@gmail.com>
index 42a98de8c05edadf92162e03e3806bef2574330a..ddceb14f6d96f8e2004556f6b4e3f0203c53dd0d 100644 (file)
@@ -31,7 +31,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 (require 'cc-mode)
 
 (declare-function org-entry-get "org"
 
 (defvar org-babel-C-compiler "gcc"
   "Command used to compile a C source code file into an
-  executable.")
+executable.")
 
 (defvar org-babel-C++-compiler "g++"
   "Command used to compile a C++ source code file into an
-  executable.")
+executable.")
 
 (defvar org-babel-c-variant nil
   "Internal variable used to hold which type of C (e.g. C or C++)
 is currently being evaluated.")
 
 (defun org-babel-execute:cpp (body params)
-  "Execute BODY according to PARAMS.  This function calls
-`org-babel-execute:C++'."
+  "Execute BODY according to PARAMS.
+This function calls `org-babel-execute:C++'."
   (org-babel-execute:C++ body params))
 
 (defun org-babel-execute:C++ (body params)
-  "Execute a block of C++ code with org-babel.  This function is
-called by `org-babel-execute-src-block'."
+  "Execute a block of C++ code with org-babel.
+This function is called by `org-babel-execute-src-block'."
   (let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params)))
 
 (defun org-babel-expand-body:C++ (body params)
@@ -71,8 +70,8 @@ header arguments (calls `org-babel-C-expand')."
   (let ((org-babel-c-variant 'cpp)) (org-babel-C-expand body params)))
 
 (defun org-babel-execute:C (body params)
-  "Execute a block of C code with org-babel.  This function is
-called by `org-babel-execute-src-block'."
+  "Execute a block of C code with org-babel.
+This function is called by `org-babel-execute-src-block'."
   (let ((org-babel-c-variant 'c)) (org-babel-C-execute body params)))
 
 (defun org-babel-expand-body:c (body params)
@@ -104,20 +103,21 @@ or `org-babel-execute:C++'."
                     (mapconcat 'identity
                                (if (listp flags) flags (list flags)) " ")
                     (org-babel-process-file-name tmp-src-file)) ""))))
-    ((lambda (results)
-       (org-babel-reassemble-table
-       (if (member "vector" (cdr (assoc :result-params params)))
-           (let ((tmp-file (org-babel-temp-file "c-")))
-             (with-temp-file tmp-file (insert results))
-             (org-babel-import-elisp-from-file tmp-file))
-         (org-babel-read results))
-       (org-babel-pick-name
-        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
-       (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
-     (org-babel-trim
-      (org-babel-eval
-       (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))))
+    (let ((results
+           (org-babel-trim
+            (org-babel-eval
+             (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))
+      (org-babel-reassemble-table
+       (org-babel-result-cond (cdr (assoc :result-params params))
+        (org-babel-read results)
+         (let ((tmp-file (org-babel-temp-file "c-")))
+           (with-temp-file tmp-file (insert results))
+           (org-babel-import-elisp-from-file tmp-file)))
+       (org-babel-pick-name
+        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
+    ))
 
 (defun org-babel-C-expand (body params)
   "Expand a block of C or C++ code with org-babel according to
@@ -147,10 +147,10 @@ it's header arguments."
                  body) "\n") "\n")))
 
 (defun org-babel-C-ensure-main-wrap (body)
-  "Wrap body in a \"main\" function call if none exists."
+  "Wrap BODY in a \"main\" function call if none exists."
   (if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body)
       body
-    (format "int main() {\n%s\nreturn(0);\n}\n" body)))
+    (format "int main() {\n%s\nreturn 0;\n}\n" body)))
 
 (defun org-babel-prep-session:C (session params)
   "This function does nothing as C is a compiled language with no
@@ -164,6 +164,59 @@ support for sessions"
 
 ;; helper functions
 
+(defun org-babel-C-format-val (type val)
+  "Handle the FORMAT part of TYPE with the data from VAL."
+  (let ((format-data (cadr type)))
+    (if (stringp format-data)
+       (cons "" (format format-data val))
+      (funcall format-data val))))
+
+(defun org-babel-C-val-to-C-type (val)
+  "Determine the type of VAL.
+Return a list (TYPE-NAME FORMAT).  TYPE-NAME should be the name of the type.
+FORMAT can be either a format string or a function which is called with VAL."
+  (cond
+   ((integerp val) '("int" "%d"))
+   ((floatp val) '("double" "%f"))
+   ((or (listp val) (vectorp val))
+    (lexical-let ((type (org-babel-C-val-to-C-list-type val)))
+      (list (car type)
+           (lambda (val)
+             (cons
+              (format "[%d]%s"
+                      (length val)
+                      (car (org-babel-C-format-val type (elt val 0))))
+              (concat "{ "
+                      (mapconcat (lambda (v)
+                                   (cdr (org-babel-C-format-val type v)))
+                                 val
+                                 ", ")
+                      " }"))))))
+   (t ;; treat unknown types as string
+    '("char" (lambda (val)
+              (let ((s (format "%s" val))) ;; convert to string for unknown types
+                (cons (format "[%d]" (1+ (length s)))
+                      (concat "\"" s "\""))))))))
+
+(defun org-babel-C-val-to-C-list-type (val)
+  "Determine the C array type of a VAL."
+  (let (type)
+    (mapc
+     #'(lambda (i)
+        (let* ((tmp-type (org-babel-C-val-to-C-type i))
+               (type-name (car type))
+               (tmp-type-name (car tmp-type)))
+          (when (and type (not (string= type-name tmp-type-name)))
+            (if (and (member type-name '("int" "double" "int32_t"))
+                     (member tmp-type-name '("int" "double" "int32_t")))
+                (setq tmp-type '("double" "" "%f"))
+              (error "Only homogeneous lists are supported by C.  You can not mix %s and %s"
+                     type-name
+                     tmp-type-name)))
+          (setq type tmp-type)))
+     val)
+    type))
+
 (defun org-babel-C-var-to-C (pair)
   "Convert an elisp val into a string of C code specifying a var
 of the same value."
@@ -174,22 +227,17 @@ of the same value."
       (setq val (symbol-name val))
       (when (= (length val) 1)
         (setq val (string-to-char val))))
-    (cond
-     ((integerp val)
-      (format "int %S = %S;" var val))
-     ((floatp val)
-      (format "double %S = %S;" var val))
-     ((or (integerp val))
-      (format "char %S = '%S';" var val))
-     ((stringp val)
-      (format "char %S[%d] = \"%s\";"
-              var (+ 1 (length val)) val))
-     (t
-      (format "u32 %S = %S;" var val)))))
-
+    (let* ((type-data (org-babel-C-val-to-C-type val))
+          (type (car type-data))
+          (formated (org-babel-C-format-val type-data val))
+          (suffix (car formated))
+          (data (cdr formated)))
+      (format "%s %s%s = %s;"
+             type
+             var
+             suffix
+             data))))
 
 (provide 'ob-C)
 
-
-
 ;;; ob-C.el ends here
index 562f37d7b9528b0ef567d62fb5184842378b03c3..58f5536675c1d91f0be5c5820c1985616627c965 100644 (file)
@@ -28,9 +28,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (declare-function orgtbl-to-tsv "org-table" (table params))
         (or graphics-file (org-babel-R-graphical-output-file params))))
     (mapconcat
      #'identity
-     ((lambda (inside)
-       (if graphics-file
-           (append
-            (list (org-babel-R-construct-graphics-device-call
-                   graphics-file params))
-            inside
-            (list "dev.off()"))
-         inside))
-      (append (org-babel-variable-assignments:R params)
-             (list body))) "\n")))
+     (let ((inside
+            (append
+             (when (cdr (assoc :prologue params))
+               (list (cdr (assoc :prologue params))))
+             (org-babel-variable-assignments:R params)
+             (list body)
+             (when (cdr (assoc :epilogue params))
+               (list (cdr (assoc :epilogue params)))))))
+       (if graphics-file
+           (append
+            (list (org-babel-R-construct-graphics-device-call
+                   graphics-file params))
+            inside
+            (list "dev.off()"))
+         inside))
+     "\n")))
 
 (defun org-babel-execute:R (body params)
   "Execute a block of R code.
@@ -212,6 +215,9 @@ This function is called by `org-babel-execute-src-block'."
       (if (org-babel-comint-buffer-livep session)
          session
        (save-window-excursion
+         (when (get-buffer session)
+           ;; Session buffer exists, but with dead process
+           (set-buffer session))
          (require 'ess) (R)
          (rename-buffer
           (if (bufferp session)
@@ -234,31 +240,40 @@ current code buffer."
   (and (member "graphics" (cdr (assq :result-params params)))
        (cdr (assq :file params))))
 
+(defvar org-babel-R-graphics-devices
+  '((:bmp "bmp" "filename")
+    (:jpg "jpeg" "filename")
+    (:jpeg "jpeg" "filename")
+    (:tikz "tikz" "file")
+    (:tiff "tiff" "filename")
+    (:png "png" "filename")
+    (:svg "svg" "file")
+    (:pdf "pdf" "file")
+    (:ps "postscript" "file")
+    (:postscript "postscript" "file"))
+  "An alist mapping graphics file types to R functions.
+
+Each member of this list is a list with three members:
+1. the file extension of the graphics file, as an elisp :keyword
+2. the R graphics device function to call to generate such a file
+3. the name of the argument to this function which specifies the
+   file to write to (typically \"file\" or \"filename\")")
+
 (defun org-babel-R-construct-graphics-device-call (out-file params)
   "Construct the call to the graphics device."
-  (let ((devices
-        '((:bmp . "bmp")
-          (:jpg . "jpeg")
-          (:jpeg . "jpeg")
-          (:tex . "tikz")
-          (:tiff . "tiff")
-          (:png . "png")
-          (:svg . "svg")
-          (:pdf . "pdf")
-          (:ps . "postscript")
-          (:postscript . "postscript")))
-       (allowed-args '(:width :height :bg :units :pointsize
-                              :antialias :quality :compression :res
-                              :type :family :title :fonts :version
-                              :paper :encoding :pagecentre :colormodel
-                              :useDingbats :horizontal))
-       (device (and (string-match ".+\\.\\([^.]+\\)" out-file)
-                    (match-string 1 out-file)))
-       (extra-args (cdr (assq :R-dev-args params))) filearg args)
-    (setq device (or (and device (cdr (assq (intern (concat ":" device))
-                                           devices))) "png"))
-    (setq filearg
-         (if (member device '("pdf" "postscript" "svg" "tikz")) "file" "filename"))
+  (let* ((allowed-args '(:width :height :bg :units :pointsize
+                               :antialias :quality :compression :res
+                               :type :family :title :fonts :version
+                               :paper :encoding :pagecentre :colormodel
+                               :useDingbats :horizontal))
+        (device (and (string-match ".+\\.\\([^.]+\\)" out-file)
+                     (match-string 1 out-file)))
+        (device-info (or (assq (intern (concat ":" device))
+                               org-babel-R-graphics-devices)
+                          (assq :png org-babel-R-graphics-devices)))
+        (extra-args (cdr (assq :R-dev-args params))) filearg args)
+    (setq device (nth 1 device-info))
+    (setq filearg (nth 2 device-info))
     (setq args (mapconcat
                (lambda (pair)
                  (if (member (car pair) allowed-args)
@@ -302,15 +317,16 @@ last statement in BODY, as elisp."
                               (format "{function ()\n{\n%s\n}}()" body)
                               (org-babel-process-file-name tmp-file 'noquote)))
        (org-babel-R-process-value-result
-       (if (or (member "scalar" result-params)
-               (member "verbatim" result-params))
-           (with-temp-buffer
-             (insert-file-contents tmp-file)
-             (buffer-string))
+       (org-babel-result-cond result-params
+         (with-temp-buffer
+           (insert-file-contents tmp-file)
+           (buffer-string))
          (org-babel-import-elisp-from-file tmp-file '(16)))
        column-names-p)))
     (output (org-babel-eval org-babel-R-command body))))
 
+(defvar ess-eval-visibly-p)
+
 (defun org-babel-R-evaluate-session
   (session body result-type result-params column-names-p row-names-p)
   "Evaluate BODY in SESSION.
@@ -335,11 +351,10 @@ last statement in BODY, as elisp."
                  "FALSE")
                ".Last.value" (org-babel-process-file-name tmp-file 'noquote)))
        (org-babel-R-process-value-result
-       (if (or (member "scalar" result-params)
-               (member "verbatim" result-params))
-           (with-temp-buffer
-             (insert-file-contents tmp-file)
-             (buffer-string))
+       (org-babel-result-cond result-params
+         (with-temp-buffer
+           (insert-file-contents tmp-file)
+           (buffer-string))
          (org-babel-import-elisp-from-file tmp-file '(16)))
        column-names-p)))
     (output
index 12d625acf2c074cc01a5dc74b75a2d3d92f90a47..a9215d0b1c852e244d7837aa68ffbe67ba0a770f 100644 (file)
@@ -32,7 +32,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 (require 'org-compat)
 (eval-when-compile (require 'cl))
 
@@ -45,7 +44,7 @@
 (defvar org-babel-awk-command "awk"
   "Name of the awk executable command.")
 
-(defun org-babel-expand-body:awk (body params &optional processed-params)
+(defun org-babel-expand-body:awk (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
     (setf body (replace-regexp-in-string
@@ -60,36 +59,33 @@ called by `org-babel-execute-src-block'"
          (cmd-line (cdr (assoc :cmd-line params)))
          (in-file (cdr (assoc :in-file params)))
         (full-body (org-babel-expand-body:awk body params))
-        (code-file ((lambda (file) (with-temp-file file (insert full-body)) file)
-                     (org-babel-temp-file "awk-")))
-        (stdin ((lambda (stdin)
+        (code-file (let ((file (org-babel-temp-file "awk-")))
+                      (with-temp-file file (insert full-body)) file))
+        (stdin (let ((stdin (cdr (assoc :stdin params))))
                   (when stdin
                     (let ((tmp (org-babel-temp-file "awk-stdin-"))
                           (res (org-babel-ref-resolve stdin)))
                       (with-temp-file tmp
                         (insert (org-babel-awk-var-to-awk res)))
-                      tmp)))
-                (cdr (assoc :stdin params))))
+                      tmp))))
          (cmd (mapconcat #'identity (remove nil (list org-babel-awk-command
                                                      "-f" code-file
                                                      cmd-line
                                                      in-file))
                         " ")))
     (org-babel-reassemble-table
-     ((lambda (results)
-       (when results
-         (if (or (member "scalar" result-params)
-                 (member "verbatim" result-params)
-                 (member "output" result-params))
-             results
-           (let ((tmp (org-babel-temp-file "awk-results-")))
-             (with-temp-file tmp (insert results))
-             (org-babel-import-elisp-from-file tmp)))))
-      (cond
-       (stdin (with-temp-buffer
-               (call-process-shell-command cmd stdin (current-buffer))
-               (buffer-string)))
-       (t (org-babel-eval cmd ""))))
+     (let ((results
+            (cond
+             (stdin (with-temp-buffer
+                      (call-process-shell-command cmd stdin (current-buffer))
+                      (buffer-string)))
+             (t (org-babel-eval cmd "")))))
+       (when results
+         (org-babel-result-cond result-params
+          results
+          (let ((tmp (org-babel-temp-file "awk-results-")))
+            (with-temp-file tmp (insert results))
+            (org-babel-import-elisp-from-file tmp)))))
      (org-babel-pick-name
       (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
      (org-babel-pick-name
index a8e53c01b13f9126488db859fd740d99a7801f0f..b4201a18a02b94ffcf6cbc4280edcd62c3345857 100644 (file)
@@ -31,7 +31,6 @@
 (unless (featurep 'xemacs)
   (require 'calc-trail)
   (require 'calc-store))
-(eval-when-compile (require 'ob-comint))
 
 (declare-function calc-store-into    "calc-store" (&optional var))
 (declare-function calc-recall        "calc-store" (&optional var))
 (defun org-babel-expand-body:calc (body params)
   "Expand BODY according to PARAMS, return the expanded body." body)
 
+(defvar org--var-syms) ; Dynamically scoped from org-babel-execute:calc
+
 (defun org-babel-execute:calc (body params)
   "Execute a block of calc code with Babel."
   (unless (get-buffer "*Calculator*")
     (save-window-excursion (calc) (calc-quit)))
   (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
-        (var-syms (mapcar #'car vars))
-        (var-names (mapcar #'symbol-name var-syms)))
+        (org--var-syms (mapcar #'car vars))
+        (var-names (mapcar #'symbol-name org--var-syms)))
     (mapc
      (lambda (pair)
        (calc-push-list (list (cdr pair)))
          ;; complex expression
          (t
           (calc-push-list
-           (list ((lambda (res)
-                    (cond
-                     ((numberp res) res)
-                     ((math-read-number res) (math-read-number res))
-                     ((listp res) (error "Calc error \"%s\" on input \"%s\""
-                                         (cadr res) line))
-                     (t (replace-regexp-in-string
-                         "'" ""
-                         (calc-eval
-                          (math-evaluate-expr
-                           ;; resolve user variables, calc built in
-                           ;; variables are handled automatically
-                           ;; upstream by calc
-                           (mapcar #'org-babel-calc-maybe-resolve-var
-                                   ;; parse line into calc objects
-                                   (car (math-read-exprs line)))))))))
-                  (calc-eval line))))))))
+           (list (let ((res (calc-eval line)))
+                    (cond
+                     ((numberp res) res)
+                     ((math-read-number res) (math-read-number res))
+                     ((listp res) (error "Calc error \"%s\" on input \"%s\""
+                                         (cadr res) line))
+                     (t (replace-regexp-in-string
+                         "'" ""
+                         (calc-eval
+                          (math-evaluate-expr
+                           ;; resolve user variables, calc built in
+                           ;; variables are handled automatically
+                           ;; upstream by calc
+                           (mapcar #'org-babel-calc-maybe-resolve-var
+                                   ;; parse line into calc objects
+                                   (car (math-read-exprs line)))))))))
+                  ))))))
      (mapcar #'org-babel-trim
             (split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
   (save-excursion
     (with-current-buffer (get-buffer "*Calculator*")
       (calc-eval (calc-top 1)))))
 
-(defvar var-syms) ; Dynamically scoped from org-babel-execute:calc
 (defun org-babel-calc-maybe-resolve-var (el)
   (if (consp el)
-      (if (and (equal 'var (car el)) (member (cadr el) var-syms))
+      (if (and (equal 'var (car el)) (member (cadr el) org--var-syms))
          (progn
            (calc-recall (cadr el))
            (prog1 (calc-top 1)
index b020498eb155fb769a630dd83d26c827b0da1e98..25b39f7f7335bc09fed294583afb2f75cd0a7d7e 100644 (file)
 
 ;;; Commentary:
 
-;;; support for evaluating clojure code, relies on slime for all eval
+;; Support for evaluating clojure code, relies on slime for all eval.
 
 ;;; Requirements:
 
-;;; - clojure (at least 1.2.0)
-;;; - clojure-mode
-;;; - slime
+;; - clojure (at least 1.2.0)
+;; - clojure-mode
+;; - slime
 
-;;; By far, the best way to install these components is by following
-;;; the directions as set out by Phil Hagelberg (Technomancy) on the
-;;; web page: http://technomancy.us/126
+;; By far, the best way to install these components is by following
+;; the directions as set out by Phil Hagelberg (Technomancy) on the
+;; web page: http://technomancy.us/126
 
 ;;; Code:
 (require 'ob)
   (require 'slime)
   (with-temp-buffer
     (insert (org-babel-expand-body:clojure body params))
-    ((lambda (result)
-       (let ((result-params (cdr (assoc :result-params params))))
-        (if (or (member "scalar" result-params)
-                (member "verbatim" result-params))
-            result
-          (condition-case nil (org-babel-script-escape result)
-            (error result)))))
-     (slime-eval
-      `(swank:eval-and-grab-output
-       ,(buffer-substring-no-properties (point-min) (point-max)))
-      (cdr (assoc :package params))))))
+    (let ((result
+           (slime-eval
+            `(swank:eval-and-grab-output
+              ,(buffer-substring-no-properties (point-min) (point-max)))
+            (cdr (assoc :package params)))))
+      (let ((result-params (cdr (assoc :result-params params))))
+        (org-babel-result-cond result-params
+          result
+          (condition-case nil (org-babel-script-escape result)
+            (error result)))))))
 
 (provide 'ob-clojure)
 
index 5ea3be2d5b6daa24c194d41e1edd7f1c8c2ea3c4..8b03e2dcc40017de35cb2a84ea6bf11f68d5e73d 100644 (file)
@@ -30,7 +30,7 @@
 ;; org-babel at large.
 
 ;;; Code:
-(require 'ob)
+(require 'ob-core)
 (require 'org-compat)
 (require 'comint)
 (eval-when-compile (require 'cl))
@@ -117,7 +117,7 @@ or user `keyboard-quit' during execution of body."
                   string-buffer))
             (setq raw (substring string-buffer (match-end 0))))
         (split-string string-buffer comint-prompt-regexp)))))
-(def-edebug-spec org-babel-comint-with-output (form body))
+(def-edebug-spec org-babel-comint-with-output (sexp body))
 
 (defun org-babel-comint-input-command (buffer cmd)
   "Pass CMD to BUFFER.
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
new file mode 100644 (file)
index 0000000..84caed7
--- /dev/null
@@ -0,0 +1,2774 @@
+;;; ob-core.el --- working with code blocks in org-mode
+
+;; Copyright (C) 2009-2013  Free Software Foundation, Inc.
+
+;; Authors: Eric Schulte
+;;     Dan Davison
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+(eval-when-compile
+  (require 'cl))
+(require 'ob-eval)
+(require 'org-macs)
+(require 'org-compat)
+
+(defconst org-babel-exeext
+  (if (memq system-type '(windows-nt cygwin))
+      ".exe"
+    nil))
+;; dynamically scoped for tramp
+(defvar org-babel-call-process-region-original nil)
+(defvar org-src-lang-modes)
+(defvar org-babel-library-of-babel)
+(declare-function show-all "outline" ())
+(declare-function org-reduce "org" (CL-FUNC CL-SEQ &rest CL-KEYS))
+(declare-function org-mark-ring-push "org" (&optional pos buffer))
+(declare-function tramp-compat-make-temp-file "tramp-compat"
+                  (filename &optional dir-flag))
+(declare-function tramp-dissect-file-name "tramp" (name &optional nodefault))
+(declare-function tramp-file-name-user "tramp" (vec))
+(declare-function tramp-file-name-host "tramp" (vec))
+(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
+(declare-function org-icompleting-read "org" (&rest args))
+(declare-function org-edit-src-code "org-src"
+                  (&optional context code edit-buffer-name quietp))
+(declare-function org-edit-src-exit "org-src"  (&optional context))
+(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
+(declare-function org-save-outline-visibility "org-macs" (use-markers &rest body))
+(declare-function org-outline-overlay-data "org" (&optional use-markers))
+(declare-function org-set-outline-overlay-data "org" (data))
+(declare-function org-narrow-to-subtree "org" ())
+(declare-function org-split-string "org" (string &optional separators))
+(declare-function org-entry-get "org"
+                 (pom property &optional inherit literal-nil))
+(declare-function org-make-options-regexp "org" (kwds &optional extra))
+(declare-function org-do-remove-indentation "org" (&optional n))
+(declare-function org-next-block "org" (arg &optional backward block-regexp))
+(declare-function org-previous-block "org" (arg &optional block-regexp))
+(declare-function org-show-context "org" (&optional key))
+(declare-function org-at-table-p "org" (&optional table-type))
+(declare-function org-cycle "org" (&optional arg))
+(declare-function org-uniquify "org" (list))
+(declare-function org-current-level "org" ())
+(declare-function org-table-import "org-table" (file arg))
+(declare-function org-add-hook "org-compat"
+                 (hook function &optional append local))
+(declare-function org-table-align "org-table" ())
+(declare-function org-table-end "org-table" (&optional table-type))
+(declare-function orgtbl-to-generic "org-table" (table params))
+(declare-function orgtbl-to-orgtbl "org-table" (table params))
+(declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info))
+(declare-function org-babel-lob-get-info "ob-lob" nil)
+(declare-function org-babel-ref-split-args "ob-ref" (arg-string))
+(declare-function org-babel-ref-parse "ob-ref" (assignment))
+(declare-function org-babel-ref-resolve "ob-ref" (ref))
+(declare-function org-babel-ref-goto-headline-id "ob-ref" (id))
+(declare-function org-babel-ref-headline-body "ob-ref" ())
+(declare-function org-babel-lob-execute-maybe "ob-lob" ())
+(declare-function org-number-sequence "org-compat" (from &optional to inc))
+(declare-function org-at-item-p "org-list" ())
+(declare-function org-list-parse-list "org-list" (&optional delete))
+(declare-function org-list-to-generic "org-list" (LIST PARAMS))
+(declare-function org-list-struct "org-list" ())
+(declare-function org-list-prevs-alist "org-list" (struct))
+(declare-function org-list-get-list-end "org-list" (item struct prevs))
+(declare-function org-remove-if "org" (predicate seq))
+(declare-function org-completing-read "org" (&rest args))
+(declare-function org-escape-code-in-region "org-src" (beg end))
+(declare-function org-unescape-code-in-string "org-src" (s))
+(declare-function org-table-to-lisp "org-table" (&optional txt))
+(declare-function org-reverse-string "org" (string))
+(declare-function org-element-context "org-element" (&optional ELEMENT))
+
+(defgroup org-babel nil
+  "Code block evaluation and management in `org-mode' documents."
+  :tag "Babel"
+  :group 'org)
+
+(defcustom org-confirm-babel-evaluate t
+  "Confirm before evaluation.
+Require confirmation before interactively evaluating code
+blocks in Org-mode buffers.  The default value of this variable
+is t, meaning confirmation is required for any code block
+evaluation.  This variable can be set to nil to inhibit any
+future confirmation requests.  This variable can also be set to a
+function which takes two arguments the language of the code block
+and the body of the code block.  Such a function should then
+return a non-nil value if the user should be prompted for
+execution or nil if no prompt is required.
+
+Warning: Disabling confirmation may result in accidental
+evaluation of potentially harmful code.  It may be advisable
+remove code block execution from C-c C-c as further protection
+against accidental code block evaluation.  The
+`org-babel-no-eval-on-ctrl-c-ctrl-c' variable can be used to
+remove code block execution from the C-c C-c keybinding."
+  :group 'org-babel
+  :version "24.1"
+  :type '(choice boolean function))
+;; don't allow this variable to be changed through file settings
+(put 'org-confirm-babel-evaluate 'safe-local-variable (lambda (x) (eq x t)))
+
+(defcustom org-babel-no-eval-on-ctrl-c-ctrl-c nil
+  "Remove code block evaluation from the C-c C-c key binding."
+  :group 'org-babel
+  :version "24.1"
+  :type 'boolean)
+
+(defcustom org-babel-results-keyword "RESULTS"
+  "Keyword used to name results generated by code blocks.
+Should be either RESULTS or NAME however any capitalization may
+be used."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-babel-noweb-wrap-start "<<"
+  "String used to begin a noweb reference in a code block.
+See also `org-babel-noweb-wrap-end'."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-noweb-wrap-end ">>"
+  "String used to end a noweb reference in a code block.
+See also `org-babel-noweb-wrap-start'."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-inline-result-wrap "=%s="
+  "Format string used to wrap inline results.
+This string must include a \"%s\" which will be replaced by the results."
+  :group 'org-babel
+  :type 'string)
+
+(defun org-babel-noweb-wrap (&optional regexp)
+  (concat org-babel-noweb-wrap-start
+         (or regexp "\\([^ \t\n].+?[^ \t]\\|[^ \t\n]\\)")
+         org-babel-noweb-wrap-end))
+
+(defvar org-babel-src-name-regexp
+  "^[ \t]*#\\+name:[ \t]*"
+  "Regular expression used to match a source name line.")
+
+(defvar org-babel-multi-line-header-regexp
+  "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
+  "Regular expression used to match multi-line header arguments.")
+
+(defvar org-babel-src-name-w-name-regexp
+  (concat org-babel-src-name-regexp
+         "\\("
+         org-babel-multi-line-header-regexp
+         "\\)*"
+         "\\([^ ()\f\t\n\r\v]+\\)")
+  "Regular expression matching source name lines with a name.")
+
+(defvar org-babel-src-block-regexp
+  (concat
+   ;; (1) indentation                 (2) lang
+   "^\\([ \t]*\\)#\\+begin_src[ \t]+\\([^ \f\t\n\r\v]+\\)[ \t]*"
+   ;; (3) switches
+   "\\([^\":\n]*\"[^\"\n*]*\"[^\":\n]*\\|[^\":\n]*\\)"
+   ;; (4) header arguments
+   "\\([^\n]*\\)\n"
+   ;; (5) body
+   "\\([^\000]*?\n\\)??[ \t]*#\\+end_src")
+  "Regexp used to identify code blocks.")
+
+(defvar org-babel-inline-src-block-regexp
+  (concat
+   ;; (1) replacement target (2) lang
+   "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)"
+   ;; (3,4) (unused, headers)
+   "\\(\\|\\[\\(.*?\\)\\]\\)"
+   ;; (5) body
+   "{\\([^\f\n\r\v]+?\\)}\\)")
+  "Regexp used to identify inline src-blocks.")
+
+(defun org-babel-get-header (params key &optional others)
+  "Select only header argument of type KEY from a list.
+Optional argument OTHERS indicates that only the header that do
+not match KEY should be returned."
+  (delq nil
+       (mapcar
+        (lambda (p) (when (funcall (if others #'not #'identity) (eq (car p) key)) p))
+        params)))
+
+(defun org-babel-get-inline-src-block-matches()
+  "Set match data if within body of an inline source block.
+Returns non-nil if match-data set"
+  (let ((src-at-0-p (save-excursion
+                     (beginning-of-line 1)
+                     (string= "src" (thing-at-point 'word))))
+       (first-line-p (= 1 (line-number-at-pos)))
+       (orig (point)))
+    (let ((search-for (cond ((and src-at-0-p first-line-p  "src_"))
+                           (first-line-p "[[:punct:] \t]src_")
+                           (t "[[:punct:] \f\t\n\r\v]src_")))
+         (lower-limit (if first-line-p
+                          nil
+                        (- (point-at-bol) 1))))
+      (save-excursion
+       (when (or (and src-at-0-p (bobp))
+                 (and (re-search-forward "}" (point-at-eol) t)
+                      (re-search-backward search-for lower-limit t)
+                      (> orig (point))))
+         (when (looking-at org-babel-inline-src-block-regexp)
+           t ))))))
+
+(defvar org-babel-inline-lob-one-liner-regexp)
+(defun org-babel-get-lob-one-liner-matches()
+  "Set match data if on line of an lob one liner.
+Returns non-nil if match-data set"
+  (save-excursion
+    (unless (= (point) (point-at-bol)) ;; move before inline block
+      (re-search-backward "[ \f\t\n\r\v]" nil t))
+    (if (looking-at org-babel-inline-lob-one-liner-regexp)
+       t
+      nil)))
+
+(defun org-babel-get-src-block-info (&optional light)
+  "Get information on the current source block.
+
+Optional argument LIGHT does not resolve remote variable
+references; a process which could likely result in the execution
+of other code blocks.
+
+Returns a list
+ (language body header-arguments-alist switches name indent block-head)."
+  (let ((case-fold-search t) head info name indent)
+    ;; full code block
+    (if (setq head (org-babel-where-is-src-block-head))
+       (save-excursion
+         (goto-char head)
+         (setq info (org-babel-parse-src-block-match))
+         (setq indent (car (last info)))
+         (setq info (butlast info))
+         (while (and (forward-line -1)
+                     (looking-at org-babel-multi-line-header-regexp))
+           (setf (nth 2 info)
+                 (org-babel-merge-params
+                  (nth 2 info)
+                  (org-babel-parse-header-arguments (match-string 1)))))
+         (when (looking-at org-babel-src-name-w-name-regexp)
+           (setq name (org-no-properties (match-string 3)))))
+      ;; inline source block
+      (when (org-babel-get-inline-src-block-matches)
+       (setq info (org-babel-parse-inline-src-block-match))))
+    ;; resolve variable references and add summary parameters
+    (when (and info (not light))
+      (setf (nth 2 info) (org-babel-process-params (nth 2 info))))
+    (when info (append info (list name indent head)))))
+
+(defvar org-current-export-file) ; dynamically bound
+(defmacro org-babel-check-confirm-evaluate (info &rest body)
+  "Evaluate BODY with special execution confirmation variables set.
+
+Specifically; NOEVAL will indicate if evaluation is allowed,
+QUERY will indicate if a user query is required, CODE-BLOCK will
+hold the language of the code block, and BLOCK-NAME will hold the
+name of the code block."
+  (declare (indent defun))
+  (org-with-gensyms
+      (lang block-body headers name eval eval-no export eval-no-export)
+    `(let* ((,lang           (nth 0 ,info))
+           (,block-body     (nth 1 ,info))
+           (,headers        (nth 2 ,info))
+           (,name           (nth 4 ,info))
+           (,eval           (or (cdr  (assoc :eval   ,headers))
+                                (when (assoc :noeval ,headers) "no")))
+           (,eval-no        (or (equal ,eval "no")
+                                (equal ,eval "never")))
+           (,export         (org-bound-and-true-p org-current-export-file))
+           (,eval-no-export (and ,export (or (equal ,eval "no-export")
+                                             (equal ,eval "never-export"))))
+           (noeval          (or ,eval-no ,eval-no-export))
+           (query           (or (equal ,eval "query")
+                                (and ,export (equal ,eval "query-export"))
+                                (if (functionp org-confirm-babel-evaluate)
+                                    (funcall org-confirm-babel-evaluate
+                                             ,lang ,block-body)
+                                  org-confirm-babel-evaluate)))
+           (code-block      (if ,info (format  " %s "  ,lang) " "))
+           (block-name      (if ,name (format " (%s) " ,name) " ")))
+       ,@body)))
+
+(defsubst org-babel-check-evaluate (info)
+  "Check if code block INFO should be evaluated.
+Do not query the user."
+  (org-babel-check-confirm-evaluate info
+    (not (when noeval
+          (message (format "Evaluation of this%scode-block%sis disabled."
+                           code-block block-name))))))
+
+ ;; dynamically scoped for asynchronous export
+(defvar org-babel-confirm-evaluate-answer-no)
+
+(defsubst org-babel-confirm-evaluate (info)
+  "Confirm evaluation of the code block INFO.
+
+If the variable `org-babel-confirm-evaluate-answer-no' is bound
+to a non-nil value, auto-answer with \"no\".
+
+This query can also be suppressed by setting the value of
+`org-confirm-babel-evaluate' to nil, in which case all future
+interactive code block evaluations will proceed without any
+confirmation from the user.
+
+Note disabling confirmation may result in accidental evaluation
+of potentially harmful code."
+  (org-babel-check-confirm-evaluate info
+    (not (when query
+          (unless
+              (and (not (org-bound-and-true-p
+                         org-babel-confirm-evaluate-answer-no))
+                   (yes-or-no-p
+                    (format "Evaluate this%scode block%son your system? "
+                            code-block block-name)))
+            (message (format "Evaluation of this%scode-block%sis aborted."
+                             code-block block-name)))))))
+
+;;;###autoload
+(defun org-babel-execute-safely-maybe ()
+  (unless org-babel-no-eval-on-ctrl-c-ctrl-c
+    (org-babel-execute-maybe)))
+
+(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-safely-maybe)
+
+;;;###autoload
+(defun org-babel-execute-maybe ()
+  (interactive)
+  (or (org-babel-execute-src-block-maybe)
+      (org-babel-lob-execute-maybe)))
+
+(defmacro org-babel-when-in-src-block (&rest body)
+  "Execute BODY if point is in a source block and return t.
+
+Otherwise do nothing and return nil."
+  `(if (or (org-babel-where-is-src-block-head)
+           (org-babel-get-inline-src-block-matches))
+       (progn
+        ,@body
+        t)
+     nil))
+
+(defun org-babel-execute-src-block-maybe ()
+  "Conditionally execute a source block.
+Detect if this is context for a Babel src-block and if so
+then run `org-babel-execute-src-block'."
+  (interactive)
+  (org-babel-when-in-src-block
+   (org-babel-eval-wipe-error-buffer)
+   (org-babel-execute-src-block current-prefix-arg)))
+
+;;;###autoload
+(defun org-babel-view-src-block-info ()
+  "Display information on the current source block.
+This includes header arguments, language and name, and is largely
+a window into the `org-babel-get-src-block-info' function."
+  (interactive)
+  (let ((info (org-babel-get-src-block-info 'light))
+       (full (lambda (it) (> (length it) 0)))
+       (printf (lambda (fmt &rest args) (princ (apply #'format fmt args)))))
+    (when info
+      (with-help-window (help-buffer)
+       (let ((name        (nth 4 info))
+             (lang        (nth 0 info))
+             (switches    (nth 3 info))
+             (header-args (nth 2 info)))
+         (when name            (funcall printf "Name: %s\n"     name))
+         (when lang            (funcall printf "Lang: %s\n"     lang))
+         (when (funcall full switches) (funcall printf "Switches: %s\n" switches))
+         (funcall printf "Header Arguments:\n")
+         (dolist (pair (sort header-args
+                             (lambda (a b) (string< (symbol-name (car a))
+                                                    (symbol-name (car b))))))
+           (when (funcall full (cdr pair))
+             (funcall printf "\t%S%s\t%s\n"
+                      (car pair)
+                      (if (> (length (format "%S" (car pair))) 7) "" "\t")
+                      (cdr pair)))))))))
+
+;;;###autoload
+(defun org-babel-expand-src-block-maybe ()
+  "Conditionally expand a source block.
+Detect if this is context for a org-babel src-block and if so
+then run `org-babel-expand-src-block'."
+  (interactive)
+  (org-babel-when-in-src-block
+   (org-babel-expand-src-block current-prefix-arg)))
+
+;;;###autoload
+(defun org-babel-load-in-session-maybe ()
+  "Conditionally load a source block in a session.
+Detect if this is context for a org-babel src-block and if so
+then run `org-babel-load-in-session'."
+  (interactive)
+  (org-babel-when-in-src-block
+   (org-babel-load-in-session current-prefix-arg)))
+
+(add-hook 'org-metaup-hook 'org-babel-load-in-session-maybe)
+
+;;;###autoload
+(defun org-babel-pop-to-session-maybe ()
+  "Conditionally pop to a session.
+Detect if this is context for a org-babel src-block and if so
+then run `org-babel-switch-to-session'."
+  (interactive)
+  (org-babel-when-in-src-block
+   (org-babel-switch-to-session current-prefix-arg)))
+
+(add-hook 'org-metadown-hook 'org-babel-pop-to-session-maybe)
+
+(defconst org-babel-common-header-args-w-values
+  '((cache     . ((no yes)))
+    (cmdline   . :any)
+    (colnames  . ((nil no yes)))
+    (comments  . ((no link yes org both noweb)))
+    (dir       . :any)
+    (eval      . ((never query)))
+    (exports   . ((code results both none)))
+    (epilogue   . :any)
+    (file      . :any)
+    (file-desc  . :any)
+    (hlines    . ((no yes)))
+    (mkdirp    . ((yes no)))
+    (no-expand)
+    (noeval)
+    (noweb     . ((yes no tangle no-export strip-export)))
+    (noweb-ref . :any)
+    (noweb-sep  . :any)
+    (padline   . ((yes no)))
+    (post       . :any)
+    (prologue   . :any)
+    (results   . ((file list vector table scalar verbatim)
+                  (raw html latex org code pp drawer)
+                  (replace silent none append prepend)
+                  (output value)))
+    (rownames  . ((no yes)))
+    (sep       . :any)
+    (session   . :any)
+    (shebang   . :any)
+    (tangle    . ((tangle yes no :any)))
+    (tangle-mode . ((#o755 #o555 #o444 :any)))
+    (var       . :any)
+    (wrap       . :any)))
+
+(defconst org-babel-header-arg-names
+  (mapcar #'car org-babel-common-header-args-w-values)
+  "Common header arguments used by org-babel.
+Note that individual languages may define their own language
+specific header arguments as well.")
+
+(defvar org-babel-default-header-args
+  '((:session . "none") (:results . "replace") (:exports . "code")
+    (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no"))
+  "Default arguments to use when evaluating a source block.")
+
+(defvar org-babel-default-inline-header-args
+  '((:session . "none") (:results . "replace") (:exports . "results"))
+  "Default arguments to use when evaluating an inline source block.")
+
+(defvar org-babel-data-names '("tblname" "results" "name"))
+
+(defvar org-babel-result-regexp
+  (concat "^[ \t]*#\\+"
+         (regexp-opt org-babel-data-names t)
+         "\\(\\[\\("
+         ;; FIXME The string below is `org-ts-regexp'
+         "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)>"
+         " \\)?\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*")
+  "Regular expression used to match result lines.
+If the results are associated with a hash key then the hash will
+be saved in the second match data.")
+
+(defvar org-babel-result-w-name-regexp
+  (concat org-babel-result-regexp
+         "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)"))
+
+(defvar org-babel-min-lines-for-block-output 10
+  "The minimum number of lines for block output.
+If number of lines of output is equal to or exceeds this
+value, the output is placed in a #+begin_example...#+end_example
+block.  Otherwise the output is marked as literal by inserting
+colons at the starts of the lines.  This variable only takes
+effect if the :results output option is in effect.")
+
+(defvar org-babel-noweb-error-langs nil
+  "Languages for which Babel will raise literate programming errors.
+List of languages for which errors should be raised when the
+source code block satisfying a noweb reference in this language
+can not be resolved.")
+
+(defvar org-babel-hash-show 4
+  "Number of initial characters to show of a hidden results hash.")
+
+(defvar org-babel-hash-show-time nil
+  "Non-nil means show the time the code block was evaluated in the result hash.")
+
+(defvar org-babel-after-execute-hook nil
+  "Hook for functions to be called after `org-babel-execute-src-block'")
+
+(defun org-babel-named-src-block-regexp-for-name (name)
+  "This generates a regexp used to match a src block named NAME."
+  (concat org-babel-src-name-regexp (regexp-quote name)
+         "[ \t(]*[\r\n]\\(?:^#.*[\r\n]\\)*"
+         (substring org-babel-src-block-regexp 1)))
+
+(defun org-babel-named-data-regexp-for-name (name)
+  "This generates a regexp used to match data named NAME."
+  (concat org-babel-result-regexp (regexp-quote name) "\\([ \t]\\|$\\)"))
+
+;;; functions
+(defvar call-process-region)
+(defvar org-babel-current-src-block-location nil
+  "Marker pointing to the src block currently being executed.
+This may also point to a call line or an inline code block.  If
+multiple blocks are being executed (e.g., in chained execution
+through use of the :var header argument) this marker points to
+the outer-most code block.")
+
+;;;###autoload
+(defun org-babel-execute-src-block (&optional arg info params)
+  "Execute the current source code block.
+Insert the results of execution into the buffer.  Source code
+execution and the collection and formatting of results can be
+controlled through a variety of header arguments.
+
+With prefix argument ARG, force re-execution even if an existing
+result cached in the buffer would otherwise have been returned.
+
+Optionally supply a value for INFO in the form returned by
+`org-babel-get-src-block-info'.
+
+Optionally supply a value for PARAMS which will be merged with
+the header arguments specified at the front of the source code
+block."
+  (interactive)
+  (let* ((org-babel-current-src-block-location
+         (or org-babel-current-src-block-location
+             (nth 6 info)
+             (org-babel-where-is-src-block-head)))
+        (info (if info
+                  (copy-tree info)
+                (org-babel-get-src-block-info)))
+        (merged-params (org-babel-merge-params (nth 2 info) params)))
+    (when (org-babel-check-evaluate
+          (let ((i info)) (setf (nth 2 i) merged-params) i))
+      (let* ((params (if params
+                        (org-babel-process-params merged-params)
+                      (nth 2 info)))
+            (cachep (and (not arg) (cdr (assoc :cache params))
+                          (string= "yes" (cdr (assoc :cache params)))))
+            (new-hash (when cachep (org-babel-sha1-hash info)))
+            (old-hash (when cachep (org-babel-current-result-hash)))
+            (cache-current-p (and (not arg) new-hash
+                                  (equal new-hash old-hash))))
+       (cond
+        (cache-current-p
+         (save-excursion ;; return cached result
+           (goto-char (org-babel-where-is-src-block-result nil info))
+           (end-of-line 1) (forward-char 1)
+           (let ((result (org-babel-read-result)))
+             (message (replace-regexp-in-string
+                       "%" "%%" (format "%S" result))) result)))
+        ((org-babel-confirm-evaluate
+          (let ((i info)) (setf (nth 2 i) merged-params) i))
+         (let* ((lang (nth 0 info))
+                (result-params (cdr (assoc :result-params params)))
+                (body (setf (nth 1 info)
+                            (if (org-babel-noweb-p params :eval)
+                                (org-babel-expand-noweb-references info)
+                              (nth 1 info))))
+                (dir (cdr (assoc :dir params)))
+                (default-directory
+                  (or (and dir (file-name-as-directory (expand-file-name dir)))
+                      default-directory))
+                (org-babel-call-process-region-original ;; for tramp handler
+                 (or (org-bound-and-true-p
+                      org-babel-call-process-region-original)
+                     (symbol-function 'call-process-region)))
+                (indent (nth 5 info))
+                result cmd)
+           (unwind-protect
+               (let ((call-process-region
+                      (lambda (&rest args)
+                        (apply 'org-babel-tramp-handle-call-process-region
+                               args))))
+                 (let ((lang-check
+                        (lambda (f)
+                          (let ((f (intern (concat "org-babel-execute:" f))))
+                            (when (fboundp f) f)))))
+                   (setq cmd
+                         (or (funcall lang-check lang)
+                             (funcall lang-check
+                                      (symbol-name
+                                       (cdr (assoc lang org-src-lang-modes))))
+                             (error "No org-babel-execute function for %s!"
+                                    lang))))
+                 (message "executing %s code block%s..."
+                          (capitalize lang)
+                          (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
+                 (if (member "none" result-params)
+                     (progn
+                       (funcall cmd body params)
+                       (message "result silenced")
+                       (setq result nil))
+                   (setq result
+                         (let ((result (funcall cmd body params)))
+                            (if (and (eq (cdr (assoc :result-type params))
+                                         'value)
+                                     (or (member "vector" result-params)
+                                         (member "table" result-params))
+                                     (not (listp result)))
+                                (list (list result)) result)))
+                   ;; If non-empty result and :file then write to :file.
+                   (when (cdr (assoc :file params))
+                     (when result
+                       (with-temp-file (cdr (assoc :file params))
+                         (insert
+                          (org-babel-format-result
+                           result (cdr (assoc :sep (nth 2 info)))))))
+                     (setq result (cdr (assoc :file params))))
+                   ;; Possibly perform post process provided its appropriate.
+                   (when (cdr (assoc :post params))
+                     (let ((*this* (if (cdr (assoc :file params))
+                                       (org-babel-result-to-file
+                                        (cdr (assoc :file params))
+                                        (when (assoc :file-desc params)
+                                          (or (cdr (assoc :file-desc params))
+                                              result)))
+                                     result)))
+                       (setq result (org-babel-ref-resolve
+                                     (cdr (assoc :post params))))
+                       (when (cdr (assoc :file params))
+                         (setq result-params
+                               (remove "file" result-params)))))
+                   (org-babel-insert-result
+                    result result-params info new-hash indent lang))
+                  (run-hooks 'org-babel-after-execute-hook)
+                 result)
+             (setq call-process-region
+                   'org-babel-call-process-region-original)))))))))
+
+(defun org-babel-expand-body:generic (body params &optional var-lines)
+  "Expand BODY with PARAMS.
+Expand a block of code with org-babel according to its header
+arguments.  This generic implementation of body expansion is
+called for languages which have not defined their own specific
+org-babel-expand-body:lang function."
+  (let ((pro (cdr (assoc :prologue params)))
+       (epi (cdr (assoc :epilogue params))))
+    (mapconcat #'identity
+              (append (when pro (list pro))
+                      var-lines
+                      (list body)
+                      (when epi (list epi)))
+              "\n")))
+
+;;;###autoload
+(defun org-babel-expand-src-block (&optional arg info params)
+  "Expand the current source code block.
+Expand according to the source code block's header
+arguments and pop open the results in a preview buffer."
+  (interactive)
+  (let* ((info (or info (org-babel-get-src-block-info)))
+         (lang (nth 0 info))
+        (params (setf (nth 2 info)
+                       (sort (org-babel-merge-params (nth 2 info) params)
+                             (lambda (el1 el2) (string< (symbol-name (car el1))
+                                                       (symbol-name (car el2)))))))
+         (body (setf (nth 1 info)
+                    (if (org-babel-noweb-p params :eval)
+                        (org-babel-expand-noweb-references info) (nth 1 info))))
+         (expand-cmd (intern (concat "org-babel-expand-body:" lang)))
+        (assignments-cmd (intern (concat "org-babel-variable-assignments:"
+                                         lang)))
+         (expanded
+         (if (fboundp expand-cmd) (funcall expand-cmd body params)
+           (org-babel-expand-body:generic
+            body params (and (fboundp assignments-cmd)
+                             (funcall assignments-cmd params))))))
+    (if (org-called-interactively-p 'any)
+       (org-edit-src-code
+        nil expanded
+        (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*"))
+      expanded)))
+
+(defun org-babel-edit-distance (s1 s2)
+  "Return the edit (levenshtein) distance between strings S1 S2."
+  (let* ((l1 (length s1))
+        (l2 (length s2))
+        (dist (vconcat (mapcar (lambda (_) (make-vector (1+ l2) nil))
+                               (number-sequence 1 (1+ l1)))))
+        (in (lambda (i j) (aref (aref dist i) j))))
+    (setf (aref (aref dist 0) 0) 0)
+    (dolist (j (number-sequence 1 l2))
+      (setf (aref (aref dist 0) j) j))
+    (dolist (i (number-sequence 1 l1))
+      (setf (aref (aref dist i) 0) i)
+      (dolist (j (number-sequence 1 l2))
+       (setf (aref (aref dist i) j)
+             (min
+              (1+ (funcall in (1- i) j))
+              (1+ (funcall in i (1- j)))
+              (+ (if (equal (aref s1 (1- i)) (aref s2 (1- j))) 0 1)
+                 (funcall in (1- i) (1- j)))))))
+    (funcall in l1 l2)))
+
+(defun org-babel-combine-header-arg-lists (original &rest others)
+  "Combine a number of lists of header argument names and arguments."
+  (let ((results (copy-sequence original)))
+    (dolist (new-list others)
+      (dolist (arg-pair new-list)
+       (let ((header (car arg-pair))
+             (args (cdr arg-pair)))
+         (setq results
+               (cons arg-pair (org-remove-if
+                               (lambda (pair) (equal header (car pair)))
+                               results))))))
+    results))
+
+;;;###autoload
+(defun org-babel-check-src-block ()
+  "Check for misspelled header arguments in the current code block."
+  (interactive)
+  ;; TODO: report malformed code block
+  ;; TODO: report incompatible combinations of header arguments
+  ;; TODO: report uninitialized variables
+  (let ((too-close 2) ;; <- control closeness to report potential match
+       (names (mapcar #'symbol-name org-babel-header-arg-names)))
+    (dolist (header (mapcar (lambda (arg) (substring (symbol-name (car arg)) 1))
+                           (and (org-babel-where-is-src-block-head)
+                                (org-babel-parse-header-arguments
+                                 (org-no-properties
+                                  (match-string 4))))))
+      (dolist (name names)
+       (when (and (not (string= header name))
+                  (<= (org-babel-edit-distance header name) too-close)
+                  (not (member header names)))
+         (error "Supplied header \"%S\" is suspiciously close to \"%S\""
+                header name))))
+    (message "No suspicious header arguments found.")))
+
+;;;###autoload
+(defun org-babel-insert-header-arg ()
+  "Insert a header argument selecting from lists of common args and values."
+  (interactive)
+  (let* ((lang (car (org-babel-get-src-block-info 'light)))
+        (lang-headers (intern (concat "org-babel-header-args:" lang)))
+        (headers (org-babel-combine-header-arg-lists
+                  org-babel-common-header-args-w-values
+                  (when (boundp lang-headers) (eval lang-headers))))
+        (arg (org-icompleting-read
+              "Header Arg: "
+              (mapcar
+               (lambda (header-spec) (symbol-name (car header-spec)))
+               headers))))
+    (insert ":" arg)
+    (let ((vals (cdr (assoc (intern arg) headers))))
+      (when vals
+       (insert
+        " "
+        (cond
+         ((eq vals :any)
+          (read-from-minibuffer "value: "))
+         ((listp vals)
+          (mapconcat
+           (lambda (group)
+             (let ((arg (org-icompleting-read
+                         "value: "
+                         (cons "default" (mapcar #'symbol-name group)))))
+               (if (and arg (not (string= "default" arg)))
+                   (concat arg " ")
+                 "")))
+           vals ""))))))))
+
+;; Add support for completing-read insertion of header arguments after ":"
+(defun org-babel-header-arg-expand ()
+  "Call `org-babel-enter-header-arg-w-completion' in appropriate contexts."
+  (when (and (equal (char-before) ?\:) (org-babel-where-is-src-block-head))
+    (org-babel-enter-header-arg-w-completion (match-string 2))))
+
+(defun org-babel-enter-header-arg-w-completion (&optional lang)
+  "Insert header argument appropriate for LANG with completion."
+  (let* ((lang-headers-var (intern (concat "org-babel-header-args:" lang)))
+         (lang-headers (when (boundp lang-headers-var) (eval lang-headers-var)))
+        (headers-w-values (org-babel-combine-header-arg-lists
+                           org-babel-common-header-args-w-values lang-headers))
+         (headers (mapcar #'symbol-name (mapcar #'car headers-w-values)))
+         (header (org-completing-read "Header Arg: " headers))
+         (args (cdr (assoc (intern header) headers-w-values)))
+         (arg (when (and args (listp args))
+                (org-completing-read
+                 (format "%s: " header)
+                 (mapcar #'symbol-name (apply #'append args))))))
+    (insert (concat header " " (or arg "")))
+    (cons header arg)))
+
+(add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)
+
+;;;###autoload
+(defun org-babel-load-in-session (&optional arg info)
+  "Load the body of the current source-code block.
+Evaluate the header arguments for the source block before
+entering the session.  After loading the body this pops open the
+session."
+  (interactive)
+  (let* ((info (or info (org-babel-get-src-block-info)))
+         (lang (nth 0 info))
+         (params (nth 2 info))
+         (body (if (not info)
+                  (user-error "No src code block at point")
+                (setf (nth 1 info)
+                      (if (org-babel-noweb-p params :eval)
+                          (org-babel-expand-noweb-references info)
+                        (nth 1 info)))))
+         (session (cdr (assoc :session params)))
+        (dir (cdr (assoc :dir params)))
+        (default-directory
+          (or (and dir (file-name-as-directory dir)) default-directory))
+        (cmd (intern (concat "org-babel-load-session:" lang))))
+    (unless (fboundp cmd)
+      (error "No org-babel-load-session function for %s!" lang))
+    (pop-to-buffer (funcall cmd session body params))
+    (end-of-line 1)))
+
+;;;###autoload
+(defun org-babel-initiate-session (&optional arg info)
+  "Initiate session for current code block.
+If called with a prefix argument then resolve any variable
+references in the header arguments and assign these variables in
+the session.  Copy the body of the code block to the kill ring."
+  (interactive "P")
+  (let* ((info (or info (org-babel-get-src-block-info (not arg))))
+         (lang (nth 0 info))
+         (body (nth 1 info))
+         (params (nth 2 info))
+         (session (cdr (assoc :session params)))
+        (dir (cdr (assoc :dir params)))
+        (default-directory
+          (or (and dir (file-name-as-directory dir)) default-directory))
+        (init-cmd (intern (format "org-babel-%s-initiate-session" lang)))
+        (prep-cmd (intern (concat "org-babel-prep-session:" lang))))
+    (if (and (stringp session) (string= session "none"))
+       (error "This block is not using a session!"))
+    (unless (fboundp init-cmd)
+      (error "No org-babel-initiate-session function for %s!" lang))
+    (with-temp-buffer (insert (org-babel-trim body))
+                      (copy-region-as-kill (point-min) (point-max)))
+    (when arg
+      (unless (fboundp prep-cmd)
+       (error "No org-babel-prep-session function for %s!" lang))
+      (funcall prep-cmd session params))
+    (funcall init-cmd session params)))
+
+;;;###autoload
+(defun org-babel-switch-to-session (&optional arg info)
+  "Switch to the session of the current code block.
+Uses `org-babel-initiate-session' to start the session.  If called
+with a prefix argument then this is passed on to
+`org-babel-initiate-session'."
+  (interactive "P")
+  (pop-to-buffer (org-babel-initiate-session arg info))
+  (end-of-line 1))
+
+(defalias 'org-babel-pop-to-session 'org-babel-switch-to-session)
+
+(defvar org-src-window-setup)
+
+;;;###autoload
+(defun org-babel-switch-to-session-with-code (&optional arg info)
+  "Switch to code buffer and display session."
+  (interactive "P")
+  (let ((swap-windows
+        (lambda ()
+          (let ((other-window-buffer (window-buffer (next-window))))
+            (set-window-buffer (next-window) (current-buffer))
+            (set-window-buffer (selected-window) other-window-buffer))
+          (other-window 1)))
+       (info (org-babel-get-src-block-info))
+       (org-src-window-setup 'reorganize-frame))
+    (save-excursion
+      (org-babel-switch-to-session arg info))
+    (org-edit-src-code)
+    (funcall swap-windows)))
+
+(defmacro org-babel-do-in-edit-buffer (&rest body)
+  "Evaluate BODY in edit buffer if there is a code block at point.
+Return t if a code block was found at point, nil otherwise."
+  `(let ((org-src-window-setup 'switch-invisibly))
+     (when (and (org-babel-where-is-src-block-head)
+               (org-edit-src-code nil nil nil))
+       (unwind-protect (progn ,@body)
+        (if (org-bound-and-true-p org-edit-src-from-org-mode)
+            (org-edit-src-exit)))
+       t)))
+(def-edebug-spec org-babel-do-in-edit-buffer (body))
+
+(defun org-babel-do-key-sequence-in-edit-buffer (key)
+  "Read key sequence and execute the command in edit buffer.
+Enter a key sequence to be executed in the language major-mode
+edit buffer.  For example, TAB will alter the contents of the
+Org-mode code block according to the effect of TAB in the
+language major-mode buffer.  For languages that support
+interactive sessions, this can be used to send code from the Org
+buffer to the session for evaluation using the native major-mode
+evaluation mechanisms."
+  (interactive "kEnter key-sequence to execute in edit buffer: ")
+  (org-babel-do-in-edit-buffer
+   (call-interactively
+    (key-binding (or key (read-key-sequence nil))))))
+
+(defvar org-bracket-link-regexp)
+
+(defun org-babel-active-location-p ()
+  (memq (car (save-match-data (org-element-context)))
+       '(babel-call inline-babel-call inline-src-block src-block)))
+
+;;;###autoload
+(defun org-babel-open-src-block-result (&optional re-run)
+  "If `point' is on a src block then open the results of the
+source code block, otherwise return nil.  With optional prefix
+argument RE-RUN the source-code block is evaluated even if
+results already exist."
+  (interactive "P")
+  (let ((info (org-babel-get-src-block-info 'light)))
+    (when info
+      (save-excursion
+       ;; go to the results, if there aren't any then run the block
+       (goto-char (or (and (not re-run) (org-babel-where-is-src-block-result))
+                      (progn (org-babel-execute-src-block)
+                             (org-babel-where-is-src-block-result))))
+       (end-of-line 1)
+       (while (looking-at "[\n\r\t\f ]") (forward-char 1))
+       ;; open the results
+       (if (looking-at org-bracket-link-regexp)
+           ;; file results
+           (org-open-at-point)
+         (let ((r (org-babel-format-result
+                   (org-babel-read-result) (cdr (assoc :sep (nth 2 info))))))
+           (pop-to-buffer (get-buffer-create "*Org-Babel Results*"))
+           (delete-region (point-min) (point-max))
+           (insert r)))
+       t))))
+
+;;;###autoload
+(defmacro org-babel-map-src-blocks (file &rest body)
+  "Evaluate BODY forms on each source-block in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer.  During evaluation of BODY the following local variables
+are set relative to the currently matched code block.
+
+full-block ------- string holding the entirety of the code block
+beg-block -------- point at the beginning of the code block
+end-block -------- point at the end of the matched code block
+lang ------------- string holding the language of the code block
+beg-lang --------- point at the beginning of the lang
+end-lang --------- point at the end of the lang
+switches --------- string holding the switches
+beg-switches ----- point at the beginning of the switches
+end-switches ----- point at the end of the switches
+header-args ------ string holding the header-args
+beg-header-args -- point at the beginning of the header-args
+end-header-args -- point at the end of the header-args
+body ------------- string holding the body of the code block
+beg-body --------- point at the beginning of the body
+end-body --------- point at the end of the body"
+  (declare (indent 1))
+  (let ((tempvar (make-symbol "file")))
+    `(let* ((,tempvar ,file)
+           (visited-p (or (null ,tempvar)
+                          (get-file-buffer (expand-file-name ,tempvar))))
+           (point (point)) to-be-removed)
+       (save-window-excursion
+        (when ,tempvar (find-file ,tempvar))
+        (setq to-be-removed (current-buffer))
+        (goto-char (point-min))
+        (while (re-search-forward org-babel-src-block-regexp nil t)
+          (when (org-babel-active-location-p)
+            (goto-char (match-beginning 0))
+            (let ((full-block (match-string 0))
+                  (beg-block (match-beginning 0))
+                  (end-block (match-end 0))
+                  (lang (match-string 2))
+                  (beg-lang (match-beginning 2))
+                  (end-lang (match-end 2))
+                  (switches (match-string 3))
+                  (beg-switches (match-beginning 3))
+                  (end-switches (match-end 3))
+                  (header-args (match-string 4))
+                  (beg-header-args (match-beginning 4))
+                  (end-header-args (match-end 4))
+                  (body (match-string 5))
+                  (beg-body (match-beginning 5))
+                  (end-body (match-end 5)))
+              ,@body
+              (goto-char end-block)))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+(def-edebug-spec org-babel-map-src-blocks (form body))
+
+;;;###autoload
+(defmacro org-babel-map-inline-src-blocks (file &rest body)
+  "Evaluate BODY forms on each inline source-block in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer."
+  (declare (indent 1))
+  (let ((tempvar (make-symbol "file")))
+    `(let* ((,tempvar ,file)
+           (visited-p (or (null ,tempvar)
+                          (get-file-buffer (expand-file-name ,tempvar))))
+           (point (point)) to-be-removed)
+       (save-window-excursion
+        (when ,tempvar (find-file ,tempvar))
+        (setq to-be-removed (current-buffer))
+        (goto-char (point-min))
+        (while (re-search-forward org-babel-inline-src-block-regexp nil t)
+          (when (org-babel-active-location-p)
+            (goto-char (match-beginning 1))
+            (save-match-data ,@body))
+          (goto-char (match-end 0))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+(def-edebug-spec org-babel-map-inline-src-blocks (form body))
+
+(defvar org-babel-lob-one-liner-regexp)
+
+;;;###autoload
+(defmacro org-babel-map-call-lines (file &rest body)
+  "Evaluate BODY forms on each call line in FILE.
+If FILE is nil evaluate BODY forms on source blocks in current
+buffer."
+  (declare (indent 1))
+  (let ((tempvar (make-symbol "file")))
+    `(let* ((,tempvar ,file)
+           (visited-p (or (null ,tempvar)
+                          (get-file-buffer (expand-file-name ,tempvar))))
+           (point (point)) to-be-removed)
+       (save-window-excursion
+        (when ,tempvar (find-file ,tempvar))
+        (setq to-be-removed (current-buffer))
+        (goto-char (point-min))
+        (while (re-search-forward org-babel-lob-one-liner-regexp nil t)
+          (when (org-babel-active-location-p)
+            (goto-char (match-beginning 1))
+            (save-match-data ,@body))
+          (goto-char (match-end 0))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+(def-edebug-spec org-babel-map-call-lines (form body))
+
+;;;###autoload
+(defmacro org-babel-map-executables (file &rest body)
+  (declare (indent 1))
+  (let ((tempvar (make-symbol "file"))
+       (rx (make-symbol "rx")))
+    `(let* ((,tempvar ,file)
+           (,rx (concat "\\(" org-babel-src-block-regexp
+                        "\\|" org-babel-inline-src-block-regexp
+                        "\\|" org-babel-lob-one-liner-regexp "\\)"))
+           (visited-p (or (null ,tempvar)
+                          (get-file-buffer (expand-file-name ,tempvar))))
+           (point (point)) to-be-removed)
+       (save-window-excursion
+        (when ,tempvar (find-file ,tempvar))
+        (setq to-be-removed (current-buffer))
+        (goto-char (point-min))
+        (while (re-search-forward ,rx nil t)
+          (when (org-babel-active-location-p)
+            (goto-char (match-beginning 1))
+            (when (looking-at org-babel-inline-src-block-regexp)
+              (forward-char 1))
+            (save-match-data ,@body))
+          (goto-char (match-end 0))))
+       (unless visited-p (kill-buffer to-be-removed))
+       (goto-char point))))
+(def-edebug-spec org-babel-map-executables (form body))
+
+;;;###autoload
+(defun org-babel-execute-buffer (&optional arg)
+  "Execute source code blocks in a buffer.
+Call `org-babel-execute-src-block' on every source block in
+the current buffer."
+  (interactive "P")
+  (org-babel-eval-wipe-error-buffer)
+  (org-save-outline-visibility t
+    (org-babel-map-executables nil
+      (if (looking-at org-babel-lob-one-liner-regexp)
+          (org-babel-lob-execute-maybe)
+        (org-babel-execute-src-block arg)))))
+
+;;;###autoload
+(defun org-babel-execute-subtree (&optional arg)
+  "Execute source code blocks in a subtree.
+Call `org-babel-execute-src-block' on every source block in
+the current subtree."
+  (interactive "P")
+  (save-restriction
+    (save-excursion
+      (org-narrow-to-subtree)
+      (org-babel-execute-buffer arg)
+      (widen))))
+
+;;;###autoload
+(defun org-babel-sha1-hash (&optional info)
+  "Generate an sha1 hash based on the value of info."
+  (interactive)
+  (let ((print-level nil)
+       (info (or info (org-babel-get-src-block-info))))
+    (setf (nth 2 info)
+         (sort (copy-sequence (nth 2 info))
+               (lambda (a b) (string< (car a) (car b)))))
+    (let* ((rm (lambda (lst)
+                (dolist (p '("replace" "silent" "none"
+                             "append" "prepend"))
+                  (setq lst (remove p lst)))
+                lst))
+          (norm (lambda (arg)
+                  (let ((v (if (and (listp (cdr arg)) (null (cddr arg)))
+                               (copy-sequence (cdr arg))
+                             (cdr arg))))
+                    (when (and v (not (and (sequencep v)
+                                           (not (consp v))
+                                           (= (length v) 0))))
+                      (cond
+                       ((and (listp v) ; lists are sorted
+                             (member (car arg) '(:result-params)))
+                        (sort (funcall rm v) #'string<))
+                       ((and (stringp v) ; strings are sorted
+                             (member (car arg) '(:results :exports)))
+                        (mapconcat #'identity (sort (funcall rm (split-string v))
+                                                    #'string<) " "))
+                       (t v)))))))
+      (let* ((it (format "%s-%s"
+                         (mapconcat
+                          #'identity
+                          (delq nil (mapcar (lambda (arg)
+                                              (let ((normalized (funcall norm arg)))
+                                                (when normalized
+                                                  (format "%S" normalized))))
+                                            (nth 2 info))) ":")
+                         (nth 1 info)))
+             (hash (sha1 it)))
+        (when (org-called-interactively-p 'interactive) (message hash))
+        hash))))
+
+(defun org-babel-current-result-hash ()
+  "Return the current in-buffer hash."
+  (org-babel-where-is-src-block-result)
+  (org-no-properties (match-string 5)))
+
+(defun org-babel-set-current-result-hash (hash)
+  "Set the current in-buffer hash to HASH."
+  (org-babel-where-is-src-block-result)
+  (save-excursion (goto-char (match-beginning 5))
+                 (mapc #'delete-overlay (overlays-at (point)))
+                 (forward-char org-babel-hash-show)
+                 (mapc #'delete-overlay (overlays-at (point)))
+                 (replace-match hash nil nil nil 5)
+                 (goto-char (point-at-bol))
+                 (org-babel-hide-hash)))
+
+(defun org-babel-hide-hash ()
+  "Hide the hash in the current results line.
+Only the initial `org-babel-hash-show' characters of the hash
+will remain visible."
+  (add-to-invisibility-spec '(org-babel-hide-hash . t))
+  (save-excursion
+    (when (and (re-search-forward org-babel-result-regexp nil t)
+               (match-string 5))
+      (let* ((start (match-beginning 5))
+             (hide-start (+ org-babel-hash-show start))
+             (end (match-end 5))
+             (hash (match-string 5))
+             ov1 ov2)
+        (setq ov1 (make-overlay start hide-start))
+        (setq ov2 (make-overlay hide-start end))
+        (overlay-put ov2 'invisible 'org-babel-hide-hash)
+        (overlay-put ov1 'babel-hash hash)))))
+
+(defun org-babel-hide-all-hashes ()
+  "Hide the hash in the current buffer.
+Only the initial `org-babel-hash-show' characters of each hash
+will remain visible.  This function should be called as part of
+the `org-mode-hook'."
+  (save-excursion
+    (while (and (not org-babel-hash-show-time)
+               (re-search-forward org-babel-result-regexp nil t))
+      (goto-char (match-beginning 0))
+      (org-babel-hide-hash)
+      (goto-char (match-end 0)))))
+(add-hook 'org-mode-hook 'org-babel-hide-all-hashes)
+
+(defun org-babel-hash-at-point (&optional point)
+  "Return the value of the hash at POINT.
+The hash is also added as the last element of the kill ring.
+This can be called with C-c C-c."
+  (interactive)
+  (let ((hash (car (delq nil (mapcar
+                             (lambda (ol) (overlay-get ol 'babel-hash))
+                              (overlays-at (or point (point))))))))
+    (when hash (kill-new hash) (message hash))))
+(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-hash-at-point)
+
+(defun org-babel-result-hide-spec ()
+  "Hide portions of results lines.
+Add `org-babel-hide-result' as an invisibility spec for hiding
+portions of results lines."
+  (add-to-invisibility-spec '(org-babel-hide-result . t)))
+(add-hook 'org-mode-hook 'org-babel-result-hide-spec)
+
+(defvar org-babel-hide-result-overlays nil
+  "Overlays hiding results.")
+
+(defun org-babel-result-hide-all ()
+  "Fold all results in the current buffer."
+  (interactive)
+  (org-babel-show-result-all)
+  (save-excursion
+    (while (re-search-forward org-babel-result-regexp nil t)
+      (save-excursion (goto-char (match-beginning 0))
+                      (org-babel-hide-result-toggle-maybe)))))
+
+(defun org-babel-show-result-all ()
+  "Unfold all results in the current buffer."
+  (mapc 'delete-overlay org-babel-hide-result-overlays)
+  (setq org-babel-hide-result-overlays nil))
+
+;;;###autoload
+(defun org-babel-hide-result-toggle-maybe ()
+  "Toggle visibility of result at point."
+  (interactive)
+  (let ((case-fold-search t))
+    (if (save-excursion
+          (beginning-of-line 1)
+          (looking-at org-babel-result-regexp))
+        (progn (org-babel-hide-result-toggle)
+               t) ;; to signal that we took action
+      nil))) ;; to signal that we did not
+
+(defun org-babel-hide-result-toggle (&optional force)
+  "Toggle the visibility of the current result."
+  (interactive)
+  (save-excursion
+    (beginning-of-line)
+    (if (re-search-forward org-babel-result-regexp nil t)
+        (let ((start (progn (beginning-of-line 2) (- (point) 1)))
+             (end (progn
+                    (while (looking-at org-babel-multi-line-header-regexp)
+                      (forward-line 1))
+                    (goto-char (- (org-babel-result-end) 1)) (point)))
+             ov)
+          (if (memq t (mapcar (lambda (overlay)
+                                (eq (overlay-get overlay 'invisible)
+                                   'org-babel-hide-result))
+                              (overlays-at start)))
+              (if (or (not force) (eq force 'off))
+                  (mapc (lambda (ov)
+                          (when (member ov org-babel-hide-result-overlays)
+                            (setq org-babel-hide-result-overlays
+                                  (delq ov org-babel-hide-result-overlays)))
+                          (when (eq (overlay-get ov 'invisible)
+                                    'org-babel-hide-result)
+                            (delete-overlay ov)))
+                        (overlays-at start)))
+            (setq ov (make-overlay start end))
+            (overlay-put ov 'invisible 'org-babel-hide-result)
+            ;; make the block accessible to isearch
+            (overlay-put
+             ov 'isearch-open-invisible
+             (lambda (ov)
+               (when (member ov org-babel-hide-result-overlays)
+                 (setq org-babel-hide-result-overlays
+                       (delq ov org-babel-hide-result-overlays)))
+               (when (eq (overlay-get ov 'invisible)
+                         'org-babel-hide-result)
+                 (delete-overlay ov))))
+            (push ov org-babel-hide-result-overlays)))
+      (error "Not looking at a result line"))))
+
+;; org-tab-after-check-for-cycling-hook
+(add-hook 'org-tab-first-hook 'org-babel-hide-result-toggle-maybe)
+;; Remove overlays when changing major mode
+(add-hook 'org-mode-hook
+         (lambda () (org-add-hook 'change-major-mode-hook
+                                  'org-babel-show-result-all 'append 'local)))
+
+(defvar org-file-properties)
+(defun org-babel-params-from-properties (&optional lang)
+  "Retrieve parameters specified as properties.
+Return a list of association lists of source block params
+specified in the properties of the current outline entry."
+  (save-match-data
+    (list
+     ;; DEPRECATED header arguments specified as separate property at
+     ;; point of definition
+     (let (val sym)
+       (org-babel-parse-multiple-vars
+       (delq nil
+             (mapcar
+              (lambda (header-arg)
+                (and (setq val (org-entry-get (point) header-arg t))
+                     (cons (intern (concat ":" header-arg))
+                           (org-babel-read val))))
+              (mapcar
+               #'symbol-name
+               (mapcar
+                #'car
+                (org-babel-combine-header-arg-lists
+                 org-babel-common-header-args-w-values
+                 (progn
+                   (setq sym (intern (concat "org-babel-header-args:" lang)))
+                   (and (boundp sym) (eval sym))))))))))
+     ;; header arguments specified with the header-args property at
+     ;; point of call
+     (org-babel-parse-header-arguments
+      (org-entry-get org-babel-current-src-block-location
+                    "header-args" 'inherit))
+     (when lang ;; language-specific header arguments at point of call
+        (org-babel-parse-header-arguments
+         (org-entry-get org-babel-current-src-block-location
+                        (concat "header-args:" lang) 'inherit))))))
+
+(defvar org-src-preserve-indentation)
+(defun org-babel-parse-src-block-match ()
+  "Parse the results from a match of the `org-babel-src-block-regexp'."
+  (let* ((block-indentation (length (match-string 1)))
+        (lang (org-no-properties (match-string 2)))
+         (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
+        (switches (match-string 3))
+         (body (org-no-properties
+               (let* ((body (match-string 5))
+                      (sub-length (- (length body) 1)))
+                 (if (and (> sub-length 0)
+                          (string= "\n" (substring body sub-length)))
+                     (substring body 0 sub-length)
+                   (or body "")))))
+        (preserve-indentation (or org-src-preserve-indentation
+                                  (save-match-data
+                                    (string-match "-i\\>" switches)))))
+    (list lang
+          ;; get block body less properties, protective commas, and indentation
+          (with-temp-buffer
+            (save-match-data
+              (insert (org-unescape-code-in-string body))
+             (unless preserve-indentation (org-do-remove-indentation))
+              (buffer-string)))
+         (apply #'org-babel-merge-params
+                org-babel-default-header-args
+                (when (boundp lang-headers) (eval lang-headers))
+                (append
+                 (org-babel-params-from-properties lang)
+                 (list (org-babel-parse-header-arguments
+                        (org-no-properties (or (match-string 4) ""))))))
+         switches
+         block-indentation)))
+
+(defun org-babel-parse-inline-src-block-match ()
+  "Parse the results from a match of the `org-babel-inline-src-block-regexp'."
+  (let* ((lang (org-no-properties (match-string 2)))
+         (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
+    (list lang
+          (org-unescape-code-in-string (org-no-properties (match-string 5)))
+          (apply #'org-babel-merge-params
+                org-babel-default-inline-header-args
+                (if (boundp lang-headers) (eval lang-headers) nil)
+                (append
+                 (org-babel-params-from-properties lang)
+                 (list (org-babel-parse-header-arguments
+                        (org-no-properties (or (match-string 4) "")))))))))
+
+(defun org-babel-balanced-split (string alts)
+  "Split STRING on instances of ALTS.
+ALTS is a cons of two character options where each option may be
+either the numeric code of a single character or a list of
+character alternatives.  For example to split on balanced
+instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
+  (let* ((matches (lambda (ch spec) (if (listp spec) (member ch spec) (equal spec ch))))
+        (matched (lambda (ch last)
+                   (if (consp alts)
+                       (and (funcall matches ch (cdr alts))
+                            (funcall matches last (car alts)))
+                     (funcall matches ch alts))))
+        (balance 0) (last 0)
+        quote partial lst)
+    (mapc (lambda (ch)  ; split on [], (), "" balanced instances of [ \t]:
+           (setq balance (+ balance
+                            (cond ((or (equal 91 ch) (equal 40 ch)) 1)
+                                  ((or (equal 93 ch) (equal 41 ch)) -1)
+                                  (t 0))))
+           (when (and (equal 34 ch) (not (equal 92 last)))
+             (setq quote (not quote)))
+           (setq partial (cons ch partial))
+           (when (and (= balance 0) (not quote) (funcall matched ch last))
+             (setq lst (cons (apply #'string (nreverse
+                                              (if (consp alts)
+                                                  (cddr partial)
+                                                (cdr partial))))
+                             lst))
+             (setq partial nil))
+           (setq last ch))
+         (string-to-list string))
+    (nreverse (cons (apply #'string (nreverse partial)) lst))))
+
+(defun org-babel-join-splits-near-ch (ch list)
+  "Join splits where \"=\" is on either end of the split."
+  (let ((last= (lambda (str) (= ch (aref str (1- (length str))))))
+       (first= (lambda (str) (= ch (aref str 0)))))
+    (reverse
+     (org-reduce (lambda (acc el)
+                  (let ((head (car acc)))
+                    (if (and head (or (funcall last= head) (funcall first= el)))
+                        (cons (concat head el) (cdr acc))
+                      (cons el acc))))
+                list :initial-value nil))))
+
+(defun org-babel-parse-header-arguments (arg-string)
+  "Parse a string of header arguments returning an alist."
+  (when (> (length arg-string) 0)
+    (org-babel-parse-multiple-vars
+     (delq nil
+          (mapcar
+           (lambda (arg)
+             (if (string-match
+                  "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)"
+                  arg)
+                 (cons (intern (match-string 1 arg))
+                       (org-babel-read (org-babel-chomp (match-string 2 arg))))
+               (cons (intern (org-babel-chomp arg)) nil)))
+           (let ((raw (org-babel-balanced-split arg-string '((32 9) . 58))))
+              (cons (car raw) (mapcar (lambda (r) (concat ":" r)) (cdr raw)))))))))
+
+(defun org-babel-parse-multiple-vars (header-arguments)
+  "Expand multiple variable assignments behind a single :var keyword.
+
+This allows expression of multiple variables with one :var as
+shown below.
+
+#+PROPERTY: var foo=1, bar=2"
+  (let (results)
+    (mapc (lambda (pair)
+           (if (eq (car pair) :var)
+               (mapcar (lambda (v) (push (cons :var (org-babel-trim v)) results))
+                       (org-babel-join-splits-near-ch
+                        61 (org-babel-balanced-split (cdr pair) 32)))
+             (push pair results)))
+         header-arguments)
+    (nreverse results)))
+
+(defun org-babel-process-params (params)
+  "Expand variables in PARAMS and add summary parameters."
+  (let* ((processed-vars (mapcar (lambda (el)
+                                  (if (consp (cdr el))
+                                      (cdr el)
+                                    (org-babel-ref-parse (cdr el))))
+                                (org-babel-get-header params :var)))
+        (vars-and-names (if (and (assoc :colname-names params)
+                                 (assoc :rowname-names params))
+                            (list processed-vars)
+                          (org-babel-disassemble-tables
+                           processed-vars
+                           (cdr (assoc :hlines params))
+                           (cdr (assoc :colnames params))
+                           (cdr (assoc :rownames params)))))
+        (raw-result (or (cdr (assoc :results params)) ""))
+        (result-params (append
+                        (split-string (if (stringp raw-result)
+                                          raw-result
+                                        (eval raw-result)))
+                        (cdr (assoc :result-params params)))))
+    (append
+     (mapcar (lambda (var) (cons :var var)) (car vars-and-names))
+     (list
+      (cons :colname-names (or (cdr (assoc :colname-names params))
+                              (cadr  vars-and-names)))
+      (cons :rowname-names (or (cdr (assoc :rowname-names params))
+                              (caddr vars-and-names)))
+      (cons :result-params result-params)
+      (cons :result-type  (cond ((member "output" result-params) 'output)
+                               ((member "value" result-params) 'value)
+                               (t 'value))))
+     (org-babel-get-header params :var 'other))))
+
+;; row and column names
+(defun org-babel-del-hlines (table)
+  "Remove all 'hlines from TABLE."
+  (remove 'hline table))
+
+(defun org-babel-get-colnames (table)
+  "Return the column names of TABLE.
+Return a cons cell, the `car' of which contains the TABLE less
+colnames, and the `cdr' of which contains a list of the column
+names."
+  (if (equal 'hline (nth 1 table))
+      (cons (cddr table) (car table))
+    (cons (cdr table) (car table))))
+
+(defun org-babel-get-rownames (table)
+  "Return the row names of TABLE.
+Return a cons cell, the `car' of which contains the TABLE less
+rownames, and the `cdr' of which contains a list of the rownames.
+Note: this function removes any hlines in TABLE."
+  (let* ((table (org-babel-del-hlines table))
+        (rownames (funcall (lambda ()
+                             (let ((tp table))
+                               (mapcar
+                                (lambda (row)
+                                  (prog1
+                                      (pop (car tp))
+                                    (setq tp (cdr tp))))
+                                table))))))
+    (cons table rownames)))
+
+(defun org-babel-put-colnames (table colnames)
+  "Add COLNAMES to TABLE if they exist."
+  (if colnames (apply 'list colnames 'hline table) table))
+
+(defun org-babel-put-rownames (table rownames)
+  "Add ROWNAMES to TABLE if they exist."
+  (if rownames
+      (mapcar (lambda (row)
+                (if (listp row)
+                    (cons (or (pop rownames) "") row)
+                  row)) table)
+    table))
+
+(defun org-babel-pick-name (names selector)
+  "Select one out of an alist of row or column names.
+SELECTOR can be either a list of names in which case those names
+will be returned directly, or an index into the list NAMES in
+which case the indexed names will be return."
+  (if (listp selector)
+      selector
+    (when names
+      (if (and selector (symbolp selector) (not (equal t selector)))
+         (cdr (assoc selector names))
+       (if (integerp selector)
+           (nth (- selector 1) names)
+         (cdr (car (last names))))))))
+
+(defun org-babel-disassemble-tables (vars hlines colnames rownames)
+  "Parse tables for further processing.
+Process the variables in VARS according to the HLINES,
+ROWNAMES and COLNAMES header arguments.  Return a list consisting
+of the vars, cnames and rnames."
+  (let (cnames rnames)
+    (list
+     (mapcar
+      (lambda (var)
+        (when (listp (cdr var))
+          (when (and (not (equal colnames "no"))
+                     (or colnames (and (equal (nth 1 (cdr var)) 'hline)
+                                       (not (member 'hline (cddr (cdr var)))))))
+            (let ((both (org-babel-get-colnames (cdr var))))
+              (setq cnames (cons (cons (car var) (cdr both))
+                                 cnames))
+              (setq var (cons (car var) (car both)))))
+          (when (and rownames (not (equal rownames "no")))
+            (let ((both (org-babel-get-rownames (cdr var))))
+              (setq rnames (cons (cons (car var) (cdr both))
+                                 rnames))
+              (setq var (cons (car var) (car both)))))
+          (when (and hlines (not (equal hlines "yes")))
+            (setq var (cons (car var) (org-babel-del-hlines (cdr var))))))
+        var)
+      vars)
+     (reverse cnames) (reverse rnames))))
+
+(defun org-babel-reassemble-table (table colnames rownames)
+  "Add column and row names to a table.
+Given a TABLE and set of COLNAMES and ROWNAMES add the names
+to the table for reinsertion to org-mode."
+  (if (listp table)
+      (let ((table (if (and rownames (= (length table) (length rownames)))
+                       (org-babel-put-rownames table rownames) table)))
+        (if (and colnames (listp (car table)) (= (length (car table))
+                                                 (length colnames)))
+            (org-babel-put-colnames table colnames) table))
+    table))
+
+(defun org-babel-where-is-src-block-head ()
+  "Find where the current source block begins.
+Return the point at the beginning of the current source
+block.  Specifically at the beginning of the #+BEGIN_SRC line.
+If the point is not on a source block then return nil."
+  (let ((initial (point)) (case-fold-search t) top bottom)
+    (or
+     (save-excursion ;; on a source name line or a #+header line
+       (beginning-of-line 1)
+       (and (or (looking-at org-babel-src-name-regexp)
+               (looking-at org-babel-multi-line-header-regexp))
+           (progn
+             (while (and (forward-line 1)
+                         (or (looking-at org-babel-src-name-regexp)
+                             (looking-at org-babel-multi-line-header-regexp))))
+             (looking-at org-babel-src-block-regexp))
+            (point)))
+     (save-excursion ;; on a #+begin_src line
+       (beginning-of-line 1)
+       (and (looking-at org-babel-src-block-regexp)
+            (point)))
+     (save-excursion ;; inside a src block
+       (and
+        (re-search-backward "^[ \t]*#\\+begin_src" nil t) (setq top (point))
+        (re-search-forward "^[ \t]*#\\+end_src" nil t) (setq bottom (point))
+        (< top initial) (< initial bottom)
+        (progn (goto-char top) (beginning-of-line 1)
+              (looking-at org-babel-src-block-regexp))
+        (point-marker))))))
+
+;;;###autoload
+(defun org-babel-goto-src-block-head ()
+  "Go to the beginning of the current code block."
+  (interactive)
+  (let ((head (org-babel-where-is-src-block-head)))
+     (if head (goto-char head) (error "Not currently in a code block"))))
+
+;;;###autoload
+(defun org-babel-goto-named-src-block (name)
+  "Go to a named source-code block."
+  (interactive
+   (let ((completion-ignore-case t)
+        (case-fold-search t)
+        (under-point (thing-at-point 'line)))
+     (list (org-icompleting-read
+           "source-block name: " (org-babel-src-block-names) nil t
+           (cond
+            ;; noweb
+            ((string-match (org-babel-noweb-wrap) under-point)
+             (let ((block-name (match-string 1 under-point)))
+               (string-match "[^(]*" block-name)
+               (match-string 0 block-name)))
+            ;; #+call:
+            ((string-match org-babel-lob-one-liner-regexp under-point)
+             (let ((source-info (car (org-babel-lob-get-info))))
+               (if (string-match "^\\([^\\[]+?\\)\\(\\[.*\\]\\)?(" source-info)
+                   (let ((source-name (match-string 1 source-info)))
+                     source-name))))
+            ;; #+results:
+            ((string-match (concat "#\\+" org-babel-results-keyword
+                                   "\\:\s+\\([^\\(]*\\)") under-point)
+             (match-string 1 under-point))
+            ;; symbol-at-point
+            ((and (thing-at-point 'symbol))
+             (org-babel-find-named-block (thing-at-point 'symbol))
+             (thing-at-point 'symbol))
+            (""))))))
+  (let ((point (org-babel-find-named-block name)))
+    (if point
+        ;; taken from `org-open-at-point'
+        (progn (org-mark-ring-push) (goto-char point) (org-show-context))
+      (message "source-code block '%s' not found in this buffer" name))))
+
+(defun org-babel-find-named-block (name)
+  "Find a named source-code block.
+Return the location of the source block identified by source
+NAME, or nil if no such block exists.  Set match data according to
+org-babel-named-src-block-regexp."
+  (save-excursion
+    (let ((case-fold-search t)
+         (regexp (org-babel-named-src-block-regexp-for-name name)) msg)
+      (goto-char (point-min))
+      (when (or (re-search-forward regexp nil t)
+               (re-search-backward regexp nil t))
+        (match-beginning 0)))))
+
+(defun org-babel-src-block-names (&optional file)
+  "Returns the names of source blocks in FILE or the current buffer."
+  (save-excursion
+    (when file (find-file file)) (goto-char (point-min))
+    (let ((case-fold-search t) names)
+      (while (re-search-forward org-babel-src-name-w-name-regexp nil t)
+       (setq names (cons (match-string 3) names)))
+      names)))
+
+;;;###autoload
+(defun org-babel-goto-named-result (name)
+  "Go to a named result."
+  (interactive
+   (let ((completion-ignore-case t))
+     (list (org-icompleting-read "source-block name: "
+                                (org-babel-result-names) nil t))))
+  (let ((point (org-babel-find-named-result name)))
+    (if point
+        ;; taken from `org-open-at-point'
+        (progn (goto-char point) (org-show-context))
+      (message "result '%s' not found in this buffer" name))))
+
+(defun org-babel-find-named-result (name &optional point)
+  "Find a named result.
+Return the location of the result named NAME in the current
+buffer or nil if no such result exists."
+  (save-excursion
+    (let ((case-fold-search t))
+      (goto-char (or point (point-min)))
+      (catch 'is-a-code-block
+       (when (re-search-forward
+              (concat org-babel-result-regexp
+                      "[ \t]" (regexp-quote name) "[ \t]*[\n\f\v\r]") nil t)
+         (when (and (string= "name" (downcase (match-string 1)))
+                    (or (beginning-of-line 1)
+                        (looking-at org-babel-src-block-regexp)
+                        (looking-at org-babel-multi-line-header-regexp)
+                        (looking-at org-babel-lob-one-liner-regexp)))
+           (throw 'is-a-code-block (org-babel-find-named-result name (point))))
+         (beginning-of-line 0) (point))))))
+
+(defun org-babel-result-names (&optional file)
+  "Returns the names of results in FILE or the current buffer."
+  (save-excursion
+    (when file (find-file file)) (goto-char (point-min))
+    (let ((case-fold-search t) names)
+      (while (re-search-forward org-babel-result-w-name-regexp nil t)
+       (setq names (cons (match-string 4) names)))
+      names)))
+
+;;;###autoload
+(defun org-babel-next-src-block (&optional arg)
+  "Jump to the next source block.
+With optional prefix argument ARG, jump forward ARG many source blocks."
+  (interactive "p")
+  (org-next-block arg nil org-babel-src-block-regexp))
+
+;;;###autoload
+(defun org-babel-previous-src-block (&optional arg)
+  "Jump to the previous source block.
+With optional prefix argument ARG, jump backward ARG many source blocks."
+  (interactive "p")
+  (org-previous-block arg org-babel-src-block-regexp))
+
+(defvar org-babel-load-languages)
+
+;;;###autoload
+(defun org-babel-mark-block ()
+  "Mark current src block."
+  (interactive)
+  (let ((head (org-babel-where-is-src-block-head)))
+    (when head
+      (save-excursion
+        (goto-char head)
+        (looking-at org-babel-src-block-regexp))
+      (push-mark (match-end 5) nil t)
+      (goto-char (match-beginning 5)))))
+
+(defun org-babel-demarcate-block (&optional arg)
+  "Wrap or split the code in the region or on the point.
+When called from inside of a code block the current block is
+split.  When called from outside of a code block a new code block
+is created.  In both cases if the region is demarcated and if the
+region is not active then the point is demarcated."
+  (interactive "P")
+  (let ((info (org-babel-get-src-block-info 'light))
+       (headers (progn (org-babel-where-is-src-block-head)
+                       (match-string 4)))
+       (stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
+    (if info
+        (mapc
+         (lambda (place)
+           (save-excursion
+             (goto-char place)
+             (let ((lang (nth 0 info))
+                   (indent (make-string (nth 5 info) ? )))
+              (when (string-match "^[[:space:]]*$"
+                                  (buffer-substring (point-at-bol)
+                                                    (point-at-eol)))
+                (delete-region (point-at-bol) (point-at-eol)))
+               (insert (concat
+                       (if (looking-at "^") "" "\n")
+                       indent "#+end_src\n"
+                       (if arg stars indent) "\n"
+                       indent "#+begin_src " lang
+                       (if (> (length headers) 1)
+                           (concat " " headers) headers)
+                       (if (looking-at "[\n\r]")
+                           ""
+                         (concat "\n" (make-string (current-column) ? )))))))
+          (move-end-of-line 2))
+         (sort (if (org-region-active-p) (list (mark) (point)) (list (point))) #'>))
+      (let ((start (point))
+           (lang (org-icompleting-read
+                  "Lang: "
+                  (mapcar #'symbol-name
+                          (delete-dups
+                           (append (mapcar #'car org-babel-load-languages)
+                                   (mapcar (lambda (el) (intern (car el)))
+                                           org-src-lang-modes))))))
+           (body (delete-and-extract-region
+                  (if (org-region-active-p) (mark) (point)) (point))))
+       (insert (concat (if (looking-at "^") "" "\n")
+                       (if arg (concat stars "\n") "")
+                       "#+begin_src " lang "\n"
+                       body
+                       (if (or (= (length body) 0)
+                               (string-match "[\r\n]$" body)) "" "\n")
+                       "#+end_src\n"))
+       (goto-char start) (move-end-of-line 1)))))
+
+(defvar org-babel-lob-one-liner-regexp)
+(defun org-babel-where-is-src-block-result (&optional insert info hash indent)
+  "Find where the current source block results begin.
+Return the point at the beginning of the result of the current
+source block.  Specifically at the beginning of the results line.
+If no result exists for this block then create a results line
+following the source block."
+  (save-excursion
+    (let* ((case-fold-search t)
+          (on-lob-line (save-excursion
+                         (beginning-of-line 1)
+                         (looking-at org-babel-lob-one-liner-regexp)))
+          (inlinep (when (org-babel-get-inline-src-block-matches)
+                     (match-end 0)))
+          (name (nth 4 (or info (org-babel-get-src-block-info 'light))))
+          (head (unless on-lob-line (org-babel-where-is-src-block-head)))
+          found beg end)
+      (when head (goto-char head))
+      (org-with-wide-buffer
+       (setq
+       found ;; was there a result (before we potentially insert one)
+       (or
+        inlinep
+        (and
+         ;; named results:
+         ;; - return t if it is found, else return nil
+         ;; - if it does not need to be rebuilt, then don't set end
+         ;; - if it does need to be rebuilt then do set end
+         name (setq beg (org-babel-find-named-result name))
+         (prog1 beg
+           (when (and hash (not (string= hash (match-string 5))))
+             (goto-char beg) (setq end beg) ;; beginning of result
+             (forward-line 1)
+             (delete-region end (org-babel-result-end)) nil)))
+        (and
+         ;; unnamed results:
+         ;; - return t if it is found, else return nil
+         ;; - if it is found, and the hash doesn't match, delete and set end
+         (or on-lob-line (re-search-forward "^[ \t]*#\\+end_src" nil t))
+         (progn (end-of-line 1)
+                (if (eobp) (insert "\n") (forward-char 1))
+                (setq end (point))
+                (or (and
+                     (not name)
+                     (progn ;; unnamed results line already exists
+                       (catch 'non-comment
+                         (while (re-search-forward "[^ \f\t\n\r\v]" nil t)
+                           (beginning-of-line 1)
+                           (cond
+                            ((looking-at (concat org-babel-result-regexp "\n"))
+                             (throw 'non-comment t))
+                            ((looking-at "^[ \t]*#") (end-of-line 1))
+                            (t (throw 'non-comment nil))))))
+                     (let ((this-hash (match-string 5)))
+                       (prog1 (point)
+                         ;; must remove and rebuild if hash!=old-hash
+                         (if (and hash (not (string= hash this-hash)))
+                             (prog1 nil
+                               (forward-line 1)
+                               (delete-region
+                                end (org-babel-result-end)))
+                           (setq end nil)))))))))))
+      (if (not (and insert end)) found
+       (goto-char end)
+       (unless beg
+         (if (looking-at "[\n\r]") (forward-char 1) (insert "\n")))
+       (insert (concat
+                (when (wholenump indent) (make-string indent ? ))
+                "#+" org-babel-results-keyword
+                (when hash
+                  (if org-babel-hash-show-time
+                      (concat
+                       "["(format-time-string "<%Y-%m-%d %H:%M:%S>")" "hash"]")
+                    (concat "["hash"]")))
+                ":"
+                (when name (concat " " name)) "\n"))
+       (unless beg (insert "\n") (backward-char))
+       (beginning-of-line 0)
+       (if hash (org-babel-hide-hash))
+       (point)))))
+
+(defvar org-block-regexp)
+(defun org-babel-read-result ()
+  "Read the result at `point' into emacs-lisp."
+  (let ((case-fold-search t) result-string)
+    (cond
+     ((org-at-table-p) (org-babel-read-table))
+     ((org-at-item-p) (org-babel-read-list))
+     ((looking-at org-bracket-link-regexp) (org-babel-read-link))
+     ((looking-at org-block-regexp) (org-babel-trim (match-string 4)))
+     ((or (looking-at "^[ \t]*: ") (looking-at "^[ \t]*:$"))
+      (setq result-string
+           (org-babel-trim
+            (mapconcat (lambda (line)
+                          (or (and (> (length line) 1)
+                                  (string-match "^[ \t]*: ?\\(.+\\)" line)
+                                  (match-string 1 line))
+                             ""))
+                       (split-string
+                        (buffer-substring
+                          (point) (org-babel-result-end)) "[\r\n]+")
+                       "\n")))
+      (or (org-babel-number-p result-string) result-string))
+     ((looking-at org-babel-result-regexp)
+      (save-excursion (forward-line 1) (org-babel-read-result))))))
+
+(defun org-babel-read-table ()
+  "Read the table at `point' into emacs-lisp."
+  (mapcar (lambda (row)
+            (if (and (symbolp row) (equal row 'hline)) row
+              (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval)) row)))
+          (org-table-to-lisp)))
+
+(defun org-babel-read-list ()
+  "Read the list at `point' into emacs-lisp."
+  (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
+         (mapcar #'cadr (cdr (org-list-parse-list)))))
+
+(defvar org-link-types-re)
+(defun org-babel-read-link ()
+  "Read the link at `point' into emacs-lisp.
+If the path of the link is a file path it is expanded using
+`expand-file-name'."
+  (let* ((case-fold-search t)
+         (raw (and (looking-at org-bracket-link-regexp)
+                   (org-no-properties (match-string 1))))
+         (type (and (string-match org-link-types-re raw)
+                    (match-string 1 raw))))
+    (cond
+     ((not type) (expand-file-name raw))
+     ((string= type "file")
+      (and (string-match "file\\(.*\\):\\(.+\\)" raw)
+           (expand-file-name (match-string 2 raw))))
+     (t raw))))
+
+(defun org-babel-format-result (result &optional sep)
+  "Format RESULT for writing to file."
+  (let ((echo-res (lambda (r) (if (stringp r) r (format "%S" r)))))
+    (if (listp result)
+       ;; table result
+       (orgtbl-to-generic
+        result (list :sep (or sep "\t") :fmt echo-res))
+      ;; scalar result
+      (funcall echo-res result))))
+
+(defun org-babel-insert-result
+  (result &optional result-params info hash indent lang)
+  "Insert RESULT into the current buffer.
+By default RESULT is inserted after the end of the
+current source block.  With optional argument RESULT-PARAMS
+controls insertion of results in the org-mode file.
+RESULT-PARAMS can take the following values:
+
+replace - (default option) insert results after the source block
+          replacing any previously inserted results
+
+silent -- no results are inserted into the Org-mode buffer but
+          the results are echoed to the minibuffer and are
+          ingested by Emacs (a potentially time consuming
+          process)
+
+file ---- the results are interpreted as a file path, and are
+          inserted into the buffer using the Org-mode file syntax
+
+list ---- the results are interpreted as an Org-mode list.
+
+raw ----- results are added directly to the Org-mode file.  This
+          is a good option if you code block will output org-mode
+          formatted text.
+
+drawer -- results are added directly to the Org-mode file as with
+          \"raw\", but are wrapped in a RESULTS drawer, allowing
+          them to later be replaced or removed automatically.
+
+org ----- results are added inside of a \"#+BEGIN_SRC org\" block.
+          They are not comma-escaped when inserted, but Org syntax
+          here will be discarded when exporting the file.
+
+html ---- results are added inside of a #+BEGIN_HTML block.  This
+          is a good option if you code block will output html
+          formatted text.
+
+latex --- results are added inside of a #+BEGIN_LATEX block.
+          This is a good option if you code block will output
+          latex formatted text.
+
+code ---- the results are extracted in the syntax of the source
+          code of the language being evaluated and are added
+          inside of a #+BEGIN_SRC block with the source-code
+          language set appropriately.  Note this relies on the
+          optional LANG argument."
+  (if (stringp result)
+      (progn
+        (setq result (org-no-properties result))
+        (when (member "file" result-params)
+         (setq result (org-babel-result-to-file
+                       result (when (assoc :file-desc (nth 2 info))
+                                (or (cdr (assoc :file-desc (nth 2 info)))
+                                    result))))))
+    (unless (listp result) (setq result (format "%S" result))))
+  (if (and result-params (member "silent" result-params))
+      (progn
+       (message (replace-regexp-in-string "%" "%%" (format "%S" result)))
+       result)
+    (save-excursion
+      (let* ((inlinep
+             (save-excursion
+               (when (or (org-babel-get-inline-src-block-matches)
+                         (org-babel-get-lob-one-liner-matches))
+                 (goto-char (match-end 0))
+                 (insert (if (listp result) "\n" " "))
+                 (point))))
+            (existing-result (unless inlinep
+                               (org-babel-where-is-src-block-result
+                                t info hash indent)))
+            (results-switches
+             (cdr (assoc :results_switches (nth 2 info))))
+            (visible-beg (copy-marker (point-min)))
+            (visible-end (copy-marker (point-max)))
+            ;; When results exist outside of the current visible
+            ;; region of the buffer, be sure to widen buffer to
+            ;; update them.
+            (outside-scope-p (and existing-result
+                                  (or (> visible-beg existing-result)
+                                      (<= visible-end existing-result))))
+            beg end)
+       (when (and (stringp result)  ; ensure results end in a newline
+                  (not inlinep)
+                  (> (length result) 0)
+                  (not (or (string-equal (substring result -1) "\n")
+                           (string-equal (substring result -1) "\r"))))
+         (setq result (concat result "\n")))
+       (unwind-protect
+           (progn
+             (when outside-scope-p (widen))
+             (if (not existing-result)
+                 (setq beg (or inlinep (point)))
+               (goto-char existing-result)
+               (save-excursion
+                 (re-search-forward "#" nil t)
+                 (setq indent (- (current-column) 1)))
+               (forward-line 1)
+               (setq beg (point))
+               (cond
+                ((member "replace" result-params)
+                 (delete-region (point) (org-babel-result-end)))
+                ((member "append" result-params)
+                 (goto-char (org-babel-result-end)) (setq beg (point-marker)))
+                ((member "prepend" result-params)))) ; already there
+             (setq results-switches
+                   (if results-switches (concat " " results-switches) ""))
+             (let ((wrap (lambda (start finish &optional no-escape)
+                           (goto-char end) (insert (concat finish "\n"))
+                           (goto-char beg) (insert (concat start "\n"))
+                           (unless no-escape
+                             (org-escape-code-in-region (min (point) end) end))
+                           (goto-char end) (goto-char (point-at-eol))
+                           (setq end (point-marker))))
+                   (proper-list-p (lambda (it) (and (listp it) (null (cdr (last it)))))))
+               ;; insert results based on type
+               (cond
+                ;; do nothing for an empty result
+                ((null result))
+                ;; insert a list if preferred
+                ((member "list" result-params)
+                 (insert
+                  (org-babel-trim
+                   (org-list-to-generic
+                    (cons 'unordered
+                          (mapcar
+                           (lambda (el) (list nil (if (stringp el) el (format "%S" el))))
+                           (if (listp result) result (split-string result "\n" t))))
+                    '(:splicep nil :istart "- " :iend "\n")))
+                  "\n"))
+                ;; assume the result is a table if it's not a string
+                ((funcall proper-list-p result)
+                 (goto-char beg)
+                 (insert (concat (orgtbl-to-orgtbl
+                                  (if (or (eq 'hline (car result))
+                                          (and (listp (car result))
+                                               (listp (cdr (car result)))))
+                                      result (list result))
+                                  '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
+                 (goto-char beg) (when (org-at-table-p) (org-table-align)))
+                ((and (listp result) (not (funcall proper-list-p result)))
+                 (insert (format "%s\n" result)))
+                ((member "file" result-params)
+                 (when inlinep (goto-char inlinep))
+                 (insert result))
+                (t (goto-char beg) (insert result)))
+               (when (funcall proper-list-p result) (goto-char (org-table-end)))
+               (setq end (point-marker))
+               ;; possibly wrap result
+               (cond
+                ((assoc :wrap (nth 2 info))
+                 (let ((name (or (cdr (assoc :wrap (nth 2 info))) "RESULTS")))
+                   (funcall wrap (concat "#+BEGIN_" name)
+                            (concat "#+END_" (car (org-split-string name))))))
+                ((member "html" result-params)
+                 (funcall wrap "#+BEGIN_HTML" "#+END_HTML"))
+                ((member "latex" result-params)
+                 (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX"))
+                ((member "org" result-params)
+                 (goto-char beg) (if (org-at-table-p) (org-cycle))
+                 (funcall wrap "#+BEGIN_SRC org" "#+END_SRC"))
+                ((member "code" result-params)
+                 (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "none") results-switches)
+                          "#+END_SRC"))
+                ((member "raw" result-params)
+                 (goto-char beg) (if (org-at-table-p) (org-cycle)))
+                ((or (member "drawer" result-params)
+                     ;; Stay backward compatible with <7.9.2
+                     (member "wrap" result-params))
+                 (goto-char beg) (if (org-at-table-p) (org-cycle))
+                 (funcall wrap ":RESULTS:" ":END:" 'no-escape))
+                ((and (not (funcall proper-list-p result))
+                      (not (member "file" result-params)))
+                 (org-babel-examplize-region beg end results-switches)
+                 (setq end (point)))))
+             ;; possibly indent the results to match the #+results line
+             (when (and (not inlinep) (numberp indent) indent (> indent 0)
+                        ;; in this case `table-align' does the work for us
+                        (not (and (listp result)
+                                  (member "append" result-params))))
+               (indent-rigidly beg end indent))
+             (if (null result)
+                 (if (member "value" result-params)
+                     (message "Code block returned no value.")
+                   (message "Code block produced no output."))
+               (message "Code block evaluation complete.")))
+         (when outside-scope-p (narrow-to-region visible-beg visible-end))
+         (set-marker visible-beg nil)
+         (set-marker visible-end nil))))))
+
+(defun org-babel-remove-result (&optional info)
+  "Remove the result of the current source block."
+  (interactive)
+  (let ((location (org-babel-where-is-src-block-result nil info)) start)
+    (when location
+      (setq start (- location 1))
+      (save-excursion
+        (goto-char location) (forward-line 1)
+        (delete-region start (org-babel-result-end))))))
+
+(defun org-babel-result-end ()
+  "Return the point at the end of the current set of results."
+  (save-excursion
+    (cond
+     ((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
+     ((org-at-item-p) (let* ((struct (org-list-struct))
+                            (prvs (org-list-prevs-alist struct)))
+                       (org-list-get-list-end (point-at-bol) struct prvs)))
+     ((let ((case-fold-search t)) (looking-at "^\\([ \t]*\\):results:"))
+      (progn (re-search-forward (concat "^" (match-string 1) ":END:"))
+            (forward-char 1) (point)))
+     (t
+      (let ((case-fold-search t))
+       (if (looking-at (concat "[ \t]*#\\+begin_\\([^ \t\n\r]+\\)"))
+           (progn (re-search-forward (concat "[ \t]*#\\+end_" (match-string 1))
+                                     nil t)
+                  (forward-char 1))
+         (while (looking-at "[ \t]*\\(: \\|:$\\|\\[\\[\\)")
+           (forward-line 1))))
+      (point)))))
+
+(defun org-babel-result-to-file (result &optional description)
+  "Convert RESULT into an `org-mode' link with optional DESCRIPTION.
+If the `default-directory' is different from the containing
+file's directory then expand relative links."
+  (when (stringp result)
+    (format "[[file:%s]%s]"
+           (if (and default-directory
+                    buffer-file-name
+                    (not (string= (expand-file-name default-directory)
+                                  (expand-file-name
+                                   (file-name-directory buffer-file-name)))))
+               (expand-file-name result default-directory)
+             result)
+           (if description (concat "[" description "]") ""))))
+
+(defvar org-babel-capitalize-examplize-region-markers nil
+  "Make true to capitalize begin/end example markers inserted by code blocks.")
+
+(defun org-babel-examplize-region (beg end &optional results-switches)
+  "Comment out region using the inline '==' or ': ' org example quote."
+  (interactive "*r")
+  (let ((chars-between (lambda (b e)
+                        (not (string-match "^[\\s]*$" (buffer-substring b e)))))
+       (maybe-cap (lambda (str) (if org-babel-capitalize-examplize-region-markers
+                                    (upcase str) str))))
+    (if (or (funcall chars-between (save-excursion (goto-char beg) (point-at-bol)) beg)
+           (funcall chars-between end (save-excursion (goto-char end) (point-at-eol))))
+       (save-excursion
+         (goto-char beg)
+         (insert (format org-babel-inline-result-wrap
+                         (prog1 (buffer-substring beg end)
+                           (delete-region beg end)))))
+      (let ((size (count-lines beg end)))
+       (save-excursion
+         (cond ((= size 0))          ; do nothing for an empty result
+               ((< size org-babel-min-lines-for-block-output)
+                (goto-char beg)
+                (dotimes (n size)
+                  (beginning-of-line 1) (insert ": ") (forward-line 1)))
+               (t
+                (goto-char beg)
+                (insert (if results-switches
+                            (format "%s%s\n"
+                                    (funcall maybe-cap "#+begin_example")
+                                    results-switches)
+                          (funcall maybe-cap "#+begin_example\n")))
+                (if (markerp end) (goto-char end) (forward-char (- end beg)))
+                (insert (funcall maybe-cap "#+end_example\n")))))))))
+
+(defun org-babel-update-block-body (new-body)
+  "Update the body of the current code block to NEW-BODY."
+  (if (not (org-babel-where-is-src-block-head))
+      (error "Not in a source block")
+    (save-match-data
+      (replace-match (concat (org-babel-trim new-body) "\n") nil t nil 5))
+    (indent-rigidly (match-beginning 5) (match-end 5) 2)))
+
+(defun org-babel-merge-params (&rest plists)
+  "Combine all parameter association lists in PLISTS.
+Later elements of PLISTS override the values of previous elements.
+This takes into account some special considerations for certain
+parameters when merging lists."
+  (let* ((results-exclusive-groups
+         (mapcar (lambda (group) (mapcar #'symbol-name group))
+                 (cdr (assoc 'results org-babel-common-header-args-w-values))))
+        (exports-exclusive-groups
+         (mapcar (lambda (group) (mapcar #'symbol-name group))
+                 (cdr (assoc 'exports org-babel-common-header-args-w-values))))
+        (variable-index 0)
+        (e-merge (lambda (exclusive-groups &rest result-params)
+                   ;; maintain exclusivity of mutually exclusive parameters
+                   (let (output)
+                     (mapc (lambda (new-params)
+                             (mapc (lambda (new-param)
+                                     (mapc (lambda (exclusive-group)
+                                             (when (member new-param exclusive-group)
+                                               (mapcar (lambda (excluded-param)
+                                                         (setq output
+                                                               (delete
+                                                                excluded-param
+                                                                output)))
+                                                       exclusive-group)))
+                                           exclusive-groups)
+                                     (setq output (org-uniquify
+                                                   (cons new-param output))))
+                                   new-params))
+                           result-params)
+                     output)))
+        params results exports tangle noweb cache vars shebang comments padline
+        clearnames)
+
+    (mapc
+     (lambda (plist)
+       (mapc
+       (lambda (pair)
+         (case (car pair)
+           (:var
+            (let ((name (if (listp (cdr pair))
+                            (cadr pair)
+                          (and (string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*="
+                                             (cdr pair))
+                               (intern (match-string 1 (cdr pair)))))))
+              (if name
+                  (setq vars
+                        (append
+                         (if (member name (mapcar #'car vars))
+                             (progn
+                               (push name clearnames)
+                               (delq nil
+                                     (mapcar
+                                      (lambda (p)
+                                        (unless (equal (car p) name) p))
+                                      vars)))
+                           vars)
+                         (list (cons name pair))))
+                ;; if no name is given and we already have named variables
+                ;; then assign to named variables in order
+                (if (and vars (nth variable-index vars))
+                    (let ((name (car (nth variable-index vars))))
+                      (push name clearnames) ; clear out colnames
+                                             ; and rownames
+                                             ; for replace vars
+                      (prog1 (setf (cddr (nth variable-index vars))
+                                   (concat (symbol-name name) "=" (cdr pair)))
+                        (incf variable-index)))
+                  (error "Variable \"%s\" must be assigned a default value"
+                         (cdr pair))))))
+           (:results
+            (setq results (funcall e-merge results-exclusive-groups
+                                   results
+                                   (split-string
+                                    (let ((r (cdr pair)))
+                                      (if (stringp r) r (eval r)))))))
+           (:file
+            (when (cdr pair)
+              (setq results (funcall e-merge results-exclusive-groups
+                                     results '("file")))
+              (unless (or (member "both" exports)
+                          (member "none" exports)
+                          (member "code" exports))
+                (setq exports (funcall e-merge exports-exclusive-groups
+                                       exports '("results"))))
+              (setq params (cons pair (assq-delete-all (car pair) params)))))
+           (:exports
+            (setq exports (funcall e-merge exports-exclusive-groups
+                                   exports (split-string (cdr pair)))))
+           (:tangle ;; take the latest -- always overwrite
+            (setq tangle (or (list (cdr pair)) tangle)))
+           (:noweb
+            (setq noweb (funcall e-merge
+                                 '(("yes" "no" "tangle" "no-export"
+                                    "strip-export" "eval"))
+                                 noweb
+                                 (split-string (or (cdr pair) "")))))
+           (:cache
+            (setq cache (funcall e-merge '(("yes" "no")) cache
+                                 (split-string (or (cdr pair) "")))))
+           (:padline
+            (setq padline (funcall e-merge '(("yes" "no")) padline
+                                   (split-string (or (cdr pair) "")))))
+           (:shebang ;; take the latest -- always overwrite
+            (setq shebang (or (list (cdr pair)) shebang)))
+           (:comments
+            (setq comments (funcall e-merge '(("yes" "no")) comments
+                                    (split-string (or (cdr pair) "")))))
+           (t ;; replace: this covers e.g. :session
+            (setq params (cons pair (assq-delete-all (car pair) params))))))
+       plist))
+     plists)
+    (setq vars (reverse vars))
+    (while vars (setq params (cons (cons :var (cddr (pop vars))) params)))
+    ;; clear out col-names and row-names for replaced variables
+    (mapc
+     (lambda (name)
+       (mapc
+       (lambda (param)
+         (when (assoc param params)
+           (setf (cdr (assoc param params))
+                 (org-remove-if (lambda (pair) (equal (car pair) name))
+                                (cdr (assoc param params))))
+           (setf params (org-remove-if (lambda (pair) (and (equal (car pair) param)
+                                                      (null (cdr pair))))
+                                       params))))
+       (list :colname-names :rowname-names)))
+     clearnames)
+    (mapc
+     (lambda (hd)
+       (let ((key (intern (concat ":" (symbol-name hd))))
+            (val (eval hd)))
+        (setf params (cons (cons key (mapconcat 'identity val " ")) params))))
+     '(results exports tangle noweb padline cache shebang comments))
+    params))
+
+(defvar org-babel-use-quick-and-dirty-noweb-expansion nil
+  "Set to true to use regular expressions to expand noweb references.
+This results in much faster noweb reference expansion but does
+not properly allow code blocks to inherit the \":noweb-ref\"
+header argument from buffer or subtree wide properties.")
+
+(defun org-babel-noweb-p (params context)
+  "Check if PARAMS require expansion in CONTEXT.
+CONTEXT may be one of :tangle, :export or :eval."
+  (let* (intersect
+        (intersect (lambda (as bs)
+                     (when as
+                       (if (member (car as) bs)
+                           (car as)
+                         (funcall intersect (cdr as) bs))))))
+    (funcall intersect (case context
+                        (:tangle '("yes" "tangle" "no-export" "strip-export"))
+                        (:eval   '("yes" "no-export" "strip-export" "eval"))
+                        (:export '("yes")))
+            (split-string (or (cdr (assoc :noweb params)) "")))))
+
+(defun org-babel-expand-noweb-references (&optional info parent-buffer)
+  "Expand Noweb references in the body of the current source code block.
+
+For example the following reference would be replaced with the
+body of the source-code block named 'example-block'.
+
+<<example-block>>
+
+Note that any text preceding the <<foo>> construct on a line will
+be interposed between the lines of the replacement text.  So for
+example if <<foo>> is placed behind a comment, then the entire
+replacement text will also be commented.
+
+This function must be called from inside of the buffer containing
+the source-code block which holds BODY.
+
+In addition the following syntax can be used to insert the
+results of evaluating the source-code block named 'example-block'.
+
+<<example-block()>>
+
+Any optional arguments can be passed to example-block by placing
+the arguments inside the parenthesis following the convention
+defined by `org-babel-lob'.  For example
+
+<<example-block(a=9)>>
+
+would set the value of argument \"a\" equal to \"9\".  Note that
+these arguments are not evaluated in the current source-code
+block but are passed literally to the \"example-block\"."
+  (let* ((parent-buffer (or parent-buffer (current-buffer)))
+         (info (or info (org-babel-get-src-block-info 'light)))
+         (lang (nth 0 info))
+         (body (nth 1 info))
+        (ob-nww-start org-babel-noweb-wrap-start)
+        (ob-nww-end org-babel-noweb-wrap-end)
+        (comment (string= "noweb" (cdr (assoc :comments (nth 2 info)))))
+        (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
+                           ":noweb-ref[ \t]+" "\\)"))
+         (new-body "")
+        (nb-add (lambda (text) (setq new-body (concat new-body text))))
+        (c-wrap (lambda (text)
+                  (with-temp-buffer
+                    (funcall (intern (concat lang "-mode")))
+                    (comment-region (point) (progn (insert text) (point)))
+                    (org-babel-trim (buffer-string)))))
+        index source-name evaluate prefix)
+    (with-temp-buffer
+      (org-set-local 'org-babel-noweb-wrap-start ob-nww-start)
+      (org-set-local 'org-babel-noweb-wrap-end ob-nww-end)
+      (insert body) (goto-char (point-min))
+      (setq index (point))
+      (while (and (re-search-forward (org-babel-noweb-wrap) nil t))
+       (save-match-data (setf source-name (match-string 1)))
+       (save-match-data (setq evaluate (string-match "\(.*\)" source-name)))
+       (save-match-data
+         (setq prefix
+               (buffer-substring (match-beginning 0)
+                                 (save-excursion
+                                   (beginning-of-line 1) (point)))))
+       ;; add interval to new-body (removing noweb reference)
+       (goto-char (match-beginning 0))
+       (funcall nb-add (buffer-substring index (point)))
+       (goto-char (match-end 0))
+       (setq index (point))
+       (funcall
+         nb-add
+         (with-current-buffer parent-buffer
+           (save-restriction
+             (widen)
+             (mapconcat ;; Interpose PREFIX between every line.
+              #'identity
+              (split-string
+               (if evaluate
+                   (let ((raw (org-babel-ref-resolve source-name)))
+                     (if (stringp raw) raw (format "%S" raw)))
+                 (or
+                  ;; Retrieve from the library of babel.
+                  (nth 2 (assoc (intern source-name)
+                                org-babel-library-of-babel))
+                  ;; Return the contents of headlines literally.
+                  (save-excursion
+                    (when (org-babel-ref-goto-headline-id source-name)
+                             (org-babel-ref-headline-body)))
+                  ;; Find the expansion of reference in this buffer.
+                  (let ((rx (concat rx-prefix source-name "[ \t\n]"))
+                        expansion)
+                    (save-excursion
+                      (goto-char (point-min))
+                      (if org-babel-use-quick-and-dirty-noweb-expansion
+                          (while (re-search-forward rx nil t)
+                            (let* ((i (org-babel-get-src-block-info 'light))
+                                   (body (org-babel-expand-noweb-references i))
+                                   (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+                                            "\n"))
+                                   (full (if comment
+                                             (let ((cs (org-babel-tangle-comment-links i)))
+                                                (concat (funcall c-wrap (car cs)) "\n"
+                                                        body "\n"
+                                                        (funcall c-wrap (cadr cs))))
+                                           body)))
+                              (setq expansion (cons sep (cons full expansion)))))
+                        (org-babel-map-src-blocks nil
+                         (let ((i (org-babel-get-src-block-info 'light)))
+                            (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
+                                             (nth 4 i))
+                                         source-name)
+                              (let* ((body (org-babel-expand-noweb-references i))
+                                     (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+                                              "\n"))
+                                     (full (if comment
+                                               (let ((cs (org-babel-tangle-comment-links i)))
+                                                  (concat (funcall c-wrap (car cs)) "\n"
+                                                          body "\n"
+                                                          (funcall c-wrap (cadr cs))))
+                                             body)))
+                                (setq expansion
+                                      (cons sep (cons full expansion)))))))))
+                    (and expansion
+                         (mapconcat #'identity (nreverse (cdr expansion)) "")))
+                  ;; Possibly raise an error if named block doesn't exist.
+                  (if (member lang org-babel-noweb-error-langs)
+                      (error "%s" (concat
+                                   (org-babel-noweb-wrap source-name)
+                                   "could not be resolved (see "
+                                   "`org-babel-noweb-error-langs')"))
+                    "")))
+               "[\n\r]") (concat "\n" prefix))))))
+      (funcall nb-add (buffer-substring index (point-max))))
+    new-body))
+
+(defun org-babel-script-escape (str &optional force)
+  "Safely convert tables into elisp lists."
+  (let ((escaped
+          (if (or force
+                  (and (stringp str)
+                       (> (length str) 2)
+                       (or (and (string-equal "[" (substring str 0 1))
+                                (string-equal "]" (substring str -1)))
+                           (and (string-equal "{" (substring str 0 1))
+                                (string-equal "}" (substring str -1)))
+                           (and (string-equal "(" (substring str 0 1))
+                                (string-equal ")" (substring str -1))))))
+              (org-babel-read
+               (concat
+                "'"
+                (let (in-single in-double out)
+                  (mapc
+                   (lambda (ch)
+                     (setq
+                      out
+                      (case ch
+                        (91 (if (or in-double in-single) ; [
+                                (cons 91 out)
+                              (cons 40 out)))
+                        (93 (if (or in-double in-single) ; ]
+                                (cons 93 out)
+                              (cons 41 out)))
+                        (123 (if (or in-double in-single) ; {
+                                 (cons 123 out)
+                               (cons 40 out)))
+                        (125 (if (or in-double in-single) ; }
+                                 (cons 125 out)
+                               (cons 41 out)))
+                        (44 (if (or in-double in-single) ; ,
+                                (cons 44 out) (cons 32 out)))
+                        (39 (if in-double ; '
+                                (cons 39 out)
+                              (setq in-single (not in-single)) (cons 34 out)))
+                        (34 (if in-single ; "
+                                (append (list 34 32) out)
+                              (setq in-double (not in-double)) (cons 34 out)))
+                        (t  (cons ch out)))))
+                   (string-to-list str))
+                  (apply #'string (reverse out)))))
+            str)))
+    (condition-case nil (org-babel-read escaped) (error escaped))))
+
+(defun org-babel-read (cell &optional inhibit-lisp-eval)
+  "Convert the string value of CELL to a number if appropriate.
+Otherwise if cell looks like lisp (meaning it starts with a
+\"(\", \"'\", \"`\" or a \"[\") then read it as lisp,
+otherwise return it unmodified as a string.  Optional argument
+NO-LISP-EVAL inhibits lisp evaluation for situations in which is
+it not appropriate."
+  (if (and (stringp cell) (not (equal cell "")))
+      (or (org-babel-number-p cell)
+          (if (and (not inhibit-lisp-eval)
+                  (or (member (substring cell 0 1) '("(" "'" "`" "["))
+                      (string= cell "*this*")))
+              (eval (read cell))
+            (if (string= (substring cell 0 1) "\"")
+               (read cell)
+             (progn (set-text-properties 0 (length cell) nil cell) cell))))
+    cell))
+
+(defun org-babel-number-p (string)
+  "If STRING represents a number return its value."
+  (if (and (string-match "[0-9]+" string)
+          (string-match "^-?[0-9]*\\.?[0-9]*$" string)
+           (= (length (substring string (match-beginning 0)
+                                (match-end 0)))
+             (length string)))
+      (string-to-number string)))
+
+(defun org-babel-import-elisp-from-file (file-name &optional separator)
+  "Read the results located at FILE-NAME into an elisp table.
+If the table is trivial, then return it as a scalar."
+  (let (result)
+    (save-window-excursion
+      (with-temp-buffer
+       (condition-case err
+           (progn
+             (org-table-import file-name separator)
+             (delete-file file-name)
+             (setq result (mapcar (lambda (row)
+                                    (mapcar #'org-babel-string-read row))
+                                  (org-table-to-lisp))))
+         (error (message "Error reading results: %s" err) nil)))
+      (if (null (cdr result)) ;; if result is trivial vector, then scalarize it
+         (if (consp (car result))
+             (if (null (cdr (car result)))
+                 (caar result)
+               result)
+           (car result))
+       result))))
+
+(defun org-babel-string-read (cell)
+  "Strip nested \"s from around strings."
+  (org-babel-read (or (and (stringp cell)
+                           (string-match "\\\"\\(.+\\)\\\"" cell)
+                           (match-string 1 cell))
+                      cell) t))
+
+(defun org-babel-chomp (string &optional regexp)
+  "Strip trailing spaces and carriage returns from STRING.
+Default regexp used is \"[ \f\t\n\r\v]\" but can be
+overwritten by specifying a regexp as a second argument."
+  (let ((regexp (or regexp "[ \f\t\n\r\v]")))
+    (while (and (> (length string) 0)
+                (string-match regexp (substring string -1)))
+      (setq string (substring string 0 -1)))
+    string))
+
+(defun org-babel-trim (string &optional regexp)
+  "Strip leading and trailing spaces and carriage returns from STRING.
+Like `org-babel-chomp' only it runs on both the front and back
+of the string."
+  (org-babel-chomp (org-reverse-string
+                    (org-babel-chomp (org-reverse-string string) regexp))
+                   regexp))
+
+(defun org-babel-tramp-handle-call-process-region
+  (start end program &optional delete buffer display &rest args)
+  "Use Tramp to handle `call-process-region'.
+Fixes a bug in `tramp-handle-call-process-region'."
+  (if (and (featurep 'tramp) (file-remote-p default-directory))
+      (let ((tmpfile (tramp-compat-make-temp-file "")))
+       (write-region start end tmpfile)
+       (when delete (delete-region start end))
+       (unwind-protect
+           ;;  (apply 'call-process program tmpfile buffer display args)
+            ;; bug in tramp
+           (apply 'process-file program tmpfile buffer display args)
+         (delete-file tmpfile)))
+    ;; org-babel-call-process-region-original is the original emacs
+    ;; definition.  It is in scope from the let binding in
+    ;; org-babel-execute-src-block
+    (apply org-babel-call-process-region-original
+           start end program delete buffer display args)))
+
+(defun org-babel-local-file-name (file)
+  "Return the local name component of FILE."
+  (if (file-remote-p file)
+      (let (localname)
+       (with-parsed-tramp-file-name file nil
+                                    localname))
+    file))
+
+(defun org-babel-process-file-name (name &optional no-quote-p)
+  "Prepare NAME to be used in an external process.
+If NAME specifies a remote location, the remote portion of the
+name is removed, since in that case the process will be executing
+remotely.  The file name is then processed by `expand-file-name'.
+Unless second argument NO-QUOTE-P is non-nil, the file name is
+additionally processed by `shell-quote-argument'"
+  (let ((f (expand-file-name (org-babel-local-file-name name))))
+    (if no-quote-p f (shell-quote-argument f))))
+
+(defvar org-babel-temporary-directory)
+(unless (or noninteractive (boundp 'org-babel-temporary-directory))
+  (defvar org-babel-temporary-directory
+    (or (and (boundp 'org-babel-temporary-directory)
+            (file-exists-p org-babel-temporary-directory)
+            org-babel-temporary-directory)
+       (make-temp-file "babel-" t))
+    "Directory to hold temporary files created to execute code blocks.
+Used by `org-babel-temp-file'.  This directory will be removed on
+Emacs shutdown."))
+
+(defmacro org-babel-result-cond (result-params scalar-form &rest table-forms)
+  "Call the code to parse raw string results according to RESULT-PARAMS."
+  (declare (indent 1)
+          (debug (form form &rest form)))
+  (org-with-gensyms (params)
+    `(let ((,params ,result-params))
+       (unless (member "none" ,params)
+        (if (or (member "scalar" ,params)
+                (member "verbatim" ,params)
+                (member "html" ,params)
+                (member "code" ,params)
+                (member "pp" ,params)
+                (and (or (member "output" ,params)
+                         (member "raw"    ,params)
+                         (member "org"    ,params)
+                         (member "drawer" ,params))
+                     (not (member "table" ,params))))
+            ,scalar-form
+          ,@table-forms)))))
+(def-edebug-spec org-babel-result-cond (form form body))
+
+(defun org-babel-temp-file (prefix &optional suffix)
+  "Create a temporary file in the `org-babel-temporary-directory'.
+Passes PREFIX and SUFFIX directly to `make-temp-file' with the
+value of `temporary-file-directory' temporarily set to the value
+of `org-babel-temporary-directory'."
+  (if (file-remote-p default-directory)
+      (let ((prefix
+             (concat (file-remote-p default-directory)
+                     (expand-file-name prefix temporary-file-directory))))
+        (make-temp-file prefix nil suffix))
+    (let ((temporary-file-directory
+          (or (and (boundp 'org-babel-temporary-directory)
+                   (file-exists-p org-babel-temporary-directory)
+                   org-babel-temporary-directory)
+              temporary-file-directory)))
+      (make-temp-file prefix nil suffix))))
+
+(defun org-babel-remove-temporary-directory ()
+  "Remove `org-babel-temporary-directory' on Emacs shutdown."
+  (when (and (boundp 'org-babel-temporary-directory)
+            (file-exists-p org-babel-temporary-directory))
+    ;; taken from `delete-directory' in files.el
+    (condition-case nil
+       (progn
+         (mapc (lambda (file)
+                 ;; This test is equivalent to
+                 ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
+                 ;; but more efficient
+                 (if (eq t (car (file-attributes file)))
+                     (delete-directory file)
+                   (delete-file file)))
+               ;; We do not want to delete "." and "..".
+               (directory-files org-babel-temporary-directory 'full
+                                "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
+         (delete-directory org-babel-temporary-directory))
+      (error
+       (message "Failed to remove temporary Org-babel directory %s"
+               (if (boundp 'org-babel-temporary-directory)
+                   org-babel-temporary-directory
+                 "[directory not defined]"))))))
+
+(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)
+
+(provide 'ob-core)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ob-core.el ends here
index d6bbbbce3a85b233e10e3c37d844d309b351ea91..36681d0ad29c203f6378cadf6f9388bbd6728651 100644 (file)
 ;; 3) we are adding the "file" and "cmdline" header arguments
 ;;
 ;; 4) there are no variables (at least for now)
-;;
-;; 5) it depends on a variable defined in org-exp-blocks (namely
-;;    `org-ditaa-jar-path') so be sure you have org-exp-blocks loaded
 
 ;;; Code:
 (require 'ob)
 (require 'org-compat)
 
-(defvar org-ditaa-jar-path) ;; provided by org-exp-blocks
-
 (defvar org-babel-default-header-args:ditaa
   '((:results . "file")
     (:exports . "results")
     (:java . "-Dfile.encoding=UTF-8"))
   "Default arguments for evaluating a ditaa source block.")
 
+(defcustom org-ditaa-jar-path (expand-file-name
+                              "ditaa.jar"
+                              (file-name-as-directory
+                               (expand-file-name
+                                "scripts"
+                                (file-name-as-directory
+                                 (expand-file-name
+                                  "../contrib"
+                                  (file-name-directory (org-find-library-dir "org")))))))
+  "Path to the ditaa jar executable."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-ditaa-java-cmd "java"
+  "Java executable to use when evaluating ditaa blocks."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-ditaa-eps-jar-path
+  (expand-file-name "DitaaEps.jar" (file-name-directory org-ditaa-jar-path))
+  "Path to the DitaaEps.jar executable."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
 (defcustom org-ditaa-jar-option "-jar"
   "Option for the ditaa jar file.
 Do not leave leading or trailing spaces in this string."
@@ -61,24 +82,33 @@ Do not leave leading or trailing spaces in this string."
   "Execute a block of Ditaa code with org-babel.
 This function is called by `org-babel-execute-src-block'."
   (let* ((result-params (split-string (or (cdr (assoc :results params)) "")))
-        (out-file ((lambda (el)
-                     (or el
-                         (error
-                          "ditaa code block requires :file header argument")))
-                   (cdr (assoc :file params))))
+        (out-file (let ((el (cdr (assoc :file params))))
+                     (or el
+                         (error
+                          "ditaa code block requires :file header argument"))))
         (cmdline (cdr (assoc :cmdline params)))
         (java (cdr (assoc :java params)))
         (in-file (org-babel-temp-file "ditaa-"))
-        (cmd (concat "java " java " " org-ditaa-jar-option " "
+        (eps (cdr (assoc :eps params)))
+        (cmd (concat org-babel-ditaa-java-cmd
+                     " " java " " org-ditaa-jar-option " "
                      (shell-quote-argument
-                      (expand-file-name org-ditaa-jar-path))
+                      (expand-file-name
+                       (if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
                      " " cmdline
                      " " (org-babel-process-file-name in-file)
-                     " " (org-babel-process-file-name out-file))))
+                     " " (org-babel-process-file-name out-file)))
+        (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
+                                (cdr (assoc :pdf params))))
+                   (concat
+                    "epstopdf"
+                    " " (org-babel-process-file-name (concat in-file ".eps"))
+                    " -o=" (org-babel-process-file-name out-file)))))
     (unless (file-exists-p org-ditaa-jar-path)
       (error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
     (with-temp-file in-file (insert body))
     (message cmd) (shell-command cmd)
+    (when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd))
     nil)) ;; signal that output has already been written to file
 
 (defun org-babel-prep-session:ditaa (session params)
index b5e78802b2d2c54b302bed642daf6f808d3d0950..7504264137437e86b675a5c586ab9d6a5a3ce117 100644 (file)
@@ -39,7 +39,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 
 (defvar org-babel-default-header-args:dot
   '((:results . "file") (:exports . "results"))
index d6073ca8ef9c6d8f0e783c1f9b7157e28b3bb14e..a30e369ec7ab41511d70dd11527aa51e8e3dcd0c 100644 (file)
@@ -27,7 +27,6 @@
 
 ;;; Code:
 (require 'ob)
-(eval-when-compile (require 'ob-comint))
 
 (defvar org-babel-default-header-args:emacs-lisp
   '((:hlines . "yes") (:colnames . "no"))
 (defun org-babel-execute:emacs-lisp (body params)
   "Execute a block of emacs-lisp code with Babel."
   (save-window-excursion
-    ((lambda (result)
-       (if (or (member "scalar" (cdr (assoc :result-params params)))
-              (member "verbatim" (cdr (assoc :result-params params))))
-          (let ((print-level nil)
-                (print-length nil))
-            (format "%S" result))
-        (org-babel-reassemble-table
-         result
-         (org-babel-pick-name (cdr (assoc :colname-names params))
-                              (cdr (assoc :colnames params)))
-         (org-babel-pick-name (cdr (assoc :rowname-names params))
-                              (cdr (assoc :rownames params))))))
-     (eval (read (format (if (member "output"
-                                    (cdr (assoc :result-params params)))
-                            "(with-output-to-string %s)"
-                          "(progn %s)")
-                        (org-babel-expand-body:emacs-lisp body params)))))))
+    (let ((result
+           (eval (read (format (if (member "output"
+                                           (cdr (assoc :result-params params)))
+                                   "(with-output-to-string %s)"
+                                 "(progn %s)")
+                               (org-babel-expand-body:emacs-lisp
+                                body params))))))
+      (org-babel-result-cond (cdr (assoc :result-params params))
+       (let ((print-level nil)
+              (print-length nil))
+          (if (or (member "scalar" (cdr (assoc :result-params params)))
+                  (member "verbatim" (cdr (assoc :result-params params))))
+              (format "%S" result)
+            (format "%s" result)))
+       (org-babel-reassemble-table
+        result
+         (org-babel-pick-name (cdr (assoc :colname-names params))
+                              (cdr (assoc :colnames params)))
+         (org-babel-pick-name (cdr (assoc :rowname-names params))
+                              (cdr (assoc :rownames params))))))))
 
 (provide 'ob-emacs-lisp)
 
index 22d2bcf288ec5061019a59741b471993ae491d54..85a8c4e31f3c75919426584ea08f6bc270de6c69 100644 (file)
@@ -27,6 +27,7 @@
 ;; shell commands.
 
 ;;; Code:
+(require 'org-macs)
 (eval-when-compile (require 'cl))
 
 (defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
@@ -50,8 +51,8 @@ STDERR with `org-babel-eval-error-notify'."
     (with-temp-buffer
       (insert body)
       (setq exit-code
-           (org-babel-shell-command-on-region
-            (point-min) (point-max) cmd t 'replace err-buff))
+           (org-babel--shell-command-on-region
+            (point-min) (point-max) cmd err-buff))
       (if (or (not (numberp exit-code)) (> exit-code 0))
          (progn
            (with-current-buffer err-buff
@@ -64,79 +65,15 @@ STDERR with `org-babel-eval-error-notify'."
   (with-temp-buffer (insert-file-contents file)
                    (buffer-string)))
 
-(defun org-babel-shell-command-on-region (start end command
-                                               &optional output-buffer replace
-                                               error-buffer display-error-buffer)
+(defun org-babel--shell-command-on-region (start end command error-buffer)
   "Execute COMMAND in an inferior shell with region as input.
 
-Fixes bugs in the emacs 23.1.1 version of `shell-command-on-region'
-
-Normally display output (if any) in temp buffer `*Shell Command Output*';
-Prefix arg means replace the region with it.  Return the exit code of
-COMMAND.
-
-To specify a coding system for converting non-ASCII characters in
-the input and output to the shell command, use
-\\[universal-coding-system-argument] before this command.  By
-default, the input (from the current buffer) is encoded in the
-same coding system that will be used to save the file,
-`buffer-file-coding-system'.  If the output is going to replace
-the region, then it is decoded from that same coding system.
-
-The noninteractive arguments are START, END, COMMAND,
-OUTPUT-BUFFER, REPLACE, ERROR-BUFFER, and DISPLAY-ERROR-BUFFER.
-Noninteractive callers can specify coding systems by binding
-`coding-system-for-read' and `coding-system-for-write'.
-
-If the command generates output, the output may be displayed
-in the echo area or in a buffer.
-If the output is short enough to display in the echo area
-\(determined by the variable `max-mini-window-height' if
-`resize-mini-windows' is non-nil), it is shown there.  Otherwise
-it is displayed in the buffer `*Shell Command Output*'.  The output
-is available in that buffer in both cases.
-
-If there is output and an error, a message about the error
-appears at the end of the output.
-
-If there is no output, or if output is inserted in the current buffer,
-then `*Shell Command Output*' is deleted.
-
-If the optional fourth argument OUTPUT-BUFFER is non-nil,
-that says to put the output in some other buffer.
-If OUTPUT-BUFFER is a buffer or buffer name, put the output there.
-If OUTPUT-BUFFER is not a buffer and not nil,
-insert output in the current buffer.
-In either case, the output is inserted after point (leaving mark after it).
-
-If REPLACE, the optional fifth argument, is non-nil, that means insert
-the output in place of text from START to END, putting point and mark
-around it.
-
-If optional sixth argument ERROR-BUFFER is non-nil, it is a buffer
-or buffer name to which to direct the command's standard error output.
-If it is nil, error output is mingled with regular output.
-If DISPLAY-ERROR-BUFFER is non-nil, display the error buffer if there
-were any errors.  (This is always t, interactively.)
-In an interactive call, the variable `shell-command-default-error-buffer'
-specifies the value of ERROR-BUFFER."
-  (interactive (let (string)
-                (unless (mark)
-                  (error "The mark is not set now, so there is no region"))
-                ;; Do this before calling region-beginning
-                ;; and region-end, in case subprocess output
-                ;; relocates them while we are in the minibuffer.
-                (setq string (read-shell-command "Shell command on region: "))
-                ;; call-interactively recognizes region-beginning and
-                ;; region-end specially, leaving them in the history.
-                (list (region-beginning) (region-end)
-                      string
-                      current-prefix-arg
-                      current-prefix-arg
-                      shell-command-default-error-buffer
-                      t)))
-  (let ((input-file (org-babel-temp-file "input-"))
-       (error-file (if error-buffer (org-babel-temp-file "scor-") nil))
+Stripped down version of shell-command-on-region for internal use
+in Babel only.  This lets us work around errors in the original
+function in various versions of Emacs.
+"
+  (let ((input-file (org-babel-temp-file "ob-input-"))
+       (error-file (if error-buffer (org-babel-temp-file "ob-error-") nil))
        ;; Unfortunately, `executable-find' does not support file name
        ;; handlers.  Therefore, we could use it in the local case
        ;; only.
@@ -154,96 +91,26 @@ specifies the value of ERROR-BUFFER."
     ;; workaround for now.
     (unless (file-remote-p default-directory)
       (delete-file error-file))
-    (if (or replace
-           (and output-buffer
-                (not (or (bufferp output-buffer) (stringp output-buffer)))))
-       ;; Replace specified region with output from command.
-       (let ((swap (and replace (< start end))))
-         ;; Don't muck with mark unless REPLACE says we should.
-         (goto-char start)
-         (and replace (push-mark (point) 'nomsg))
-         (write-region start end input-file)
-         (delete-region start end)
-         (setq exit-status
-               (process-file shell-file-name input-file
-                             (if error-file
-                                 (list output-buffer error-file)
-                               t)
-                             nil shell-command-switch command))
-         ;; It is rude to delete a buffer which the command is not using.
-         ;; (let ((shell-buffer (get-buffer "*Shell Command Output*")))
-         ;;   (and shell-buffer (not (eq shell-buffer (current-buffer)))
-         ;;     (kill-buffer shell-buffer)))
-         ;; Don't muck with mark unless REPLACE says we should.
-         (and replace swap (exchange-point-and-mark)))
-      ;; No prefix argument: put the output in a temp buffer,
-      ;; replacing its entire contents.
-      (let ((buffer (get-buffer-create
-                    (or output-buffer "*Shell Command Output*"))))
-       (unwind-protect
-           (if (eq buffer (current-buffer))
-               ;; If the input is the same buffer as the output,
-               ;; delete everything but the specified region,
-               ;; then replace that region with the output.
-               (progn (setq buffer-read-only nil)
-                      (delete-region (max start end) (point-max))
-                      (delete-region (point-min) (min start end))
-                      (write-region (point-min) (point-max) input-file)
-                      (delete-region (point-min) (point-max))
-                      (setq exit-status
-                            (process-file shell-file-name input-file
-                                          (if error-file
-                                              (list t error-file)
-                                            t)
-                                          nil shell-command-switch command)))
-             ;; Clear the output buffer, then run the command with
-             ;; output there.
-             (let ((directory default-directory))
-               (with-current-buffer buffer
-                 (setq buffer-read-only nil)
-                 (if (not output-buffer)
-                     (setq default-directory directory))
-                 (erase-buffer)))
-             (setq exit-status
-                   (process-file shell-file-name nil
-                                 (if error-file
-                                     (list buffer error-file)
-                                   buffer)
-                                 nil shell-command-switch command)))
-         ;; Report the output.
-         (with-current-buffer buffer
-           (setq mode-line-process
-                 (cond ((null exit-status)
-                        " - Error")
-                       ((stringp exit-status)
-                        (format " - Signal [%s]" exit-status))
-                       ((not (equal 0 exit-status))
-                        (format " - Exit [%d]" exit-status)))))
-         (if (with-current-buffer buffer (> (point-max) (point-min)))
-             ;; There's some output, display it
-             (display-message-or-buffer buffer)
-           ;; No output; error?
-           (let ((output
-                  (if (and error-file
-                           (< 0 (nth 7 (file-attributes error-file))))
-                      "some error output"
-                    "no output")))
-             (cond ((null exit-status)
-                    (message "(Shell command failed with error)"))
-                   ((equal 0 exit-status)
-                    (message "(Shell command succeeded with %s)"
-                             output))
-                   ((stringp exit-status)
-                    (message "(Shell command killed by signal %s)"
-                             exit-status))
-                   (t
-                    (message "(Shell command failed with code %d and %s)"
-                             exit-status output))))
-           ;; Don't kill: there might be useful info in the undo-log.
-           ;; (kill-buffer buffer)
-           ))))
-
-    (when (and input-file (file-exists-p input-file))
+    ;; we always call this with 'replace, remove conditional
+    ;; Replace specified region with output from command.
+    (let ((swap (< start end)))
+      (goto-char start)
+      (push-mark (point) 'nomsg)
+      (write-region start end input-file)
+      (delete-region start end)
+      (setq exit-status
+           (process-file shell-file-name input-file
+                         (if error-file
+                             (list t error-file)
+                           t)
+                         nil shell-command-switch command))
+      (when swap (exchange-point-and-mark)))
+
+    (when (and input-file (file-exists-p input-file)
+              ;; bind org-babel--debug-input around the call to keep
+              ;; the temporary input files available for inspection
+              (not (when (boundp 'org-babel--debug-input)
+                     org-babel--debug-input)))
       (delete-file input-file))
 
     (when (and error-file (file-exists-p error-file))
@@ -258,8 +125,7 @@ specifies the value of ERROR-BUFFER."
              (format-insert-file error-file nil)
              ;; Put point after the inserted errors.
              (goto-char (- (point-max) pos-from-end)))
-           (and display-error-buffer
-                (display-buffer (current-buffer)))))
+           (current-buffer)))
       (delete-file error-file))
     exit-status))
 
index 37a9f71cf591beae0a44df9c9dd1dbdb52a4f629..d6d4566c29f4a04a6202d3fafa766b6f5d162b32 100644 (file)
@@ -23,8 +23,7 @@
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Code:
-(require 'ob)
-(require 'org-exp-blocks)
+(require 'ob-core)
 (eval-when-compile
   (require 'cl))
 
 
 (declare-function org-babel-lob-get-info "ob-lob" ())
 (declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
+(declare-function org-between-regexps-p "org"
+                 (start-re end-re &optional lim-up lim-down))
+(declare-function org-get-indentation "org" (&optional line))
 (declare-function org-heading-components "org" ())
+(declare-function org-in-block-p "org" (names))
+(declare-function org-in-verbatim-emphasis "org" ())
 (declare-function org-link-search "org" (s &optional type avoid-pos stealth))
 (declare-function org-fill-template "org" (template alist))
-(declare-function org-in-verbatim-emphasis "org" ())
-(declare-function org-in-block-p "org" (names))
-(declare-function org-between-regexps-p "org" (start-re end-re &optional lim-up lim-down))
-
-(add-to-list 'org-export-interblocks '(src org-babel-exp-non-block-elements))
-(org-export-blocks-add-block '(src org-babel-exp-src-block nil))
+(declare-function org-split-string "org" (string &optional separators))
+(declare-function org-element-at-point "org-element" (&optional keep-trail))
+(declare-function org-element-context "org-element" ())
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
+(declare-function org-escape-code-in-string "org-src" (s))
 
 (defcustom org-export-babel-evaluate t
   "Switch controlling code evaluation during export.
 When set to nil no code will be evaluated as part of the export
-process."
+process.  When set to 'inline-only, only inline code blocks will
+be executed."
   :group 'org-babel
   :version "24.1"
-  :type 'boolean)
+  :type '(choice (const :tag "Never" nil)
+                (const :tag "Only inline code" inline-only)
+                (const :tag "Always" t)))
 (put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
 
 (defun org-babel-exp-get-export-buffer ()
@@ -62,6 +69,8 @@ process."
    ('otherwise
     (error "Requested export buffer when `org-current-export-file' is nil"))))
 
+(defvar org-link-search-inhibit-query)
+
 (defmacro org-babel-exp-in-export-file (lang &rest body)
   (declare (indent 1))
   `(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang)))
@@ -86,10 +95,10 @@ process."
        results)))
 (def-edebug-spec org-babel-exp-in-export-file (form body))
 
-(defun org-babel-exp-src-block (body &rest headers)
+(defun org-babel-exp-src-block (&rest headers)
   "Process source block for export.
-Depending on the 'export' headers argument in replace the source
-code block with...
+Depending on the 'export' headers argument, replace the source
+code block like this:
 
 both ---- display the code and the results
 
@@ -99,11 +108,12 @@ code ---- the default, display the code inside the block but do
 results - just like none only the block is run on export ensuring
           that it's results are present in the org-mode buffer
 
-none ----- do not display either code or results upon export"
+none ---- do not display either code or results upon export
+
+Assume point is at the beginning of block's starting line."
   (interactive)
   (unless noninteractive (message "org-babel-exp processing..."))
   (save-excursion
-    (goto-char (match-beginning 0))
     (let* ((info (org-babel-get-src-block-info 'light))
           (lang (nth 0 info))
           (raw-params (nth 2 info)) hash)
@@ -114,11 +124,11 @@ none ----- do not display either code or results upon export"
          (org-babel-exp-in-export-file lang
            (setf (nth 2 info)
                  (org-babel-process-params
-                  (org-babel-merge-params
-                   org-babel-default-header-args
-                   (org-babel-params-from-properties lang)
-                   (if (boundp lang-headers) (eval lang-headers) nil)
-                   raw-params))))
+                  (apply #'org-babel-merge-params
+                         org-babel-default-header-args
+                         (if (boundp lang-headers) (eval lang-headers) nil)
+                         (append (org-babel-params-from-properties lang)
+                                 (list raw-params))))))
          (setf hash (org-babel-sha1-hash info)))
        (org-babel-exp-do-export info 'block hash)))))
 
@@ -149,66 +159,156 @@ this template."
       (let ((m (make-marker)))
        (set-marker m end (current-buffer))
        (setq end m)))
-    (let ((rx (concat "\\("  org-babel-inline-src-block-regexp
+    (let ((rx (concat "\\(?:"  org-babel-inline-src-block-regexp
                      "\\|" org-babel-lob-one-liner-regexp "\\)")))
-      (while (and (< (point) (marker-position end))
-                 (re-search-forward rx end t))
-       (if (save-excursion
-             (goto-char (match-beginning 0))
-             (looking-at org-babel-inline-src-block-regexp))
-           (progn
-             (forward-char 1)
-             (let* ((info (save-match-data
-                            (org-babel-parse-inline-src-block-match)))
-                    (params (nth 2 info)))
-               (save-match-data
-                 (goto-char (match-beginning 2))
-                 (unless (org-babel-in-example-or-verbatim)
-                   ;; expand noweb references in the original file
-                   (setf (nth 1 info)
-                         (if (and (cdr (assoc :noweb params))
-                                  (string= "yes" (cdr (assoc :noweb params))))
-                             (org-babel-expand-noweb-references
-                              info (org-babel-exp-get-export-buffer))
-                           (nth 1 info)))
-                   (let ((code-replacement (save-match-data
-                                             (org-babel-exp-do-export
-                                              info 'inline))))
-                     (if code-replacement
-                         (progn (replace-match code-replacement nil nil nil 1)
-                                (delete-char 1))
-                       (org-babel-examplize-region (match-beginning 1)
-                                                   (match-end 1))
-                       (forward-char 2)))))))
-         (unless (org-babel-in-example-or-verbatim)
-           (let* ((lob-info (org-babel-lob-get-info))
-                  (inlinep (match-string 11))
-                  (inline-start (match-end 11))
-                  (inline-end (match-end 0))
-                  (results (save-match-data
-                             (org-babel-exp-do-export
-                              (list "emacs-lisp" "results"
-                                    (org-babel-merge-params
-                                     org-babel-default-header-args
-                                     org-babel-default-lob-header-args
-                                     (org-babel-params-from-properties)
-                                     (org-babel-parse-header-arguments
-                                      (org-no-properties
-                                       (concat ":var results="
-                                               (mapconcat #'identity
-                                                          (butlast lob-info)
-                                                          " ")))))
-                                    "" nil (car (last lob-info)))
-                              'lob)))
-                  (rep (org-fill-template
-                        org-babel-exp-call-line-template
-                        `(("line"  . ,(nth 0 lob-info))))))
-             (if inlinep
-                 (save-excursion
-                   (goto-char inline-start)
-                   (delete-region inline-start inline-end)
-                   (insert rep))
-               (replace-match rep t t)))))))))
+      (while (re-search-forward rx end t)
+       (save-excursion
+         (let* ((element (save-excursion
+                           ;; If match is inline, point is at its
+                           ;; end.  Move backward so
+                           ;; `org-element-context' can get the
+                           ;; object, not the following one.
+                           (backward-char)
+                           (save-match-data (org-element-context))))
+                (type (org-element-type element)))
+           (when (memq type '(babel-call inline-babel-call inline-src-block))
+             (let ((beg-el (org-element-property :begin element))
+                   (end-el (org-element-property :end element)))
+               (case type
+                 (inline-src-block
+                  (let* ((info (org-babel-parse-inline-src-block-match))
+                         (params (nth 2 info)))
+                    (setf (nth 1 info)
+                          (if (and (cdr (assoc :noweb params))
+                                   (string= "yes" (cdr (assoc :noweb params))))
+                              (org-babel-expand-noweb-references
+                               info (org-babel-exp-get-export-buffer))
+                            (nth 1 info)))
+                    (goto-char beg-el)
+                    (let ((replacement (org-babel-exp-do-export info 'inline)))
+                      (if (equal replacement "")
+                          ;; Replacement code is empty: completely
+                          ;; remove inline src block, including extra
+                          ;; white space that might have been created
+                          ;; when inserting results.
+                          (delete-region beg-el
+                                         (progn (goto-char end-el)
+                                                (skip-chars-forward " \t")
+                                                (point)))
+                        ;; Otherwise: remove inline src block but
+                        ;; preserve following white spaces.  Then
+                        ;; insert value.
+                        (delete-region beg-el
+                                       (progn (goto-char end-el)
+                                              (skip-chars-backward " \t")
+                                              (point)))
+                        (insert replacement)))))
+                 ((babel-call inline-babel-call)
+                  (let* ((lob-info (org-babel-lob-get-info))
+                         (results
+                          (org-babel-exp-do-export
+                           (list "emacs-lisp" "results"
+                                 (apply #'org-babel-merge-params
+                                        org-babel-default-header-args
+                                        org-babel-default-lob-header-args
+                                        (append
+                                         (org-babel-params-from-properties)
+                                         (list
+                                          (org-babel-parse-header-arguments
+                                           (org-no-properties
+                                            (concat
+                                             ":var results="
+                                             (mapconcat 'identity
+                                                        (butlast lob-info 2)
+                                                        " ")))))))
+                                 "" (nth 3 lob-info) (nth 2 lob-info))
+                           'lob))
+                         (rep (org-fill-template
+                               org-babel-exp-call-line-template
+                               `(("line"  . ,(nth 0 lob-info))))))
+                    ;; If replacement is empty, completely remove the
+                    ;; object/element, including any extra white space
+                    ;; that might have been created when including
+                    ;; results.
+                    (if (equal rep "")
+                        (delete-region
+                         beg-el
+                         (progn (goto-char end-el)
+                                (if (not (eq type 'babel-call))
+                                    (progn (skip-chars-forward " \t") (point))
+                                  (skip-chars-forward " \r\t\n")
+                                  (line-beginning-position))))
+                      ;; Otherwise, preserve following white
+                      ;; spaces/newlines and then, insert replacement
+                      ;; string.
+                      (goto-char beg-el)
+                      (delete-region beg-el
+                                     (progn (goto-char end-el)
+                                            (skip-chars-backward " \r\t\n")
+                                            (point)))
+                      (insert rep)))))))))))))
+
+(defvar org-src-preserve-indentation)  ; From org-src.el
+(defun org-babel-exp-process-buffer ()
+  "Execute all blocks in visible part of buffer."
+  (interactive)
+  (save-window-excursion
+    (let ((case-fold-search t)
+         (pos (point-min)))
+      (goto-char pos)
+      (while (re-search-forward "^[ \t]*#\\+BEGIN_SRC" nil t)
+        (let ((element (save-match-data (org-element-at-point))))
+          (when (eq (org-element-type element) 'src-block)
+            (let* ((match-start (copy-marker (match-beginning 0)))
+                   (begin (copy-marker (org-element-property :begin element)))
+                   ;; Make sure we don't remove any blank lines after
+                   ;; the block when replacing it.
+                   (block-end (save-excursion
+                               (goto-char (org-element-property :end element))
+                               (skip-chars-backward " \r\t\n")
+                               (copy-marker (line-end-position))))
+                   (ind (org-get-indentation))
+                   (headers
+                   (cons
+                    (org-element-property :language element)
+                    (let ((params (org-element-property :parameters element)))
+                      (and params (org-split-string params "[ \t]+"))))))
+              ;; Execute all non-block elements between POS and
+              ;; current block.
+              (org-babel-exp-non-block-elements pos begin)
+             ;; Take care of matched block: compute replacement
+             ;; string. In particular, a nil REPLACEMENT means the
+             ;; block should be left as-is while an empty string
+             ;; should remove the block.
+              (let ((replacement (progn (goto-char match-start)
+                                       (org-babel-exp-src-block headers))))
+                (cond ((not replacement) (goto-char block-end))
+                     ((equal replacement "")
+                      (delete-region begin
+                                     (progn (goto-char block-end)
+                                            (skip-chars-forward " \r\t\n")
+                                            (if (eobp) (point)
+                                              (line-beginning-position)))))
+                     (t
+                      (goto-char match-start)
+                      (delete-region (point) block-end)
+                      (insert replacement)
+                      (if (org-element-property :preserve-indent element)
+                          ;; Indent only the code block markers.
+                          (save-excursion (skip-chars-backward " \r\t\n")
+                                          (indent-line-to ind)
+                                          (goto-char match-start)
+                                          (indent-line-to ind))
+                        ;; Indent everything.
+                        (indent-rigidly match-start (point) ind)))))
+             (setq pos (line-beginning-position))
+              ;; Cleanup markers.
+             (set-marker match-start nil)
+             (set-marker begin nil)
+              (set-marker block-end nil)))))
+      ;; Eventually execute all non-block Babel elements between last
+      ;; src-block and end of buffer.
+      (org-babel-exp-non-block-elements pos (point-max)))))
 
 (defun org-babel-in-example-or-verbatim ()
   "Return true if point is in example or verbatim code.
@@ -269,14 +369,12 @@ replaced with its value."
   (org-fill-template
    org-babel-exp-code-template
    `(("lang"  . ,(nth 0 info))
-     ("body"  . ,(if (string= (nth 0 info) "org")
-                    (replace-regexp-in-string "^" "," (nth 1 info))
-                  (nth 1 info)))
+     ("body"  . ,(org-escape-code-in-string (nth 1 info)))
      ,@(mapcar (lambda (pair)
                 (cons (substring (symbol-name (car pair)) 1)
                       (format "%S" (cdr pair))))
               (nth 2 info))
-     ("flags" . ,((lambda (f) (when f (concat " " f))) (nth 3 info)))
+     ("flags" . ,(let ((f (nth 3 info))) (when f (concat " " f))))
      ("name"  . ,(or (nth 4 info) "")))))
 
 (defun org-babel-exp-results (info type &optional silent hash)
@@ -285,14 +383,17 @@ Results are prepared in a manner suitable for export by org-mode.
 This function is called by `org-babel-exp-do-export'.  The code
 block will be evaluated.  Optional argument SILENT can be used to
 inhibit insertion of results into the buffer."
-  (when (and org-export-babel-evaluate
+  (when (and (or (eq org-export-babel-evaluate t)
+                (and (eq type 'inline)
+                     (eq org-export-babel-evaluate 'inline-only)))
             (not (and hash (equal hash (org-babel-current-result-hash)))))
     (let ((lang (nth 0 info))
          (body (if (org-babel-noweb-p (nth 2 info) :eval)
                    (org-babel-expand-noweb-references
                     info (org-babel-exp-get-export-buffer))
                  (nth 1 info)))
-         (info (copy-sequence info)))
+         (info (copy-sequence info))
+         (org-babel-current-src-block-location (point-marker)))
       ;; skip code blocks which we can't evaluate
       (when (fboundp (intern (concat "org-babel-execute:" lang)))
        (org-babel-eval-wipe-error-buffer)
@@ -318,10 +419,10 @@ inhibit insertion of results into the buffer."
           ((equal type 'lob)
            (save-excursion
              (re-search-backward org-babel-lob-one-liner-regexp nil t)
-             (org-babel-execute-src-block nil info)))))))))
-
-(provide 'ob-exp)
+             (let (org-confirm-babel-evaluate)
+               (org-babel-execute-src-block nil info))))))))))
 
 
+(provide 'ob-exp)
 
 ;;; ob-exp.el ends here
index 8d5012fb82dbcda467edb408976fdf9fb54dfbd8..61cb19a56c510e1e0de0d3d11f389af41030efa7 100644 (file)
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 (require 'cc-mode)
 
 (declare-function org-entry-get "org"
                  (pom property &optional inherit literal-nil))
+(declare-function org-every "org" (pred seq))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("fortran" . "F90"))
                     (mapconcat 'identity
                                (if (listp flags) flags (list flags)) " ")
                     (org-babel-process-file-name tmp-src-file)) ""))))
-    ((lambda (results)
-       (org-babel-reassemble-table
-       (if (member "vector" (cdr (assoc :result-params params)))
-           (let ((tmp-file (org-babel-temp-file "f-")))
-             (with-temp-file tmp-file (insert results))
-             (org-babel-import-elisp-from-file tmp-file))
-         (org-babel-read results))
-       (org-babel-pick-name
-        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
-       (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
-     (org-babel-trim
-      (org-babel-eval
-       (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))))
+    (let ((results
+           (org-babel-trim
+            (org-babel-eval
+             (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))
+      (org-babel-reassemble-table
+       (org-babel-result-cond (cdr (assoc :result-params params))
+        (org-babel-read results)
+         (let ((tmp-file (org-babel-temp-file "f-")))
+           (with-temp-file tmp-file (insert results))
+           (org-babel-import-elisp-from-file tmp-file)))
+       (org-babel-pick-name
+        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
 
 (defun org-babel-expand-body:fortran (body params)
   "Expand a block of fortran or fortran code with org-babel according to
@@ -144,6 +144,12 @@ of the same value."
      ((stringp val)
       (format "character(len=%d), parameter ::  %S = '%s'\n"
               (length val) var val))
+     ;; val is a matrix
+     ((and (listp val) (org-every #'listp val))
+      (format "real, parameter :: %S(%d,%d) = transpose( reshape( %s , (/ %d, %d /) ) )\n"
+             var (length val) (length (car val)) 
+             (org-babel-fortran-transform-list val)
+             (length (car val)) (length val)))
      ((listp val)
       (format "real, parameter :: %S(%d) = %s\n"
              var (length val) (org-babel-fortran-transform-list val)))
index 488d2508e6d0f05f6f2e4f1a272155ebc0f1c12f..cc9186b1adcd2e9bdc839c9b38286e5f99d0997e 100644 (file)
@@ -39,8 +39,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
 (eval-when-compile (require 'cl))
 
 (declare-function org-time-string-to-time "org" (s))
   '((:results . "file") (:exports . "results") (:session . nil))
   "Default arguments to use when evaluating a gnuplot source block.")
 
+(defvar org-babel-header-args:gnuplot
+  '((title     . :any)
+    (lines     . :any)
+    (sets      . :any)
+    (x-labels  . :any)
+    (y-labels  . :any)
+    (timefmt   . :any)
+    (time-ind  . :any)
+    (missing   . :any)
+    (term       . :any))
+  "Gnuplot specific header args.")
+
 (defvar org-babel-gnuplot-timestamp-fmt nil)
 
+(defvar *org-babel-gnuplot-missing* nil)
+
+(defcustom *org-babel-gnuplot-terms*
+  '((eps . "postscript eps"))
+  "List of file extensions and the associated gnuplot terminal."
+  :group 'org-babel
+  :type '(repeat (cons (symbol :tag "File extension")
+                      (string :tag "Gnuplot terminal"))))
+
 (defun org-babel-gnuplot-process-vars (params)
   "Extract variables from PARAMS and process the variables.
 Dumps all vectors into files and returns an association list
 of variable names and the related value to be used in the gnuplot
 code."
-  (mapcar
-   (lambda (pair)
-     (cons
-      (car pair) ;; variable name
-      (if (listp (cdr pair)) ;; variable value
-          (org-babel-gnuplot-table-to-data
-           (cdr pair) (org-babel-temp-file "gnuplot-") params)
-        (cdr pair))))
-   (mapcar #'cdr (org-babel-get-header params :var))))
+  (let ((*org-babel-gnuplot-missing* (cdr (assoc :missing params))))
+    (mapcar
+     (lambda (pair)
+       (cons
+       (car pair) ;; variable name
+       (if (listp (cdr pair)) ;; variable value
+           (org-babel-gnuplot-table-to-data
+            (cdr pair) (org-babel-temp-file "gnuplot-") params)
+         (cdr pair))))
+     (mapcar #'cdr (org-babel-get-header params :var)))))
 
 (defun org-babel-expand-body:gnuplot (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (save-window-excursion
     (let* ((vars (org-babel-gnuplot-process-vars params))
            (out-file (cdr (assoc :file params)))
-           (term (or (cdr (assoc :term params))
-                     (when out-file (file-name-extension out-file))))
+          (prologue (cdr (assoc :prologue params)))
+          (epilogue (cdr (assoc :epilogue params)))
+          (term (or (cdr (assoc :term params))
+                     (when out-file
+                      (let ((ext (file-name-extension out-file)))
+                        (or (cdr (assoc (intern (downcase ext))
+                                        *org-babel-gnuplot-terms*))
+                            ext)))))
            (cmdline (cdr (assoc :cmdline params)))
-           (title (plist-get params :title))
-           (lines (plist-get params :line))
-           (sets (plist-get params :set))
-           (x-labels (plist-get params :xlabels))
-           (y-labels (plist-get params :ylabels))
-           (timefmt (plist-get params :timefmt))
-           (time-ind (or (plist-get params :timeind)
+           (title (cdr (assoc :title params)))
+           (lines (cdr (assoc :line params)))
+           (sets (cdr (assoc :set params)))
+           (x-labels (cdr (assoc :xlabels params)))
+           (y-labels (cdr (assoc :ylabels params)))
+           (timefmt (cdr (assoc :timefmt params)))
+           (time-ind (or (cdr (assoc :timeind params))
                          (when timefmt 1)))
+          (missing (cdr (assoc :missing params)))
           (add-to-body (lambda (text) (setq body (concat text "\n" body))))
            output)
       ;; append header argument settings to body
-      (when title (funcall add-to-body (format "set title '%s'" title))) ;; title
-      (when lines (mapc (lambda (el) (funcall add-to-body el)) lines)) ;; line
+      (when title (funcall add-to-body (format "set title '%s'" title)))
+      (when lines (mapc (lambda (el) (funcall add-to-body el)) lines))
+      (when missing
+       (funcall add-to-body (format "set datafile missing '%s'" missing)))
       (when sets
        (mapc (lambda (el) (funcall add-to-body (format "set %s" el))) sets))
       (when x-labels
        (funcall add-to-body
                 (format "set xtics (%s)"
                         (mapconcat (lambda (pair)
-                                     (format "\"%s\" %d" (cdr pair) (car pair)))
+                                     (format "\"%s\" %d"
+                                             (cdr pair) (car pair)))
                                    x-labels ", "))))
       (when y-labels
        (funcall add-to-body
                 (format "set ytics (%s)"
                         (mapconcat (lambda (pair)
-                                     (format "\"%s\" %d" (cdr pair) (car pair)))
+                                     (format "\"%s\" %d"
+                                             (cdr pair) (car pair)))
                                    y-labels ", "))))
       (when time-ind
        (funcall add-to-body "set xdata time")
        (funcall add-to-body (concat "set timefmt \""
                                     (or timefmt
                                         "%Y-%m-%d-%H:%M:%S") "\"")))
-      (when out-file (funcall add-to-body (format "set output \"%s\"" out-file)))
+      (when out-file
+       ;; set the terminal at the top of the block
+       (funcall add-to-body (format "set output \"%s\"" out-file))
+       ;; and close the terminal at the bottom of the block
+       (setq body (concat body "\nset output\n")))
       (when term (funcall add-to-body (format "set term %s" term)))
       ;; insert variables into code body: this should happen last
       ;; placing the variables at the *top* of the code in case their
       ;; values are used later
-      (funcall add-to-body (mapconcat #'identity
-                                     (org-babel-variable-assignments:gnuplot params)
-                                     "\n"))
+      (funcall add-to-body
+              (mapconcat #'identity
+                         (org-babel-variable-assignments:gnuplot params)
+                         "\n"))
       ;; replace any variable names preceded by '$' with the actual
       ;; value of the variable
       (mapc (lambda (pair)
              (setq body (replace-regexp-in-string
                          (format "\\$%s" (car pair)) (cdr pair) body)))
-           vars))
+           vars)
+      (when prologue (funcall add-to-body prologue))
+      (when epilogue (setq body (concat body "\n" epilogue))))
     body))
 
 (defun org-babel-execute:gnuplot (body params)
@@ -201,7 +239,8 @@ then create one.  Return the initialized session.  The current
 
 (defun org-babel-gnuplot-quote-timestamp-field (s)
   "Convert S from timestamp to Unix time and export to gnuplot."
-  (format-time-string org-babel-gnuplot-timestamp-fmt (org-time-string-to-time s)))
+  (format-time-string org-babel-gnuplot-timestamp-fmt
+                     (org-time-string-to-time s)))
 
 (defvar org-table-number-regexp)
 (defvar org-ts-regexp3)
@@ -212,7 +251,12 @@ then create one.  Return the initialized session.  The current
   (if (string-match org-table-number-regexp s) s
     (if (string-match org-ts-regexp3 s)
        (org-babel-gnuplot-quote-timestamp-field s)
-      (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))))
+      (if (zerop (length s))
+         (or *org-babel-gnuplot-missing* s)
+       (if (string-match "[ \"]" "?")
+           (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"")
+                   "\"")
+         s)))))
 
 (defun org-babel-gnuplot-table-to-data (table data-file params)
   "Export TABLE to DATA-FILE in a format readable by gnuplot.
index eca6d829c153e891555dcab49c1196f807c7b666..6c9fed14fa37477f61c8a05838b085754b693ec5 100644 (file)
@@ -40,7 +40,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-comint)
 (require 'comint)
 (eval-when-compile (require 'cl))
 
@@ -53,7 +52,8 @@
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("haskell" . "hs"))
 
-(defvar org-babel-default-header-args:haskell '())
+(defvar org-babel-default-header-args:haskell
+  '((:padlines . "no")))
 
 (defvar org-babel-haskell-lhs2tex-command "lhs2tex")
 
                    (cdr (member org-babel-haskell-eoe
                                 (reverse (mapcar #'org-babel-trim raw)))))))
     (org-babel-reassemble-table
-     (cond
-      ((equal result-type 'output)
-       (mapconcat #'identity (reverse (cdr results)) "\n"))
-      ((equal result-type 'value)
-       (org-babel-haskell-table-or-string (car results))))
+     (let ((result
+            (case result-type
+              (output (mapconcat #'identity (reverse (cdr results)) "\n"))
+              (value (car results)))))
+       (org-babel-result-cond (cdr (assoc :result-params params))
+        result (org-babel-haskell-table-or-string result)))
      (org-babel-pick-name (cdr (assoc :colname-names params))
                          (cdr (assoc :colname-names params)))
      (org-babel-pick-name (cdr (assoc :rowname-names params))
@@ -147,8 +148,10 @@ specifying a variable of the same value."
     (format "%S" var)))
 
 (defvar org-src-preserve-indentation)
-(declare-function org-export-as-latex "org-latex"
-                 (arg &optional ext-plist to-buffer body-only pub-dir))
+(defvar org-export-copy-to-kill-ring)
+(declare-function org-export-to-file "ox"
+                 (backend file
+                          &optional async subtreep visible-only body-only ext-plist))
 (defun org-babel-haskell-export-to-lhs (&optional arg)
   "Export to a .lhs file with all haskell code blocks escaped.
 When called with a prefix argument the resulting
@@ -192,7 +195,11 @@ constructs (header arguments, no-web syntax etc...) are ignored."
         (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
     (save-excursion
       ;; export to latex w/org and save as .lhs
-      (find-file tmp-org-file) (funcall 'org-export-as-latex nil)
+      (require 'ox-latex)
+      (find-file tmp-org-file)
+      ;; Ensure we do not clutter kill ring with incomplete results.
+      (let (org-export-copy-to-kill-ring)
+       (org-export-to-file 'latex tmp-tex-file))
       (kill-buffer nil)
       (delete-file tmp-org-file)
       (find-file tmp-tex-file)
index d4686a98eeecb788be8fb96fc643f55ffcd7099b..5368ff51598f0ad403b101a4ba1cc4f0190f80cd 100644 (file)
@@ -33,9 +33,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
@@ -97,12 +94,11 @@ in BODY as elisp."
     (value (let* ((src-file (org-babel-temp-file "io-"))
                   (wrapper (format org-babel-io-wrapper-method body)))
              (with-temp-file src-file (insert wrapper))
-             ((lambda (raw)
-                (if (member "code" result-params)
-                    raw
-                  (org-babel-io-table-or-string raw)))
-              (org-babel-eval
-               (concat org-babel-io-command " " src-file) ""))))))
+             (let ((raw (org-babel-eval
+                         (concat org-babel-io-command " " src-file) "")))
+               (org-babel-result-cond result-params
+                raw
+                 (org-babel-io-table-or-string raw)))))))
 
 
 (defun org-babel-prep-session:io (session params)
index 96128ed1520d7dcf447319495c3c508a5973f820..37ac8daea5d15f3c2c8dbeac0daa8d24c99eb7aa 100644 (file)
@@ -28,7 +28,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("java" . "java"))
     ;; created package-name directories if missing
     (unless (or (not packagename) (file-exists-p packagename))
       (make-directory packagename 'parents))
-    ((lambda (results)
-       (org-babel-reassemble-table
-       (if (member "vector" (cdr (assoc :result-params params)))
-           (let ((tmp-file (org-babel-temp-file "c-")))
-             (with-temp-file tmp-file (insert results))
-             (org-babel-import-elisp-from-file tmp-file))
-         (org-babel-read results))
-       (org-babel-pick-name
-        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
-       (org-babel-pick-name
-        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
-     (org-babel-eval (concat org-babel-java-command
-                            " " cmdline " " classname) ""))))
+    (let ((results (org-babel-eval (concat org-babel-java-command
+                                           " " cmdline " " classname) "")))
+      (org-babel-reassemble-table
+       (org-babel-result-cond (cdr (assoc :result-params params))
+        (org-babel-read results)
+         (let ((tmp-file (org-babel-temp-file "c-")))
+           (with-temp-file tmp-file (insert results))
+           (org-babel-import-elisp-from-file tmp-file)))
+       (org-babel-pick-name
+        (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
+       (org-babel-pick-name
+        (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
 
 (provide 'ob-java)
 
index 4e4c3abfa158dc88f34588974d374250fe6e7035..78914bc2c6676c63a69e1304e636a7eef9279b9d 100644 (file)
@@ -39,9 +39,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (declare-function run-mozilla "ext:moz" (arg))
@@ -68,30 +65,32 @@ This function is called by `org-babel-execute-src-block'"
   (let* ((org-babel-js-cmd (or (cdr (assoc :cmd params)) org-babel-js-cmd))
          (result-type (cdr (assoc :result-type params)))
          (full-body (org-babel-expand-body:generic
-                    body params (org-babel-variable-assignments:js params))))
-    (org-babel-js-read
-     (if (not (string= (cdr (assoc :session params)) "none"))
-        ;; session evaluation
-         (let ((session (org-babel-prep-session:js
-                        (cdr (assoc :session params)) params)))
-          (nth 1
-               (org-babel-comint-with-output
-                   (session (format "%S" org-babel-js-eoe) t body)
-                 (mapc
-                  (lambda (line)
-                    (insert (org-babel-chomp line)) (comint-send-input nil t))
-                  (list body (format "%S" org-babel-js-eoe))))))
-       ;; external evaluation
-       (let ((script-file (org-babel-temp-file "js-script-")))
-         (with-temp-file script-file
-           (insert
-            ;; return the value or the output
-            (if (string= result-type "value")
-                (format org-babel-js-function-wrapper full-body)
-              full-body)))
-         (org-babel-eval
-         (format "%s %s" org-babel-js-cmd
-                 (org-babel-process-file-name script-file)) ""))))))
+                    body params (org-babel-variable-assignments:js params)))
+        (result (if (not (string= (cdr (assoc :session params)) "none"))
+                    ;; session evaluation
+                    (let ((session (org-babel-prep-session:js
+                                    (cdr (assoc :session params)) params)))
+                      (nth 1
+                           (org-babel-comint-with-output
+                               (session (format "%S" org-babel-js-eoe) t body)
+                             (mapc
+                              (lambda (line)
+                                (insert (org-babel-chomp line))
+                                (comint-send-input nil t))
+                              (list body (format "%S" org-babel-js-eoe))))))
+                  ;; external evaluation
+                  (let ((script-file (org-babel-temp-file "js-script-")))
+                    (with-temp-file script-file
+                      (insert
+                       ;; return the value or the output
+                       (if (string= result-type "value")
+                           (format org-babel-js-function-wrapper full-body)
+                         full-body)))
+                    (org-babel-eval
+                     (format "%s %s" org-babel-js-cmd
+                             (org-babel-process-file-name script-file)) "")))))
+    (org-babel-result-cond (cdr (assoc :result-params params))
+      result (org-babel-js-read result))))
 
 (defun org-babel-js-read (results)
   "Convert RESULTS into an appropriate elisp value.
index 01a54ca87d33ccfe80544d1285ae7544f4e54fc2..6cc7387e16ac372e194cc8d594216eebfc72b6c4 100644 (file)
@@ -29,7 +29,7 @@
 ;; functions and their associated keys.
 
 ;;; Code:
-(require 'ob)
+(require 'ob-core)
 
 (defvar org-babel-key-prefix "\C-c\C-v"
   "The key prefix for Babel interactive key-bindings.
index 104f971c678d788f9a18030e6ab7d9b58d742abe..edc9fe8813fdfb70541fcdbeb37ca8e64941266c 100644 (file)
 (declare-function org-create-formula-image "org" (string tofile options buffer))
 (declare-function org-splice-latex-header "org"
                  (tpl def-pkg pkg snippets-p &optional extra))
-(declare-function org-export-latex-fix-inputenc "org-latex" ())
+(declare-function org-latex-guess-inputenc "ox-latex" (header))
+(declare-function org-latex-compile "ox-latex" (file))
+
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
 
-(defvar org-format-latex-header)
-(defvar org-format-latex-header-extra)
-(defvar org-export-latex-packages-alist)
-(defvar org-export-latex-default-packages-alist)
-(defvar org-export-pdf-logfiles)
-(defvar org-latex-to-pdf-process)
-(defvar org-export-pdf-remove-logfiles)
-(defvar org-format-latex-options)
-(defvar org-export-latex-packages-alist)
+(defvar org-format-latex-header)         ; From org.el
+(defvar org-format-latex-options)        ; From org.el
+(defvar org-latex-default-packages-alist) ; From org.el
+(defvar org-latex-packages-alist)        ; From org.el
 
 (defvar org-babel-default-header-args:latex
   '((:results . "latex") (:exports . "results"))
   "Default arguments to use when evaluating a LaTeX source block.")
 
+(defcustom org-babel-latex-htlatex nil
+  "The htlatex command to enable conversion of latex to SVG or HTML."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-latex-htlatex-packages
+  '("[usenames]{color}" "{tikz}" "{color}" "{listings}" "{amsmath}")
+  "Packages to use for htlatex export."
+  :group 'org-babel
+  :type '(list string))
+
 (defun org-babel-expand-body:latex (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (mapc (lambda (pair) ;; replace variables
@@ -81,28 +89,32 @@ This function is called by `org-babel-execute-src-block'."
             (width (and fit (cdr (assoc :pdfwidth params))))
             (headers (cdr (assoc :headers params)))
             (in-buffer (not (string= "no" (cdr (assoc :buffer params)))))
-            (org-export-latex-packages-alist
-             (append (cdr (assoc :packages params))
-                     org-export-latex-packages-alist)))
+            (org-latex-packages-alist
+             (append (cdr (assoc :packages params)) org-latex-packages-alist)))
         (cond
          ((and (string-match "\\.png$" out-file) (not imagemagick))
           (org-create-formula-image
            body out-file org-format-latex-options in-buffer))
-         ((or (string-match "\\.pdf$" out-file) imagemagick)
-         (require 'org-latex)
+         ((string-match "\\.tikz$" out-file)
+         (when (file-exists-p out-file) (delete-file out-file))
+         (with-temp-file out-file
+           (insert body)))
+        ((or (string-match "\\.pdf$" out-file) imagemagick)
          (with-temp-file tex-file
+           (require 'ox-latex)
            (insert
-            (org-splice-latex-header
-             org-format-latex-header
-             (delq
-              nil
-              (mapcar
-               (lambda (el)
-                 (unless (and (listp el) (string= "hyperref" (cadr el)))
-                   el))
-               org-export-latex-default-packages-alist))
-             org-export-latex-packages-alist
-             org-format-latex-header-extra)
+            (org-latex-guess-inputenc
+             (org-splice-latex-header
+              org-format-latex-header
+              (delq
+               nil
+               (mapcar
+                (lambda (el)
+                  (unless (and (listp el) (string= "hyperref" (cadr el)))
+                    el))
+                org-latex-default-packages-alist))
+              org-latex-packages-alist
+              nil))
             (if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
             (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
             (if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
@@ -113,14 +125,10 @@ This function is called by `org-babel-execute-src-block'."
                             (mapconcat #'identity headers "\n")
                           headers) "\n")
               "")
-            (if org-format-latex-header-extra
-                (concat "\n" org-format-latex-header-extra)
-              "")
             (if fit
                 (concat "\n\\begin{document}\n\\begin{preview}\n" body
                         "\n\\end{preview}\n\\end{document}\n")
-              (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))
-           (org-export-latex-fix-inputenc))
+              (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
           (when (file-exists-p out-file) (delete-file out-file))
          (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
            (cond
@@ -131,13 +139,46 @@ This function is called by `org-babel-execute-src-block'."
               transient-pdf-file out-file im-in-options im-out-options)
              (when (file-exists-p transient-pdf-file)
                (delete-file transient-pdf-file))))))
+        ((and (or (string-match "\\.svg$" out-file)
+                  (string-match "\\.html$" out-file))
+              org-babel-latex-htlatex)
+         (with-temp-file tex-file
+           (insert (concat
+                    "\\documentclass[preview]{standalone}
+\\def\\pgfsysdriver{pgfsys-tex4ht.def}
+"
+                    (mapconcat (lambda (pkg)
+                                 (concat "\\usepackage" pkg))
+                               org-babel-latex-htlatex-packages
+                               "\n")
+                    "\\begin{document}"
+                    body
+                    "\\end{document}")))
+         (when (file-exists-p out-file) (delete-file out-file))
+         (let ((default-directory (file-name-directory tex-file)))
+           (shell-command (format "%s %s" org-babel-latex-htlatex tex-file)))
+         (cond
+          ((file-exists-p (concat (file-name-sans-extension tex-file) "-1.svg"))
+           (if (string-match "\\.svg$" out-file)
+               (progn
+                 (shell-command "pwd")
+                 (shell-command (format "mv %s %s"
+                                        (concat (file-name-sans-extension tex-file) "-1.svg")
+                                        out-file)))
+             (error "SVG file produced but HTML file requested.")))
+          ((file-exists-p (concat (file-name-sans-extension tex-file) ".html"))
+           (if (string-match "\\.html$" out-file)
+               (shell-command "mv %s %s"
+                              (concat (file-name-sans-extension tex-file)
+                                      ".html")
+                              out-file)
+             (error "HTML file produced but SVG file requested.")))))
          ((string-match "\\.\\([^\\.]+\\)$" out-file)
           (error "Can not create %s files, please specify a .png or .pdf file or try the :imagemagick header argument"
                 (match-string 1 out-file))))
         nil) ;; signal that output has already been written to file
     body))
 
-
 (defun convert-pdf (pdffile out-file im-in-options im-out-options)
   "Generate a file from a pdf file using imagemagick."
   (let ((cmd (concat "convert " im-in-options " " pdffile " "
@@ -146,55 +187,14 @@ This function is called by `org-babel-execute-src-block'."
     (shell-command cmd)))
 
 (defun org-babel-latex-tex-to-pdf (file)
-  "Generate a pdf file according to the contents FILE.
-Extracted from `org-export-as-pdf' in org-latex.el."
-  (let* ((wconfig (current-window-configuration))
-         (default-directory (file-name-directory file))
-         (base (file-name-sans-extension file))
-         (pdffile (concat base ".pdf"))
-         (cmds org-latex-to-pdf-process)
-         (outbuf (get-buffer-create "*Org PDF LaTeX Output*"))
-         output-dir cmd)
-    (with-current-buffer outbuf (erase-buffer))
-    (message (concat "Processing LaTeX file " file "..."))
-    (setq output-dir (file-name-directory file))
-    (if (and cmds (symbolp cmds))
-       (funcall cmds (shell-quote-argument file))
-      (while cmds
-       (setq cmd (pop cmds))
-       (while (string-match "%b" cmd)
-         (setq cmd (replace-match
-                    (save-match-data
-                      (shell-quote-argument base))
-                    t t cmd)))
-       (while (string-match "%f" cmd)
-         (setq cmd (replace-match
-                    (save-match-data
-                      (shell-quote-argument file))
-                    t t cmd)))
-       (while (string-match "%o" cmd)
-         (setq cmd (replace-match
-                    (save-match-data
-                      (shell-quote-argument output-dir))
-                    t t cmd)))
-       (shell-command cmd outbuf)))
-    (message (concat "Processing LaTeX file " file "...done"))
-    (if (not (file-exists-p pdffile))
-       (error (concat "PDF file " pdffile " was not produced"))
-      (set-window-configuration wconfig)
-      (when org-export-pdf-remove-logfiles
-       (dolist (ext org-export-pdf-logfiles)
-         (setq file (concat base "." ext))
-         (and (file-exists-p file) (delete-file file))))
-      (message "Exporting to PDF...done")
-      pdffile)))
+  "Generate a pdf file according to the contents FILE."
+  (require 'ox-latex)
+  (org-latex-compile file))
 
 (defun org-babel-prep-session:latex (session params)
   "Return an error because LaTeX doesn't support sessions."
   (error "LaTeX does not support sessions"))
 
-(provide 'ob-latex)
-
-
 
+(provide 'ob-latex)
 ;;; ob-latex.el ends here
index 0554a36ab020f399a2008426b098dbf5b8e67991..a58a443dc144353f26ae0b92196789ee899bc191 100644 (file)
 ;; http://lilypond.org/manuals.html
 
 ;;; Code:
-
 (require 'ob)
-(require 'ob-eval)
-(require 'ob-tangle)
 (require 'outline)
 (defalias 'lilypond-mode 'LilyPond-mode)
 
@@ -155,7 +152,11 @@ specific arguments to =org-babel-tangle="
       " -dbackend=eps "
       "-dno-gs-load-fonts "
       "-dinclude-eps-fonts "
-      "--png "
+      (or (cdr (assoc (file-name-extension out-file)
+                     '(("pdf" . "--pdf ")
+                       ("ps" . "--ps ")
+                       ("png" . "--png "))))
+         "--png ")
       "--output="
       (file-name-sans-extension out-file)
       " "
@@ -199,7 +200,6 @@ FILE-NAME is full path to lilypond (.ly) file"
   (let ((arg-1 (ly-determine-ly-path)) ;program
         (arg-2 nil)                    ;infile
         (arg-3 "*lilypond*")           ;buffer
-        (arg-4 t)                      ;display
        (arg-4 t)                      ;display
        (arg-5 (if ly-gen-png  "--png"  "")) ;&rest...
        (arg-6 (if ly-gen-html "--html" ""))
index 4ff9718553bd174da73c2cff37f8b7babb9685ee..c912fd9f0fa16235d0e1706aaddb363f01c9c52a 100644 (file)
@@ -75,23 +75,24 @@ current directory string."
   "Execute a block of Common Lisp code with Babel."
   (require 'slime)
   (org-babel-reassemble-table
-   ((lambda (result)
-      (if (member "output" (cdr (assoc :result-params params)))
-         (car result)
-       (condition-case nil
-           (read (org-babel-lisp-vector-to-list (cadr result)))
-         (error (cadr result)))))
-    (with-temp-buffer
-      (insert (org-babel-expand-body:lisp body params))
-      (slime-eval `(swank:eval-and-grab-output
-                   ,(let ((dir (if (assoc :dir params)
-                                   (cdr (assoc :dir params))
-                                 default-directory)))
-                      (format
-                       (if dir (format org-babel-lisp-dir-fmt dir) "(progn %s)")
-                       (buffer-substring-no-properties
-                        (point-min) (point-max)))))
-                 (cdr (assoc :package params)))))
+   (let ((result
+          (with-temp-buffer
+            (insert (org-babel-expand-body:lisp body params))
+            (slime-eval `(swank:eval-and-grab-output
+                          ,(let ((dir (if (assoc :dir params)
+                                          (cdr (assoc :dir params))
+                                        default-directory)))
+                             (format
+                              (if dir (format org-babel-lisp-dir-fmt dir)
+                                "(progn %s)")
+                              (buffer-substring-no-properties
+                               (point-min) (point-max)))))
+                        (cdr (assoc :package params))))))
+     (org-babel-result-cond (cdr (assoc :result-params params))
+       (car result)
+       (condition-case nil
+           (read (org-babel-lisp-vector-to-list (cadr result)))
+         (error (cadr result)))))
    (org-babel-pick-name (cdr (assoc :colname-names params))
                        (cdr (assoc :colnames params)))
    (org-babel-pick-name (cdr (assoc :rowname-names params))
index 3727829359e4e6ae9f3d3b970dbef382d0edf2ea..d37940a1883d9477f619a901007bf2a006f3055f 100644 (file)
@@ -25,7 +25,7 @@
 ;;; Code:
 (eval-when-compile
   (require 'cl))
-(require 'ob)
+(require 'ob-core)
 (require 'ob-table)
 
 (declare-function org-babel-in-example-or-verbatim "ob-exp" nil)
@@ -35,7 +35,7 @@
 This is an association list.  Populate the library by adding
 files to `org-babel-lob-files'.")
 
-(defcustom org-babel-lob-files '()
+(defcustom org-babel-lob-files nil
   "Files used to populate the `org-babel-library-of-babel'.
 To add files to this list use the `org-babel-lob-ingest' command."
   :group 'org-babel
@@ -114,29 +114,45 @@ if so then run the appropriate source block from the Library."
                          (or (funcall nonempty 8 19) ""))
                  (funcall nonempty 9 18)))
         (list (length (if (= (length (match-string 12)) 0)
-                          (match-string 2) (match-string 11)))))))))
-
+                          (match-string 2) (match-string 11)))
+              (save-excursion
+                (forward-line -1)
+                (and (looking-at (concat org-babel-src-name-regexp
+                                         "\\([^\n]*\\)$"))
+                     (org-no-properties (match-string 1))))))))))
+
+(defvar org-babel-default-header-args:emacs-lisp) ; Defined in ob-emacs-lisp.el
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
-  (let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
-        (pre-params (org-babel-merge-params
-                     org-babel-default-header-args
-                     (org-babel-params-from-properties)
-                     (org-babel-parse-header-arguments
-                      (org-no-properties
-                       (concat ":var results="
-                               (mapconcat #'identity (butlast info) " "))))))
+  (let* ((mkinfo (lambda (p)
+                  (list "emacs-lisp" "results" p nil
+                        (nth 3 info) ;; name
+                        (nth 2 info))))
+        (pre-params (apply #'org-babel-merge-params
+                           org-babel-default-header-args
+                           org-babel-default-header-args:emacs-lisp
+                           (append
+                            (org-babel-params-from-properties)
+                            (list
+                             (org-babel-parse-header-arguments
+                              (org-no-properties
+                               (concat
+                                ":var results="
+                                (mapconcat #'identity (butlast info 2)
+                                           " "))))))))
         (pre-info (funcall mkinfo pre-params))
-        (cache? (and (cdr (assoc :cache pre-params))
-                     (string= "yes" (cdr (assoc :cache pre-params)))))
-        (new-hash (when cache? (org-babel-sha1-hash pre-info)))
-        (old-hash (when cache? (org-babel-current-result-hash))))
-    (if (and cache? (equal new-hash old-hash))
+        (cache-p (and (cdr (assoc :cache pre-params))
+                      (string= "yes" (cdr (assoc :cache pre-params)))))
+        (new-hash (when cache-p (org-babel-sha1-hash pre-info)))
+        (old-hash (when cache-p (org-babel-current-result-hash)))
+        (org-babel-current-src-block-location (point-marker)))
+    (if (and cache-p (equal new-hash old-hash))
        (save-excursion (goto-char (org-babel-where-is-src-block-result))
                        (forward-line 1)
                        (message "%S" (org-babel-read-result)))
-      (prog1 (org-babel-execute-src-block
-             nil (funcall mkinfo (org-babel-process-params pre-params)))
+      (prog1 (let* ((proc-params (org-babel-process-params pre-params))
+                    org-confirm-babel-evaluate)
+              (org-babel-execute-src-block nil (funcall mkinfo proc-params)))
        ;; update the hash
        (when new-hash (org-babel-set-current-result-hash new-hash))))))
 
diff --git a/lisp/org/ob-makefile.el b/lisp/org/ob-makefile.el
new file mode 100644 (file)
index 0000000..517b5a6
--- /dev/null
@@ -0,0 +1,47 @@
+;;; ob-makefile.el --- org-babel functions for makefile evaluation
+
+;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
+
+;; Author: Eric Schulte and Thomas S. Dye
+;; Keywords: literate programming, reproducible research
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file exists solely for tangling a Makefile from org-mode files.
+
+;;; Code:
+(require 'ob)
+
+(defvar org-babel-default-header-args:makefile '())
+
+(defun org-babel-execute:makefile (body params)
+  "Execute a block of makefile code.
+This function is called by `org-babel-execute-src-block'."
+  body)
+
+(defun org-babel-prep-session:makefile (session params)
+  "Return an error if the :session header argument is set.  Make
+does not support sessions."
+  (error "Makefile sessions are nonsensical"))
+
+(provide 'ob-makefile)
+
+
+
+;;; ob-makefile.el ends here
index 4a91ca9b2816dc2d2336956c746d64d7e8d3829e..5be378ed600fd9c97cb78a453646b519708ac6b0 100644 (file)
@@ -65,8 +65,8 @@
               "\n")))
 
 (defun org-babel-execute:maxima (body params)
-  "Execute a block of Maxima entries with org-babel.  This function is
-called by `org-babel-execute-src-block'."
+  "Execute a block of Maxima entries with org-babel.
+This function is called by `org-babel-execute-src-block'."
   (message "executing Maxima source code block")
   (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
        (result
@@ -76,23 +76,22 @@ called by `org-babel-execute-src-block'."
                             org-babel-maxima-command in-file cmdline)))
           (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
           (message cmd)
-          ((lambda (raw) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
-             (mapconcat
-              #'identity
-              (delq nil
-                    (mapcar (lambda (line)
-                              (unless (or (string-match "batch" line)
-                                          (string-match "^rat: replaced .*$" line)
-                                          (= 0 (length line)))
-                                line))
-                            (split-string raw "[\r\n]"))) "\n"))
-           (org-babel-eval cmd "")))))
+           ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' "
+          (let ((raw (org-babel-eval cmd "")))
+             (mapconcat
+              #'identity
+              (delq nil
+                    (mapcar (lambda (line)
+                              (unless (or (string-match "batch" line)
+                                          (string-match "^rat: replaced .*$" line)
+                                          (string-match "^;;; Loading #P" line)
+                                          (= 0 (length line)))
+                                line))
+                            (split-string raw "[\r\n]"))) "\n")))))
     (if (org-babel-maxima-graphical-output-file params)
        nil
-      (if (or (member "scalar" result-params)
-             (member "verbatim" result-params)
-             (member "output" result-params))
-         result
+      (org-babel-result-cond result-params
+       result
        (let ((tmp-file (org-babel-temp-file "maxima-res-")))
          (with-temp-file tmp-file (insert result))
          (org-babel-import-elisp-from-file tmp-file))))))
index 5838d7dec7e1fb6018ea1e5ac5c19f647a0aac6e..209ad7dcc37c224f4c857d7f1ea3e3678f28dcb9 100644 (file)
@@ -55,7 +55,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 
 (defvar org-babel-default-header-args:mscgen
   '((:results . "file") (:exports . "results"))
index bff41f8f1cf5f00aa7072c7d0e2c35c8a4f479d0..25f79c5b7760a7b27b87f219f0b3c3cb18026e4d 100644 (file)
 
 ;;; Code:
 (require 'ob)
-(require 'ob-comint)
 (require 'comint)
 (eval-when-compile (require 'cl))
 
 (declare-function tuareg-run-caml "ext:tuareg" ())
+(declare-function tuareg-run-ocaml "ext:tuareg" ())
 (declare-function tuareg-interactive-send-input "ext:tuareg" ())
 
 (defvar org-babel-tangle-lang-exts)
 (defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
 (defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
 
+(defcustom org-babel-ocaml-command "ocaml"
+  "Name of the command for executing Ocaml code."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-babel
+  :type 'string)
+
 (defun org-babel-execute:ocaml (body params)
   "Execute a block of Ocaml code with Babel."
   (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
@@ -63,7 +70,7 @@
                  (session org-babel-ocaml-eoe-output t full-body)
                (insert
                 (concat
-                 (org-babel-chomp full-body)"\n"org-babel-ocaml-eoe-indicator))
+                 (org-babel-chomp full-body)";;\n"org-babel-ocaml-eoe-indicator))
                (tuareg-interactive-send-input)))
         (clean
          (car (let ((re (regexp-quote org-babel-ocaml-eoe-output)) out)
                                         (progn (setq out t) nil))))
                                   (mapcar #'org-babel-trim (reverse raw))))))))
     (org-babel-reassemble-table
-     (org-babel-ocaml-parse-output (org-babel-trim clean))
+     (let ((raw (org-babel-trim clean))
+          (result-params (cdr (assoc :result-params params))))
+       (org-babel-result-cond result-params
+        ;; strip type information from output unless verbatim is specified
+        (if (and (not (member "verbatim" result-params))
+                 (string-match "= \\(.+\\)$" raw))
+            (match-string 1 raw) raw)
+        (org-babel-ocaml-parse-output raw)))
      (org-babel-pick-name
       (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
      (org-babel-pick-name
                                                  (stringp session))
                                             session
                                           tuareg-interactive-buffer-name)))
-    (save-window-excursion (tuareg-run-caml)
-                           (get-buffer tuareg-interactive-buffer-name))))
+    (save-window-excursion (if (fboundp 'tuareg-run-process-if-needed)
+        (tuareg-run-process-if-needed org-babel-ocaml-command)
+       (tuareg-run-caml)))
+    (get-buffer tuareg-interactive-buffer-name)))
 
 (defun org-babel-variable-assignments:ocaml (params)
   "Return list of ocaml statements assigning the block's variables."
 (defun org-babel-ocaml-parse-output (output)
   "Parse OUTPUT.
 OUTPUT is string output from an ocaml process."
-  (let ((regexp "%s = \\(.+\\)$"))
+  (let ((regexp "[^:]+ : %s = \\(.+\\)$"))
     (cond
      ((string-match (format regexp "string") output)
       (org-babel-read (match-string 1 output)))
index 3394d579ae69f7c7df25b2a91cbcfae05b482cde..40bedfdb134a3a215dceb82b37542953ad91a513 100644 (file)
@@ -30,9 +30,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (declare-function matlab-shell "ext:matlab-mode")
@@ -154,7 +151,8 @@ create.  Return the initialized session."
   "Create an octave inferior process buffer.
 If there is not a current inferior-process-buffer in SESSION then
 create.  Return the initialized session."
-  (if matlabp (require 'matlab) (require 'octave-inf))
+  (if matlabp (require 'matlab) (or (require 'octave-inf nil 'noerror)
+                                   (require 'octave)))
   (unless (string= session "none")
     (let ((session (or session
                       (if matlabp "*Inferior Matlab*" "*Inferior Octave*"))))
index a5cd96a75b16e5b3efa15ce3ff7440e5c58ff163..892c56c25b30c2ccac2b6a798b8a23308d3e403d 100644 (file)
@@ -29,7 +29,8 @@
 ;;; Code:
 (require 'ob)
 
-(declare-function org-export-string "org-exp" (string fmt &optional dir))
+(declare-function org-export-string-as "ox"
+                 (string backend &optional body-only ext-plist))
 
 (defvar org-babel-default-header-args:org
   '((:results . "raw silent") (:exports . "code"))
@@ -42,8 +43,9 @@
 (defun org-babel-expand-body:org (body params)
   (dolist (var (mapcar #'cdr (org-babel-get-header params :var)))
     (setq body (replace-regexp-in-string
-               (regexp-quote (format "$%s" (car var)))  (cdr var) body
-               nil 'literal)))
+               (regexp-quote (format "$%s" (car var)))
+               (format "%s" (cdr var))
+               body nil 'literal)))
   body)
 
 (defun org-babel-execute:org (body params)
@@ -53,10 +55,10 @@ This function is called by `org-babel-execute-src-block'."
        (body (org-babel-expand-body:org
               (replace-regexp-in-string "^," "" body) params)))
     (cond
-     ((member "latex" result-params) (org-export-string
-                                     (concat "#+Title: \n" body) "latex"))
-     ((member "html" result-params)  (org-export-string body "html"))
-     ((member "ascii" result-params) (org-export-string body "ascii"))
+     ((member "latex" result-params)
+      (org-export-string-as (concat "#+Title: \n" body) 'latex t))
+     ((member "html" result-params) (org-export-string-as  body 'html t))
+     ((member "ascii" result-params) (org-export-string-as body 'ascii t))
      (t body))))
 
 (defun org-babel-prep-session:org (session params)
index b37df807aed0abb26d350e81c9a3512f690b763c..d374e47ebfae91f7439b9ffa8c5950bf36ce3261 100644 (file)
@@ -28,7 +28,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts)
@@ -49,7 +48,7 @@ This function is called by `org-babel-execute-src-block'."
                     body params (org-babel-variable-assignments:perl params)))
         (session (org-babel-perl-initiate-session session)))
     (org-babel-reassemble-table
-     (org-babel-perl-evaluate session full-body result-type)
+     (org-babel-perl-evaluate session full-body result-type result-params)
      (org-babel-pick-name
       (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
      (org-babel-pick-name
@@ -63,20 +62,33 @@ This function is called by `org-babel-execute-src-block'."
   "Return list of perl statements assigning the block's variables."
   (mapcar
    (lambda (pair)
-     (format "$%s=%s;"
-            (car pair)
-            (org-babel-perl-var-to-perl (cdr pair))))
+     (org-babel-perl--var-to-perl (cdr pair) (car pair)))
    (mapcar #'cdr (org-babel-get-header params :var))))
 
 ;; helper functions
 
-(defun org-babel-perl-var-to-perl (var)
+(defvar org-babel-perl-var-wrap "q(%s)"
+  "Wrapper for variables inserted into Perl code.")
+
+(defvar org-babel-perl--lvl)
+(defun org-babel-perl--var-to-perl (var &optional varn)
   "Convert an elisp value to a perl variable.
 The elisp value, VAR, is converted to a string of perl source code
 specifying a var of the same value."
-  (if (listp var)
-      (concat "[" (mapconcat #'org-babel-perl-var-to-perl var ", ") "]")
-    (format "%S" var)))
+  (if varn
+      (let ((org-babel-perl--lvl 0) (lvar (listp var)) prefix)
+       (concat "my $" (symbol-name varn) "=" (when lvar "\n")
+               (org-babel-perl--var-to-perl var)
+               ";\n"))
+    (let ((prefix (make-string (* 2 org-babel-perl--lvl) ?\ )))
+      (concat prefix
+             (if (listp var)
+                 (let ((org-babel-perl--lvl (1+ org-babel-perl--lvl)))
+                   (concat "[\n"
+                           (mapconcat #'org-babel-perl--var-to-perl var "")
+                           prefix "]"))
+               (format "q(%s)" var))
+             (unless (zerop org-babel-perl--lvl) ",\n")))))
 
 (defvar org-babel-perl-buffers '(:default . nil))
 
@@ -84,32 +96,60 @@ specifying a var of the same value."
   "Return nil because sessions are not supported by perl."
   nil)
 
-(defvar org-babel-perl-wrapper-method
-  "
-sub main {
-%s
-}
-@r = main;
-open(o, \">%s\");
-print o join(\"\\n\", @r), \"\\n\"")
+(defvar org-babel-perl-wrapper-method "{
+    my $babel_sub = sub {
+        %s
+    };
+    open my $BOH, qq(>%s) or die qq(Perl: Could not open output file.$/);
+    my $rv = &$babel_sub();
+    my $rt = ref $rv;
+    select $BOH;
+    if (qq(ARRAY) eq $rt) {
+        local $\\=$/;
+        local $,=qq(\t);
+       foreach my $rv ( @$rv ) {
+           my $rt = ref $rv;
+           if (qq(ARRAY) eq $rt) {
+               print @$rv;
+           } else {
+               print $rv;
+           }
+       }
+    } else {
+       print $rv;
+    }
+}")
+
+(defvar org-babel-perl-preface nil)
 
 (defvar org-babel-perl-pp-wrapper-method
   nil)
 
-(defun org-babel-perl-evaluate (session body &optional result-type)
+(defun org-babel-perl-evaluate (session ibody &optional result-type result-params)
   "Pass BODY to the Perl process in SESSION.
 If RESULT-TYPE equals 'output then return a list of the outputs
 of the statements in BODY, if RESULT-TYPE equals 'value then
 return the value of the last statement in BODY, as elisp."
   (when session (error "Sessions are not supported for Perl"))
-  (case result-type
-    (output (org-babel-eval org-babel-perl-command body))
-    (value (let ((tmp-file (org-babel-temp-file "perl-")))
-            (org-babel-eval
-             org-babel-perl-command
-             (format org-babel-perl-wrapper-method body
-                     (org-babel-process-file-name tmp-file 'noquote)))
-            (org-babel-eval-read-file tmp-file)))))
+  (let* ((body (concat org-babel-perl-preface ibody))
+        (tmp-file (org-babel-temp-file "perl-"))
+        (tmp-babel-file (org-babel-process-file-name
+                         tmp-file 'noquote)))
+    (let ((results
+           (case result-type
+             (output
+              (with-temp-file tmp-file
+                (insert
+                 (org-babel-eval org-babel-perl-command body))
+                (buffer-string)))
+             (value
+              (org-babel-eval org-babel-perl-command
+                              (format org-babel-perl-wrapper-method
+                                      body tmp-babel-file))))))
+      (when results
+        (org-babel-result-cond result-params
+         (org-babel-eval-read-file tmp-file)
+          (org-babel-import-elisp-from-file tmp-file '(16)))))))
 
 (provide 'ob-perl)
 
index 1029b6f2a941011a03ae80ca9d3c13e9842f2927..279cd7b3f45c59ba900b8f360bc7620547a3902b 100644 (file)
@@ -54,8 +54,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
-(require 'ob-comint)
 (require 'comint)
 (eval-when-compile (require 'cl))
 
@@ -80,7 +78,7 @@
   :version "24.1"
   :type 'string)
 
-(defun org-babel-expand-body:picolisp (body params &optional processed-params)
+(defun org-babel-expand-body:picolisp (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))
         (result-params (cdr (assoc :result-params params)))
  called by `org-babel-execute-src-block'"
   (message "executing Picolisp source code block")
   (let* (
-        ;; name of the session or "none"
+        ;; Name of the session or "none".
         (session-name (cdr (assoc :session params)))
-        ;; set the session if the session variable is non-nil
+        ;; Set the session if the session variable is non-nil.
         (session (org-babel-picolisp-initiate-session session-name))
-        ;; either OUTPUT or VALUE which should behave as described above
+        ;; Either OUTPUT or VALUE which should behave as described above.
         (result-type (cdr (assoc :result-type params)))
         (result-params (cdr (assoc :result-params params)))
-        ;; expand the body with `org-babel-expand-body:picolisp'
+        ;; Expand the body with `org-babel-expand-body:picolisp'.
         (full-body (org-babel-expand-body:picolisp body params))
-         ;; wrap body appropriately for the type of evaluation and results
+         ;; Wrap body appropriately for the type of evaluation and results.
          (wrapped-body
           (cond
            ((or (member "code" result-params)
             (format "(print (out \"/dev/null\" %s))" full-body))
            ((member "value" result-params)
             (format "(out \"/dev/null\" %s)" full-body))
-           (t full-body))))
-
-    ((lambda (result)
-       (if (or (member "verbatim" result-params)
-               (member "scalar" result-params)
-               (member "output" result-params)
-               (member "code" result-params)
-               (member "pp" result-params)
-               (= (length result) 0))
-           result
-         (read result)))
-     (if (not (string= session-name "none"))
-         ;; session based evaluation
-        (mapconcat ;; <- joins the list back together into a single string
-          #'identity
-          (butlast ;; <- remove the org-babel-picolisp-eoe line
-           (delq nil
-                 (mapcar
-                  (lambda (line)
-                    (org-babel-chomp ;; remove trailing newlines
-                     (when (> (length line) 0) ;; remove empty lines
-                      (cond
-                       ;; remove leading "-> " from return values
-                       ((and (>= (length line) 3)
-                             (string= "-> " (substring line 0 3)))
-                        (substring line 3))
-                       ;; remove trailing "-> <<return-value>>" on the
-                       ;; last line of output
-                       ((and (member "output" result-params)
-                             (string-match-p "->" line))
-                        (substring line 0 (string-match "->" line)))
-                       (t line)
-                       )
-                       ;; (if (and (>= (length line) 3) ;; remove leading "<- "
-                       ;;          (string= "-> " (substring line 0 3)))
-                       ;;     (substring line 3)
-                       ;;   line)
-                      )))
-                  ;; returns a list of the output of each evaluated expression
-                  (org-babel-comint-with-output (session org-babel-picolisp-eoe)
-                    (insert wrapped-body) (comint-send-input)
-                    (insert "'" org-babel-picolisp-eoe) (comint-send-input)))))
-          "\n")
-       ;; external evaluation
-       (let ((script-file (org-babel-temp-file "picolisp-script-")))
-        (with-temp-file script-file
-          (insert (concat wrapped-body "(bye)")))
-         (org-babel-eval
-          (format "%s %s"
-                  org-babel-picolisp-cmd
-                  (org-babel-process-file-name script-file))
-          ""))))))
+           (t full-body)))
+         (result
+          (if (not (string= session-name "none"))
+              ;; Session based evaluation.
+              (mapconcat ;; <- joins the list back into a single string
+               #'identity
+               (butlast ;; <- remove the org-babel-picolisp-eoe line
+                (delq nil
+                      (mapcar
+                       (lambda (line)
+                         (org-babel-chomp      ;; Remove trailing newlines.
+                          (when (> (length line) 0) ;; Remove empty lines.
+                            (cond
+                             ;; Remove leading "-> " from return values.
+                             ((and (>= (length line) 3)
+                                   (string= "-> " (substring line 0 3)))
+                              (substring line 3))
+                             ;; Remove trailing "-> <<return-value>>" on the
+                             ;; last line of output.
+                             ((and (member "output" result-params)
+                                   (string-match-p "->" line))
+                              (substring line 0 (string-match "->" line)))
+                             (t line)
+                             )
+                            ;;(if (and (>= (length line) 3);Remove leading "<-"
+                            ;;         (string= "-> " (substring line 0 3)))
+                            ;;    (substring line 3)
+                            ;;  line)
+                            )))
+                       ;; Returns a list of the output of each evaluated exp.
+                       (org-babel-comint-with-output
+                           (session org-babel-picolisp-eoe)
+                         (insert wrapped-body) (comint-send-input)
+                         (insert "'" org-babel-picolisp-eoe)
+                         (comint-send-input)))))
+               "\n")
+            ;; external evaluation
+            (let ((script-file (org-babel-temp-file "picolisp-script-")))
+              (with-temp-file script-file
+                (insert (concat wrapped-body "(bye)")))
+              (org-babel-eval
+               (format "%s %s"
+                       org-babel-picolisp-cmd
+                       (org-babel-process-file-name script-file))
+               "")))))
+    (org-babel-result-cond result-params
+      result
+      (read result))))
 
 (defun org-babel-picolisp-initiate-session (&optional session-name)
   "If there is not a current inferior-process-buffer in SESSION
index bb52c376b4abdd7c65b5497ff050e1a40626f4bf..c17d4448a3c453402ec23427ae344e48184df6af 100644 (file)
@@ -35,7 +35,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 
 (defvar org-babel-default-header-args:plantuml
   '((:results . "file") (:exports . "results"))
index 79cc53ea0fa8dc1c7b7f0061fd7092d2d9e0b9a3..99c35ce2863ae33dd8fa569c9866ad93f6d2392b 100644 (file)
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (declare-function org-remove-indentation "org" )
 (declare-function py-shell "ext:python-mode" (&optional argprompt))
 (declare-function py-toggle-shells "ext:python-mode" (arg))
-(declare-function run-python "ext:python" (&optional cmd noshow new))
+(declare-function run-python "ext:python" (cmd &optional dedicated show))
 
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("python" . "py"))
 
 (defvar org-babel-default-header-args:python '())
 
-(defvar org-babel-python-command "python"
-  "Name of the command for executing Python code.")
+(defcustom org-babel-python-command "python"
+  "Name of the command for executing Python code."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-babel
+  :type 'string)
 
-(defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python)
+(defcustom org-babel-python-mode
+  (if (or (featurep 'xemacs) (featurep 'python-mode)) 'python-mode 'python)
   "Preferred python mode for use in running python interactively.
-This will typically be either 'python or 'python-mode.")
+This will typically be either 'python or 'python-mode."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
 
 (defvar org-src-preserve-indentation)
 
+(defcustom org-babel-python-hline-to "None"
+  "Replace hlines in incoming tables with this when translating to python."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-babel-python-None-to 'hline
+  "Replace 'None' in python tables with this before returning."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
 (defun org-babel-execute:python (body params)
   "Execute a block of Python code with Babel.
 This function is called by `org-babel-execute-src-block'."
@@ -114,7 +134,7 @@ specifying a variable of the same value."
   (if (listp var)
       (concat "[" (mapconcat #'org-babel-python-var-to-python var ", ") "]")
     (if (equal var 'hline)
-       "None"
+       org-babel-python-hline-to
       (format
        (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
        var))))
@@ -123,15 +143,36 @@ specifying a variable of the same value."
   "Convert RESULTS into an appropriate elisp value.
 If the results look like a list or tuple, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-script-escape results))
+  (let ((res (org-babel-script-escape results)))
+    (if (listp res)
+        (mapcar (lambda (el) (if (equal el 'None)
+                            org-babel-python-None-to el))
+                res)
+      res)))
 
-(defvar org-babel-python-buffers '((:default . nil)))
+(defvar org-babel-python-buffers '((:default . "*Python*")))
 
 (defun org-babel-python-session-buffer (session)
   "Return the buffer associated with SESSION."
   (cdr (assoc session org-babel-python-buffers)))
 
+(defun org-babel-python-with-earmuffs (session)
+  (let ((name (if (stringp session) session (format "%s" session))))
+    (if (and (string= "*" (substring name 0 1))
+            (string= "*" (substring name (- (length name) 1))))
+       name
+      (format "*%s*" name))))
+
+(defun org-babel-python-without-earmuffs (session)
+  (let ((name (if (stringp session) session (format "%s" session))))
+    (if (and (string= "*" (substring name 0 1))
+            (string= "*" (substring name (- (length name) 1))))
+       (substring name 1 (- (length name) 1))
+      name)))
+
 (defvar py-default-interpreter)
+(defvar py-which-bufname)
+(defvar python-shell-buffer-name)
 (defun org-babel-python-initiate-session-by-key (&optional session)
   "Initiate a python session.
 If there is not a current inferior-process-buffer in SESSION
@@ -139,13 +180,20 @@ then create.  Return the initialized session."
   (require org-babel-python-mode)
   (save-window-excursion
     (let* ((session (if session (intern session) :default))
-           (python-buffer (org-babel-python-session-buffer session)))
+           (python-buffer (org-babel-python-session-buffer session))
+          (cmd (if (member system-type '(cygwin windows-nt ms-dos))
+                   (concat org-babel-python-command " -i")
+                 org-babel-python-command)))
       (cond
        ((and (eq 'python org-babel-python-mode)
             (fboundp 'run-python)) ; python.el
-       (if (version< "24.1" emacs-version)
-           (run-python org-babel-python-command)
-         (run-python)))
+       (if (not (version< "24.1" emacs-version))
+           (run-python cmd)
+         (unless python-buffer
+           (setq python-buffer (org-babel-python-with-earmuffs session)))
+         (let ((python-shell-buffer-name
+                (org-babel-python-without-earmuffs python-buffer)))
+           (run-python cmd))))
        ((and (eq 'python-mode org-babel-python-mode)
             (fboundp 'py-shell)) ; python-mode.el
        ;; Make sure that py-which-bufname is initialized, as otherwise
@@ -160,7 +208,7 @@ then create.  Return the initialized session."
                          (concat "Python-" (symbol-name session))))
               (py-which-bufname bufname))
          (py-shell)
-         (setq python-buffer (concat "*" bufname "*"))))
+         (setq python-buffer (org-babel-python-with-earmuffs bufname))))
        (t
        (error "No function available for running an inferior Python")))
       (setq org-babel-python-buffers
@@ -205,37 +253,34 @@ open('%s', 'w').write( pprint.pformat(main()) )")
 If RESULT-TYPE equals 'output then return standard output as a
 string.  If RESULT-TYPE equals 'value then return the value of the
 last statement in BODY, as elisp."
-  ((lambda (raw)
-     (if (or (member "code" result-params)
-            (member "pp" result-params)
-            (and (member "output" result-params)
-                 (not (member "table" result-params))))
-        raw
-       (org-babel-python-table-or-string (org-babel-trim raw))))
-   (case result-type
-     (output (org-babel-eval org-babel-python-command
-                            (concat (if preamble (concat preamble "\n") "")
-                                    body)))
-     (value (let ((tmp-file (org-babel-temp-file "python-")))
-             (org-babel-eval
-              org-babel-python-command
-              (concat
-               (if preamble (concat preamble "\n") "")
-               (format
-                (if (member "pp" result-params)
-                    org-babel-python-pp-wrapper-method
-                  org-babel-python-wrapper-method)
-                (mapconcat
-                 (lambda (line) (format "\t%s" line))
-                 (split-string
-                  (org-remove-indentation
-                   (org-babel-trim body))
-                  "[\r\n]") "\n")
-                (org-babel-process-file-name tmp-file 'noquote))))
-             (org-babel-eval-read-file tmp-file))))))
+  (let ((raw
+         (case result-type
+           (output (org-babel-eval org-babel-python-command
+                                   (concat (if preamble (concat preamble "\n"))
+                                           body)))
+           (value (let ((tmp-file (org-babel-temp-file "python-")))
+                    (org-babel-eval
+                     org-babel-python-command
+                     (concat
+                      (if preamble (concat preamble "\n") "")
+                      (format
+                       (if (member "pp" result-params)
+                           org-babel-python-pp-wrapper-method
+                         org-babel-python-wrapper-method)
+                       (mapconcat
+                        (lambda (line) (format "\t%s" line))
+                        (split-string
+                         (org-remove-indentation
+                          (org-babel-trim body))
+                         "[\r\n]") "\n")
+                       (org-babel-process-file-name tmp-file 'noquote))))
+                    (org-babel-eval-read-file tmp-file))))))
+    (org-babel-result-cond result-params
+      raw
+      (org-babel-python-table-or-string (org-babel-trim raw)))))
 
 (defun org-babel-python-evaluate-session
-  (session body &optional result-type result-params)
+    (session body &optional result-type result-params)
   "Pass BODY to the Python process in SESSION.
 If RESULT-TYPE equals 'output then return standard output as a
 string.  If RESULT-TYPE equals 'value then return the value of the
@@ -252,42 +297,41 @@ last statement in BODY, as elisp."
                  (format "open('%s', 'w').write(pprint.pformat(_))"
                          (org-babel-process-file-name tmp-file 'noquote)))
               (list (format "open('%s', 'w').write(str(_))"
-                            (org-babel-process-file-name tmp-file 'noquote)))))))
+                            (org-babel-process-file-name tmp-file
+                                                          'noquote)))))))
         (input-body (lambda (body)
                       (mapc (lambda (line) (insert line) (funcall send-wait))
                             (split-string body "[\r\n]"))
-                      (funcall send-wait))))
-    ((lambda (results)
-       (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results)
-        (if (or (member "code" result-params)
-                (member "pp" result-params)
-                (and (member "output" result-params)
-                     (not (member "table" result-params))))
-            results
-          (org-babel-python-table-or-string results))))
-     (case result-type
-       (output
-       (mapconcat
-        #'org-babel-trim
-        (butlast
-         (org-babel-comint-with-output
-             (session org-babel-python-eoe-indicator t body)
-           (funcall input-body body)
-           (funcall send-wait) (funcall send-wait)
-           (insert org-babel-python-eoe-indicator)
-           (funcall send-wait))
-         2) "\n"))
-       (value
-       (let ((tmp-file (org-babel-temp-file "python-")))
-         (org-babel-comint-with-output
-             (session org-babel-python-eoe-indicator nil body)
-           (let ((comint-process-echoes nil))
-             (funcall input-body body)
-             (funcall dump-last-value tmp-file (member "pp" result-params))
-             (funcall send-wait) (funcall send-wait)
-             (insert org-babel-python-eoe-indicator)
-             (funcall send-wait)))
-         (org-babel-eval-read-file tmp-file)))))))
+                      (funcall send-wait)))
+         (results
+          (case result-type
+            (output
+             (mapconcat
+              #'org-babel-trim
+              (butlast
+               (org-babel-comint-with-output
+                   (session org-babel-python-eoe-indicator t body)
+                 (funcall input-body body)
+                 (funcall send-wait) (funcall send-wait)
+                 (insert org-babel-python-eoe-indicator)
+                 (funcall send-wait))
+               2) "\n"))
+            (value
+             (let ((tmp-file (org-babel-temp-file "python-")))
+               (org-babel-comint-with-output
+                   (session org-babel-python-eoe-indicator nil body)
+                 (let ((comint-process-echoes nil))
+                   (funcall input-body body)
+                   (funcall dump-last-value tmp-file
+                            (member "pp" result-params))
+                   (funcall send-wait) (funcall send-wait)
+                   (insert org-babel-python-eoe-indicator)
+                   (funcall send-wait)))
+               (org-babel-eval-read-file tmp-file))))))
+    (unless (string= (substring org-babel-python-eoe-indicator 1 -1) results)
+      (org-babel-result-cond result-params
+       results
+        (org-babel-python-table-or-string results)))))
 
 (defun org-babel-python-read-string (string)
   "Strip 's from around Python string."
index 389c36318e243057970604e6ee1b1b91a868cf3e..5a3c8ba2e4894521b6ec3b41e8198d5fcbbee47b 100644 (file)
@@ -40,7 +40,7 @@
 ;; So an example of a simple src block referencing table data in the
 ;; same file would be
 
-;;  #+TBLNAME: sandbox
+;;  #+NAME: sandbox
 ;;  | 1 |         2 | 3 |
 ;;  | 4 | org-babel | 6 |
 ;;
@@ -49,7 +49,7 @@
 ;;  #+end_src
 
 ;;; Code:
-(require 'ob)
+(require 'ob-core)
 (eval-when-compile
   (require 'cl))
 
@@ -83,7 +83,10 @@ the variable."
     (let ((var (match-string 1 assignment))
          (ref (match-string 2 assignment)))
       (cons (intern var)
-           (let ((out (org-babel-read ref)))
+           (let ((out (save-excursion
+                        (when org-babel-current-src-block-location
+                          (goto-char org-babel-current-src-block-location))
+                        (org-babel-read ref))))
              (if (equal out ref)
                  (if (string-match "^\".*\"$" ref)
                      (read ref)
index 747c6fc3da2f9bcb1754c3d2ff2079e7b296ce13..fe1ee0ff09881b6e0c32de45011144b4477d71c6 100644 (file)
@@ -37,9 +37,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (declare-function run-ruby "ext:inf-ruby" (&optional command name))
 (defvar org-babel-ruby-command "ruby"
   "Name of command to use for executing ruby code.")
 
+(defcustom org-babel-ruby-hline-to "nil"
+  "Replace hlines in incoming tables with this when translating to ruby."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-babel-ruby-nil-to 'hline
+  "Replace 'nil' in ruby tables with this before returning."
+  :group 'org-babel
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+
+
 (defun org-babel-execute:ruby (body params)
   "Execute a block of Ruby code with Babel.
 This function is called by `org-babel-execute-src-block'."
@@ -71,7 +84,9 @@ This function is called by `org-babel-execute-src-block'."
                   (org-babel-ruby-evaluate
                    session full-body result-type result-params))))
     (org-babel-reassemble-table
-     result
+     (org-babel-result-cond result-params
+       result
+       (org-babel-ruby-table-or-string result))
      (org-babel-pick-name (cdr (assoc :colname-names params))
                          (cdr (assoc :colnames params)))
      (org-babel-pick-name (cdr (assoc :rowname-names params))
@@ -116,13 +131,20 @@ Convert an elisp value into a string of ruby source code
 specifying a variable of the same value."
   (if (listp var)
       (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
-    (format "%S" var)))
+    (if (equal var 'hline)
+       org-babel-ruby-hline-to
+      (format "%S" var))))
 
 (defun org-babel-ruby-table-or-string (results)
   "Convert RESULTS into an appropriate elisp value.
 If RESULTS look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-script-escape results))
+  (let ((res (org-babel-script-escape results)))
+    (if (listp res)
+        (mapcar (lambda (el) (if (equal el 'nil)
+                            org-babel-ruby-nil-to el))
+                res)
+      res)))
 
 (defun org-babel-ruby-initiate-session (&optional session params)
   "Initiate a ruby session.
@@ -181,12 +203,11 @@ return the value of the last statement in BODY, as elisp."
                              org-babel-ruby-pp-wrapper-method
                            org-babel-ruby-wrapper-method)
                          body (org-babel-process-file-name tmp-file 'noquote)))
-                ((lambda (raw)
-                   (if (or (member "code" result-params)
-                           (member "pp" result-params))
-                       raw
-                     (org-babel-ruby-table-or-string raw)))
-                 (org-babel-eval-read-file tmp-file)))))
+                (let ((raw (org-babel-eval-read-file tmp-file)))
+                   (if (or (member "code" result-params)
+                           (member "pp" result-params))
+                       raw
+                     (org-babel-ruby-table-or-string raw))))))
     ;; comint session evaluation
     (case result-type
       (output
@@ -206,31 +227,27 @@ return the value of the last statement in BODY, as elisp."
              (comint-send-input nil t)) 2)
           "\n") "[\r\n]")) "\n"))
       (value
-       ((lambda (results)
-         (if (or (member "code" result-params) (member "pp" result-params))
-             results
-           (org-babel-ruby-table-or-string results)))
-       (let* ((tmp-file (org-babel-temp-file "ruby-"))
-              (ppp (or (member "code" result-params)
-                       (member "pp" result-params))))
-         (org-babel-comint-with-output
-             (buffer org-babel-ruby-eoe-indicator t body)
-           (when ppp (insert "require 'pp';") (comint-send-input nil t))
-           (mapc
-            (lambda (line)
-              (insert (org-babel-chomp line)) (comint-send-input nil t))
-            (append
-             (list body)
-             (if (not ppp)
-                 (list (format org-babel-ruby-f-write
-                               (org-babel-process-file-name tmp-file 'noquote)))
-               (list
-                "results=_" "require 'pp'" "orig_out = $stdout"
-                (format org-babel-ruby-pp-f-write
-                        (org-babel-process-file-name tmp-file 'noquote))))
-             (list org-babel-ruby-eoe-indicator)))
-           (comint-send-input nil t))
-         (org-babel-eval-read-file tmp-file)))))))
+       (let* ((tmp-file (org-babel-temp-file "ruby-"))
+             (ppp (or (member "code" result-params)
+                      (member "pp" result-params))))
+        (org-babel-comint-with-output
+            (buffer org-babel-ruby-eoe-indicator t body)
+          (when ppp (insert "require 'pp';") (comint-send-input nil t))
+          (mapc
+           (lambda (line)
+             (insert (org-babel-chomp line)) (comint-send-input nil t))
+           (append
+            (list body)
+            (if (not ppp)
+                (list (format org-babel-ruby-f-write
+                              (org-babel-process-file-name tmp-file 'noquote)))
+              (list
+               "results=_" "require 'pp'" "orig_out = $stdout"
+               (format org-babel-ruby-pp-f-write
+                       (org-babel-process-file-name tmp-file 'noquote))))
+            (list org-babel-ruby-eoe-indicator)))
+          (comint-send-input nil t))
+        (org-babel-eval-read-file tmp-file))))))
 
 (defun org-babel-ruby-read-string (string)
   "Strip \\\"s from around a ruby string."
index 60a10dbee590e5b8228d38f2fc143d6d831444e4..cdb75bea092491920dd4a0e5f47ded366b61639d 100644 (file)
@@ -39,7 +39,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
 
 (defvar org-babel-default-header-args:sass '())
 
index 3a07b344b234047f93c55af0f2b739d5b90fdf08..f77836194578cfbf4ccf9f33ab164c4cd11bd5c7 100644 (file)
@@ -31,9 +31,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (eval-when-compile (require 'cl))
 
 (defvar org-babel-tangle-lang-exts) ;; Autoloaded
@@ -103,12 +100,11 @@ in BODY as elisp."
      (let* ((src-file (org-babel-temp-file "scala-"))
             (wrapper (format org-babel-scala-wrapper-method body)))
        (with-temp-file src-file (insert wrapper))
-       ((lambda (raw)
-          (if (member "code" result-params)
-              raw
-            (org-babel-scala-table-or-string raw)))
-        (org-babel-eval
-         (concat org-babel-scala-command " " src-file) ""))))))
+       (let ((raw (org-babel-eval
+                   (concat org-babel-scala-command " " src-file) "")))
+         (org-babel-result-cond result-params
+          raw
+           (org-babel-scala-table-or-string raw)))))))
 
 
 (defun org-babel-prep-session:scala (session params)
index bd7ea823f7134e221cfbad2401b286c20dad1c9f..f979640a5a1602039055cbf8181422707a9fa7b9 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
-;; Author: Eric Schulte
+;; Authors: Eric Schulte, Michael Gauland
 ;; Keywords: literate programming, reproducible research, scheme
 ;; Homepage: http://orgmode.org
 
 ;; - a working scheme implementation
 ;;   (e.g. guile http://www.gnu.org/software/guile/guile.html)
 ;;
-;; - for session based evaluation cmuscheme.el is required which is
-;;   included in Emacs
+;; - for session based evaluation geiser is required, which is available from
+;;   ELPA.
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
-(eval-when-compile (require 'cl))
+(require 'geiser nil t)
+(defvar geiser-repl--repl)             ; Defined in geiser-repl.el
+(defvar geiser-impl--implementation)   ; Defined in geiser-impl.el
+(defvar geiser-default-implementation) ; Defined in geiser-impl.el
+(defvar geiser-active-implementations) ; Defined in geiser-impl.el
 
-(declare-function run-scheme "ext:cmuscheme" (cmd))
+(declare-function run-geiser "geiser-repl" (impl))
+(declare-function geiser-mode "geiser-mode" ())
+(declare-function geiser-eval-region "geiser-mode" (start end &optional and-go raw nomsg))
+(declare-function geiser-repl-exit "geiser-repl" (&optional arg))
 
 (defvar org-babel-default-header-args:scheme '()
   "Default header arguments for scheme code blocks.")
 
-(defvar org-babel-scheme-eoe "org-babel-scheme-eoe"
-  "String to indicate that evaluation has completed.")
-
-(defcustom org-babel-scheme-cmd "guile"
-  "Name of command used to evaluate scheme blocks."
-  :group 'org-babel
-  :version "24.1"
-  :type 'string)
-
 (defun org-babel-expand-body:scheme (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
                 ")\n" body ")")
       body)))
 
-(defvar scheme-program-name)
+
+(defvar org-babel-scheme-repl-map (make-hash-table :test 'equal)
+  "Map of scheme sessions to session names.")
+
+(defun org-babel-scheme-cleanse-repl-map ()
+  "Remove dead buffers from the REPL map."
+  (maphash
+   (lambda (x y)
+     (when (not (buffer-name y))
+       (remhash x org-babel-scheme-repl-map)))
+   org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-session-buffer (session-name)
+  "Look up the scheme buffer for a session; return nil if it doesn't exist."
+  (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions
+  (gethash session-name org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-set-session-buffer (session-name buffer)
+  "Record the scheme buffer used for a given session."
+  (puthash session-name buffer org-babel-scheme-repl-map))
+
+(defun org-babel-scheme-get-buffer-impl (buffer)
+  "Returns the scheme implementation geiser associates with the buffer."
+  (with-current-buffer (set-buffer buffer)
+    geiser-impl--implementation))
+
+(defun org-babel-scheme-get-repl (impl name)
+  "Switch to a scheme REPL, creating it if it doesn't exist:"
+  (let ((buffer (org-babel-scheme-get-session-buffer name)))
+    (or buffer
+       (progn
+         (run-geiser impl)
+         (if name
+             (progn
+               (rename-buffer name t)
+               (org-babel-scheme-set-session-buffer name (current-buffer))))
+         (current-buffer)))))
+
+(defun org-babel-scheme-make-session-name (buffer name impl)
+  "Generate a name for the session buffer.
+
+For a named session, the buffer name will be the session name.
+
+If the session is unnamed (nil), generate a name.
+
+If the session is 'none', use nil for the session name, and
+org-babel-scheme-execute-with-geiser will use a temporary session."
+  (let ((result
+        (cond ((not name)
+               (concat buffer " " (symbol-name impl) " REPL"))
+              ((string= name "none") nil)
+              (name))))
+    result))
+
+(defun org-babel-scheme-execute-with-geiser (code output impl repl)
+  "Execute code in specified REPL. If the REPL doesn't exist, create it
+using the given scheme implementation.
+
+Returns the output of executing the code if the output parameter
+is true; otherwise returns the last value."
+  (let ((result nil))
+    (with-temp-buffer
+      (insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl))
+      (newline)
+      (insert (if output
+                 (format "(with-output-to-string (lambda () %s))" code)
+               code))
+      (geiser-mode)
+      (let ((repl-buffer (save-current-buffer
+                          (org-babel-scheme-get-repl impl repl))))
+       (when (not (eq impl (org-babel-scheme-get-buffer-impl
+                            (current-buffer))))
+         (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
+                  (org-babel-scheme-get-buffer-impl (current-buffer))
+                  (symbolp (org-babel-scheme-get-buffer-impl
+                            (current-buffer)))))
+       (setq geiser-repl--repl repl-buffer)
+       (setq geiser-impl--implementation nil)
+       (geiser-eval-region (point-min) (point-max))
+       (setq result
+             (if (equal (substring (current-message) 0 3) "=> ")
+                 (replace-regexp-in-string "^=> " "" (current-message))
+               "\"An error occurred.\""))
+       (when (not repl)
+         (save-current-buffer (set-buffer repl-buffer)
+                              (geiser-repl-exit))
+         (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
+         (kill-buffer repl-buffer))
+       (setq result (if (or (string= result "#<void>")
+                            (string= result "#<unspecified>"))
+                        nil
+                      (read result)))))
+    result))
+
 (defun org-babel-execute:scheme (body params)
   "Execute a block of Scheme code with org-babel.
 This function is called by `org-babel-execute-src-block'"
-  (let* ((result-type (cdr (assoc :result-type params)))
-        (org-babel-scheme-cmd (or (cdr (assoc :scheme params))
-                                  org-babel-scheme-cmd))
-         (full-body (org-babel-expand-body:scheme body params)))
-    (read
-     (if (not (string= (cdr (assoc :session params)) "none"))
-         ;; session evaluation
-        (let ((session (org-babel-prep-session:scheme
-                        (cdr (assoc :session params)) params)))
-          (org-babel-comint-with-output
-              (session (format "%S" org-babel-scheme-eoe) t body)
-            (mapc
-             (lambda (line)
-               (insert (org-babel-chomp line)) (comint-send-input nil t))
-             (list body (format "%S" org-babel-scheme-eoe)))))
-       ;; external evaluation
-       (let ((script-file (org-babel-temp-file "scheme-script-")))
-         (with-temp-file script-file
-           (insert
-            ;; return the value or the output
-            (if (string= result-type "value")
-                (format "(display %s)" full-body)
-              full-body)))
-         (org-babel-eval
-         (format "%s %s" org-babel-scheme-cmd
-                 (org-babel-process-file-name script-file)) ""))))))
-
-(defun org-babel-prep-session:scheme (session params)
-  "Prepare SESSION according to the header arguments specified in PARAMS."
-  (let* ((session (org-babel-scheme-initiate-session session))
-        (vars (mapcar #'cdr (org-babel-get-header params :var)))
-        (var-lines
-         (mapcar
-          (lambda (var) (format "%S" (print `(define ,(car var) ',(cdr var)))))
-          vars)))
-    (when session
-      (org-babel-comint-in-buffer session
-       (sit-for .5) (goto-char (point-max))
-       (mapc (lambda (var)
-               (insert var) (comint-send-input nil t)
-               (org-babel-comint-wait-for-output session)
-               (sit-for .1) (goto-char (point-max))) var-lines)))
-    session))
-
-(defun org-babel-scheme-initiate-session (&optional session)
-  "If there is not a current inferior-process-buffer in SESSION
-then create.  Return the initialized session."
-  (require 'cmuscheme)
-  (unless (string= session "none")
-    (let ((session-buffer (save-window-excursion
-                           (run-scheme org-babel-scheme-cmd)
-                           (rename-buffer session)
-                           (current-buffer))))
-      (if (org-babel-comint-buffer-livep session-buffer)
-         (progn (sit-for .25) session-buffer)
-        (sit-for .5)
-        (org-babel-scheme-initiate-session session)))))
+  (let* ((source-buffer (current-buffer))
+        (source-buffer-name (replace-regexp-in-string ;; zap surrounding *
+                             "^ ?\\*\\([^*]+\\)\\*" "\\1"
+                             (buffer-name source-buffer))))
+    (save-excursion
+      (org-babel-reassemble-table
+       (let* ((result-type (cdr (assoc :result-type params)))
+             (impl (or (when (cdr (assoc :scheme params))
+                         (intern (cdr (assoc :scheme params))))
+                       geiser-default-implementation
+                       (car geiser-active-implementations)))
+             (session (org-babel-scheme-make-session-name
+                       source-buffer-name (cdr (assoc :session params)) impl))
+             (full-body (org-babel-expand-body:scheme body params)))
+        (org-babel-scheme-execute-with-geiser
+         full-body                      ; code
+         (string= result-type "output") ; output?
+         impl                           ; implementation
+         (and (not (string= session "none")) session))) ; session
+       (org-babel-pick-name (cdr (assoc :colname-names params))
+                           (cdr (assoc :colnames params)))
+       (org-babel-pick-name (cdr (assoc :rowname-names params))
+                           (cdr (assoc :rownames params)))))))
 
 (provide 'ob-scheme)
 
-
-
 ;;; ob-scheme.el ends here
index 621110b2d49a0acc0b9c8c6525dcf1b7149b25f2..f26337697ae585ec5d6e3d2ab35be7db42bff964 100644 (file)
@@ -34,7 +34,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
 
 (defvar org-babel-screen-location "screen"
   "The command location for screen.
index c0e6b15feb9560b8b27b97262e0e492ff39b651b..4984ff9bf45c87f5a7b82906418cc4459026b110 100644 (file)
@@ -27,9 +27,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
 (require 'shell)
 (eval-when-compile (require 'cl))
 
@@ -56,9 +53,9 @@ This will be passed to  `shell-command-on-region'")
 This function is called by `org-babel-execute-src-block'."
   (let* ((session (org-babel-sh-initiate-session
                   (cdr (assoc :session params))))
-        (stdin ((lambda (stdin) (when stdin (org-babel-sh-var-to-string
-                                             (org-babel-ref-resolve stdin))))
-                (cdr (assoc :stdin params))))
+        (stdin (let ((stdin (cdr (assoc :stdin params))))
+                  (when stdin (org-babel-sh-var-to-string
+                               (org-babel-ref-resolve stdin)))))
          (full-body (org-babel-expand-body:generic
                     body params (org-babel-variable-assignments:sh params))))
     (org-babel-reassemble-table
@@ -109,7 +106,7 @@ var of the same value."
   "Convert an elisp value to a string."
   (let ((echo-var (lambda (v) (if (stringp v) v (format "%S" v)))))
     (cond
-     ((and (listp var) (listp (car var)))
+     ((and (listp var) (or (listp (car var)) (equal (car var) 'hline)))
       (orgtbl-to-generic var  (list :sep (or sep "\t") :fmt echo-var)))
      ((listp var)
       (mapconcat echo-var var "\n"))
@@ -138,70 +135,69 @@ Emacs-lisp table, otherwise return the results as a string."
 If RESULT-TYPE equals 'output then return a list of the outputs
 of the statements in BODY, if RESULT-TYPE equals 'value then
 return the value of the last statement in BODY."
-  ((lambda (results)
-     (when results
-       (let ((result-params (cdr (assoc :result-params params))))
-        (if (or (member "scalar" result-params)
-                (member "verbatim" result-params)
-                (member "output" result-params))
-            results
-          (let ((tmp-file (org-babel-temp-file "sh-")))
-            (with-temp-file tmp-file (insert results))
-            (org-babel-import-elisp-from-file tmp-file))))))
-   (cond
-    (stdin                             ; external shell script w/STDIN
-     (let ((script-file (org-babel-temp-file "sh-script-"))
-          (stdin-file (org-babel-temp-file "sh-stdin-"))
-          (shebang (cdr (assoc :shebang params)))
-          (padline (not (string= "no" (cdr (assoc :padline params))))))
-       (with-temp-file script-file
-        (when shebang (insert (concat shebang "\n")))
-        (when padline (insert "\n"))
-        (insert body))
-       (set-file-modes script-file #o755)
-       (with-temp-file stdin-file (insert stdin))
-       (with-temp-buffer
-        (call-process-shell-command
-         (if shebang
-             script-file
-           (format "%s %s" org-babel-sh-command script-file))
-         stdin-file
-         (current-buffer))
-        (buffer-string))))
-    (session                           ; session evaluation
-     (mapconcat
-      #'org-babel-sh-strip-weird-long-prompt
-      (mapcar
-       #'org-babel-trim
-       (butlast
-       (org-babel-comint-with-output
-           (session org-babel-sh-eoe-output t body)
-         (mapc
-          (lambda (line)
-            (insert line)
-            (comint-send-input nil t)
-            (while (save-excursion
-                     (goto-char comint-last-input-end)
-                     (not (re-search-forward
-                           comint-prompt-regexp nil t)))
-              (accept-process-output (get-buffer-process (current-buffer)))))
-          (append
-           (split-string (org-babel-trim body) "\n")
-           (list org-babel-sh-eoe-indicator))))
-       2)) "\n"))
-    ('otherwise                                ; external shell script
-     (if (and (cdr (assoc :shebang params))
-             (> (length (cdr (assoc :shebang params))) 0))
-        (let ((script-file (org-babel-temp-file "sh-script-"))
-              (shebang (cdr (assoc :shebang params)))
-              (padline (not (string= "no" (cdr (assoc :padline params))))))
-          (with-temp-file script-file
-            (when shebang (insert (concat shebang "\n")))
-            (when padline (insert "\n"))
-            (insert body))
-          (set-file-modes script-file #o755)
-          (org-babel-eval script-file ""))
-       (org-babel-eval org-babel-sh-command (org-babel-trim body)))))))
+  (let ((results
+         (cond
+          (stdin                        ; external shell script w/STDIN
+           (let ((script-file (org-babel-temp-file "sh-script-"))
+                 (stdin-file (org-babel-temp-file "sh-stdin-"))
+                 (shebang (cdr (assoc :shebang params)))
+                 (padline (not (string= "no" (cdr (assoc :padline params))))))
+             (with-temp-file script-file
+               (when shebang (insert (concat shebang "\n")))
+               (when padline (insert "\n"))
+               (insert body))
+             (set-file-modes script-file #o755)
+             (with-temp-file stdin-file (insert stdin))
+             (with-temp-buffer
+               (call-process-shell-command
+                (if shebang
+                    script-file
+                  (format "%s %s" org-babel-sh-command script-file))
+                stdin-file
+                (current-buffer))
+               (buffer-string))))
+          (session                      ; session evaluation
+           (mapconcat
+            #'org-babel-sh-strip-weird-long-prompt
+            (mapcar
+             #'org-babel-trim
+             (butlast
+              (org-babel-comint-with-output
+                  (session org-babel-sh-eoe-output t body)
+                (mapc
+                 (lambda (line)
+                   (insert line)
+                   (comint-send-input nil t)
+                   (while (save-excursion
+                            (goto-char comint-last-input-end)
+                            (not (re-search-forward
+                                  comint-prompt-regexp nil t)))
+                     (accept-process-output
+                      (get-buffer-process (current-buffer)))))
+                 (append
+                  (split-string (org-babel-trim body) "\n")
+                  (list org-babel-sh-eoe-indicator))))
+              2)) "\n"))
+          ('otherwise                   ; external shell script
+           (if (and (cdr (assoc :shebang params))
+                    (> (length (cdr (assoc :shebang params))) 0))
+               (let ((script-file (org-babel-temp-file "sh-script-"))
+                     (shebang (cdr (assoc :shebang params)))
+                     (padline (not (equal "no" (cdr (assoc :padline params))))))
+                 (with-temp-file script-file
+                   (when shebang (insert (concat shebang "\n")))
+                   (when padline (insert "\n"))
+                   (insert body))
+                 (set-file-modes script-file #o755)
+                 (org-babel-eval script-file ""))
+             (org-babel-eval org-babel-sh-command (org-babel-trim body)))))))
+    (when results
+      (let ((result-params (cdr (assoc :result-params params))))
+        (org-babel-result-cond result-params
+          results
+          (let ((tmp-file (org-babel-temp-file "sh-")))
+            (with-temp-file tmp-file (insert results))
+            (org-babel-import-elisp-from-file tmp-file)))))))
 
 (defun org-babel-sh-strip-weird-long-prompt (string)
   "Remove prompt cruft from a string of shell output."
index ec31546a0acecfe7b68b51dd83951bfc804a1fcf..68169da9a689c499074b7a975b991a17f9c2c34d 100644 (file)
@@ -36,6 +36,7 @@
 (require 'ob)
 
 (declare-function shen-eval-defun "ext:inf-shen" (&optional and-go))
+(declare-function org-babel-ruby-var-to-ruby "ob-ruby" (var))
 
 (defvar org-babel-default-header-args:shen '()
   "Default header arguments for shen code blocks.")
@@ -65,15 +66,14 @@ This function is called by `org-babel-execute-src-block'"
   (let* ((result-type (cdr (assoc :result-type params)))
         (result-params (cdr (assoc :result-params params)))
          (full-body (org-babel-expand-body:shen body params)))
-    ((lambda (results)
-       (if (or (member 'scalar result-params)
-              (member 'verbatim result-params))
-          results
-        (condition-case nil (org-babel-script-escape results)
-          (error results))))
-     (with-temp-buffer
-       (insert full-body)
-       (call-interactively #'shen-eval-defun)))))
+    (let ((results
+           (with-temp-buffer
+             (insert full-body)
+             (call-interactively #'shen-eval-defun))))
+      (org-babel-result-cond result-params 
+        results
+        (condition-case nil (org-babel-script-escape results)
+          (error results))))))
 
 (provide 'ob-shen)
 ;;; ob-shen.el ends here
index 131fa46f147577600aca5d105f710ea6867636a1..d17dd8a7f9d515823d788b90144dd996a4a896d2 100644 (file)
 ;;
 ;; Also SQL evaluation generally takes place inside of a database.
 ;;
-;; For now lets just allow a generic ':cmdline' header argument.
+;; Header args used:
+;; - engine
+;; - cmdline
+;; - dbhost
+;; - dbuser
+;; - dbpassword
+;; - database
+;; - colnames (default, nil, means "yes")
+;; - result-params
+;; - out-file
+;; The following are used but not really implemented for SQL:
+;; - colname-names
+;; - rownames
+;; - rowname-names
 ;;
 ;; TODO:
 ;;
 ;; - support for sessions
-;; - add more useful header arguments (user, passwd, database, etc...)
 ;; - support for more engines (currently only supports mysql)
 ;; - what's a reasonable way to drop table data into SQL?
 ;;
 
 (defvar org-babel-default-header-args:sql '())
 
-(defvar org-babel-header-args:sql
-  '((engine   . :any)
-    (out-file . :any)))
+(defconst org-babel-header-args:sql
+  '((engine           . :any)
+    (out-file         . :any)
+    (dbhost           . :any)
+    (dbuser           . :any)
+    (dbpassword               . :any)
+    (database         . :any))
+  "SQL-specific header arguments.")
 
 (defun org-babel-expand-body:sql (body params)
   "Expand BODY according to the values of PARAMS."
   (org-babel-sql-expand-vars
    body (mapcar #'cdr (org-babel-get-header params :var))))
 
+(defun dbstring-mysql (host user password database)
+  "Make MySQL cmd line args for database connection.  Pass nil to omit that arg."
+  (combine-and-quote-strings
+   (remq nil
+        (list (when host     (concat "-h" host))
+              (when user     (concat "-u" user))
+              (when password (concat "-p" password))
+              (when database (concat "-D" database))))))
+
 (defun org-babel-execute:sql (body params)
   "Execute a block of Sql code with Babel.
 This function is called by `org-babel-execute-src-block'."
   (let* ((result-params (cdr (assoc :result-params params)))
          (cmdline (cdr (assoc :cmdline params)))
+         (dbhost (cdr (assoc :dbhost params)))
+         (dbuser (cdr (assoc :dbuser params)))
+         (dbpassword (cdr (assoc :dbpassword params)))
+         (database (cdr (assoc :database params)))
          (engine (cdr (assoc :engine params)))
+         (colnames-p (not (equal "no" (cdr (assoc :colnames params)))))
          (in-file (org-babel-temp-file "sql-in-"))
          (out-file (or (cdr (assoc :out-file params))
                        (org-babel-temp-file "sql-out-")))
         (header-delim "")
          (command (case (intern engine)
-                    ('dbi (format "dbish --batch '%s' < %s | sed '%s' > %s"
+                    ('dbi (format "dbish --batch %s < %s | sed '%s' > %s"
                                  (or cmdline "")
                                  (org-babel-process-file-name in-file)
-                                 "/^+/d;s/^\|//;$d"
+                                 "/^+/d;s/^\|//;s/(NULL)/ /g;$d"
                                  (org-babel-process-file-name out-file)))
                     ('monetdb (format "mclient -f tab %s < %s > %s"
                                       (or cmdline "")
@@ -85,7 +116,9 @@ This function is called by `org-babel-execute-src-block'."
                                      (or cmdline "")
                                      (org-babel-process-file-name in-file)
                                      (org-babel-process-file-name out-file)))
-                    ('mysql (format "mysql %s < %s > %s"
+                    ('mysql (format "mysql %s %s %s < %s > %s"
+                                   (dbstring-mysql dbhost dbuser dbpassword database)
+                                   (if colnames-p "" "-N")
                                     (or cmdline "")
                                    (org-babel-process-file-name in-file)
                                    (org-babel-process-file-name out-file)))
@@ -102,28 +135,39 @@ This function is called by `org-babel-execute-src-block'."
         (t ""))
        (org-babel-expand-body:sql body params)))
     (message command)
-    (shell-command command)
-    (if (or (member "scalar" result-params)
-           (member "verbatim" result-params)
-           (member "html" result-params)
-           (member "code" result-params)
-           (equal (point-min) (point-max)))
-       (with-temp-buffer
+    (org-babel-eval command "")
+    (org-babel-result-cond result-params
+      (with-temp-buffer
          (progn (insert-file-contents-literally out-file) (buffer-string)))
       (with-temp-buffer
-       ;; need to figure out what the delimiter is for the header row
-       (with-temp-buffer
-         (insert-file-contents out-file)
-         (goto-char (point-min))
-         (when (re-search-forward "^\\(-+\\)[^-]" nil t)
-           (setq header-delim (match-string-no-properties 1)))
-         (goto-char (point-max))
-         (forward-char -1)
-         (while (looking-at "\n")
-           (delete-char 1)
-           (goto-char (point-max))
-           (forward-char -1))
-         (write-file out-file))
+       (cond
+         ((or (eq (intern engine) 'mysql)
+              (eq (intern engine) 'dbi)
+              (eq (intern engine) 'postgresql))
+          ;; Add header row delimiter after column-names header in first line
+          (cond
+           (colnames-p
+            (with-temp-buffer
+              (insert-file-contents out-file)
+              (goto-char (point-min))
+              (forward-line 1)
+              (insert "-\n")
+              (setq header-delim "-")
+              (write-file out-file)))))
+         (t
+          ;; Need to figure out the delimiter for the header row
+          (with-temp-buffer
+            (insert-file-contents out-file)
+            (goto-char (point-min))
+            (when (re-search-forward "^\\(-+\\)[^-]" nil t)
+              (setq header-delim (match-string-no-properties 1)))
+            (goto-char (point-max))
+            (forward-char -1)
+            (while (looking-at "\n")
+              (delete-char 1)
+              (goto-char (point-max))
+              (forward-char -1))
+            (write-file out-file))))
        (org-table-import out-file '(16))
        (org-babel-reassemble-table
         (mapcar (lambda (x)
@@ -142,19 +186,17 @@ This function is called by `org-babel-execute-src-block'."
    (lambda (pair)
      (setq body
           (replace-regexp-in-string
-           (format "\$%s" (car pair))
-           ((lambda (val)
-              (if (listp val)
-                  ((lambda (data-file)
-                     (with-temp-file data-file
-                       (insert (orgtbl-to-csv
-                                val '(:fmt (lambda (el) (if (stringp el)
-                                                            el
-                                                          (format "%S" el)))))))
-                     data-file)
-                   (org-babel-temp-file "sql-data-"))
-                (if (stringp val) val (format "%S" val))))
-            (cdr pair))
+           (format "\$%s" (car pair))  ;FIXME: "\$" == "$"!
+           (let ((val (cdr pair)))
+              (if (listp val)
+                  (let ((data-file (org-babel-temp-file "sql-data-")))
+                    (with-temp-file data-file
+                      (insert (orgtbl-to-csv
+                               val '(:fmt (lambda (el) (if (stringp el)
+                                                      el
+                                                    (format "%S" el)))))))
+                    data-file)
+                (if (stringp val) val (format "%S" val))))
            body)))
    vars)
   body)
index c25e786fb61e42a7099ec151e100e6bb6f6d94ec..fcfdb8ebd3e3de965355e67c38eed7c9550e712c 100644 (file)
@@ -27,8 +27,6 @@
 
 ;;; Code:
 (require 'ob)
-(require 'ob-eval)
-(require 'ob-ref)
 
 (declare-function org-fill-template "org" (template alist))
 (declare-function org-table-convert-region "org-table"
@@ -98,43 +96,40 @@ This function is called by `org-babel-execute-src-block'."
          (cons "db " db)))
        ;; body of the code block
        (org-babel-expand-body:sqlite body params)))
-      (if (or (member "scalar" result-params)
-             (member "verbatim" result-params)
-             (member "html" result-params)
-             (member "code" result-params)
-             (equal (point-min) (point-max)))
-         (buffer-string)
-       (org-table-convert-region (point-min) (point-max)
-                                 (if (or (member :csv others)
-                                         (member :column others)
-                                         (member :line others)
-                                         (member :list others)
-                                         (member :html others) separator)
-                                     nil
-                                   '(4)))
-       (org-babel-sqlite-table-or-scalar
-        (org-babel-sqlite-offset-colnames
-         (org-table-to-lisp) headers-p))))))
+      (org-babel-result-cond result-params
+       (buffer-string)
+       (if (equal (point-min) (point-max))
+           ""
+         (org-table-convert-region (point-min) (point-max)
+                                   (if (or (member :csv others)
+                                           (member :column others)
+                                           (member :line others)
+                                           (member :list others)
+                                           (member :html others) separator)
+                                       nil
+                                     '(4)))
+         (org-babel-sqlite-table-or-scalar
+          (org-babel-sqlite-offset-colnames
+           (org-table-to-lisp) headers-p)))))))
 
 (defun org-babel-sqlite-expand-vars (body vars)
   "Expand the variables held in VARS in BODY."
+  ;; FIXME: Redundancy with org-babel-sql-expand-vars!
   (mapc
    (lambda (pair)
      (setq body
           (replace-regexp-in-string
-           (format "\$%s" (car pair))
-           ((lambda (val)
-              (if (listp val)
-                  ((lambda (data-file)
-                     (with-temp-file data-file
-                       (insert (orgtbl-to-csv
-                                val '(:fmt (lambda (el) (if (stringp el)
-                                                            el
-                                                          (format "%S" el)))))))
-                     data-file)
-                   (org-babel-temp-file "sqlite-data-"))
-                (if (stringp val) val (format "%S" val))))
-            (cdr pair))
+           (format "\$%s" (car pair))  ;FIXME: "\$" == "$"!
+           (let ((val (cdr pair)))
+              (if (listp val)
+                  (let ((data-file (org-babel-temp-file "sqlite-data-")))
+                    (with-temp-file data-file
+                      (insert (orgtbl-to-csv
+                               val '(:fmt (lambda (el) (if (stringp el)
+                                                      el
+                                                    (format "%S" el)))))))
+                    data-file)
+                (if (stringp val) val (format "%S" val))))
            body)))
    vars)
   body)
@@ -147,7 +142,7 @@ This function is called by `org-babel-execute-src-block'."
     (mapcar (lambda (row)
              (if (equal 'hline row)
                  'hline
-               (mapcar #'org-babel-read row))) result)))
+               (mapcar #'org-babel-string-read row))) result)))
 
 (defun org-babel-sqlite-offset-colnames (table headers-p)
   "If HEADERS-P is non-nil then offset the first row as column names."
index 99951cab7bffb5b1388cdf35a1545ae75412d912..c71bb8758f8c7fbd5e818e53a2b857aa375924d1 100644 (file)
@@ -50,7 +50,7 @@
 ;; #+TBLFM: $2='(sbe 'fibbd (n $1))
 
 ;;; Code:
-(require 'ob)
+(require 'ob-core)
 
 (defun org-babel-table-truncate-at-newline (string)
   "Replace newline character with ellipses.
@@ -60,7 +60,7 @@ character and replace it with ellipses."
       (concat (substring string 0 (match-beginning 0))
              (if (match-string 1 string) "...")) string))
 
-(defmacro sbe (source-block &rest variables)
+(defmacro sbe (source-block &rest variables) ;FIXME: Namespace prefix!
   "Return the results of calling SOURCE-BLOCK with VARIABLES.
 Each element of VARIABLES should be a two
 element list, whose first element is the name of the variable and
@@ -85,6 +85,7 @@ as shown in the example below.
 
 | 1 | 2 | :file nothing.png | nothing.png |
 #+TBLFM: @1$4='(sbe test-sbe $3 (x $1) (y $2))"
+  (declare (debug (form form)))
   (let* ((header-args (if (stringp (car variables)) (car variables) ""))
         (variables (if (stringp (car variables)) (cdr variables) variables)))
     (let* (quote
@@ -97,39 +98,41 @@ as shown in the example below.
                                (lambda (el)
                                  (if (eq '$ el)
                                      (prog1 nil (setq quote t))
-                                   (prog1 (if quote
-                                              (format "\"%s\"" el)
-                                            (org-no-properties el))
+                                   (prog1
+                                       (cond
+                                        (quote (format "\"%s\"" el))
+                                        ((stringp el) (org-no-properties el))
+                                        (t el))
                                      (setq quote nil))))
                                (cdr var)))))
             variables)))
       (unless (stringp source-block)
        (setq source-block (symbol-name source-block)))
-      ((lambda (result)
-        (org-babel-trim (if (stringp result) result (format "%S" result))))
-       (if (and source-block (> (length source-block) 0))
-          (let ((params
-                 (eval `(org-babel-parse-header-arguments
-                         (concat
-                          ":var results="
-                          ,source-block
-                          "[" ,header-args "]"
-                          "("
-                          (mapconcat
-                           (lambda (var-spec)
-                             (if (> (length (cdr var-spec)) 1)
-                                 (format "%S='%S"
-                                         (car var-spec)
-                                         (mapcar #'read (cdr var-spec)))
-                               (format "%S=%s"
-                                       (car var-spec) (cadr var-spec))))
-                           ',variables ", ")
-                          ")")))))
-            (org-babel-execute-src-block
-             nil (list "emacs-lisp" "results" params)
-             '((:results . "silent"))))
-        "")))))
-(def-edebug-spec sbe (form form))
+      (let ((result
+             (if (and source-block (> (length source-block) 0))
+                 (let ((params
+                        ;; FIXME: Why `eval'?!?!?
+                        (eval `(org-babel-parse-header-arguments
+                                (concat
+                                 ":var results="
+                                 ,source-block
+                                 "[" ,header-args "]"
+                                 "("
+                                 (mapconcat
+                                  (lambda (var-spec)
+                                    (if (> (length (cdr var-spec)) 1)
+                                        (format "%S='%S"
+                                                (car var-spec)
+                                                (mapcar #'read (cdr var-spec)))
+                                      (format "%S=%s"
+                                              (car var-spec) (cadr var-spec))))
+                                  ',variables ", ")
+                                 ")")))))
+                   (org-babel-execute-src-block
+                    nil (list "emacs-lisp" "results" params)
+                    '((:results . "silent"))))
+               "")))
+        (org-babel-trim (if (stringp result) result (format "%S" result)))))))
 
 (provide 'ob-table)
 
index c3b6a483ee6836ef76895a832683a5612176dc8b..ffc74cb22a94cab3326800dd7ba4d98bc74c2636 100644 (file)
 ;; Extract the code from source blocks out into raw source-code files.
 
 ;;; Code:
-(require 'ob)
 (require 'org-src)
 (eval-when-compile
   (require 'cl))
 
+(declare-function org-edit-special "org" (&optional arg))
 (declare-function org-link-escape "org" (text &optional table))
+(declare-function org-store-link "org" (arg))
+(declare-function org-open-link-from-string "org" (s &optional arg reference-buffer))
 (declare-function org-heading-components "org" ())
 (declare-function org-back-to-heading "org" (invisible-ok))
 (declare-function org-fill-template "org" (template alist))
@@ -112,7 +114,7 @@ result.  The default value is `org-babel-trim'."
 (defun org-babel-find-file-noselect-refresh (file)
   "Find file ensuring that the latest changes on disk are
 represented in the file."
-  (find-file-noselect file)
+  (find-file-noselect file 'nowarn)
   (with-current-buffer (get-file-buffer file)
     (revert-buffer t t t)))
 
@@ -136,69 +138,49 @@ evaluating BODY."
        ,temp-result)))
 (def-edebug-spec org-babel-with-temp-filebuffer (form body))
 
-;;;###autoload
-(defun org-babel-load-file (file)
-  "Load Emacs Lisp source code blocks in the Org-mode FILE.
-This function exports the source code using
-`org-babel-tangle' and then loads the resulting file using
-`load-file'."
-  (interactive "fFile to load: ")
-  (let* ((age (lambda (file)
-               (float-time
-                (time-subtract (current-time)
-                               (nth 5 (or (file-attributes (file-truename file))
-                                          (file-attributes file)))))))
-        (base-name (file-name-sans-extension file))
-        (exported-file (concat base-name ".el")))
-    ;; tangle if the org-mode file is newer than the elisp file
-    (unless (and (file-exists-p exported-file)
-                (> (funcall age file) (funcall age exported-file)))
-      (org-babel-tangle-file file exported-file "emacs-lisp"))
-    (load-file exported-file)
-    (message "Loaded %s" exported-file)))
-
 ;;;###autoload
 (defun org-babel-tangle-file (file &optional target-file lang)
   "Extract the bodies of source code blocks in FILE.
 Source code blocks are extracted with `org-babel-tangle'.
 Optional argument TARGET-FILE can be used to specify a default
 export file for all source blocks.  Optional argument LANG can be
-used to limit the exported source code blocks by language."
+used to limit the exported source code blocks by language.
+Return a list whose CAR is the tangled file name."
   (interactive "fFile to tangle: \nP")
   (let ((visited-p (get-file-buffer (expand-file-name file)))
        to-be-removed)
-    (save-window-excursion
-      (find-file file)
-      (setq to-be-removed (current-buffer))
-      (org-babel-tangle nil target-file lang))
-    (unless visited-p
-      (kill-buffer to-be-removed))))
+    (prog1
+       (save-window-excursion
+         (find-file file)
+         (setq to-be-removed (current-buffer))
+         (org-babel-tangle nil target-file lang))
+      (unless visited-p
+       (kill-buffer to-be-removed)))))
 
 (defun org-babel-tangle-publish (_ filename pub-dir)
   "Tangle FILENAME and place the results in PUB-DIR."
   (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
 
 ;;;###autoload
-(defun org-babel-tangle (&optional only-this-block target-file lang)
+(defun org-babel-tangle (&optional arg target-file lang)
   "Write code blocks to source-specific files.
 Extract the bodies of all source code blocks from the current
-file into their own source-specific files.  Optional argument
-TARGET-FILE can be used to specify a default export file for all
-source blocks.  Optional argument LANG can be used to limit the
-exported source code blocks by language."
+file into their own source-specific files.
+With one universal prefix argument, only tangle the block at point.
+When two universal prefix arguments, only tangle blocks for the
+tangle file of the block at point.
+Optional argument TARGET-FILE can be used to specify a default
+export file for all source blocks.  Optional argument LANG can be
+used to limit the exported source code blocks by language."
   (interactive "P")
   (run-hooks 'org-babel-pre-tangle-hook)
-  ;; possibly restrict the buffer to the current code block
+  ;; Possibly Restrict the buffer to the current code block
   (save-restriction
-    (when only-this-block
-      (unless (org-babel-where-is-src-block-head)
-       (error "Point is not currently inside of a code block"))
-      (save-match-data
-       (unless (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info))))
-                   target-file)
-         (setq target-file
-               (read-from-minibuffer "Tangle to: " (buffer-file-name)))))
-      (narrow-to-region (match-beginning 0) (match-end 0)))
+    (when (equal arg '(4))
+      (let ((head (org-babel-where-is-src-block-head)))
+         (if head
+             (goto-char head)
+           (user-error "Point is not in a source code block"))))
     (save-excursion
       (let ((block-counter 0)
            (org-babel-default-header-args
@@ -206,6 +188,10 @@ exported source code blocks by language."
                 (org-babel-merge-params org-babel-default-header-args
                                         (list (cons :tangle target-file)))
               org-babel-default-header-args))
+           (tangle-file
+            (when (equal arg '(16))
+              (or (cdr (assoc :tangle (nth 2 (org-babel-get-src-block-info 'light))))
+                  (user-error "Point is not in a source code block"))))
            path-collector)
        (mapc ;; map over all languages
         (lambda (by-lang)
@@ -224,8 +210,9 @@ exported source code blocks by language."
              (lambda (spec)
                (let ((get-spec (lambda (name) (cdr (assoc name (nth 4 spec))))))
                  (let* ((tangle (funcall get-spec :tangle))
-                        (she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb))
-                                   (funcall get-spec :shebang)))
+                        (she-bang (let ((sheb (funcall get-spec :shebang)))
+                                     (when (> (length sheb) 0) sheb)))
+                        (tangle-mode (funcall get-spec :tangle-mode))
                         (base-name (cond
                                     ((string= "yes" tangle)
                                      (file-name-sans-extension
@@ -237,13 +224,13 @@ exported source code blocks by language."
                                      (if (and ext (string= "yes" tangle))
                                          (concat base-name "." ext) base-name))))
                    (when file-name
-                     ;; possibly create the parent directories for file
-                     (when ((lambda (m) (and m (not (string= m "no"))))
-                            (funcall get-spec :mkdirp))
+                     ;; Possibly create the parent directories for file.
+                     (when (let ((m (funcall get-spec :mkdirp)))
+                              (and m (not (string= m "no"))))
                        (make-directory (file-name-directory file-name) 'parents))
                      ;; delete any old versions of file
                      (when (and (file-exists-p file-name)
-                                (not (member file-name path-collector)))
+                                (not (member file-name (mapcar #'car path-collector))))
                        (delete-file file-name))
                      ;; drop source-block to file
                      (with-temp-buffer
@@ -261,24 +248,35 @@ exported source code blocks by language."
                            (insert content)
                            (write-region nil nil file-name))))
                      ;; if files contain she-bangs, then make the executable
-                     (when she-bang (set-file-modes file-name #o755))
+                     (when she-bang
+                       (unless tangle-mode (setq tangle-mode #o755)))
                      ;; update counter
                      (setq block-counter (+ 1 block-counter))
-                     (add-to-list 'path-collector file-name)))))
+                     (add-to-list 'path-collector
+                                  (cons file-name tangle-mode)
+                                  nil
+                                  (lambda (a b) (equal (car a) (car b))))))))
              specs)))
-        (org-babel-tangle-collect-blocks lang))
+        (if (equal arg '(4))
+            (org-babel-tangle-single-block 1 t)
+          (org-babel-tangle-collect-blocks lang tangle-file)))
        (message "Tangled %d code block%s from %s" block-counter
                 (if (= block-counter 1) "" "s")
                 (file-name-nondirectory
-                 (buffer-file-name (or (buffer-base-buffer) (current-buffer)))))
+                 (buffer-file-name
+                  (or (buffer-base-buffer) (current-buffer)))))
        ;; run `org-babel-post-tangle-hook' in all tangled files
        (when org-babel-post-tangle-hook
          (mapc
           (lambda (file)
             (org-babel-with-temp-filebuffer file
               (run-hooks 'org-babel-post-tangle-hook)))
-          path-collector))
-       path-collector))))
+          (mapcar #'car path-collector)))
+       ;; set permissions on tangled files
+       (mapc (lambda (pair)
+               (when (cdr pair) (set-file-modes (car pair) (cdr pair))))
+             path-collector)
+       (mapcar #'car path-collector)))))
 
 (defun org-babel-tangle-clean ()
   "Remove comments inserted by `org-babel-tangle'.
@@ -298,12 +296,12 @@ references."
 (defvar org-bracket-link-regexp)
 (defun org-babel-spec-to-string (spec)
   "Insert SPEC into the current file.
-Insert the source-code specified by SPEC into the current
-source code file.  This function uses `comment-region' which
-assumes that the appropriate major-mode is set.  SPEC has the
-form
 
-  (start-line file link source-name params body comment)"
+Insert the source-code specified by SPEC into the current source
+code file.  This function uses `comment-region' which assumes
+that the appropriate major-mode is set.  SPEC has the form:
+
+  \(start-line file link source-name params body comment)"
   (let* ((start-line (nth 0 spec))
         (file (nth 1 spec))
         (link (nth 2 spec))
@@ -316,9 +314,8 @@ form
                     (string= comments "yes") (string= comments "noweb")))
         (link-data (mapcar (lambda (el)
                              (cons (symbol-name el)
-                                   ((lambda (le)
-                                      (if (stringp le) le (format "%S" le)))
-                                    (eval el))))
+                                   (let ((le (eval el)))
+                                      (if (stringp le) le (format "%S" le)))))
                            '(start-line file link source-name)))
         (insert-comment (lambda (text)
                           (when (and comments (not (string= comments "no"))
@@ -335,116 +332,137 @@ form
     (insert
      (format
       "%s\n"
-      (replace-regexp-in-string
-       "^," ""
+      (org-unescape-code-in-string
        (org-babel-trim body (if org-src-preserve-indentation "[\f\n\r\v]")))))
     (when link-p
       (funcall
        insert-comment
        (org-fill-template org-babel-tangle-comment-format-end link-data)))))
 
-(defun org-babel-tangle-collect-blocks (&optional language)
+(defvar org-comment-string) ;; Defined in org.el
+(defun org-babel-tangle-collect-blocks (&optional language tangle-file)
   "Collect source blocks in the current Org-mode file.
 Return an association list of source-code block specifications of
 the form used by `org-babel-spec-to-string' grouped by language.
-Optional argument LANG can be used to limit the collected source
-code blocks by language."
-  (let ((block-counter 1) (current-heading "") blocks)
+Optional argument LANGUAGE can be used to limit the collected
+source code blocks by language.  Optional argument TANGLE-FILE
+can be used to limit the collected code blocks by target file."
+  (let ((block-counter 1) (current-heading "") blocks by-lang)
     (org-babel-map-src-blocks (buffer-file-name)
-      ((lambda (new-heading)
-        (if (not (string= new-heading current-heading))
-            (progn
-              (setq block-counter 1)
-              (setq current-heading new-heading))
-          (setq block-counter (+ 1 block-counter))))
-       (replace-regexp-in-string "[ \t]" "-"
-                                (condition-case nil
-                                    (or (nth 4 (org-heading-components))
-                                        "(dummy for heading without text)")
-                                  (error (buffer-file-name)))))
-      (let* ((start-line (save-restriction (widen)
-                                          (+ 1 (line-number-at-pos (point)))))
-            (file (buffer-file-name))
-            (info (org-babel-get-src-block-info 'light))
-            (src-lang (nth 0 info)))
-        (unless (string= (cdr (assoc :tangle (nth 2 info))) "no")
+      (lambda (new-heading)
+       (if (not (string= new-heading current-heading))
+           (progn
+             (setq block-counter 1)
+             (setq current-heading new-heading))
+         (setq block-counter (+ 1 block-counter))))
+      (replace-regexp-in-string "[ \t]" "-"
+                               (condition-case nil
+                                   (or (nth 4 (org-heading-components))
+                                       "(dummy for heading without text)")
+                                 (error (buffer-file-name))))
+      (let* ((info (org-babel-get-src-block-info 'light))
+            (src-lang (nth 0 info))
+            (src-tfile (cdr (assoc :tangle (nth 2 info)))))
+        (unless (or (string-match (concat "^" org-comment-string) current-heading)
+                   (string= (cdr (assoc :tangle (nth 2 info))) "no")
+                   (and tangle-file (not (equal tangle-file src-tfile))))
           (unless (and language (not (string= language src-lang)))
-           (let* ((info (org-babel-get-src-block-info))
-                  (params (nth 2 info))
-                  (extra (nth 3 info))
-                  (cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
-                                     (match-string 1 extra))
-                                org-coderef-label-format))
-                  (link ((lambda (link)
-                           (and (string-match org-bracket-link-regexp link)
-                                (match-string 1 link)))
-                         (org-no-properties
-                          (org-store-link nil))))
-                  (source-name
-                   (intern (or (nth 4 info)
-                               (format "%s:%d"
-                                       current-heading block-counter))))
-                  (expand-cmd
-                   (intern (concat "org-babel-expand-body:" src-lang)))
-                  (assignments-cmd
-                   (intern (concat "org-babel-variable-assignments:" src-lang)))
-                  (body
-                   ((lambda (body) ;; run the tangle-body-hook
-                      (with-temp-buffer
-                        (insert body)
-                        (when (string-match "-r" extra)
-                          (goto-char (point-min))
-                          (while (re-search-forward
-                                  (replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
-                            (replace-match "")))
-                        (run-hooks 'org-babel-tangle-body-hook)
-                        (buffer-string)))
-                    ((lambda (body) ;; expand the body in language specific manner
-                       (if (assoc :no-expand params)
-                           body
-                         (if (fboundp expand-cmd)
-                             (funcall expand-cmd body params)
-                           (org-babel-expand-body:generic
-                            body params
-                            (and (fboundp assignments-cmd)
-                                 (funcall assignments-cmd params))))))
-                     (if (org-babel-noweb-p params :tangle)
-                         (org-babel-expand-noweb-references info)
-                       (nth 1 info)))))
-                  (comment
-                   (when (or (string= "both" (cdr (assoc :comments params)))
-                             (string= "org" (cdr (assoc :comments params))))
-                     ;; from the previous heading or code-block end
-                     (funcall
-                      org-babel-process-comment-text
-                      (buffer-substring
-                       (max (condition-case nil
-                                (save-excursion
-                                  (org-back-to-heading t)  ; sets match data
-                                  (match-end 0))
-                              (error (point-min)))
-                            (save-excursion
-                              (if (re-search-backward
-                                   org-babel-src-block-regexp nil t)
-                                  (match-end 0)
-                                (point-min))))
-                       (point)))))
-                  by-lang)
-             ;; add the spec for this block to blocks under it's language
-             (setq by-lang (cdr (assoc src-lang blocks)))
-             (setq blocks (delq (assoc src-lang blocks) blocks))
-             (setq blocks (cons
-                           (cons src-lang
-                                 (cons (list start-line file link
-                                             source-name params body comment)
-                                       by-lang)) blocks)))))))
-    ;; ensure blocks in the correct order
+           ;; Add the spec for this block to blocks under it's language
+           (setq by-lang (cdr (assoc src-lang blocks)))
+           (setq blocks (delq (assoc src-lang blocks) blocks))
+           (setq blocks (cons
+                         (cons src-lang
+                               (cons
+                                (org-babel-tangle-single-block
+                                 block-counter)
+                                by-lang)) blocks))))))
+    ;; Ensure blocks are in the correct order
     (setq blocks
           (mapcar
           (lambda (by-lang) (cons (car by-lang) (reverse (cdr by-lang))))
           blocks))
     blocks))
 
+(defun org-babel-tangle-single-block
+  (block-counter &optional only-this-block)
+  "Collect the tangled source for current block.
+Return the list of block attributes needed by
+`org-babel-tangle-collect-blocks'.
+When ONLY-THIS-BLOCK is non-nil, return the full association
+list to be used by `org-babel-tangle' directly."
+  (let* ((info (org-babel-get-src-block-info))
+        (start-line
+         (save-restriction (widen)
+                           (+ 1 (line-number-at-pos (point)))))
+        (file (buffer-file-name))
+        (src-lang (nth 0 info))
+        (params (nth 2 info))
+        (extra (nth 3 info))
+        (cref-fmt (or (and (string-match "-l \"\\(.+\\)\"" extra)
+                           (match-string 1 extra))
+                      org-coderef-label-format))
+        (link (let ((link (org-no-properties
+                            (org-store-link nil))))
+                 (and (string-match org-bracket-link-regexp link)
+                      (match-string 1 link))))
+        (source-name
+         (intern (or (nth 4 info)
+                     (format "%s:%d"
+                             (or (ignore-errors (nth 4 (org-heading-components)))
+                                 "No heading")
+                             block-counter))))
+        (expand-cmd
+         (intern (concat "org-babel-expand-body:" src-lang)))
+        (assignments-cmd
+         (intern (concat "org-babel-variable-assignments:" src-lang)))
+        (body
+         ;; Run the tangle-body-hook.
+          (let* ((body ;; Expand the body in language specific manner.
+                  (if (org-babel-noweb-p params :tangle)
+                      (org-babel-expand-noweb-references info)
+                    (nth 1 info)))
+                 (body
+                  (if (assoc :no-expand params)
+                      body
+                    (if (fboundp expand-cmd)
+                        (funcall expand-cmd body params)
+                      (org-babel-expand-body:generic
+                       body params
+                       (and (fboundp assignments-cmd)
+                            (funcall assignments-cmd params)))))))
+            (with-temp-buffer
+              (insert body)
+              (when (string-match "-r" extra)
+                (goto-char (point-min))
+                (while (re-search-forward
+                        (replace-regexp-in-string "%s" ".+" cref-fmt) nil t)
+                  (replace-match "")))
+              (run-hooks 'org-babel-tangle-body-hook)
+              (buffer-string))))
+        (comment
+         (when (or (string= "both" (cdr (assoc :comments params)))
+                   (string= "org" (cdr (assoc :comments params))))
+           ;; From the previous heading or code-block end
+           (funcall
+            org-babel-process-comment-text
+            (buffer-substring
+             (max (condition-case nil
+                      (save-excursion
+                        (org-back-to-heading t)  ; Sets match data
+                        (match-end 0))
+                    (error (point-min)))
+                  (save-excursion
+                    (if (re-search-backward
+                         org-babel-src-block-regexp nil t)
+                        (match-end 0)
+                      (point-min))))
+             (point)))))
+        (result
+         (list start-line file link source-name params body comment)))
+    (if only-this-block
+       (list (cons src-lang (list result)))
+      result)))
+
 (defun org-babel-tangle-comment-links ( &optional info)
   "Return a list of begin and end link comments for the code block at point."
   (let* ((start-line (org-babel-where-is-src-block-head))
@@ -455,9 +473,8 @@ code blocks by language."
         (source-name (nth 4 (or info (org-babel-get-src-block-info 'light))))
         (link-data (mapcar (lambda (el)
                              (cons (symbol-name el)
-                                   ((lambda (le)
-                                      (if (stringp le) le (format "%S" le)))
-                                    (eval el))))
+                                   (let ((le (eval el)))
+                                      (if (stringp le) le (format "%S" le)))))
                            '(start-line file link source-name))))
     (list (org-fill-template org-babel-tangle-comment-format-beg link-data)
          (org-fill-template org-babel-tangle-comment-format-end link-data))))
@@ -489,13 +506,15 @@ which enable the original code blocks to be found."
   "Jump from a tangled code file to the related Org-mode file."
   (interactive)
   (let ((mid (point))
-       start end done
+       start body-start end done
         target-buffer target-char link path block-name body)
     (save-window-excursion
       (save-excursion
        (while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
                    (not ; ever wider searches until matching block comments
                     (and (setq start (point-at-eol))
+                         (setq body-start (save-excursion
+                                            (forward-line 2) (point-at-bol)))
                          (setq link (match-string 0))
                          (setq path (match-string 3))
                          (setq block-name (match-string 5))
@@ -516,8 +535,19 @@ which enable the original code blocks to be found."
           (org-babel-next-src-block
            (string-to-number (match-string 1 block-name)))
         (org-babel-goto-named-src-block block-name))
+      ;; position at the beginning of the code block body
+      (goto-char (org-babel-where-is-src-block-head))
+      (forward-line 1)
+      ;; Use org-edit-special to isolate the code.
+      (org-edit-special)
+      ;; Then move forward the correct number of characters in the
+      ;; code buffer.
+      (forward-char (- mid body-start))
+      ;; And return to the Org-mode buffer with the point in the right
+      ;; place.
+      (org-edit-src-exit)
       (setq target-char (point)))
-    (pop-to-buffer target-buffer)
+    (org-src-switch-to-buffer target-buffer t)
     (prog1 body (goto-char target-char))))
 
 (provide 'ob-tangle)
index 724571481f72b2b7c136517e2d7ada08f13fdc88..827dd04a902af90cb54c91256e6de9ba023b2bdc 100644 (file)
@@ -3,7 +3,6 @@
 ;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
-;;     Dan Davison
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
 
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Code:
-(eval-when-compile
-  (require 'cl))
-(require 'ob-eval)
 (require 'org-macs)
 (require 'org-compat)
-
-(defconst org-babel-exeext
-  (if (memq system-type '(windows-nt cygwin))
-      ".exe"
-    nil))
-(defvar org-babel-call-process-region-original)
-(defvar org-src-lang-modes)
-(defvar org-babel-library-of-babel)
-(declare-function show-all "outline" ())
-(declare-function org-reduce "org" (CL-FUNC CL-SEQ &rest CL-KEYS))
-(declare-function org-mark-ring-push "org" (&optional pos buffer))
-(declare-function tramp-compat-make-temp-file "tramp-compat"
-                  (filename &optional dir-flag))
-(declare-function tramp-dissect-file-name "tramp" (name &optional nodefault))
-(declare-function tramp-file-name-user "tramp" (vec))
-(declare-function tramp-file-name-host "tramp" (vec))
-(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
-(declare-function org-icompleting-read "org" (&rest args))
-(declare-function org-edit-src-code "org-src"
-                  (&optional context code edit-buffer-name quietp))
-(declare-function org-edit-src-exit "org-src"  (&optional context))
-(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
-(declare-function org-save-outline-visibility "org-macs" (use-markers &rest body))
-(declare-function org-outline-overlay-data "org" (&optional use-markers))
-(declare-function org-set-outline-overlay-data "org" (data))
-(declare-function org-narrow-to-subtree "org" ())
-(declare-function org-entry-get "org"
-                 (pom property &optional inherit literal-nil))
-(declare-function org-make-options-regexp "org" (kwds &optional extra))
-(declare-function org-do-remove-indentation "org" (&optional n))
-(declare-function org-show-context "org" (&optional key))
-(declare-function org-at-table-p "org" (&optional table-type))
-(declare-function org-cycle "org" (&optional arg))
-(declare-function org-uniquify "org" (list))
-(declare-function org-current-level "org" ())
-(declare-function org-table-import "org-table" (file arg))
-(declare-function org-add-hook "org-compat"
-                 (hook function &optional append local))
-(declare-function org-table-align "org-table" ())
-(declare-function org-table-end "org-table" (&optional table-type))
-(declare-function orgtbl-to-generic "org-table" (table params))
-(declare-function orgtbl-to-orgtbl "org-table" (table params))
-(declare-function org-babel-tangle-comment-links "ob-tangle" (&optional info))
-(declare-function org-babel-lob-get-info "ob-lob" nil)
-(declare-function org-babel-ref-split-args "ob-ref" (arg-string))
-(declare-function org-babel-ref-parse "ob-ref" (assignment))
-(declare-function org-babel-ref-resolve "ob-ref" (ref))
-(declare-function org-babel-ref-goto-headline-id "ob-ref" (id))
-(declare-function org-babel-ref-headline-body "ob-ref" ())
-(declare-function org-babel-lob-execute-maybe "ob-lob" ())
-(declare-function org-number-sequence "org-compat" (from &optional to inc))
-(declare-function org-at-item-p "org-list" ())
-(declare-function org-list-parse-list "org-list" (&optional delete))
-(declare-function org-list-to-generic "org-list" (LIST PARAMS))
-(declare-function org-list-struct "org-list" ())
-(declare-function org-list-prevs-alist "org-list" (struct))
-(declare-function org-list-get-list-end "org-list" (item struct prevs))
-(declare-function org-remove-if "org" (predicate seq))
-(declare-function org-completing-read "org" (&rest args))
-(declare-function org-escape-code-in-region "org-src" (beg end))
-(declare-function org-unescape-code-in-string "org-src" (s))
-(declare-function org-table-to-lisp "org-table" (&optional txt))
-
-(defgroup org-babel nil
-  "Code block evaluation and management in `org-mode' documents."
-  :tag "Babel"
-  :group 'org)
-
-(defcustom org-confirm-babel-evaluate t
-  "Confirm before evaluation.
-Require confirmation before interactively evaluating code
-blocks in Org-mode buffers.  The default value of this variable
-is t, meaning confirmation is required for any code block
-evaluation.  This variable can be set to nil to inhibit any
-future confirmation requests.  This variable can also be set to a
-function which takes two arguments the language of the code block
-and the body of the code block.  Such a function should then
-return a non-nil value if the user should be prompted for
-execution or nil if no prompt is required.
-
-Warning: Disabling confirmation may result in accidental
-evaluation of potentially harmful code.  It may be advisable
-remove code block execution from C-c C-c as further protection
-against accidental code block evaluation.  The
-`org-babel-no-eval-on-ctrl-c-ctrl-c' variable can be used to
-remove code block execution from the C-c C-c keybinding."
-  :group 'org-babel
-  :version "24.1"
-  :type '(choice boolean function))
-;; don't allow this variable to be changed through file settings
-(put 'org-confirm-babel-evaluate 'safe-local-variable (lambda (x) (eq x t)))
-
-(defcustom org-babel-no-eval-on-ctrl-c-ctrl-c nil
-  "Remove code block evaluation from the C-c C-c key binding."
-  :group 'org-babel
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-babel-results-keyword "RESULTS"
-  "Keyword used to name results generated by code blocks.
-Should be either RESULTS or NAME however any capitalization may
-be used."
-  :group 'org-babel
-  :type 'string)
-
-(defcustom org-babel-noweb-wrap-start "<<"
-  "String used to begin a noweb reference in a code block.
-See also `org-babel-noweb-wrap-end'."
-  :group 'org-babel
-  :type 'string)
-
-(defcustom org-babel-noweb-wrap-end ">>"
-  "String used to end a noweb reference in a code block.
-See also `org-babel-noweb-wrap-start'."
-  :group 'org-babel
-  :type 'string)
-
-(defun org-babel-noweb-wrap (&optional regexp)
-  (concat org-babel-noweb-wrap-start
-         (or regexp "\\([^ \t\n].+?[^ \t]\\|[^ \t\n]\\)")
-         org-babel-noweb-wrap-end))
-
-(defvar org-babel-src-name-regexp
-  "^[ \t]*#\\+name:[ \t]*"
-  "Regular expression used to match a source name line.")
-
-(defvar org-babel-multi-line-header-regexp
-  "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
-  "Regular expression used to match multi-line header arguments.")
-
-(defvar org-babel-src-name-w-name-regexp
-  (concat org-babel-src-name-regexp
-         "\\("
-         org-babel-multi-line-header-regexp
-         "\\)*"
-         "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)")
-  "Regular expression matching source name lines with a name.")
-
-(defvar org-babel-src-block-regexp
-  (concat
-   ;; (1) indentation                 (2) lang
-   "^\\([ \t]*\\)#\\+begin_src[ \t]+\\([^ \f\t\n\r\v]+\\)[ \t]*"
-   ;; (3) switches
-   "\\([^\":\n]*\"[^\"\n*]*\"[^\":\n]*\\|[^\":\n]*\\)"
-   ;; (4) header arguments
-   "\\([^\n]*\\)\n"
-   ;; (5) body
-   "\\([^\000]*?\n\\)?[ \t]*#\\+end_src")
-  "Regexp used to identify code blocks.")
-
-(defvar org-babel-inline-src-block-regexp
-  (concat
-   ;; (1) replacement target (2) lang
-   "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)"
-   ;; (3,4) (unused, headers)
-   "\\(\\|\\[\\(.*?\\)\\]\\)"
-   ;; (5) body
-   "{\\([^\f\n\r\v]+?\\)}\\)")
-  "Regexp used to identify inline src-blocks.")
-
-(defun org-babel-get-header (params key &optional others)
-  "Select only header argument of type KEY from a list.
-Optional argument OTHERS indicates that only the header that do
-not match KEY should be returned."
-  (delq nil
-       (mapcar
-        (lambda (p) (when (funcall (if others #'not #'identity) (eq (car p) key)) p))
-        params)))
-
-(defun org-babel-get-inline-src-block-matches()
-  "Set match data if within body of an inline source block.
-Returns non-nil if match-data set"
-  (let ((src-at-0-p (save-excursion
-                     (beginning-of-line 1)
-                     (string= "src" (thing-at-point 'word))))
-       (first-line-p (= 1 (line-number-at-pos)))
-       (orig (point)))
-    (let ((search-for (cond ((and src-at-0-p first-line-p  "src_"))
-                           (first-line-p "[[:punct:] \t]src_")
-                           (t "[[:punct:] \f\t\n\r\v]src_")))
-         (lower-limit (if first-line-p
-                          nil
-                        (- (point-at-bol) 1))))
-      (save-excursion
-       (when (or (and src-at-0-p (bobp))
-                 (and (re-search-forward "}" (point-at-eol) t)
-                      (re-search-backward search-for lower-limit t)
-                      (> orig (point))))
-         (when (looking-at org-babel-inline-src-block-regexp)
-           t ))))))
-
-(defvar org-babel-inline-lob-one-liner-regexp)
-(defun org-babel-get-lob-one-liner-matches()
-  "Set match data if on line of an lob one liner.
-Returns non-nil if match-data set"
-  (save-excursion
-    (unless (= (point) (point-at-bol)) ;; move before inline block
-      (re-search-backward "[ \f\t\n\r\v]" nil t))
-    (if (looking-at org-babel-inline-lob-one-liner-regexp)
-       t
-      nil)))
-
-(defun org-babel-get-src-block-info (&optional light)
-  "Get information on the current source block.
-
-Optional argument LIGHT does not resolve remote variable
-references; a process which could likely result in the execution
-of other code blocks.
-
-Returns a list
- (language body header-arguments-alist switches name indent)."
-  (let ((case-fold-search t) head info name indent)
-    ;; full code block
-    (if (setq head (org-babel-where-is-src-block-head))
-       (save-excursion
-         (goto-char head)
-         (setq info (org-babel-parse-src-block-match))
-         (setq indent (car (last info)))
-         (setq info (butlast info))
-         (while (and (forward-line -1)
-                     (looking-at org-babel-multi-line-header-regexp))
-           (setf (nth 2 info)
-                 (org-babel-merge-params
-                  (nth 2 info)
-                  (org-babel-parse-header-arguments (match-string 1)))))
-         (when (looking-at org-babel-src-name-w-name-regexp)
-           (setq name (org-no-properties (match-string 3)))
-           (when (and (match-string 5) (> (length (match-string 5)) 0))
-             (setf (nth 2 info) ;; merge functional-syntax vars and header-args
-                   (org-babel-merge-params
-                    (mapcar
-                     (lambda (ref) (cons :var ref))
-                     (mapcar
-                      (lambda (var) ;; check that each variable is initialized
-                        (if (string-match ".+=.+" var)
-                            var
-                          (error
-                           "variable \"%s\"%s must be assigned a default value"
-                           var (if name (format " in block \"%s\"" name) ""))))
-                      (org-babel-ref-split-args (match-string 5))))
-                    (nth 2 info))))))
-      ;; inline source block
-      (when (org-babel-get-inline-src-block-matches)
-       (setq info (org-babel-parse-inline-src-block-match))))
-    ;; resolve variable references and add summary parameters
-    (when (and info (not light))
-      (setf (nth 2 info) (org-babel-process-params (nth 2 info))))
-    (when info (append info (list name indent)))))
-
-(defvar org-current-export-file) ; dynamically bound
-(defun org-babel-confirm-evaluate (info)
-  "Confirm evaluation of the code block INFO.
-This behavior can be suppressed by setting the value of
-`org-confirm-babel-evaluate' to nil, in which case all future
-interactive code block evaluations will proceed without any
-confirmation from the user.
-
-Note disabling confirmation may result in accidental evaluation
-of potentially harmful code."
-  (let* ((eval (or (cdr (assoc :eval (nth 2 info)))
-                  (when (assoc :noeval (nth 2 info)) "no")))
-         (query (cond ((equal eval "query") t)
-                     ((and (boundp 'org-current-export-file)
-                           org-current-export-file
-                           (equal eval "query-export")) t)
-                      ((functionp org-confirm-babel-evaluate)
-                       (funcall org-confirm-babel-evaluate
-                                (nth 0 info) (nth 1 info)))
-                      (t org-confirm-babel-evaluate))))
-    (if (or (equal eval "never") (equal eval "no")
-           (and (boundp 'org-current-export-file)
-                org-current-export-file
-                (or (equal eval "no-export")
-                    (equal eval "never-export")))
-           (and query
-                (not (yes-or-no-p
-                      (format "Evaluate this%scode block%son your system? "
-                              (if info (format " %s " (nth 0 info)) " ")
-                              (if (nth 4 info)
-                                  (format " (%s) " (nth 4 info)) " "))))))
-       (prog1 nil (message "Evaluation %s"
-                           (if (or (equal eval "never") (equal eval "no")
-                                   (equal eval "no-export")
-                                   (equal eval "never-export"))
-                               "Disabled" "Aborted")))
-      t)))
-
-;;;###autoload
-(defun org-babel-execute-safely-maybe ()
-  (unless org-babel-no-eval-on-ctrl-c-ctrl-c
-    (org-babel-execute-maybe)))
-
-(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-safely-maybe)
-
-;;;###autoload
-(defun org-babel-execute-maybe ()
-  (interactive)
-  (or (org-babel-execute-src-block-maybe)
-      (org-babel-lob-execute-maybe)))
-
-(defun org-babel-execute-src-block-maybe ()
-  "Conditionally execute a source block.
-Detect if this is context for a Babel src-block and if so
-then run `org-babel-execute-src-block'."
-  (interactive)
-  (let ((info (org-babel-get-src-block-info)))
-    (if info
-       (progn (org-babel-eval-wipe-error-buffer)
-              (org-babel-execute-src-block current-prefix-arg info) t) nil)))
-
-;;;###autoload
-(defun org-babel-view-src-block-info ()
-  "Display information on the current source block.
-This includes header arguments, language and name, and is largely
-a window into the `org-babel-get-src-block-info' function."
-  (interactive)
-  (let ((info (org-babel-get-src-block-info 'light))
-       (full (lambda (it) (> (length it) 0)))
-       (printf (lambda (fmt &rest args) (princ (apply #'format fmt args)))))
-    (when info
-      (with-help-window (help-buffer)
-       (let ((name        (nth 4 info))
-             (lang        (nth 0 info))
-             (switches    (nth 3 info))
-             (header-args (nth 2 info)))
-         (when name            (funcall printf "Name: %s\n"     name))
-         (when lang            (funcall printf "Lang: %s\n"     lang))
-         (when (funcall full switches) (funcall printf "Switches: %s\n" switches))
-         (funcall printf "Header Arguments:\n")
-         (dolist (pair (sort header-args
-                             (lambda (a b) (string< (symbol-name (car a))
-                                                    (symbol-name (car b))))))
-           (when (funcall full (cdr pair))
-             (funcall printf "\t%S%s\t%s\n"
-                      (car pair)
-                      (if (> (length (format "%S" (car pair))) 7) "" "\t")
-                      (cdr pair)))))))))
-
-;;;###autoload
-(defun org-babel-expand-src-block-maybe ()
-  "Conditionally expand a source block.
-Detect if this is context for a org-babel src-block and if so
-then run `org-babel-expand-src-block'."
-  (interactive)
-  (let ((info (org-babel-get-src-block-info)))
-    (if info
-       (progn (org-babel-expand-src-block current-prefix-arg info) t)
-      nil)))
-
-;;;###autoload
-(defun org-babel-load-in-session-maybe ()
-  "Conditionally load a source block in a session.
-Detect if this is context for a org-babel src-block and if so
-then run `org-babel-load-in-session'."
-  (interactive)
-  (let ((info (org-babel-get-src-block-info)))
-    (if info
-       (progn (org-babel-load-in-session current-prefix-arg info) t)
-      nil)))
-
-(add-hook 'org-metaup-hook 'org-babel-load-in-session-maybe)
-
-;;;###autoload
-(defun org-babel-pop-to-session-maybe ()
-  "Conditionally pop to a session.
-Detect if this is context for a org-babel src-block and if so
-then run `org-babel-pop-to-session'."
-  (interactive)
-  (let ((info (org-babel-get-src-block-info)))
-    (if info (progn (org-babel-pop-to-session current-prefix-arg info) t) nil)))
-
-(add-hook 'org-metadown-hook 'org-babel-pop-to-session-maybe)
-
-(defconst org-babel-common-header-args-w-values
-  '((cache     . ((no yes)))
-    (cmdline   . :any)
-    (colnames  . ((nil no yes)))
-    (comments  . ((no link yes org both noweb)))
-    (dir       . :any)
-    (eval      . ((never query)))
-    (exports   . ((code results both none)))
-    (file      . :any)
-    (file-desc  . :any)
-    (hlines    . ((no yes)))
-    (mkdirp    . ((yes no)))
-    (no-expand)
-    (noeval)
-    (noweb     . ((yes no tangle no-export strip-export)))
-    (noweb-ref . :any)
-    (noweb-sep  . :any)
-    (padline   . ((yes no)))
-    (results   . ((file list vector table scalar verbatim)
-                  (raw html latex org code pp drawer)
-                  (replace silent append prepend)
-                  (output value)))
-    (rownames  . ((no yes)))
-    (sep       . :any)
-    (session   . :any)
-    (shebang   . :any)
-    (tangle    . ((tangle yes no :any)))
-    (var       . :any)
-    (wrap       . :any)))
-
-(defconst org-babel-header-arg-names
-  (mapcar #'car org-babel-common-header-args-w-values)
-  "Common header arguments used by org-babel.
-Note that individual languages may define their own language
-specific header arguments as well.")
-
-(defvar org-babel-default-header-args
-  '((:session . "none") (:results . "replace") (:exports . "code")
-    (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no")
-    (:padnewline . "yes"))
-  "Default arguments to use when evaluating a source block.")
-
-(defvar org-babel-default-inline-header-args
-  '((:session . "none") (:results . "replace") (:exports . "results"))
-  "Default arguments to use when evaluating an inline source block.")
-
-(defvar org-babel-data-names '("tblname" "results" "name"))
-
-(defvar org-babel-result-regexp
-  (concat "^[ \t]*#\\+"
-         (regexp-opt org-babel-data-names t)
-         "\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*")
-  "Regular expression used to match result lines.
-If the results are associated with a hash key then the hash will
-be saved in the second match data.")
-
-(defvar org-babel-result-w-name-regexp
-  (concat org-babel-result-regexp
-         "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)"))
-
-(defvar org-babel-min-lines-for-block-output 10
-  "The minimum number of lines for block output.
-If number of lines of output is equal to or exceeds this
-value, the output is placed in a #+begin_example...#+end_example
-block.  Otherwise the output is marked as literal by inserting
-colons at the starts of the lines.  This variable only takes
-effect if the :results output option is in effect.")
-
-(defvar org-babel-noweb-error-langs nil
-  "Languages for which Babel will raise literate programming errors.
-List of languages for which errors should be raised when the
-source code block satisfying a noweb reference in this language
-can not be resolved.")
-
-(defvar org-babel-hash-show 4
-  "Number of initial characters to show of a hidden results hash.")
-
-(defvar org-babel-after-execute-hook nil
-  "Hook for functions to be called after `org-babel-execute-src-block'")
-
-(defun org-babel-named-src-block-regexp-for-name (name)
-  "This generates a regexp used to match a src block named NAME."
-  (concat org-babel-src-name-regexp (regexp-quote name)
-         "[ \t(]*[\r\n]\\(?:^#.*[\r\n]\\)*"
-         (substring org-babel-src-block-regexp 1)))
-
-(defun org-babel-named-data-regexp-for-name (name)
-  "This generates a regexp used to match data named NAME."
-  (concat org-babel-result-regexp (regexp-quote name) "\\([ \t]\\|$\\)"))
-
-;;; functions
-(defvar call-process-region)
-
-;;;###autoload
-(defun org-babel-execute-src-block (&optional arg info params)
-  "Execute the current source code block.
-Insert the results of execution into the buffer.  Source code
-execution and the collection and formatting of results can be
-controlled through a variety of header arguments.
-
-With prefix argument ARG, force re-execution even if an existing
-result cached in the buffer would otherwise have been returned.
-
-Optionally supply a value for INFO in the form returned by
-`org-babel-get-src-block-info'.
-
-Optionally supply a value for PARAMS which will be merged with
-the header arguments specified at the front of the source code
-block."
-  (interactive)
-  (let ((info (or info (org-babel-get-src-block-info))))
-    (when (org-babel-confirm-evaluate
-          (let ((i info))
-            (setf (nth 2 i) (org-babel-merge-params (nth 2 info) params))
-            i))
-      (let* ((lang (nth 0 info))
-            (params (if params
-                        (org-babel-process-params
-                         (org-babel-merge-params (nth 2 info) params))
-                      (nth 2 info)))
-            (cache? (and (not arg) (cdr (assoc :cache params))
-                         (string= "yes" (cdr (assoc :cache params)))))
-            (result-params (cdr (assoc :result-params params)))
-            (new-hash (when cache? (org-babel-sha1-hash info)))
-            (old-hash (when cache? (org-babel-current-result-hash)))
-            (body (setf (nth 1 info)
-                        (if (org-babel-noweb-p params :eval)
-                            (org-babel-expand-noweb-references info)
-                          (nth 1 info))))
-            (dir (cdr (assoc :dir params)))
-            (default-directory
-              (or (and dir (file-name-as-directory (expand-file-name dir)))
-                  default-directory))
-            (org-babel-call-process-region-original
-             (if (boundp 'org-babel-call-process-region-original)
-                 org-babel-call-process-region-original
-               (symbol-function 'call-process-region)))
-            (indent (car (last info)))
-            result cmd)
-       (unwind-protect
-           (let ((call-process-region
-                  (lambda (&rest args)
-                    (apply 'org-babel-tramp-handle-call-process-region args))))
-             (let ((lang-check (lambda (f)
-                                 (let ((f (intern (concat "org-babel-execute:" f))))
-                                   (when (fboundp f) f)))))
-               (setq cmd
-                     (or (funcall lang-check lang)
-                         (funcall lang-check (symbol-name
-                                              (cdr (assoc lang org-src-lang-modes))))
-                         (error "No org-babel-execute function for %s!" lang))))
-             (if (and (not arg) new-hash (equal new-hash old-hash))
-                 (save-excursion ;; return cached result
-                   (goto-char (org-babel-where-is-src-block-result nil info))
-                   (end-of-line 1) (forward-char 1)
-                   (setq result (org-babel-read-result))
-                   (message (replace-regexp-in-string
-                             "%" "%%" (format "%S" result))) result)
-               (message "executing %s code block%s..."
-                        (capitalize lang)
-                        (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
-               (setq result
-                     ((lambda (result)
-                        (if (and (eq (cdr (assoc :result-type params)) 'value)
-                                 (or (member "vector" result-params)
-                                     (member "table" result-params))
-                                 (not (listp result)))
-                            (list (list result)) result))
-                      (funcall cmd body params)))
-               ;; if non-empty result and :file then write to :file
-               (when (cdr (assoc :file params))
-                 (when result
-                   (with-temp-file (cdr (assoc :file params))
-                     (insert
-                      (org-babel-format-result
-                       result (cdr (assoc :sep (nth 2 info)))))))
-                 (setq result (cdr (assoc :file params))))
-               (org-babel-insert-result
-                result result-params info new-hash indent lang)
-               (run-hooks 'org-babel-after-execute-hook)
-               result))
-         (setq call-process-region 'org-babel-call-process-region-original))))))
-
-(defun org-babel-expand-body:generic (body params &optional var-lines)
-  "Expand BODY with PARAMS.
-Expand a block of code with org-babel according to its header
-arguments.  This generic implementation of body expansion is
-called for languages which have not defined their own specific
-org-babel-expand-body:lang function."
-  (mapconcat #'identity (append var-lines (list body)) "\n"))
-
-;;;###autoload
-(defun org-babel-expand-src-block (&optional arg info params)
-  "Expand the current source code block.
-Expand according to the source code block's header
-arguments and pop open the results in a preview buffer."
-  (interactive)
-  (let* ((info (or info (org-babel-get-src-block-info)))
-         (lang (nth 0 info))
-        (params (setf (nth 2 info)
-                       (sort (org-babel-merge-params (nth 2 info) params)
-                             (lambda (el1 el2) (string< (symbol-name (car el1))
-                                                       (symbol-name (car el2)))))))
-         (body (setf (nth 1 info)
-                    (if (org-babel-noweb-p params :eval)
-                        (org-babel-expand-noweb-references info) (nth 1 info))))
-         (expand-cmd (intern (concat "org-babel-expand-body:" lang)))
-        (assignments-cmd (intern (concat "org-babel-variable-assignments:"
-                                         lang)))
-         (expanded
-         (if (fboundp expand-cmd) (funcall expand-cmd body params)
-           (org-babel-expand-body:generic
-            body params (and (fboundp assignments-cmd)
-                             (funcall assignments-cmd params))))))
-    (org-edit-src-code
-     nil expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*"))))
-
-(defun org-babel-edit-distance (s1 s2)
-  "Return the edit (levenshtein) distance between strings S1 S2."
-  (let* ((l1 (length s1))
-        (l2 (length s2))
-        (dist (vconcat (mapcar (lambda (_) (make-vector (1+ l2) nil))
-                               (number-sequence 1 (1+ l1)))))
-        (in (lambda (i j) (aref (aref dist i) j)))
-        (mmin (lambda (&rest lst) (apply #'min (remove nil lst)))))
-    (setf (aref (aref dist 0) 0) 0)
-    (dolist (i (number-sequence 1 l1))
-      (dolist (j (number-sequence 1 l2))
-       (setf (aref (aref dist i) j)
-             (+ (if (equal (aref s1 (1- i)) (aref s2 (1- j))) 0 1)
-                (funcall mmin (funcall in (1- i) j)
-                         (funcall in i (1- j))
-                         (funcall in (1- i) (1- j)))))))
-    (funcall in l1 l2)))
-
-(defun org-babel-combine-header-arg-lists (original &rest others)
-  "Combine a number of lists of header argument names and arguments."
-  (let ((results (copy-sequence original)))
-    (dolist (new-list others)
-      (dolist (arg-pair new-list)
-       (let ((header (car arg-pair))
-             (args (cdr arg-pair)))
-         (setq results
-               (cons arg-pair (org-remove-if
-                               (lambda (pair) (equal header (car pair)))
-                               results))))))
-    results))
-
-;;;###autoload
-(defun org-babel-check-src-block ()
-  "Check for misspelled header arguments in the current code block."
-  (interactive)
-  ;; TODO: report malformed code block
-  ;; TODO: report incompatible combinations of header arguments
-  ;; TODO: report uninitialized variables
-  (let ((too-close 2) ;; <- control closeness to report potential match
-       (names (mapcar #'symbol-name org-babel-header-arg-names)))
-    (dolist (header (mapcar (lambda (arg) (substring (symbol-name (car arg)) 1))
-                           (and (org-babel-where-is-src-block-head)
-                                (org-babel-parse-header-arguments
-                                 (org-no-properties
-                                  (match-string 4))))))
-      (dolist (name names)
-       (when (and (not (string= header name))
-                  (<= (org-babel-edit-distance header name) too-close)
-                  (not (member header names)))
-         (error "Supplied header \"%S\" is suspiciously close to \"%S\""
-                header name))))
-    (message "No suspicious header arguments found.")))
-
-;;;###autoload
-(defun org-babel-insert-header-arg ()
-  "Insert a header argument selecting from lists of common args and values."
-  (interactive)
-  (let* ((lang (car (org-babel-get-src-block-info 'light)))
-        (lang-headers (intern (concat "org-babel-header-args:" lang)))
-        (headers (org-babel-combine-header-arg-lists
-                  org-babel-common-header-args-w-values
-                  (if (boundp lang-headers) (eval lang-headers) nil)))
-        (arg (org-icompleting-read
-              "Header Arg: "
-              (mapcar
-               (lambda (header-spec) (symbol-name (car header-spec)))
-               headers))))
-    (insert ":" arg)
-    (let ((vals (cdr (assoc (intern arg) headers))))
-      (when vals
-       (insert
-        " "
-        (cond
-         ((eq vals :any)
-          (read-from-minibuffer "value: "))
-         ((listp vals)
-          (mapconcat
-           (lambda (group)
-             (let ((arg (org-icompleting-read
-                         "value: "
-                         (cons "default" (mapcar #'symbol-name group)))))
-               (if (and arg (not (string= "default" arg)))
-                   (concat arg " ")
-                 "")))
-           vals ""))))))))
-
-;; Add support for completing-read insertion of header arguments after ":"
-(defun org-babel-header-arg-expand ()
-  "Call `org-babel-enter-header-arg-w-completion' in appropriate contexts."
-  (when (and (equal (char-before) ?\:) (org-babel-where-is-src-block-head))
-    (org-babel-enter-header-arg-w-completion (match-string 2))))
-
-(defun org-babel-enter-header-arg-w-completion (&optional lang)
-  "Insert header argument appropriate for LANG with completion."
-  (let* ((lang-headers-var (intern (concat "org-babel-header-args:" lang)))
-         (lang-headers (when (boundp lang-headers-var) (eval lang-headers-var)))
-        (headers-w-values (org-babel-combine-header-arg-lists
-                           org-babel-common-header-args-w-values lang-headers))
-         (headers (mapcar #'symbol-name (mapcar #'car headers-w-values)))
-         (header (org-completing-read "Header Arg: " headers))
-         (args (cdr (assoc (intern header) headers-w-values)))
-         (arg (when (and args (listp args))
-                (org-completing-read
-                 (format "%s: " header)
-                 (mapcar #'symbol-name (apply #'append args))))))
-    (insert (concat header " " (or arg "")))
-    (cons header arg)))
-
-(add-hook 'org-tab-first-hook 'org-babel-header-arg-expand)
-
-;;;###autoload
-(defun org-babel-load-in-session (&optional arg info)
-  "Load the body of the current source-code block.
-Evaluate the header arguments for the source block before
-entering the session.  After loading the body this pops open the
-session."
-  (interactive)
-  (let* ((info (or info (org-babel-get-src-block-info)))
-         (lang (nth 0 info))
-         (params (nth 2 info))
-         (body (setf (nth 1 info)
-                    (if (org-babel-noweb-p params :eval)
-                         (org-babel-expand-noweb-references info)
-                      (nth 1 info))))
-         (session (cdr (assoc :session params)))
-        (dir (cdr (assoc :dir params)))
-        (default-directory
-          (or (and dir (file-name-as-directory dir)) default-directory))
-        (cmd (intern (concat "org-babel-load-session:" lang))))
-    (unless (fboundp cmd)
-      (error "No org-babel-load-session function for %s!" lang))
-    (pop-to-buffer (funcall cmd session body params))
-    (end-of-line 1)))
-
-;;;###autoload
-(defun org-babel-initiate-session (&optional arg info)
-  "Initiate session for current code block.
-If called with a prefix argument then resolve any variable
-references in the header arguments and assign these variables in
-the session.  Copy the body of the code block to the kill ring."
-  (interactive "P")
-  (let* ((info (or info (org-babel-get-src-block-info (not arg))))
-         (lang (nth 0 info))
-         (body (nth 1 info))
-         (params (nth 2 info))
-         (session (cdr (assoc :session params)))
-        (dir (cdr (assoc :dir params)))
-        (default-directory
-          (or (and dir (file-name-as-directory dir)) default-directory))
-        (init-cmd (intern (format "org-babel-%s-initiate-session" lang)))
-        (prep-cmd (intern (concat "org-babel-prep-session:" lang))))
-    (if (and (stringp session) (string= session "none"))
-       (error "This block is not using a session!"))
-    (unless (fboundp init-cmd)
-      (error "No org-babel-initiate-session function for %s!" lang))
-    (with-temp-buffer (insert (org-babel-trim body))
-                      (copy-region-as-kill (point-min) (point-max)))
-    (when arg
-      (unless (fboundp prep-cmd)
-       (error "No org-babel-prep-session function for %s!" lang))
-      (funcall prep-cmd session params))
-    (funcall init-cmd session params)))
-
-;;;###autoload
-(defun org-babel-switch-to-session (&optional arg info)
-  "Switch to the session of the current code block.
-Uses `org-babel-initiate-session' to start the session.  If called
-with a prefix argument then this is passed on to
-`org-babel-initiate-session'."
-  (interactive "P")
-  (pop-to-buffer (org-babel-initiate-session arg info))
-  (end-of-line 1))
-
-(defalias 'org-babel-pop-to-session 'org-babel-switch-to-session)
-
-;;;###autoload
-(defun org-babel-switch-to-session-with-code (&optional arg info)
-  "Switch to code buffer and display session."
-  (interactive "P")
-  (let ((swap-windows
-        (lambda ()
-          (let ((other-window-buffer (window-buffer (next-window))))
-            (set-window-buffer (next-window) (current-buffer))
-            (set-window-buffer (selected-window) other-window-buffer))
-          (other-window 1)))
-       (info (org-babel-get-src-block-info))
-       (org-src-window-setup 'reorganize-frame))
-    (save-excursion
-      (org-babel-switch-to-session arg info))
-    (org-edit-src-code)
-    (funcall swap-windows)))
-
-(defmacro org-babel-do-in-edit-buffer (&rest body)
-  "Evaluate BODY in edit buffer if there is a code block at point.
-Return t if a code block was found at point, nil otherwise."
-  `(let ((org-src-window-setup 'switch-invisibly))
-     (when (and (org-babel-where-is-src-block-head)
-               (org-edit-src-code nil nil nil))
-       (unwind-protect (progn ,@body)
-        (if (org-bound-and-true-p org-edit-src-from-org-mode)
-            (org-edit-src-exit)))
-       t)))
-(def-edebug-spec org-babel-do-in-edit-buffer (body))
-
-(defun org-babel-do-key-sequence-in-edit-buffer (key)
-  "Read key sequence and execute the command in edit buffer.
-Enter a key sequence to be executed in the language major-mode
-edit buffer.  For example, TAB will alter the contents of the
-Org-mode code block according to the effect of TAB in the
-language major-mode buffer.  For languages that support
-interactive sessions, this can be used to send code from the Org
-buffer to the session for evaluation using the native major-mode
-evaluation mechanisms."
-  (interactive "kEnter key-sequence to execute in edit buffer: ")
-  (org-babel-do-in-edit-buffer
-   (call-interactively
-    (key-binding (or key (read-key-sequence nil))))))
-
-(defvar org-bracket-link-regexp)
-
-;;;###autoload
-(defun org-babel-open-src-block-result (&optional re-run)
-  "If `point' is on a src block then open the results of the
-source code block, otherwise return nil.  With optional prefix
-argument RE-RUN the source-code block is evaluated even if
-results already exist."
-  (interactive "P")
-  (let ((info (org-babel-get-src-block-info)))
-    (when info
-      (save-excursion
-       ;; go to the results, if there aren't any then run the block
-       (goto-char (or (and (not re-run) (org-babel-where-is-src-block-result))
-                      (progn (org-babel-execute-src-block)
-                             (org-babel-where-is-src-block-result))))
-       (end-of-line 1)
-       (while (looking-at "[\n\r\t\f ]") (forward-char 1))
-       ;; open the results
-       (if (looking-at org-bracket-link-regexp)
-           ;; file results
-           (org-open-at-point)
-         (let ((r (org-babel-format-result
-                   (org-babel-read-result) (cdr (assoc :sep (nth 2 info))))))
-           (pop-to-buffer (get-buffer-create "*Org-Babel Results*"))
-           (delete-region (point-min) (point-max))
-           (insert r)))
-       t))))
-
-;;;###autoload
-(defmacro org-babel-map-src-blocks (file &rest body)
-  "Evaluate BODY forms on each source-block in FILE.
-If FILE is nil evaluate BODY forms on source blocks in current
-buffer.  During evaluation of BODY the following local variables
-are set relative to the currently matched code block.
-
-full-block ------- string holding the entirety of the code block
-beg-block -------- point at the beginning of the code block
-end-block -------- point at the end of the matched code block
-lang ------------- string holding the language of the code block
-beg-lang --------- point at the beginning of the lang
-end-lang --------- point at the end of the lang
-switches --------- string holding the switches
-beg-switches ----- point at the beginning of the switches
-end-switches ----- point at the end of the switches
-header-args ------ string holding the header-args
-beg-header-args -- point at the beginning of the header-args
-end-header-args -- point at the end of the header-args
-body ------------- string holding the body of the code block
-beg-body --------- point at the beginning of the body
-end-body --------- point at the end of the body"
-  (declare (indent 1))
-  (let ((tempvar (make-symbol "file")))
-    `(let* ((,tempvar ,file)
-           (visited-p (or (null ,tempvar)
-                          (get-file-buffer (expand-file-name ,tempvar))))
-           (point (point)) to-be-removed)
-       (save-window-excursion
-        (when ,tempvar (find-file ,tempvar))
-        (setq to-be-removed (current-buffer))
-        (goto-char (point-min))
-        (while (re-search-forward org-babel-src-block-regexp nil t)
-          (goto-char (match-beginning 0))
-          (let ((full-block (match-string 0))
-                (beg-block (match-beginning 0))
-                (end-block (match-end 0))
-                (lang (match-string 2))
-                (beg-lang (match-beginning 2))
-                (end-lang (match-end 2))
-                (switches (match-string 3))
-                (beg-switches (match-beginning 3))
-                (end-switches (match-end 3))
-                (header-args (match-string 4))
-                (beg-header-args (match-beginning 4))
-                (end-header-args (match-end 4))
-                (body (match-string 5))
-                (beg-body (match-beginning 5))
-                (end-body (match-end 5)))
-            ,@body
-            (goto-char end-block))))
-       (unless visited-p (kill-buffer to-be-removed))
-       (goto-char point))))
-(def-edebug-spec org-babel-map-src-blocks (form body))
-
-;;;###autoload
-(defmacro org-babel-map-inline-src-blocks (file &rest body)
-  "Evaluate BODY forms on each inline source-block in FILE.
-If FILE is nil evaluate BODY forms on source blocks in current
-buffer."
-  (declare (indent 1))
-  (let ((tempvar (make-symbol "file")))
-    `(let* ((,tempvar ,file)
-           (visited-p (or (null ,tempvar)
-                          (get-file-buffer (expand-file-name ,tempvar))))
-           (point (point)) to-be-removed)
-       (save-window-excursion
-        (when ,tempvar (find-file ,tempvar))
-        (setq to-be-removed (current-buffer))
-        (goto-char (point-min))
-        (while (re-search-forward org-babel-inline-src-block-regexp nil t)
-          (goto-char (match-beginning 1))
-          (save-match-data ,@body)
-          (goto-char (match-end 0))))
-       (unless visited-p (kill-buffer to-be-removed))
-       (goto-char point))))
-(def-edebug-spec org-babel-map-inline-src-blocks (form body))
-
-(defvar org-babel-lob-one-liner-regexp)
-
-;;;###autoload
-(defmacro org-babel-map-call-lines (file &rest body)
-  "Evaluate BODY forms on each call line in FILE.
-If FILE is nil evaluate BODY forms on source blocks in current
-buffer."
-  (declare (indent 1))
-  (let ((tempvar (make-symbol "file")))
-    `(let* ((,tempvar ,file)
-           (visited-p (or (null ,tempvar)
-                          (get-file-buffer (expand-file-name ,tempvar))))
-           (point (point)) to-be-removed)
-       (save-window-excursion
-        (when ,tempvar (find-file ,tempvar))
-        (setq to-be-removed (current-buffer))
-        (goto-char (point-min))
-        (while (re-search-forward org-babel-lob-one-liner-regexp nil t)
-          (goto-char (match-beginning 1))
-          (save-match-data ,@body)
-          (goto-char (match-end 0))))
-       (unless visited-p (kill-buffer to-be-removed))
-       (goto-char point))))
-(def-edebug-spec org-babel-map-call-lines (form body))
-
-;;;###autoload
-(defmacro org-babel-map-executables (file &rest body)
-  (declare (indent 1))
-  (let ((tempvar (make-symbol "file"))
-       (rx (make-symbol "rx")))
-    `(let* ((,tempvar ,file)
-           (,rx (concat "\\(" org-babel-src-block-regexp
-                        "\\|" org-babel-inline-src-block-regexp
-                        "\\|" org-babel-lob-one-liner-regexp "\\)"))
-           (visited-p (or (null ,tempvar)
-                          (get-file-buffer (expand-file-name ,tempvar))))
-           (point (point)) to-be-removed)
-       (save-window-excursion
-        (when ,tempvar (find-file ,tempvar))
-        (setq to-be-removed (current-buffer))
-        (goto-char (point-min))
-        (while (re-search-forward ,rx nil t)
-          (goto-char (match-beginning 1))
-          (when (looking-at org-babel-inline-src-block-regexp)(forward-char 1))
-          (save-match-data ,@body)
-          (goto-char (match-end 0))))
-       (unless visited-p (kill-buffer to-be-removed))
-       (goto-char point))))
-(def-edebug-spec org-babel-map-executables (form body))
-
-;;;###autoload
-(defun org-babel-execute-buffer (&optional arg)
-  "Execute source code blocks in a buffer.
-Call `org-babel-execute-src-block' on every source block in
-the current buffer."
-  (interactive "P")
-  (org-babel-eval-wipe-error-buffer)
-  (org-save-outline-visibility t
-    (org-babel-map-executables nil
-      (if (looking-at org-babel-lob-one-liner-regexp)
-          (org-babel-lob-execute-maybe)
-        (org-babel-execute-src-block arg)))))
-
-;;;###autoload
-(defun org-babel-execute-subtree (&optional arg)
-  "Execute source code blocks in a subtree.
-Call `org-babel-execute-src-block' on every source block in
-the current subtree."
-  (interactive "P")
-  (save-restriction
-    (save-excursion
-      (org-narrow-to-subtree)
-      (org-babel-execute-buffer arg)
-      (widen))))
-
-;;;###autoload
-(defun org-babel-sha1-hash (&optional info)
-  "Generate an sha1 hash based on the value of info."
-  (interactive)
-  (let ((print-level nil)
-       (info (or info (org-babel-get-src-block-info))))
-    (setf (nth 2 info)
-         (sort (copy-sequence (nth 2 info))
-               (lambda (a b) (string< (car a) (car b)))))
-    (let* ((rm (lambda (lst)
-                (dolist (p '("replace" "silent" "append" "prepend"))
-                  (setq lst (remove p lst)))
-                lst))
-          (norm (lambda (arg)
-                  (let ((v (if (and (listp (cdr arg)) (null (cddr arg)))
-                               (copy-sequence (cdr arg))
-                             (cdr arg))))
-                    (when (and v (not (and (sequencep v)
-                                           (not (consp v))
-                                           (= (length v) 0))))
-                      (cond
-                       ((and (listp v) ; lists are sorted
-                             (member (car arg) '(:result-params)))
-                        (sort (funcall rm v) #'string<))
-                       ((and (stringp v) ; strings are sorted
-                             (member (car arg) '(:results :exports)))
-                        (mapconcat #'identity (sort (funcall rm (split-string v))
-                                                    #'string<) " "))
-                       (t v)))))))
-      ((lambda (hash)
-        (when (org-called-interactively-p 'interactive) (message hash)) hash)
-       (let ((it (format "%s-%s"
-                        (mapconcat
-                         #'identity
-                         (delq nil (mapcar (lambda (arg)
-                                             (let ((normalized (funcall norm arg)))
-                                               (when normalized
-                                                 (format "%S" normalized))))
-                                           (nth 2 info))) ":")
-                        (nth 1 info))))
-        (sha1 it))))))
-
-(defun org-babel-current-result-hash ()
-  "Return the current in-buffer hash."
-  (org-babel-where-is-src-block-result)
-  (org-no-properties (match-string 3)))
-
-(defun org-babel-set-current-result-hash (hash)
-  "Set the current in-buffer hash to HASH."
-  (org-babel-where-is-src-block-result)
-  (save-excursion (goto-char (match-beginning 3))
-                 ;; (mapc #'delete-overlay (overlays-at (point)))
-                 (replace-match hash nil nil nil 3)
-                 (org-babel-hide-hash)))
-
-(defun org-babel-hide-hash ()
-  "Hide the hash in the current results line.
-Only the initial `org-babel-hash-show' characters of the hash
-will remain visible."
-  (add-to-invisibility-spec '(org-babel-hide-hash . t))
-  (save-excursion
-    (when (and (re-search-forward org-babel-result-regexp nil t)
-               (match-string 3))
-      (let* ((start (match-beginning 3))
-             (hide-start (+ org-babel-hash-show start))
-             (end (match-end 3))
-             (hash (match-string 3))
-             ov1 ov2)
-        (setq ov1 (make-overlay start hide-start))
-        (setq ov2 (make-overlay hide-start end))
-        (overlay-put ov2 'invisible 'org-babel-hide-hash)
-        (overlay-put ov1 'babel-hash hash)))))
-
-(defun org-babel-hide-all-hashes ()
-  "Hide the hash in the current buffer.
-Only the initial `org-babel-hash-show' characters of each hash
-will remain visible.  This function should be called as part of
-the `org-mode-hook'."
-  (save-excursion
-    (while (re-search-forward org-babel-result-regexp nil t)
-      (goto-char (match-beginning 0))
-      (org-babel-hide-hash)
-      (goto-char (match-end 0)))))
-(add-hook 'org-mode-hook 'org-babel-hide-all-hashes)
-
-(defun org-babel-hash-at-point (&optional point)
-  "Return the value of the hash at POINT.
-The hash is also added as the last element of the kill ring.
-This can be called with C-c C-c."
-  (interactive)
-  (let ((hash (car (delq nil (mapcar
-                             (lambda (ol) (overlay-get ol 'babel-hash))
-                              (overlays-at (or point (point))))))))
-    (when hash (kill-new hash) (message hash))))
-(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-hash-at-point)
-
-(defun org-babel-result-hide-spec ()
-  "Hide portions of results lines.
-Add `org-babel-hide-result' as an invisibility spec for hiding
-portions of results lines."
-  (add-to-invisibility-spec '(org-babel-hide-result . t)))
-(add-hook 'org-mode-hook 'org-babel-result-hide-spec)
-
-(defvar org-babel-hide-result-overlays nil
-  "Overlays hiding results.")
-
-(defun org-babel-result-hide-all ()
-  "Fold all results in the current buffer."
-  (interactive)
-  (org-babel-show-result-all)
-  (save-excursion
-    (while (re-search-forward org-babel-result-regexp nil t)
-      (save-excursion (goto-char (match-beginning 0))
-                      (org-babel-hide-result-toggle-maybe)))))
-
-(defun org-babel-show-result-all ()
-  "Unfold all results in the current buffer."
-  (mapc 'delete-overlay org-babel-hide-result-overlays)
-  (setq org-babel-hide-result-overlays nil))
-
-;;;###autoload
-(defun org-babel-hide-result-toggle-maybe ()
-  "Toggle visibility of result at point."
-  (interactive)
-  (let ((case-fold-search t))
-    (if (save-excursion
-          (beginning-of-line 1)
-          (looking-at org-babel-result-regexp))
-        (progn (org-babel-hide-result-toggle)
-               t) ;; to signal that we took action
-      nil))) ;; to signal that we did not
-
-(defun org-babel-hide-result-toggle (&optional force)
-  "Toggle the visibility of the current result."
-  (interactive)
-  (save-excursion
-    (beginning-of-line)
-    (if (re-search-forward org-babel-result-regexp nil t)
-        (let ((start (progn (beginning-of-line 2) (- (point) 1)))
-             (end (progn
-                    (while (looking-at org-babel-multi-line-header-regexp)
-                      (forward-line 1))
-                    (goto-char (- (org-babel-result-end) 1)) (point)))
-             ov)
-          (if (memq t (mapcar (lambda (overlay)
-                                (eq (overlay-get overlay 'invisible)
-                                   'org-babel-hide-result))
-                              (overlays-at start)))
-              (if (or (not force) (eq force 'off))
-                  (mapc (lambda (ov)
-                          (when (member ov org-babel-hide-result-overlays)
-                            (setq org-babel-hide-result-overlays
-                                  (delq ov org-babel-hide-result-overlays)))
-                          (when (eq (overlay-get ov 'invisible)
-                                    'org-babel-hide-result)
-                            (delete-overlay ov)))
-                        (overlays-at start)))
-            (setq ov (make-overlay start end))
-            (overlay-put ov 'invisible 'org-babel-hide-result)
-            ;; make the block accessible to isearch
-            (overlay-put
-             ov 'isearch-open-invisible
-             (lambda (ov)
-               (when (member ov org-babel-hide-result-overlays)
-                 (setq org-babel-hide-result-overlays
-                       (delq ov org-babel-hide-result-overlays)))
-               (when (eq (overlay-get ov 'invisible)
-                         'org-babel-hide-result)
-                 (delete-overlay ov))))
-            (push ov org-babel-hide-result-overlays)))
-      (error "Not looking at a result line"))))
-
-;; org-tab-after-check-for-cycling-hook
-(add-hook 'org-tab-first-hook 'org-babel-hide-result-toggle-maybe)
-;; Remove overlays when changing major mode
-(add-hook 'org-mode-hook
-         (lambda () (org-add-hook 'change-major-mode-hook
-                                  'org-babel-show-result-all 'append 'local)))
-
-(defvar org-file-properties)
-(defun org-babel-params-from-properties (&optional lang)
-  "Retrieve parameters specified as properties.
-Return an association list of any source block params which
-may be specified in the properties of the current outline entry."
-  (save-match-data
-    (let (val sym)
-      (org-babel-parse-multiple-vars
-       (delq nil
-            (mapcar
-             (lambda (header-arg)
-               (and (setq val (org-entry-get (point) header-arg t))
-                    (cons (intern (concat ":" header-arg))
-                          (org-babel-read val))))
-             (mapcar
-              #'symbol-name
-              (mapcar
-               #'car
-               (org-babel-combine-header-arg-lists
-                org-babel-common-header-args-w-values
-                (progn
-                  (setq sym (intern (concat "org-babel-header-args:" lang)))
-                  (and (boundp sym) (eval sym))))))))))))
-
-(defvar org-src-preserve-indentation)
-(defun org-babel-parse-src-block-match ()
-  "Parse the results from a match of the `org-babel-src-block-regexp'."
-  (let* ((block-indentation (length (match-string 1)))
-        (lang (org-no-properties (match-string 2)))
-         (lang-headers (intern (concat "org-babel-default-header-args:" lang)))
-        (switches (match-string 3))
-         (body (org-no-properties
-               (let* ((body (match-string 5))
-                      (sub-length (- (length body) 1)))
-                 (if (and (> sub-length 0)
-                          (string= "\n" (substring body sub-length)))
-                     (substring body 0 sub-length)
-                   (or body "")))))
-        (preserve-indentation (or org-src-preserve-indentation
-                                  (save-match-data
-                                    (string-match "-i\\>" switches)))))
-    (list lang
-          ;; get block body less properties, protective commas, and indentation
-          (with-temp-buffer
-            (save-match-data
-              (insert (org-unescape-code-in-string body))
-             (unless preserve-indentation (org-do-remove-indentation))
-              (buffer-string)))
-         (org-babel-merge-params
-          org-babel-default-header-args
-           (org-babel-params-from-properties lang)
-          (if (boundp lang-headers) (eval lang-headers) nil)
-          (org-babel-parse-header-arguments
-            (org-no-properties (or (match-string 4) ""))))
-         switches
-         block-indentation)))
-
-(defun org-babel-parse-inline-src-block-match ()
-  "Parse the results from a match of the `org-babel-inline-src-block-regexp'."
-  (let* ((lang (org-no-properties (match-string 2)))
-         (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
-    (list lang
-          (org-unescape-code-in-string (org-no-properties (match-string 5)))
-          (org-babel-merge-params
-           org-babel-default-inline-header-args
-           (org-babel-params-from-properties lang)
-           (if (boundp lang-headers) (eval lang-headers) nil)
-           (org-babel-parse-header-arguments
-            (org-no-properties (or (match-string 4) "")))))))
-
-(defun org-babel-balanced-split (string alts)
-  "Split STRING on instances of ALTS.
-ALTS is a cons of two character options where each option may be
-either the numeric code of a single character or a list of
-character alternatives.  For example to split on balanced
-instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
-  (let* ((matches (lambda (ch spec) (if (listp spec) (member ch spec) (equal spec ch))))
-        (matched (lambda (ch last)
-                   (if (consp alts)
-                       (and (funcall matches ch (cdr alts))
-                            (funcall matches last (car alts)))
-                     (funcall matches ch alts))))
-        (balance 0) (last 0)
-        quote partial lst)
-    (mapc (lambda (ch)  ; split on [], (), "" balanced instances of [ \t]:
-           (setq balance (+ balance
-                            (cond ((or (equal 91 ch) (equal 40 ch)) 1)
-                                  ((or (equal 93 ch) (equal 41 ch)) -1)
-                                  (t 0))))
-           (when (and (equal 34 ch) (not (equal 92 last)))
-             (setq quote (not quote)))
-           (setq partial (cons ch partial))
-           (when (and (= balance 0) (not quote) (funcall matched ch last))
-             (setq lst (cons (apply #'string (nreverse
-                                              (if (consp alts)
-                                                  (cddr partial)
-                                                (cdr partial))))
-                             lst))
-             (setq partial nil))
-           (setq last ch))
-         (string-to-list string))
-    (nreverse (cons (apply #'string (nreverse partial)) lst))))
-
-(defun org-babel-join-splits-near-ch (ch list)
-  "Join splits where \"=\" is on either end of the split."
-  (let ((last= (lambda (str) (= ch (aref str (1- (length str))))))
-       (first= (lambda (str) (= ch (aref str 0)))))
-    (reverse
-     (org-reduce (lambda (acc el)
-                  (let ((head (car acc)))
-                    (if (and head (or (funcall last= head) (funcall first= el)))
-                        (cons (concat head el) (cdr acc))
-                      (cons el acc))))
-                list :initial-value nil))))
-
-(defun org-babel-parse-header-arguments (arg-string)
-  "Parse a string of header arguments returning an alist."
-  (when (> (length arg-string) 0)
-    (org-babel-parse-multiple-vars
-     (delq nil
-          (mapcar
-           (lambda (arg)
-             (if (string-match
-                  "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)"
-                  arg)
-                 (cons (intern (match-string 1 arg))
-                       (org-babel-read (org-babel-chomp (match-string 2 arg))))
-               (cons (intern (org-babel-chomp arg)) nil)))
-           ((lambda (raw)
-              (cons (car raw) (mapcar (lambda (r) (concat ":" r)) (cdr raw))))
-            (org-babel-balanced-split arg-string '((32 9) . 58))))))))
-
-(defun org-babel-parse-multiple-vars (header-arguments)
-  "Expand multiple variable assignments behind a single :var keyword.
-
-This allows expression of multiple variables with one :var as
-shown below.
-
-#+PROPERTY: var foo=1, bar=2"
-  (let (results)
-    (mapc (lambda (pair)
-           (if (eq (car pair) :var)
-               (mapcar (lambda (v) (push (cons :var (org-babel-trim v)) results))
-                       (org-babel-join-splits-near-ch
-                        61 (org-babel-balanced-split (cdr pair) 32)))
-             (push pair results)))
-         header-arguments)
-    (nreverse results)))
-
-(defun org-babel-process-params (params)
-  "Expand variables in PARAMS and add summary parameters."
-  (let* ((processed-vars (mapcar (lambda (el)
-                                  (if (consp (cdr el))
-                                      (cdr el)
-                                    (org-babel-ref-parse (cdr el))))
-                                (org-babel-get-header params :var)))
-        (vars-and-names (if (and (assoc :colname-names params)
-                                 (assoc :rowname-names params))
-                            (list processed-vars)
-                          (org-babel-disassemble-tables
-                           processed-vars
-                           (cdr (assoc :hlines params))
-                           (cdr (assoc :colnames params))
-                           (cdr (assoc :rownames params)))))
-        (raw-result (or (cdr (assoc :results params)) ""))
-        (result-params (append
-                        (split-string (if (stringp raw-result)
-                                          raw-result
-                                        (eval raw-result)))
-                        (cdr (assoc :result-params params)))))
-    (append
-     (mapcar (lambda (var) (cons :var var)) (car vars-and-names))
-     (list
-      (cons :colname-names (or (cdr (assoc :colname-names params))
-                              (cadr  vars-and-names)))
-      (cons :rowname-names (or (cdr (assoc :rowname-names params))
-                              (caddr vars-and-names)))
-      (cons :result-params result-params)
-      (cons :result-type  (cond ((member "output" result-params) 'output)
-                               ((member "value" result-params) 'value)
-                               (t 'value))))
-     (org-babel-get-header params :var 'other))))
-
-;; row and column names
-(defun org-babel-del-hlines (table)
-  "Remove all 'hlines from TABLE."
-  (remove 'hline table))
-
-(defun org-babel-get-colnames (table)
-  "Return the column names of TABLE.
-Return a cons cell, the `car' of which contains the TABLE less
-colnames, and the `cdr' of which contains a list of the column
-names."
-  (if (equal 'hline (nth 1 table))
-      (cons (cddr table) (car table))
-    (cons (cdr table) (car table))))
-
-(defun org-babel-get-rownames (table)
-  "Return the row names of TABLE.
-Return a cons cell, the `car' of which contains the TABLE less
-colnames, and the `cdr' of which contains a list of the column
-names.  Note: this function removes any hlines in TABLE."
-  (let* ((trans (lambda (table) (apply #'mapcar* #'list table)))
-        (width (apply 'max
-                      (mapcar (lambda (el) (if (listp el) (length el) 0)) table)))
-        (table (funcall trans (mapcar (lambda (row)
-                                        (if (not (equal row 'hline))
-                                            row
-                                          (setq row '())
-                                          (dotimes (n width)
-                                            (setq row (cons 'hline row)))
-                                          row))
-                                      table))))
-    (cons (mapcar (lambda (row) (if (equal (car row) 'hline) 'hline row))
-                 (funcall trans (cdr table)))
-         (remove 'hline (car table)))))
-
-(defun org-babel-put-colnames (table colnames)
-  "Add COLNAMES to TABLE if they exist."
-  (if colnames (apply 'list colnames 'hline table) table))
-
-(defun org-babel-put-rownames (table rownames)
-  "Add ROWNAMES to TABLE if they exist."
-  (if rownames
-      (mapcar (lambda (row)
-                (if (listp row)
-                    (cons (or (pop rownames) "") row)
-                  row)) table)
-    table))
-
-(defun org-babel-pick-name (names selector)
-  "Select one out of an alist of row or column names.
-SELECTOR can be either a list of names in which case those names
-will be returned directly, or an index into the list NAMES in
-which case the indexed names will be return."
-  (if (listp selector)
-      selector
-    (when names
-      (if (and selector (symbolp selector) (not (equal t selector)))
-         (cdr (assoc selector names))
-       (if (integerp selector)
-           (nth (- selector 1) names)
-         (cdr (car (last names))))))))
-
-(defun org-babel-disassemble-tables (vars hlines colnames rownames)
-  "Parse tables for further processing.
-Process the variables in VARS according to the HLINES,
-ROWNAMES and COLNAMES header arguments.  Return a list consisting
-of the vars, cnames and rnames."
-  (let (cnames rnames)
-    (list
-     (mapcar
-      (lambda (var)
-        (when (listp (cdr var))
-          (when (and (not (equal colnames "no"))
-                     (or colnames (and (equal (nth 1 (cdr var)) 'hline)
-                                       (not (member 'hline (cddr (cdr var)))))))
-            (let ((both (org-babel-get-colnames (cdr var))))
-              (setq cnames (cons (cons (car var) (cdr both))
-                                 cnames))
-              (setq var (cons (car var) (car both)))))
-          (when (and rownames (not (equal rownames "no")))
-            (let ((both (org-babel-get-rownames (cdr var))))
-              (setq rnames (cons (cons (car var) (cdr both))
-                                 rnames))
-              (setq var (cons (car var) (car both)))))
-          (when (and hlines (not (equal hlines "yes")))
-            (setq var (cons (car var) (org-babel-del-hlines (cdr var))))))
-        var)
-      vars)
-     (reverse cnames) (reverse rnames))))
-
-(defun org-babel-reassemble-table (table colnames rownames)
-  "Add column and row names to a table.
-Given a TABLE and set of COLNAMES and ROWNAMES add the names
-to the table for reinsertion to org-mode."
-  (if (listp table)
-      ((lambda (table)
-         (if (and colnames (listp (car table)) (= (length (car table))
-                                                  (length colnames)))
-             (org-babel-put-colnames table colnames) table))
-       (if (and rownames (= (length table) (length rownames)))
-           (org-babel-put-rownames table rownames) table))
-    table))
-
-(defun org-babel-where-is-src-block-head ()
-  "Find where the current source block begins.
-Return the point at the beginning of the current source
-block.  Specifically at the beginning of the #+BEGIN_SRC line.
-If the point is not on a source block then return nil."
-  (let ((initial (point)) (case-fold-search t) top bottom)
-    (or
-     (save-excursion ;; on a source name line or a #+header line
-       (beginning-of-line 1)
-       (and (or (looking-at org-babel-src-name-regexp)
-               (looking-at org-babel-multi-line-header-regexp))
-           (progn
-             (while (and (forward-line 1)
-                         (or (looking-at org-babel-src-name-regexp)
-                             (looking-at org-babel-multi-line-header-regexp))))
-             (looking-at org-babel-src-block-regexp))
-            (point)))
-     (save-excursion ;; on a #+begin_src line
-       (beginning-of-line 1)
-       (and (looking-at org-babel-src-block-regexp)
-            (point)))
-     (save-excursion ;; inside a src block
-       (and
-        (re-search-backward "^[ \t]*#\\+begin_src" nil t) (setq top (point))
-        (re-search-forward "^[ \t]*#\\+end_src" nil t) (setq bottom (point))
-        (< top initial) (< initial bottom)
-        (progn (goto-char top) (beginning-of-line 1)
-              (looking-at org-babel-src-block-regexp))
-        (point))))))
-
-;;;###autoload
-(defun org-babel-goto-src-block-head ()
-  "Go to the beginning of the current code block."
-  (interactive)
-  ((lambda (head)
-     (if head (goto-char head) (error "Not currently in a code block")))
-   (org-babel-where-is-src-block-head)))
-
-;;;###autoload
-(defun org-babel-goto-named-src-block (name)
-  "Go to a named source-code block."
-  (interactive
-   (let ((completion-ignore-case t)
-        (case-fold-search t)
-        (under-point (thing-at-point 'line)))
-     (list (org-icompleting-read
-           "source-block name: " (org-babel-src-block-names) nil t
-           (cond
-            ;; noweb
-            ((string-match (org-babel-noweb-wrap) under-point)
-             (let ((block-name (match-string 1 under-point)))
-               (string-match "[^(]*" block-name)
-               (match-string 0 block-name)))
-            ;; #+call:
-            ((string-match org-babel-lob-one-liner-regexp under-point)
-             (let ((source-info (car (org-babel-lob-get-info))))
-               (if (string-match "^\\([^\\[]+?\\)\\(\\[.*\\]\\)?(" source-info)
-                   (let ((source-name (match-string 1 source-info)))
-                     source-name))))
-            ;; #+results:
-            ((string-match (concat "#\\+" org-babel-results-keyword
-                                   "\\:\s+\\([^\\(]*\\)") under-point)
-             (match-string 1 under-point))
-            ;; symbol-at-point
-            ((and (thing-at-point 'symbol))
-             (org-babel-find-named-block (thing-at-point 'symbol))
-             (thing-at-point 'symbol))
-            (""))))))
-  (let ((point (org-babel-find-named-block name)))
-    (if point
-        ;; taken from `org-open-at-point'
-        (progn (org-mark-ring-push) (goto-char point) (org-show-context))
-      (message "source-code block '%s' not found in this buffer" name))))
-
-(defun org-babel-find-named-block (name)
-  "Find a named source-code block.
-Return the location of the source block identified by source
-NAME, or nil if no such block exists.  Set match data according to
-org-babel-named-src-block-regexp."
-  (save-excursion
-    (let ((case-fold-search t)
-         (regexp (org-babel-named-src-block-regexp-for-name name)) msg)
-      (goto-char (point-min))
-      (when (or (re-search-forward regexp nil t)
-               (re-search-backward regexp nil t))
-        (match-beginning 0)))))
-
-(defun org-babel-src-block-names (&optional file)
-  "Returns the names of source blocks in FILE or the current buffer."
-  (save-excursion
-    (when file (find-file file)) (goto-char (point-min))
-    (let ((case-fold-search t) names)
-      (while (re-search-forward org-babel-src-name-w-name-regexp nil t)
-       (setq names (cons (match-string 3) names)))
-      names)))
-
-;;;###autoload
-(defun org-babel-goto-named-result (name)
-  "Go to a named result."
-  (interactive
-   (let ((completion-ignore-case t))
-     (list (org-icompleting-read "source-block name: "
-                                (org-babel-result-names) nil t))))
-  (let ((point (org-babel-find-named-result name)))
-    (if point
-        ;; taken from `org-open-at-point'
-        (progn (goto-char point) (org-show-context))
-      (message "result '%s' not found in this buffer" name))))
-
-(defun org-babel-find-named-result (name &optional point)
-  "Find a named result.
-Return the location of the result named NAME in the current
-buffer or nil if no such result exists."
-  (save-excursion
-    (let ((case-fold-search t))
-      (goto-char (or point (point-min)))
-      (catch 'is-a-code-block
-       (when (re-search-forward
-              (concat org-babel-result-regexp
-                      "[ \t]" (regexp-quote name) "[ \t]*[\n\f\v\r]") nil t)
-         (when (and (string= "name" (downcase (match-string 1)))
-                    (or (beginning-of-line 1)
-                        (looking-at org-babel-src-block-regexp)
-                        (looking-at org-babel-multi-line-header-regexp)))
-           (throw 'is-a-code-block (org-babel-find-named-result name (point))))
-         (beginning-of-line 0) (point))))))
-
-(defun org-babel-result-names (&optional file)
-  "Returns the names of results in FILE or the current buffer."
-  (save-excursion
-    (when file (find-file file)) (goto-char (point-min))
-    (let ((case-fold-search t) names)
-      (while (re-search-forward org-babel-result-w-name-regexp nil t)
-       (setq names (cons (match-string 4) names)))
-      names)))
-
-;;;###autoload
-(defun org-babel-next-src-block (&optional arg)
-  "Jump to the next source block.
-With optional prefix argument ARG, jump forward ARG many source blocks."
-  (interactive "P")
-  (when (looking-at org-babel-src-block-regexp) (forward-char 1))
-  (condition-case nil
-      (re-search-forward org-babel-src-block-regexp nil nil (or arg 1))
-    (error (error "No further code blocks")))
-  (goto-char (match-beginning 0)) (org-show-context))
-
-;;;###autoload
-(defun org-babel-previous-src-block (&optional arg)
-  "Jump to the previous source block.
-With optional prefix argument ARG, jump backward ARG many source blocks."
-  (interactive "P")
-  (condition-case nil
-      (re-search-backward org-babel-src-block-regexp nil nil (or arg 1))
-    (error (error "No previous code blocks")))
-  (goto-char (match-beginning 0)) (org-show-context))
-
-(defvar org-babel-load-languages)
-
-;;;###autoload
-(defun org-babel-mark-block ()
-  "Mark current src block."
-  (interactive)
-  ((lambda (head)
-     (when head
-       (save-excursion
-        (goto-char head)
-        (looking-at org-babel-src-block-regexp))
-       (push-mark (match-end 5) nil t)
-       (goto-char (match-beginning 5))))
-   (org-babel-where-is-src-block-head)))
-
-(defun org-babel-demarcate-block (&optional arg)
-  "Wrap or split the code in the region or on the point.
-When called from inside of a code block the current block is
-split.  When called from outside of a code block a new code block
-is created.  In both cases if the region is demarcated and if the
-region is not active then the point is demarcated."
-  (interactive "P")
-  (let ((info (org-babel-get-src-block-info 'light))
-       (headers (progn (org-babel-where-is-src-block-head)
-                       (match-string 4)))
-       (stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
-    (if info
-        (mapc
-         (lambda (place)
-           (save-excursion
-             (goto-char place)
-             (let ((lang (nth 0 info))
-                   (indent (make-string (nth 5 info) ? )))
-              (when (string-match "^[[:space:]]*$"
-                                  (buffer-substring (point-at-bol)
-                                                    (point-at-eol)))
-                (delete-region (point-at-bol) (point-at-eol)))
-               (insert (concat
-                       (if (looking-at "^") "" "\n")
-                       indent "#+end_src\n"
-                       (if arg stars indent) "\n"
-                       indent "#+begin_src " lang
-                       (if (> (length headers) 1)
-                           (concat " " headers) headers)
-                       (if (looking-at "[\n\r]")
-                           ""
-                         (concat "\n" (make-string (current-column) ? )))))))
-          (move-end-of-line 2))
-         (sort (if (org-region-active-p) (list (mark) (point)) (list (point))) #'>))
-      (let ((start (point))
-           (lang (org-icompleting-read "Lang: "
-                                       (mapcar (lambda (el) (symbol-name (car el)))
-                                               org-babel-load-languages)))
-           (body (delete-and-extract-region
-                  (if (org-region-active-p) (mark) (point)) (point))))
-       (insert (concat (if (looking-at "^") "" "\n")
-                       (if arg (concat stars "\n") "")
-                       "#+begin_src " lang "\n"
-                       body
-                       (if (or (= (length body) 0)
-                               (string-match "[\r\n]$" body)) "" "\n")
-                       "#+end_src\n"))
-       (goto-char start) (move-end-of-line 1)))))
-
-(defvar org-babel-lob-one-liner-regexp)
-(defun org-babel-where-is-src-block-result (&optional insert info hash indent)
-  "Find where the current source block results begin.
-Return the point at the beginning of the result of the current
-source block.  Specifically at the beginning of the results line.
-If no result exists for this block then create a results line
-following the source block."
-  (save-excursion
-    (let* ((case-fold-search t)
-          (on-lob-line (save-excursion
-                         (beginning-of-line 1)
-                         (looking-at org-babel-lob-one-liner-regexp)))
-          (inlinep (when (org-babel-get-inline-src-block-matches)
-                     (match-end 0)))
-          (name (if on-lob-line
-                    (mapconcat #'identity (butlast (org-babel-lob-get-info)) "")
-                  (nth 4 (or info (org-babel-get-src-block-info 'light)))))
-          (head (unless on-lob-line (org-babel-where-is-src-block-head)))
-          found beg end)
-      (when head (goto-char head))
-      (setq
-       found ;; was there a result (before we potentially insert one)
-       (or
-       inlinep
-       (and
-        ;; named results:
-        ;; - return t if it is found, else return nil
-        ;; - if it does not need to be rebuilt, then don't set end
-        ;; - if it does need to be rebuilt then do set end
-        name (setq beg (org-babel-find-named-result name))
-        (prog1 beg
-          (when (and hash (not (string= hash (match-string 3))))
-            (goto-char beg) (setq end beg) ;; beginning of result
-            (forward-line 1)
-            (delete-region end (org-babel-result-end)) nil)))
-       (and
-        ;; unnamed results:
-        ;; - return t if it is found, else return nil
-        ;; - if it is found, and the hash doesn't match, delete and set end
-        (or on-lob-line (re-search-forward "^[ \t]*#\\+end_src" nil t))
-        (progn (end-of-line 1)
-               (if (eobp) (insert "\n") (forward-char 1))
-               (setq end (point))
-               (or (and (not name)
-                        (progn ;; unnamed results line already exists
-                          (re-search-forward "[^ \f\t\n\r\v]" nil t)
-                          (beginning-of-line 1)
-                          (looking-at
-                           (concat org-babel-result-regexp "\n")))
-                        (prog1 (point)
-                          ;; must remove and rebuild if hash!=old-hash
-                          (if (and hash (not (string= hash (match-string 3))))
-                              (prog1 nil
-                                (forward-line 1)
-                                (delete-region
-                                 end (org-babel-result-end)))
-                            (setq end nil)))))))))
-      (if (and insert end)
-         (progn
-           (goto-char end)
-           (unless beg
-             (if (looking-at "[\n\r]") (forward-char 1) (insert "\n")))
-           (insert (concat
-                    (if indent
-                        (mapconcat
-                         (lambda (el) " ")
-                         (org-number-sequence 1 indent) "")
-                      "")
-                    "#+" org-babel-results-keyword
-                    (when hash (concat "["hash"]"))
-                    ":"
-                    (when name (concat " " name)) "\n"))
-           (unless beg (insert "\n") (backward-char))
-           (beginning-of-line 0)
-           (if hash (org-babel-hide-hash))
-           (point))
-       found))))
-
-(defvar org-block-regexp)
-(defun org-babel-read-result ()
-  "Read the result at `point' into emacs-lisp."
-  (let ((case-fold-search t) result-string)
-    (cond
-     ((org-at-table-p) (org-babel-read-table))
-     ((org-at-item-p) (org-babel-read-list))
-     ((looking-at org-bracket-link-regexp) (org-babel-read-link))
-     ((looking-at org-block-regexp) (org-babel-trim (match-string 4)))
-     ((looking-at "^[ \t]*: ")
-      (setq result-string
-           (org-babel-trim
-            (mapconcat (lambda (line)
-                          (if (and (> (length line) 1)
-                                   (string-match "^[ \t]*: \\(.+\\)" line))
-                              (match-string 1 line)
-                            line))
-                       (split-string
-                        (buffer-substring
-                          (point) (org-babel-result-end)) "[\r\n]+")
-                       "\n")))
-      (or (org-babel-number-p result-string) result-string))
-     ((looking-at org-babel-result-regexp)
-      (save-excursion (forward-line 1) (org-babel-read-result))))))
-
-(defun org-babel-read-table ()
-  "Read the table at `point' into emacs-lisp."
-  (mapcar (lambda (row)
-            (if (and (symbolp row) (equal row 'hline)) row
-              (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval)) row)))
-          (org-table-to-lisp)))
-
-(defun org-babel-read-list ()
-  "Read the list at `point' into emacs-lisp."
-  (mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
-         (mapcar #'cadr (cdr (org-list-parse-list)))))
-
-(defvar org-link-types-re)
-(defun org-babel-read-link ()
-  "Read the link at `point' into emacs-lisp.
-If the path of the link is a file path it is expanded using
-`expand-file-name'."
-  (let* ((case-fold-search t)
-         (raw (and (looking-at org-bracket-link-regexp)
-                   (org-no-properties (match-string 1))))
-         (type (and (string-match org-link-types-re raw)
-                    (match-string 1 raw))))
-    (cond
-     ((not type) (expand-file-name raw))
-     ((string= type "file")
-      (and (string-match "file\\(.*\\):\\(.+\\)" raw)
-           (expand-file-name (match-string 2 raw))))
-     (t raw))))
-
-(defun org-babel-format-result (result &optional sep)
-  "Format RESULT for writing to file."
-  (let ((echo-res (lambda (r) (if (stringp r) r (format "%S" r)))))
-    (if (listp result)
-       ;; table result
-       (orgtbl-to-generic
-        result (list :sep (or sep "\t") :fmt echo-res))
-      ;; scalar result
-      (funcall echo-res result))))
-
-(defun org-babel-insert-result
-  (result &optional result-params info hash indent lang)
-  "Insert RESULT into the current buffer.
-By default RESULT is inserted after the end of the
-current source block.  With optional argument RESULT-PARAMS
-controls insertion of results in the org-mode file.
-RESULT-PARAMS can take the following values:
-
-replace - (default option) insert results after the source block
-          replacing any previously inserted results
-
-silent -- no results are inserted
-
-file ---- the results are interpreted as a file path, and are
-          inserted into the buffer using the Org-mode file syntax
-
-list ---- the results are interpreted as an Org-mode list.
-
-raw ----- results are added directly to the Org-mode file.  This
-          is a good option if you code block will output org-mode
-          formatted text.
-
-drawer -- results are added directly to the Org-mode file as with
-          \"raw\", but are wrapped in a RESULTS drawer, allowing
-          them to later be replaced or removed automatically.
-
-org ----- results are added inside of a \"#+BEGIN_SRC org\" block.
-          They are not comma-escaped when inserted, but Org syntax
-          here will be discarded when exporting the file.
-
-html ---- results are added inside of a #+BEGIN_HTML block.  This
-          is a good option if you code block will output html
-          formatted text.
-
-latex --- results are added inside of a #+BEGIN_LATEX block.
-          This is a good option if you code block will output
-          latex formatted text.
-
-code ---- the results are extracted in the syntax of the source
-          code of the language being evaluated and are added
-          inside of a #+BEGIN_SRC block with the source-code
-          language set appropriately.  Note this relies on the
-          optional LANG argument."
-  (if (stringp result)
-      (progn
-        (setq result (org-no-properties result))
-        (when (member "file" result-params)
-         (setq result (org-babel-result-to-file
-                       result (when (assoc :file-desc (nth 2 info))
-                                (or (cdr (assoc :file-desc (nth 2 info)))
-                                    result))))))
-    (unless (listp result) (setq result (format "%S" result))))
-  (if (and result-params (member "silent" result-params))
-      (progn
-       (message (replace-regexp-in-string "%" "%%" (format "%S" result)))
-       result)
-    (save-excursion
-      (let* ((inlinep
-             (save-excursion
-               (when (or (org-babel-get-inline-src-block-matches)
-                         (org-babel-get-lob-one-liner-matches))
-                 (goto-char (match-end 0))
-                 (insert (if (listp result) "\n" " "))
-                 (point))))
-            (existing-result (unless inlinep
-                               (org-babel-where-is-src-block-result
-                                t info hash indent)))
-            (results-switches
-             (cdr (assoc :results_switches (nth 2 info))))
-            beg end)
-       (when (and (stringp result)  ; ensure results end in a newline
-                  (not inlinep)
-                  (> (length result) 0)
-                  (not (or (string-equal (substring result -1) "\n")
-                           (string-equal (substring result -1) "\r"))))
-         (setq result (concat result "\n")))
-       (if (not existing-result)
-           (setq beg (or inlinep (point)))
-         (goto-char existing-result)
-         (save-excursion
-           (re-search-forward "#" nil t)
-           (setq indent (- (current-column) 1)))
-         (forward-line 1)
-         (setq beg (point))
-         (cond
-          ((member "replace" result-params)
-           (delete-region (point) (org-babel-result-end)))
-          ((member "append" result-params)
-           (goto-char (org-babel-result-end)) (setq beg (point-marker)))
-          ((member "prepend" result-params)))) ; already there
-       (setq results-switches
-             (if results-switches (concat " " results-switches) ""))
-       (let ((wrap (lambda (start finish)
-                     (goto-char end) (insert (concat finish "\n"))
-                     (goto-char beg) (insert (concat start "\n"))
-                     (org-escape-code-in-region (point) end)
-                     (goto-char end) (goto-char (point-at-eol))
-                     (setq end (point-marker))))
-             (proper-list-p (lambda (it) (and (listp it) (null (cdr (last it)))))))
-         ;; insert results based on type
-         (cond
-          ;; do nothing for an empty result
-          ((null result))
-          ;; insert a list if preferred
-          ((member "list" result-params)
-           (insert
-            (org-babel-trim
-             (org-list-to-generic
-              (cons 'unordered
-                    (mapcar
-                     (lambda (el) (list nil (if (stringp el) el (format "%S" el))))
-                     (if (listp result) result (list result))))
-              '(:splicep nil :istart "- " :iend "\n")))
-            "\n"))
-          ;; assume the result is a table if it's not a string
-          ((funcall proper-list-p result)
-           (goto-char beg)
-           (insert (concat (orgtbl-to-orgtbl
-                            (if (or (eq 'hline (car result))
-                                    (and (listp (car result))
-                                         (listp (cdr (car result)))))
-                                result (list result))
-                            '(:fmt (lambda (cell) (format "%s" cell)))) "\n"))
-           (goto-char beg) (when (org-at-table-p) (org-table-align)))
-          ((and (listp result) (not (funcall proper-list-p result)))
-           (insert (format "%s\n" result)))
-          ((member "file" result-params)
-           (when inlinep (goto-char inlinep))
-           (insert result))
-          (t (goto-char beg) (insert result)))
-         (when (funcall proper-list-p result) (goto-char (org-table-end)))
-         (setq end (point-marker))
-         ;; possibly wrap result
-         (cond
-          ((assoc :wrap (nth 2 info))
-           (let ((name (or (cdr (assoc :wrap (nth 2 info))) "RESULTS")))
-             (funcall wrap (concat "#+BEGIN_" name) (concat "#+END_" name))))
-          ((member "html" result-params)
-           (funcall wrap "#+BEGIN_HTML" "#+END_HTML"))
-          ((member "latex" result-params)
-           (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX"))
-          ((member "org" result-params)
-           (funcall wrap "#+BEGIN_SRC org" "#+END_SRC"))
-          ((member "code" result-params)
-           (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "none") results-switches)
-                    "#+END_SRC"))
-          ((member "raw" result-params)
-           (goto-char beg) (if (org-at-table-p) (org-cycle)))
-          ((or (member "drawer" result-params)
-               ;; Stay backward compatible with <7.9.2
-               (member "wrap" result-params))
-           (funcall wrap ":RESULTS:" ":END:"))
-          ((and (not (funcall proper-list-p result))
-                (not (member "file" result-params)))
-           (org-babel-examplize-region beg end results-switches)
-           (setq end (point)))))
-       ;; possibly indent the results to match the #+results line
-       (when (and (not inlinep) (numberp indent) indent (> indent 0)
-                  ;; in this case `table-align' does the work for us
-                  (not (and (listp result)
-                            (member "append" result-params))))
-         (indent-rigidly beg end indent))))
-    (if (null result)
-       (if (member "value" result-params)
-           (message "Code block returned no value.")
-         (message "Code block produced no output."))
-      (message "Code block evaluation complete."))))
-
-(defun org-babel-remove-result (&optional info)
-  "Remove the result of the current source block."
-  (interactive)
-  (let ((location (org-babel-where-is-src-block-result nil info)) start)
-    (when location
-      (setq start (- location 1))
-      (save-excursion
-        (goto-char location) (forward-line 1)
-        (delete-region start (org-babel-result-end))))))
-
-(defun org-babel-result-end ()
-  "Return the point at the end of the current set of results."
-  (save-excursion
-    (cond
-     ((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
-     ((org-at-item-p) (let* ((struct (org-list-struct))
-                            (prvs (org-list-prevs-alist struct)))
-                       (org-list-get-list-end (point-at-bol) struct prvs)))
-     ((let ((case-fold-search t)) (looking-at "^\\([ \t]*\\):results:"))
-      (progn (re-search-forward (concat "^" (match-string 1) ":END:"))
-            (forward-char 1) (point)))
-     (t
-      (let ((case-fold-search t))
-       (if (looking-at (concat "[ \t]*#\\+begin_\\([^ \t\n\r]+\\)"))
-           (progn (re-search-forward (concat "[ \t]*#\\+end_" (match-string 1))
-                                     nil t)
-                  (forward-char 1))
-         (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
-           (forward-line 1))))
-      (point)))))
-
-(defun org-babel-result-to-file (result &optional description)
-  "Convert RESULT into an `org-mode' link with optional DESCRIPTION.
-If the `default-directory' is different from the containing
-file's directory then expand relative links."
-  (when (stringp result)
-    (format "[[file:%s]%s]"
-           (if (and default-directory
-                    buffer-file-name
-                    (not (string= (expand-file-name default-directory)
-                                  (expand-file-name
-                                   (file-name-directory buffer-file-name)))))
-               (expand-file-name result default-directory)
-             result)
-           (if description (concat "[" description "]") ""))))
-
-(defvar org-babel-capitalize-examplize-region-markers nil
-  "Make true to capitalize begin/end example markers inserted by code blocks.")
-
-(defun org-babel-examplize-region (beg end &optional results-switches)
-  "Comment out region using the inline '==' or ': ' org example quote."
-  (interactive "*r")
-  (let ((chars-between (lambda (b e)
-                        (not (string-match "^[\\s]*$" (buffer-substring b e)))))
-       (maybe-cap (lambda (str) (if org-babel-capitalize-examplize-region-markers
-                                    (upcase str) str))))
-    (if (or (funcall chars-between (save-excursion (goto-char beg) (point-at-bol)) beg)
-           (funcall chars-between end (save-excursion (goto-char end) (point-at-eol))))
-       (save-excursion
-         (goto-char beg)
-         (insert (format "=%s=" (prog1 (buffer-substring beg end)
-                                  (delete-region beg end)))))
-      (let ((size (count-lines beg end)))
-       (save-excursion
-         (cond ((= size 0))          ; do nothing for an empty result
-               ((< size org-babel-min-lines-for-block-output)
-                (goto-char beg)
-                (dotimes (n size)
-                  (beginning-of-line 1) (insert ": ") (forward-line 1)))
-               (t
-                (goto-char beg)
-                (insert (if results-switches
-                            (format "%s%s\n"
-                                    (funcall maybe-cap "#+begin_example")
-                                    results-switches)
-                          (funcall maybe-cap "#+begin_example\n")))
-                (if (markerp end) (goto-char end) (forward-char (- end beg)))
-                (insert (funcall maybe-cap "#+end_example\n")))))))))
-
-(defun org-babel-update-block-body (new-body)
-  "Update the body of the current code block to NEW-BODY."
-  (if (not (org-babel-where-is-src-block-head))
-      (error "Not in a source block")
-    (save-match-data
-      (replace-match (concat (org-babel-trim new-body) "\n") nil t nil 5))
-    (indent-rigidly (match-beginning 5) (match-end 5) 2)))
-
-(defun org-babel-merge-params (&rest plists)
-  "Combine all parameter association lists in PLISTS.
-Later elements of PLISTS override the values of previous elements.
-This takes into account some special considerations for certain
-parameters when merging lists."
-  (let* ((results-exclusive-groups
-         (mapcar (lambda (group) (mapcar #'symbol-name group))
-                 (cdr (assoc 'results org-babel-common-header-args-w-values))))
-        (exports-exclusive-groups
-         (mapcar (lambda (group) (mapcar #'symbol-name group))
-                 (cdr (assoc 'exports org-babel-common-header-args-w-values))))
-        (variable-index 0)
-        (e-merge (lambda (exclusive-groups &rest result-params)
-                   ;; maintain exclusivity of mutually exclusive parameters
-                   (let (output)
-                     (mapc (lambda (new-params)
-                             (mapc (lambda (new-param)
-                                     (mapc (lambda (exclusive-group)
-                                             (when (member new-param exclusive-group)
-                                               (mapcar (lambda (excluded-param)
-                                                         (setq output
-                                                               (delete
-                                                                excluded-param
-                                                                output)))
-                                                       exclusive-group)))
-                                           exclusive-groups)
-                                     (setq output (org-uniquify
-                                                   (cons new-param output))))
-                                   new-params))
-                           result-params)
-                     output)))
-        params results exports tangle noweb cache vars shebang comments padline)
-
-    (mapc
-     (lambda (plist)
-       (mapc
-       (lambda (pair)
-         (case (car pair)
-           (:var
-            (let ((name (if (listp (cdr pair))
-                            (cadr pair)
-                          (and (string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*="
-                                             (cdr pair))
-                               (intern (match-string 1 (cdr pair)))))))
-              (if name
-                  (setq vars
-                        (append
-                         (if (member name (mapcar #'car vars))
-                             (delq nil
-                                   (mapcar
-                                    (lambda (p)
-                                      (unless (equal (car p) name) p))
-                                    vars))
-                           vars)
-                         (list (cons name pair))))
-                ;; if no name is given and we already have named variables
-                ;; then assign to named variables in order
-                (if (and vars (nth variable-index vars))
-                    (prog1 (setf (cddr (nth variable-index vars))
-                                 (concat (symbol-name
-                                          (car (nth variable-index vars)))
-                                         "=" (cdr pair)))
-                      (incf variable-index))
-                  (error "Variable \"%s\" must be assigned a default value"
-                         (cdr pair))))))
-           (:results
-            (setq results (funcall e-merge results-exclusive-groups
-                                   results
-                                   (split-string
-                                    (let ((r (cdr pair)))
-                                      (if (stringp r) r (eval r)))))))
-           (:file
-            (when (cdr pair)
-              (setq results (funcall e-merge results-exclusive-groups
-                                     results '("file")))
-              (unless (or (member "both" exports)
-                          (member "none" exports)
-                          (member "code" exports))
-                (setq exports (funcall e-merge exports-exclusive-groups
-                                       exports '("results"))))
-              (setq params (cons pair (assq-delete-all (car pair) params)))))
-           (:exports
-            (setq exports (funcall e-merge exports-exclusive-groups
-                                   exports (split-string (cdr pair)))))
-           (:tangle ;; take the latest -- always overwrite
-            (setq tangle (or (list (cdr pair)) tangle)))
-           (:noweb
-            (setq noweb (funcall e-merge
-                                 '(("yes" "no" "tangle" "no-export"
-                                    "strip-export" "eval"))
-                                 noweb
-                                 (split-string (or (cdr pair) "")))))
-           (:cache
-            (setq cache (funcall e-merge '(("yes" "no")) cache
-                                 (split-string (or (cdr pair) "")))))
-           (:padline
-            (setq padline (funcall e-merge '(("yes" "no")) padline
-                                   (split-string (or (cdr pair) "")))))
-           (:shebang ;; take the latest -- always overwrite
-            (setq shebang (or (list (cdr pair)) shebang)))
-           (:comments
-            (setq comments (funcall e-merge '(("yes" "no")) comments
-                                    (split-string (or (cdr pair) "")))))
-           (t ;; replace: this covers e.g. :session
-            (setq params (cons pair (assq-delete-all (car pair) params))))))
-       plist))
-     plists)
-    (setq vars (reverse vars))
-    (while vars (setq params (cons (cons :var (cddr (pop vars))) params)))
-    (mapc
-     (lambda (hd)
-       (let ((key (intern (concat ":" (symbol-name hd))))
-            (val (eval hd)))
-        (setf params (cons (cons key (mapconcat 'identity val " ")) params))))
-     '(results exports tangle noweb padline cache shebang comments))
-    params))
-
-(defvar *org-babel-use-quick-and-dirty-noweb-expansion* nil
-  "Set to true to use regular expressions to expand noweb references.
-This results in much faster noweb reference expansion but does
-not properly allow code blocks to inherit the \":noweb-ref\"
-header argument from buffer or subtree wide properties.")
-
-(defun org-babel-noweb-p (params context)
-  "Check if PARAMS require expansion in CONTEXT.
-CONTEXT may be one of :tangle, :export or :eval."
-  (let* (intersect
-        (intersect (lambda (as bs)
-                     (when as
-                       (if (member (car as) bs)
-                           (car as)
-                         (funcall intersect (cdr as) bs))))))
-    (funcall intersect (case context
-                        (:tangle '("yes" "tangle" "no-export" "strip-export"))
-                        (:eval   '("yes" "no-export" "strip-export" "eval"))
-                        (:export '("yes")))
-            (split-string (or (cdr (assoc :noweb params)) "")))))
-
-(defun org-babel-expand-noweb-references (&optional info parent-buffer)
-  "Expand Noweb references in the body of the current source code block.
-
-For example the following reference would be replaced with the
-body of the source-code block named 'example-block'.
-
-<<example-block>>
-
-Note that any text preceding the <<foo>> construct on a line will
-be interposed between the lines of the replacement text.  So for
-example if <<foo>> is placed behind a comment, then the entire
-replacement text will also be commented.
-
-This function must be called from inside of the buffer containing
-the source-code block which holds BODY.
-
-In addition the following syntax can be used to insert the
-results of evaluating the source-code block named 'example-block'.
-
-<<example-block()>>
-
-Any optional arguments can be passed to example-block by placing
-the arguments inside the parenthesis following the convention
-defined by `org-babel-lob'.  For example
-
-<<example-block(a=9)>>
-
-would set the value of argument \"a\" equal to \"9\".  Note that
-these arguments are not evaluated in the current source-code
-block but are passed literally to the \"example-block\"."
-  (let* ((parent-buffer (or parent-buffer (current-buffer)))
-         (info (or info (org-babel-get-src-block-info)))
-         (lang (nth 0 info))
-         (body (nth 1 info))
-        (ob-nww-start org-babel-noweb-wrap-start)
-        (ob-nww-end org-babel-noweb-wrap-end)
-        (comment (string= "noweb" (cdr (assoc :comments (nth 2 info)))))
-        (rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
-                           ":noweb-ref[ \t]+" "\\)"))
-         (new-body "")
-        (nb-add (lambda (text) (setq new-body (concat new-body text))))
-        (c-wrap (lambda (text)
-                  (with-temp-buffer
-                    (funcall (intern (concat lang "-mode")))
-                    (comment-region (point) (progn (insert text) (point)))
-                    (org-babel-trim (buffer-string)))))
-        index source-name evaluate prefix blocks-in-buffer)
-    (with-temp-buffer
-      (org-set-local 'org-babel-noweb-wrap-start ob-nww-start)
-      (org-set-local 'org-babel-noweb-wrap-end ob-nww-end)
-      (insert body) (goto-char (point-min))
-      (setq index (point))
-      (while (and (re-search-forward (org-babel-noweb-wrap) nil t))
-       (save-match-data (setf source-name (match-string 1)))
-       (save-match-data (setq evaluate (string-match "\(.*\)" source-name)))
-       (save-match-data
-         (setq prefix
-               (buffer-substring (match-beginning 0)
-                                 (save-excursion
-                                   (beginning-of-line 1) (point)))))
-       ;; add interval to new-body (removing noweb reference)
-       (goto-char (match-beginning 0))
-       (funcall nb-add (buffer-substring index (point)))
-       (goto-char (match-end 0))
-       (setq index (point))
-       (funcall nb-add
-                (with-current-buffer parent-buffer
-                  (save-restriction
-                    (widen)
-                    (mapconcat ;; interpose PREFIX between every line
-                     #'identity
-                     (split-string
-                      (if evaluate
-                          (let ((raw (org-babel-ref-resolve source-name)))
-                            (if (stringp raw) raw (format "%S" raw)))
-                        (or
-                         ;; retrieve from the library of babel
-                         (nth 2 (assoc (intern source-name)
-                                       org-babel-library-of-babel))
-                         ;; return the contents of headlines literally
-                         (save-excursion
-                           (when (org-babel-ref-goto-headline-id source-name)
-                             (org-babel-ref-headline-body)))
-                         ;; find the expansion of reference in this buffer
-                         (let ((rx (concat rx-prefix source-name "[ \t\n]"))
-                               expansion)
-                           (save-excursion
-                             (goto-char (point-min))
-                             (if *org-babel-use-quick-and-dirty-noweb-expansion*
-                                 (while (re-search-forward rx nil t)
-                                   (let* ((i (org-babel-get-src-block-info 'light))
-                                          (body (org-babel-expand-noweb-references i))
-                                          (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
-                                                   "\n"))
-                                          (full (if comment
-                                                    ((lambda (cs)
-                                                       (concat (funcall c-wrap (car cs)) "\n"
-                                                               body "\n"
-                                                               (funcall c-wrap (cadr cs))))
-                                                     (org-babel-tangle-comment-links i))
-                                                  body)))
-                                     (setq expansion (cons sep (cons full expansion)))))
-                               (org-babel-map-src-blocks nil
-                                 (let ((i (org-babel-get-src-block-info 'light)))
-                                   (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
-                                                    (nth 4 i))
-                                                source-name)
-                                     (let* ((body (org-babel-expand-noweb-references i))
-                                            (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
-                                                     "\n"))
-                                            (full (if comment
-                                                      ((lambda (cs)
-                                                         (concat (funcall c-wrap (car cs)) "\n"
-                                                                 body "\n"
-                                                                 (funcall c-wrap (cadr cs))))
-                                                       (org-babel-tangle-comment-links i))
-                                                    body)))
-                                       (setq expansion
-                                             (cons sep (cons full expansion)))))))))
-                           (and expansion
-                                (mapconcat #'identity (nreverse (cdr expansion)) "")))
-                         ;; possibly raise an error if named block doesn't exist
-                         (if (member lang org-babel-noweb-error-langs)
-                             (error "%s" (concat
-                                          (org-babel-noweb-wrap source-name)
-                                          "could not be resolved (see "
-                                          "`org-babel-noweb-error-langs')"))
-                           "")))
-                      "[\n\r]") (concat "\n" prefix))))))
-      (funcall nb-add (buffer-substring index (point-max))))
-    new-body))
-
-(defun org-babel-script-escape (str &optional force)
-  "Safely convert tables into elisp lists."
-  (let (in-single in-double out)
-    ((lambda (escaped) (condition-case nil (org-babel-read escaped) (error escaped)))
-     (if (or force
-            (and (stringp str)
-                 (> (length str) 2)
-                 (or (and (string-equal "[" (substring str 0 1))
-                          (string-equal "]" (substring str -1)))
-                     (and (string-equal "{" (substring str 0 1))
-                          (string-equal "}" (substring str -1)))
-                     (and (string-equal "(" (substring str 0 1))
-                          (string-equal ")" (substring str -1))))))
-        (org-babel-read
-         (concat
-          "'"
-          (progn
-            (mapc
-             (lambda (ch)
-               (setq
-                out
-                (case ch
-                  (91 (if (or in-double in-single) ; [
-                          (cons 91 out)
-                        (cons 40 out)))
-                  (93 (if (or in-double in-single) ; ]
-                          (cons 93 out)
-                        (cons 41 out)))
-                  (123 (if (or in-double in-single) ; {
-                           (cons 123 out)
-                         (cons 40 out)))
-                  (125 (if (or in-double in-single) ; }
-                           (cons 125 out)
-                         (cons 41 out)))
-                  (44 (if (or in-double in-single) ; ,
-                          (cons 44 out) (cons 32 out)))
-                  (39 (if in-double    ; '
-                          (cons 39 out)
-                        (setq in-single (not in-single)) (cons 34 out)))
-                  (34 (if in-single    ; "
-                          (append (list 34 32) out)
-                        (setq in-double (not in-double)) (cons 34 out)))
-                  (t  (cons ch out)))))
-             (string-to-list str))
-            (apply #'string (reverse out)))))
-       str))))
-
-(defun org-babel-read (cell &optional inhibit-lisp-eval)
-  "Convert the string value of CELL to a number if appropriate.
-Otherwise if cell looks like lisp (meaning it starts with a
-\"(\", \"'\", \"`\" or a \"[\") then read it as lisp, otherwise
-return it unmodified as a string.  Optional argument NO-LISP-EVAL
-inhibits lisp evaluation for situations in which is it not
-appropriate."
-  (if (and (stringp cell) (not (equal cell "")))
-      (or (org-babel-number-p cell)
-          (if (and (not inhibit-lisp-eval)
-                  (member (substring cell 0 1) '("(" "'" "`" "[")))
-              (eval (read cell))
-            (if (string= (substring cell 0 1) "\"")
-               (read cell)
-             (progn (set-text-properties 0 (length cell) nil cell) cell))))
-    cell))
-
-(defun org-babel-number-p (string)
-  "If STRING represents a number return its value."
-  (if (and (string-match "^-?[0-9]*\\.?[0-9]*$" string)
-           (= (length (substring string (match-beginning 0)
-                                (match-end 0)))
-             (length string)))
-      (string-to-number string)))
-
-(defun org-babel-import-elisp-from-file (file-name &optional separator)
-  "Read the results located at FILE-NAME into an elisp table.
-If the table is trivial, then return it as a scalar."
-  (let (result)
-    (save-window-excursion
-      (with-temp-buffer
-       (condition-case err
-           (progn
-             (org-table-import file-name separator)
-             (delete-file file-name)
-             (setq result (mapcar (lambda (row)
-                                    (mapcar #'org-babel-string-read row))
-                                  (org-table-to-lisp))))
-         (error (message "Error reading results: %s" err) nil)))
-      (if (null (cdr result)) ;; if result is trivial vector, then scalarize it
-         (if (consp (car result))
-             (if (null (cdr (car result)))
-                 (caar result)
-               result)
-           (car result))
-       result))))
-
-(defun org-babel-string-read (cell)
-  "Strip nested \"s from around strings."
-  (org-babel-read (or (and (stringp cell)
-                           (string-match "\\\"\\(.+\\)\\\"" cell)
-                           (match-string 1 cell))
-                      cell) t))
-
-(defun org-babel-reverse-string (string)
-  "Return the reverse of STRING."
-  (apply 'string (reverse (string-to-list string))))
-
-(defun org-babel-chomp (string &optional regexp)
-  "Strip trailing spaces and carriage returns from STRING.
-Default regexp used is \"[ \f\t\n\r\v]\" but can be
-overwritten by specifying a regexp as a second argument."
-  (let ((regexp (or regexp "[ \f\t\n\r\v]")))
-    (while (and (> (length string) 0)
-                (string-match regexp (substring string -1)))
-      (setq string (substring string 0 -1)))
-    string))
-
-(defun org-babel-trim (string &optional regexp)
-  "Strip leading and trailing spaces and carriage returns from STRING.
-Like `org-babel-chomp' only it runs on both the front and back
-of the string."
-  (org-babel-chomp (org-babel-reverse-string
-                    (org-babel-chomp (org-babel-reverse-string string) regexp))
-                   regexp))
-
-(defvar org-babel-org-babel-call-process-region-original nil)
-(defun org-babel-tramp-handle-call-process-region
-  (start end program &optional delete buffer display &rest args)
-  "Use Tramp to handle `call-process-region'.
-Fixes a bug in `tramp-handle-call-process-region'."
-  (if (and (featurep 'tramp) (file-remote-p default-directory))
-      (let ((tmpfile (tramp-compat-make-temp-file "")))
-       (write-region start end tmpfile)
-       (when delete (delete-region start end))
-       (unwind-protect
-           ;;  (apply 'call-process program tmpfile buffer display args)
-            ;; bug in tramp
-           (apply 'process-file program tmpfile buffer display args)
-         (delete-file tmpfile)))
-    ;; org-babel-call-process-region-original is the original emacs
-    ;; definition.  It is in scope from the let binding in
-    ;; org-babel-execute-src-block
-    (apply org-babel-call-process-region-original
-           start end program delete buffer display args)))
-
-(defun org-babel-local-file-name (file)
-  "Return the local name component of FILE."
-  (if (file-remote-p file)
-      (let (localname)
-       (with-parsed-tramp-file-name file nil
-                                    localname))
-    file))
-
-(defun org-babel-process-file-name (name &optional no-quote-p)
-  "Prepare NAME to be used in an external process.
-If NAME specifies a remote location, the remote portion of the
-name is removed, since in that case the process will be executing
-remotely.  The file name is then processed by `expand-file-name'.
-Unless second argument NO-QUOTE-P is non-nil, the file name is
-additionally processed by `shell-quote-argument'"
-  ((lambda (f) (if no-quote-p f (shell-quote-argument f)))
-   (expand-file-name (org-babel-local-file-name name))))
-
-(defvar org-babel-temporary-directory)
-(unless (or noninteractive (boundp 'org-babel-temporary-directory))
-  (defvar org-babel-temporary-directory
-    (or (and (boundp 'org-babel-temporary-directory)
-            (file-exists-p org-babel-temporary-directory)
-            org-babel-temporary-directory)
-       (make-temp-file "babel-" t))
-    "Directory to hold temporary files created to execute code blocks.
-Used by `org-babel-temp-file'.  This directory will be removed on
-Emacs shutdown."))
-
-(defun org-babel-temp-file (prefix &optional suffix)
-  "Create a temporary file in the `org-babel-temporary-directory'.
-Passes PREFIX and SUFFIX directly to `make-temp-file' with the
-value of `temporary-file-directory' temporarily set to the value
-of `org-babel-temporary-directory'."
-  (let ((temporary-file-directory
-        (if (file-remote-p default-directory)
-            (concat (file-remote-p default-directory) "/tmp")
-          (or (and (boundp 'org-babel-temporary-directory)
-                   (file-exists-p org-babel-temporary-directory)
-                   org-babel-temporary-directory)
-              temporary-file-directory))))
-      (make-temp-file prefix nil suffix)))
-
-(defun org-babel-remove-temporary-directory ()
-  "Remove `org-babel-temporary-directory' on Emacs shutdown."
-  (when (and (boundp 'org-babel-temporary-directory)
-            (file-exists-p org-babel-temporary-directory))
-    ;; taken from `delete-directory' in files.el
-    (condition-case nil
-       (progn
-         (mapc (lambda (file)
-                 ;; This test is equivalent to
-                 ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
-                 ;; but more efficient
-                 (if (eq t (car (file-attributes file)))
-                     (delete-directory file)
-                   (delete-file file)))
-               ;; We do not want to delete "." and "..".
-               (directory-files org-babel-temporary-directory 'full
-                                "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
-         (delete-directory org-babel-temporary-directory))
-      (error
-       (message "Failed to remove temporary Org-babel directory %s"
-               (if (boundp 'org-babel-temporary-directory)
-                   org-babel-temporary-directory
-                 "[directory not defined]"))))))
-
-(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)
+(require 'ob-eval)
+(require 'ob-core)
+(require 'ob-comint)
+(require 'ob-exp)
+(require 'ob-keys)
+(require 'ob-table)
+(require 'ob-lob)
+(require 'ob-ref)
+(require 'ob-tangle)
 
 (provide 'ob)
 
index 764b15ff6c558ffb7baf2ee78060e3ec56264746..5ef92f7aaebfee699b9dbe24ee6097bf2ea108ba 100644 (file)
@@ -227,7 +227,9 @@ As the value of this option simply gets inserted into the HTML <head> header,
 you can \"misuse\" it to also add other text to the header."
   :group 'org-agenda-export
   :group 'org-export-html
-  :type 'string)
+  :type '(choice
+         (const nil)
+         (string)))
 
 (defcustom org-agenda-persistent-filter nil
   "When set, keep filters from one agenda view to the next."
@@ -242,6 +244,11 @@ you can \"misuse\" it to also add other text to the header."
 (defconst org-sorting-choice
   '(choice
     (const time-up) (const time-down)
+    (const timestamp-up) (const timestamp-down)
+    (const scheduled-up) (const scheduled-down)
+    (const deadline-up)  (const deadline-down)
+    (const ts-up) (const ts-down)
+    (const tsia-up) (const tsia-down)
     (const category-keep) (const category-up) (const category-down)
     (const tag-down) (const tag-up)
     (const priority-up) (const priority-down)
@@ -254,9 +261,50 @@ you can \"misuse\" it to also add other text to the header."
 
 ;; Keep custom values for `org-agenda-filter-preset' compatible with
 ;; the new variable `org-agenda-tag-filter-preset'.
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
-  (defvaralias 'org-agenda-filter 'org-agenda-tag-filter))
+(org-defvaralias 'org-agenda-filter-preset 'org-agenda-tag-filter-preset)
+(org-defvaralias 'org-agenda-filter 'org-agenda-tag-filter)
+
+(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
+  "List of types searched for when creating the daily/weekly agenda.
+This variable is a list of symbols that controls the types of
+items that appear in the daily/weekly agenda.  Allowed symbols in this
+list are are
+
+  :timestamp   List items containing a date stamp or date range matching
+               the selected date.  This includes sexp entries in angular
+               brackets.
+
+  :sexp        List entries resulting from plain diary-like sexps.
+
+  :deadline    List deadline due on that date.  When the date is today,
+               also list any deadlines past due, or due within
+              `org-deadline-warning-days'.  `:deadline' must appear before
+               `:scheduled' if the setting of
+               `org-agenda-skip-scheduled-if-deadline-is-shown' is to have
+               any effect.
+
+  :deadline*   Same as above, but only include the deadline if it has an
+               hour specification as [h]h:mm.
+
+  :scheduled   List all items which are scheduled for the given date.
+              The diary for *today* also contains items which were
+              scheduled earlier and are not yet marked DONE.
+
+  :scheduled*  Same as above, but only include the scheduled item if it
+               has an hour specification as [h]h:mm.
+
+By default, all four non-starred types are turned on.
+
+When :scheduled* or :deadline* are included, :schedule or :deadline
+will be ignored.
+
+Never set this variable globally using `setq', because then it
+will apply to all future agenda commands.  Instead, bind it with
+`let' to scope it dynamically into the agenda-constructing
+command.  A good way to set it is through options in
+`org-agenda-custom-commands'.  For a more flexible (though
+somewhat less efficient) way of determining what is included in
+the daily/weekly agenda, see `org-agenda-skip-function'.")
 
 (defconst org-agenda-custom-commands-local-options
   `(repeat :tag "Local settings for this command.  Remember to quote values"
@@ -282,6 +330,7 @@ you can \"misuse\" it to also add other text to the header."
                         (const org-agenda-span)
                         (choice (const :tag "Day" 'day)
                                 (const :tag "Week" 'week)
+                                (const :tag "Fortnight" 'fortnight)
                                 (const :tag "Month" 'month)
                                 (const :tag "Year" 'year)
                                 (integer :tag "Custom")))
@@ -311,13 +360,21 @@ you can \"misuse\" it to also add other text to the header."
                          (const :format "" quote)
                          (repeat
                           (string :tag "+tag or -tag"))))
+                  (list :tag "Regexp filter preset"
+                        (const org-agenda-regexp-filter-preset)
+                        (list
+                         (const :format "" quote)
+                         (repeat
+                          (string :tag "+regexp or -regexp"))))
                   (list :tag "Set daily/weekly entry types"
                         (const org-agenda-entry-types)
                         (list
                          (const :format "" quote)
-                         (set :greedy t :value (:deadline :scheduled :timestamp :sexp)
+                         (set :greedy t :value ,org-agenda-entry-types
                               (const :deadline)
                               (const :scheduled)
+                              (const :deadline*)
+                              (const :scheduled*)
                               (const :timestamp)
                               (const :sexp))))
                   (list :tag "Standard skipping condition"
@@ -371,8 +428,8 @@ This will be spliced into the custom type of
 `org-agenda-custom-commands'.")
 
 
-(defcustom org-agenda-custom-commands '(("n" "Agenda and all TODO's"
-                                        ((agenda "") (alltodo))))
+(defcustom org-agenda-custom-commands
+  '(("n" "Agenda and all TODO's" ((agenda "") (alltodo ""))))
   "Custom commands for the agenda.
 These commands will be offered on the splash screen displayed by the
 agenda dispatcher \\[org-agenda].  Each entry is a list like this:
@@ -603,6 +660,13 @@ that are marked with the ARCHIVE tag will be included anyway.  When this is
 t, also all archive files associated with the current selection of agenda
 files will be included.")
 
+(defcustom org-agenda-restriction-lock-highlight-subtree t
+  "Non-nil means highlight the whole subtree when restriction is active.
+Otherwise only highlight the headline.  Highlighting the whole subtree is
+useful to ensure no edits happen beyond the restricted region."
+  :group 'org-agenda
+  :type 'boolean)
+
 (defcustom org-agenda-skip-comment-trees t
   "Non-nil means skip trees that start with the COMMENT keyword.
 When nil, these trees are also scanned by agenda commands."
@@ -740,8 +804,24 @@ to make his option also apply to the tags-todo list."
          (const :tag "Show all TODOs, even if they have a deadline" nil)
          (integer :tag "Ignore if N or more days in past(-) or future(+).")))
 
+(defcustom org-agenda-todo-ignore-time-comparison-use-seconds nil
+  "Time unit to use when possibly ignoring an agenda item.
+
+See the docstring of various `org-agenda-todo-ignore-*' options.
+The default is to compare time stamps using days.  An item is thus
+considered to be in the future if it is at least one day after today.
+Non-nil means to compare time stamps using seconds.  An item is then
+considered future if it has a time value later than current time."
+  :group 'org-agenda-skip
+  :group 'org-agenda-todo-list
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Compare time with days" nil)
+         (const :tag "Compare time with seconds" t)))
+
 (defcustom org-agenda-tags-todo-honor-ignore-options nil
-  "Non-nil means honor todo-list ...ignore options also in tags-todo search.
+  "Non-nil means honor todo-list ignores options also in tags-todo search.
 The variables
    `org-agenda-todo-ignore-with-date',
    `org-agenda-todo-ignore-timestamp',
@@ -768,20 +848,29 @@ is DONE."
 
 (defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
   "Non-nil means skip scheduling line if same entry shows because of deadline.
-In the agenda of today, an entry can show up multiple times because
-it is both scheduled and has a nearby deadline, and maybe a plain time
-stamp as well.
-When this variable is t, then only the deadline is shown and the fact that
-the entry is scheduled today or was scheduled previously is not shown.
-When this variable is nil, the entry will be shown several times.  When
-the variable is the symbol `not-today', then skip scheduled previously,
-but not scheduled today."
+
+In the agenda of today, an entry can show up multiple times
+because it is both scheduled and has a nearby deadline, and maybe
+a plain time stamp as well.
+
+When this variable is nil, the entry will be shown several times.
+
+When set to t, then only the deadline is shown and the fact that
+the entry is scheduled today or was scheduled previously is not
+shown.
+
+When set to the symbol `not-today', skip scheduled previously,
+but not scheduled today.
+
+When set to the symbol `repeated-after-deadline', skip scheduled
+items if they are repeated beyond the current deadline."
   :group 'org-agenda-skip
   :group 'org-agenda-daily/weekly
   :type '(choice
          (const :tag "Never" nil)
          (const :tag "Always" t)
-         (const :tag "Not when scheduled today" not-today)))
+         (const :tag "Not when scheduled today" not-today)
+         (const :tag "When repeated past deadline" repeated-after-deadline)))
 
 (defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
   "Non-nil means skip timestamp line if same entry shows because of deadline.
@@ -813,9 +902,10 @@ deadlines are always turned off when the item is DONE."
 This will apply on all days where a prewarning for the deadline would
 be shown, but not at the day when the entry is actually due.  On that day,
 the deadline will be shown anyway.
-This variable may be set to nil, t, or a number which will then give
-the number of days before the actual deadline when the prewarnings
-should resume.
+This variable may be set to nil, t, the symbol `pre-scheduled',
+or a number which will then give the number of days before the actual
+deadline when the prewarnings should resume.  The symbol `pre-scheduled'
+eliminates the deadline prewarning only prior to the scheduled date.
 This can be used in a workflow where the first showing of the deadline will
 trigger you to schedule it, and then you don't want to be reminded of it
 because you will take care of it on the day when scheduled."
@@ -824,9 +914,26 @@ because you will take care of it on the day when scheduled."
   :version "24.1"
   :type '(choice
          (const :tag "Always show prewarning" nil)
+         (const :tag "Remove prewarning prior to scheduled date" pre-scheduled)
          (const :tag "Remove prewarning if entry is scheduled" t)
          (integer :tag "Restart prewarning N days before deadline")))
 
+(defcustom org-agenda-skip-scheduled-delay-if-deadline nil
+  "Non-nil means skip scheduled delay when entry also has a deadline.
+This variable may be set to nil, t, the symbol `post-deadline',
+or a number which will then give the number of days after the actual
+scheduled date when the delay should expire.  The symbol `post-deadline'
+eliminates the schedule delay when the date is posterior to the deadline."
+  :group 'org-agenda-skip
+  :group 'org-agenda-daily/weekly
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Always honor delay" nil)
+         (const :tag "Ignore delay if posterior to the deadline" post-deadline)
+         (const :tag "Ignore delay if entry has a deadline" t)
+         (integer :tag "Honor delay up until N days after the scheduled date")))
+
 (defcustom org-agenda-skip-additional-timestamps-same-entry nil
   "When nil, multiple same-day timestamps in entry make multiple agenda lines.
 When non-nil, after the search for timestamps has matched once in an
@@ -840,7 +947,7 @@ entry, the rest of the entry will not be searched."
   :group 'org-agenda-daily/weekly
   :type 'boolean)
 
-(defcustom org-agenda-dim-blocked-tasks nil
+(defcustom org-agenda-dim-blocked-tasks t
   "Non-nil means dim blocked tasks in the agenda display.
 This causes some overhead during agenda construction, but if you
 have turned on `org-enforce-todo-dependencies',
@@ -956,6 +1063,13 @@ removed from entry text before it is shown in the agenda."
   :group 'org-agenda
   :type '(repeat (regexp)))
 
+(defcustom org-agenda-entry-text-leaders "    > "
+  "Text prepended to the entry text in agenda buffers."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-agenda
+  :type 'string)
+
 (defvar org-agenda-entry-text-cleanup-hook nil
   "Hook that is run after basic cleanup of entry text to be shown in agenda.
 This cleanup is done in a temporary buffer, so the function may inspect and
@@ -1013,7 +1127,8 @@ option will be ignored."
 Should be 1 or 7.
 Obsolete, see `org-agenda-span'."
   :group 'org-agenda-daily/weekly
-  :type 'integer)
+  :type '(choice (const nil)
+                (integer)))
 
 (make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
 
@@ -1024,13 +1139,14 @@ Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
   :type '(choice (const :tag "Day" day)
                 (const :tag "Week" week)
+                (const :tag "Fortnight" fortnight)
                 (const :tag "Month" month)
                 (const :tag "Year" year)
                 (integer :tag "Custom")))
 
 (defcustom org-agenda-start-on-weekday 1
   "Non-nil means start the overview always on the specified weekday.
-0 denotes Sunday, 1 denotes Monday etc.
+0 denotes Sunday, 1 denotes Monday, etc.
 When nil, always start on the current day.
 Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
@@ -1055,7 +1171,7 @@ a calendar-style date list like (month day year)."
          (function :tag "Function")))
 
 (defun org-agenda-format-date-aligned (date)
-  "Format a date string for display in the daily/weekly agenda, or timeline.
+  "Format a DATE string for display in the daily/weekly agenda, or timeline.
 This function makes sure that dates are aligned for easy reading."
   (require 'cal-iso)
   (let* ((dayname (calendar-day-name date))
@@ -1108,8 +1224,7 @@ For example, 9:30am would become 09:30 rather than  9:30."
      ":" minute ampm)))
 
 (defun org-agenda-time-of-day-to-ampm-maybe (time)
-  "Conditionally convert TIME to AM/PM format
-based on `org-agenda-timegrid-use-ampm'"
+  "Conditionally convert TIME to AM/PM format based on `org-agenda-timegrid-use-ampm'."
   (if org-agenda-timegrid-use-ampm
       (org-agenda-time-of-day-to-ampm time)
     time))
@@ -1164,7 +1279,7 @@ shown, either today or the nearest into the future."
          (const :tag "Don't show repeating stamps" nil)))
 
 (defcustom org-scheduled-past-days 10000
-  "No. of days to continue listing scheduled items that are not marked DONE.
+  "Number of days to continue listing scheduled items not marked DONE.
 When an item is scheduled on a date, it shows up in the agenda on this
 day and will be listed until it is marked done for the number of days
 given here."
@@ -1294,9 +1409,8 @@ boolean search."
   :version "24.1"
   :type 'boolean)
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-search-view-search-words-only
-      'org-agenda-search-view-always-boolean))
+(org-defvaralias 'org-agenda-search-view-search-words-only
+  'org-agenda-search-view-always-boolean)
 
 (defcustom org-agenda-search-view-force-full-words nil
   "Non-nil means, search words must be matches as complete words.
@@ -1305,6 +1419,15 @@ When nil, they may also match part of a word."
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-agenda-search-view-max-outline-level nil
+  "Maximum outline level to display in search view.
+E.g. when this is set to 1, the search view will only
+show headlines of level 1."
+  :group 'org-agenda-search-view
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
 (defgroup org-agenda-time-grid nil
   "Options concerning the time grid in the Org-mode Agenda."
   :tag "Org Agenda Time Grid"
@@ -1393,6 +1516,16 @@ symbols are recognized:
 
 time-up            Put entries with time-of-day indications first, early first
 time-down          Put entries with time-of-day indications first, late first
+timestamp-up       Sort by any timestamp, early first
+timestamp-down     Sort by any timestamp, late first
+scheduled-up       Sort by scheduled timestamp, early first
+scheduled-down     Sort by scheduled timestamp, late first
+deadline-up        Sort by deadline timestamp, early first
+deadline-down      Sort by deadline timestamp, late first
+ts-up              Sort by active timestamp, early first
+ts-down            Sort by active timestamp, late first
+tsia-up            Sort by inactive timestamp, early first
+tsia-down          Sort by inactive timestamp, late first
 category-keep      Keep the default order of categories, corresponding to the
                   sequence in `org-agenda-files'.
 category-up        Sort alphabetically by category, A-Z.
@@ -1493,15 +1626,17 @@ This format works similar to a printf format, with the following meaning:
   %c   the category of the item, \"Diary\" for entries from the diary,
        or as given by the CATEGORY keyword or derived from the file name
   %e   the effort required by the item
+  %l   the level of the item (insert X space(s) if item is of level X)
   %i   the icon category of the item, see `org-agenda-category-icon-alist'
   %T   the last tag of the item (ignore inherited tags, which come first)
   %t   the HH:MM time-of-day specification if one applies to the entry
   %s   Scheduling/Deadline information, a short string
+  %b   show breadcrumbs, i.e., the names of the higher levels
   %(expression) Eval EXPRESSION and replace the control string
                 by the result
 
 All specifiers work basically like the standard `%s' of printf, but may
-contain two additional characters:  a question mark just after the `%'
+contain two additional characters: a question mark just after the `%'
 and a whitespace/punctuation character just before the final letter.
 
 If the first character after `%' is a question mark, the entire field
@@ -1511,11 +1646,11 @@ present, but zero width when absent.  For example, \"%?-12t\" will
 result in a 12 character time field if a time of the day is specified,
 but will completely disappear in entries which do not contain a time.
 
-If there is punctuation or whitespace character just before the final
-format letter, this character will be appended to the field value if
-the value is not empty.  For example, the format \"%-12:c\" leads to
-\"Diary: \" if the category is \"Diary\".  If the category were be
-empty, no additional colon would be inserted.
+If there is punctuation or whitespace character just before the
+final format letter, this character will be appended to the field
+value if the value is not empty.  For example, the format
+\"%-12:c\" leads to \"Diary: \" if the category is \"Diary\".  If
+the category is empty, no additional colon is inserted.
 
 The default value for the agenda sublist is \"  %-12:c%?-12t% s\",
 which means:
@@ -1588,6 +1723,8 @@ this item is scheduled, due to automatic rescheduling of unfinished items
 for the following day.  So this number is one larger than the number of days
 that passed since this item was scheduled first."
   :group 'org-agenda-line-format
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type '(list
          (string :tag "Scheduled today     ")
          (string :tag "Scheduled previously")))
@@ -1597,17 +1734,17 @@ that passed since this item was scheduled first."
 These entries are added to the agenda when pressing \"[\"."
   :group 'org-agenda-line-format
   :version "24.1"
-  :type '(list
-         (string :tag "Scheduled today     ")
-         (string :tag "Scheduled previously")))
+  :type 'string)
 
-(defcustom org-agenda-deadline-leaders '("Deadline:  " "In %3d d.: ")
+(defcustom org-agenda-deadline-leaders '("Deadline:  " "In %3d d.: " "%2d d. ago: ")
   "Text preceding deadline items in the agenda view.
-This is a list with two strings.  The first applies when the item has its
-deadline on the current day.  The second applies when it is in the past or
-in the future, it may contain %d to capture how many days away the deadline
-is (was)."
+This is a list with three strings.  The first applies when the item has its
+deadline on the current day.  The second applies when the deadline is in the
+future, the third one when it is in the past.  The strings may contain %d
+to capture the number of days."
   :group 'org-agenda-line-format
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type '(list
          (string :tag "Deadline today   ")
          (choice :tag "Deadline relative"
@@ -1716,9 +1853,8 @@ When this is the symbol `prefix', only remove tags when
          (const :tag "Never" nil)
          (const :tag "When prefix format contains %T" prefix)))
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-remove-tags-when-in-prefix
-      'org-agenda-remove-tags))
+(org-defvaralias 'org-agenda-remove-tags-when-in-prefix
+  'org-agenda-remove-tags)
 
 (defcustom org-agenda-tags-column (if (featurep 'xemacs) -79 -80)
   "Shift tags in agenda items to this column.
@@ -1728,8 +1864,7 @@ it means that the tags should be flushright to that column.  For example,
   :group 'org-agenda-line-format
   :type 'integer)
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column))
+(org-defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
 
 (defcustom org-agenda-fontify-priorities 'cookies
   "Non-nil means highlight low and high priorities in agenda.
@@ -1762,7 +1897,7 @@ returns a face, or nil if does not want to specify a face and let
 the normal rules apply."
   :group 'org-agenda-line-format
   :version "24.1"
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defcustom org-agenda-category-icon-alist nil
   "Alist of category icon to be displayed in agenda views.
@@ -1844,7 +1979,7 @@ Note that for the purpose of tag filtering, only the lower-case version of
 all tags will be considered, so that this function will only ever see
 the lower-case version of all tags."
   :group 'org-agenda
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defcustom org-agenda-bulk-custom-functions nil
   "Alist of characters and custom functions for bulk actions.
@@ -1887,8 +2022,7 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
 
 (defvar org-agenda-mode-map (make-sparse-keymap)
   "Keymap for `org-agenda-mode'.")
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-keymap 'org-agenda-mode-map))
+(org-defvaralias 'org-agenda-keymap 'org-agenda-mode-map)
 
 (defvar org-agenda-menu) ; defined later in this file.
 (defvar org-agenda-restrict nil) ; defined later in this file.
@@ -1956,12 +2090,14 @@ When nil, `q' will kill the single agenda buffer."
     org-agenda-bulk-marked-entries
     org-agenda-undo-has-started-in
     org-agenda-info
-    org-agenda-tag-filter-overlays
-    org-agenda-cat-filter-overlays
     org-agenda-pre-window-conf
     org-agenda-columns-active
+    org-agenda-tag-filter-overlays
     org-agenda-tag-filter
+    org-agenda-cat-filter-overlays
     org-agenda-category-filter
+    org-agenda-re-filter-overlays
+    org-agenda-regexp-filter
     org-agenda-markers
     org-agenda-last-search-view-search-was-boolean
     org-agenda-filtered-by-category
@@ -2015,10 +2151,10 @@ The following commands are available:
   (org-add-hook 'post-command-hook 'org-agenda-update-agenda-type nil 'local)
   (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
   ;; Make sure properties are removed when copying text
-  (add-hook 'filter-buffer-substring-functions
-           (lambda (fun start end delete)
-             (substring-no-properties (funcall fun start end delete)))
-            nil t)
+  (org-add-hook 'filter-buffer-substring-functions
+               (lambda (fun start end delete)
+                 (substring-no-properties (funcall fun start end delete)))
+               nil t)
   (unless org-agenda-keep-modes
     (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
          org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
@@ -2049,8 +2185,12 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "\C-m"     'org-agenda-switch-to)
 (org-defkey org-agenda-mode-map "\C-k"     'org-agenda-kill)
 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
+(org-defkey org-agenda-mode-map [(meta down)] 'org-agenda-drag-line-forward)
+(org-defkey org-agenda-mode-map [(meta up)] 'org-agenda-drag-line-backward)
 (org-defkey org-agenda-mode-map "m"        'org-agenda-bulk-mark)
+(org-defkey org-agenda-mode-map "\M-m"     'org-agenda-bulk-toggle)
 (org-defkey org-agenda-mode-map "*"        'org-agenda-bulk-mark-all)
+(org-defkey org-agenda-mode-map "\M-*"     'org-agenda-bulk-toggle-all)
 (org-defkey org-agenda-mode-map "#"        'org-agenda-dim-blocked-tasks)
 (org-defkey org-agenda-mode-map "%"        'org-agenda-bulk-mark-regexp)
 (org-defkey org-agenda-mode-map "u"        'org-agenda-bulk-unmark)
@@ -2164,9 +2304,12 @@ The following commands are available:
 (org-defkey org-agenda-mode-map "{" 'org-agenda-manipulate-query-add-re)
 (org-defkey org-agenda-mode-map "}" 'org-agenda-manipulate-query-subtract-re)
 (org-defkey org-agenda-mode-map "/" 'org-agenda-filter-by-tag)
+(org-defkey org-agenda-mode-map "=" 'org-agenda-filter-by-regexp)
+(org-defkey org-agenda-mode-map "|" 'org-agenda-filter-remove-all)
 (org-defkey org-agenda-mode-map "\\" 'org-agenda-filter-by-tag-refine)
+(org-defkey org-agenda-mode-map "~" 'org-agenda-limit-interactively)
 (org-defkey org-agenda-mode-map "<" 'org-agenda-filter-by-category)
-(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-category)
+(org-defkey org-agenda-mode-map "^" 'org-agenda-filter-by-top-headline)
 (org-defkey org-agenda-mode-map ";" 'org-timer-set-timer)
 (define-key org-agenda-mode-map "?" 'org-agenda-show-the-flagging-note)
 (org-defkey org-agenda-mode-map "\C-c\C-x\C-mg"    'org-mobile-pull)
@@ -2194,7 +2337,11 @@ The following commands are available:
      ["Week View" org-agenda-week-view
       :active (org-agenda-check-type nil 'agenda)
       :style radio :selected (eq org-agenda-current-span 'week)
-      :keys "v w  (or just w)"]
+      :keys "v w"]
+     ["Fortnight View" org-agenda-fortnight-view
+      :active (org-agenda-check-type nil 'agenda)
+      :style radio :selected (eq org-agenda-current-span 'fortnight)
+      :keys "v f"]
      ["Month View" org-agenda-month-view
       :active (org-agenda-check-type nil 'agenda)
       :style radio :selected (eq org-agenda-current-span 'month)
@@ -2263,9 +2410,11 @@ The following commands are available:
     ("Bulk action"
      ["Mark entry" org-agenda-bulk-mark t]
      ["Mark all" org-agenda-bulk-mark-all t]
-     ["Mark matching regexp" org-agenda-bulk-mark-regexp t]
      ["Unmark entry" org-agenda-bulk-unmark t]
-     ["Unmark all entries" org-agenda-bulk-unmark-all :active t :keys "U"])
+     ["Unmark all" org-agenda-bulk-unmark-all :active t :keys "U"]
+     ["Toggle mark" org-agenda-bulk-toggle t]
+     ["Toggle all" org-agenda-bulk-toggle-all t]
+     ["Mark regexp" org-agenda-bulk-mark-regexp t])
     ["Act on all marked" org-agenda-bulk-action t]
     "--"
     ("Tags and Properties"
@@ -2307,7 +2456,7 @@ The following commands are available:
      ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
      ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
      "--"
-     ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
+     ["Create iCalendar File" org-icalendar-combine-agenda-files t])
     "--"
     ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
     "--"
@@ -2336,12 +2485,12 @@ This undoes changes both in the agenda buffer and in the remote buffer
 that have been changed along."
   (interactive)
   (or org-agenda-allow-remote-undo
-      (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
+      (user-error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo"))
   (if (not (eq this-command last-command))
       (setq org-agenda-undo-has-started-in nil
            org-agenda-pending-undo-list org-agenda-undo-list))
   (if (not org-agenda-pending-undo-list)
-      (error "No further undo information"))
+      (user-error "No further undo information"))
   (let* ((entry (pop org-agenda-pending-undo-list))
         buf line cmd rembuf)
     (setq cmd (pop entry) line (pop entry))
@@ -2392,6 +2541,8 @@ Here are the available contexts definitions:
       in-mode: command displayed only in matching modes
   not-in-file: command not displayed in matching files
   not-in-mode: command not displayed in matching modes
+    in-buffer: command displayed only in matching buffers
+not-in-buffer: command not displayed in matching buffers
    [function]: a custom function taking no argument
 
 If you define several checks, the agenda command will be
@@ -2417,11 +2568,89 @@ duplicates.)"
                                      (choice
                                       (const :tag "In file" in-file)
                                       (const :tag "Not in file" not-in-file)
+                                      (const :tag "In buffer" in-buffer)
+                                      (const :tag "Not in buffer" not-in-buffer)
                                       (const :tag "In mode" in-mode)
                                       (const :tag "Not in mode" not-in-mode))
                                      (regexp))
                                (function :tag "Custom function"))))))
 
+(defcustom org-agenda-max-entries nil
+  "Maximum number of entries to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-agenda-custom-commands
+  :type '(choice (symbol :tag "No limit" nil)
+                (integer :tag "Max number of entries")
+                (repeat
+                 (cons (choice :tag "Agenda type"
+                               (const agenda)
+                               (const todo)
+                               (const tags)
+                               (const search)
+                               (const timeline))
+                       (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-todos nil
+  "Maximum number of TODOs to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-agenda-custom-commands
+  :type '(choice (symbol :tag "No limit" nil)
+                (integer :tag "Max number of entries")
+                (repeat
+                 (cons (choice :tag "Agenda type"
+                               (const agenda)
+                               (const todo)
+                               (const tags)
+                               (const search)
+                               (const timeline))
+                       (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-tags nil
+  "Maximum number of tagged entries to display in an agenda.
+This can be nil (no limit) or an integer or an alist of agenda
+types with an associated number of entries to display in this
+type."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-agenda-custom-commands
+  :type '(choice (symbol :tag "No limit" nil)
+                (integer :tag "Max number of entries")
+                (repeat
+                 (cons (choice :tag "Agenda type"
+                               (const agenda)
+                               (const todo)
+                               (const tags)
+                               (const search)
+                               (const timeline))
+                       (integer :tag "Max number of entries")))))
+
+(defcustom org-agenda-max-effort nil
+  "Maximum cumulated effort duration for the agenda.
+This can be nil (no limit) or a number of minutes (as an integer)
+or an alist of agenda types with an associated number of minutes
+to limit entries to in this type."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-agenda-custom-commands
+  :type '(choice (symbol :tag "No limit" nil)
+                (integer :tag "Max number of entries")
+                (repeat
+                 (cons (choice :tag "Agenda type"
+                               (const agenda)
+                               (const todo)
+                               (const tags)
+                               (const search)
+                               (const timeline))
+                       (integer :tag "Max number of entries")))))
+
 (defvar org-keys nil)
 (defvar org-match nil)
 ;;;###autoload
@@ -2515,12 +2744,12 @@ Pressing `<' twice means to restrict to the current subtree or region
        (put 'org-agenda-files 'org-restrict (list bfn))
        (cond
         ((eq restriction 'region)
-         (setq org-agenda-restrict t)
+         (setq org-agenda-restrict (current-buffer))
          (move-marker org-agenda-restrict-begin (region-beginning))
          (move-marker org-agenda-restrict-end (region-end)))
         ((eq restriction 'subtree)
          (save-excursion
-           (setq org-agenda-restrict t)
+           (setq org-agenda-restrict (current-buffer))
            (org-back-to-heading t)
            (move-marker org-agenda-restrict-begin (point))
            (move-marker org-agenda-restrict-end
@@ -2541,6 +2770,8 @@ Pressing `<' twice means to restrict to the current subtree or region
              (cond
               ((eq type 'agenda)
                (org-let lprops '(org-agenda-list current-prefix-arg)))
+              ((eq type 'agenda*)
+               (org-let lprops '(org-agenda-list current-prefix-arg nil nil t)))
               ((eq type 'alltodo)
                (org-let lprops '(org-todo-list current-prefix-arg)))
               ((eq type 'search)
@@ -2569,7 +2800,7 @@ Pressing `<' twice means to restrict to the current subtree or region
                (org-let lprops '(funcall type org-match)))
               ((fboundp type)
                (org-let lprops '(funcall type org-match)))
-              (t (error "Invalid custom agenda command type %s" type))))
+              (t (user-error "Invalid custom agenda command type %s" type))))
          (org-agenda-run-series (nth 1 entry) (cddr entry))))
        ((equal org-keys "C")
        (setq org-agenda-custom-commands org-agenda-custom-commands-orig)
@@ -2600,14 +2831,16 @@ Pressing `<' twice means to restrict to the current subtree or region
         t t))
        ((equal org-keys "L")
        (unless (derived-mode-p 'org-mode)
-         (error "This is not an Org-mode file"))
+         (user-error "This is not an Org-mode file"))
        (unless restriction
          (put 'org-agenda-files 'org-restrict (list bfn))
          (org-call-with-arg 'org-timeline arg)))
        ((equal org-keys "#") (call-interactively 'org-agenda-list-stuck-projects))
        ((equal org-keys "/") (call-interactively 'org-occur-in-agenda-files))
        ((equal org-keys "!") (customize-variable 'org-stuck-projects))
-       (t (error "Invalid agenda key"))))))
+       (t (user-error "Invalid agenda key"))))))
+
+(defvar org-agenda-multi)
 
 (defun org-agenda-append-agenda ()
   "Append another agenda view to the current one.
@@ -2615,14 +2848,16 @@ This function allows interactive building of block agendas.
 Agenda views are separated by `org-agenda-block-separator'."
   (interactive)
   (unless (derived-mode-p 'org-agenda-mode)
-    (error "Can only append from within agenda buffer"))
+    (user-error "Can only append from within agenda buffer"))
   (let ((org-agenda-multi t))
     (org-agenda)
     (widen)
     (org-agenda-finalize)
+    (setq buffer-read-only t)
     (org-agenda-fit-window-to-buffer)))
 
 (defun org-agenda-normalize-custom-commands (cmds)
+  "Normalize custom commands CMDS."
   (delq nil
        (mapcar
         (lambda (x)
@@ -2697,6 +2932,7 @@ L   Timeline for current buffer         #   List stuck projects (!=configure)
                     (cond
                      ((string-match "\\S-" desc) desc)
                      ((eq type 'agenda) "Agenda for current week or day")
+                     ((eq type 'agenda*) "Appointments for current week or day")
                      ((eq type 'alltodo) "List of all TODO entries")
                      ((eq type 'search) "Word search")
                      ((eq type 'stuck) "List of stuck projects")
@@ -2820,7 +3056,7 @@ L   Timeline for current buffer         #   List stuck projects (!=configure)
             (org-agenda-get-restriction-and-command prefix-descriptions))
 
           ((equal c ?q) (error "Abort"))
-          (t (error "Invalid key %c" c))))))))
+          (t (user-error "Invalid key %c" c))))))))
 
 (defun org-agenda-fit-window-to-buffer ()
   "Fit the window to the buffer size."
@@ -2836,6 +3072,7 @@ L   Timeline for current buffer         #   List stuck projects (!=configure)
 (defvar org-agenda-overriding-arguments nil)
 (defvar org-agenda-overriding-cmd-arguments nil)
 (defun org-agenda-run-series (name series)
+  "Run agenda NAME as a SERIES of agenda commands."
   (org-let (nth 1 series) '(org-agenda-prepare name))
   ;; We need to reset agenda markers here, because when constructing a
   ;; block agenda, the individual blocks do not do that.
@@ -2858,6 +3095,9 @@ L   Timeline for current buffer         #   List stuck projects (!=configure)
         ((eq type 'agenda)
          (org-let2 gprops lprops
            '(call-interactively 'org-agenda-list)))
+        ((eq type 'agenda*)
+         (org-let2 gprops lprops
+           '(funcall 'org-agenda-list nil nil t)))
         ((eq type 'alltodo)
          (org-let2 gprops lprops
            '(call-interactively 'org-todo-list)))
@@ -2898,9 +3138,10 @@ longer string it is used as a tags/todo match string.
 Parameters are alternating variable names and values that will be bound
 before running the agenda command."
   (org-eval-in-environment (org-make-parameter-alist parameters)
-    (if (> (length cmd-key) 2)
-       (org-tags-view nil cmd-key)
-      (org-agenda nil cmd-key)))
+    (let (org-agenda-sticky)
+      (if (> (length cmd-key) 2)
+         (org-tags-view nil cmd-key)
+       (org-agenda nil cmd-key))))
   (set-buffer org-agenda-buffer-name)
   (princ (buffer-string)))
 
@@ -3005,6 +3246,7 @@ This ensures the export commands can easily use it."
 
 ;;;###autoload
 (defun org-store-agenda-views (&rest parameters)
+  "Store agenda views."
   (interactive)
   (eval (list 'org-batch-store-agenda-views)))
 
@@ -3060,10 +3302,12 @@ This ensures the export commands can easily use it."
 (defun org-agenda-write (file &optional open nosettings agenda-bufname)
   "Write the current buffer (an agenda view) as a file.
 Depending on the extension of the file name, plain text (.txt),
-HTML (.html or .htm) or Postscript (.ps) is produced.
+HTML (.html or .htm), PDF (.pdf) or Postscript (.ps) is produced.
 If the extension is .ics, run icalendar export over all files used
 to construct the agenda and limit the export to entries listed in the
 agenda now.
+If the extension is .org, collect all subtrees corresponding to the
+agenda entries and add them in an .org file.
 With prefix argument OPEN, open the new file immediately.
 If NOSETTINGS is given, do not scope the settings of
 `org-agenda-exporter-settings' into the export commands.  This is used when
@@ -3071,13 +3315,16 @@ the settings have already been scoped and we do not wish to overrule other,
 higher priority settings.
 If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
   (interactive "FWrite agenda to file: \nP")
-  (if (not (file-writable-p file))
-      (error "Cannot write agenda to file %s" file))
+  (if (or (not (file-writable-p file))
+         (and (file-exists-p file)
+              (if (org-called-interactively-p 'any)
+                  (not (y-or-n-p (format "Overwrite existing file %s? " file))))))
+      (user-error "Cannot write agenda to file %s" file))
   (org-let (if nosettings nil org-agenda-exporter-settings)
     '(save-excursion
        (save-window-excursion
         (org-agenda-mark-filtered-text)
-        (let ((bs (copy-sequence (buffer-string))) beg)
+        (let ((bs (copy-sequence (buffer-string))) beg content)
           (org-agenda-unmark-filtered-text)
           (with-temp-buffer
             (rename-buffer org-agenda-write-buffer-name t)
@@ -3093,6 +3340,25 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
             (cond
              ((org-bound-and-true-p org-mobile-creating-agendas)
               (org-mobile-write-agenda-for-mobile file))
+             ((string-match "\\.org\\'" file)
+              (let (content p m message-log-max)
+                (goto-char (point-min))
+                (while (setq p (next-single-property-change (point) 'org-hd-marker nil))
+                  (goto-char p)
+                  (setq m (get-text-property (point) 'org-hd-marker))
+                  (when m
+                    (push (save-excursion
+                            (set-buffer (marker-buffer m))
+                            (goto-char m)
+                            (org-copy-subtree 1 nil t t)
+                            org-subtree-clip)
+                          content)))
+                (find-file file)
+                (erase-buffer)
+                (mapcar (lambda (s) (org-paste-subtree 1 s)) (reverse content))
+                (write-file file)
+                (kill-buffer (current-buffer))
+                (message "Org file written to %s" file)))
              ((string-match "\\.html?\\'" file)
               (require 'htmlize)
               (set-buffer (htmlize-buffer (current-buffer)))
@@ -3120,14 +3386,8 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
               (delete-file (concat (file-name-sans-extension file) ".ps"))
               (message "PDF written to %s" file))
              ((string-match "\\.ics\\'" file)
-              (require 'org-icalendar)
-              (let ((org-agenda-marker-table
-                     (org-create-marker-find-array
-                      (org-agenda-collect-markers)))
-                    (org-icalendar-verify-function 'org-check-agenda-marker-table)
-                    (org-combined-agenda-icalendar-file file))
-                (apply 'org-export-icalendar 'combine
-                       (org-agenda-files nil 'ifmode))))
+              (require 'ox-icalendar)
+              (org-icalendar-export-current-agenda (expand-file-name file)))
              (t
               (let ((bs (buffer-string)))
                 (find-file file)
@@ -3143,6 +3403,7 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
 
 (defvar org-agenda-tag-filter-overlays nil)
 (defvar org-agenda-cat-filter-overlays nil)
+(defvar org-agenda-re-filter-overlays nil)
 
 (defun org-agenda-mark-filtered-text ()
   "Mark all text hidden by filtering with a text property."
@@ -3154,7 +3415,8 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
          (overlay-start o) (overlay-end o)
          'org-filtered t)))
      (append org-agenda-tag-filter-overlays
-            org-agenda-cat-filter-overlays))))
+            org-agenda-cat-filter-overlays
+            org-agenda-re-filter-overlays))))
 
 (defun org-agenda-unmark-filtered-text ()
   "Remove the filtering text property."
@@ -3278,43 +3540,6 @@ removed from the entry content.  Currently only `planning' is allowed here."
                (setq txt (buffer-substring (point-min) (point)))))))))
     txt))
 
-(defun org-agenda-collect-markers ()
-  "Collect the markers pointing to entries in the agenda buffer."
-  (let (m markers)
-    (save-excursion
-      (goto-char (point-min))
-      (while (not (eobp))
-       (when (setq m (or (org-get-at-bol 'org-hd-marker)
-                         (org-get-at-bol 'org-marker)))
-         (push m markers))
-       (beginning-of-line 2)))
-    (nreverse markers)))
-
-(defun org-create-marker-find-array (marker-list)
-  "Create a alist of files names with all marker positions in that file."
-  (let (f tbl m a p)
-    (while (setq m (pop marker-list))
-      (setq p (marker-position m)
-           f (buffer-file-name (or (buffer-base-buffer
-                                    (marker-buffer m))
-                                   (marker-buffer m))))
-      (if (setq a (assoc f tbl))
-         (push (marker-position m) (cdr a))
-       (push (list f p) tbl)))
-    (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
-           tbl)))
-
-(defvar org-agenda-marker-table nil) ; dynamically scoped parameter
-(defun org-check-agenda-marker-table ()
-  "Check of the current entry is on the marker list."
-  (let ((file (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
-       a)
-    (and (setq a (assoc file org-agenda-marker-table))
-        (save-match-data
-          (save-excursion
-            (org-back-to-heading t)
-            (member (point) (cdr a)))))))
-
 (defun org-check-for-org-mode ()
   "Make sure current buffer is in org-mode.  Error if not."
   (or (derived-mode-p 'org-mode)
@@ -3329,7 +3554,8 @@ removed from the entry content.  Currently only `planning' is allowed here."
 (defvar org-agenda-name nil)
 (defvar org-agenda-tag-filter nil)
 (defvar org-agenda-category-filter nil)
-(defvar org-agenda-top-category-filter nil)
+(defvar org-agenda-regexp-filter nil)
+(defvar org-agenda-top-headline-filter nil)
 (defvar org-agenda-tag-filter-while-redo nil)
 (defvar org-agenda-tag-filter-preset nil
   "A preset of the tags filter used for secondary agenda filtering.
@@ -3351,6 +3577,15 @@ the entire agenda view.  In a block agenda, it will not work reliably to
 define a filter for one of the individual blocks.  You need to set it in
 the global options and expect it to be applied to the entire view.")
 
+(defvar org-agenda-regexp-filter-preset nil
+  "A preset of the regexp filter used for secondary agenda filtering.
+This must be a list of strings, each string must be a single category
+preceded by \"+\" or \"-\".
+This variable should not be set directly, but agenda custom commands can
+bind it in the options section.  The preset filter is a global property of
+the entire agenda view.  In a block agenda, it will not work reliably to
+define a filter for one of the individual blocks.  You need to set it in
+the global options and expect it to be applied to the entire view.")
 
 (defun org-agenda-use-sticky-p ()
   "Return non-nil if an agenda buffer named
@@ -3409,11 +3644,14 @@ generating a new one."
     (setq org-drawers-for-agenda nil)
     (unless org-agenda-persistent-filter
       (setq org-agenda-tag-filter nil
-           org-agenda-category-filter nil))
+           org-agenda-category-filter nil
+           org-agenda-regexp-filter nil))
     (put 'org-agenda-tag-filter :preset-filter
         org-agenda-tag-filter-preset)
     (put 'org-agenda-category-filter :preset-filter
         org-agenda-category-filter-preset)
+    (put 'org-agenda-regexp-filter :preset-filter
+        org-agenda-regexp-filter-preset)
     (if org-agenda-multi
        (progn
          (setq buffer-read-only nil)
@@ -3516,14 +3754,13 @@ generating a new one."
          (org-agenda-filter-apply org-agenda-tag-filter 'tag))
        (when (or org-agenda-category-filter (get 'org-agenda-category-filter :preset-filter))
          (org-agenda-filter-apply org-agenda-category-filter 'category))
+       (when (or org-agenda-regexp-filter (get 'org-agenda-regexp-filter :preset-filter))
+         (org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
        (org-add-hook 'kill-buffer-hook 'org-agenda-reset-markers 'append 'local)))))
 
 (defun org-agenda-mark-clocking-task ()
   "Mark the current clock entry in the agenda if it is present."
-  (mapc (lambda (o)
-         (if (eq (overlay-get o 'type) 'org-agenda-clocking)
-             (delete-overlay o)))
-       (overlays-in (point-min) (point-max)))
+  (org-agenda-unmark-clocking-task)
   (when (marker-buffer org-clock-hd-marker)
     (save-excursion
       (goto-char (point-min))
@@ -3538,6 +3775,13 @@ generating a new one."
            (overlay-put ov 'help-echo
                         "The clock is running in this item")))))))
 
+(defun org-agenda-unmark-clocking-task ()
+  "Unmark the current clocking task."
+  (mapc (lambda (o)
+         (if (eq (overlay-get o 'type) 'org-agenda-clocking)
+             (delete-overlay o)))
+       (overlays-in (point-min) (point-max))))
+
 (defun org-agenda-fontify-priorities ()
   "Make highest priority lines bold, and lowest italic."
   (interactive)
@@ -3545,8 +3789,7 @@ generating a new one."
                        (delete-overlay o)))
        (overlays-in (point-min) (point-max)))
   (save-excursion
-    (let ((inhibit-read-only t)
-         b e p ov h l)
+    (let (b e p ov h l)
       (goto-char (point-min))
       (while (re-search-forward "\\[#\\(.\\)\\]" nil t)
        (setq h (or (get-char-property (point) 'org-highest-priority)
@@ -3561,21 +3804,27 @@ generating a new one."
              ov (make-overlay b e))
        (overlay-put
         ov 'face
-        (cond ((org-face-from-face-or-color
-                'priority nil
-                (cdr (assoc p org-priority-faces))))
-              ((and (listp org-agenda-fontify-priorities)
-                    (org-face-from-face-or-color
-                     'priority nil
-                     (cdr (assoc p org-agenda-fontify-priorities)))))
-              ((equal p l) 'italic)
-              ((equal p h) 'bold)))
+        (cons (cond ((org-face-from-face-or-color
+                      'priority nil
+                      (cdr (assoc p org-priority-faces))))
+                    ((and (listp org-agenda-fontify-priorities)
+                          (org-face-from-face-or-color
+                           'priority nil
+                           (cdr (assoc p org-agenda-fontify-priorities)))))
+                    ((equal p l) 'italic)
+                    ((equal p h) 'bold))
+              'org-priority))
        (overlay-put ov 'org-type 'org-priority)))))
 
+(defvar org-depend-tag-blocked)
+
 (defun org-agenda-dim-blocked-tasks (&optional invisible)
+  "Dim currently blocked TODO's in the agenda display.
+When INVISIBLE is non-nil, hide currently blocked TODO instead of
+dimming them."
   (interactive "P")
-  "Dim currently blocked TODO's in the agenda display."
-  (message "Dim or hide blocked tasks...")
+  (when (org-called-interactively-p 'interactive)
+    (message "Dim or hide blocked tasks..."))
   (mapc (lambda (o) (if (eq (overlay-get o 'org-type) 'org-blocked-todo)
                        (delete-overlay o)))
        (overlays-in (point-min) (point-max)))
@@ -3605,7 +3854,8 @@ generating a new one."
                (overlay-put ov 'invisible t)
              (overlay-put ov 'face 'org-agenda-dimmed-todo-face))
            (overlay-put ov 'org-type 'org-blocked-todo))))))
-    (message "Dim or hide blocked tasks...done"))
+    (when (org-called-interactively-p 'interactive)
+      (message "Dim or hide blocked tasks...done")))
 
 (defvar org-agenda-skip-function nil
   "Function to be called at each match during agenda construction.
@@ -3640,7 +3890,7 @@ continue from there."
       (throw :skip t))))
 
 (defun org-agenda-skip-eval (form)
-  "If FORM is a function or a list, call (or eval) is and return result.
+  "If FORM is a function or a list, call (or eval) it and return the result.
 `save-excursion' and `save-match-data' are wrapped around the call, so point
 and match data are returned to the previous state no matter what these
 functions do."
@@ -3695,7 +3945,8 @@ This check for agenda markers in all agenda buffers currently active."
       (error "No marker points to an entry here"))
     (setq txt (concat "\n" (org-no-properties
                            (org-agenda-get-some-entry-text
-                            m org-agenda-entry-text-maxlines "    > "))))
+                            m org-agenda-entry-text-maxlines
+                            org-agenda-entry-text-leaders))))
     (when (string-match "\\S-" txt)
       (setq o (make-overlay (point-at-bol) (point-at-eol)))
       (overlay-put o 'evaporate t)
@@ -3735,6 +3986,7 @@ This check for agenda markers in all agenda buffers currently active."
 ;;; Agenda timeline
 
 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
+(defvar org-agenda-show-log-scoped) ;; dynamically scope in `org-timeline' or `org-agenda-list'
 
 (defun org-timeline (&optional dotodo)
   "Show a time-sorted view of the entries in the current org file.
@@ -3746,6 +3998,7 @@ dates."
   (interactive "P")
   (let* ((dopast t)
         (org-agenda-show-log-scoped org-agenda-show-log)
+        (org-agenda-show-log org-agenda-show-log-scoped)
         (entry (buffer-file-name (or (buffer-base-buffer (current-buffer))
                                      (current-buffer))))
         (date (calendar-current-date))
@@ -3762,9 +4015,11 @@ dates."
         args
         s e rtn d emptyp)
     (setq org-agenda-redo-command
-         (list 'progn
-               (list 'org-switch-to-buffer-other-window (current-buffer))
-               (list 'org-timeline (list 'quote dotodo))))
+         (list 'let
+               (list (list 'org-agenda-show-log 'org-agenda-show-log))
+               (list 'org-switch-to-buffer-other-window (current-buffer))
+               (list 'org-timeline (list 'quote dotodo))))
+    (put 'org-agenda-redo-command 'org-lprops nil)
     (if (not dopast)
        ;; Remove past dates from the list of dates.
        (setq day-numbers (delq nil (mapcar (lambda(x)
@@ -3815,12 +4070,13 @@ dates."
              (put-text-property s (1- (point)) 'org-agenda-date-header t)
              (if (equal d today)
                  (put-text-property s (1- (point)) 'org-today t))
-             (and rtn (insert (org-agenda-finalize-entries rtn) "\n"))
+             (and rtn (insert (org-agenda-finalize-entries rtn 'timeline) "\n"))
              (put-text-property s (1- (point)) 'day d)))))
-    (goto-char (point-min))
     (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
                   (point-min)))
-    (add-text-properties (point-min) (point-max) '(org-agenda-type timeline))
+    (add-text-properties
+     (point-min) (point-max)
+     `(org-agenda-type timeline org-redo-cmd ,org-agenda-redo-command))
     (org-agenda-finalize)
     (setq buffer-read-only t)))
 
@@ -3874,46 +4130,16 @@ When EMPTY is non-nil, also include days without any entries."
 
 (defvar org-agenda-start-day nil  ; dynamically scoped parameter
   "Start day for the agenda view.
-Custom commands can set this variable in the options section.")
+Custom commands can set this variable in the options section.
+This is usually a string like \"2007-11-01\", \"+2d\" or any other
+input allowed when reading a date through the Org calendar.
+See the docstring of `org-read-date' for details.")
 (defvar org-starting-day nil) ; local variable in the agenda buffer
 (defvar org-arg-loc nil) ; local variable
 
-(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
-  "List of types searched for when creating the daily/weekly agenda.
-This variable is a list of symbols that controls the types of
-items that appear in the daily/weekly agenda.  Allowed symbols in this
-list are are
-
-   :timestamp    List items containing a date stamp or date range matching
-                 the selected date.  This includes sexp entries in
-                 angular brackets.
-
-   :sexp         List entries resulting from plain diary-like sexps.
-
-   :deadline     List deadline due on that date.  When the date is today,
-                 also list any deadlines past due, or due within
-                `org-deadline-warning-days'.  `:deadline' must appear before
-                 `:scheduled' if the setting of
-                 `org-agenda-skip-scheduled-if-deadline-is-shown' is to have
-                 any effect.
-
-   :scheduled    List all items which are scheduled for the given date.
-                The diary for *today* also contains items which were
-                scheduled earlier and are not yet marked DONE.
-
-By default, all four types are turned on.
-
-Never set this variable globally using `setq', because then it
-will apply to all future agenda commands.  Instead, bind it with
-`let' to scope it dynamically into the agenda-constructing
-command.  A good way to set it is through options in
-`org-agenda-custom-commands'.  For a more flexible (though
-somewhat less efficient) way of determining what is included in
-the daily/weekly agenda, see `org-agenda-skip-function'.")
-
 (defvar org-agenda-buffer-tmp-name nil)
 ;;;###autoload
-(defun org-agenda-list (&optional arg start-day span)
+(defun org-agenda-list (&optional arg start-day span with-hour)
   "Produce a daily/weekly view from all files in variable `org-agenda-files'.
 The view will be for the current day or week, but from the overview buffer
 you will be able to go to other days/weeks.
@@ -3923,7 +4149,10 @@ span ARG days.  Lisp programs should instead specify SPAN to change
 the number of days.  SPAN defaults to `org-agenda-span'.
 
 START-DAY defaults to TODAY, or to the most recent match for the weekday
-given in `org-agenda-start-on-weekday'."
+given in `org-agenda-start-on-weekday'.
+
+When WITH-HOUR is non-nil, only include scheduled and deadline
+items if they have an hour specification like [h]h:mm."
   (interactive "P")
   (if org-agenda-overriding-arguments
       (setq arg (car org-agenda-overriding-arguments)
@@ -3954,7 +4183,7 @@ given in `org-agenda-start-on-weekday'."
           (sd (or start-day today))
           (ndays (org-agenda-span-to-ndays span sd))
           (org-agenda-start-on-weekday
-           (if (eq ndays 7)
+           (if (or (eq ndays 7) (eq ndays 14))
                org-agenda-start-on-weekday))
           (thefiles (org-agenda-files nil 'ifmode))
           (files thefiles)
@@ -3973,7 +4202,7 @@ given in `org-agenda-start-on-weekday'."
           s e rtn rtnall file date d start-pos end-pos todayp
           clocktable-start clocktable-end filter)
       (setq org-agenda-redo-command
-           (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span)))
+           (list 'org-agenda-list (list 'quote arg) start-day (list 'quote span) with-hour))
       (dotimes (n (1- ndays))
        (push (1+ (car day-numbers)) day-numbers))
       (setq day-numbers (nreverse day-numbers))
@@ -4016,9 +4245,26 @@ given in `org-agenda-start-on-weekday'."
          (catch 'nextfile
            (org-check-agenda-file file)
            (let ((org-agenda-entry-types org-agenda-entry-types))
-             (unless org-agenda-include-deadlines
+             ;; Starred types override non-starred equivalents
+             (when (member :deadline* org-agenda-entry-types)
                (setq org-agenda-entry-types
                      (delq :deadline org-agenda-entry-types)))
+             (when (member :scheduled* org-agenda-entry-types)
+               (setq org-agenda-entry-types
+                     (delq :scheduled org-agenda-entry-types)))
+             ;; Honor with-hour
+             (when with-hour
+               (when (member :deadline org-agenda-entry-types)
+                 (setq org-agenda-entry-types
+                       (delq :deadline org-agenda-entry-types))
+                 (push :deadline* org-agenda-entry-types))
+               (when (member :scheduled org-agenda-entry-types)
+                 (setq org-agenda-entry-types
+                       (delq :scheduled org-agenda-entry-types))
+                 (push :scheduled* org-agenda-entry-types)))
+             (unless org-agenda-include-deadlines
+               (setq org-agenda-entry-types
+                     (delq :deadline* (delq :deadline org-agenda-entry-types))))
              (cond
               ((memq org-agenda-show-log-scoped '(only clockcheck))
                (setq rtn (org-agenda-get-day-entries
@@ -4056,7 +4302,7 @@ given in `org-agenda-start-on-weekday'."
              (setq rtnall
                    (org-agenda-add-time-grid-maybe rtnall ndays todayp))
              (if rtnall (insert ;; all entries
-                         (org-agenda-finalize-entries rtnall)
+                         (org-agenda-finalize-entries rtnall 'agenda)
                          "\n"))
              (put-text-property s (1- (point)) 'day d)
              (put-text-property s (1- (point)) 'org-day-cnt day-cnt))))
@@ -4106,13 +4352,16 @@ given in `org-agenda-start-on-weekday'."
   (cond ((symbolp n) n)
        ((= n 1) 'day)
        ((= n 7) 'week)
+       ((= n 14) 'fortnight)
        (t n)))
 
 (defun org-agenda-span-to-ndays (span &optional start-day)
-  "Return ndays from SPAN, possibly starting at START-DAY."
+  "Return ndays from SPAN, possibly starting at START-DAY.
+START-DAY is an absolute time value."
   (cond ((numberp span) span)
        ((eq span 'day) 1)
        ((eq span 'week) 7)
+       ((eq span 'fortnight) 14)
        ((eq span 'month)
         (let ((date (calendar-gregorian-from-absolute start-day)))
           (calendar-last-day-of-month (car date) (caddr date))))
@@ -4206,7 +4455,7 @@ in `org-agenda-text-search-extra-files'."
         (full-words org-agenda-search-view-force-full-words)
         (org-agenda-text-search-extra-files org-agenda-text-search-extra-files)
         regexp rtn rtnall files file pos inherited-tags
-        marker category category-pos tags c neg re boolean
+        marker category category-pos level tags c neg re boolean
         ee txt beg end words regexps+ regexps- hdl-only buffer beg1 str)
     (unless (and (not edit-at)
                 (stringp string)
@@ -4323,7 +4572,7 @@ in `org-agenda-text-search-extra-files'."
              (let ((case-fold-search t))
                (save-excursion
                  (save-restriction
-                   (if org-agenda-restrict
+                   (if (eq buffer org-agenda-restrict)
                        (narrow-to-region org-agenda-restrict-begin
                                          org-agenda-restrict-end)
                      (widen))
@@ -4334,10 +4583,23 @@ in `org-agenda-text-search-extra-files'."
                    (goto-char (max (point-min) (1- (point))))
                    (while (re-search-forward regexp nil t)
                      (org-back-to-heading t)
+                     (while (and org-agenda-search-view-max-outline-level
+                                 (> (org-reduced-level (org-outline-level))
+                                    org-agenda-search-view-max-outline-level)
+                                 (forward-line -1)
+                                 (outline-back-to-heading t)))
                      (skip-chars-forward "* ")
                      (setq beg (point-at-bol)
                            beg1 (point)
-                           end (progn (outline-next-heading) (point)))
+                           end (progn
+                                 (outline-next-heading)
+                                 (while (and org-agenda-search-view-max-outline-level
+                                             (> (org-reduced-level (org-outline-level))
+                                                org-agenda-search-view-max-outline-level)
+                                             (forward-line 1)
+                                             (outline-next-heading)))
+                                 (point)))
+
                      (catch :skip
                        (goto-char beg)
                        (org-agenda-skip)
@@ -4358,6 +4620,7 @@ in `org-agenda-text-search-extra-files'."
                        (goto-char beg)
                        (setq marker (org-agenda-new-marker (point))
                              category (org-get-category)
+                             level (make-string (org-reduced-level (org-outline-level)) ? )
                              category-pos (get-text-property (point) 'org-category-position)
                              inherited-tags
                              (or (eq org-agenda-show-inherited-tags 'always)
@@ -4371,10 +4634,11 @@ in `org-agenda-text-search-extra-files'."
                                   ""
                                   (buffer-substring-no-properties
                                    beg1 (point-at-eol))
-                                  category tags t))
+                                  level category tags t))
                        (org-add-props txt props
                          'org-marker marker 'org-hd-marker marker
                          'org-todo-regexp org-todo-regexp
+                         'level level
                          'org-complex-heading-regexp org-complex-heading-regexp
                          'priority 1000 'org-category category
                          'org-category-position category-pos
@@ -4399,7 +4663,7 @@ in `org-agenda-text-search-extra-files'."
                               (list 'face 'org-agenda-structure))))
       (org-agenda-mark-header-line (point-min))
       (when rtnall
-       (insert (org-agenda-finalize-entries rtnall) "\n"))
+       (insert (org-agenda-finalize-entries rtnall 'search) "\n"))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
       (add-text-properties (point-min) (point-max)
@@ -4412,6 +4676,18 @@ in `org-agenda-text-search-extra-files'."
 
 ;;; Agenda TODO list
 
+(defun org-agenda-propertize-selected-todo-keywords (keywords)
+  "Use `org-todo-keyword-faces' for the selected todo KEYWORDS."
+  (concat
+   (if (or (equal keywords "ALL") (not keywords))
+       (propertize "ALL" 'face 'warning)
+     (mapconcat
+      (lambda (kw)
+        (propertize kw 'face (org-get-todo-face kw)))
+      (org-split-string keywords "|")
+      "|"))
+   "\n"))
+
 (defvar org-select-this-todo-keyword nil)
 (defvar org-last-arg nil)
 
@@ -4472,9 +4748,8 @@ for a keyword.  A numeric prefix directly selects the Nth keyword in
                                   (concat "ToDo: "
                                           (or org-select-this-todo-keyword "ALL"))))
        (org-agenda-mark-header-line (point-min))
-       (setq pos (point))
-       (insert (or org-select-this-todo-keyword "ALL") "\n")
-       (add-text-properties pos (1- (point)) (list 'face 'org-warning))
+       (insert (org-agenda-propertize-selected-todo-keywords
+                org-select-this-todo-keyword))
        (setq pos (point))
        (unless org-agenda-multi
          (insert "Available with `N r': (0)[ALL]")
@@ -4489,7 +4764,7 @@ for a keyword.  A numeric prefix directly selects the Nth keyword in
        (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))
       (org-agenda-mark-header-line (point-min))
       (when rtnall
-       (insert (org-agenda-finalize-entries rtnall) "\n"))
+       (insert (org-agenda-finalize-entries rtnall 'todo) "\n"))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
       (add-text-properties (point-min) (point-max)
@@ -4517,8 +4792,6 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
         buffer)
     (when (and (stringp match) (not (string-match "\\S-" match)))
       (setq match nil))
-    (setq matcher (org-make-tags-matcher match)
-         match (car matcher) matcher (cdr matcher))
     (catch 'exit
       (if org-agenda-sticky
          (setq org-agenda-buffer-name
@@ -4526,7 +4799,11 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
                    (format "*Org Agenda(%s:%s)*"
                            (or org-keys (or (and todo-only "M") "m")) match)
                  (format "*Org Agenda(%s)*" (or (and todo-only "M") "m")))))
+      ;; Prepare agendas (and `org-tag-alist-for-agenda') before
+      ;; expanding tags within `org-make-tags-matcher'
       (org-agenda-prepare (concat "TAGS " match))
+      (setq matcher (org-make-tags-matcher match)
+           match (car matcher) matcher (cdr matcher))
       (org-compile-prefix-format 'tags)
       (org-set-sorting-strategy 'tags)
       (setq org-agenda-query-string match)
@@ -4551,7 +4828,7 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
                (error "Agenda file %s is not in `org-mode'" file))
              (save-excursion
                (save-restriction
-                 (if org-agenda-restrict
+                 (if (eq buffer org-agenda-restrict)
                      (narrow-to-region org-agenda-restrict-begin
                                        org-agenda-restrict-end)
                    (widen))
@@ -4574,7 +4851,7 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
        (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))
       (org-agenda-mark-header-line (point-min))
       (when rtnall
-       (insert (org-agenda-finalize-entries rtnall) "\n"))
+       (insert (org-agenda-finalize-entries rtnall 'tags) "\n"))
       (goto-char (point-min))
       (or org-agenda-multi (org-agenda-fit-window-to-buffer))
       (add-text-properties (point-min) (point-max)
@@ -4863,7 +5140,7 @@ of what a project is and how to check if it stuck, customize the variable
       (setq entries
            (mapcar
             (lambda (x)
-              (setq x (org-agenda-format-item "" x "Diary" nil 'time))
+              (setq x (org-agenda-format-item "" x nil "Diary" nil 'time))
               ;; Extend the text properties to the beginning of the line
               (org-add-props x (text-properties-at (1- (length x)) x)
                 'type "diary" 'date date 'face 'org-agenda-diary))
@@ -4953,8 +5230,8 @@ all files listed in `org-agenda-files' will be checked automatically:
 
    &%%(org-diary)
 
-If you don't give any arguments (as in the example above), the default
-arguments (:deadline :scheduled :timestamp :sexp) are used.
+If you don't give any arguments (as in the example above), the default value
+of `org-agenda-entry-types' is used: (:deadline :scheduled :timestamp :sexp).
 So the example above may also be written as
 
    &%%(org-diary :deadline :timestamp :sexp :scheduled)
@@ -4970,7 +5247,7 @@ function from a program - use `org-agenda-get-day-entries' instead."
     (org-agenda-reset-markers))
   (org-compile-prefix-format 'agenda)
   (org-set-sorting-strategy 'agenda)
-  (setq args (or args '(:deadline :scheduled :timestamp :sexp)))
+  (setq args (or args org-agenda-entry-types))
   (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
                    (list entry)
                  (org-agenda-files t)))
@@ -4988,8 +5265,11 @@ function from a program - use `org-agenda-get-day-entries' instead."
     (while (setq file (pop files))
       (setq rtn (apply 'org-agenda-get-day-entries file date args))
       (setq results (append results rtn)))
-    (if results
-       (concat (org-agenda-finalize-entries results) "\n"))))
+    (when results
+      (setq results
+           (mapcar (lambda (i) (replace-regexp-in-string
+                                org-bracket-link-regexp "\\3" i)) results))
+      (concat (org-agenda-finalize-entries results) "\n"))))
 
 ;;; Agenda entry finders
 
@@ -4999,7 +5279,7 @@ FILE is the path to a file to be checked for entries.  DATE is date like
 the one returned by `calendar-current-date'.  ARGS are symbols indicating
 which kind of entries should be extracted.  For details about these, see
 the documentation of `org-diary'."
-  (setq args (or args '(:deadline :scheduled :timestamp :sexp)))
+  (setq args (or args org-agenda-entry-types))
   (let* ((org-startup-folded nil)
         (org-startup-align-all-tables nil)
         (buffer (if (file-exists-p file)
@@ -5016,7 +5296,7 @@ the documentation of `org-diary'."
        (let ((case-fold-search nil))
          (save-excursion
            (save-restriction
-             (if org-agenda-restrict
+             (if (eq buffer org-agenda-restrict)
                  (narrow-to-region org-agenda-restrict-begin
                                    org-agenda-restrict-end)
                (widen))
@@ -5039,16 +5319,29 @@ the documentation of `org-diary'."
                 ((eq arg :scheduled)
                  (setq rtn (org-agenda-get-scheduled deadline-results))
                  (setq results (append results rtn)))
+                ((eq arg :scheduled*)
+                 (setq rtn (org-agenda-get-scheduled deadline-results t))
+                 (setq results (append results rtn)))
                 ((eq arg :closed)
                  (setq rtn (org-agenda-get-progress))
                  (setq results (append results rtn)))
                 ((eq arg :deadline)
                  (setq rtn (org-agenda-get-deadlines))
                  (setq deadline-results (copy-sequence rtn))
+                 (setq results (append results rtn)))
+                ((eq arg :deadline*)
+                 (setq rtn (org-agenda-get-deadlines t))
+                 (setq deadline-results (copy-sequence rtn))
                  (setq results (append results rtn))))))))
        results))))
 
+(defsubst org-em (x y list)
+  "Is X or Y a member of LIST?"
+  (or (memq x list) (memq y list)))
+
 (defvar org-heading-keyword-regexp-format) ; defined in org.el
+(defvar org-agenda-sorting-strategy-selected nil)
+
 (defun org-agenda-get-todos ()
   "Return the TODO information for agenda display."
   (let* ((props (list 'face nil
@@ -5073,8 +5366,8 @@ the documentation of `org-diary'."
                                               "|")
                                              "\\|") "\\)"))
                          (t org-not-done-regexp))))
-        marker priority category category-pos tags todo-state
-        ee txt beg end inherited-tags)
+        marker priority category category-pos level tags todo-state ts-date ts-date-type
+        ee txt beg end inherited-tags todo-state-end-pos)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -5082,6 +5375,10 @@ the documentation of `org-diary'."
          (beginning-of-line)
          (org-agenda-skip)
          (setq beg (point) end (save-excursion (outline-next-heading) (point)))
+         (unless (and (setq todo-state (org-get-todo-state))
+                      (setq todo-state-end-pos (match-end 2)))
+           (goto-char end)
+           (throw :skip nil))
          (when (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item end)
            (goto-char (1+ beg))
            (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
@@ -5089,6 +5386,33 @@ the documentation of `org-diary'."
        (goto-char (match-beginning 2))
        (setq marker (org-agenda-new-marker (match-beginning 0))
              category (org-get-category)
+             ts-date (let (ts)
+                       (save-match-data
+                         (cond ((org-em 'scheduled-up 'scheduled-down
+                                        org-agenda-sorting-strategy-selected)
+                                (setq ts (org-entry-get (point) "SCHEDULED")
+                                      ts-date-type " scheduled"))
+                               ((org-em 'deadline-up 'deadline-down
+                                        org-agenda-sorting-strategy-selected)
+                                (setq ts (org-entry-get (point) "DEADLINE")
+                                      ts-date-type " deadline"))
+                               ((org-em 'ts-up 'ts-down
+                                        org-agenda-sorting-strategy-selected)
+                                (setq ts (org-entry-get (point) "TIMESTAMP")
+                                      ts-date-type " timestamp"))
+                               ((org-em 'tsia-up 'tsia-down
+                                        org-agenda-sorting-strategy-selected)
+                                (setq ts (org-entry-get (point) "TIMESTAMP_IA")
+                                      ts-date-type " timestamp_ia"))
+                               ((org-em 'timestamp-up 'timestamp-down
+                                        org-agenda-sorting-strategy-selected)
+                                (setq ts (or (org-entry-get (point) "SCHEDULED")
+                                             (org-entry-get (point) "DEADLINE")
+                                             (org-entry-get (point) "TIMESTAMP")
+                                             (org-entry-get (point) "TIMESTAMP_IA"))
+                                      ts-date-type ""))
+                               (t (setq ts-date-type "")))
+                         (when ts (ignore-errors (org-time-string-to-absolute ts)))))
              category-pos (get-text-property (point) 'org-category-position)
              txt (org-trim
                   (buffer-substring (match-beginning 2) (match-end 0)))
@@ -5100,17 +5424,19 @@ the documentation of `org-diary'."
                       (or (eq org-agenda-use-tag-inheritance t)
                           (memq 'todo org-agenda-use-tag-inheritance))))
              tags (org-get-tags-at nil (not inherited-tags))
-             txt (org-agenda-format-item "" txt category tags t)
-             priority (1+ (org-get-priority txt))
-             todo-state (org-get-todo-state))
+             level (make-string (org-reduced-level (org-outline-level)) ? )
+             txt (org-agenda-format-item "" txt level category tags t)
+             priority (1+ (org-get-priority txt)))
        (org-add-props txt props
          'org-marker marker 'org-hd-marker marker
          'priority priority 'org-category category
+         'level level
+         'ts-date ts-date
          'org-category-position category-pos
-         'type "todo" 'todo-state todo-state)
+         'type (concat "todo" ts-date-type) 'todo-state todo-state)
        (push txt ee)
        (if org-agenda-todo-list-sublevels
-           (goto-char (match-end 2))
+           (goto-char todo-state-end-pos)
          (org-end-of-subtree 'invisible))))
     (nreverse ee)))
 
@@ -5119,7 +5445,8 @@ the documentation of `org-diary'."
 This function is invoked if `org-agenda-todo-ignore-deadlines',
 `org-agenda-todo-ignore-scheduled' or
 `org-agenda-todo-ignore-timestamp' is set to an integer."
-  (let ((days (org-days-to-time time)))
+  (let ((days (org-time-stamp-to-now
+              time org-agenda-todo-ignore-time-comparison-use-seconds)))
     (if (>= n 0)
        (>= days n)
       (<= days n))))
@@ -5139,9 +5466,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
               (re-search-forward org-scheduled-time-regexp end t)
               (cond
                ((eq org-agenda-todo-ignore-scheduled 'future)
-                (> (org-days-to-time (match-string 1)) 0))
+                (> (org-time-stamp-to-now
+                    (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                ((eq org-agenda-todo-ignore-scheduled 'past)
-                (<= (org-days-to-time (match-string 1)) 0))
+                (<= (org-time-stamp-to-now
+                     (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                ((numberp org-agenda-todo-ignore-scheduled)
                 (org-agenda-todo-custom-ignore-p
                  (match-string 1) org-agenda-todo-ignore-scheduled))
@@ -5153,9 +5482,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                ((eq org-agenda-todo-ignore-deadlines 'far)
                 (not (org-deadline-close (match-string 1))))
                ((eq org-agenda-todo-ignore-deadlines 'future)
-                (> (org-days-to-time (match-string 1)) 0))
+                (> (org-time-stamp-to-now
+                    (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                ((eq org-agenda-todo-ignore-deadlines 'past)
-                (<= (org-days-to-time (match-string 1)) 0))
+                (<= (org-time-stamp-to-now
+                     (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                ((numberp org-agenda-todo-ignore-deadlines)
                 (org-agenda-todo-custom-ignore-p
                  (match-string 1) org-agenda-todo-ignore-deadlines))
@@ -5178,9 +5509,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                   (when (re-search-forward org-ts-regexp nil t)
                     (cond
                      ((eq org-agenda-todo-ignore-timestamp 'future)
-                      (> (org-days-to-time (match-string 1)) 0))
+                      (> (org-time-stamp-to-now
+                          (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                      ((eq org-agenda-todo-ignore-timestamp 'past)
-                      (<= (org-days-to-time (match-string 1)) 0))
+                      (<= (org-time-stamp-to-now
+                           (match-string 1) org-agenda-todo-ignore-time-comparison-use-seconds) 0))
                      ((numberp org-agenda-todo-ignore-timestamp)
                       (org-agenda-todo-custom-ignore-p
                        (match-string 1) org-agenda-todo-ignore-timestamp))
@@ -5217,9 +5550,9 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
           "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
           "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
         marker hdmarker deadlinep scheduledp clockp closedp inactivep
-        donep tmp priority category category-pos ee txt timestr tags
+        donep tmp priority category category-pos level ee txt timestr tags
         b0 b3 e3 head todo-state end-of-match show-all warntime habitp
-        inherited-tags)
+        inherited-tags ts-date)
     (goto-char (point-min))
     (while (setq end-of-match (re-search-forward regexp nil t))
       (setq b0 (match-beginning 0)
@@ -5278,18 +5611,21 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                      (and (eq org-agenda-show-inherited-tags t)
                           (or (eq org-agenda-use-tag-inheritance t)
                               (memq 'agenda org-agenda-use-tag-inheritance))))
-                 tags (org-get-tags-at nil (not inherited-tags)))
+                 tags (org-get-tags-at nil (not inherited-tags))
+                 level (make-string (org-reduced-level (org-outline-level)) ? ))
            (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
            (setq head (or (match-string 1) ""))
            (setq txt (org-agenda-format-item
                       (if inactivep org-agenda-inactive-leader nil)
-                      head category tags timestr
+                      head level category tags timestr
                       remove-re habitp)))
          (setq priority (org-get-priority txt))
-         (org-add-props txt props
-           'org-marker marker 'org-hd-marker hdmarker)
-         (org-add-props txt nil 'priority priority
+         (org-add-props txt props 'priority priority
+                        'org-marker marker 'org-hd-marker hdmarker
                         'org-category category 'date date
+                        'level level
+                        'ts-date
+                        (ignore-errors (org-time-string-to-absolute timestr))
                         'org-category-position category-pos
                         'todo-state todo-state
                         'warntime warntime
@@ -5309,7 +5645,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
         (regexp "^&?%%(")
-        marker category extra category-pos ee txt tags entry
+        marker category extra category-pos level ee txt tags entry
         result beg b sexp sexp-entry todo-state warntime inherited-tags)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
@@ -5326,6 +5662,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
        (setq result (org-diary-sexp-entry sexp sexp-entry date))
        (when result
          (setq marker (org-agenda-new-marker beg)
+               level (make-string (org-reduced-level (org-outline-level)) ? )
                category (org-get-category beg)
                category-pos (get-text-property beg 'org-category-position)
                inherited-tags
@@ -5350,13 +5687,11 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
            (if (string-match "\\S-" r)
                (setq txt r)
              (setq txt "SEXP entry returned empty string"))
-
-           (setq txt (org-agenda-format-item
-                      extra txt category tags 'time))
-           (org-add-props txt props 'org-marker marker)
-           (org-add-props txt nil
+           (setq txt (org-agenda-format-item extra txt level category tags 'time))
+           (org-add-props txt props 'org-marker marker
              'org-category category 'date date 'todo-state todo-state
              'org-category-position category-pos 'tags tags
+             'level level
              'type "sexp" 'warntime warntime)
            (push txt ee)))))
     (nreverse ee)))
@@ -5394,10 +5729,12 @@ DAYNAME is a number between 0 (Sunday) and 6 (Saturday).
 SKIP-WEEKS is any number of ISO weeks in the block period for which the
 item should be skipped.  If any of the SKIP-WEEKS arguments is the symbol
 `holidays', then any date that is known by the Emacs calendar to be a
-holiday will also be skipped."
+holiday will also be skipped.  If SKIP-WEEKS arguments are holiday strings,
+then those holidays will be skipped."
   (let* ((date1 (calendar-absolute-from-gregorian (list m1 d1 y1)))
         (date2 (calendar-absolute-from-gregorian (list m2 d2 y2)))
-        (d (calendar-absolute-from-gregorian date)))
+        (d (calendar-absolute-from-gregorian date))
+        (h (when skip-weeks (calendar-check-holidays date))))
     (and
      (<= date1 d)
      (<= d date2)
@@ -5406,8 +5743,8 @@ holiday will also be skipped."
         (progn
           (require 'cal-iso)
           (not (member (car (calendar-iso-from-absolute d)) skip-weeks))))
-     (not (and (memq 'holidays skip-weeks)
-              (calendar-check-holidays date)))
+     (not (or (and h (memq 'holidays skip-weeks))
+             (delq nil (mapcar (lambda(g) (member g skip-weeks)) h))))
      entry)))
 
 (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks)
@@ -5430,7 +5767,6 @@ please use `org-class' instead."
      dayname skip-weeks)))
 (make-obsolete 'org-diary-class 'org-class "")
 
-(defvar org-agenda-show-log-scoped) ;; dynamically scope in `org-timeline' or `org-agenda-list'
 (defalias 'org-get-closed 'org-agenda-get-progress)
 (defun org-agenda-get-progress ()
   "Return the logged TODO entries for agenda display."
@@ -5465,7 +5801,7 @@ please use `org-class' instead."
                            (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
                    1 11))))
         (org-agenda-search-headline-for-time nil)
-        marker hdmarker priority category category-pos tags closedp
+        marker hdmarker priority category category-pos level tags closedp
         statep clockp state ee txt extra timestr rest clocked inherited-tags)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
@@ -5511,7 +5847,8 @@ please use `org-class' instead."
                      (and (eq org-agenda-show-inherited-tags t)
                           (or (eq org-agenda-use-tag-inheritance t)
                               (memq 'todo org-agenda-use-tag-inheritance))))
-                 tags (org-get-tags-at nil (not inherited-tags)))
+                 tags (org-get-tags-at nil (not inherited-tags))
+                 level (make-string (org-reduced-level (org-outline-level)) ? ))
            (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
            (setq txt (match-string 1))
            (when extra
@@ -5524,12 +5861,13 @@ please use `org-class' instead."
                        (closedp "Closed:    ")
                        (statep (concat "State:     (" state ")"))
                        (t (concat "Clocked:   (" clocked  ")")))
-                      txt category tags timestr)))
+                      txt level category tags timestr)))
          (setq priority 100000)
          (org-add-props txt props
            'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done
            'priority priority 'org-category category
            'org-category-position category-pos
+           'level level
            'type "closed" 'date date
            'undone-face 'org-warning 'done-face 'org-agenda-done)
          (push txt ee))
@@ -5540,7 +5878,8 @@ please use `org-class' instead."
   "Add overlays, showing issues with clocking.
 See also the user option `org-agenda-clock-consistency-checks'."
   (interactive)
-  (let* ((pl org-agenda-clock-consistency-checks)
+  (let* ((org-time-clocksum-use-effort-durations nil)
+        (pl org-agenda-clock-consistency-checks)
         (re (concat "^[ \t]*"
                     org-clock-string
                     "[ \t]+"
@@ -5589,13 +5928,13 @@ See also the user option `org-agenda-clock-consistency-checks'."
         ((> dt (* 60 maxtime))
          ;; a very long clocking chunk
          (setq issue (format "Clocking interval is very long: %s"
-                             (org-minutes-to-hh:mm-string
+                             (org-minutes-to-clocksum-string
                               (floor (/ (float dt) 60.))))
                face (or (plist-get pl :long-face) face)))
         ((< dt (* 60 mintime))
          ;; a very short clocking chunk
          (setq issue (format "Clocking interval is very short: %s"
-                             (org-minutes-to-hh:mm-string
+                             (org-minutes-to-clocksum-string
                               (floor (/ (float dt) 60.))))
                face (or (plist-get pl :short-face) face)))
         ((and (> tlend 0) (< ts tlend))
@@ -5655,8 +5994,10 @@ See also the user option `org-agenda-clock-consistency-checks'."
       ;; Nope, this gap is not OK
       nil)))
 
-(defun org-agenda-get-deadlines ()
-  "Return the deadline information for agenda display."
+(defun org-agenda-get-deadlines (&optional with-hour)
+  "Return the deadline information for agenda display.
+When WITH-HOUR is non-nil, only return deadlines with an hour
+specification like [h]h:mm."
   (let* ((props (list 'mouse-face 'highlight
                      'org-not-done-regexp org-not-done-regexp
                      'org-todo-regexp org-todo-regexp
@@ -5664,26 +6005,21 @@ See also the user option `org-agenda-clock-consistency-checks'."
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
-        (regexp org-deadline-time-regexp)
+        (regexp (if with-hour
+                    org-deadline-time-hour-regexp
+                  org-deadline-time-regexp))
         (todayp (org-agenda-todayp date)) ; DATE bound by calendar
-        (d1 (calendar-absolute-from-gregorian date))  ; DATE bound by calendar
-        d2 diff dfrac wdays pos pos1 category category-pos
+        (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
+        (dl0 (car org-agenda-deadline-leaders))
+        (dl1 (nth 1 org-agenda-deadline-leaders))
+        (dl2 (or (nth 2 org-agenda-deadline-leaders) dl1))
+        d2 diff dfrac wdays pos pos1 category category-pos level
         tags suppress-prewarning ee txt head face s todo-state
-        show-all upcomingp donep timestr warntime inherited-tags)
+        show-all upcomingp donep timestr warntime inherited-tags ts-date)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
-      (setq suppress-prewarning nil)
       (catch :skip
        (org-agenda-skip)
-       (when (and org-agenda-skip-deadline-prewarning-if-scheduled
-                  (save-match-data
-                    (string-match org-scheduled-time-regexp
-                                  (buffer-substring (point-at-bol)
-                                                    (point-at-eol)))))
-         (setq suppress-prewarning
-               (if (integerp org-agenda-skip-deadline-prewarning-if-scheduled)
-                   org-agenda-skip-deadline-prewarning-if-scheduled
-                 0)))
        (setq s (match-string 1)
              txt nil
              pos (1- (match-beginning 1))
@@ -5692,10 +6028,32 @@ See also the user option `org-agenda-clock-consistency-checks'."
                           (member todo-state
                                   org-agenda-repeating-timestamp-show-all))
              d2 (org-time-string-to-absolute
-                 (match-string 1) d1 'past show-all
-                 (current-buffer) pos)
-             diff (- d2 d1)
-             wdays (if suppress-prewarning
+                 s d1 'past show-all (current-buffer) pos)
+             diff (- d2 d1))
+       (setq suppress-prewarning
+             (let ((ds (and org-agenda-skip-deadline-prewarning-if-scheduled
+                            (let ((item (buffer-substring (point-at-bol)
+                                                          (point-at-eol))))
+                              (save-match-data
+                                (and (string-match
+                                      org-scheduled-time-regexp item)
+                                     (match-string 1 item)))))))
+               (cond
+                ((not ds) nil)
+                ;; The current item has a scheduled date (in ds), so
+                ;; evaluate its prewarning lead time.
+                ((integerp org-agenda-skip-deadline-prewarning-if-scheduled)
+                 ;; Use global prewarning-restart lead time.
+                 org-agenda-skip-deadline-prewarning-if-scheduled)
+                ((eq org-agenda-skip-deadline-prewarning-if-scheduled
+                     'pre-scheduled)
+                 ;; Set prewarning to no earlier than scheduled.
+                 (min (- d2 (org-time-string-to-absolute
+                             ds d1 'past show-all (current-buffer) pos))
+                      org-deadline-warning-days))
+                ;; Set prewarning to deadline.
+                (t 0))))
+       (setq wdays (if suppress-prewarning
                        (let ((org-deadline-warning-days suppress-prewarning))
                          (org-get-wdays s))
                      (org-get-wdays s))
@@ -5721,6 +6079,7 @@ See also the user option `org-agenda-clock-consistency-checks'."
                    (throw :skip nil)
                  (goto-char (match-end 0))
                  (setq pos1 (match-beginning 0))
+                 (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
                  (setq inherited-tags
                        (or (eq org-agenda-show-inherited-tags 'always)
                            (and (listp org-agenda-show-inherited-tags)
@@ -5738,22 +6097,25 @@ See also the user option `org-agenda-clock-consistency-checks'."
                            (concat (substring s (match-beginning 1)) " "))
                    (setq timestr 'time))
                  (setq txt (org-agenda-format-item
-                            (if (= diff 0)
-                                (car org-agenda-deadline-leaders)
-                              (if (functionp
-                                   (nth 1 org-agenda-deadline-leaders))
-                                  (funcall
-                                   (nth 1 org-agenda-deadline-leaders)
-                                   diff date)
-                                (format (nth 1 org-agenda-deadline-leaders)
-                                        diff)))
-                            head category tags
+                            (cond ((= diff 0) dl0)
+                                  ((> diff 0)
+                                   (if (functionp dl1)
+                                       (funcall dl1 diff date)
+                                     (format dl1 diff)))
+                                  (t
+                                   (if (functionp dl2)
+                                       (funcall dl2 diff date)
+                                     (format dl2 (if (string= dl2 dl1)
+                                                     diff (abs diff))))))
+                            head level category tags
                             (if (not (= diff 0)) nil timestr)))))
              (when txt
                (setq face (org-agenda-deadline-face dfrac))
                (org-add-props txt props
                  'org-marker (org-agenda-new-marker pos)
                  'warntime warntime
+                 'level level
+                 'ts-date d2
                  'org-hd-marker (org-agenda-new-marker pos1)
                  'priority (+ (- diff)
                               (org-get-priority txt))
@@ -5775,8 +6137,10 @@ FRACTION is what fraction of the head-warning time has passed."
       (while (setq f (pop faces))
        (if (>= fraction (car f)) (throw 'exit (cdr f)))))))
 
-(defun org-agenda-get-scheduled (&optional deadline-results)
-  "Return the scheduled information for agenda display."
+(defun org-agenda-get-scheduled (&optional deadline-results with-hour)
+  "Return the scheduled information for agenda display.
+When WITH-HOUR is non-nil, only return scheduled items with
+an hour specification like [h]h:mm."
   (let* ((props (list 'org-not-done-regexp org-not-done-regexp
                      'org-todo-regexp org-todo-regexp
                      'org-complex-heading-regexp org-complex-heading-regexp
@@ -5785,7 +6149,9 @@ FRACTION is what fraction of the head-warning time has passed."
                      'help-echo
                      (format "mouse-2 or RET jump to org file %s"
                              (abbreviate-file-name buffer-file-name))))
-        (regexp org-scheduled-time-regexp)
+        (regexp (if with-hour
+                    org-scheduled-time-hour-regexp
+                  org-scheduled-time-regexp))
         (todayp (org-agenda-todayp date)) ; DATE bound by calendar
         (d1 (calendar-absolute-from-gregorian date))  ; DATE bound by calendar
         mm
@@ -5794,9 +6160,10 @@ FRACTION is what fraction of the head-warning time has passed."
                                             0 'org-hd-marker a))
                                   (cons (marker-position mm) a)))
                  deadline-results))
-        d2 diff pos pos1 category category-pos tags donep
+        d2 diff pos pos1 category category-pos level tags donep
         ee txt head pastschedp todo-state face timestr s habitp show-all
-        did-habit-check-p warntime inherited-tags)
+        did-habit-check-p warntime inherited-tags ts-date suppress-delay
+        ddays)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -5809,18 +6176,50 @@ FRACTION is what fraction of the head-warning time has passed."
                           (member todo-state
                                   org-agenda-repeating-timestamp-show-all))
              d2 (org-time-string-to-absolute
-                 (match-string 1) d1 'past show-all
-                 (current-buffer) pos)
+                 s d1 'past show-all (current-buffer) pos)
              diff (- d2 d1)
              warntime (get-text-property (point) 'org-appt-warntime))
        (setq pastschedp (and todayp (< diff 0)))
        (setq did-habit-check-p nil)
+       (setq suppress-delay
+             (let ((ds (and org-agenda-skip-scheduled-delay-if-deadline
+                            (let ((item (buffer-substring (point-at-bol) (point-at-eol))))
+                              (save-match-data
+                                (and (string-match
+                                      org-deadline-time-regexp item)
+                                     (match-string 1 item)))))))
+               (cond
+                ((not ds) nil)
+                ;; The current item has a deadline date (in ds), so
+                ;; evaluate its delay time.
+                ((integerp org-agenda-skip-scheduled-delay-if-deadline)
+                 ;; Use global delay time.
+                 (- org-agenda-skip-scheduled-delay-if-deadline))
+                ((eq org-agenda-skip-scheduled-delay-if-deadline
+                     'post-deadline)
+                 ;; Set delay to no later than deadline.
+                 (min (- d2 (org-time-string-to-absolute
+                             ds d1 'past show-all (current-buffer) pos))
+                      org-scheduled-delay-days))
+                (t 0))))
+       (setq ddays (if suppress-delay
+                       (let ((org-scheduled-delay-days suppress-delay))
+                         (org-get-wdays s t t))
+                     (org-get-wdays s t)))
+       ;; Use a delay of 0 when there is a repeater and the delay is
+       ;; of the form --3d
+       (when (and (save-match-data (string-match "--[0-9]+[hdwmy]" s))
+                  (< (org-time-string-to-absolute s)
+                     (org-time-string-to-absolute
+                      s d2 'past nil (current-buffer) pos)))
+         (setq ddays 0))
        ;; When to show a scheduled item in the calendar:
        ;; If it is on or past the date.
-       (when (or (and (< diff 0)
+       (when (or (and (> ddays 0) (= diff (- ddays)))
+                 (and (zerop ddays) (= diff 0))
+                 (and (< (+ diff ddays) 0)
                       (< (abs diff) org-scheduled-past-days)
                       (and todayp (not org-agenda-only-exact-dates)))
-                 (= diff 0)
                  ;; org-is-habit-p uses org-entry-get, which is expansive
                  ;; so we go extra mile to only call it once
                  (and todayp
@@ -5842,6 +6241,10 @@ FRACTION is what fraction of the head-warning time has passed."
                                  (org-is-habit-p))))
              (setq category (org-get-category)
                    category-pos (get-text-property (point) 'org-category-position))
+             (if (and (eq org-agenda-skip-scheduled-if-deadline-is-shown
+                          'repeated-after-deadline)
+                      (<= 0 (- d2 (time-to-days (org-get-deadline-time (point))))))
+                 (throw :skip nil))
              (if (not (re-search-backward "^\\*+[ \t]+" nil t))
                  (throw :skip nil)
                (goto-char (match-end 0))
@@ -5854,7 +6257,7 @@ FRACTION is what fraction of the head-warning time has passed."
                        (throw :skip nil))
                  (if (and
                       (or (eq t org-agenda-skip-scheduled-if-deadline-is-shown)
-                          (and org-agenda-skip-scheduled-if-deadline-is-shown
+                          (and (eq org-agenda-skip-scheduled-if-deadline-is-shown 'not-today)
                                pastschedp))
                       (setq mm (assoc pos1 deadline-position-alist)))
                      (throw :skip nil)))
@@ -5865,7 +6268,9 @@ FRACTION is what fraction of the head-warning time has passed."
                          (and (eq org-agenda-show-inherited-tags t)
                               (or (eq org-agenda-use-tag-inheritance t)
                                   (memq 'agenda org-agenda-use-tag-inheritance))))
+
                      tags (org-get-tags-at nil (not inherited-tags)))
+               (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
                (setq head (buffer-substring
                            (point)
                            (progn (skip-chars-forward "^\r\n") (point))))
@@ -5878,7 +6283,7 @@ FRACTION is what fraction of the head-warning time has passed."
                               (car org-agenda-scheduled-leaders)
                             (format (nth 1 org-agenda-scheduled-leaders)
                                     (- 1 diff)))
-                          head category tags
+                          head level category tags
                           (if (not (= diff 0)) nil timestr)
                           nil habitp))))
            (when txt
@@ -5896,7 +6301,9 @@ FRACTION is what fraction of the head-warning time has passed."
                'org-hd-marker (org-agenda-new-marker pos1)
                'type (if pastschedp "past-scheduled" "scheduled")
                'date (if pastschedp d2 date)
+               'ts-date d2
                'warntime warntime
+               'level level
                'priority (if habitp
                              (org-habit-get-priority habitp)
                            (+ 94 (- 5 diff) (org-get-priority txt)))
@@ -5920,7 +6327,7 @@ FRACTION is what fraction of the head-warning time has passed."
         (regexp org-tr-regexp)
         (d0 (calendar-absolute-from-gregorian date))
         marker hdmarker ee txt d1 d2 s1 s2 category category-pos
-        todo-state tags pos head donep inherited-tags)
+        level todo-state tags pos head donep inherited-tags)
     (goto-char (point-min))
     (while (re-search-forward regexp nil t)
       (catch :skip
@@ -5954,7 +6361,9 @@ FRACTION is what fraction of the head-warning time has passed."
                            (and (eq org-agenda-show-inherited-tags t)
                                 (or (eq org-agenda-use-tag-inheritance t)
                                     (memq 'agenda org-agenda-use-tag-inheritance))))
+
                        tags (org-get-tags-at nil (not inherited-tags)))
+                 (setq level (make-string (org-reduced-level (org-outline-level)) ? ))
                  (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
                  (setq head (match-string 1))
                  (let ((remove-re
@@ -5969,7 +6378,7 @@ FRACTION is what fraction of the head-warning time has passed."
                                (nth (if (= d1 d2) 0 1)
                                     org-agenda-timerange-leaders)
                                (1+ (- d0 d1)) (1+ (- d2 d1)))
-                              head category tags
+                              head level category tags
                               (cond ((and (= d1 d0) (= d2 d0))
                                      (concat "<" start-time ">--<" end-time ">"))
                                      ((= d1 d0)
@@ -5980,6 +6389,7 @@ FRACTION is what fraction of the head-warning time has passed."
                (org-add-props txt props
                  'org-marker marker 'org-hd-marker hdmarker
                  'type "block" 'date date
+                 'level level
                  'todo-state todo-state
                  'priority (org-get-priority txt) 'org-category category
                  'org-category-position category-pos)
@@ -5999,6 +6409,9 @@ The flag is set if the currently compiled format contains a `%T'.")
 (defvar org-prefix-has-effort nil
   "A flag, set by `org-compile-prefix-format'.
 The flag is set if the currently compiled format contains a `%e'.")
+(defvar org-prefix-has-breadcrumbs nil
+  "A flag, set by `org-compile-prefix-format'.
+The flag is set if the currently compiled format contains a `%b'.")
 (defvar org-prefix-category-length nil
   "Used by `org-compile-prefix-format' to remember the category field width.")
 (defvar org-prefix-category-max-length nil
@@ -6012,20 +6425,23 @@ The flag is set if the currently compiled format contains a `%e'.")
          (return (cadr entry))
        (return (apply 'create-image (cdr entry)))))))
 
-(defun org-agenda-format-item (extra txt &optional category tags dotime
+(defun org-agenda-format-item (extra txt &optional level category tags dotime
                                     remove-re habitp)
   "Format TXT to be inserted into the agenda buffer.
-In particular, it adds the prefix and corresponding text properties.  EXTRA
-must be a string and replaces the `%s' specifier in the prefix format.
-CATEGORY (string, symbol or nil) may be used to overrule the default
+In particular, add the prefix and corresponding text properties.
+
+EXTRA must be a string to replace the `%s' specifier in the prefix format.
+LEVEL may be a string to replace the `%l' specifier.
+CATEGORY (a string, a symbol or nil) may be used to overrule the default
 category taken from local variable or file name.  It will replace the `%c'
-specifier in the format.  DOTIME, when non-nil, indicates that a
-time-of-day should be extracted from TXT for sorting of this entry, and for
-the `%t' specifier in the format.  When DOTIME is a string, this string is
-searched for a time before TXT is.  TAGS can be the tags of the headline.
+specifier in the format.
+DOTIME, when non-nil, indicates that a time-of-day should be extracted from
+TXT for sorting of this entry, and for the `%t' specifier in the format.
+When DOTIME is a string, this string is searched for a time before TXT is.
+TAGS can be the tags of the headline.
 Any match of REMOVE-RE will be removed from TXT."
   ;; We keep the org-prefix-* variable values along with a compiled
-  ;; formatter, so that multiple agendas existing at the same time, do
+  ;; formatter, so that multiple agendas existing at the same time do
   ;; not step on each other toes.
   ;;
   ;; It was inconvenient to make these variables buffer local in
@@ -6038,13 +6454,14 @@ Any match of REMOVE-RE will be removed from TXT."
          do (set var value))
     (save-match-data
       ;; Diary entries sometimes have extra whitespace at the beginning
-      (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt)))
+      (setq txt (org-trim txt))
 
       ;; Fix the tags part in txt
       (setq txt (org-agenda-fix-displayed-tags
                 txt tags
                 org-agenda-show-inherited-tags
                 org-agenda-hide-tags-regexp))
+
       (let* ((category (or category
                           (if (stringp org-category)
                               org-category
@@ -6065,7 +6482,7 @@ Any match of REMOVE-RE will be removed from TXT."
                             (and org-agenda-search-headline-for-time txt))))
             (time-of-day (and dotime (org-get-time-of-day ts)))
             stamp plain s0 s1 s2 rtn srp l
-            duration thecategory)
+            duration thecategory breadcrumbs)
        (and (derived-mode-p 'org-mode) buffer-file-name
             (add-to-list 'org-agenda-contributing-files buffer-file-name))
        (when (and dotime time-of-day)
@@ -6093,10 +6510,12 @@ Any match of REMOVE-RE will be removed from TXT."
          (if s2 (setq s2 (org-get-time-of-day s2 'string t)))
 
          ;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set
-         (when (and s1 (not s2) org-agenda-default-appointment-duration)
-           (setq s2
-                 (org-minutes-to-hh:mm-string
-                  (+ (org-hh:mm-string-to-minutes s1) org-agenda-default-appointment-duration))))
+         (let (org-time-clocksum-use-effort-durations)
+           (when (and s1 (not s2) org-agenda-default-appointment-duration)
+             (setq s2
+                   (org-minutes-to-clocksum-string
+                    (+ (org-hh:mm-string-to-minutes s1)
+                       org-agenda-default-appointment-duration)))))
 
          ;; Compute the duration
          (when s2
@@ -6115,12 +6534,15 @@ Any match of REMOVE-RE will be removed from TXT."
                               (match-string 2 txt))
                       t t txt))))
        (when (derived-mode-p 'org-mode)
-         (setq effort (ignore-errors (get-text-property 0 'org-effort txt)))
-         (when effort
+         (setq effort (ignore-errors (get-text-property 0 'org-effort txt))))
+
+       ;; org-agenda-add-time-grid-maybe calls us with *Agenda* as
+       ;; current buffer, so move this check outside of above
+       (if effort
            (setq neffort (org-duration-string-to-minutes effort)
-                 effort (setq effort (concat "[" effort "]")))))
-       ;; prevent erroring out with %e format when there is no effort
-       (or effort (setq effort ""))
+                 effort (setq effort (concat "[" effort "]")))
+         ;; prevent erroring out with %e format when there is no effort
+         (setq effort ""))
 
        (when remove-re
          (while (string-match remove-re txt)
@@ -6131,6 +6553,10 @@ Any match of REMOVE-RE will be removed from TXT."
        (add-text-properties 0 (length txt) '(org-heading t) txt)
 
        ;; Prepare the variables needed in the eval of the compiled format
+       (if org-prefix-has-breadcrumbs
+           (setq breadcrumbs (org-with-point-at (org-get-at-bol 'org-marker)
+                               (let ((s (org-display-outline-path nil nil "->" t)))
+                                 (if (eq "" s) "" (concat s "->"))))))
        (setq time (cond (s2 (concat
                              (org-agenda-time-of-day-to-ampm-maybe s1)
                              "-" (org-agenda-time-of-day-to-ampm-maybe s2)
@@ -6143,7 +6569,8 @@ Any match of REMOVE-RE will be removed from TXT."
                         (t ""))
              extra (or (and (not habitp) extra) "")
              category (if (symbolp category) (symbol-name category) category)
-             thecategory (copy-sequence category))
+             thecategory (copy-sequence category)
+             level (or level ""))
        (if (string-match org-bracket-link-regexp category)
            (progn
              (setq l (if (match-end 3)
@@ -6171,7 +6598,9 @@ Any match of REMOVE-RE will be removed from TXT."
          'duration duration
          'effort effort
          'effort-minutes neffort
+         'breadcrumbs breadcrumbs
          'txt txt
+         'level level
          'time time
          'extra extra
          'format org-prefix-format-compiled
@@ -6216,9 +6645,13 @@ The modified list may contain inherited tags, and tags matched by
     s))
 
 (defvar org-agenda-sorting-strategy) ;; because the def is in a let form
-(defvar org-agenda-sorting-strategy-selected nil)
 
 (defun org-agenda-add-time-grid-maybe (list ndays todayp)
+  "Add a time-grid for agenda items which need it.
+
+LIST is the list of agenda items formatted by `org-agenda-list'.
+NDAYS is the span of the current agenda view.
+TODAYP is `t' when the current agenda view is on today."
   (catch 'exit
     (cond ((not org-agenda-use-time-grid) (throw 'exit list))
          ((and todayp (member 'today (car org-agenda-time-grid))))
@@ -6240,16 +6673,14 @@ The modified list may contain inherited tags, and tags matched by
        (unless (and remove (member time have))
          (setq time (replace-regexp-in-string " " "0" (format "%04s" time)))
          (push (org-agenda-format-item
-                nil string "" nil
+                nil string nil "" nil
                 (concat (substring time 0 -2) ":" (substring time -2)))
                new)
          (put-text-property
           2 (length (car new)) 'face 'org-time-grid (car new))))
       (when (and todayp org-agenda-show-current-time-in-grid)
        (push (org-agenda-format-item
-              nil
-              org-agenda-current-time-string
-              "" nil
+              nil org-agenda-current-time-string nil "" nil
               (format-time-string "%H:%M "))
              new)
        (put-text-property
@@ -6263,9 +6694,11 @@ The modified list may contain inherited tags, and tags matched by
   "Compile the prefix format into a Lisp form that can be evaluated.
 The resulting form and associated variable bindings is returned
 and stored in the variable `org-prefix-format-compiled'."
-  (setq org-prefix-has-time nil org-prefix-has-tag nil
+  (setq org-prefix-has-time nil
+       org-prefix-has-tag nil
        org-prefix-category-length nil
-       org-prefix-has-effort nil)
+       org-prefix-has-effort nil
+       org-prefix-has-breadcrumbs nil)
   (let ((s (cond
            ((stringp org-agenda-prefix-format)
             org-agenda-prefix-format)
@@ -6274,11 +6707,11 @@ and stored in the variable `org-prefix-format-compiled'."
            (t "  %-12:c%?-12t% s")))
        (start 0)
        varform vars var e c f opt)
-    (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\|(.+)\\)"
+    (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cltseib]\\|(.+)\\)"
                         s start)
       (setq var (or (cdr (assoc (match-string 4 s)
-                               '(("c" . category) ("t" . time) ("s" . extra)
-                                 ("i" . category-icon) ("T" . tag) ("e" . effort))))
+                               '(("c" . category) ("t" . time) ("l" . level) ("s" . extra)
+                                 ("i" . category-icon) ("T" . tag) ("e" . effort) ("b" . breadcrumbs))))
                    'eval)
            c (or (match-string 3 s) "")
            opt (match-beginning 1)
@@ -6286,6 +6719,7 @@ and stored in the variable `org-prefix-format-compiled'."
       (if (equal var 'time) (setq org-prefix-has-time t))
       (if (equal var 'tag)  (setq org-prefix-has-tag  t))
       (if (equal var 'effort) (setq org-prefix-has-effort t))
+      (if (equal var 'breadcrumbs) (setq org-prefix-has-breadcrumbs t))
       (setq f (concat "%" (match-string 2 s) "s"))
       (when (equal var 'category)
        (setq org-prefix-category-length
@@ -6312,7 +6746,8 @@ and stored in the variable `org-prefix-format-compiled'."
             `((org-prefix-has-time ,org-prefix-has-time)
               (org-prefix-has-tag ,org-prefix-has-tag)
               (org-prefix-category-length ,org-prefix-category-length)
-              (org-prefix-has-effort ,org-prefix-has-effort))
+              (org-prefix-has-effort ,org-prefix-has-effort)
+              (org-prefix-has-breadcrumbs ,org-prefix-has-breadcrumbs))
             `(format ,s ,@vars))))))
 
 (defun org-set-sorting-strategy (key)
@@ -6372,14 +6807,69 @@ You can also use this function as a filter, by returning nil for lines
 you don't want to have in the agenda at all.  For this application, you
 could bind the variable in the options section of a custom command.")
 
-(defun org-agenda-finalize-entries (list &optional nosort)
-  "Sort and concatenate the agenda items."
-  (setq list (mapcar 'org-agenda-highlight-todo list))
-  (if nosort
-      list
+(defun org-agenda-finalize-entries (list &optional type)
+  "Sort, limit and concatenate the LIST of agenda items.
+The optional argument TYPE tells the agenda type."
+  (let ((max-effort (cond ((listp org-agenda-max-effort)
+                          (cdr (assoc type org-agenda-max-effort)))
+                         (t org-agenda-max-effort)))
+       (max-todo (cond ((listp org-agenda-max-todos)
+                        (cdr (assoc type org-agenda-max-todos)))
+                       (t org-agenda-max-todos)))
+       (max-tags (cond ((listp org-agenda-max-tags)
+                        (cdr (assoc type org-agenda-max-tags)))
+                       (t org-agenda-max-tags)))
+       (max-entries (cond ((listp org-agenda-max-entries)
+                           (cdr (assoc type org-agenda-max-entries)))
+                          (t org-agenda-max-entries))) l)
     (when org-agenda-before-sorting-filter-function
-      (setq list (delq nil (mapcar org-agenda-before-sorting-filter-function list))))
-    (mapconcat 'identity (sort list 'org-entries-lessp) "\n")))
+      (setq list
+           (delq nil
+                 (mapcar
+                  org-agenda-before-sorting-filter-function list))))
+    (setq list (mapcar 'org-agenda-highlight-todo list)
+         list (mapcar 'identity (sort list 'org-entries-lessp)))
+    (when max-effort
+      (setq list (org-agenda-limit-entries
+                 list 'effort-minutes max-effort 'identity)))
+    (when max-todo
+      (setq list (org-agenda-limit-entries list 'todo-state max-todo)))
+    (when max-tags
+      (setq list (org-agenda-limit-entries list 'tags max-tags)))
+    (when max-entries
+      (setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
+    (mapconcat 'identity list "\n")))
+
+(defun org-agenda-limit-entries (list prop limit &optional fn)
+  "Limit the number of agenda entries."
+  (let ((include (and limit (< limit 0))))
+    (if limit
+       (let ((fun (or fn (lambda (p) (if p 1))))
+             (lim 0))
+         (delq nil
+               (mapcar
+                (lambda (e)
+                  (let ((pval (funcall fun (get-text-property 1 prop e))))
+                    (if pval (setq lim (+ lim pval)))
+                    (cond ((and pval (<= lim (abs limit))) e)
+                          ((and include (not pval)) e))))
+                list)))
+      list)))
+
+(defun org-agenda-limit-interactively ()
+  "In agenda, interactively limit entries to various maximums."
+  (interactive)
+  (let* ((max (read-char "Number of [e]ntries [t]odos [T]ags [E]ffort? "))
+        (num (string-to-number (read-from-minibuffer "How many? "))))
+    (cond ((equal max ?e)
+          (let ((org-agenda-max-entries num)) (org-agenda-redo)))
+         ((equal max ?t)
+          (let ((org-agenda-max-todos num)) (org-agenda-redo)))
+         ((equal max ?T)
+          (let ((org-agenda-max-tags num)) (org-agenda-redo)))
+         ((equal max ?E)
+          (let ((org-agenda-max-effort num)) (org-agenda-redo)))))
+  (org-agenda-fit-window-to-buffer))
 
 (defun org-agenda-highlight-todo (x)
   (let ((org-done-keywords org-done-keywords-for-agenda)
@@ -6506,6 +6996,20 @@ could bind the variable in the options section of a custom command.")
     (cond ((< ta tb) -1)
          ((< tb ta) +1))))
 
+(defsubst org-cmp-ts (a b &optional type)
+  "Compare the timestamps values of entries A and B.
+When TYPE is \"scheduled\", \"deadline\", \"timestamp\" or
+\"timestamp_ia\", compare within each of these type.  When TYPE
+is the empty string, compare all timestamps without respect of
+their type."
+  (let* ((def (if org-sort-agenda-notime-is-late 9901 -1))
+        (ta (or (and (string-match type (or (get-text-property 1 'type a) ""))
+                     (get-text-property 1 'ts-date a)) def))
+        (tb (or (and (string-match type (or (get-text-property 1 'type b) ""))
+                     (get-text-property 1 'ts-date b)) def)))
+    (cond ((< ta tb) -1)
+         ((< tb ta) +1))))
+
 (defsubst org-cmp-habit-p (a b)
   "Compare the todo states of strings A and B."
   (let ((ha (get-text-property 1 'org-habit-p a))
@@ -6513,13 +7017,26 @@ could bind the variable in the options section of a custom command.")
     (cond ((and ha (not hb)) -1)
          ((and (not ha) hb) +1))))
 
-(defsubst org-em (x y list) (or (memq x list) (memq y list)))
-
 (defun org-entries-lessp (a b)
   "Predicate for sorting agenda entries."
   ;; The following variables will be used when the form is evaluated.
   ;; So even though the compiler complains, keep them.
   (let* ((ss org-agenda-sorting-strategy-selected)
+        (timestamp-up    (and (org-em 'timestamp-up 'timestamp-down ss)
+                              (org-cmp-ts a b "")))
+        (timestamp-down  (if timestamp-up (- timestamp-up) nil))
+        (scheduled-up    (and (org-em 'scheduled-up 'scheduled-down ss)
+                              (org-cmp-ts a b "scheduled")))
+        (scheduled-down  (if scheduled-up (- scheduled-up) nil))
+        (deadline-up     (and (org-em 'deadline-up 'deadline-down ss)
+                              (org-cmp-ts a b "deadline")))
+        (deadline-down   (if deadline-up (- deadline-up) nil))
+        (tsia-up         (and (org-em 'tsia-up 'tsia-down ss)
+                              (org-cmp-ts a b "iatimestamp_ia")))
+        (tsia-down       (if tsia-up (- tsia-up) nil))
+        (ts-up           (and (org-em 'ts-up 'ts-down ss)
+                              (org-cmp-ts a b "timestamp")))
+        (ts-down         (if ts-up (- ts-up) nil))
         (time-up         (and (org-em 'time-up 'time-down ss)
                               (org-cmp-time a b)))
         (time-down       (if time-up (- time-up) nil))
@@ -6567,6 +7084,7 @@ could bind the variable in the options section of a custom command.")
             'help-echo "Agendas are currently limited to this subtree.")
 (org-detach-overlay org-agenda-restriction-lock-overlay)
 
+;;;###autoload
 (defun org-agenda-set-restriction-lock (&optional type)
   "Set restriction lock for agenda, to current subtree or file.
 Restriction will be the file if TYPE is `file', or if type is the
@@ -6582,15 +7100,19 @@ in the file.  Otherwise, restriction will be to the current subtree."
              (t 'file)))
   (if (eq type 'subtree)
       (progn
-       (setq org-agenda-restrict t)
+       (setq org-agenda-restrict (current-buffer))
        (setq org-agenda-overriding-restriction 'subtree)
        (put 'org-agenda-files 'org-restrict
             (list (buffer-file-name (buffer-base-buffer))))
        (org-back-to-heading t)
-       (move-overlay org-agenda-restriction-lock-overlay (point) (point-at-eol))
+       (move-overlay org-agenda-restriction-lock-overlay
+                     (point)
+                     (if org-agenda-restriction-lock-highlight-subtree
+                         (save-excursion (org-end-of-subtree t t) (point))
+                       (point-at-eol)))
        (move-marker org-agenda-restrict-begin (point))
        (move-marker org-agenda-restrict-end
-                    (save-excursion (org-end-of-subtree t)))
+                    (save-excursion (org-end-of-subtree t t)))
        (message "Locking agenda restriction to subtree"))
     (put 'org-agenda-files 'org-restrict
         (list (buffer-file-name (buffer-base-buffer))))
@@ -6643,8 +7165,9 @@ Allowed types are 'agenda 'timeline 'todo 'tags 'search."
          (error "Not allowed in %s-type agenda buffers" org-agenda-type)
        nil))))
 
-(defun org-agenda-Quit (&optional arg)
-  "Exit agenda by removing the window or the buffer."
+(defun org-agenda-Quit ()
+  "Exit the agenda and kill buffers loaded by `org-agenda'.
+Also restore the window configuration."
   (interactive)
   (if org-agenda-columns-active
       (org-columns-quit)
@@ -6663,6 +7186,7 @@ Allowed types are 'agenda 'timeline 'todo 'tags 'search."
        (kill-buffer buf)
        (org-columns-remove-overlays)
        (setq org-agenda-archives-mode nil)))
+    (setq org-agenda-buffer nil)
     ;; Maybe restore the pre-agenda window configuration.
     (and org-agenda-restore-windows-after-quit
         (not (eq org-agenda-window-setup 'other-frame))
@@ -6671,8 +7195,8 @@ Allowed types are 'agenda 'timeline 'todo 'tags 'search."
         (setq org-agenda-pre-window-conf nil))))
 
 (defun org-agenda-quit ()
-  "Exit agenda by killing agenda buffer or burying it when
-`org-agenda-sticky' is non-NIL"
+  "Exit the agenda and restore the window configuration.
+When `org-agenda-sticky' is non-nil, only bury the agenda."
   (interactive)
   (if (and (eq org-indirect-buffer-display 'other-window)
           org-last-indirect-buffer)
@@ -6701,9 +7225,9 @@ Allowed types are 'agenda 'timeline 'todo 'tags 'search."
       (org-agenda-Quit))))
 
 (defun org-agenda-exit ()
-  "Exit agenda by removing the window or the buffer.
-Also kill all Org-mode buffers which have been loaded by `org-agenda'.
-Org-mode buffers visited directly by the user will not be touched."
+  "Exit the agenda and restore the window configuration.
+Also kill Org-mode buffers loaded by `org-agenda'.  Org-mode
+buffers visited directly by the user will not be touched."
   (interactive)
   (org-release-buffers org-agenda-new-buffers)
   (setq org-agenda-new-buffers nil)
@@ -6711,8 +7235,8 @@ Org-mode buffers visited directly by the user will not be touched."
 
 (defun org-agenda-kill-all-agenda-buffers ()
   "Kill all buffers in `org-agenda-mode'.
-This is used when toggling sticky agendas.  You can also explicitly invoke it
-with `C-c a C-k'."
+This is used when toggling sticky agendas.
+You can also explicitly invoke it with `C-c a C-k'."
   (interactive)
   (let (blist)
     (dolist (buf (buffer-list))
@@ -6740,9 +7264,11 @@ in the agenda."
         (org-agenda-keep-modes t)
         (tag-filter org-agenda-tag-filter)
         (tag-preset (get 'org-agenda-tag-filter :preset-filter))
-        (top-cat-filter org-agenda-top-category-filter)
+        (top-hl-filter org-agenda-top-headline-filter)
         (cat-filter org-agenda-category-filter)
         (cat-preset (get 'org-agenda-category-filter :preset-filter))
+        (re-filter org-agenda-regexp-filter)
+        (re-preset (get 'org-agenda-regexp-filter :preset-filter))
         (org-agenda-tag-filter-while-redo (or tag-filter tag-preset))
         (cols org-agenda-columns-active)
         (line (org-current-line))
@@ -6760,19 +7286,26 @@ in the agenda."
         (series-redo-cmd (get-text-property p 'org-series-redo-cmd)))
     (put 'org-agenda-tag-filter :preset-filter nil)
     (put 'org-agenda-category-filter :preset-filter nil)
+    (put 'org-agenda-regexp-filter :preset-filter nil)
     (and cols (org-columns-quit))
     (message "Rebuilding agenda buffer...")
     (if series-redo-cmd
        (eval series-redo-cmd)
-      (org-let lprops '(eval redo-cmd)))
+      (org-let lprops redo-cmd))
     (setq org-agenda-undo-list nil
-         org-agenda-pending-undo-list nil)
+         org-agenda-pending-undo-list nil
+         org-agenda-tag-filter tag-filter
+         org-agenda-category-filter cat-filter
+         org-agenda-regexp-filter re-filter
+         org-agenda-top-headline-filter top-hl-filter)
     (message "Rebuilding agenda buffer...done")
     (put 'org-agenda-tag-filter :preset-filter tag-preset)
     (put 'org-agenda-category-filter :preset-filter cat-preset)
+    (put 'org-agenda-regexp-filter :preset-filter re-preset)
     (and (or tag-filter tag-preset) (org-agenda-filter-apply tag-filter 'tag))
     (and (or cat-filter cat-preset) (org-agenda-filter-apply cat-filter 'category))
-    (and top-cat-filter (org-agenda-filter-top-category-apply top-cat-filter))
+    (and (or re-filter re-preset) (org-agenda-filter-apply re-filter 'regexp))
+    (and top-hl-filter (org-agenda-filter-top-headline-apply top-hl-filter))
     (and cols (org-called-interactively-p 'any) (org-agenda-columns))
     (org-goto-line line)
     (recenter window-line)))
@@ -6789,11 +7322,18 @@ The category is that of the current line."
           org-agenda-category-filter)
       (org-agenda-filter-show-all-cat)
     (let ((cat (org-no-properties (get-text-property (point) 'org-category))))
-      (if cat (org-agenda-filter-apply
-              (list (concat (if strip "-" "+") cat)) 'category)
-       (error "No category at point")))))
-
-(defun org-find-top-category (&optional pos)
+      (cond
+       ((and cat strip)
+        (org-agenda-filter-apply
+         (push (concat "-" cat) org-agenda-category-filter) 'category))
+       ((and cat)
+        (org-agenda-filter-apply
+         (setq org-agenda-category-filter
+              (list (concat "+" cat))) 'category))
+       ((error "No category at point"))))))
+
+(defun org-find-top-headline (&optional pos)
+  "Find the topmost parent headline and return it."
   (save-excursion
     (with-current-buffer (if pos (marker-buffer pos) (current-buffer))
       (if pos (goto-char pos))
@@ -6802,21 +7342,49 @@ The category is that of the current line."
       (ignore-errors
        (nth 4 (org-heading-components))))))
 
-(defvar org-agenda-filtered-by-top-category nil)
-
-(defun org-agenda-filter-by-top-category (strip)
-  "Keep only those lines in the agenda buffer that have a specific category.
-The category is that of the current line."
+(defvar org-agenda-filtered-by-top-headline nil)
+(defun org-agenda-filter-by-top-headline (strip)
+  "Keep only those lines that are descendants from the same top headline.
+The top headline is that of the current line."
   (interactive "P")
-  (if org-agenda-filtered-by-top-category
+  (if org-agenda-filtered-by-top-headline
       (progn
-        (setq org-agenda-filtered-by-top-category nil
-             org-agenda-top-category-filter nil)
+        (setq org-agenda-filtered-by-top-headline nil
+             org-agenda-top-headline-filter nil)
         (org-agenda-filter-show-all-cat))
-    (let ((cat (org-find-top-category (org-get-at-bol 'org-hd-marker))))
-      (if cat (org-agenda-filter-top-category-apply cat strip)
+    (let ((cat (org-find-top-headline (org-get-at-bol 'org-hd-marker))))
+      (if cat (org-agenda-filter-top-headline-apply cat strip)
         (error "No top-level category at point")))))
 
+(defvar org-agenda-regexp-filter nil)
+(defun org-agenda-filter-by-regexp (strip)
+  "Filter agenda entries by a regular expression.
+Regexp filters are cumulative.
+With no prefix argument, keep entries matching the regexp.
+With one prefix argument, filter out entries matching the regexp.
+With two prefix arguments, remove the regexp filters."
+  (interactive "P")
+  (if (not (equal strip '(16)))
+      (let ((flt (concat (if (equal strip '(4)) "-" "+")
+                        (read-from-minibuffer
+                         (if (equal strip '(4))
+                             "Filter out entries matching regexp: "
+                             "Narrow to entries matching regexp: ")))))
+       (push flt org-agenda-regexp-filter)
+       (org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
+    (org-agenda-filter-show-all-re)
+    (message "Regexp filter removed")))
+
+(defun org-agenda-filter-remove-all ()
+  "Remove all filters from the current agenda buffer."
+  (interactive)
+  (when org-agenda-tag-filter
+    (org-agenda-filter-show-all-tag))
+  (when org-agenda-category-filter
+    (org-agenda-filter-show-all-cat))
+  (when org-agenda-regexp-filter
+    (org-agenda-filter-show-all-re)))
+
 (defun org-agenda-filter-by-tag (strip &optional char narrow)
   "Keep only those lines in the agenda buffer that have a specific tag.
 The tag is selected with its fast selection letter, as configured.
@@ -6881,7 +7449,7 @@ to switch to narrowing."
      ((equal char ?\r)
       (org-agenda-filter-show-all-tag)
       (when org-agenda-auto-exclude-function
-       (setq org-agenda-tag-filter '())
+       (setq org-agenda-tag-filter nil)
        (dolist (tag (org-agenda-get-represented-tags))
          (let ((modifier (funcall org-agenda-auto-exclude-function tag)))
            (if modifier
@@ -6938,29 +7506,61 @@ to switch to narrowing."
   (interactive "P")
   (org-agenda-filter-by-tag strip char 'refine))
 
-(defun org-agenda-filter-make-matcher ()
+(defun org-agenda-filter-make-matcher (filter type)
   "Create the form that tests a line for agenda filter."
   (let (f f1)
-    ;; first compute the tag-filter matcher
-    (dolist (x (delete-dups
-               (append (get 'org-agenda-tag-filter
-                            :preset-filter) org-agenda-tag-filter)))
-      (if (member x '("-" "+"))
-         (setq f1 (if (equal x "-") 'tags '(not tags)))
-       (if (string-match "[<=>?]" x)
-           (setq f1 (org-agenda-filter-effort-form x))
-         (setq f1 (list 'member (downcase (substring x 1)) 'tags)))
-       (if (equal (string-to-char x) ?-)
-           (setq f1 (list 'not f1))))
-      (push f1 f))
-    ;; then compute the category-filter matcher
-    (dolist (x (delete-dups
-               (append (get 'org-agenda-category-filter
-                            :preset-filter) org-agenda-category-filter)))
-      (if (equal "-" (substring x 0 1))
-         (setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
-       (setq f1 (list 'equal (substring x 1) 'cat)))
-      (push f1 f))
+    (cond
+     ;; Tag filter
+     ((eq type 'tag)
+      (setq filter
+           (delete-dups
+            (append (get 'org-agenda-tag-filter :preset-filter)
+                    filter)))
+      (dolist (x filter)
+       (let ((nfilter (org-agenda-filter-expand-tags filter)) nf nf1
+             (ffunc
+              (lambda (nf0 nf01 fltr notgroup op)
+                (dolist (x fltr)
+                  (if (member x '("-" "+"))
+                      (setq nf01 (if (equal x "-") 'tags '(not tags)))
+                    (if (string-match "[<=>?]" x)
+                        (setq nf01 (org-agenda-filter-effort-form x))
+                      (setq nf01 (list 'member (downcase (substring x 1))
+                                       'tags)))
+                    (when (equal (string-to-char x) ?-)
+                      (setq nf01 (list 'not nf01))
+                      (when (not notgroup) (setq op 'and))))
+                  (push nf01 nf0))
+                (if notgroup
+                    (push (cons 'and nf0) f)
+                  (push (cons (or op 'or) nf0) f)))))
+         (cond ((equal filter '("+"))
+                (setq f (list (list 'not 'tags))))
+               ((equal nfilter filter)
+                (funcall ffunc f1 f filter t nil))
+               (t (funcall ffunc nf1 nf nfilter nil nil))))))
+     ;; Category filter
+     ((eq type 'category)
+      (setq filter
+           (delete-dups
+            (append (get 'org-agenda-category-filter :preset-filter)
+                    filter)))
+      (dolist (x filter)
+       (if (equal "-" (substring x 0 1))
+           (setq f1 (list 'not (list 'equal (substring x 1) 'cat)))
+         (setq f1 (list 'equal (substring x 1) 'cat)))
+       (push f1 f)))
+     ;; Regexp filter
+     ((eq type 'regexp)
+      (setq filter
+           (delete-dups
+            (append (get 'org-agenda-regexp-filter :preset-filter)
+                    filter)))
+      (dolist (x filter)
+       (if (equal "-" (substring x 0 1))
+           (setq f1 (list 'not (list 'string-match (substring x 1) 'txt)))
+         (setq f1 (list 'string-match (substring x 1) 'txt)))
+       (push f1 f))))
     (cons 'and (nreverse f))))
 
 (defun org-agenda-filter-effort-form (e)
@@ -6985,13 +7585,31 @@ If the line does not have an effort defined, return nil."
       (funcall op (or eff (if org-sort-agenda-noeffort-is-high 32767 0))
               value))))
 
+(defun org-agenda-filter-expand-tags (filter &optional no-operator)
+  "Expand group tags in FILTER for the agenda.
+When NO-OPERATOR is non-nil, do not add the + operator to returned tags."
+  (if org-group-tags
+      (let ((case-fold-search t) rtn)
+       (mapc
+        (lambda (f)
+          (let (f0 dir)
+            (if (string-match "^\\([+-]\\)\\(.+\\)" f)
+                (setq dir (match-string 1 f) f0 (match-string 2 f))
+              (setq dir (if no-operator "" "+") f0 f))
+            (setq rtn (append (mapcar (lambda(f1) (concat dir f1))
+                                      (org-tags-expand f0 t t))
+                              rtn))))
+        filter)
+       (reverse rtn))
+    filter))
+
 (defun org-agenda-filter-apply (filter type)
   "Set FILTER as the new agenda filter and apply it."
-  (let (tags cat)
-    (if (eq type 'tag)
-       (setq org-agenda-tag-filter filter)
-      (setq org-agenda-category-filter filter))
-    (setq org-agenda-filter-form (org-agenda-filter-make-matcher))
+  ;; Deactivate `org-agenda-entry-text-mode' when filtering
+  (if org-agenda-entry-text-mode (org-agenda-entry-text-mode))
+  (let (tags cat txt)
+    (setq org-agenda-filter-form
+         (org-agenda-filter-make-matcher filter type))
     (if (and (eq type 'category)
             (not (equal (substring (car filter) 0 1) "-")))
        ;; Only set `org-agenda-filtered-by-category' to t
@@ -7003,8 +7621,13 @@ If the line does not have an effort defined, return nil."
       (while (not (eobp))
        (if (org-get-at-bol 'org-marker)
            (progn
-             (setq tags (org-get-at-bol 'tags) ; used in eval
-                   cat (get-text-property (point) 'org-category))
+             (setq tags ; used in eval
+                   (apply 'append
+                          (mapcar (lambda (f)
+                                    (org-agenda-filter-expand-tags (list f) t))
+                                  (org-get-at-bol 'tags)))
+                   cat (get-text-property (point) 'org-category)
+                   txt (get-text-property (point) 'txt))
              (if (not (eval org-agenda-filter-form))
                  (org-agenda-filter-hide-line type))
              (beginning-of-line 2))
@@ -7012,32 +7635,33 @@ If the line does not have an effort defined, return nil."
     (if (get-char-property (point) 'invisible)
        (ignore-errors (org-agenda-previous-line)))))
 
-(defun org-agenda-filter-top-category-apply (category &optional negative)
-  "Set FILTER as the new agenda filter and apply it."
+(defun org-agenda-filter-top-headline-apply (hl &optional negative)
+  "Filter by top headline HL."
   (org-agenda-set-mode-name)
   (save-excursion
     (goto-char (point-min))
     (while (not (eobp))
       (let* ((pos (org-get-at-bol 'org-hd-marker))
-             (topcat (and pos (org-find-top-category pos))))
-        (if (and topcat (funcall (if negative 'identity 'not)
-                                 (string= category topcat)))
+             (tophl (and pos (org-find-top-headline pos))))
+        (if (and tophl (funcall (if negative 'identity 'not)
+                                 (string= hl tophl)))
             (org-agenda-filter-hide-line 'category)))
       (beginning-of-line 2)))
   (if (get-char-property (point) 'invisible)
       (org-agenda-previous-line))
-  (setq org-agenda-top-category-filter category
-       org-agenda-filtered-by-top-category t))
+  (setq org-agenda-top-headline-filter hl
+       org-agenda-filtered-by-top-headline t))
 
 (defun org-agenda-filter-hide-line (type)
+  "Hide lines with TYPE in the agenda buffer."
   (let (ov)
     (setq ov (make-overlay (max (point-min) (1- (point-at-bol)))
                           (point-at-eol)))
     (overlay-put ov 'invisible t)
     (overlay-put ov 'type type)
-    (if (eq type 'tag)
-       (push ov org-agenda-tag-filter-overlays)
-      (push ov org-agenda-cat-filter-overlays))))
+    (cond ((eq type 'tag) (push ov org-agenda-tag-filter-overlays))
+         ((eq type 'category) (push ov org-agenda-cat-filter-overlays))
+         ((eq type 'regexp) (push ov org-agenda-re-filter-overlays)))))
 
 (defun org-agenda-fix-tags-filter-overlays-at (&optional pos)
   (setq pos (or pos (point)))
@@ -7051,13 +7675,23 @@ If the line does not have an effort defined, return nil."
                          (overlay-end ov)))))))
 
 (defun org-agenda-filter-show-all-tag nil
+  "Remove tag filter overlays from the agenda buffer."
   (mapc 'delete-overlay org-agenda-tag-filter-overlays)
   (setq org-agenda-tag-filter-overlays nil
        org-agenda-tag-filter nil
        org-agenda-filter-form nil)
   (org-agenda-set-mode-name))
 
+(defun org-agenda-filter-show-all-re nil
+  "Remove regexp filter overlays from the agenda buffer."
+  (mapc 'delete-overlay org-agenda-re-filter-overlays)
+  (setq org-agenda-re-filter-overlays nil
+       org-agenda-regexp-filter nil
+       org-agenda-filter-form nil)
+  (org-agenda-set-mode-name))
+
 (defun org-agenda-filter-show-all-cat nil
+  "Remove category filter overlays from the agenda buffer."
   (mapc 'delete-overlay org-agenda-cat-filter-overlays)
   (setq org-agenda-cat-filter-overlays nil
        org-agenda-filtered-by-category nil
@@ -7121,23 +7755,31 @@ Negative selection means regexp must not match for selection of an entry."
   (let* ((org-read-date-prefer-future
          (eval org-agenda-jump-prefer-future))
         (date (org-read-date))
+        (day (time-to-days (org-time-string-to-time date)))
         (org-agenda-sticky-orig org-agenda-sticky)
         (org-agenda-buffer-tmp-name (buffer-name))
         (args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
         (0-arg (or current-prefix-arg (car args)))
         (2-arg (nth 2 args))
+        (with-hour-p (nth 4 org-agenda-redo-command))
         (newcmd (list 'org-agenda-list 0-arg date
-                      (org-agenda-span-to-ndays 2-arg)))
+                      (org-agenda-span-to-ndays
+                       2-arg (org-time-string-to-absolute date))
+                      with-hour-p))
         (newargs (cdr newcmd))
         (inhibit-read-only t)
         org-agenda-sticky)
     (if (not (org-agenda-check-type t 'agenda))
-       (error "Not available in non-agenda blocks")
+       (error "Not available in non-agenda views")
       (add-text-properties (point-min) (point-max)
                           `(org-redo-cmd ,newcmd org-last-args ,newargs))
       (org-agenda-redo)
-    (setq org-agenda-sticky org-agenda-sticky-orig
-         org-agenda-this-buffer-is-sticky org-agenda-sticky))))
+      (goto-char (point-min))
+      (while (not (or (= (or (get-text-property (point) 'day) 0) day)
+                     (save-excursion (move-beginning-of-line 2) (eobp))))
+       (move-beginning-of-line 2))
+      (setq org-agenda-sticky org-agenda-sticky-orig
+           org-agenda-this-buffer-is-sticky org-agenda-sticky))))
 
 (defun org-agenda-goto-today ()
   "Go to today."
@@ -7203,6 +7845,8 @@ With prefix ARG, go forward that many times the current span."
       (setq sd (+ arg sd)))
      ((eq span 'week)
       (setq sd (+ (* 7 arg) sd)))
+     ((eq span 'fortnight)
+      (setq sd (+ (* 14 arg) sd)))
      ((eq span 'month)
       (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
            sd (calendar-absolute-from-gregorian greg2))
@@ -7232,7 +7876,7 @@ With prefix ARG, go backward that many times the current span."
 (defun org-agenda-view-mode-dispatch ()
   "Call one of the view mode commands."
   (interactive)
-  (message "View: [d]ay        [w]eek       [m]onth       [y]ear   [SPC]reset  [q]uit/abort
+  (message "View: [d]ay  [w]eek  for[t]night  [m]onth  [y]ear  [SPC]reset  [q]uit/abort
       time[G]rid   [[]inactive  [f]ollow      [l]og    [L]og-all   [c]lockcheck
       [a]rch-trees [A]rch-files clock[R]eport include[D]iary       [E]ntryText")
   (let ((a (read-char-exclusive)))
@@ -7240,6 +7884,7 @@ With prefix ARG, go backward that many times the current span."
       (?\  (call-interactively 'org-agenda-reset-view))
       (?d (call-interactively 'org-agenda-day-view))
       (?w (call-interactively 'org-agenda-week-view))
+      (?t (call-interactively 'org-agenda-fortnight-view))
       (?m (call-interactively 'org-agenda-month-view))
       (?y (call-interactively 'org-agenda-year-view))
       (?l (call-interactively 'org-agenda-log-mode))
@@ -7264,11 +7909,11 @@ With prefix ARG, go backward that many times the current span."
   "Switch to default view for agenda."
   (interactive)
   (org-agenda-change-time-span (or org-agenda-ndays org-agenda-span)))
-(defun org-agenda-day-view (&optional day-of-year)
+(defun org-agenda-day-view (&optional day-of-month)
   "Switch to daily view for agenda.
-With argument DAY-OF-YEAR, switch to that day of the year."
+With argument DAY-OF-MONTH, switch to that day of the month."
   (interactive "P")
-  (org-agenda-change-time-span 'day day-of-year))
+  (org-agenda-change-time-span 'day day-of-month))
 (defun org-agenda-week-view (&optional iso-week)
   "Switch to daily view for agenda.
 With argument ISO-WEEK, switch to the corresponding ISO week.
@@ -7278,6 +7923,15 @@ week 12 of year 2007.  Years in the range 1938-2037 can also be
 written as 2-digit years."
   (interactive "P")
   (org-agenda-change-time-span 'week iso-week))
+(defun org-agenda-fortnight-view (&optional iso-week)
+  "Switch to daily view for agenda.
+With argument ISO-WEEK, switch to the corresponding ISO week.
+If ISO-WEEK has more then 2 digits, only the last two encode the
+week.  Any digits before this encode a year.  So 200712 means
+week 12 of year 2007.  Years in the range 1938-2037 can also be
+written as 2-digit years."
+  (interactive "P")
+  (org-agenda-change-time-span 'fortnight iso-week))
 (defun org-agenda-month-view (&optional month)
   "Switch to monthly view for agenda.
 With argument MONTH, switch to that month."
@@ -7299,7 +7953,7 @@ written as 2-digit years."
 
 (defun org-agenda-change-time-span (span &optional n)
   "Change the agenda view to SPAN.
-SPAN may be `day', `week', `month', `year'."
+SPAN may be `day', `week', `fortnight', `month', `year'."
   (org-agenda-check-type t 'agenda)
   (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
         (curspan (nth 2 args)))
@@ -7320,7 +7974,7 @@ SPAN may be `day', `week', `month', `year'."
 
 (defun org-agenda-compute-starting-span (sd span &optional n)
   "Compute starting date for agenda.
-SPAN may be `day', `week', `month', `year'.  The return value
+SPAN may be `day', `week', `fortnight', `month', `year'.  The return value
 is a cons cell with the starting date and the number of days,
 so that the date SD will be in that range."
   (let* ((greg (calendar-gregorian-from-absolute sd))
@@ -7333,7 +7987,7 @@ so that the date SD will be in that range."
        (setq sd (+ (calendar-absolute-from-gregorian
                     (list mg 1 yg))
                    n -1))))
-     ((eq span 'week)
+     ((or (eq span 'week) (eq span 'fortnight))
       (let* ((nt (calendar-day-of-week
                  (calendar-gregorian-from-absolute sd)))
             (d (if org-agenda-start-on-weekday
@@ -7418,17 +8072,24 @@ so that the date SD will be in that range."
 (defun org-agenda-entry-text-mode (&optional arg)
   "Toggle entry text mode in an agenda buffer."
   (interactive "P")
-  (setq org-agenda-entry-text-mode (or (integerp arg)
-                                       (not org-agenda-entry-text-mode)))
-  (org-agenda-entry-text-hide)
-  (and org-agenda-entry-text-mode
-       (let ((org-agenda-entry-text-maxlines
-             (if (integerp arg) arg org-agenda-entry-text-maxlines)))
-        (org-agenda-entry-text-show)))
-  (org-agenda-set-mode-name)
-  (message "Entry text mode is %s.  Maximum number of lines is %d"
-          (if org-agenda-entry-text-mode "on" "off")
-          (if (integerp arg) arg org-agenda-entry-text-maxlines)))
+  (if (or org-agenda-tag-filter
+         org-agenda-category-filter
+         org-agenda-regexp-filter
+         org-agenda-top-headline-filter)
+      (user-error "Can't show entry text in filtered views")
+    (setq org-agenda-entry-text-mode (or (integerp arg)
+                                        (not org-agenda-entry-text-mode)))
+    (org-agenda-entry-text-hide)
+    (and org-agenda-entry-text-mode
+        (let ((org-agenda-entry-text-maxlines
+               (if (integerp arg) arg org-agenda-entry-text-maxlines)))
+          (org-agenda-entry-text-show)))
+    (org-agenda-set-mode-name)
+    (message "Entry text mode is %s%s"
+            (if org-agenda-entry-text-mode "on" "off")
+            (if (not org-agenda-entry-text-mode) ""
+              (format " (maximum number of lines is %d)"
+                      (if (integerp arg) arg org-agenda-entry-text-maxlines))))))
 
 (defun org-agenda-clockreport-mode (&optional with-filter)
   "Toggle clocktable mode in an agenda buffer.
@@ -7532,8 +8193,8 @@ When called with a prefix argument, include all archive files as well."
               ((eq org-agenda-show-log 'clockcheck) " ClkCk")
               (org-agenda-show-log " Log")
               (t ""))
-             (if (or org-agenda-category-filter (get 'org-agenda-category-filter
-                                                     :preset-filter))
+             (if (or org-agenda-category-filter
+                     (get 'org-agenda-category-filter :preset-filter))
                  '(:eval (org-propertize
                           (concat " <"
                                   (mapconcat
@@ -7544,10 +8205,9 @@ When called with a prefix argument, include all archive files as well."
                                    "")
                                   ">")
                           'face 'org-agenda-filter-category
-                          'help-echo "Category used in filtering"))
-               "")
-             (if (or org-agenda-tag-filter (get 'org-agenda-tag-filter
-                                                :preset-filter))
+                          'help-echo "Category used in filtering")) "")
+             (if (or org-agenda-tag-filter
+                     (get 'org-agenda-tag-filter :preset-filter))
                  '(:eval (org-propertize
                           (concat " {"
                                   (mapconcat
@@ -7558,8 +8218,20 @@ When called with a prefix argument, include all archive files as well."
                                    "")
                                   "}")
                           'face 'org-agenda-filter-tags
-                          'help-echo "Tags used in filtering"))
-               "")
+                          'help-echo "Tags used in filtering")) "")
+             (if (or org-agenda-regexp-filter
+                     (get 'org-agenda-regexp-filter :preset-filter))
+                 '(:eval (org-propertize
+                          (concat " ["
+                                  (mapconcat
+                                   'identity
+                                   (append
+                                    (get 'org-agenda-regexp-filter :preset-filter)
+                                    org-agenda-regexp-filter)
+                                   "")
+                                  "]")
+                          'face 'org-agenda-filter-regexp
+                          'help-echo "Regexp used in filtering")) "")
              (if org-agenda-archives-mode
                  (if (eq org-agenda-archives-mode t)
                      " Archives"
@@ -7734,7 +8406,7 @@ Point is in the buffer where the item originated.")
            (if (and confirm
                     (not (y-or-n-p "Archive this subtree or entry? ")))
                (error "Abort")
-             (save-excursion
+             (save-window-excursion
                (goto-char pos)
                (let ((org-agenda-buffer-name bufname-orig))
                  (org-remove-subtree-entries-from-agenda))
@@ -7768,10 +8440,19 @@ If this information is not given, the function uses the tree at point."
          (beginning-of-line 0))))))
 
 (defun org-agenda-refile (&optional goto rfloc no-update)
-  "Refile the item at point."
+  "Refile the item at point.
+
+When GOTO is 0 or '(64), clear the refile cache.
+When GOTO is '(16), go to the location of the last refiled item.
+RFLOC can be a refile location obtained in a different way.
+When NO-UPDATE is non-nil, don't redo the agenda buffer."
   (interactive "P")
-  (if (equal goto '(16))
-      (org-refile-goto-last-stored)
+  (cond
+   ((member goto '(0 (64)))
+    (org-refile-cache-clear))
+   ((equal goto '(16))
+    (org-refile-goto-last-stored))
+   (t
     (let* ((buffer-orig (buffer-name))
           (marker (or (org-get-at-bol 'org-hd-marker)
                       (org-agenda-error)))
@@ -7789,7 +8470,7 @@ If this information is not given, the function uses the tree at point."
            (let ((org-agenda-buffer-name buffer-orig))
              (org-remove-subtree-entries-from-agenda))
            (org-refile goto buffer rfloc)))))
-    (unless no-update (org-agenda-redo))))
+    (unless no-update (org-agenda-redo)))))
 
 (defun org-agenda-open-link (&optional arg)
   "Open the link(s) in the current entry, if any.
@@ -8147,7 +8828,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
                    (save-excursion (save-restriction (widen)
                                                      (goto-char hdmarker)
                                                      (org-get-tags-at)))))
-        props m pl undone-face done-face finish new dotime cat tags)
+        props m pl undone-face done-face finish new dotime level cat tags)
     (save-excursion
       (goto-char (point-max))
       (beginning-of-line 1)
@@ -8159,6 +8840,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
          (setq props (text-properties-at (point))
                dotime (org-get-at-bol 'dotime)
                cat (org-get-at-bol 'org-category)
+               level (org-get-at-bol 'level)
                tags thetags
                new
                (let ((org-prefix-format-compiled
@@ -8169,7 +8851,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
                    (save-excursion
                      (save-restriction
                        (widen)
-                       (org-agenda-format-item extra newhead cat tags dotime)))))
+                       (org-agenda-format-item extra newhead level cat tags dotime)))))
                pl (text-property-any (point-at-bol) (point-at-eol) 'org-heading t)
                undone-face (org-get-at-bol 'undone-face)
                done-face (org-get-at-bol 'done-face))
@@ -8472,7 +9154,7 @@ Called with a universal prefix arg, show the priority instead of setting it."
       (goto-char (point-max))
       (while (not (bobp))
        (when (equal marker (org-get-at-bol 'org-marker))
-         (org-move-to-column (- (window-width) (length stamp)) t)
+         (org-move-to-column (- (window-width) (length stamp)) t nil t)
          (org-agenda-fix-tags-filter-overlays-at (point))
           (if (featurep 'xemacs)
              ;; Use `duplicable' property to trigger undo recording
@@ -8560,9 +9242,9 @@ ARG is passed through to `org-deadline'."
       (org-clock-in arg)
     (let* ((marker (or (org-get-at-bol 'org-marker)
                       (org-agenda-error)))
-          (hdmarker (or (org-get-at-bol 'org-hd-marker)
-                        marker))
+          (hdmarker (or (org-get-at-bol 'org-hd-marker) marker))
           (pos (marker-position marker))
+          (col (current-column))
           newhead)
       (org-with-remote-undo (marker-buffer marker)
         (with-current-buffer (marker-buffer marker)
@@ -8573,14 +9255,15 @@ ARG is passed through to `org-deadline'."
          (org-cycle-hide-drawers 'children)
          (org-clock-in arg)
          (setq newhead (org-get-heading)))
-       (org-agenda-change-all-lines newhead hdmarker)))))
+       (org-agenda-change-all-lines newhead hdmarker))
+      (org-move-to-column col))))
 
 (defun org-agenda-clock-out ()
   "Stop the currently running clock."
   (interactive)
   (unless (marker-buffer org-clock-marker)
     (error "No running clock"))
-  (let ((marker (make-marker)) newhead)
+  (let ((marker (make-marker)) (col (current-column)) newhead)
     (org-with-remote-undo (marker-buffer org-clock-marker)
       (with-current-buffer (marker-buffer org-clock-marker)
        (save-excursion
@@ -8592,13 +9275,15 @@ ARG is passed through to `org-deadline'."
            (org-clock-out)
            (setq newhead (org-get-heading))))))
     (org-agenda-change-all-lines newhead marker)
-    (move-marker marker nil)))
+    (move-marker marker nil)
+    (org-move-to-column col)
+    (org-agenda-unmark-clocking-task)))
 
 (defun org-agenda-clock-cancel (&optional arg)
   "Cancel the currently running clock."
   (interactive "P")
   (unless (marker-buffer org-clock-marker)
-    (error "No running clock"))
+    (user-error "No running clock"))
   (org-with-remote-undo (marker-buffer org-clock-marker)
     (org-clock-cancel)))
 
@@ -8626,7 +9311,7 @@ buffer, display it in another window."
        (setq d1 (calendar-cursor-to-date t)
              d2 (car calendar-mark-ring))
       (setq dp1 (get-text-property (point-at-bol) 'day))
-      (unless dp1 (error "No date defined in current line"))
+      (unless dp1 (user-error "No date defined in current line"))
       (setq d1 (calendar-gregorian-from-absolute dp1)
            d2 (and (ignore-errors (mark))
                    (save-excursion
@@ -8650,7 +9335,7 @@ buffer, display it in another window."
      ((equal char ?b)
       (setq text (read-string "Block entry: "))
       (unless (and d1 d2 (not (equal d1 d2)))
-       (error "No block of days selected"))
+       (user-error "No block of days selected"))
       (org-agenda-add-entry-to-org-agenda-diary-file 'block text d1 d2)
       (and (equal (buffer-name) org-agenda-buffer-name) (org-agenda-redo)))
      ((equal char ?j)
@@ -8659,7 +9344,7 @@ buffer, display it in another window."
       (require 'org-datetree)
       (org-datetree-find-date-create d1)
       (org-reveal t))
-     (t (error "Invalid selection character `%c'" char)))))
+     (t (user-error "Invalid selection character `%c'" char)))))
 
 (defcustom org-agenda-insert-diary-strategy 'date-tree
   "Where in `org-agenda-diary-file' should new entries be added?
@@ -8717,7 +9402,7 @@ the resulting entry will not be shown.  When TEXT is empty, switch to
            ;; Use org-agenda-format-item to parse text for a time-range and
            ;; remove it.  FIXME: This is a hack, we should refactor
            ;; that function to make time extraction available separately
-           (setq fmt (org-agenda-format-item nil text nil nil t)
+           (setq fmt (org-agenda-format-item nil text nil nil nil t)
                  time (get-text-property 0 'time fmt)
                  time2 (if (> (length time) 0)
                            ;; split-string removes trailing ...... if
@@ -8819,11 +9504,11 @@ entries in that Org-mode file."
           (point (point))
           (mark (or (mark t) (point))))
       (unless cmd
-       (error "No command associated with <%c>" char))
+       (user-error "No command associated with <%c>" char))
       (unless (and (get-text-property point 'day)
                   (or (not (equal ?b char))
                       (get-text-property mark 'day)))
-       (error "Don't know which date to use for diary entry"))
+       (user-error "Don't know which date to use for diary entry"))
       ;; We implement this by hacking the `calendar-cursor-to-date' function
       ;; and the `calendar-mark-ring' variable.  Saves a lot of code.
       (let ((calendar-mark-ring
@@ -8844,7 +9529,7 @@ entries in that Org-mode file."
   (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (unless (get-text-property (min (1- (point-max)) (point)) 'day)
-    (error "Don't know which date to use for the calendar command"))
+    (user-error "Don't know which date to use for the calendar command"))
   (let* ((oldf (symbol-function 'calendar-cursor-to-date))
         (point (point))
         (date (calendar-gregorian-from-absolute
@@ -8893,7 +9578,7 @@ argument, latitude and longitude will be prompted for."
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (let* ((day (or (get-text-property (min (1- (point-max)) (point)) 'day)
-                 (error "Don't know which date to open in calendar")))
+                 (user-error "Don't know which date to open in calendar")))
         (date (calendar-gregorian-from-absolute day))
         (calendar-move-hook nil)
         (calendar-view-holidays-initially-flag nil)
@@ -8916,7 +9601,7 @@ This is a command that has to be installed in `calendar-mode-map'."
   (let ((day (get-text-property (min (1- (point-max)) (point)) 'day))
        date s)
     (unless day
-      (error "Don't know which date to convert"))
+      (user-error "Don't know which date to convert"))
     (setq date (calendar-gregorian-from-absolute day))
     (setq s (concat
             "Gregorian:  " (calendar-date-string date) "\n"
@@ -8952,14 +9637,17 @@ This is a command that has to be installed in `calendar-mode-map'."
       (let* ((m (org-get-at-bol 'org-hd-marker))
             ov)
        (unless (org-agenda-bulk-marked-p)
-         (unless m (error "Nothing to mark at point"))
+         (unless m (user-error "Nothing to mark at point"))
          (push m org-agenda-bulk-marked-entries)
          (setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol))))
          (org-overlay-display ov (concat org-agenda-bulk-mark-char " ")
                               (org-get-todo-face "TODO")
                               'evaporate)
          (overlay-put ov 'type 'org-marked-entry-overlay))
-       (beginning-of-line 2)
+       (end-of-line 1)
+       (or (ignore-errors
+             (goto-char (next-single-property-change (point) 'txt)))
+           (beginning-of-line 2))
        (while (and (get-char-property (point) 'invisible) (not (eobp)))
          (beginning-of-line 2))
        (message "%d entries marked for bulk action"
@@ -8973,12 +9661,13 @@ This is a command that has to be installed in `calendar-mode-map'."
 (defun org-agenda-bulk-mark-regexp (regexp)
   "Mark entries matching REGEXP for future agenda bulk action."
   (interactive "sMark entries matching regexp: ")
-  (let ((entries-marked 0))
+  (let ((entries-marked 0) txt-at-point)
     (save-excursion
       (goto-char (point-min))
       (goto-char (next-single-property-change (point) 'txt))
-      (while (re-search-forward regexp nil t)
-       (when (string-match regexp (get-text-property (point) 'txt))
+      (while (and (re-search-forward regexp nil t)
+                 (setq txt-at-point (get-text-property (point) 'txt)))
+       (when (string-match regexp txt-at-point)
          (setq entries-marked (1+ entries-marked))
          (call-interactively 'org-agenda-bulk-mark))))
     (if (not entries-marked)
@@ -8995,15 +9684,27 @@ This is a command that has to be installed in `calendar-mode-map'."
           (setq org-agenda-bulk-marked-entries
                 (delete (org-get-at-bol 'org-hd-marker)
                         org-agenda-bulk-marked-entries))
-          (beginning-of-line 2)
+          (end-of-line 1)
+          (or (ignore-errors
+                (goto-char (next-single-property-change (point) 'txt)))
+              (beginning-of-line 2))
           (while (and (get-char-property (point) 'invisible) (not (eobp)))
             (beginning-of-line 2))
           (message "%d entries left marked for bulk action"
                    (length org-agenda-bulk-marked-entries)))
          (t (message "No entry to unmark here")))))
 
+(defun org-agenda-bulk-toggle-all ()
+  "Toggle all marks for bulk action."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (while (ignore-errors
+            (goto-char (next-single-property-change (point) 'txt)))
+      (org-agenda-bulk-toggle))))
+
 (defun org-agenda-bulk-toggle ()
-  "Toggle marking the entry at point for bulk action."
+  "Toggle the mark at point for bulk action."
   (interactive)
   (if (org-agenda-bulk-marked-p)
       (org-agenda-bulk-unmark)
@@ -9044,14 +9745,14 @@ bulk action."
 The prefix arg is passed through to the command if possible."
   (interactive "P")
   ;; Make sure we have markers, and only valid ones
-  (unless org-agenda-bulk-marked-entries (error "No entries are marked"))
+  (unless org-agenda-bulk-marked-entries (user-error "No entries are marked"))
   (mapc
    (lambda (m)
      (unless (and (markerp m)
                  (marker-buffer m)
                  (buffer-live-p (marker-buffer m))
                  (marker-position m))
-       (error "Marker %s for bulk command is invalid" m)))
+       (user-error "Marker %s for bulk command is invalid" m)))
    org-agenda-bulk-marked-entries)
 
   ;; Prompt for the bulk command
@@ -9130,7 +9831,7 @@ The prefix arg is passed through to the command if possible."
 
         ((equal action ?S)
          (if (not (org-agenda-check-type nil 'agenda 'timeline 'todo))
-             (error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type)
+             (user-error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type)
            (let ((days (read-number
                         (format "Scatter tasks across how many %sdays: "
                                 (if arg "week" "")) 7)))
@@ -9168,7 +9869,7 @@ The prefix arg is passed through to the command if possible."
                           (org-icompleting-read "Function: "
                                                 obarray 'fboundp t nil nil)))))
 
-        (t (error "Invalid bulk action")))
+        (t (user-error "Invalid bulk action")))
 
        ;; Sort the markers, to make sure that parents are handled before children
        (setq entries (sort entries
@@ -9202,15 +9903,45 @@ The prefix arg is passed through to the command if possible."
                 (if (not org-agenda-persistent-marks)
                     "" " (kept marked)"))))))
 
-(defun org-agenda-capture ()
-  "Call `org-capture' with the date at point."
-  (interactive)
+(defun org-agenda-capture (&optional with-time)
+  "Call `org-capture' with the date at point.
+With a `C-1' prefix, use the HH:MM value at point (if any) or the
+current HH:MM time."
+  (interactive "P")
   (if (not (eq major-mode 'org-agenda-mode))
-      (error "You cannot do this outside of agenda buffers")
+      (user-error "You cannot do this outside of agenda buffers")
     (let ((org-overriding-default-time
-          (org-get-cursor-date)))
+          (org-get-cursor-date (equal with-time 1))))
       (call-interactively 'org-capture))))
 
+;;; Dragging agenda lines forward/backward
+
+(defun org-agenda-drag-line-forward (arg)
+  "Drag an agenda line forward by ARG lines."
+  (interactive "p")
+  (let ((inhibit-read-only t) lst)
+    (if (or (not (get-text-property (point) 'txt))
+           (save-excursion
+             (dotimes (n arg)
+               (move-beginning-of-line 2)
+               (push (not (get-text-property (point) 'txt)) lst))
+             (delq nil lst)))
+       (message "Cannot move line forward")
+      (org-drag-line-forward arg))))
+
+(defun org-agenda-drag-line-backward (arg)
+  "Drag an agenda line backward by ARG lines."
+  (interactive "p")
+  (let ((inhibit-read-only t) lst)
+    (if (or (not (get-text-property (point) 'txt))
+           (save-excursion
+             (dotimes (n arg)
+               (move-beginning-of-line 0)
+               (push (not (get-text-property (point) 'txt)) lst))
+             (delq nil lst)))
+       (message "Cannot move line backward")
+      (org-drag-line-backward arg))))
+
 ;;; Flagging notes
 
 (defun org-agenda-show-the-flagging-note ()
@@ -9222,7 +9953,7 @@ tag and (if present) the flagging note."
        (win (selected-window))
        note heading newhead)
     (unless hdmarker
-      (error "No linked entry at point"))
+      (user-error "No linked entry at point"))
     (if (and (eq this-command last-command)
             (y-or-n-p "Unflag and remove any flagging note? "))
        (progn
@@ -9232,7 +9963,7 @@ tag and (if present) the flagging note."
          (message "Entry unflagged"))
       (setq note (org-entry-get hdmarker "THEFLAGGINGNOTE"))
       (unless note
-       (error "No flagging note"))
+       (user-error "No flagging note"))
       (org-kill-new note)
       (org-switch-to-buffer-other-window "*Flagging Note*")
       (erase-buffer)
@@ -9288,7 +10019,8 @@ will only add headlines containing IMPORTANT or headlines
 belonging to the \"Work\" category.
 
 ARGS are symbols indicating what kind of entries to consider.
-By default `org-agenda-to-appt' will use :deadline, :scheduled
+By default `org-agenda-to-appt' will use :deadline*, :scheduled*
+\(i.e., deadlines and scheduled items with a hh:mm specification)
 and :timestamp entries.  See the docstring of `org-diary' for
 details and examples.
 
@@ -9299,7 +10031,7 @@ to override `appt-message-warning-time'."
   (if (eq filter t)
       (setq filter (read-from-minibuffer "Regexp filter: ")))
   (let* ((cnt 0) ; count added events
-        (scope (or args '(:deadline :scheduled :timestamp)))
+        (scope (or args '(:deadline* :scheduled* :timestamp)))
         (org-agenda-new-buffers nil)
         (org-deadline-warning-days 0)
         ;; Do not use `org-today' here because appt only takes
@@ -9321,7 +10053,10 @@ to override `appt-message-warning-time'."
     ;; Map thru entries and find if we should filter them out
     (mapc
      (lambda(x)
-       (let* ((evt (org-trim (or (get-text-property 1 'txt x) "")))
+       (let* ((evt (org-trim
+                   (replace-regexp-in-string
+                    org-bracket-link-regexp "\\3"
+                    (or (get-text-property 1 'txt x) ""))))
              (cat (get-text-property 1 'org-category x))
              (tod (get-text-property 1 'time-of-day x))
              (ok (or (null filter)
index 2fcfc8634fe68b8c48dd769081e6a7555f20d570..d5bdff16f9bbbc79b08e5c1c05950b34ce657443 100644 (file)
@@ -71,6 +71,15 @@ This variable is obsolete and has no effect anymore, instead add or remove
   :group 'org-archive
   :type 'boolean)
 
+(defcustom org-archive-file-header-format "\nArchived entries from file %s\n\n"
+  "The header format string for newly created archive files.
+When nil, no header will be inserted.
+When a string, a %s formatter will be replaced by the file name."
+  :group 'org-archive
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
 (defcustom org-archive-subtree-add-inherited-tags 'infile
   "Non-nil means append inherited tags when archiving a subtree."
   :group 'org-archive
@@ -278,9 +287,9 @@ this heading."
              (let ((org-insert-mode-line-in-empty-file t)
                    (org-inhibit-startup t))
                (call-interactively 'org-mode)))
-         (when newfile-p
+         (when (and newfile-p org-archive-file-header-format)
            (goto-char (point-max))
-           (insert (format "\nArchived entries from file %s\n\n"
+           (insert (format org-archive-file-header-format
                            (buffer-file-name this-buffer))))
          (when datetree-date
            (require 'org-datetree)
diff --git a/lisp/org/org-ascii.el b/lisp/org/org-ascii.el
deleted file mode 100644 (file)
index c5a4b37..0000000
+++ /dev/null
@@ -1,730 +0,0 @@
-;;; org-ascii.el --- ASCII export for Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;;; Code:
-
-(require 'org-exp)
-
-(eval-when-compile
-  (require 'cl))
-
-(defgroup org-export-ascii nil
-  "Options specific for ASCII export of Org-mode files."
-  :tag "Org Export ASCII"
-  :group 'org-export)
-
-(defcustom org-export-ascii-underline '(?\= ?\- ?\~ ?\^ ?\. ?\# ?\$)
-  "Characters for underlining headings in ASCII export.
-In the given sequence, these characters will be used for level 1, 2, ..."
-  :group 'org-export-ascii
-  :type '(repeat character))
-
-(defcustom org-export-ascii-bullets '(?* ?+ ?-)
-  "Bullet characters for headlines converted to lists in ASCII export.
-The first character is used for the first lest level generated in this
-way, and so on.  If there are more levels than characters given here,
-the list will be repeated.
-Note that plain lists will keep the same bullets as the have in the
-Org-mode file."
-  :group 'org-export-ascii
-  :type '(repeat character))
-
-(defcustom org-export-ascii-links-to-notes t
-  "Non-nil means convert links to notes before the next headline.
-When nil, the link will be exported in place.  If the line becomes long
-in this way, it will be wrapped."
-  :group 'org-export-ascii
-  :type 'boolean)
-
-(defcustom org-export-ascii-table-keep-all-vertical-lines nil
-  "Non-nil means keep all vertical lines in ASCII tables.
-When nil, vertical lines will be removed except for those needed
-for column grouping."
-  :group 'org-export-ascii
-  :type 'boolean)
-
-(defcustom org-export-ascii-table-widen-columns t
-  "Non-nil means widen narrowed columns for export.
-When nil, narrowed columns will look in ASCII export just like in org-mode,
-i.e. with \"=>\" as ellipsis."
-  :group 'org-export-ascii
-  :type 'boolean)
-
-(defvar org-export-ascii-entities 'ascii
-  "The ascii representation to be used during ascii export.
-Possible values are:
-
-ascii     Only use plain ASCII characters
-latin1    Include Latin-1 character
-utf8      Use all UTF-8 characters")
-
-;;; Hooks
-
-(defvar org-export-ascii-final-hook nil
-  "Hook run at the end of ASCII export, in the new buffer.")
-
-;;; ASCII export
-
-(defvar org-ascii-current-indentation nil) ; For communication
-
-;;;###autoload
-(defun org-export-as-latin1 (&rest args)
-  "Like `org-export-as-ascii', use latin1 encoding for special symbols."
-  (interactive)
-  (org-export-as-encoding 'org-export-as-ascii (org-called-interactively-p 'any)
-                         'latin1 args))
-
-;;;###autoload
-(defun org-export-as-latin1-to-buffer (&rest args)
-  "Like `org-export-as-ascii-to-buffer', use latin1 encoding for symbols."
-  (interactive)
-  (org-export-as-encoding 'org-export-as-ascii-to-buffer
-                         (org-called-interactively-p 'any) 'latin1 args))
-
-;;;###autoload
-(defun org-export-as-utf8 (&rest args)
-  "Like `org-export-as-ascii', use encoding for special symbols."
-  (interactive)
-  (org-export-as-encoding 'org-export-as-ascii
-                         (org-called-interactively-p 'any)
-                         'utf8 args))
-
-;;;###autoload
-(defun org-export-as-utf8-to-buffer (&rest args)
-  "Like `org-export-as-ascii-to-buffer', use utf8 encoding for symbols."
-  (interactive)
-  (org-export-as-encoding 'org-export-as-ascii-to-buffer
-                         (org-called-interactively-p 'any) 'utf8 args))
-
-(defun org-export-as-encoding (command interactivep encoding &rest args)
-  (let ((org-export-ascii-entities encoding))
-    (if interactivep
-       (call-interactively command)
-      (apply command args))))
-
-
-;;;###autoload
-(defun org-export-as-ascii-to-buffer (arg)
-  "Call `org-export-as-ascii` with output to a temporary buffer.
-No file is created.  The prefix ARG is passed through to `org-export-as-ascii'."
-  (interactive "P")
-  (org-export-as-ascii arg nil "*Org ASCII Export*")
-  (when org-export-show-temporary-export-buffer
-    (switch-to-buffer-other-window "*Org ASCII Export*")))
-
-;;;###autoload
-(defun org-replace-region-by-ascii (beg end)
-  "Assume the current region has org-mode syntax, and convert it to plain ASCII.
-This can be used in any buffer.  For example, you could write an
-itemized list in org-mode syntax in a Mail buffer and then use this
-command to convert it."
-  (interactive "r")
-  (let (reg ascii buf pop-up-frames)
-    (save-window-excursion
-      (if (derived-mode-p 'org-mode)
-         (setq ascii (org-export-region-as-ascii
-                      beg end t 'string))
-       (setq reg (buffer-substring beg end)
-             buf (get-buffer-create "*Org tmp*"))
-       (with-current-buffer buf
-         (erase-buffer)
-         (insert reg)
-         (org-mode)
-         (setq ascii (org-export-region-as-ascii
-                      (point-min) (point-max) t 'string)))
-       (kill-buffer buf)))
-    (delete-region beg end)
-    (insert ascii)))
-
-;;;###autoload
-(defun org-export-region-as-ascii (beg end &optional body-only buffer)
-  "Convert region from BEG to END in org-mode buffer to plain ASCII.
-If prefix arg BODY-ONLY is set, omit file header, footer, and table of
-contents, and only produce the region of converted text, useful for
-cut-and-paste operations.
-If BUFFER is a buffer or a string, use/create that buffer as a target
-of the converted ASCII.  If BUFFER is the symbol `string', return the
-produced ASCII as a string and leave not buffer behind.  For example,
-a Lisp program could call this function in the following way:
-
-  (setq ascii (org-export-region-as-ascii beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (interactive "r\nP")
-  (when (org-called-interactively-p 'any)
-    (setq buffer "*Org ASCII Export*"))
-  (let ((transient-mark-mode t) (zmacs-regions t)
-       ext-plist rtn)
-    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
-    (goto-char end)
-    (set-mark (point)) ;; to activate the region
-    (goto-char beg)
-    (setq rtn (org-export-as-ascii nil ext-plist buffer body-only))
-    (if (fboundp 'deactivate-mark) (deactivate-mark))
-    (if (and (org-called-interactively-p 'any) (bufferp rtn))
-       (switch-to-buffer-other-window rtn)
-      rtn)))
-
-;;;###autoload
-(defun org-export-as-ascii (arg &optional ext-plist to-buffer body-only pub-dir)
-  "Export the outline as a pretty ASCII file.
-If there is an active region, export only the region.
-The prefix ARG specifies how many levels of the outline should become
-underlined headlines, default is 3.    Lower levels will become bulleted
-lists.  EXT-PLIST is a property list with external parameters overriding
-org-mode's default settings, but still inferior to file-local
-settings.  When TO-BUFFER is non-nil, create a buffer with that
-name and export to that buffer.  If TO-BUFFER is the symbol
-`string', don't leave any buffer behind but just return the
-resulting ASCII as a string.  When BODY-ONLY is set, don't produce
-the file header and footer.  When PUB-DIR is set, use this as the
-publishing directory."
-  (interactive "P")
-  (run-hooks 'org-export-first-hook)
-  (setq-default org-todo-line-regexp org-todo-line-regexp)
-  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
-                                       ext-plist
-                                       (org-infile-export-plist)))
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (level-offset (if subtree-p
-                          (save-excursion
-                            (goto-char rbeg)
-                            (+ (funcall outline-level)
-                               (if org-odd-levels-only 1 0)))
-                        0))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        ;; The following two are dynamically scoped into other
-        ;; routines below.
-        (org-current-export-dir
-         (or pub-dir (org-export-directory :html opt-plist)))
-        (org-current-export-file buffer-file-name)
-        (custom-times org-display-custom-times)
-        (org-ascii-current-indentation '(0 . 0))
-        (level 0) line txt
-        (umax nil)
-        (umax-toc nil)
-        (case-fold-search nil)
-        (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
-        (filename (if to-buffer
-                      nil
-                    (concat (file-name-as-directory
-                             (or pub-dir
-                                 (org-export-directory :ascii opt-plist)))
-                            (file-name-sans-extension
-                             (or (and subtree-p
-                                      (org-entry-get (region-beginning)
-                                                     "EXPORT_FILE_NAME" t))
-                                 (file-name-nondirectory bfname)))
-                            ".txt")))
-        (filename (and filename
-                       (if (equal (file-truename filename)
-                                  (file-truename bfname))
-                           (concat filename ".txt")
-                         filename)))
-        (buffer (if to-buffer
-                    (cond
-                     ((eq to-buffer 'string)
-                      (get-buffer-create "*Org ASCII Export*"))
-                     (t (get-buffer-create to-buffer)))
-                  (find-file-noselect filename)))
-        (org-levels-open (make-vector org-level-max nil))
-        (odd org-odd-levels-only)
-        (date  (plist-get opt-plist :date))
-        (author (plist-get opt-plist :author))
-        (title (or (and subtree-p (org-export-get-title-from-subtree))
-                   (plist-get opt-plist :title)
-                   (and (not
-                         (plist-get opt-plist :skip-before-1st-heading))
-                        (org-export-grab-title-from-buffer))
-                   (and (buffer-file-name)
-                        (file-name-sans-extension
-                         (file-name-nondirectory bfname)))
-                   "UNTITLED"))
-        (email (plist-get opt-plist :email))
-        (language (plist-get opt-plist :language))
-        (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)"))
-        (todo nil)
-        (lang-words nil)
-        (region
-         (buffer-substring
-          (if (org-region-active-p) (region-beginning) (point-min))
-          (if (org-region-active-p) (region-end) (point-max))))
-        (org-export-footnotes-seen nil)
-        (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
-        (lines (org-split-string
-                (org-export-preprocess-string
-                 region
-                 :for-backend 'ascii
-                 :skip-before-1st-heading
-                 (plist-get opt-plist :skip-before-1st-heading)
-                 :drawers (plist-get opt-plist :drawers)
-                 :tags (plist-get opt-plist :tags)
-                 :priority (plist-get opt-plist :priority)
-                 :footnotes (plist-get opt-plist :footnotes)
-                 :timestamps (plist-get opt-plist :timestamps)
-                 :todo-keywords (plist-get opt-plist :todo-keywords)
-                 :tasks (plist-get opt-plist :tasks)
-                 :verbatim-multiline t
-                 :select-tags (plist-get opt-plist :select-tags)
-                 :exclude-tags (plist-get opt-plist :exclude-tags)
-                 :archived-trees
-                 (plist-get opt-plist :archived-trees)
-                 :add-text (plist-get opt-plist :text))
-                "\n"))
-        thetoc have-headings first-heading-pos
-        table-open table-buffer link-buffer link type path desc desc0 rpl wrap fnc)
-    (let ((inhibit-read-only t))
-      (org-unmodified
-       (remove-text-properties (point-min) (point-max)
-                              '(:org-license-to-kill t))))
-
-    (setq org-min-level (org-get-min-level lines level-offset))
-    (setq org-last-level org-min-level)
-    (org-init-section-numbers)
-    (setq lang-words (or (assoc language org-export-language-setup)
-                        (assoc "en" org-export-language-setup)))
-    (set-buffer buffer)
-    (erase-buffer)
-    (fundamental-mode)
-    (org-install-letbind)
-    ;; create local variables for all options, to make sure all called
-    ;; functions get the correct information
-    (mapc (lambda (x)
-           (set (make-local-variable (nth 2 x))
-                (plist-get opt-plist (car x))))
-         org-export-plist-vars)
-    (org-set-local 'org-odd-levels-only odd)
-    (setq umax (if arg (prefix-numeric-value arg)
-                org-export-headline-levels))
-    (setq umax-toc (if (integerp org-export-with-toc)
-                      (min org-export-with-toc umax)
-                    umax))
-
-    ;; File header
-    (unless body-only
-      (when (and title (not (string= "" title)))
-       (org-insert-centered title ?=)
-       (insert "\n"))
-
-      (if (and (or author email)
-              org-export-author-info)
-         (insert (concat (nth 1 lang-words) ": " (or author "")
-                         (if (and org-export-email-info
-                                  email (string-match "\\S-" email))
-                             (concat " <" email ">") "")
-                         "\n")))
-
-      (cond
-       ((and date (string-match "%" date))
-       (setq date (format-time-string date)))
-       (date)
-       (t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
-
-      (if (and date org-export-time-stamp-file)
-         (insert (concat (nth 2 lang-words) ": " date"\n")))
-
-      (unless (= (point) (point-min))
-       (insert "\n\n")))
-
-    (if (and org-export-with-toc (not body-only))
-       (progn
-         (push (concat (nth 3 lang-words) "\n") thetoc)
-         (push (concat (make-string (string-width (nth 3 lang-words)) ?=)
-                       "\n") thetoc)
-         (mapc #'(lambda (line)
-                   (if (string-match org-todo-line-regexp
-                                     line)
-                       ;; This is a headline
-                       (progn
-                         (setq have-headings t)
-                         (setq level (- (match-end 1) (match-beginning 1)
-                                        level-offset)
-                               level (org-tr-level level)
-                               txt (match-string 3 line)
-                               todo
-                               (or (and org-export-mark-todo-in-toc
-                                        (match-beginning 2)
-                                        (not (member (match-string 2 line)
-                                                     org-done-keywords)))
-                                       ; TODO, not DONE
-                                   (and org-export-mark-todo-in-toc
-                                        (= level umax-toc)
-                                        (org-search-todo-below
-                                         line lines level))))
-                         (setq txt (org-html-expand-for-ascii txt))
-
-                         (while (string-match org-bracket-link-regexp txt)
-                           (setq txt
-                                 (replace-match
-                                  (match-string (if (match-end 2) 3 1) txt)
-                                  t t txt)))
-
-                         (if (and (memq org-export-with-tags '(not-in-toc nil))
-                                  (string-match
-                                   (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
-                                   txt))
-                             (setq txt (replace-match "" t t txt)))
-                         (if (string-match quote-re0 txt)
-                             (setq txt (replace-match "" t t txt 1)))
-
-                         (if org-export-with-section-numbers
-                             (setq txt (concat (org-section-number level)
-                                               " " txt)))
-                         (if (<= level umax-toc)
-                             (progn
-                               (push
-                                (concat
-                                 (make-string
-                                  (* (max 0 (- level org-min-level)) 4) ?\ )
-                                 (format (if todo "%s (*)\n" "%s\n") txt))
-                                thetoc)
-                               (setq org-last-level level))
-                           ))))
-               lines)
-         (setq thetoc (if have-headings (nreverse thetoc) nil))))
-
-    (org-init-section-numbers)
-    (while (setq line (pop lines))
-      (when (and link-buffer (string-match org-outline-regexp-bol line))
-       (org-export-ascii-push-links (nreverse link-buffer))
-       (setq link-buffer nil))
-      (setq wrap nil)
-      ;; Remove the quoted HTML tags.
-      (setq line (org-html-expand-for-ascii line))
-      ;; Replace links with the description when possible
-      (while (string-match org-bracket-link-analytic-regexp++ line)
-       (setq path (match-string 3 line)
-             link (concat (match-string 1 line) path)
-             type (match-string 2 line)
-             desc0 (match-string 5 line)
-             desc0 (replace-regexp-in-string "\\\\_" "_" desc0)
-             desc (or desc0 link)
-             desc (replace-regexp-in-string "\\\\_" "_" desc))
-       (if (and (> (length link) 8)
-                (equal (substring link 0 8) "coderef:"))
-           (setq line (replace-match
-                       (format (org-export-get-coderef-format (substring link 8) desc)
-                               (cdr (assoc
-                                     (substring link 8)
-                                     org-export-code-refs)))
-                       t t line))
-         (setq rpl (concat "[" desc "]"))
-         (if (functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
-             (setq rpl (or (save-match-data
-                             (funcall fnc (org-link-unescape path)
-                                      desc0 'ascii))
-                           rpl))
-           (when (and desc0 (not (equal desc0 link)))
-             (if org-export-ascii-links-to-notes
-                 (push (cons desc0 link) link-buffer)
-               (setq rpl (concat rpl " (" link ")")
-                     wrap (+ (length line) (- (length (match-string 0 line)))
-                             (length desc))))))
-         (setq line (replace-match rpl t t line))))
-      (when custom-times
-       (setq line (org-translate-time line)))
-      (cond
-       ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
-       ;; a Headline
-       (setq first-heading-pos (or first-heading-pos (point)))
-       (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
-                                    level-offset))
-             txt (match-string 2 line))
-       (org-ascii-level-start level txt umax lines))
-
-       ((and org-export-with-tables
-            (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
-       (if (not table-open)
-           ;; New table starts
-           (setq table-open t table-buffer nil))
-       ;; Accumulate lines
-       (setq table-buffer (cons line table-buffer))
-       (when (or (not lines)
-                 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
-                                    (car lines))))
-         (setq table-open nil
-               table-buffer (nreverse table-buffer))
-         (insert (mapconcat
-                  (lambda (x)
-                    (org-fix-indentation x org-ascii-current-indentation))
-                  (org-format-table-ascii table-buffer)
-                  "\n") "\n")))
-       (t
-       (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)"
-                         line)
-           (setq line (replace-match "\\1\\3:" t nil line)))
-       (setq line (org-fix-indentation line org-ascii-current-indentation))
-       ;; Remove forced line breaks
-       (if (string-match "\\\\\\\\[ \t]*$" line)
-           (setq line (replace-match "" t t line)))
-       (if (and org-export-with-fixed-width
-                (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line))
-           (setq line (replace-match "\\1" nil nil line))
-         (if wrap (setq line (org-export-ascii-wrap line wrap))))
-       (insert line "\n"))))
-
-    (org-export-ascii-push-links (nreverse link-buffer))
-
-    (normal-mode)
-
-    ;; insert the table of contents
-    (when thetoc
-      (goto-char (point-min))
-      (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t)
-         (progn
-           (goto-char (match-beginning 0))
-           (replace-match ""))
-       (goto-char first-heading-pos))
-      (mapc 'insert thetoc)
-      (or (looking-at "[ \t]*\n[ \t]*\n")
-         (insert "\n\n")))
-
-    ;; Convert whitespace place holders
-    (goto-char (point-min))
-    (let (beg end)
-      (while (setq beg (next-single-property-change (point) 'org-whitespace))
-       (setq end (next-single-property-change beg 'org-whitespace))
-       (goto-char beg)
-       (delete-region beg end)
-       (insert (make-string (- end beg) ?\ ))))
-
-    ;; remove display and invisible chars
-    (let (beg end)
-      (goto-char (point-min))
-      (while (setq beg (next-single-property-change (point) 'display))
-       (setq end (next-single-property-change beg 'display))
-       (delete-region beg end)
-       (goto-char beg)
-       (insert "=>"))
-      (goto-char (point-min))
-      (while (setq beg (next-single-property-change (point) 'org-cwidth))
-       (setq end (next-single-property-change beg 'org-cwidth))
-       (delete-region beg end)
-       (goto-char beg)))
-    (run-hooks 'org-export-ascii-final-hook)
-    (or to-buffer (save-buffer))
-    (goto-char (point-min))
-    (or (org-export-push-to-kill-ring "ASCII")
-       (message "Exporting... done"))
-    ;; Return the buffer or a string, according to how this function was called
-    (if (eq to-buffer 'string)
-       (prog1 (buffer-substring (point-min) (point-max))
-         (kill-buffer (current-buffer)))
-      (current-buffer))))
-
-;;;###autoload
-(defun org-export-ascii-preprocess (parameters)
-  "Do extra work for ASCII export."
-  ;;
-  ;; Realign tables to get rid of narrowing
-  (when org-export-ascii-table-widen-columns
-    (let ((org-table-do-narrow nil))
-      (goto-char (point-min))
-      (org-ascii-replace-entities)
-      (goto-char (point-min))
-      (org-table-map-tables
-       (lambda () (org-if-unprotected (org-table-align)))
-       'quietly)))
-  ;; Put quotes around verbatim text
-  (goto-char (point-min))
-  (while (re-search-forward org-verbatim-re nil t)
-    (org-if-unprotected-at (match-beginning 4)
-      (goto-char (match-end 2))
-      (backward-delete-char 1) (insert "'")
-      (goto-char (match-beginning 2))
-      (delete-char 1) (insert "`")
-      (goto-char (match-end 2))))
-  ;; Remove target markers
-  (goto-char (point-min))
-  (while (re-search-forward  "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t)
-    (org-if-unprotected-at (match-beginning 1)
-      (replace-match "\\1\\2")))
-  ;; Remove list start counters
-  (goto-char (point-min))
-  (while (org-list-search-forward
-         "\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*" nil t)
-    (replace-match ""))
-  (remove-text-properties
-   (point-min) (point-max)
-   '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil)))
-
-(defun org-html-expand-for-ascii (line)
-  "Handle quoted HTML for ASCII export."
-  (if org-export-html-expand
-      (while (string-match "@<[^<>\n]*>" line)
-       ;; We just remove the tags for now.
-       (setq line (replace-match "" nil nil line))))
-  line)
-
-(defun org-ascii-replace-entities ()
-  "Replace entities with the ASCII representation."
-  (let (e)
-    (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t)
-      (org-if-unprotected-at (match-beginning 1)
-       (setq e (org-entity-get-representation (match-string 1)
-                                              org-export-ascii-entities))
-       (and e (replace-match e t t))))))
-
-(defun org-export-ascii-wrap (line where)
-  "Wrap LINE at or before WHERE."
-  (let ((ind (org-get-indentation line))
-       pos)
-    (catch 'found
-      (loop for i from where downto (/ where 2) do
-           (and (equal (aref line i) ?\ )
-                (setq pos i)
-                (throw 'found t))))
-    (if pos
-       (concat (substring line 0 pos) "\n"
-               (make-string ind ?\ )
-               (substring line (1+ pos)))
-      line)))
-
-(defun org-export-ascii-push-links (link-buffer)
-  "Push out links in the buffer."
-  (when link-buffer
-    ;; We still have links to push out.
-    (insert "\n")
-    (let ((ind ""))
-      (save-match-data
-       (if (save-excursion
-             (re-search-backward
-              (concat "^\\(\\([ \t]*\\)\\|\\("
-                      org-outline-regexp
-                      "\\)\\)[^ \t\n]") nil t))
-           (setq ind (or (match-string 2)
-                         (make-string (length (match-string 3)) ?\ )))))
-      (mapc (lambda (x) (insert ind "[" (car x) "]: " (cdr x) "\n"))
-           link-buffer))
-    (insert "\n")))
-
-(defun org-ascii-level-start (level title umax &optional lines)
-  "Insert a new level in ASCII export."
-  (let (char (n (- level umax 1)) (ind 0))
-    (if (> level umax)
-       (progn
-         (insert (make-string (* 2 n) ?\ )
-                 (char-to-string (nth (% n (length org-export-ascii-bullets))
-                                      org-export-ascii-bullets))
-                 " " title "\n")
-         ;; find the indentation of the next non-empty line
-         (catch 'stop
-           (while lines
-             (if (string-match "^\\* " (car lines)) (throw 'stop nil))
-             (if (string-match "^\\([ \t]*\\)\\S-" (car lines))
-                 (throw 'stop (setq ind (org-get-indentation (car lines)))))
-             (pop lines)))
-         (setq org-ascii-current-indentation (cons (* 2 (1+ n)) ind)))
-      (if (or (not (equal (char-before) ?\n))
-             (not (equal (char-before (1- (point))) ?\n)))
-         (insert "\n"))
-      (setq char (or (nth (1- level) org-export-ascii-underline)
-                    (car (last org-export-ascii-underline))))
-      (unless org-export-with-tags
-       (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
-           (setq title (replace-match "" t t title))))
-      (if org-export-with-section-numbers
-         (setq title (concat (org-section-number level) " " title)))
-      (insert title "\n" (make-string (string-width title) char) "\n")
-      (setq org-ascii-current-indentation '(0 . 0)))))
-
-(defun org-insert-centered (s &optional underline)
-  "Insert the string S centered and underline it with character UNDERLINE."
-  (let ((ind (max (/ (- fill-column (string-width s)) 2) 0)))
-    (insert (make-string ind ?\ ) s "\n")
-    (if underline
-       (insert (make-string ind ?\ )
-               (make-string (string-width s) underline)
-               "\n"))))
-
-(defvar org-table-colgroup-info nil)
-(defun org-format-table-ascii (lines)
-  "Format a table for ascii export."
-  (if (stringp lines)
-      (setq lines (org-split-string lines "\n")))
-  (if (not (string-match "^[ \t]*|" (car lines)))
-      ;; Table made by table.el - test for spanning
-      lines
-
-    ;; A normal org table
-    ;; Get rid of hlines at beginning and end
-    (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-    (setq lines (nreverse lines))
-    (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-    (setq lines (nreverse lines))
-    (when org-export-table-remove-special-lines
-      ;; Check if the table has a marking column.  If yes remove the
-      ;; column and the special lines
-      (setq lines (org-table-clean-before-export lines)))
-    ;; Get rid of the vertical lines except for grouping
-    (if org-export-ascii-table-keep-all-vertical-lines
-       lines
-      (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info))
-           rtn line vl1 start)
-       (while (setq line (pop lines))
-         (if (string-match org-table-hline-regexp line)
-             (and (string-match "|\\(.*\\)|" line)
-                  (setq line (replace-match " \\1" t nil line)))
-           (setq start 0 vl1 vl)
-           (while (string-match "|" line start)
-             (setq start (match-end 0))
-             (or (pop vl1) (setq line (replace-match " " t t line)))))
-         (push line rtn))
-       (nreverse rtn)))))
-
-(defun org-colgroup-info-to-vline-list (info)
-  (let (vl new last)
-    (while info
-      (setq last new new (pop info))
-      (if (or (memq last '(:end :startend))
-             (memq new  '(:start :startend)))
-         (push t vl)
-       (push nil vl)))
-    (setq vl (nreverse vl))
-    (and vl (setcar vl nil))
-    vl))
-
-(provide 'org-ascii)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-ascii.el ends here
index 3e665b79da8af702e22abb88f30c3d7c67f742bb..898d9116e77356f701b147f7ae5f4178414b445d 100644 (file)
@@ -42,6 +42,8 @@
 (require 'org-id)
 (require 'org)
 
+(declare-function vc-git-root "vc-git" (file))
+
 (defgroup org-attach nil
   "Options concerning entry attachments in Org-mode."
   :tag "Org Attach"
@@ -54,6 +56,15 @@ where the Org file lives."
   :group 'org-attach
   :type 'directory)
 
+(defcustom org-attach-git-annex-cutoff (* 32 1024)
+  "If non-nil, files larger than this will be annexed instead of stored."
+  :group 'org-attach
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "None" nil)
+         (integer :tag "Bytes")))
+
 (defcustom org-attach-auto-tag "ATTACH"
   "Tag that will be triggered automatically when an entry has an attachment."
   :group 'org-attach
@@ -252,18 +263,32 @@ the ATTACH_DIR property) their own attachment directory."
 (defun org-attach-commit ()
   "Commit changes to git if `org-attach-directory' is properly initialized.
 This checks for the existence of a \".git\" directory in that directory."
-  (let ((dir (expand-file-name org-attach-directory)))
-    (when (file-exists-p (expand-file-name ".git" dir))
+  (let* ((dir (expand-file-name org-attach-directory))
+        (git-dir (vc-git-root dir))
+        (changes 0))
+    (when git-dir
       (with-temp-buffer
        (cd dir)
-       (shell-command "git add .")
-       (shell-command "git ls-files --deleted" t)
-       (mapc #'(lambda (file)
-                 (unless (string= file "")
-                   (shell-command
-                    (concat "git rm \"" file "\""))))
-             (split-string (buffer-string) "\n"))
-       (shell-command "git commit -m 'Synchronized attachments'")))))
+       (let ((have-annex
+              (and org-attach-git-annex-cutoff
+                   (file-exists-p (expand-file-name "annex" git-dir)))))
+         (dolist (new-or-modified
+                  (split-string
+                   (shell-command-to-string
+                    "git ls-files -zmo --exclude-standard") "\0" t))
+           (if (and have-annex
+                    (>= (nth 7 (file-attributes new-or-modified))
+                        org-attach-git-annex-cutoff))
+               (call-process "git" nil nil nil "annex" "add" new-or-modified)
+             (call-process "git" nil nil nil "add" new-or-modified))
+           (incf changes)))
+       (dolist (deleted
+                (split-string
+                 (shell-command-to-string "git ls-files -z --deleted") "\0" t))
+         (call-process "git" nil nil nil "rm" deleted)
+         (incf changes))
+       (when (> changes 0)
+         (shell-command "git commit -m 'Synchronized attachments'"))))))
 
 (defun org-attach-tag (&optional off)
   "Turn the autotag on or (if OFF is set) off."
@@ -405,14 +430,14 @@ This ignores files starting with a \".\", and files ending in \"~\"."
                (directory-files dir nil "[^~]\\'"))))
 
 (defun org-attach-reveal (&optional if-exists)
-  "Show the attachment directory of the current task in dired."
+  "Show the attachment directory of the current task.
+This will attempt to use an external program to show the directory."
   (interactive "P")
   (let ((attach-dir (org-attach-dir (not if-exists))))
     (and attach-dir (org-open-file attach-dir))))
 
 (defun org-attach-reveal-in-emacs ()
-  "Show the attachment directory of the current task.
-This will attempt to use an external program to show the directory."
+  "Show the attachment directory of the current task in dired."
   (interactive)
   (let ((attach-dir (org-attach-dir t)))
     (dired attach-dir)))
index a45a26f0fe843cb3a8d81e0cbbf1d4c08370cb98..f122b67ea1a5c3c185e1392d6fc55faa68690a84 100644 (file)
 (declare-function bbdb-search-name "ext:bbdb-com" (regexp &optional layout))
 (declare-function bbdb-search-organization "ext:bbdb-com" (regexp &optional layout))
 
-;; `bbdb-record-note' is part of BBDB v3.x
+;; `bbdb-record-note' was part of BBDB v3.x
 (declare-function bbdb-record-note "ext:bbdb" (record label))
+;; `bbdb-record-xfield' replaces it in recent BBDB v3.x+
+(declare-function bbdb-record-xfield "ext:bbdb" (record label))
 
 (declare-function calendar-leap-year-p "calendar" (year))
 (declare-function diary-ordinal-suffix "diary-lib" (n))
@@ -306,14 +308,17 @@ The hash table is created on first use.")
   "Create a hash with anniversaries extracted from BBDB, for fast access.
 The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
   (let ((old-bbdb (fboundp 'bbdb-record-getprop))
+       (record-func (if (fboundp 'bbdb-record-xfield)
+                        'bbdb-record-xfield
+                      'bbdb-record-note))
        split tmp annivs)
     (clrhash org-bbdb-anniv-hash)
     (dolist (rec (bbdb-records))
       (when (setq annivs (if old-bbdb
                             (bbdb-record-getprop
                              rec org-bbdb-anniversary-field)
-                          (bbdb-record-note
-                           rec org-bbdb-anniversary-field)))
+                          (funcall record-func
+                                   rec org-bbdb-anniversary-field)))
         (setq annivs (if old-bbdb
                         (bbdb-split annivs "\n")
                       ;; parameter order is reversed in new bbdb
diff --git a/lisp/org/org-beamer.el b/lisp/org/org-beamer.el
deleted file mode 100644 (file)
index 78b57a4..0000000
+++ /dev/null
@@ -1,657 +0,0 @@
-;;; org-beamer.el --- Beamer-specific LaTeX export for org-mode
-;;
-;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
-;;
-;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
-;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
-;; Keywords: org, wp, tex
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This library implement the special treatment needed by using the
-;; beamer class during LaTeX export.
-
-;;; Code:
-
-(require 'org)
-(require 'org-exp)
-
-(defvar org-export-latex-header)
-(defvar org-export-latex-options-plist)
-(defvar org-export-opt-plist)
-
-(defgroup org-beamer nil
-  "Options specific for using the beamer class in LaTeX export."
-  :tag "Org Beamer"
-  :group 'org-export-latex)
-
-(defcustom org-beamer-use-parts nil
-  ""
-  :group 'org-beamer
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-beamer-frame-level 1
-  "The level that should be interpreted as a frame.
-The levels above this one will be translated into a sectioning structure.
-Setting this to 2 will allow sections, 3 will allow subsections as well.
-You can set this to 4 as well, if you at the same time set
-`org-beamer-use-parts' to make the top levels `\part'."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(choice
-         (const :tag "Frames need a BEAMER_env property" nil)
-         (integer :tag "Specific level makes a frame")))
-
-(defcustom org-beamer-frame-default-options ""
-  "Default options string to use for frames, should contains the [brackets].
-And example for this is \"[allowframebreaks]\"."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(string :tag "[options]"))
-
-(defcustom org-beamer-column-view-format
-  "%45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)"
-  "Default column view format that should be used to fill the template."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(choice
-         (const  :tag "Do not insert Beamer column view format" nil)
-         (string :tag "Beamer column view format")))
-
-(defcustom org-beamer-themes
-  "\\usetheme{default}\\usecolortheme{default}"
-  "Default string to be used for extra heading stuff in beamer presentations.
-When a beamer template is filled, this will be the default for
-BEAMER_HEADER_EXTRA, which will be inserted just before \\begin{document}."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(choice
-         (const  :tag "Do not insert Beamer themes" nil)
-         (string :tag "Beamer themes")))
-
-(defconst org-beamer-column-widths
-  "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
-  "The column widths that should be installed as allowed property values.")
-
-(defconst org-beamer-transitions
-  "\transblindsvertical \transblindshorizontal \transboxin \transboxout \transdissolve \transduration \transglitter \transsplithorizontalin \transsplithorizontalout \transsplitverticalin \transsplitverticalout \transwipe :ETC"
-  "Transitions available for beamer.
-These are just a completion help.")
-
-(defconst org-beamer-environments-default
-  '(("frame"          "f" "dummy- special handling hard coded" "dummy")
-    ("columns"        "C" "\\begin{columns}%o %% %h%x"         "\\end{columns}")
-    ("column"         "c" "\\begin{column}%o{%h\\textwidth}%x" "\\end{column}")
-    ("block"          "b" "\\begin{block}%a{%h}%x"             "\\end{block}")
-    ("alertblock"     "a" "\\begin{alertblock}%a{%h}%x"        "\\end{alertblock}")
-    ("verse"          "v" "\\begin{verse}%a %% %h%x"           "\\end{verse}")
-    ("quotation"      "q" "\\begin{quotation}%a %% %h%x"       "\\end{quotation}")
-    ("quote"          "Q" "\\begin{quote}%a %% %h%x"           "\\end{quote}")
-    ("structureenv"   "s" "\\begin{structureenv}%a %% %h%x"    "\\end{structureenv}")
-    ("theorem"        "t" "\\begin{theorem}%a%U%x"             "\\end{theorem}")
-    ("definition"     "d" "\\begin{definition}%a%U%x"          "\\end{definition}")
-    ("example"        "e" "\\begin{example}%a%U%x"             "\\end{example}")
-    ("exampleblock"   "E" "\\begin{exampleblock}%a{%h}%x"      "\\end{exampleblock}")
-    ("proof"          "p" "\\begin{proof}%a%U%x"               "\\end{proof}")
-    ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}%x"    "\\end{beamercolorbox}")
-    ("normal"         "h" "%h" "") ; Emit the heading as normal text
-    ("note"           "n" "\\note%o%a{%h"                      "}")
-    ("noteNH"         "N" "\\note%o%a{"                        "}") ; note, ignore heading
-    ("ignoreheading"  "i" "%%%% %h" ""))
-  "Environments triggered by properties in Beamer export.
-These are the defaults - for user definitions, see
-`org-beamer-environments-extra'.
-\"normal\" is a special fake environment, which emit the heading as
-normal text.  It is needed when an environment should be surrounded
-by normal text.  Since beamer export converts nodes into environments,
-you need to have a node to end the environment.
-For example
-
-   ** a frame
-      some text
-   *** Blocktitle :B_block:
-       inside the block
-   *** After the block :B_normal:
-       continuing here
-   ** next frame")
-
-(defcustom org-beamer-environments-extra nil
-  "Environments triggered by tags in Beamer export.
-Each entry has 4 elements:
-
-name    Name of the environment
-key     Selection key for `org-beamer-select-environment'
-open    The opening template for the environment, with the following escapes
-        %a   the action/overlay specification
-        %A   the default action/overlay specification
-        %o   the options argument of the template
-        %h   the headline text
-        %H   if there is headline text, that text in {} braces
-        %U   if there is headline text, that text in [] brackets
-        %x   the content of the BEAMER_extra property
-close   The closing string of the environment."
-
-  :group 'org-beamer
-  :version "24.1"
-  :type '(repeat
-         (list
-          (string :tag "Environment")
-          (string :tag "Selection key")
-          (string :tag "Begin")
-          (string :tag "End"))))
-
-(defcustom org-beamer-inherited-properties nil
-  "Properties that should be inherited during beamer export."
-  :group 'org-beamer
-  :type '(repeat
-         (string :tag "Property")))
-
-(defvar org-beamer-frame-level-now nil)
-(defvar org-beamer-header-extra nil)
-(defvar org-beamer-export-is-beamer-p nil)
-(defvar org-beamer-inside-frame-at-level nil)
-(defvar org-beamer-columns-open nil)
-(defvar org-beamer-column-open nil)
-
-(defun org-beamer-cleanup-column-width (width)
-  "Make sure the width is not empty, and that it has a unit."
-  (setq width (org-trim (or width "")))
-  (unless (string-match "\\S-" width) (setq width "0.5"))
-  (if (string-match "\\`[.0-9]+\\'" width)
-      (setq width (concat width "\\textwidth")))
-  width)
-
-(defun org-beamer-open-column (&optional width opt)
-  (org-beamer-close-column-maybe)
-  (setq org-beamer-column-open t)
-  (setq width (org-beamer-cleanup-column-width width))
-  (insert (format "\\begin{column}%s{%s}\n" (or opt "") width)))
-(defun org-beamer-close-column-maybe ()
-  (when org-beamer-column-open
-    (setq org-beamer-column-open nil)
-    (insert "\\end{column}\n")))
-(defun org-beamer-open-columns-maybe (&optional opts)
-  (unless org-beamer-columns-open
-    (setq org-beamer-columns-open t)
-    (insert (format "\\begin{columns}%s\n" (or opts "")))))
-(defun org-beamer-close-columns-maybe ()
-  (org-beamer-close-column-maybe)
-  (when org-beamer-columns-open
-    (setq org-beamer-columns-open nil)
-    (insert "\\end{columns}\n")))
-
-(defun org-beamer-select-environment ()
-  "Select the environment to be used by beamer for this entry.
-While this uses (for convenience) a tag selection interface, the result
-of this command will be that the BEAMER_env *property* of the entry is set.
-
-In addition to this, the command will also set a tag as a visual aid, but
-the tag does not have any semantic meaning."
-  (interactive)
-  (let* ((envs (append org-beamer-environments-extra
-                      org-beamer-environments-default))
-        (org-tag-alist
-         (append '((:startgroup))
-                 (mapcar (lambda (e) (cons (concat "B_" (car e))
-                                           (string-to-char (nth 1 e))))
-                         envs)
-                 '((:endgroup))
-                 '(("BMCOL" . ?|))))
-        (org-fast-tag-selection-single-key t))
-    (org-set-tags)
-    (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
-      (cond
-       ((equal org-last-tag-selection-key ?|)
-       (if (string-match ":BMCOL:" tags)
-           (org-set-property "BEAMER_col" (read-string "Column width: "))
-         (org-delete-property "BEAMER_col")))
-       ((string-match (concat ":B_\\("
-                             (mapconcat 'car envs "\\|")
-                             "\\):")
-                     tags)
-       (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
-       (t (org-entry-delete nil "BEAMER_env"))))))
-
-;;;###autoload
-(defun org-beamer-sectioning (level text)
-  "Return the sectioning entry for the current headline.
-LEVEL is the reduced level of the headline.
-TEXT is the text of the headline, everything except the leading stars.
-The return value is a cons cell.  The car is the headline text, usually
-just TEXT, but possibly modified if options have been extracted from the
-text.  The cdr is the sectioning entry, similar to what is given
-in org-export-latex-classes."
-  (let* ((frame-level (or org-beamer-frame-level-now org-beamer-frame-level))
-        (default
-          (if org-beamer-use-parts
-              '((1 . ("\\part{%s}" . "\\part*{%s}"))
-                (2 . ("\\section{%s}" . "\\section*{%s}"))
-                (3 . ("\\subsection{%s}" . "\\subsection*{%s}")))
-            '((1 . ("\\section{%s}" . "\\section*{%s}"))
-              (2 . ("\\subsection{%s}" . "\\subsection*{%s}")))))
-        (envs (append org-beamer-environments-extra
-                      org-beamer-environments-default))
-        (props (org-get-text-property-any 0 'org-props text))
-        (in "") (out "") org-beamer-option org-beamer-action org-beamer-defaction org-beamer-environment org-beamer-extra
-        columns-option column-option
-        env have-text ass tmp)
-    (if (= frame-level 0) (setq frame-level nil))
-    (when (and org-beamer-inside-frame-at-level
-              (<= level org-beamer-inside-frame-at-level))
-      (setq org-beamer-inside-frame-at-level nil))
-    (when (setq tmp (org-beamer-assoc-not-empty "BEAMER_col" props))
-      (if (and (string-match "\\`[0-9.]+\\'" tmp)
-              (or (= (string-to-number tmp) 1.0)
-                  (= (string-to-number tmp) 0.0)))
-         ;; column width 1 means close columns, go back to full width
-         (org-beamer-close-columns-maybe)
-       (when (setq ass (assoc "BEAMER_envargs" props))
-         (let (case-fold-search)
-           (while (string-match "C\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
-             (setq columns-option (match-string 1 (cdr ass)))
-             (setcdr ass (replace-match "" t t (cdr ass))))
-           (while (string-match "c\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
-             (setq column-option (match-string 1 (cdr ass)))
-             (setcdr ass (replace-match "" t t (cdr ass))))))
-       (org-beamer-open-columns-maybe columns-option)
-       (org-beamer-open-column tmp column-option)))
-    (cond
-     ((or (equal (cdr (assoc "BEAMER_env" props)) "frame")
-         (and frame-level (= level frame-level)))
-      ;; A frame
-      (org-beamer-get-special props)
-
-      (setq in (org-fill-template
-               "\\begin{frame}%a%A%o%T%S%x"
-               (list (cons "a" (or org-beamer-action ""))
-                     (cons "A" (or org-beamer-defaction ""))
-                     (cons "o" (or org-beamer-option org-beamer-frame-default-options ""))
-                     (cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
-                     (cons "h" "%s")
-                     (cons "T" (if (string-match "\\S-" text)
-                                   "\n\\frametitle{%s}" ""))
-                     (cons "S" (if (string-match "\\\\\\\\" text)
-                                   "\n\\framesubtitle{%s}" ""))))
-           out (copy-sequence "\\end{frame}"))
-      (org-add-props out
-         '(org-insert-hook org-beamer-close-columns-maybe))
-      (setq org-beamer-inside-frame-at-level level)
-      (cons text (list in out in out)))
-     ((and (setq env (cdr (assoc "BEAMER_env" props)))
-          (setq ass (assoc env envs)))
-      ;; A beamer environment selected by the BEAMER_env property
-      (if (string-match "[ \t]+:[ \t]*$" text)
-         (setq text (replace-match "" t t text)))
-      (if (member env '("note" "noteNH"))
-         ;; There should be no labels in a note, so we remove the targets
-         ;; FIXME???
-         (remove-text-properties 0 (length text) '(target nil) text))
-      (org-beamer-get-special props)
-      (setq text (org-trim text))
-      (setq have-text (string-match "\\S-" text))
-      (setq in (org-fill-template
-               (nth 2 ass)
-               (list (cons "a" (or org-beamer-action ""))
-                     (cons "A" (or org-beamer-defaction ""))
-                     (cons "o" (or org-beamer-option ""))
-                     (cons "x" (if org-beamer-extra (concat "\n" org-beamer-extra) ""))
-                     (cons "h" "%s")
-                     (cons "H" (if have-text (concat "{" text "}") ""))
-                     (cons "U" (if have-text (concat "[" text "]") ""))))
-           out (nth 3 ass))
-      (cond
-       ((equal out "\\end{columns}")
-       (setq org-beamer-columns-open t)
-       (setq out (org-add-props (copy-sequence out)
-                     '(org-insert-hook
-                       (lambda ()
-                         (org-beamer-close-column-maybe)
-                         (setq org-beamer-columns-open nil))))))
-       ((equal out "\\end{column}")
-       (org-beamer-open-columns-maybe)))
-      (cons text (list in out in out)))
-     ((and (not org-beamer-inside-frame-at-level)
-          (or (not frame-level)
-              (< level frame-level))
-          (assoc level default))
-      ;; Normal sectioning
-      (cons text (cdr (assoc level default))))
-     (t nil))))
-
-(defvar org-beamer-extra)
-(defvar org-beamer-option)
-(defvar org-beamer-action)
-(defvar org-beamer-defaction)
-(defvar org-beamer-environment)
-(defun org-beamer-get-special (props)
-  "Extract an option, action, and default action string from text.
-The variables org-beamer-option, org-beamer-action, org-beamer-defaction,
-org-beamer-extra are all scoped into this function dynamically."
-  (let (tmp)
-    (setq org-beamer-environment (org-beamer-assoc-not-empty "BEAMER_env" props))
-    (setq org-beamer-extra (org-beamer-assoc-not-empty "BEAMER_extra" props))
-    (when org-beamer-extra
-      (setq org-beamer-extra (replace-regexp-in-string "\\\\n" "\n" org-beamer-extra)))
-    (setq tmp (org-beamer-assoc-not-empty "BEAMER_envargs" props))
-    (when tmp
-      (setq tmp (copy-sequence tmp))
-      (if (string-match "\\[<[^][<>]*>\\]" tmp)
-         (setq org-beamer-defaction (match-string 0 tmp)
-               tmp (replace-match "" t t tmp)))
-      (if (string-match "\\[[^][]*\\]" tmp)
-         (setq org-beamer-option (match-string 0 tmp)
-               tmp (replace-match "" t t tmp)))
-      (if (string-match "<[^<>]*>" tmp)
-         (setq org-beamer-action (match-string 0 tmp)
-               tmp (replace-match "" t t tmp))))))
-
-(defun org-beamer-assoc-not-empty (elt list)
-  (let ((tmp (cdr (assoc elt list))))
-    (and tmp (string-match "\\S-" tmp) tmp)))
-
-
-(defvar org-beamer-mode-map (make-sparse-keymap)
-  "The keymap for `org-beamer-mode'.")
-(define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
-
-;;;###autoload
-(define-minor-mode org-beamer-mode
-  "Special support for editing Org-mode files made to export to beamer."
-  nil " Bm" nil)
-(when (fboundp 'font-lock-add-keywords)
-  (font-lock-add-keywords
-   'org-mode
-   '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
-   'prepent))
-
-(defun org-beamer-place-default-actions-for-lists ()
-  "Find default overlay specifications in items, and move them.
-The need to be after the begin statement of the environment."
-  (when org-beamer-export-is-beamer-p
-    (let (dovl)
-      (goto-char (point-min))
-      (while (re-search-forward
-             "^[ \t]*\\\\begin{\\(itemize\\|enumerate\\|description\\)}[ \t\n]*\\\\item\\>\\( ?\\(<[^<>\n]*>\\|\\[[^][\n*]\\]\\)\\)?[ \t]*\\S-" nil t)
-       (if (setq dovl (cdr (assoc "BEAMER_dovl"
-                                  (get-text-property (match-end 0)
-                                                     'org-props))))
-           (save-excursion
-             (goto-char (1+ (match-end 1)))
-             (insert dovl)))))))
-
-(defun org-beamer-amend-header ()
-  "Add `org-beamer-header-extra' to the LaTeX header.
-If the file contains the string BEAMER-HEADER-EXTRA-HERE on a line
-by itself, it will be replaced with `org-beamer-header-extra'.  If not,
-the value will be inserted right after the documentclass statement."
-  (when (and org-beamer-export-is-beamer-p
-            org-beamer-header-extra)
-    (goto-char (point-min))
-    (cond
-     ((re-search-forward
-       "^[ \t]*\\[?BEAMER-HEADER-EXTRA\\(-HERE\\)?\\]?[ \t]*$" nil t)
-      (replace-match org-beamer-header-extra t t)
-      (or (bolp) (insert "\n")))
-     ((re-search-forward "^[ \t]*\\\\begin{document}" nil t)
-      (beginning-of-line 1)
-      (insert org-beamer-header-extra)
-      (or (bolp) (insert "\n"))))))
-
-(defcustom org-beamer-fragile-re "\\\\\\(verb\\|lstinline\\)\\|^[ \t]*\\\\begin{\\(verbatim\\|lstlisting\\|minted\\)}"
-  "If this regexp matches in a frame, the frame is marked as fragile."
-  :group 'org-beamer
-  :version "24.1"
-  :type 'regexp)
-
-(defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
-  "The special face for beamer tags."
-  :group 'org-beamer)
-
-
-;; Functions to initialize and post-process
-;; These functions will be hooked into various places in the export process
-
-(defun org-beamer-initialize-open-trackers ()
-  "Reset variables that track if certain environments are open during export."
-  (setq org-beamer-columns-open nil)
-  (setq org-beamer-column-open nil)
-  (setq org-beamer-inside-frame-at-level nil)
-  (setq org-beamer-export-is-beamer-p nil))
-
-(defun org-beamer-after-initial-vars ()
-  "Find special settings for beamer and store them.
-The effect is that these values will be accessible during export."
-  ;; First verify that we are exporting using the beamer class
-  (setq org-beamer-export-is-beamer-p
-       (string-match "\\\\documentclass\\(\\[[^][]*?\\]\\)?{beamer}"
-                     org-export-latex-header))
-  (when org-beamer-export-is-beamer-p
-    ;; Find the frame level
-    (setq org-beamer-frame-level-now
-         (or (and (org-region-active-p)
-                  (save-excursion
-                    (goto-char (region-beginning))
-                    (and (looking-at org-complex-heading-regexp)
-                         (org-entry-get nil "BEAMER_FRAME_LEVEL" 'selective))))
-             (save-excursion
-               (save-restriction
-                 (widen)
-                 (goto-char (point-min))
-                 (and (re-search-forward
-                       "^#\\+BEAMER_FRAME_LEVEL:[ \t]*\\(.*?\\)[ \t]*$" nil t)
-                      (match-string 1))))
-             (plist-get org-export-latex-options-plist :beamer-frame-level)
-             org-beamer-frame-level))
-    ;; Normalize the value so that the functions can trust the value
-    (cond
-     ((not org-beamer-frame-level-now)
-      (setq org-beamer-frame-level-now nil))
-     ((stringp org-beamer-frame-level-now)
-      (setq org-beamer-frame-level-now
-           (string-to-number org-beamer-frame-level-now))))
-    ;; Find the header additions, most likely theme commands
-    (setq org-beamer-header-extra
-         (or (and (org-region-active-p)
-                  (save-excursion
-                    (goto-char (region-beginning))
-                    (and (looking-at org-complex-heading-regexp)
-                         (org-entry-get nil "BEAMER_HEADER_EXTRA"
-                                        'selective))))
-             (save-excursion
-               (save-restriction
-                 (widen)
-                 (let ((txt ""))
-                   (goto-char (point-min))
-                   (while (re-search-forward
-                           "^#\\+BEAMER_HEADER_EXTRA:[ \t]*\\(.*?\\)[ \t]*$"
-                           nil t)
-                     (setq txt (concat txt "\n" (match-string 1))))
-                   (if (> (length txt) 0) (substring txt 1)))))
-             (plist-get org-export-latex-options-plist
-                        :beamer-header-extra)))
-    (let ((inhibit-read-only t)
-         (case-fold-search nil)
-         props)
-      (org-unmodified
-       (remove-text-properties (point-min) (point-max) '(org-props nil))
-       (org-map-entries
-       '(progn
-          (setq props (org-entry-properties nil 'standard))
-          (if (and (not (assoc "BEAMER_env" props))
-                   (looking-at ".*?:B_\\(note\\(NH\\)?\\):"))
-              (push (cons "BEAMER_env" (match-string 1)) props))
-          (when (org-bound-and-true-p org-beamer-inherited-properties)
-            (mapc (lambda (p)
-                    (unless (assoc p props)
-                      (let ((v (org-entry-get nil p 'inherit)))
-                        (and v (push (cons p v) props)))))
-                  org-beamer-inherited-properties))
-          (put-text-property (point-at-bol) (point-at-eol) 'org-props props)))
-       (setq org-export-latex-options-plist
-            (plist-put org-export-latex-options-plist :tags nil))))))
-
-(defun org-beamer-auto-fragile-frames ()
-  "Mark any frames containing verbatim environments as fragile.
-This function will run in the final LaTeX document."
-  (when org-beamer-export-is-beamer-p
-    (let (opts)
-      (goto-char (point-min))
-      ;; Find something that might be fragile
-      (while (re-search-forward org-beamer-fragile-re nil t)
-       (save-excursion
-         ;; Are we inside a frame here?
-         (when (and (re-search-backward "^[ \t]*\\\\\\(begin\\|end\\){frame}\\(<[^>]*>\\)?"
-                                        nil t)
-                    (equal (match-string 1) "begin"))
-           ;; yes, inside a frame, make sure "fragile" is one of the options
-           (goto-char (match-end 0))
-           (if (not (looking-at "\\[.*?\\]"))
-               (insert "[fragile]")
-             (setq opts (substring (match-string 0) 1 -1))
-             (delete-region (match-beginning 0) (match-end 0))
-             (setq opts (org-split-string opts ","))
-             (add-to-list 'opts "fragile")
-             (insert "[" (mapconcat 'identity opts ",") "]"))))))))
-
-(defcustom org-beamer-outline-frame-title "Outline"
-  "Default title of a frame containing an outline."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(string :tag "Outline frame title")
-  )
-
-(defcustom org-beamer-outline-frame-options nil
-  "Outline frame options appended after \\begin{frame}.
-You might want to put e.g. [allowframebreaks=0.9] here.  Remember to
-include square brackets."
-  :group 'org-beamer
-  :version "24.1"
-  :type '(string :tag "Outline frame options")
-  )
-
-(defun org-beamer-fix-toc ()
-  "Fix the table of contents by removing the vspace line."
-  (when org-beamer-export-is-beamer-p
-    (save-excursion
-      (goto-char (point-min))
-      (when (re-search-forward "\\(\\\\setcounter{tocdepth.*\n\\\\tableofcontents.*\n\\)\\(\\\\vspace\\*.*\\)"
-                              nil t)
-       (replace-match
-        (concat "\\\\begin{frame}" org-beamer-outline-frame-options
-                "\n\\\\frametitle{"
-                org-beamer-outline-frame-title
-                "}\n\\1\\\\end{frame}")
-        t nil)))))
-
-(defun org-beamer-property-changed (property value)
-  "Track the BEAMER_env property with tags."
-  (cond
-   ((equal property "BEAMER_env")
-    (save-excursion
-      (org-back-to-heading t)
-      (let ((tags (org-get-tags)))
-       (setq tags (delq nil (mapcar (lambda (x)
-                                      (if (string-match "^B_" x) nil x))
-                                    tags)))
-       (org-set-tags-to tags))
-      (when (and value (stringp value) (string-match "\\S-" value))
-       (org-toggle-tag (concat "B_" value) 'on))))
-   ((equal property "BEAMER_col")
-    (org-toggle-tag "BMCOL" (if (and value (string-match "\\S-" value))
-                               'on 'off)))))
-
-(defun org-beamer-select-beamer-code ()
-  "Take code marked for BEAMER and turn it into marked for LaTeX."
-  (when org-beamer-export-is-beamer-p
-    (goto-char (point-min))
-    (while (re-search-forward
-           "^\\([ \]*#\\+\\(begin_\\|end_\\)?\\)\\(beamer\\)\\>" nil t)
-      (replace-match "\\1latex"))))
-
-;; OK, hook all these functions into appropriate places
-(add-hook 'org-export-first-hook
-         'org-beamer-initialize-open-trackers)
-(add-hook 'org-property-changed-functions
-         'org-beamer-property-changed)
-(add-hook 'org-export-latex-after-initial-vars-hook
-         'org-beamer-after-initial-vars)
-(add-hook 'org-export-latex-final-hook
-         'org-beamer-place-default-actions-for-lists)
-(add-hook 'org-export-latex-final-hook
-         'org-beamer-auto-fragile-frames)
-(add-hook 'org-export-latex-final-hook
-         'org-beamer-fix-toc)
-(add-hook 'org-export-latex-final-hook
-         'org-beamer-amend-header)
-(add-hook 'org-export-preprocess-before-selecting-backend-code-hook
-         'org-beamer-select-beamer-code)
-
-(defun org-insert-beamer-options-template (&optional kind)
-  "Insert a settings template, to make sure users do this right."
-  (interactive (progn
-                (message "Current [s]ubtree or [g]lobal?")
-                (if (equal (read-char-exclusive) ?g)
-                    (list 'global)
-                  (list 'subtree))))
-  (if (eq kind 'subtree)
-      (progn
-       (org-back-to-heading t)
-       (org-reveal)
-       (org-entry-put nil "LaTeX_CLASS" "beamer")
-       (org-entry-put nil "LaTeX_CLASS_OPTIONS" "[presentation]")
-       (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
-       (org-entry-put nil "BEAMER_FRAME_LEVEL" (number-to-string
-                                                org-beamer-frame-level))
-       (when org-beamer-themes
-         (org-entry-put nil "BEAMER_HEADER_EXTRA" org-beamer-themes))
-       (when org-beamer-column-view-format
-         (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
-       (org-entry-put nil "BEAMER_col_ALL" "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC"))
-    (insert "#+LaTeX_CLASS: beamer\n")
-    (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
-    (insert (format "#+BEAMER_FRAME_LEVEL: %d\n" org-beamer-frame-level) "\n")
-    (when org-beamer-themes
-      (insert "#+BEAMER_HEADER_EXTRA: " org-beamer-themes "\n"))
-    (when org-beamer-column-view-format
-      (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
-    (insert "#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC\n")))
-
-
-(defun org-beamer-allowed-property-values (property)
-  "Supply allowed values for BEAMER properties."
-  (cond
-   ((and (equal property "BEAMER_env")
-        (not (org-entry-get nil (concat property "_ALL") 'inherit)))
-    ;; If no allowed values for BEAMER_env have been defined,
-    ;; supply all defined environments
-    (mapcar 'car (append org-beamer-environments-extra
-                        org-beamer-environments-default)))
-   ((and (equal property "BEAMER_col")
-        (not (org-entry-get nil (concat property "_ALL") 'inherit)))
-    ;; If no allowed values for BEAMER_col have been defined,
-    ;; supply some
-    '("0.1" "0.2" "0.3" "0.4" "0.5" "0.6" "0.7" "0.8" "0.9" "" ":ETC"))
-   (t nil)))
-
-(add-hook 'org-property-allowed-value-functions
-         'org-beamer-allowed-property-values)
-
-(provide 'org-beamer)
-
-;;; org-beamer.el ends here
index 6ed6abc42b568c230ce993e8de1a5592c3474cab..def9340e43067fdb7a8ba5fdcd4acd817ac1b716 100644 (file)
@@ -2,10 +2,10 @@
 ;;
 ;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
 ;;
-;; Authors: Bastien Guerry <bzg at altern dot org>
+;; Authors: Bastien Guerry <bzg@gnu.org>
 ;;       Carsten Dominik <carsten dot dominik at gmail dot com>
 ;;       Eric Schulte <schulte dot eric at gmail dot com>
-;; Keywords: org, wp, remember
+;; Keywords: org, wp, capture
 ;;
 ;; This file is part of GNU Emacs.
 ;;
@@ -31,7 +31,7 @@
 ;; the link that contains the author name, the year and a short title.
 ;;
 ;; It also stores detailed information about the entry so that
-;; remember templates can access and enter this information easily.
+;; capture templates can access and enter this information easily.
 ;;
 ;; The available properties for each entry are listed here:
 ;;
 ;; :booktitle     :month          :annote      :abstract
 ;; :key           :btype
 ;;
-;; Here is an example of a remember template that use some of this
+;; Here is an example of a capture template that use some of this
 ;; information (:author :year :title :journal :pages):
 ;;
-;; (setq org-remember-templates
+;; (setq org-capture-templates
 ;;   '((?b "* READ %?\n\n%a\n\n%:author (%:year): %:title\n   \
 ;;          In %:journal, %:pages.")))
 ;;
-;; Let's say you want to remember this BibTeX entry:
+;; Let's say you want to capture this BibTeX entry:
 ;;
 ;; @Article{dolev83,
 ;;   author =   {Danny Dolev and Andrew C. Yao},
@@ -61,7 +61,7 @@
 ;;   month =    {Mars}
 ;; }
 ;;
-;; M-x `org-remember' on this entry will produce this buffer:
+;; M-x `org-capture' on this entry will produce this buffer:
 ;;
 ;; =====================================================================
 ;; * READ <== [point here]
@@ -94,7 +94,7 @@
 ;;
 ;; The link creation part has been part of Org-mode for a long time.
 ;;
-;; Creating better remember template information was inspired by a request
+;; Creating better capture template information was inspired by a request
 ;; of Austin Frank: http://article.gmane.org/gmane.emacs.orgmode/4112
 ;; and then implemented by Bastien Guerry.
 ;;
 For example setting to 'BIB_' would allow interoperability with fireforg."
   :group 'org-bibtex
   :version "24.1"
-  :type  'string)
+  :type  '(choice
+          (const nil)
+          (string)))
 
 (defcustom org-bibtex-treat-headline-as-title t
   "Treat headline text as title if title property is absent.
@@ -291,12 +293,13 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords' is t."
 \f
 ;;; Utility functions
 (defun org-bibtex-get (property)
-  ((lambda (it) (when it (org-babel-trim it)))
-   (let ((org-special-properties
-         (delete "FILE" (copy-sequence org-special-properties))))
-     (or
-      (org-entry-get (point) (upcase property))
-      (org-entry-get (point) (concat org-bibtex-prefix (upcase property)))))))
+  (let ((it (let ((org-special-properties
+                   (delete "FILE" (copy-sequence org-special-properties))))
+              (or
+               (org-entry-get (point) (upcase property))
+               (org-entry-get (point) (concat org-bibtex-prefix
+                                              (upcase property)))))))
+    (when it (org-babel-trim it))))
 
 (defun org-bibtex-put (property value)
   (let ((prop (upcase (if (keywordp property)
@@ -382,8 +385,8 @@ This variable is relevant only if `org-bibtex-export-tags-as-keywords' is t."
        (princ (cdr (assoc field org-bibtex-fields))))
       (with-current-buffer buf-name (visual-line-mode 1))
       (org-fit-window-to-buffer (get-buffer-window buf-name))
-      ((lambda (result) (when (> (length result) 0) result))
-       (read-from-minibuffer (format "%s: " name))))))
+      (let ((result (read-from-minibuffer (format "%s: " name))))
+        (when (> (length result) 0) result)))))
 
 (defun org-bibtex-autokey ()
   "Generate an autokey for the current headline."
@@ -537,20 +540,21 @@ Headlines are exported using `org-bibtex-export-headline'."
          "Bibtex file: " nil nil nil
          (file-name-nondirectory
           (concat (file-name-sans-extension (buffer-file-name)) ".bib")))))
-  ((lambda (error-point)
-     (when error-point
-       (goto-char error-point)
-       (message "Bibtex error at %S" (nth 4 (org-heading-components)))))
-   (catch 'bib
-     (let ((bibtex-entries (remove nil (org-map-entries
-                                       (lambda ()
-                                         (condition-case foo
-                                             (org-bibtex-headline)
-                                           (error (throw 'bib (point)))))))))
-       (with-temp-file filename
-        (insert (mapconcat #'identity bibtex-entries "\n")))
-       (message "Successfully exported %d BibTeX entries to %s"
-               (length bibtex-entries) filename) nil))))
+  (let ((error-point
+         (catch 'bib
+           (let ((bibtex-entries
+                  (remove nil (org-map-entries
+                               (lambda ()
+                                 (condition-case foo
+                                     (org-bibtex-headline)
+                                   (error (throw 'bib (point)))))))))
+             (with-temp-file filename
+               (insert (mapconcat #'identity bibtex-entries "\n")))
+             (message "Successfully exported %d BibTeX entries to %s"
+                      (length bibtex-entries) filename) nil))))
+    (when error-point
+      (goto-char error-point)
+      (message "Bibtex error at %S" (nth 4 (org-heading-components))))))
 
 (defun org-bibtex-check (&optional optional)
   "Check the current headline for required fields.
@@ -558,8 +562,8 @@ With prefix argument OPTIONAL also prompt for optional fields."
   (interactive "P")
   (save-restriction
     (org-narrow-to-subtree)
-    (let ((type ((lambda (name) (when name (intern (concat ":" name))))
-                 (org-bibtex-get org-bibtex-type-property-name))))
+    (let ((type (let ((name (org-bibtex-get org-bibtex-type-property-name)))
+                  (when name (intern (concat ":" name))))))
       (when type (org-bibtex-fleshout type optional)))))
 
 (defun org-bibtex-check-all (&optional optional)
@@ -623,6 +627,27 @@ This uses `bibtex-parse-entry'."
            (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
           org-bibtex-entries)))
 
+(defun org-bibtex-read-buffer (buffer)
+  "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.
+Return the number of saved entries."
+  (interactive "bbuffer: ")
+  (let ((start-length (length org-bibtex-entries)))
+    (with-current-buffer buffer
+      (save-excursion
+       (goto-char (point-max))
+       (while (not (= (point) (point-min)))
+         (backward-char 1)
+         (org-bibtex-read)
+         (bibtex-beginning-of-entry))))
+    (let ((added (- (length org-bibtex-entries) start-length)))
+      (message "parsed %d entries" added)
+      added)))
+
+(defun org-bibtex-read-file (file)
+  "Read FILE with `org-bibtex-read-buffer'."
+  (interactive "ffile: ")
+  (org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile)))
+
 (defun org-bibtex-write ()
   "Insert a heading built from the first element of `org-bibtex-entries'."
   (interactive)
@@ -664,6 +689,14 @@ This uses `bibtex-parse-entry'."
        (org-bibtex-write)
       (error "Yanked text does not appear to contain a BibTeX entry"))))
 
+(defun org-bibtex-import-from-file (file)
+  "Read bibtex entries from FILE and insert as Org-mode headlines after point."
+  (interactive "ffile: ")
+  (dotimes (_ (org-bibtex-read-file file))
+    (save-excursion (org-bibtex-write))
+    (re-search-forward org-property-end-re)
+    (open-line 1) (forward-char 1)))
+
 (defun org-bibtex-export-to-kill-ring ()
   "Export current headline to kill ring as bibtex entry."
   (interactive)
index 8a271b8d0558368a1caf8714a0de94a2b624ac24..39804ac3c0161bbba6bfad6681d6bde8888ce83b 100644 (file)
 ;;
 ;;; Commentary:
 
-;; This file contains an alternative implementation of the same functionality
-;; that is also provided by org-remember.el.  The implementation is more
+;; This file contains an alternative implementation of the functionality
+;; that used to be provided by org-remember.el.  The implementation is more
 ;; streamlined, can produce more target types (e.g. plain list items or
 ;; table lines).  Also, it does not use a temporary buffer for editing
 ;; the captured entry - instead it uses an indirect buffer that visits
 ;; the new entry already in the target buffer (this was an idea by Samuel
-;; Wales).  John Wiegley's excellent `remember.el' is not needed for this
-;; implementation, even though we borrow heavily from its ideas.
+;; Wales).  John Wiegley's excellent `remember.el' is not needed anymore
+;; for this implementation, even though we borrow heavily from its ideas.
 
 ;; This implementation heavily draws on ideas by James TD Smith and
 ;; Samuel Wales, and, of cause, uses John Wiegley's remember.el as inspiration.
@@ -50,7 +50,6 @@
 (eval-when-compile
   (require 'cl))
 (require 'org)
-(require 'org-mks)
 
 (declare-function org-datetree-find-date-create "org-datetree"
                  (date &optional keep-restriction))
@@ -182,6 +181,8 @@ properties are:
                      template only needs information that can be added
                      automatically.
 
+ :jump-to-captured   When set, jump to the captured entry when finished.
+
  :empty-lines        Set this to the number of lines the should be inserted
                      before and after the new item.  Default 0, only common
                      other value is 1.
@@ -223,7 +224,9 @@ freely formatted text.  Furthermore, the following %-escapes will
 be replaced with content and expanded in this order:
 
   %[pathname] Insert the contents of the file given by `pathname'.
-  %(sexp)     Evaluate elisp `(sexp)' and replace with the result.
+  %(sexp)     Evaluate elisp `(sexp)' and replace it with the results.
+              For convenience, %:keyword (see below) placeholders within
+              the expression will be expanded prior to this.
   %<...>      The result of format-time-string on the ... format specification.
   %t          Time stamp, date only.
   %T          Time stamp with date and time.
@@ -237,7 +240,7 @@ be replaced with content and expanded in this order:
   %x          Content of the X clipboard.
   %k          Title of currently clocked task.
   %K          Link to currently clocked task.
-  %n          User name (taken from `user-full-name').
+  %n          User name (taken from the variable `user-full-name').
   %f          File visited by current buffer when org-capture was called.
   %F          Full path of the file or directory visited by current buffer.
   %:keyword   Specific information for certain link types, see below.
@@ -338,11 +341,15 @@ calendar                |  %:type %:date"
                         ;; Give the most common options as checkboxes
                         :options (((const :format "%v " :prepend) (const t))
                                   ((const :format "%v " :immediate-finish) (const t))
+                                  ((const :format "%v " :jump-to-captured) (const t))
                                   ((const :format "%v " :empty-lines) (const 1))
+                                  ((const :format "%v " :empty-lines-before) (const 1))
+                                  ((const :format "%v " :empty-lines-after) (const 1))
                                   ((const :format "%v " :clock-in) (const t))
                                   ((const :format "%v " :clock-keep) (const t))
                                   ((const :format "%v " :clock-resume) (const t))
                                   ((const :format "%v " :unnarrowed) (const t))
+                                  ((const :format "%v " :table-line-pos) (const t))
                                   ((const :format "%v " :kill-buffer) (const t))))))))
 
 (defcustom org-capture-before-finalize-hook nil
@@ -439,6 +446,7 @@ Turning on this mode runs the normal hook `org-capture-mode-hook'."
 
 ;;;###autoload
 (defun org-capture-string (string &optional keys)
+  "Capture STRING with the template selected by KEYS."
   (interactive "sInitial text: \n")
   (let ((org-capture-initial string)
        (org-capture-entry (org-capture-select-template keys)))
@@ -459,6 +467,8 @@ Here are the available contexts definitions:
       in-mode: command displayed only in matching modes
   not-in-file: command not displayed in matching files
   not-in-mode: command not displayed in matching modes
+    in-buffer: command displayed only in matching buffers
+not-in-buffer: command not displayed in matching buffers
    [function]: a custom function taking no argument
 
 If you define several checks, the agenda command will be
@@ -484,6 +494,8 @@ to avoid duplicates.)"
                                     (choice
                                      (const :tag "In file" in-file)
                                      (const :tag "Not in file" not-in-file)
+                                     (const :tag "In buffer" in-buffer)
+                                     (const :tag "Not in buffer" not-in-buffer)
                                      (const :tag "In mode" in-mode)
                                      (const :tag "Not in mode" not-in-mode))
                                     (regexp))
@@ -491,7 +503,7 @@ to avoid duplicates.)"
 
 (defcustom org-capture-use-agenda-date nil
   "Non-nil means use the date at point when capturing from agendas.
-When nil, you can still capturing using the date at point with \\[org-agenda-capture]]."
+When nil, you can still capture using the date at point with \\[org-agenda-capture]."
   :group 'org-capture
   :version "24.3"
   :type 'boolean)
@@ -514,17 +526,19 @@ stored.
 
 When called with a `C-0' (zero) prefix, insert a template at point.
 
-Lisp programs can set KEYS to a string associated with a template
+ELisp programs can set KEYS to a string associated with a template
 in `org-capture-templates'.  In this case, interactive selection
 will be bypassed.
 
 If `org-capture-use-agenda-date' is non-nil, capturing from the
-agenda will use the date at point as the default date."
+agenda will use the date at point as the default date.  Then, a
+`C-1' prefix will tell the capture process to use the HH:MM time
+of the day at point (if any) or the current HH:MM time."
   (interactive "P")
   (when (and org-capture-use-agenda-date
             (eq major-mode 'org-agenda-mode))
     (setq org-overriding-default-time
-         (org-get-cursor-date)))
+         (org-get-cursor-date (equal goto 1))))
   (cond
    ((equal goto '(4)) (org-capture-goto-target))
    ((equal goto '(16)) (org-capture-goto-last-stored))
@@ -563,8 +577,9 @@ agenda will use the date at point as the default date."
                              (file-name-nondirectory
                               (buffer-file-name orig-buf)))
                         :annotation annotation
-                        :initial initial)
-       (org-capture-put :default-time
+                        :initial initial
+                        :return-to-wconf (current-window-configuration)
+                        :default-time
                         (or org-overriding-default-time
                             (org-current-time)))
        (org-capture-set-target-location)
@@ -579,7 +594,8 @@ agenda will use the date at point as the default date."
            ;;insert at point
            (org-capture-insert-template-here)
          (condition-case error
-             (org-capture-place-template)
+             (org-capture-place-template
+              (equal (car (org-capture-get :target)) 'function))
            ((error quit)
             (if (and (buffer-base-buffer (current-buffer))
                      (string-match "\\`CAPTURE-" (buffer-name)))
@@ -600,7 +616,7 @@ agenda will use the date at point as the default date."
                (error
                 "Could not start the clock in this capture buffer")))
          (if (org-capture-get :immediate-finish)
-             (org-capture-finalize nil)))))))))
+             (org-capture-finalize)))))))))
 
 (defun org-capture-get-template ()
   "Get the template from a file or a function if necessary."
@@ -625,6 +641,8 @@ agenda will use the date at point as the default date."
 With prefix argument STAY-WITH-CAPTURE, jump to the location of the
 captured item after finalizing."
   (interactive "P")
+  (when (org-capture-get :jump-to-captured)
+    (setq stay-with-capture t))
   (unless (and org-capture-mode
               (buffer-base-buffer (current-buffer)))
     (error "This does not seem to be a capture buffer for Org-mode"))
@@ -771,14 +789,14 @@ already gone.  Any prefix argument will be passed to the refile command."
   (let ((pos (point))
        (base (buffer-base-buffer (current-buffer)))
        (org-refile-for-capture t))
-    (org-capture-finalize)
     (save-window-excursion
       (with-current-buffer (or base (current-buffer))
        (save-excursion
          (save-restriction
            (widen)
            (goto-char pos)
-           (call-interactively 'org-refile)))))))
+           (call-interactively 'org-refile)))))
+    (org-capture-finalize)))
 
 (defun org-capture-kill ()
   "Abort the current capture process."
@@ -893,7 +911,8 @@ Store them in the capture property list."
                                (current-time))))
              (org-capture-put
               :default-time
-              (cond ((and (not org-time-was-given)
+              (cond ((and (or (not (boundp 'org-time-was-given))
+                              (not org-time-was-given))
                           (not (= (time-to-days prompt-time) (org-today))))
                      ;; Use 00:00 when no time is given for another date than today?
                      (apply 'encode-time (append '(0 0 0) (cdddr (decode-time prompt-time)))))
@@ -964,14 +983,17 @@ it.  When it is a variable, retrieve the value.  Return whatever we get."
             (find-file-noselect (expand-file-name file org-directory)))))
 
 (defun org-capture-steal-local-variables (buffer)
-  "Install Org-mode local variables."
+  "Install Org-mode local variables of BUFFER."
   (mapc (lambda (v)
          (ignore-errors (org-set-local (car v) (cdr v))))
        (buffer-local-variables buffer)))
 
-(defun org-capture-place-template ()
-  "Insert the template at the target location, and display the buffer."
-  (org-capture-put :return-to-wconf (current-window-configuration))
+(defun org-capture-place-template (&optional inhibit-wconf-store)
+  "Insert the template at the target location, and display the buffer.
+When `inhibit-wconf-store', don't store the window configuration, as it
+may have been stored before."
+  (unless inhibit-wconf-store
+    (org-capture-put :return-to-wconf (current-window-configuration)))
   (delete-other-windows)
   (org-switch-to-buffer-other-window
    (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
@@ -1250,8 +1272,11 @@ Of course, if exact position has been required, just put it there."
        (save-restriction
          (widen)
          (goto-char pos)
-         (with-demoted-errors
-           (bookmark-set "org-capture-last-stored"))
+         (let ((bookmark-name (plist-get org-bookmark-names-plist
+                                         :last-capture)))
+           (when bookmark-name
+             (with-demoted-errors
+               (bookmark-set bookmark-name))))
          (move-marker org-capture-last-stored-marker (point)))))))
 
 (defun org-capture-narrow (beg end)
@@ -1261,7 +1286,7 @@ Of course, if exact position has been required, just put it there."
     (goto-char beg)))
 
 (defun org-capture-empty-lines-before (&optional n)
-  "Arrange for the correct number of empty lines before the insertion point.
+  "Set the correct number of empty lines before the insertion point.
 Point will be after the empty lines, so insertion can directly be done."
   (setq n (or n (org-capture-get :empty-lines-before)
              (org-capture-get :empty-lines) 0))
@@ -1271,7 +1296,7 @@ Point will be after the empty lines, so insertion can directly be done."
     (if (> n 0) (newline n))))
 
 (defun org-capture-empty-lines-after (&optional n)
-  "Arrange for the correct number of empty lines after the inserted string.
+  "Set the correct number of empty lines after the inserted string.
 Point will remain at the first line after the inserted text."
   (setq n (or n (org-capture-get :empty-lines-after)
              (org-capture-get :empty-lines) 0))
@@ -1284,6 +1309,7 @@ Point will remain at the first line after the inserted text."
 (defvar org-clock-marker) ; Defined in org.el
 
 (defun org-capture-insert-template-here ()
+  "Insert the capture template at point."
   (let* ((template (org-capture-get :template))
         (type  (org-capture-get :type))
         beg end pp)
@@ -1366,8 +1392,106 @@ Use PREFIX as a prefix for the name of the indirect buffer."
   (unless (org-kill-is-subtree-p tree)
     (error "Template is not a valid Org entry or tree")))
 
-;;; The template code
+(defun org-mks (table title &optional prompt specials)
+  "Select a member of an alist with multiple keys.
+TABLE is the alist which should contain entries where the car is a string.
+There should be two types of entries.
+
+1. prefix descriptions like (\"a\" \"Description\")
+   This indicates that `a' is a prefix key for multi-letter selection, and
+   that there are entries following with keys like \"ab\", \"ax\"...
+
+2. Selectable members must have more than two elements, with the first
+   being the string of keys that lead to selecting it, and the second a
+   short description string of the item.
+
+The command will then make a temporary buffer listing all entries
+that can be selected with a single key, and all the single key
+prefixes.  When you press the key for a single-letter entry, it is selected.
+When you press a prefix key, the commands (and maybe further prefixes)
+under this key will be shown and offered for selection.
+
+TITLE will be placed over the selection in the temporary buffer,
+PROMPT will be used when prompting for a key.  SPECIAL is an alist with
+also (\"key\" \"description\") entries.  When one of these is selection,
+only the bare key is returned."
+  (setq prompt (or prompt "Select: "))
+  (let (tbl orig-table dkey ddesc des-keys allowed-keys
+           current prefix rtn re pressed buffer (inhibit-quit t))
+    (save-window-excursion
+      (setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
+      (setq orig-table table)
+      (catch 'exit
+       (while t
+         (erase-buffer)
+         (insert title "\n\n")
+         (setq tbl table
+               des-keys nil
+               allowed-keys nil
+               cursor-type nil)
+         (setq prefix (if current (concat current " ") ""))
+         (while tbl
+           (cond
+            ((and (= 2 (length (car tbl))) (= (length (caar tbl)) 1))
+             ;; This is a description on this level
+             (setq dkey (caar tbl) ddesc (cadar tbl))
+             (pop tbl)
+             (push dkey des-keys)
+             (push dkey allowed-keys)
+             (insert prefix "[" dkey "]" "..." "  " ddesc "..." "\n")
+             ;; Skip keys which are below this prefix
+             (setq re (concat "\\`" (regexp-quote dkey)))
+             (let (case-fold-search)
+               (while (and tbl (string-match re (caar tbl))) (pop tbl))))
+            ((= 2 (length (car tbl)))
+             ;; Not yet a usable description, skip it
+             )
+            (t
+             ;; usable entry on this level
+             (insert prefix "[" (caar tbl) "]" "     " (nth 1 (car tbl)) "\n")
+             (push (caar tbl) allowed-keys)
+             (pop tbl))))
+         (when specials
+           (insert "-------------------------------------------------------------------------------\n")
+           (let ((sp specials))
+             (while sp
+               (insert (format "[%s]     %s\n"
+                               (caar sp) (nth 1 (car sp))))
+               (push (caar sp) allowed-keys)
+               (pop sp))))
+         (push "\C-g" allowed-keys)
+         (goto-char (point-min))
+         (if (not (pos-visible-in-window-p (point-max)))
+             (org-fit-window-to-buffer))
+         (message prompt)
+         (setq pressed (char-to-string (read-char-exclusive)))
+         (while (not (member pressed allowed-keys))
+           (message "Invalid key `%s'" pressed) (sit-for 1)
+           (message prompt)
+           (setq pressed (char-to-string (read-char-exclusive))))
+         (when (equal pressed "\C-g")
+           (kill-buffer buffer)
+           (error "Abort"))
+         (when (and (not (assoc pressed table))
+                    (not (member pressed des-keys))
+                    (assoc pressed specials))
+           (throw 'exit (setq rtn pressed)))
+         (unless (member pressed des-keys)
+           (throw 'exit (setq rtn (rassoc (cdr (assoc pressed table))
+                                          orig-table))))
+         (setq current (concat current pressed))
+         (setq table (mapcar
+                      (lambda (x)
+                        (if (and (> (length (car x)) 1)
+                                 (equal (substring (car x) 0 1) pressed))
+                            (cons (substring (car x) 1) (cdr x))
+                          nil))
+                      table))
+         (setq table (remove nil table)))))
+    (when buffer (kill-buffer buffer))
+    rtn))
 
+;;; The template code
 (defun org-capture-select-template (&optional keys)
   "Select a capture template.
 Lisp programs can force the template by setting KEYS to a string."
@@ -1496,10 +1620,8 @@ The template may still contain \"%?\" for cursor positioning."
                (setq v-i (mapconcat 'identity
                                     (org-split-string initial "\n")
                                     (concat "\n" lead))))))
-         (replace-match
-          (or (org-add-props (eval (intern (concat "v-" (match-string 1))))
-                  '(org-protected t)) "")
-          t t)))
+         (replace-match (or (eval (intern (concat "v-" (match-string 1)))) "")
+                        t t)))
 
       ;; From the property list
       (when plist-p
@@ -1515,8 +1637,7 @@ The template may still contain \"%?\" for cursor positioning."
       (let ((org-inhibit-startup t)) (org-mode))
       ;; Interactive template entries
       (goto-char (point-min))
-      (while (and (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
-                 (not (get-text-property (1- (point)) 'org-protected)))
+      (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
        (unless (org-capture-escaped-%)
          (setq char (if (match-end 3) (match-string-no-properties 3))
                prompt (if (match-end 2) (match-string-no-properties 2)))
@@ -1621,9 +1742,29 @@ The template may still contain \"%?\" for cursor positioning."
       (goto-char (match-beginning 0))
       (let ((template-start (point)))
        (forward-char 1)
-       (let ((result (org-eval (read (current-buffer)))))
+       (let* ((sexp (read (current-buffer)))
+              (result (org-eval
+                       (org-capture--expand-keyword-in-embedded-elisp sexp))))
          (delete-region template-start (point))
-         (insert result))))))
+         (when result
+           (if (stringp result)
+               (insert result)
+             (error "Capture template sexp `%s' must evaluate to string or nil"
+                    sexp))))))))
+
+(defun org-capture--expand-keyword-in-embedded-elisp (attr)
+  "Recursively replace capture link keywords in ATTR sexp.
+Such keywords are prefixed with \"%:\".  See
+`org-capture-template' for more information."
+  (cond ((consp attr)
+        (mapcar 'org-capture--expand-keyword-in-embedded-elisp attr))
+       ((symbolp attr)
+        (let* ((attr-symbol (symbol-name attr))
+               (key (and (string-match "%\\(:.*\\)" attr-symbol)
+                         (intern (match-string 1 attr-symbol)))))
+          (or (plist-get org-store-link-plist key)
+              attr)))
+       (t attr)))
 
 (defun org-capture-inside-embedded-elisp-p ()
   "Return non-nil if point is inside of embedded elisp %(sexp)."
@@ -1643,7 +1784,7 @@ The template may still contain \"%?\" for cursor positioning."
 
 ;;;###autoload
 (defun org-capture-import-remember-templates ()
-  "Set org-capture-templates to be similar to `org-remember-templates'."
+  "Set `org-capture-templates' to be similar to `org-remember-templates'."
   (interactive)
   (when (and (yes-or-no-p
              "Import old remember templates into org-capture-templates? ")
@@ -1660,7 +1801,7 @@ The template may still contain \"%?\" for cursor positioning."
                   (position (or (nth 4 entry) org-remember-default-headline))
                   (type 'entry)
                   (prepend org-reverse-note-order)
-                  immediate target)
+                  immediate target jump-to-captured)
               (cond
                ((member position '(top bottom))
                 (setq target (list 'file file)
@@ -1674,9 +1815,13 @@ The template may still contain \"%?\" for cursor positioning."
                 (setq template (replace-match "" t t template)
                       immediate t))
 
+              (when (string-match "%&" template)
+                (setq jump-to-captured t))
+
               (append (list key desc type target template)
                       (if prepend '(:prepend t))
-                      (if immediate '(:immediate-finish t)))))
+                      (if immediate '(:immediate-finish t))
+                      (if jump-to-captured '(:jump-to-captured t)))))
 
           org-remember-templates))))
 
index a536d025c041af1ad085d7a3c3715d0e11b36a50..978bde475d473668bcac8d677966cba16d54c473 100644 (file)
 
 ;; This file contains the time clocking code for Org-mode
 
-(require 'org-exp)
 ;;; Code:
 
 (eval-when-compile
   (require 'cl))
+(require 'org)
 
 (declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
@@ -95,6 +95,24 @@ clocking out."
          (repeat :tag "State list"
                  (string :tag "TODO keyword"))))
 
+(defcustom org-clock-rounding-minutes 0
+  "Rounding minutes when clocking in or out.
+The default value is 0 so that no rounding is done.
+When set to a non-integer value, use the car of
+`org-time-stamp-rounding-minutes', like for setting a time-stamp.
+
+E.g. if `org-clock-rounding-minutes' is set to 5, time is 14:47
+and you clock in: then the clock starts at 14:45.  If you clock
+out within the next 5 minutes, the clock line will be removed;
+if you clock out 8 minutes after your clocked in, the clock
+out time will be 14:50."
+  :group 'org-clock
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (integer :tag "Minutes (0 for no rounding)")
+         (symbol  :tag "Use `org-time-stamp-rounding-minutes'" 'same-as-time-stamp)))
+
 (defcustom org-clock-out-remove-zero-time-clocks nil
   "Non-nil means remove the clock line when the resulting time is zero."
   :group 'org-clock
@@ -141,7 +159,7 @@ state to switch it to."
 This is the string shown in the mode line when a clock is running.
 The function is called with point at the beginning of the headline."
   :group 'org-clock
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defcustom org-clock-string-limit 0
   "Maximum length of clock strings in the mode line.  0 means no limit."
@@ -177,7 +195,7 @@ Emacs initialization file."
          (const :tag "No persistence" nil)))
 
 (defcustom org-clock-persist-file (convert-standard-filename
-                                  "~/.emacs.d/org-clock-save.el")
+                                  (concat user-emacs-directory "org-clock-save.el"))
   "File to save clock data to."
   :group 'org-clock
   :type 'string)
@@ -193,17 +211,17 @@ Emacs initialization file."
   :type 'boolean)
 
 (defcustom org-clock-sound nil
-  "Sound that will used for notifications.
-Possible values:
+  "Sound to use for notifications.
+Possible values are:
 
-nil        no sound played.
-t          standard Emacs beep
-file name  play this sound file.  If not possible, fall back to beep"
+nil        No sound played
+t          Standard Emacs beep
+file name  Play this sound file, fall back to beep"
   :group 'org-clock
   :type '(choice
          (const :tag "No sound" nil)
          (const :tag "Standard beep" t)
-         (file :tag "Play sound file")))
+         (file  :tag "Play sound file")))
 
 (define-obsolete-variable-alias 'org-clock-modeline-total
   'org-clock-mode-line-total "24.3")
@@ -226,7 +244,7 @@ auto     Automatically, either `all', or `repeat' for repeating tasks"
          (const :tag "All task time" all)
          (const :tag "Automatically, `all' or since `repeat'" auto)))
 
-(defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text)
+(org-defvaralias 'org-task-overrun-text 'org-clock-task-overrun-text)
 (defcustom org-clock-task-overrun-text nil
   "Extra mode line text to indicate that the clock is overrun.
 The can be nil to indicate that instead of adding text, the clock time
@@ -245,6 +263,7 @@ The function or program will be called with the notification
 string as argument."
   :group 'org-clock
   :type '(choice
+         (const nil)
          (string :tag "Program")
          (function :tag "Function")))
 
@@ -256,9 +275,11 @@ string as argument."
 (defcustom org-clocktable-defaults
   (list
    :maxlevel 2
-   :lang org-export-default-language
+   :lang (or (org-bound-and-true-p org-export-default-language) "en")
    :scope 'file
    :block nil
+   :wstart 1
+   :mstart 1
    :tstart nil
    :tend nil
    :step nil
@@ -341,13 +362,13 @@ play with them."
   "Format string for the total time cells."
   :group 'org-clock
   :version "24.1"
-  :type 'boolean)
+  :type 'string)
 
 (defcustom org-clock-file-time-cell-format "*%s*"
   "Format string for the file time cells."
   :group 'org-clock
   :version "24.1"
-  :type 'boolean)
+  :type 'string)
 
 (defcustom org-clock-clocked-in-display 'mode-line
   "When clocked in for a task, org-mode can display the current
@@ -378,6 +399,20 @@ specifications than `frame-title-format', which see."
   :group 'org-clock
   :type 'sexp)
 
+(defcustom org-clock-x11idle-program-name "x11idle"
+  "Name of the program which prints X11 idle time in milliseconds.
+
+You can find x11idle.c in the contrib/scripts directory of the
+Org git distribution. Or, you can do:
+
+    sudo apt-get install xprintidle
+
+if you are using Debian."
+  :group 'org-clock
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
 (defvar org-clock-in-prepare-hook nil
   "Hook run when preparing the clock.
 This hook is run before anything happens to the task that
@@ -403,7 +438,6 @@ to add an effort property.")
 (defvar org-clock-mode-line-timer nil)
 (defvar org-clock-idle-timer nil)
 (defvar org-clock-heading) ; defined in org.el
-(defvar org-clock-heading-for-remember "")
 (defvar org-clock-start-time "")
 
 (defvar org-clock-leftover-time nil
@@ -481,46 +515,55 @@ of a different task.")
   "Hook called in task selection just before prompting the user.")
 
 (defun org-clock-select-task (&optional prompt)
-  "Select a task that recently was associated with clocking."
+  "Select a task that was recently associated with clocking."
   (interactive)
-  (let (sel-list rpl (i 0) s)
-    (save-window-excursion
-      (org-switch-to-buffer-other-window
-       (get-buffer-create "*Clock Task Select*"))
-      (erase-buffer)
-      (when (marker-buffer org-clock-default-task)
-       (insert (org-add-props "Default Task\n" nil 'face 'bold))
-       (setq s (org-clock-insert-selection-line ?d org-clock-default-task))
-       (push s sel-list))
-      (when (marker-buffer org-clock-interrupted-task)
-       (insert (org-add-props "The task interrupted by starting the last one\n" nil 'face 'bold))
-       (setq s (org-clock-insert-selection-line ?i org-clock-interrupted-task))
-       (push s sel-list))
-      (when (org-clocking-p)
-       (insert (org-add-props "Current Clocking Task\n" nil 'face 'bold))
-       (setq s (org-clock-insert-selection-line ?c org-clock-marker))
-       (push s sel-list))
-      (insert (org-add-props "Recent Tasks\n" nil 'face 'bold))
-      (mapc
-       (lambda (m)
-        (when (marker-buffer m)
-          (setq i (1+ i)
-                s (org-clock-insert-selection-line
-                   (if (< i 10)
-                       (+ i ?0)
-                     (+ i (- ?A 10))) m))
-          (if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s))))
-          (push s sel-list)))
-       org-clock-history)
-      (run-hooks 'org-clock-before-select-task-hook)
-      (org-fit-window-to-buffer)
-      (message (or prompt "Select task for clocking:"))
-      (setq rpl (read-char-exclusive))
-      (cond
-       ((eq rpl ?q) nil)
-       ((eq rpl ?x) nil)
-       ((assoc rpl sel-list) (cdr (assoc rpl sel-list)))
-       (t (error "Invalid task choice %c" rpl))))))
+  (let (och chl sel-list rpl (i 0) s)
+    ;; Remove successive dups from the clock history to consider
+    (mapc (lambda (c) (if (not (equal c (car och))) (push c och)))
+         org-clock-history)
+    (setq och (reverse och) chl (length och))
+    (if (zerop chl)
+       (user-error "No recent clock")
+      (save-window-excursion
+       (org-switch-to-buffer-other-window
+        (get-buffer-create "*Clock Task Select*"))
+       (erase-buffer)
+       (when (marker-buffer org-clock-default-task)
+         (insert (org-add-props "Default Task\n" nil 'face 'bold))
+         (setq s (org-clock-insert-selection-line ?d org-clock-default-task))
+         (push s sel-list))
+       (when (marker-buffer org-clock-interrupted-task)
+         (insert (org-add-props "The task interrupted by starting the last one\n" nil 'face 'bold))
+         (setq s (org-clock-insert-selection-line ?i org-clock-interrupted-task))
+         (push s sel-list))
+       (when (org-clocking-p)
+         (insert (org-add-props "Current Clocking Task\n" nil 'face 'bold))
+         (setq s (org-clock-insert-selection-line ?c org-clock-marker))
+         (push s sel-list))
+       (insert (org-add-props "Recent Tasks\n" nil 'face 'bold))
+       (mapc
+        (lambda (m)
+          (when (marker-buffer m)
+            (setq i (1+ i)
+                  s (org-clock-insert-selection-line
+                     (if (< i 10)
+                         (+ i ?0)
+                       (+ i (- ?A 10))) m))
+            (if (fboundp 'int-to-char) (setf (car s) (int-to-char (car s))))
+            (push s sel-list)))
+        och)
+       (run-hooks 'org-clock-before-select-task-hook)
+       (goto-char (point-min))
+       ;; Set min-height relatively to circumvent a possible but in
+       ;; `fit-window-to-buffer'
+       (fit-window-to-buffer nil nil (if (< chl 10) chl (+ 5 chl)))
+       (message (or prompt "Select task for clocking:"))
+       (setq cursor-type nil rpl (read-char-exclusive))
+       (cond
+        ((eq rpl ?q) nil)
+        ((eq rpl ?x) nil)
+        ((assoc rpl sel-list) (cdr (assoc rpl sel-list)))
+        (t (user-error "Invalid task choice %c" rpl)))))))
 
 (defun org-clock-insert-selection-line (i marker)
   "Insert a line for the clock selection menu.
@@ -547,7 +590,7 @@ pointing to it."
                           org-odd-levels-only)
                          (length prefix)))))))
       (when (and cat task)
-       (insert (format "[%c] %-15s %s\n" i cat task))
+       (insert (format "[%c] %-12s  %s\n" i cat task))
        (cons i marker)))))
 
 (defvar org-clock-task-overrun nil
@@ -560,30 +603,33 @@ pointing to it."
 If an effort estimate was defined for the current item, use
 01:30/01:50 format (clocked/estimated).
 If not, show simply the clocked time like 01:50."
-  (let* ((clocked-time (org-clock-get-clocked-time))
-        (h (floor clocked-time 60))
-        (m (- clocked-time (* 60 h))))
+  (let ((clocked-time (org-clock-get-clocked-time)))
     (if org-clock-effort
        (let* ((effort-in-minutes
                (org-duration-string-to-minutes org-clock-effort))
-              (effort-h (floor effort-in-minutes 60))
-              (effort-m (- effort-in-minutes (* effort-h 60)))
               (work-done-str
                (org-propertize
-                (format org-time-clocksum-format h m)
+                (org-minutes-to-clocksum-string clocked-time)
                 'face (if (and org-clock-task-overrun (not org-clock-task-overrun-text))
                           'org-mode-line-clock-overrun 'org-mode-line-clock)))
-              (effort-str (format org-time-clocksum-format effort-h effort-m))
+              (effort-str (org-minutes-to-clocksum-string effort-in-minutes))
               (clockstr (org-propertize
                          (concat  " [%s/" effort-str
                                   "] (" (replace-regexp-in-string "%" "%%" org-clock-heading) ")")
                          'face 'org-mode-line-clock)))
          (format clockstr work-done-str))
-      (org-propertize (format
-                      (concat "[" org-time-clocksum-format " (%s)]")
-                      h m org-clock-heading)
+      (org-propertize (concat "[" (org-minutes-to-clocksum-string clocked-time)
+                             (format " (%s)" org-clock-heading) "]")
                      'face 'org-mode-line-clock))))
 
+(defun org-clock-get-last-clock-out-time ()
+  "Get the last clock-out time for the current subtree."
+  (save-excursion
+    (let ((end (save-excursion (org-end-of-subtree))))
+      (when (re-search-forward (concat org-clock-string
+                                      ".*\\]--\\(\\[[^]]+\\]\\)") end t)
+       (org-time-string-to-time (match-string 1))))))
+
 (defun org-clock-update-mode-line ()
   (if org-clock-effort
       (org-clock-notify-once-if-expired)
@@ -620,9 +666,12 @@ previous clocking intervals."
   "Add to or set the effort estimate of the item currently being clocked.
 VALUE can be a number of minutes, or a string with format hh:mm or mm.
 When the string starts with a + or a - sign, the current value of the effort
-property will be changed by that amount.
-This will update the \"Effort\" property of currently clocked item, and
-the mode line."
+property will be changed by that amount.  If the effort value is expressed
+as an `org-effort-durations' (e.g. \"3h\"), the modified value will be
+converted to a hh:mm duration.
+
+This command will update the \"Effort\" property of the currently
+clocked item, and the value displayed in the mode line."
   (interactive)
   (if (org-clock-is-active)
       (let ((current org-clock-effort) sign)
@@ -646,7 +695,7 @@ the mode line."
              (setq value (- current value))
            (if (equal ?+ sign) (setq value (+ current value)))))
        (setq value (max 0 value)
-             org-clock-effort (org-minutes-to-hh:mm-string value))
+             org-clock-effort (org-minutes-to-clocksum-string value))
        (org-entry-put org-clock-marker "Effort" org-clock-effort)
        (org-clock-update-mode-line)
        (message "Effort is now %s" org-clock-effort))
@@ -669,13 +718,14 @@ Notification is shown only once."
            (setq org-clock-notification-was-shown t)
            (org-notify
             (format "Task '%s' should be finished by now. (%s)"
-                    org-clock-heading org-clock-effort) t))
+                    org-clock-heading org-clock-effort) org-clock-sound))
        (setq org-clock-notification-was-shown nil)))))
 
 (defun org-notify (notification &optional play-sound)
-  "Send a NOTIFICATION and maybe PLAY-SOUND."
+  "Send a NOTIFICATION and maybe PLAY-SOUND.
+If PLAY-SOUND is non-nil, it overrides `org-clock-sound'."
   (org-show-notification notification)
-  (if play-sound (org-clock-play-sound)))
+  (if play-sound (org-clock-play-sound play-sound)))
 
 (defun org-show-notification (notification)
   "Show notification.
@@ -700,21 +750,23 @@ use libnotify if available, or fall back on a message."
        ;; a fall back option
        (t (message "%s" notification))))
 
-(defun org-clock-play-sound ()
+(defun org-clock-play-sound (&optional clock-sound)
   "Play sound as configured by `org-clock-sound'.
-Use alsa's aplay tool if available."
-  (cond
-   ((not org-clock-sound))
-   ((eq org-clock-sound t) (beep t) (beep t))
-   ((stringp org-clock-sound)
-    (let ((file (expand-file-name org-clock-sound)))
-      (if (file-exists-p file)
-         (if (executable-find "aplay")
-             (start-process "org-clock-play-notification" nil
-                            "aplay" file)
-           (condition-case nil
-               (play-sound-file file)
-             (error (beep t) (beep t)))))))))
+Use alsa's aplay tool if available.
+If CLOCK-SOUND is non-nil, it overrides `org-clock-sound'."
+  (let ((org-clock-sound (or clock-sound org-clock-sound)))
+    (cond
+     ((not org-clock-sound))
+     ((eq org-clock-sound t) (beep t) (beep t))
+     ((stringp org-clock-sound)
+      (let ((file (expand-file-name org-clock-sound)))
+       (if (file-exists-p file)
+           (if (executable-find "aplay")
+               (start-process "org-clock-play-notification" nil
+                              "aplay" file)
+             (condition-case nil
+                 (play-sound-file file)
+               (error (beep t) (beep t))))))))))
 
 (defvar org-clock-mode-line-entry nil
   "Information for the mode line about the running clock.")
@@ -887,19 +939,23 @@ was started."
                (with-output-to-temp-buffer "*Org Clock*"
                  (princ "Select a Clock Resolution Command:
 
-i/q/C-g  Ignore this question; the same as keeping all the idle time.
+i/q      Ignore this question; the same as keeping all the idle time.
 
 k/K      Keep X minutes of the idle time (default is all).  If this
          amount is less than the default, you will be clocked out
          that many minutes after the time that idling began, and then
          clocked back in at the present time.
+
 g/G      Indicate that you \"got back\" X minutes ago.  This is quite
          different from 'k': it clocks you out from the beginning of
          the idle period and clock you back in X minutes ago.
+
 s/S      Subtract the idle time from the current clock.  This is the
          same as keeping 0 minutes.
+
 C        Cancel the open timer altogether.  It will be as though you
          never clocked in.
+
 j/J      Jump to the current clock, to make manual adjustments.
 
 For all these options, using uppercase makes your final state
@@ -1010,13 +1066,13 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling
 (defvar org-x11idle-exists-p
   ;; Check that x11idle exists
   (and (eq window-system 'x)
-       (eq (call-process-shell-command "command" nil nil nil "-v" "x11idle") 0)
+       (eq (call-process-shell-command "command" nil nil nil "-v" org-clock-x11idle-program-name) 0)
        ;; Check that x11idle can retrieve the idle time
-       (eq (call-process-shell-command "x11idle" nil nil nil) 0)))
+       (eq (call-process-shell-command org-clock-x11idle-program-name nil nil nil) 0)))
 
 (defun org-x11-idle-seconds ()
   "Return the current X11 idle time in seconds."
-  (/ (string-to-number (shell-command-to-string "x11idle")) 1000))
+  (/ (string-to-number (shell-command-to-string org-clock-x11idle-program-name)) 1000))
 
 (defun org-user-idle-seconds ()
   "Return the number of seconds the user has been idle for.
@@ -1037,7 +1093,7 @@ This is performed after `org-clock-idle-time' minutes, to check
 if the user really wants to stay clocked in after being idle for
 so long."
   (when (and org-clock-idle-time (not org-clock-resolving-clocks)
-            org-clock-marker)
+            org-clock-marker (marker-buffer org-clock-marker))
     (let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
           (org-clock-user-idle-start
            (time-subtract (current-time)
@@ -1056,17 +1112,9 @@ so long."
                         60.0))))
           org-clock-user-idle-start)))))
 
-(defvar org-clock-current-task nil
-  "Task currently clocked in.")
-(defun org-clock-set-current ()
-  "Set `org-clock-current-task' to the task currently clocked in."
-  (setq org-clock-current-task (nth 4 (org-heading-components))))
-
-(defun org-clock-delete-current ()
-  "Reset `org-clock-current-task' to nil."
-  (setq org-clock-current-task nil))
-
+(defvar org-clock-current-task nil "Task currently clocked in.")
 (defvar org-clock-out-time nil) ; store the time of the last clock-out
+(defvar org--msg-extra)
 
 ;;;###autoload
 (defun org-clock-in (&optional select start-time)
@@ -1086,7 +1134,7 @@ make this the default behavior.)"
   (catch 'abort
     (let ((interrupting (and (not org-clock-resolving-clocks-due-to-idleness)
                             (org-clocking-p)))
-         ts selected-task target-pos (msg-extra "")
+         ts selected-task target-pos (org--msg-extra "")
          (leftover (and (not org-clock-resolving-clocks)
                         org-clock-leftover-time)))
 
@@ -1156,14 +1204,9 @@ make this the default behavior.)"
            (goto-char target-pos)
            (org-back-to-heading t)
            (or interrupting (move-marker org-clock-interrupted-task nil))
-           (save-excursion
-             (forward-char) ;; make sure the marker is not at the
-             ;; beginning of the heading, since the
-             ;; user is liking to insert stuff here
-             ;; manually
-             (run-hooks 'org-clock-in-prepare-hook)
-             (org-clock-history-push))
-           (org-clock-set-current)
+           (run-hooks 'org-clock-in-prepare-hook)
+           (org-clock-history-push)
+           (setq org-clock-current-task (nth 4 (org-heading-components)))
            (cond ((functionp org-clock-in-switch-to-state)
                   (looking-at org-complex-heading-regexp)
                   (let ((newstate (funcall org-clock-in-switch-to-state
@@ -1174,23 +1217,15 @@ make this the default behavior.)"
                                                 org-clock-in-switch-to-state
                                                 "\\>"))))
                   (org-todo org-clock-in-switch-to-state)))
-           (setq org-clock-heading-for-remember
-                 (and (looking-at org-complex-heading-regexp)
-                      (match-end 4)
-                      (org-trim (buffer-substring (match-end 1)
-                                                  (match-end 4)))))
            (setq org-clock-heading
                  (cond ((and org-clock-heading-function
                              (functionp org-clock-heading-function))
                         (funcall org-clock-heading-function))
-                       ((and (looking-at org-complex-heading-regexp)
-                             (match-string 4))
+                       ((nth 4 (org-heading-components))
                         (replace-regexp-in-string
                          "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1"
-                         (match-string 4)))
+                         (match-string-no-properties 4)))
                        (t "???")))
-           (setq org-clock-heading (org-propertize org-clock-heading
-                                                   'face nil))
            (org-clock-find-position org-clock-in-resume)
            (cond
             ((and org-clock-in-resume
@@ -1233,11 +1268,12 @@ make this the default behavior.)"
                             (y-or-n-p
                              (format
                               "You stopped another clock %d mins ago; start this one from then? "
-                              (/ (- (org-float-time (current-time))
+                              (/ (- (org-float-time
+                                     (org-current-time org-clock-rounding-minutes t))
                                     (org-float-time leftover)) 60)))
                             leftover)
                        start-time
-                       (current-time)))
+                       (org-current-time org-clock-rounding-minutes t)))
              (setq ts (org-insert-time-stamp org-clock-start-time
                                              'with-hm 'inactive))))
            (move-marker org-clock-marker (point) (buffer-base-buffer))
@@ -1270,7 +1306,7 @@ make this the default behavior.)"
              (setq org-clock-idle-timer nil))
            (setq org-clock-idle-timer
                  (run-with-timer 60 60 'org-resolve-clocks-if-idle))
-           (message "Clock starts at %s - %s" ts msg-extra)
+           (message "Clock starts at %s - %s" ts org--msg-extra)
            (run-hooks 'org-clock-in-hook)))))))
 
 ;;;###autoload
@@ -1288,8 +1324,9 @@ for a todo state to switch to, overriding the existing value
   (if (equal arg '(4))
       (org-clock-in (org-clock-select-task))
     (let ((start-time (if (or org-clock-continuously (equal arg '(16)))
-                         (or org-clock-out-time (current-time))
-                       (current-time))))
+                         (or org-clock-out-time
+                             (org-current-time org-clock-rounding-minutes t))
+                       (org-current-time org-clock-rounding-minutes t))))
       (if (null org-clock-history)
          (message "No last clock")
        (let ((org-clock-in-switch-to-state
@@ -1315,7 +1352,6 @@ for a todo state to switch to, overriding the existing value
     (org-back-to-heading t)
     (move-marker org-clock-default-task (point))))
 
-(defvar msg-extra)
 (defun org-clock-get-sum-start ()
   "Return the time from which clock times should be counted.
 This is for the currently running clock as it is displayed
@@ -1328,10 +1364,10 @@ decides which time to use."
        (lr (org-entry-get nil "LAST_REPEAT")))
     (cond
      ((equal cmt "current")
-      (setq msg-extra "showing time in current clock instance")
+      (setq org--msg-extra "showing time in current clock instance")
       (current-time))
      ((equal cmt "today")
-      (setq msg-extra "showing today's task time.")
+      (setq org--msg-extra "showing today's task time.")
       (let* ((dt (decode-time (current-time))))
        (setq dt (append (list 0 0 0) (nthcdr 3 dt)))
        (if org-extend-today-until
@@ -1340,12 +1376,12 @@ decides which time to use."
      ((or (equal cmt "all")
          (and (or (not cmt) (equal cmt "auto"))
               (not lr)))
-      (setq msg-extra "showing entire task time.")
+      (setq org--msg-extra "showing entire task time.")
       nil)
      ((or (equal cmt "repeat")
          (and (or (not cmt) (equal cmt "auto"))
               lr))
-      (setq msg-extra "showing task time since last repeat.")
+      (setq org--msg-extra "showing task time since last repeat.")
       (if (not lr)
          nil
        (org-time-string-to-time lr)))
@@ -1461,7 +1497,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
                                  org-todo-keywords-1)
                                nil t "DONE")
             org-clock-out-switch-to-state))
-         (now (current-time))
+         (now (org-current-time org-clock-rounding-minutes))
          ts te s h m remove)
       (setq org-clock-out-time now)
       (save-excursion ; Do not replace this with `with-current-buffer'.
@@ -1522,11 +1558,20 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
                                                "\\>"))))
                  (org-todo org-clock-out-switch-to-state))))))
          (force-mode-line-update)
-         (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
-                  (if remove " => LINE REMOVED" ""))
-          (run-hooks 'org-clock-out-hook)
+         (message (concat "Clock stopped at %s after "
+                          (org-minutes-to-clocksum-string (+ (* 60 h) m)) "%s")
+                  te (if remove " => LINE REMOVED" ""))
+         (let ((h org-clock-out-hook))
+           ;; If a closing note needs to be stored in the drawer
+           ;; where clocks are stored, let's temporarily disable
+           ;; `org-clock-remove-empty-clock-drawer'
+           (if (and (equal org-clock-into-drawer org-log-into-drawer)
+                    (eq org-log-done 'note)
+                    org-clock-out-when-done)
+               (setq h (delq 'org-clock-remove-empty-clock-drawer h)))
+           (mapc (lambda (f) (funcall f)) h))
          (unless (org-clocking-p)
-           (org-clock-delete-current)))))))
+           (setq org-clock-current-task nil)))))))
 
 (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer)
 
@@ -1545,19 +1590,22 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
          (org-remove-empty-drawer-at clock-drawer (point))
          (forward-line 1))))))
 
-(defun org-clock-timestamps-up nil
-  "Increase CLOCK timestamps at cursor."
-  (interactive)
-  (org-clock-timestamps-change 'up))
+(defun org-clock-timestamps-up (&optional n)
+  "Increase CLOCK timestamps at cursor.
+Optional argument N tells to change by that many units."
+  (interactive "P")
+  (org-clock-timestamps-change 'up n))
 
-(defun org-clock-timestamps-down nil
-  "Increase CLOCK timestamps at cursor."
-  (interactive)
-  (org-clock-timestamps-change 'down))
+(defun org-clock-timestamps-down (&optional n)
+  "Increase CLOCK timestamps at cursor.
+Optional argument N tells to change by that many units."
+  (interactive "P")
+  (org-clock-timestamps-change 'down n))
 
-(defun org-clock-timestamps-change (updown)
+(defun org-clock-timestamps-change (updown &optional n)
   "Change CLOCK timestamps synchronously at cursor.
-UPDOWN tells whether to change 'up or 'down."
+UPDOWN tells whether to change 'up or 'down.
+Optional argument N tells to change by that many units."
   (setq org-ts-what nil)
   (when (org-at-timestamp-p t)
     (let ((tschange (if (eq updown 'up) 'org-timestamp-up
@@ -1573,9 +1621,9 @@ UPDOWN tells whether to change 'up or 'down."
       (if (<= begts2 (point)) (setq updatets1 t))
       (if (not ts2)
          ;; fall back on org-timestamp-up if there is only one
-         (funcall tschange)
+         (funcall tschange n)
        ;; setq this so that (boundp 'org-ts-what is non-nil)
-       (funcall tschange)
+       (funcall tschange n)
        (let ((ts (if updatets1 ts2 ts1))
              (begts (if updatets1 begts1 begts2)))
          (setq tdiff
@@ -1620,6 +1668,12 @@ UPDOWN tells whether to change 'up or 'down."
   (message "Clock canceled")
   (run-hooks 'org-clock-cancel-hook))
 
+(defcustom org-clock-goto-before-context 2
+  "Number of lines of context to display before currently clocked-in entry.
+This applies when using `org-clock-goto'."
+  :group 'org-clock
+  :type 'integer)
+
 ;;;###autoload
 (defun org-clock-goto (&optional select)
   "Go to the currently clocked-in entry, or to the most recently clocked one.
@@ -1643,7 +1697,7 @@ With prefix arg SELECT, offer recently clocked tasks for selection."
     (org-show-entry)
     (org-back-to-heading t)
     (org-cycle-hide-drawers 'children)
-    (recenter)
+    (recenter org-clock-goto-before-context)
     (org-reveal)
     (if recent
        (message "No running clock, this is the most recently clocked task"))
@@ -1669,7 +1723,7 @@ each headline in the time range with point at the headline.  Headlines for
 which HEADLINE-FILTER returns nil are excluded from the clock summation.
 PROPNAME lets you set a custom text property instead of :org-clock-minutes."
   (interactive)
-  (org-unmodified
+  (org-with-silent-modifications
    (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
                      org-clock-string
                      "[ \t]*\\(?:\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)\\|=>[ \t]+\\([0-9]+\\):\\([0-9]+\\)\\)"))
@@ -1784,12 +1838,9 @@ Use \\[org-clock-remove-overlays] to remove the subtree times."
        (when org-remove-highlights-with-change
          (org-add-hook 'before-change-functions 'org-clock-remove-overlays
                        nil 'local))))
-    (if org-time-clocksum-use-fractional
-       (message (concat "Total file time: " org-time-clocksum-fractional-format
-                        " (%d hours and %d minutes)")
-                (/ (+ (* h 60.0) m) 60.0) h m)
-      (message (concat "Total file time: " org-time-clocksum-format
-                      " (%d hours and %d minutes)") h m h m))))
+      (message (concat "Total file time: "
+                      (org-minutes-to-clocksum-string org-clock-file-total-minutes)
+                      " (%d hours and %d minutes)") h m)))
 
 (defvar org-clock-overlays nil)
 (make-variable-buffer-local 'org-clock-overlays)
@@ -1801,9 +1852,6 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it
 will be easy to remove."
   (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
         (l (if level (org-get-valid-level level 0) 0))
-        (fmt (concat "%s " (if org-time-clocksum-use-fractional
-                               org-time-clocksum-fractional-format
-                             org-time-clocksum-format) "%s"))
         (off 0)
         ov tx)
     (org-move-to-column c)
@@ -1812,14 +1860,9 @@ will be easy to remove."
     (setq ov (make-overlay (point-at-bol) (point-at-eol))
          tx (concat (buffer-substring (point-at-bol) (point))
                     (make-string (+ off (max 0 (- c (current-column)))) ?.)
-                    (org-add-props (if org-time-clocksum-use-fractional
-                                       (format fmt
-                                               (make-string l ?*)
-                                               (/ (+ (* h 60.0) m) 60.0)
-                                               (make-string (- 16 l) ?\ ))
-                                     (format fmt
-                                             (make-string l ?*) h m
-                                             (make-string (- 16 l) ?\ )))
+                    (org-add-props (concat (make-string l ?*) " "
+                                           (org-minutes-to-clocksum-string time)
+                                           (make-string (- 16 l) ?\ ))
                         (list 'face 'org-clock-overlay))
                     ""))
     (if (not (featurep 'xemacs))
@@ -1969,20 +2012,27 @@ buffer and update it."
        ((> startday 4)
        (list 39 startday year)))))))
 
-(defun org-clock-special-range (key &optional time as-strings)
+(defun org-clock-special-range (key &optional time as-strings wstart mstart)
   "Return two times bordering a special time range.
 Key is a symbol specifying the range and can be one of `today', `yesterday',
 `thisweek', `lastweek', `thismonth', `lastmonth', `thisyear', `lastyear'.
-A week starts Monday 0:00 and ends Sunday 24:00.
-The range is determined relative to TIME.  TIME defaults to the current time.
+By default, a week starts Monday 0:00 and ends Sunday 24:00.
+The range is determined relative to TIME, which defaults to current time.
 The return value is a cons cell with two internal times like the ones
-returned by `current time' or `encode-time'. if AS-STRINGS is non-nil,
-the returned times will be formatted strings."
+returned by `current time' or `encode-time'.
+If AS-STRINGS is non-nil, the returned times will be formatted strings.
+If WSTART is non-nil, use this number to specify the starting day of a
+week (monday is 1).
+If MSTART is non-nil, use this number to specify the starting day of a
+month (1 is the first day of the month).
+If you can combine both, the month starting day will have priority."
   (if (integerp key) (setq key (intern (number-to-string key))))
   (let* ((tm (decode-time (or time (current-time))))
         (s 0) (m (nth 1 tm)) (h (nth 2 tm))
         (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm))
         (dow (nth 6 tm))
+        (ws (or wstart 1))
+        (ms (or mstart 1))
         (skey (symbol-name key))
         (shift 0)
          (q (cond ((>= (nth 4 tm) 10) 4)
@@ -2037,20 +2087,21 @@ the returned times will be formatted strings."
      ((memq key '(day today))
       (setq d (+ d shift) h 0 m 0 h1 24 m1 0))
      ((memq key '(week thisweek))
-      (setq diff (+ (* -7 shift) (if (= dow 0) 6 (1- dow)))
+      (setq diff (+ (* -7 shift) (if (= dow 0) (- 7 ws) (- dow ws)))
            m 0 h 0 d (- d diff) d1 (+ 7 d)))
      ((memq key '(month thismonth))
-      (setq d 1 h 0 m 0 d1 1 month (+ month shift) month1 (1+ month) h1 0 m1 0))
+      (setq d (or ms 1) h 0 m 0 d1 (or ms 1)
+           month (+ month shift) month1 (1+ month) h1 0 m1 0))
      ((memq key '(quarter thisq))
-                                       ; compute if this shift remains in this year
-                                       ; if not, compute how many years and quarters we have to shift (via floor*)
-                                       ; and compute the shifted years, months and quarters
+      ;; Compute if this shift remains in this year.  If not, compute
+      ;; how many years and quarters we have to shift (via floor*) and
+      ;; compute the shifted years, months and quarters.
       (cond
        ((< (+ (- q 1) shift) 0) ; shift not in this year
        (setq interval (* -1 (+ (- q 1) shift)))
-                                       ; set tmp to ((years to shift) (quarters to shift))
+       ;; Set tmp to ((years to shift) (quarters to shift)).
        (setq tmp (org-floor* interval 4))
-                                       ; due to the use of floor, 0 quarters actually means 4
+       ;; Due to the use of floor, 0 quarters actually means 4.
        (if (= 0 (nth 1 tmp))
            (setq shiftedy (- y (nth 0 tmp))
                  shiftedm 1
@@ -2080,8 +2131,7 @@ the returned times will be formatted strings."
      ((memq key '(year thisyear))
       (setq txt (format-time-string "the year %Y" ts)))
      ((memq key '(quarter thisq))
-      (setq txt (concat (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy))))
-     )
+      (setq txt (concat (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy)))))
     (if as-strings
        (list (format-time-string fm ts) (format-time-string fm te) txt)
       (list ts te txt))))
@@ -2186,6 +2236,8 @@ the currently selected interval size."
           (te (plist-get params :tend))
           (link (plist-get params :link))
           (maxlevel (or (plist-get params :maxlevel) 3))
+          (ws (plist-get params :wstart))
+          (ms (plist-get params :mstart))
           (step (plist-get params :step))
           (timestamp (plist-get params :timestamp))
           (formatter (or (plist-get params :formatter)
@@ -2196,7 +2248,7 @@ the currently selected interval size."
       ;; Check if we need to do steps
       (when block
        ;; Get the range text for the header
-       (setq cc (org-clock-special-range block nil t)
+       (setq cc (org-clock-special-range block nil t ws ms)
              ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
       (when step
        ;; Write many tables, in steps
@@ -2276,7 +2328,8 @@ from the dynamic block definition."
   ;; well-defined number of columns...
   (let* ((hlchars '((1 . "*") (2 . "/")))
         (lwords (assoc (or (plist-get params :lang)
-                           org-export-default-language)
+                           (org-bound-and-true-p org-export-default-language)
+                           "en")
                        org-clock-clocktable-language-setup))
         (multifile (plist-get params :multifile))
         (block (plist-get params :block))
@@ -2284,10 +2337,14 @@ from the dynamic block definition."
         (te (plist-get params :tend))
         (header (plist-get  params :header))
         (narrow (plist-get params :narrow))
+        (ws (or (plist-get params :wstart) 1))
+        (ms (or (plist-get params :mstart) 1))
         (link (plist-get params :link))
         (maxlevel (or (plist-get params :maxlevel) 3))
         (emph (plist-get params :emphasize))
         (level-p (plist-get params :level))
+        (org-time-clocksum-use-effort-durations
+         (plist-get params :effort-durations))
         (timestamp (plist-get params :timestamp))
         (properties (plist-get params :properties))
         (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
@@ -2326,7 +2383,7 @@ from the dynamic block definition."
 
     (when block
       ;; Get the range text for the header
-      (setq range-text (nth 2 (org-clock-special-range block nil t))))
+      (setq range-text (nth 2 (org-clock-special-range block nil t ws ms))))
 
     ;; Compute the total time
     (setq total-time (apply '+ (mapcar 'cadr tables)))
@@ -2339,13 +2396,14 @@ from the dynamic block definition."
      (or header
         ;; Format the standard header
         (concat
+         "#+CAPTION: "
          (nth 9 lwords) " ["
          (substring
           (format-time-string (cdr org-time-stamp-formats))
           1 -1)
          "]"
          (if block (concat ", for " range-text ".") "")
-         "\n\n")))
+         "\n")))
 
     ;; Insert the narrowing line
     (when (and narrow (integerp narrow) (not narrow-cut-p))
@@ -2378,7 +2436,7 @@ from the dynamic block definition."
      (if properties (make-string (length properties) ?|) "")  ; properties columns, maybe
      (concat (format org-clock-total-time-cell-format (nth 7 lwords))  "| ") ; instead of a headline
      (format org-clock-total-time-cell-format
-            (org-minutes-to-hh:mm-string (or total-time 0))) ; the time
+            (org-minutes-to-clocksum-string (or total-time 0))) ; the time
      "|\n")                          ; close line
 
     ;; Now iterate over the tables and insert the data
@@ -2402,7 +2460,7 @@ from the dynamic block definition."
                     (if level-p   "| " "") ; level column, maybe
                     (if timestamp "| " "") ; timestamp column, maybe
                     (if properties (make-string (length properties) ?|) "")  ;properties columns, maybe
-                    (org-minutes-to-hh:mm-string (nth 1 tbl))))) ; the time
+                    (org-minutes-to-clocksum-string (nth 1 tbl))))) ; the time
 
          ;; Get the list of node entries and iterate over it
          (setq entries (nth 2 tbl))
@@ -2435,7 +2493,7 @@ from the dynamic block definition."
             hlc headline hlc "|"                                ; headline
             (make-string (min (1- ntcol) (or (- level 1))) ?|)
                                        ; empty fields for higher levels
-            hlc (org-minutes-to-hh:mm-string (nth 3 entry)) hlc ; time
+            hlc (org-minutes-to-clocksum-string (nth 3 entry)) hlc ; time
             "|\n"                                               ; close line
             )))))
     ;; When exporting subtrees or regions the region might be
@@ -2508,13 +2566,15 @@ from the dynamic block definition."
   (let* ((p1 (copy-sequence params))
         (ts (plist-get p1 :tstart))
         (te (plist-get p1 :tend))
+        (ws (plist-get p1 :wstart))
+        (ms (plist-get p1 :mstart))
         (step0 (plist-get p1 :step))
         (step (cdr (assoc step0 '((day . 86400) (week . 604800)))))
         (stepskip0 (plist-get p1 :stepskip0))
         (block (plist-get p1 :block))
-        cc range-text step-time)
+        cc range-text step-time tsb)
     (when block
-      (setq cc (org-clock-special-range block nil t)
+      (setq cc (org-clock-special-range block nil t ws ms)
            ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
     (cond
      ((numberp ts)
@@ -2532,17 +2592,21 @@ from the dynamic block definition."
      (te
       (setq te (org-float-time
                (apply 'encode-time (org-parse-time-string te))))))
+    (setq tsb
+         (if (eq step0 'week)
+             (- ts (* 86400 (- (nth 6 (decode-time (seconds-to-time ts))) ws)))
+           ts))
     (setq p1 (plist-put p1 :header ""))
     (setq p1 (plist-put p1 :step nil))
     (setq p1 (plist-put p1 :block nil))
-    (while (< ts te)
+    (while (< tsb te)
       (or (bolp) (insert "\n"))
       (setq p1 (plist-put p1 :tstart (format-time-string
                                      (org-time-stamp-format nil t)
-                                     (seconds-to-time ts))))
+                                     (seconds-to-time (max tsb ts)))))
       (setq p1 (plist-put p1 :tend (format-time-string
                                    (org-time-stamp-format nil t)
-                                   (seconds-to-time (setq ts (+ ts step))))))
+                                   (seconds-to-time (min te (setq tsb (+ tsb step)))))))
       (insert "\n" (if (eq step0 'day) "Daily report: "
                     "Weekly report starting on: ")
              (plist-get p1 :tstart) "\n")
@@ -2584,6 +2648,8 @@ TIME:      The sum of all time spend in this tree, in minutes.  This time
         (timestamp (plist-get params :timestamp))
         (ts (plist-get params :tstart))
         (te (plist-get params :tend))
+        (ws (plist-get params :wstart))
+        (ms (plist-get params :mstart))
         (block (plist-get params :block))
         (link (plist-get params :link))
         (tags (plist-get params :tags))
@@ -2595,7 +2661,7 @@ TIME:      The sum of all time spend in this tree, in minutes.  This time
 
     (setq org-clock-file-total-minutes nil)
     (when block
-      (setq cc (org-clock-special-range block nil t)
+      (setq cc (org-clock-special-range block nil t ws ms)
            ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
     (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
     (when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
@@ -2605,9 +2671,9 @@ TIME:      The sum of all time spend in this tree, in minutes.  This time
       (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
     ;; Now the times are strings we can parse.
     (if ts (setq ts (org-float-time
-                    (apply 'encode-time (org-parse-time-string ts)))))
+                    (seconds-to-time (org-matcher-time ts)))))
     (if te (setq te (org-float-time
-                    (apply 'encode-time (org-parse-time-string te)))))
+                    (seconds-to-time (org-matcher-time te)))))
     (save-excursion
       (org-clock-sum ts te
                     (unless (null matcher)
@@ -2751,9 +2817,7 @@ The details of what will be saved are regulated by the variable
                   (buffer-file-name b)
                   (or (not org-clock-persist-query-save)
                       (y-or-n-p (concat "Save current clock ("
-                                        (substring-no-properties
-                                         org-clock-heading)
-                                        ") "))))
+                                        org-clock-heading ") "))))
              (insert "(setq resume-clock '(\""
                      (buffer-file-name (org-clocking-buffer))
                      "\" . " (int-to-string (marker-position org-clock-marker))
index 5a59196baa1b1c288cda832bc801a2b255f0064f..523b42186b48cca7e0dbb479d2a76d99e4fd7564 100644 (file)
@@ -36,7 +36,7 @@
 (declare-function org-clock-sum-today "org-clock" (&optional headline-filter))
 
 (when (featurep 'xemacs)
-  (error "Do not load this file into XEmacs, use `org-colview-xemacs.el'"))
+  (error "Do not load this file into XEmacs, use `org-colview-xemacs.el' from the contrib/ directory"))
 
 ;;; Column View
 
@@ -169,8 +169,10 @@ This is the compiled version of the format.")
                            (get-text-property (point-at-bol) 'face))
                       'default))
         (color (list :foreground (face-attribute ref-face :foreground)))
-        (face (list color 'org-column ref-face))
-        (face1 (list color 'org-agenda-column-dateline ref-face))
+        (font (list :height (face-attribute 'default :height)
+                    :family (face-attribute 'default :family)))
+        (face (list color font 'org-column ref-face))
+        (face1 (list color font 'org-agenda-column-dateline ref-face))
         (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp))
         pom property ass width f string ov column val modval s2 title calc)
     ;; Check if the entry is in another buffer.
@@ -223,7 +225,7 @@ This is the compiled version of the format.")
       (setq s2 (org-columns-add-ellipses (or modval val) width))
       (setq string (format f s2))
       ;; Create the overlay
-      (org-unmodified
+      (org-with-silent-modifications
        (setq ov (org-columns-new-overlay
                 beg (setq beg (1+ beg)) string (if dateline face1 face)))
        (overlay-put ov 'keymap org-columns-map)
@@ -332,7 +334,7 @@ for the duration of the command.")
        (remove-hook 'post-command-hook 'org-columns-hscoll-title 'local))
       (move-marker org-columns-begin-marker nil)
       (move-marker org-columns-top-level-marker nil)
-      (org-unmodified
+      (org-with-silent-modifications
        (mapc 'delete-overlay org-columns-overlays)
        (setq org-columns-overlays nil)
        (let ((inhibit-read-only t))
@@ -384,7 +386,7 @@ CPHR is the complex heading regexp to use for parsing ITEM."
 (defun org-columns-quit ()
   "Remove the column overlays and in this way exit column editing."
   (interactive)
-  (org-unmodified
+  (org-with-silent-modifications
    (org-columns-remove-overlays)
    (let ((inhibit-read-only t))
      (remove-text-properties (point-min) (point-max) '(read-only t))))
@@ -414,6 +416,10 @@ If yes, throw an error indicating that changing it does not make sense."
       (org-columns-next-allowed-value)
     (org-columns-edit-value "TAGS")))
 
+(defvar org-agenda-overriding-columns-format nil
+  "When set, overrides any other format definition for the agenda.
+Don't set this, this is meant for dynamic scoping.")
+
 (defun org-columns-edit-value (&optional key)
   "Edit the value of the property at point in column view.
 Where possible, use the standard interface for changing this line."
@@ -488,7 +494,7 @@ Where possible, use the standard interface for changing this line."
          (org-agenda-columns)))
        (t
        (let ((inhibit-read-only t))
-         (org-unmodified
+         (org-with-silent-modifications
           (remove-text-properties
            (max (point-min) (1- bol)) eol '(read-only t)))
          (unwind-protect
@@ -589,9 +595,9 @@ an integer, select that value."
       (if (= nth -1) (setq nth 9)))
     (when (equal key "ITEM")
       (error "Cannot edit item headline from here"))
-    (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
+    (unless (or allowed (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM")))
       (error "Allowed values for this property have not been defined"))
-    (if (member key '("SCHEDULED" "DEADLINE"))
+    (if (member key '("SCHEDULED" "DEADLINE" "CLOCKSUM"))
        (setq nval (if previous 'earlier 'later))
       (if previous (setq allowed (reverse allowed)))
       (cond
@@ -899,10 +905,6 @@ display, or in the #+COLUMNS line of the current buffer."
                (insert-before-markers "#+COLUMNS: " fmt "\n")))
            (org-set-local 'org-columns-default-format fmt))))))
 
-(defvar org-agenda-overriding-columns-format nil
-  "When set, overrides any other format definition for the agenda.
-Don't set this, this is meant for dynamic scoping.")
-
 (defun org-columns-get-autowidth-alist (s cache)
   "Derive the maximum column widths from the format and the cache."
   (let ((start 0) rtn)
@@ -920,7 +922,7 @@ Don't set this, this is meant for dynamic scoping.")
 
 (defun org-columns-compute-all ()
   "Compute all columns that have operators defined."
-  (org-unmodified
+  (org-with-silent-modifications
    (remove-text-properties (point-min) (point-max) '(org-summaries t)))
   (let ((columns org-columns-current-fmt-compiled)
        (org-columns-time (time-to-number-of-days (current-time)))
@@ -996,7 +998,7 @@ Don't set this, this is meant for dynamic scoping.")
          (if (assoc property sum-alist)
              (setcdr (assoc property sum-alist) useval)
            (push (cons property useval) sum-alist)
-           (org-unmodified
+           (org-with-silent-modifications
             (add-text-properties sumpos (1+ sumpos)
                                  (list 'org-summaries sum-alist))))
          (when (and val (not (equal val (if flag str val))))
@@ -1058,8 +1060,7 @@ Don't set this, this is meant for dynamic scoping.")
    ((memq fmt '(estimate)) (org-estimate-print n printf))
    ((not (numberp n)) "")
    ((memq fmt '(add_times max_times min_times mean_times))
-    (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
-      (format org-time-clocksum-format h m)))
+    (org-hours-to-clocksum-string n))
    ((eq fmt 'checkbox)
     (cond ((= n (floor n)) "[X]")
          ((> n 1.) "[-]")
@@ -1305,10 +1306,10 @@ PARAMS is a property list of parameters:
                            (if (eq 'hline x) x (cons "" x)))
                          tbl))
        (setq tbl (append tbl (list (cons "/" (make-list nfields "<>"))))))
-      (setq pos (point))
       (when content-lines
        (while (string-match "^#" (car content-lines))
          (insert (pop content-lines) "\n")))
+      (setq pos (point))
       (insert (org-listtable-to-string tbl))
       (when (plist-get params :width)
        (insert "\n|" (mapconcat (lambda (x) (format "<%d>" (max 3 x)))
@@ -1404,7 +1405,7 @@ and tailing newline characters."
            ;; OK, the property is not defined.  Use appointment duration?
            (when (and org-agenda-columns-add-appointments-to-effort-sum
                       (setq d (get-text-property (point) 'duration)))
-             (setq d (org-minutes-to-hh:mm-string d))
+             (setq d (org-minutes-to-clocksum-string d))
              (put-text-property 0 (length d) 'face 'org-warning d)
              (push (cons org-effort-property d) p)))
          (push (cons (org-current-line) p) cache))
@@ -1510,9 +1511,8 @@ This will add overlays to the date lines, to show the summary for each day."
        (save-excursion
          (save-restriction
            (widen)
-           (org-unmodified
-            (remove-text-properties (point-min) (point-max)
-                                    '(org-summaries t)))
+           (org-with-silent-modifications
+            (remove-text-properties (point-min) (point-max) '(org-summaries t)))
            (goto-char (point-min))
            (org-columns-get-format-and-top-level)
            (while (setq fm (pop fmt))
index 9292b994367555314c16f97091685561795286ab..b714f13a66341cd8f97da583ba9cce41013d74a5 100644 (file)
@@ -113,6 +113,41 @@ any other entries, and any resulting duplicates will be removed entirely."
 \f
 ;;;; Emacs/XEmacs compatibility
 
+(eval-and-compile
+  (defun org-defvaralias (new-alias base-variable &optional docstring)
+    "Compatibility function for defvaralias.
+Don't do the aliasing when `defvaralias' is not bound."
+    (declare (indent 1))
+    (when (fboundp 'defvaralias)
+      (defvaralias new-alias base-variable docstring)))
+
+  (when (and (not (boundp 'user-emacs-directory))
+            (boundp 'user-init-directory))
+    (org-defvaralias 'user-emacs-directory 'user-init-directory)))
+
+(when (featurep 'xemacs)
+  (defadvice custom-handle-keyword
+    (around org-custom-handle-keyword
+           activate preactivate)
+    "Remove custom keywords not recognized to avoid producing an error."
+    (cond
+     ((eq (ad-get-arg 1) :package-version))
+     (t ad-do-it)))
+  (defadvice define-obsolete-variable-alias
+    (around org-define-obsolete-variable-alias
+           (obsolete-name current-name &optional when docstring)
+           activate preactivate)
+    "Declare arguments defined in later versions of Emacs."
+    ad-do-it)
+  (defadvice define-obsolete-function-alias
+    (around org-define-obsolete-function-alias
+           (obsolete-name current-name &optional when docstring)
+           activate preactivate)
+    "Declare arguments defined in later versions of Emacs."
+    ad-do-it)
+  (defvar customize-package-emacs-version-alist nil)
+  (defvar temporary-file-directory (temp-directory)))
+
 ;; Keys
 (defconst org-xemacs-key-equivalents
   '(([mouse-1] . [button1])
@@ -226,7 +261,7 @@ ignored in this case."
 ;; Region compatibility
 
 (defvar org-ignore-region nil
-  "To temporarily disable the active region.")
+  "Non-nil means temporarily disable the active region.")
 
 (defun org-region-active-p ()
   "Is `transient-mark-mode' on and the region active?
@@ -300,10 +335,11 @@ Works on both Emacs and XEmacs."
       (org-xemacs-without-invisibility (indent-line-to column))
     (indent-line-to column)))
 
-(defun org-move-to-column (column &optional force buffer)
-  (if (featurep 'xemacs)
-      (org-xemacs-without-invisibility (move-to-column column force buffer))
-    (move-to-column column force)))
+(defun org-move-to-column (column &optional force buffer ignore-invisible)
+  (let ((buffer-invisibility-spec ignore-invisible))
+    (if (featurep 'xemacs)
+       (org-xemacs-without-invisibility (move-to-column column force buffer))
+      (move-to-column column force))))
 
 (defun org-get-x-clipboard-compat (value)
   "Get the clipboard value on XEmacs or Emacs 21."
@@ -378,11 +414,11 @@ TIME defaults to the current time."
   "Suppress popup windows.
 Let-bind some variables to nil around BODY to achieve the desired
 effect, which variables to use depends on the Emacs version."
-    (if (org-version-check "24.2.50" "" :predicate)
-       `(let (pop-up-frames display-buffer-alist)
-          ,@body)
-      `(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
-        ,@body)))
+  (if (org-version-check "24.2.50" "" :predicate)
+      `(let (pop-up-frames display-buffer-alist)
+        ,@body)
+    `(let (pop-up-frames special-display-buffer-names special-display-regexps special-display-function)
+       ,@body)))
 
 (if (fboundp 'string-match-p)
     (defalias 'org-string-match-p 'string-match-p)
@@ -484,6 +520,29 @@ With two arguments, return floor and remainder of their quotient."
           (defun org-release () "N/A")
           (defun org-git-version () "N/A !!check installation!!"))))))
 
+(defun org-file-equal-p (f1 f2)
+  "Return t if files F1 and F2 are the same.
+Implements `file-equal-p' for older emacsen and XEmacs."
+  (if (fboundp 'file-equal-p)
+      (file-equal-p f1 f2)
+    (let (f1-attr f2-attr)
+      (and (setq f1-attr (file-attributes (file-truename f1)))
+          (setq f2-attr (file-attributes (file-truename f2)))
+          (equal f1-attr f2-attr)))))
+
+;; `buffer-narrowed-p' is available for Emacs >=24.3
+(defun org-buffer-narrowed-p ()
+  "Compatibility function for `buffer-narrowed-p'."
+  (if (fboundp 'buffer-narrowed-p)
+      (buffer-narrowed-p)
+    (/= (- (point-max) (point-min)) (buffer-size))))
+
+(defmacro org-with-silent-modifications (&rest body)
+  (if (fboundp 'with-silent-modifications)
+      `(with-silent-modifications ,@body)
+    `(org-unmodified ,@body)))
+(def-edebug-spec org-with-silent-modifications (body))
+
 (provide 'org-compat)
 
 ;;; org-compat.el ends here
index 2dfc4addcc25c87628d3734fb3788a0c39da2a19..b02a7ceffbd9ce495d1ce66e12f38ebd26cf4899 100644 (file)
@@ -139,11 +139,11 @@ See `org-crypt-disable-auto-save'."
       (message "org-decrypt: Decrypting entry with auto-save-mode enabled.  This may cause leakage."))
      ((eq org-crypt-disable-auto-save 'encrypt)
       (message "org-decrypt: Enabling re-encryption on auto-save.")
-      (add-hook 'auto-save-hook
-               (lambda ()
-                 (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
-                 (org-encrypt-entries))
-               nil t))
+      (org-add-hook 'auto-save-hook
+                   (lambda ()
+                     (message "org-crypt: Re-encrypting all decrypted entries due to auto-save.")
+                     (org-encrypt-entries))
+                   nil t))
      (t nil))))
 
 (defun org-crypt-key-for-heading ()
@@ -264,7 +264,7 @@ See `org-crypt-disable-auto-save'."
   "Add a hook to automatically encrypt entries before a file is saved to disk."
   (add-hook
    'org-mode-hook
-   (lambda () (add-hook 'before-save-hook 'org-encrypt-entries nil t))))
+   (lambda () (org-add-hook 'before-save-hook 'org-encrypt-entries nil t))))
 
 (add-hook 'org-reveal-start-hook 'org-decrypt-entry)
 
index 833c1dd6c1eaab6f7266fe8da83b05bfe30cb8d2..9d8ed6c62b309a27873cf3566deb29bd50f34ce3 100644 (file)
 ;;
 ;;     (progn
 ;;       (message "-- rebuilding tags tables...")
-;;       (mapc 'org-create-tags tags-table-list))
+;;       (mapc 'org-ctags-create-tags tags-table-list))
 
 ;;; Code:
 
@@ -156,11 +156,8 @@ Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/
 See the ctags documentation for more information.")
 
 (defcustom org-ctags-path-to-ctags
-  (case system-type
-    (windows-nt "ctags.exe")
-    (darwin "ctags-exuberant")
-    (t "ctags-exuberant"))
-  "Full path to the ctags executable file."
+  (if (executable-find "ctags-exuberant") "ctags-exuberant" "ctags")
+  "Name of the ctags executable file."
   :group 'org-ctags
   :version "24.1"
   :type 'file)
index e0f4d10bc2d74b4f0746751517fdeb5cd7e4e31f..dd4b1b0e1b3a05734d2f25677b6224aaabcf74c2 100644 (file)
@@ -72,7 +72,8 @@ tree can be found."
       (goto-char (prog1 (point) (widen))))))
 
 (defun org-datetree-find-year-create (year)
-  (let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)")
+  "Find the YEAR datetree or create it."
+  (let ((re "^\\*+[ \t]+\\([12][0-9]\\{3\\}\\)\\(\\s-*?\\([ \t]:[[:alnum:]:_@#%]+:\\)?\\s-*$\\)")
        match)
     (goto-char (point-min))
     (while (and (setq match (re-search-forward re nil t))
@@ -90,6 +91,7 @@ tree can be found."
       (org-datetree-insert-line year)))))
 
 (defun org-datetree-find-month-create (year month)
+  "Find the datetree for YEAR and MONTH or create it."
   (org-narrow-to-subtree)
   (let ((re (format "^\\*+[ \t]+%d-\\([01][0-9]\\) \\w+$" year))
        match)
@@ -109,6 +111,7 @@ tree can be found."
       (org-datetree-insert-line year month)))))
 
 (defun org-datetree-find-day-create (year month day)
+  "Find the datetree for YEAR, MONTH and DAY or create it."
   (org-narrow-to-subtree)
   (let ((re (format "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" year month))
        match)
diff --git a/lisp/org/org-docbook.el b/lisp/org/org-docbook.el
deleted file mode 100644 (file)
index 5253d91..0000000
+++ /dev/null
@@ -1,1453 +0,0 @@
-;;; org-docbook.el --- DocBook exporter for org-mode
-;;
-;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
-;;
-;; Emacs Lisp Archive Entry
-;; Filename: org-docbook.el
-;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
-;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
-;; Keywords: org, wp, docbook
-;; Description: Converts an org-mode buffer into DocBook
-;; URL:
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This library implements a DocBook exporter for org-mode.  The basic
-;; idea and design is very similar to what `org-export-as-html' has.
-;; Code prototype was also started with `org-export-as-html'.
-;;
-;; Put this file into your load-path and the following line into your
-;; ~/.emacs:
-;;
-;;   (require 'org-docbook)
-;;
-;; The interactive functions are similar to those of the HTML and LaTeX
-;; exporters:
-;;
-;; M-x `org-export-as-docbook'
-;; M-x `org-export-as-docbook-pdf'
-;; M-x `org-export-as-docbook-pdf-and-open'
-;; M-x `org-export-as-docbook-batch'
-;; M-x `org-export-as-docbook-to-buffer'
-;; M-x `org-export-region-as-docbook'
-;; M-x `org-replace-region-by-docbook'
-;;
-;; Note that, in order to generate PDF files using the DocBook XML files
-;; created by DocBook exporter, the following two variables have to be
-;; set based on what DocBook tools you use for XSLT processor and XSL-FO
-;; processor:
-;;
-;;   org-export-docbook-xslt-proc-command
-;;   org-export-docbook-xsl-fo-proc-command
-;;
-;; Check the document of these two variables to see examples of how they
-;; can be set.
-;;
-;; If the Org file to be exported contains special characters written in
-;; TeX-like syntax, like \alpha and \beta, you need to include the right
-;; entity file(s) in the DOCTYPE declaration for the DocBook XML file.
-;; This is required to make the DocBook XML file valid.  The DOCTYPE
-;; declaration string can be set using the following variable:
-;;
-;;   org-export-docbook-doctype
-;;
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-
-(require 'footnote)
-(require 'org)
-(require 'org-exp)
-(require 'org-html)
-(require 'format-spec)
-
-;;; Variables:
-
-(defvar org-docbook-para-open nil)
-(defvar org-export-docbook-inline-images t)
-(defvar org-export-docbook-link-org-files-as-docbook nil)
-
-(declare-function org-id-find-id-file "org-id" (id))
-
-;;; User variables:
-
-(defgroup org-export-docbook nil
-  "Options for exporting Org-mode files to DocBook."
-  :tag "Org Export DocBook"
-  :group 'org-export)
-
-(defcustom org-export-docbook-extension ".xml"
-  "Extension of DocBook XML files."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-header "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-  "Header of DocBook XML files."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-doctype nil
-  "DOCTYPE declaration string for DocBook XML files.
-This can be used to include entities that are needed to handle
-special characters in Org files.
-
-For example, if the Org file to be exported contains XHTML
-entities, you can set this variable to:
-
-\"<!DOCTYPE article [
-<!ENTITY % xhtml1-symbol PUBLIC
-\"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
-\"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
->
-%xhtml1-symbol;
-]>
-\"
-
-If you want to process DocBook documents without an Internet
-connection, it is suggested that you download the required entity
-file(s) and use system identifier(s) (external files) in the
-DOCTYPE declaration."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-article-header "<article xmlns=\"http://docbook.org/ns/docbook\"
-         xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"5.0\" xml:lang=\"en\">"
-  "Article header of DocBook XML files."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-section-id-prefix "sec-"
-  "Prefix of section IDs used during exporting.
-This can be set before exporting to avoid same set of section IDs
-being used again and again, which can be a problem when multiple
-people work on the same document."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-footnote-id-prefix "fn-"
-  "The prefix of footnote IDs used during exporting.
-Like `org-export-docbook-section-id-prefix', this variable can help
-avoid same set of footnote IDs being used multiple times."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-footnote-separator "<superscript>, </superscript>"
-  "Text used to separate footnotes."
-  :group 'org-export-docbook
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-docbook-emphasis-alist
-  `(("*" "<emphasis role=\"bold\">" "</emphasis>")
-    ("/" "<emphasis>" "</emphasis>")
-    ("_" "<emphasis role=\"underline\">" "</emphasis>")
-    ("=" "<code>" "</code>")
-    ("~" "<literal>" "</literal>")
-    ("+" "<emphasis role=\"strikethrough\">" "</emphasis>"))
-  "A list of DocBook expressions to convert emphasis fontifiers.
-Each element of the list is a list of three elements.
-The first element is the character used as a marker for fontification.
-The second element is a format string to wrap fontified text with.
-The third element decides whether to protect converted text from other
-conversions."
-  :group 'org-export-docbook
-  :type 'alist)
-
-(defcustom org-export-docbook-default-image-attributes
-  `(("align" . "\"center\"")
-    ("valign". "\"middle\""))
-  "Alist of default DocBook image attributes.
-These attributes will be inserted into element <imagedata> by
-default, but users can override them using `#+ATTR_DocBook:'."
-  :group 'org-export-docbook
-  :type 'alist)
-
-(defcustom org-export-docbook-inline-image-extensions
-  '("jpeg" "jpg" "png" "gif" "svg")
-  "Extensions of image files that can be inlined into DocBook."
-  :group 'org-export-docbook
-  :type '(repeat (string :tag "Extension")))
-
-(defcustom org-export-docbook-coding-system nil
-  "Coding system for DocBook XML files."
-  :group 'org-export-docbook
-  :type 'coding-system)
-
-(defcustom org-export-docbook-xslt-stylesheet nil
-  "File name of the XSLT stylesheet used by DocBook exporter.
-This XSLT stylesheet is used by
-`org-export-docbook-xslt-proc-command' to generate the Formatting
-Object (FO) files.  You can use either `fo/docbook.xsl' that
-comes with DocBook, or any customization layer you may have."
-  :group 'org-export-docbook
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-docbook-xslt-proc-command nil
-  "Format of XSLT processor command used by DocBook exporter.
-This command is used to process a DocBook XML file to generate
-the Formatting Object (FO) file.
-
-The value of this variable should be a format control string that
-includes three arguments: `%i', `%o', and `%s'.  During exporting
-time, `%i' is replaced by the input DocBook XML file name, `%o'
-is replaced by the output FO file name, and `%s' is replaced by
-`org-export-docbook-xslt-stylesheet' (or the #+XSLT option if it
-is specified in the Org file).
-
-For example, if you use Saxon as the XSLT processor, you may want
-to set the variable to
-
-  \"java com.icl.saxon.StyleSheet -o %o %i %s\"
-
-If you use Xalan, you can set it to
-
-  \"java org.apache.xalan.xslt.Process -out %o -in %i -xsl %s\"
-
-For xsltproc, the following string should work:
-
-  \"xsltproc --output %o %s %i\"
-
-You can include additional stylesheet parameters in this command.
-Just make sure that they meet the syntax requirement of each
-processor."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-xsl-fo-proc-command nil
-  "Format of XSL-FO processor command used by DocBook exporter.
-This command is used to process a Formatting Object (FO) file to
-generate the PDF file.
-
-The value of this variable should be a format control string that
-includes two arguments: `%i' and `%o'.  During exporting time,
-`%i' is replaced by the input FO file name, and `%o' is replaced
-by the output PDF file name.
-
-For example, if you use FOP as the XSL-FO processor, you can set
-the variable to
-
-  \"fop %i %o\""
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-keywords-markup "<literal>%s</literal>"
-  "A printf format string to be applied to keywords by DocBook exporter."
-  :group 'org-export-docbook
-  :type 'string)
-
-(defcustom org-export-docbook-timestamp-markup "<emphasis>%s</emphasis>"
-  "A printf format string to be applied to time stamps by DocBook exporter."
-  :group 'org-export-docbook
-  :type 'string)
-
-;;; Hooks
-
-(defvar org-export-docbook-final-hook nil
-  "Hook run at the end of DocBook export, in the new buffer.")
-
-;;; Autoload functions:
-
-;;;###autoload
-(defun org-export-as-docbook-batch ()
-  "Call `org-export-as-docbook' in batch style.
-This function can be used in batch processing.
-
-For example:
-
-$ emacs --batch
-        --load=$HOME/lib/emacs/org.el
-        --visit=MyOrgFile.org --funcall org-export-as-docbook-batch"
-  (org-export-as-docbook))
-
-;;;###autoload
-(defun org-export-as-docbook-to-buffer ()
-  "Call `org-export-as-docbook' with output to a temporary buffer.
-No file is created."
-  (interactive)
-  (org-export-as-docbook nil "*Org DocBook Export*")
-  (when org-export-show-temporary-export-buffer
-    (switch-to-buffer-other-window "*Org DocBook Export*")))
-
-;;;###autoload
-(defun org-replace-region-by-docbook (beg end)
-  "Replace the region from BEG to END with its DocBook export.
-It assumes the region has `org-mode' syntax, and then convert it to
-DocBook.  This can be used in any buffer.  For example, you could
-write an itemized list in `org-mode' syntax in an DocBook buffer and
-then use this command to convert it."
-  (interactive "r")
-  (let (reg docbook buf)
-    (save-window-excursion
-      (if (derived-mode-p 'org-mode)
-         (setq docbook (org-export-region-as-docbook
-                        beg end t 'string))
-       (setq reg (buffer-substring beg end)
-             buf (get-buffer-create "*Org tmp*"))
-       (with-current-buffer buf
-         (erase-buffer)
-         (insert reg)
-         (org-mode)
-         (setq docbook (org-export-region-as-docbook
-                        (point-min) (point-max) t 'string)))
-       (kill-buffer buf)))
-    (delete-region beg end)
-    (insert docbook)))
-
-;;;###autoload
-(defun org-export-region-as-docbook (beg end &optional body-only buffer)
-  "Convert region from BEG to END in `org-mode' buffer to DocBook.
-If prefix arg BODY-ONLY is set, omit file header and footer and
-only produce the region of converted text, useful for
-cut-and-paste operations.  If BUFFER is a buffer or a string,
-use/create that buffer as a target of the converted DocBook.  If
-BUFFER is the symbol `string', return the produced DocBook as a
-string and leave not buffer behind.  For example, a Lisp program
-could call this function in the following way:
-
-  (setq docbook (org-export-region-as-docbook beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (interactive "r\nP")
-  (when (org-called-interactively-p 'any)
-    (setq buffer "*Org DocBook Export*"))
-  (let ((transient-mark-mode t)
-       (zmacs-regions t)
-       rtn)
-    (goto-char end)
-    (set-mark (point)) ;; To activate the region
-    (goto-char beg)
-    (setq rtn (org-export-as-docbook nil buffer body-only))
-    (if (fboundp 'deactivate-mark) (deactivate-mark))
-    (if (and (org-called-interactively-p 'any) (bufferp rtn))
-       (switch-to-buffer-other-window rtn)
-      rtn)))
-
-;;;###autoload
-(defun org-export-as-docbook-pdf (&optional ext-plist to-buffer body-only pub-dir)
-  "Export as DocBook XML file, and generate PDF file."
-  (interactive "P")
-  (if (or (not org-export-docbook-xslt-proc-command)
-         (not (string-match "%[ios].+%[ios].+%[ios]" org-export-docbook-xslt-proc-command)))
-      (error "XSLT processor command is not set correctly"))
-  (if (or (not org-export-docbook-xsl-fo-proc-command)
-         (not (string-match "%[io].+%[io]" org-export-docbook-xsl-fo-proc-command)))
-      (error "XSL-FO processor command is not set correctly"))
-  (message "Exporting to PDF...")
-  (let* ((wconfig (current-window-configuration))
-        (opt-plist
-         (org-export-process-option-filters
-          (org-combine-plists (org-default-export-plist)
-                              ext-plist
-                              (org-infile-export-plist))))
-        (docbook-buf (org-export-as-docbook ext-plist to-buffer body-only pub-dir))
-        (filename (buffer-file-name docbook-buf))
-        (base (file-name-sans-extension filename))
-        (fofile (concat base ".fo"))
-        (pdffile (concat base ".pdf")))
-    (and (file-exists-p pdffile) (delete-file pdffile))
-    (message "Processing DocBook XML file...")
-    (shell-command (format-spec org-export-docbook-xslt-proc-command
-                               (format-spec-make
-                                ?i (shell-quote-argument filename)
-                                ?o (shell-quote-argument fofile)
-                                ?s (shell-quote-argument
-                                    (or (plist-get opt-plist :xslt)
-                                        org-export-docbook-xslt-stylesheet)))))
-    (shell-command (format-spec org-export-docbook-xsl-fo-proc-command
-                               (format-spec-make
-                                ?i (shell-quote-argument fofile)
-                                ?o (shell-quote-argument pdffile))))
-    (message "Processing DocBook file...done")
-    (if (not (file-exists-p pdffile))
-       (error "PDF file was not produced")
-      (set-window-configuration wconfig)
-      (message "Exporting to PDF...done")
-      pdffile)))
-
-;;;###autoload
-(defun org-export-as-docbook-pdf-and-open ()
-  "Export as DocBook XML file, generate PDF file, and open it."
-  (interactive)
-  (let ((pdffile (org-export-as-docbook-pdf)))
-    (if pdffile
-       (org-open-file pdffile)
-      (error "PDF file was not produced"))))
-
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
-
-;;;###autoload
-(defun org-export-as-docbook (&optional ext-plist to-buffer body-only pub-dir)
-  "Export the current buffer as a DocBook file.
-If there is an active region, export only the region.  When
-HIDDEN is obsolete and does nothing.  EXT-PLIST is a
-property list with external parameters overriding org-mode's
-default settings, but still inferior to file-local settings.
-When TO-BUFFER is non-nil, create a buffer with that name and
-export to that buffer.  If TO-BUFFER is the symbol `string',
-don't leave any buffer behind but just return the resulting HTML
-as a string.  When BODY-ONLY is set, don't produce the file
-header and footer, simply return the content of the document (all
-top-level sections).  When PUB-DIR is set, use this as the
-publishing directory."
-  (interactive "P")
-  (run-hooks 'org-export-first-hook)
-
-  ;; Make sure we have a file name when we need it.
-  (when (and (not (or to-buffer body-only))
-            (not buffer-file-name))
-    (if (buffer-base-buffer)
-       (org-set-local 'buffer-file-name
-                      (with-current-buffer (buffer-base-buffer)
-                        buffer-file-name))
-      (error "Need a file name to be able to export")))
-
-  (message "Exporting...")
-  (setq-default org-todo-line-regexp org-todo-line-regexp)
-  (setq-default org-deadline-line-regexp org-deadline-line-regexp)
-  (setq-default org-done-keywords org-done-keywords)
-  (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
-  (let* ((opt-plist
-         (org-export-process-option-filters
-          (org-combine-plists (org-default-export-plist)
-                              ext-plist
-                              (org-infile-export-plist))))
-        (link-validate (plist-get opt-plist :link-validation-function))
-        valid
-        (odd org-odd-levels-only)
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (level-offset (if subtree-p
-                          (save-excursion
-                            (goto-char rbeg)
-                            (+ (funcall outline-level)
-                               (if org-odd-levels-only 1 0)))
-                        0))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        ;; The following two are dynamically scoped into other
-        ;; routines below.
-        (org-current-export-dir
-         (or pub-dir (org-export-directory :docbook opt-plist)))
-        (org-current-export-file buffer-file-name)
-        (level 0) (line "") (origline "") txt todo
-        (filename (if to-buffer nil
-                    (expand-file-name
-                     (concat
-                      (file-name-sans-extension
-                       (or (and subtree-p
-                                (org-entry-get (region-beginning)
-                                               "EXPORT_FILE_NAME" t))
-                           (file-name-nondirectory buffer-file-name)))
-                      org-export-docbook-extension)
-                     (file-name-as-directory
-                      (or pub-dir (org-export-directory :docbook opt-plist))))))
-        (current-dir (if buffer-file-name
-                         (file-name-directory buffer-file-name)
-                       default-directory))
-        (auto-insert nil); Avoid any auto-insert stuff for the new file
-        (buffer (if to-buffer
-                    (cond
-                     ((eq to-buffer 'string)
-                      (get-buffer-create "*Org DocBook Export*"))
-                     (t (get-buffer-create to-buffer)))
-                  (find-file-noselect filename)))
-        ;; org-levels-open is a global variable
-        (org-levels-open (make-vector org-level-max nil))
-        (date (plist-get opt-plist :date))
-        (author (or (plist-get opt-plist :author)
-                    user-full-name))
-        (email (plist-get opt-plist :email))
-        firstname othername surname
-        (title (or (and subtree-p (org-export-get-title-from-subtree))
-                   (plist-get opt-plist :title)
-                   (and (not
-                         (plist-get opt-plist :skip-before-1st-heading))
-                        (org-export-grab-title-from-buffer))
-                   (and buffer-file-name
-                        (file-name-sans-extension
-                         (file-name-nondirectory buffer-file-name)))
-                   "UNTITLED"))
-        ;; We will use HTML table formatter to export tables to DocBook
-        ;; format, so need to set html-table-tag here.
-        (html-table-tag (plist-get opt-plist :html-table-tag))
-        (quote-re0   (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
-        (quote-re    (format org-heading-keyword-regexp-format
-                             org-quote-string))
-        (inquote     nil)
-        (infixed     nil)
-        (inverse     nil)
-        (llt org-plain-list-ordered-item-terminator)
-        (email (plist-get opt-plist :email))
-        (language (plist-get opt-plist :language))
-        (lang-words  nil)
-        cnt
-        (start 0)
-        (coding-system (and (boundp 'buffer-file-coding-system)
-                            buffer-file-coding-system))
-        (coding-system-for-write (or org-export-docbook-coding-system
-                                     coding-system))
-        (save-buffer-coding-system (or org-export-docbook-coding-system
-                                       coding-system))
-        (charset (and coding-system-for-write
-                      (fboundp 'coding-system-get)
-                      (coding-system-get coding-system-for-write
-                                         'mime-charset)))
-        (region
-         (buffer-substring
-          (if region-p (region-beginning) (point-min))
-          (if region-p (region-end) (point-max))))
-        (org-export-footnotes-seen nil)
-        (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
-        (lines
-         (org-split-string
-          (org-export-preprocess-string
-           region
-           :emph-multiline t
-           :for-backend 'docbook
-           :skip-before-1st-heading
-           (plist-get opt-plist :skip-before-1st-heading)
-           :drawers (plist-get opt-plist :drawers)
-           :todo-keywords (plist-get opt-plist :todo-keywords)
-           :tasks (plist-get opt-plist :tasks)
-           :tags (plist-get opt-plist :tags)
-           :priority (plist-get opt-plist :priority)
-           :footnotes (plist-get opt-plist :footnotes)
-           :timestamps (plist-get opt-plist :timestamps)
-           :archived-trees
-           (plist-get opt-plist :archived-trees)
-           :select-tags (plist-get opt-plist :select-tags)
-           :exclude-tags (plist-get opt-plist :exclude-tags)
-           :add-text
-           (plist-get opt-plist :text)
-           :LaTeX-fragments
-           (plist-get opt-plist :LaTeX-fragments))
-          "[\r\n]"))
-        ;; Use literal output to show check boxes.
-        (checkbox-start
-         (nth 1 (assoc "=" org-export-docbook-emphasis-alist)))
-        (checkbox-end
-         (nth 2 (assoc "=" org-export-docbook-emphasis-alist)))
-        table-open type
-        table-buffer table-orig-buffer
-        ind item-type starter
-        rpl path attr caption label desc descp desc1 desc2 link
-        fnc item-tag item-number
-        footref-seen footnote-list
-        id-file
-        )
-
-    ;; Fine detailed info about author name.
-    (if (string-match "\\([^ ]+\\) \\(.+ \\)?\\([^ ]+\\)" author)
-       (progn
-         (setq firstname (match-string 1 author)
-               othername (or (match-string 2 author) "")
-               surname (match-string 3 author))))
-
-    ;; Get all footnote text.
-    (setq footnote-list
-         (org-export-docbook-get-footnotes lines))
-
-    (let ((inhibit-read-only t))
-      (org-unmodified
-       (remove-text-properties (point-min) (point-max)
-                              '(:org-license-to-kill t))))
-
-    (setq org-min-level (org-get-min-level lines level-offset))
-    (setq org-last-level org-min-level)
-    (org-init-section-numbers)
-
-    ;; Get and save the date.
-    (cond
-     ((and date (string-match "%" date))
-      (setq date (format-time-string date)))
-     (date)
-     (t (setq date (format-time-string "%Y-%m-%d %T %Z"))))
-
-    ;; Get the language-dependent settings
-    (setq lang-words (or (assoc language org-export-language-setup)
-                        (assoc "en" org-export-language-setup)))
-
-    ;; Switch to the output buffer.  Use fundamental-mode for now.  We
-    ;; could turn on nXML mode later and do some indentation.
-    (set-buffer buffer)
-    (let ((inhibit-read-only t)) (erase-buffer))
-    (fundamental-mode)
-    (org-install-letbind)
-
-    (and (fboundp 'set-buffer-file-coding-system)
-        (set-buffer-file-coding-system coding-system-for-write))
-
-    ;; The main body...
-    (let ((case-fold-search nil)
-         (org-odd-levels-only odd))
-
-      ;; Create local variables for all options, to make sure all called
-      ;; functions get the correct information
-      (mapc (lambda (x)
-             (set (make-local-variable (nth 2 x))
-                  (plist-get opt-plist (car x))))
-           org-export-plist-vars)
-
-      ;; Insert DocBook file header, title, and author info.
-      (unless body-only
-       (insert org-export-docbook-header)
-       (if org-export-docbook-doctype
-           (insert org-export-docbook-doctype))
-       (insert "<!-- Date: " date " -->\n")
-       (insert (format "<!-- DocBook XML file generated by Org-mode %s Emacs %s -->\n"
-                       (org-version) emacs-major-version))
-       (insert org-export-docbook-article-header)
-       (insert (format
-                "\n  <title>%s</title>
-  <info>
-    <author>
-      <personname>
-        <firstname>%s</firstname> <othername>%s</othername> <surname>%s</surname>
-      </personname>
-      %s
-    </author>
-  </info>\n"
-                (org-docbook-expand title)
-                firstname othername surname
-                (if (and org-export-email-info
-                         email (string-match "\\S-" email))
-                    (concat "<email>" email "</email>") "")
-                )))
-
-      (org-init-section-numbers)
-
-      (org-export-docbook-open-para)
-
-      ;; Loop over all the lines...
-      (while (setq line (pop lines) origline line)
-       (catch 'nextline
-
-         ;; End of quote section?
-         (when (and inquote (string-match org-outline-regexp-bol line))
-           (insert "]]></programlisting>\n")
-           (org-export-docbook-open-para)
-           (setq inquote nil))
-         ;; Inside a quote section?
-         (when inquote
-           (insert (org-docbook-protect line) "\n")
-           (throw 'nextline nil))
-
-         ;; Fixed-width, verbatim lines (examples)
-         (when (and org-export-with-fixed-width
-                    (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
-           (when (not infixed)
-             (setq infixed t)
-             (org-export-docbook-close-para-maybe)
-             (insert "<programlisting><![CDATA["))
-           (insert (match-string 3 line) "\n")
-           (when (or (not lines)
-                     (not (string-match "^[ \t]*\\(:.*\\)"
-                                        (car lines))))
-             (setq infixed nil)
-             (insert "]]></programlisting>\n")
-             (org-export-docbook-open-para))
-           (throw 'nextline nil))
-
-         ;; Protected HTML
-         (when (get-text-property 0 'org-protected line)
-           (let (par (ind (get-text-property 0 'original-indentation line)))
-             (when (re-search-backward
-                    "\\(<para>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
-               (setq par (match-string 1))
-               (replace-match "\\2\n"))
-             (insert line "\n")
-             (while (and lines
-                         (or (= (length (car lines)) 0)
-                             (not ind)
-                             (equal ind (get-text-property 0 'original-indentation (car lines))))
-                         (or (= (length (car lines)) 0)
-                             (get-text-property 0 'org-protected (car lines))))
-               (insert (pop lines) "\n"))
-             (and par (insert "<para>\n")))
-           (throw 'nextline nil))
-
-         ;; Start of block quotes and verses
-         (when (or (equal "ORG-BLOCKQUOTE-START" line)
-                   (and (equal "ORG-VERSE-START" line)
-                        (setq inverse t)))
-           (org-export-docbook-close-para-maybe)
-           (insert "<blockquote>")
-           ;; Check whether attribution for this blockquote exists.
-           (let (tmp1
-                 attribution
-                 (end (if inverse "ORG-VERSE-END" "ORG-BLOCKQUOTE-END"))
-                 (quote-lines nil))
-             (while (and (setq tmp1 (pop lines))
-                         (not (equal end tmp1)))
-               (push tmp1 quote-lines))
-             (push tmp1 lines)         ; Put back quote end mark
-             ;; Check the last line in the quote to see if it contains
-             ;; the attribution.
-             (setq tmp1 (pop quote-lines))
-             (if (string-match "\\(^.*\\)\\(--[ \t]+\\)\\(.+\\)$" tmp1)
-                 (progn
-                   (setq attribution (match-string 3 tmp1))
-                   (when (save-match-data
-                           (string-match "[^ \t]" (match-string 1 tmp1)))
-                     (push (match-string 1 tmp1) lines)))
-               (push tmp1 lines))
-             (while (setq tmp1 (pop quote-lines))
-               (push tmp1 lines))
-             (when attribution
-               (insert "<attribution>" attribution "</attribution>")))
-           ;; Insert <literallayout> for verse.
-           (if inverse
-               (insert "\n<literallayout>")
-             (org-export-docbook-open-para))
-           (throw 'nextline nil))
-
-         ;; End of block quotes
-         (when (equal "ORG-BLOCKQUOTE-END" line)
-           (org-export-docbook-close-para-maybe)
-           (insert "</blockquote>\n")
-           (org-export-docbook-open-para)
-           (throw 'nextline nil))
-
-         ;; End of verses
-         (when (equal "ORG-VERSE-END" line)
-           (insert "</literallayout>\n</blockquote>\n")
-           (org-export-docbook-open-para)
-           (setq inverse nil)
-           (throw 'nextline nil))
-
-         ;; Text centering.  Element <para role="centered"> does not
-         ;; seem to work with FOP, so for now we use <informaltable> to
-         ;; center the text, which can contain multiple paragraphs.
-         (when (equal "ORG-CENTER-START" line)
-           (org-export-docbook-close-para-maybe)
-           (insert "<informaltable frame=\"none\" colsep=\"0\" rowsep=\"0\">\n"
-                   "<tgroup align=\"center\" cols=\"1\">\n"
-                   "<tbody><row><entry>\n")
-           (org-export-docbook-open-para)
-           (throw 'nextline nil))
-
-         (when (equal "ORG-CENTER-END" line)
-           (org-export-docbook-close-para-maybe)
-           (insert "</entry></row></tbody>\n"
-                   "</tgroup>\n</informaltable>\n")
-           (org-export-docbook-open-para)
-           (throw 'nextline nil))
-
-         ;; Make targets to anchors.  Note that currently FOP does not
-         ;; seem to support <anchor> tags when generating PDF output,
-         ;; but this can be used in DocBook --> HTML conversion.
-         (setq start 0)
-         (while (string-match
-                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
-           (cond
-            ((get-text-property (match-beginning 1) 'org-protected line)
-             (setq start (match-end 1)))
-            ((match-end 2)
-             (setq line (replace-match
-                         (format "@<anchor xml:id=\"%s\"/>"
-                                 (org-solidify-link-text (match-string 1 line)))
-                         t t line)))
-            (t
-             (setq line (replace-match
-                         (format "@<anchor xml:id=\"%s\"/>"
-                                 (org-solidify-link-text (match-string 1 line)))
-                         t t line)))))
-
-         ;; Put time stamps and related keywords into special mark-up
-         ;; elements.
-         (setq line (org-export-docbook-handle-time-stamps line))
-
-         ;; Replace "&", "<" and ">" by "&amp;", "&lt;" and "&gt;".
-         ;; Handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>").
-         ;; Also handle sub_superscripts and check boxes.
-         (or (string-match org-table-hline-regexp line)
-             (setq line (org-docbook-expand line)))
-
-         ;; Format the links
-         (setq start 0)
-         (while (string-match org-bracket-link-analytic-regexp++ line start)
-           (setq start (match-beginning 0))
-           (setq path (save-match-data (org-link-unescape
-                                        (match-string 3 line))))
-           (setq type (cond
-                       ((match-end 2) (match-string 2 line))
-                       ((save-match-data
-                          (or (file-name-absolute-p path)
-                              (string-match "^\\.\\.?/" path)))
-                        "file")
-                       (t "internal")))
-           (setq path (org-extract-attributes (org-link-unescape path)))
-           (setq attr (get-text-property 0 'org-attributes path)
-                 caption (get-text-property 0 'org-caption path)
-                 label (get-text-property 0 'org-label path))
-           (setq desc1 (if (match-end 5) (match-string 5 line))
-                 desc2 (if (match-end 2) (concat type ":" path) path)
-                 descp (and desc1 (not (equal desc1 desc2)))
-                 desc (or desc1 desc2))
-           ;; Make an image out of the description if that is so wanted
-           (when (and descp (org-file-image-p
-                             desc org-export-docbook-inline-image-extensions))
-             (save-match-data
-               (if (string-match "^file:" desc)
-                   (setq desc (substring desc (match-end 0))))))
-           ;; FIXME: do we need to unescape here somewhere?
-           (cond
-            ((equal type "internal")
-             (setq rpl (format "<link linkend=\"%s\">%s</link>"
-                               (org-solidify-link-text
-                                (save-match-data (org-link-unescape path)) nil)
-                               (org-export-docbook-format-desc desc))))
-            ((and (equal type "id")
-                  (setq id-file (org-id-find-id-file path)))
-             ;; This is an id: link to another file (if it was the same file,
-             ;; it would have become an internal link...)
-             (save-match-data
-               (setq id-file (file-relative-name
-                              id-file (file-name-directory org-current-export-file)))
-               (setq id-file (concat (file-name-sans-extension id-file)
-                                     org-export-docbook-extension))
-               (setq rpl (format "<link xlink:href=\"%s#%s\">%s</link>"
-                                 id-file path (org-export-docbook-format-desc desc)))))
-            ((member type '("http" "https"))
-             ;; Standard URL, just check if we need to inline an image
-             (if (and (or (eq t org-export-docbook-inline-images)
-                          (and org-export-docbook-inline-images (not descp)))
-                      (org-file-image-p
-                       path org-export-docbook-inline-image-extensions))
-                 (setq rpl (org-export-docbook-format-image
-                            (concat type ":" path)))
-               (setq link (concat type ":" path))
-               (setq rpl (format "<link xlink:href=\"%s\">%s</link>"
-                                 (org-export-html-format-href link)
-                                 (org-export-docbook-format-desc desc)))
-               ))
-            ((member type '("ftp" "mailto" "news"))
-             ;; Standard URL
-             (setq link (concat type ":" path))
-             (setq rpl (format "<link xlink:href=\"%s\">%s</link>"
-                               (org-export-html-format-href link)
-                               (org-export-docbook-format-desc desc))))
-            ((string= type "coderef")
-             (setq rpl (format (org-export-get-coderef-format path (and descp desc))
-                               (cdr (assoc path org-export-code-refs)))))
-            ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
-             ;; The link protocol has a function for format the link
-             (setq rpl
-                   (save-match-data
-                     (funcall fnc (org-link-unescape path) desc1 'html))))
-
-            ((string= type "file")
-             ;; FILE link
-             (let* ((filename path)
-                    (abs-p (file-name-absolute-p filename))
-                    thefile file-is-image-p search)
-               (save-match-data
-                 (if (string-match "::\\(.*\\)" filename)
-                     (setq search (match-string 1 filename)
-                           filename (replace-match "" t nil filename)))
-                 (setq valid
-                       (if (functionp link-validate)
-                           (funcall link-validate filename current-dir)
-                         t))
-                 (setq file-is-image-p
-                       (org-file-image-p
-                        filename org-export-docbook-inline-image-extensions))
-                 (setq thefile (if abs-p (expand-file-name filename) filename))
-                 ;; Carry over the properties (expand-file-name will
-                 ;; discard the properties of filename)
-                 (add-text-properties 0 (1- (length thefile))
-                                      (list 'org-caption caption
-                                            'org-attributes attr
-                                            'org-label label)
-                                      thefile)
-                 (when (and org-export-docbook-link-org-files-as-docbook
-                            (string-match "\\.org$" thefile))
-                   (setq thefile (concat (substring thefile 0
-                                                    (match-beginning 0))
-                                         org-export-docbook-extension))
-                   (if (and search
-                            ;; make sure this is can be used as target search
-                            (not (string-match "^[0-9]*$" search))
-                            (not (string-match "^\\*" search))
-                            (not (string-match "^/.*/$" search)))
-                       (setq thefile (concat thefile "#"
-                                             (org-solidify-link-text
-                                              (org-link-unescape search)))))
-                   (when (string-match "^file:" desc)
-                     (setq desc (replace-match "" t t desc))
-                     (if (string-match "\\.org$" desc)
-                         (setq desc (replace-match "" t t desc))))))
-               (setq rpl (if (and file-is-image-p
-                                  (or (eq t org-export-docbook-inline-images)
-                                      (and org-export-docbook-inline-images
-                                           (not descp))))
-                             (progn
-                               (message "image %s %s" thefile org-docbook-para-open)
-                               (org-export-docbook-format-image thefile))
-                           (format "<link xlink:href=\"%s\">%s</link>"
-                                   thefile (org-export-docbook-format-desc desc))))
-               (if (not valid) (setq rpl desc))))
-
-            (t
-             ;; Just publish the path, as default
-             (setq rpl (concat "&lt;" type ":"
-                               (save-match-data (org-link-unescape path))
-                               "&gt;"))))
-           (setq line (replace-match rpl t t line)
-                 start (+ start (length rpl))))
-
-         ;; TODO items: can we do something better?!
-         (if (and (string-match org-todo-line-regexp line)
-                  (match-beginning 2))
-             (setq line
-                   (concat (substring line 0 (match-beginning 2))
-                           "[" (match-string 2 line) "]"
-                           (substring line (match-end 2)))))
-
-         ;; Does this contain a reference to a footnote?
-         (when org-export-with-footnotes
-           (setq start 0)
-           (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
-             ;; Discard protected matches not clearly identified as
-             ;; footnote markers.
-             (if (or (get-text-property (match-beginning 2) 'org-protected line)
-                     (not (get-text-property (match-beginning 2) 'org-footnote line)))
-                 (setq start (match-end 2))
-               (let* ((num (match-string 2 line))
-                      (footnote-def (assoc num footnote-list)))
-                 (if (assoc num footref-seen)
-                     (setq line (replace-match
-                                 (format "%s<footnoteref linkend=\"%s%s\"/>"
-                                         (match-string 1 line)
-                                         org-export-docbook-footnote-id-prefix num)
-                                 t t line))
-                   (setq line (replace-match
-                               (concat
-                                (format "%s<footnote xml:id=\"%s%s\"><para>%s</para></footnote>"
-                                        (match-string 1 line)
-                                        org-export-docbook-footnote-id-prefix
-                                        num
-                                        (if footnote-def
-                                            (save-match-data
-                                              (org-docbook-expand (cdr footnote-def)))
-                                          (format "FOOTNOTE DEFINITION NOT FOUND: %s" num)))
-                                ;; If another footnote is following the
-                                ;; current one, add a separator.
-                                (if (save-match-data
-                                      (string-match "\\`\\[[0-9]+\\]"
-                                                    (substring line (match-end 0))))
-                                    org-export-docbook-footnote-separator
-                                  ""))
-                               t t line))
-                   (push (cons num 1) footref-seen))))))
-
-         (cond
-          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
-           ;; This is a headline
-           (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
-                                        level-offset))
-                 txt (match-string 2 line))
-           (if (string-match quote-re0 txt)
-               (setq txt (replace-match "" t t txt)))
-           (org-export-docbook-level-start level txt)
-           ;; QUOTES
-           (when (string-match quote-re line)
-             (org-export-docbook-close-para-maybe)
-             (insert "<programlisting><![CDATA[")
-             (setq inquote t)))
-
-          ;; Tables: since version 4.3 of DocBook DTD, HTML tables are
-          ;; supported.  We can use existing HTML table exporter code
-          ;; here.
-          ((and org-export-with-tables
-                (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
-           (if (not table-open)
-               ;; New table starts
-               (setq table-open t
-                     table-buffer nil
-                     table-orig-buffer nil))
-           ;; Accumulate lines
-           (setq table-buffer (cons line table-buffer)
-                 table-orig-buffer (cons origline table-orig-buffer))
-           (when (or (not lines)
-                     (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
-                                        (car lines))))
-             (setq table-open nil
-                   table-buffer (nreverse table-buffer)
-                   table-orig-buffer (nreverse table-orig-buffer))
-             (org-export-docbook-close-para-maybe)
-             (insert (org-export-docbook-finalize-table
-                      (org-format-table-html table-buffer table-orig-buffer
-                                             'no-css)))))
-
-          ;; Normal lines
-          (t
-           ;; This line either is list item or end a list.
-           (when (when (get-text-property 0 'list-item line)
-                   (setq line (org-export-docbook-list-line
-                               line
-                               (get-text-property 0 'list-item line)
-                               (get-text-property 0 'list-struct line)
-                               (get-text-property 0 'list-prevs line)))))
-
-           ;; Empty lines start a new paragraph.  If hand-formatted lists
-           ;; are not fully interpreted, lines starting with "-", "+", "*"
-           ;; also start a new paragraph.
-           (if (and (string-match "^ [-+*]-\\|^[ \t]*$" line)
-                    (not inverse))
-               (org-export-docbook-open-para))
-
-           ;; Is this the start of a footnote?
-           (when org-export-with-footnotes
-             (when (and (boundp 'footnote-section-tag-regexp)
-                        (string-match (concat "^" footnote-section-tag-regexp)
-                                      line))
-               ;; ignore this line
-               (throw 'nextline nil))
-             ;; These footnote lines have been read and saved before,
-             ;; ignore them at this time.
-             (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
-               (org-export-docbook-close-para-maybe)
-               (throw 'nextline nil)))
-
-           ;; FIXME: It might be a good idea to add an option to
-           ;; support line break processing instruction <?linebreak?>.
-           ;; Org-mode supports line break "\\" in HTML exporter, and
-           ;; some DocBook users may also want to force line breaks
-           ;; even though DocBook only supports that in
-           ;; <literallayout>.
-
-           (insert line "\n")))))
-
-      ;; Properly close all local lists and other lists
-      (when inquote
-       (insert "]]></programlisting>\n")
-       (org-export-docbook-open-para))
-
-      ;; Close all open sections.
-      (org-export-docbook-level-start 1 nil)
-
-      (unless (plist-get opt-plist :buffer-will-be-killed)
-       (normal-mode)
-       (if (eq major-mode (default-value 'major-mode))
-           (nxml-mode)))
-
-      ;; Remove empty paragraphs.  Replace them with a newline.
-      (goto-char (point-min))
-      (while (re-search-forward
-             "[ \r\n\t]*\\(<para>\\)[ \r\n\t]*</para>[ \r\n\t]*" nil t)
-       (when (not (get-text-property (match-beginning 1) 'org-protected))
-         (replace-match "\n")
-         (backward-char 1)))
-      ;; Fill empty sections with <para></para>.  This is to make sure
-      ;; that the DocBook document generated is valid and well-formed.
-      (goto-char (point-min))
-      (while (re-search-forward
-             "</title>\\([ \r\n\t]*\\)</section>" nil t)
-       (when (not (get-text-property (match-beginning 0) 'org-protected))
-         (replace-match "\n<para></para>\n" nil nil nil 1)))
-      ;; Insert the last closing tag.
-      (goto-char (point-max))
-      (unless body-only
-       (insert "</article>"))
-      (run-hooks 'org-export-docbook-final-hook)
-      (or to-buffer (save-buffer))
-      (goto-char (point-min))
-      (or (org-export-push-to-kill-ring "DocBook")
-         (message "Exporting... done"))
-      (if (eq to-buffer 'string)
-         (prog1 (buffer-substring (point-min) (point-max))
-           (kill-buffer (current-buffer)))
-       (current-buffer)))))
-
-(defun org-export-docbook-open-para ()
-  "Insert <para>, but first close previous paragraph if any."
-  (org-export-docbook-close-para-maybe)
-  (insert "\n<para>")
-  (setq org-docbook-para-open t))
-
-(defun org-export-docbook-close-para-maybe ()
-  "Close DocBook paragraph if there is one open."
-  (when org-docbook-para-open
-    (insert "</para>\n")
-    (setq org-docbook-para-open nil)))
-
-(defun org-export-docbook-close-li (&optional type)
-  "Close list if necessary."
-  (org-export-docbook-close-para-maybe)
-  (if (equal type "d")
-      (insert "</listitem></varlistentry>\n")
-    (insert "</listitem>\n")))
-
-(defun org-export-docbook-level-start (level title)
-  "Insert a new level in DocBook export.
-When TITLE is nil, just close all open levels."
-  (org-export-docbook-close-para-maybe)
-  (let* ((target (and title (org-get-text-property-any 0 'target title)))
-        (l org-level-max)
-        section-number)
-    (while (>= l level)
-      (if (aref org-levels-open (1- l))
-         (progn
-           (insert "</section>\n")
-           (aset org-levels-open (1- l) nil)))
-      (setq l (1- l)))
-    (when title
-      ;; If title is nil, this means this function is called to close
-      ;; all levels, so the rest is done only if title is given.
-      ;;
-      ;; Format tags: put them into a superscript like format.
-      (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
-       (setq title
-             (replace-match
-              (if org-export-with-tags
-                  (save-match-data
-                    (concat
-                     "<superscript>"
-                     (match-string 1 title)
-                     "</superscript>"))
-                "")
-              t t title)))
-      (aset org-levels-open (1- level) t)
-      (setq section-number (org-section-number level))
-      (insert (format "\n<section xml:id=\"%s%s\">\n<title>%s</title>"
-                     org-export-docbook-section-id-prefix
-                     (replace-regexp-in-string "\\." "_" section-number)
-                     title))
-      (org-export-docbook-open-para))))
-
-(defun org-docbook-expand (string)
-  "Prepare STRING for DocBook export.
-Applies all active conversions.  If there are links in the
-string, don't modify these."
-  (let* ((re (concat org-bracket-link-regexp "\\|"
-                    (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
-        m s l res)
-    (while (setq m (string-match re string))
-      (setq s (substring string 0 m)
-           l (match-string 0 string)
-           string (substring string (match-end 0)))
-      (push (org-docbook-do-expand s) res)
-      (push l res))
-    (push (org-docbook-do-expand string) res)
-    (apply 'concat (nreverse res))))
-
-(defun org-docbook-do-expand (s)
-  "Apply all active conversions to translate special ASCII to DocBook."
-  (setq s (org-html-protect s))
-  (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
-    (setq s (replace-match "<\\1>" t nil s)))
-  (if org-export-with-emphasize
-      (setq s (org-export-docbook-convert-emphasize s)))
-  (if org-export-with-special-strings
-      (setq s (org-export-docbook-convert-special-strings s)))
-  (if org-export-with-sub-superscripts
-      (setq s (org-export-docbook-convert-sub-super s)))
-  (if org-export-with-TeX-macros
-      (let ((start 0) wd rep)
-       (while (setq start (string-match "\\\\\\([a-zA-Z]+\\)\\({}\\)?"
-                                        s start))
-         (if (get-text-property (match-beginning 0) 'org-protected s)
-             (setq start (match-end 0))
-           (setq wd (match-string 1 s))
-           (if (setq rep (org-entity-get-representation wd 'html))
-               (setq s (replace-match rep t t s))
-             (setq start (+ start (length wd))))))))
-  s)
-
-(defun org-export-docbook-format-desc (desc)
-  "Make sure DESC is valid as a description in a link."
-  (save-match-data
-    (org-docbook-do-expand desc)))
-
-(defun org-export-docbook-convert-emphasize (string)
-  "Apply emphasis for DocBook exporting."
-  (let ((s 0) rpl)
-    (while (string-match org-emph-re string s)
-      (if (not (equal
-               (substring string (match-beginning 3) (1+ (match-beginning 3)))
-               (substring string (match-beginning 4) (1+ (match-beginning 4)))))
-         (setq s (match-beginning 0)
-               rpl
-               (concat
-                (match-string 1 string)
-                (nth 1 (assoc (match-string 3 string)
-                              org-export-docbook-emphasis-alist))
-                (match-string 4 string)
-                (nth 2 (assoc (match-string 3 string)
-                              org-export-docbook-emphasis-alist))
-                (match-string 5 string))
-               string (replace-match rpl t t string)
-               s (+ s (- (length rpl) 2)))
-       (setq s (1+ s))))
-    string))
-
-(defun org-docbook-protect (string)
-  (org-html-protect string))
-
-;; For now, simply return string as it is.
-(defun org-export-docbook-convert-special-strings (string)
-  "Convert special characters in STRING to DocBook."
-  string)
-
-(defun org-export-docbook-get-footnotes (lines)
-  "Given a list of LINES, return a list of alist footnotes."
-  (let ((list nil) line)
-    (while (setq line (pop lines))
-      (if (string-match "^[ \t]*\\[\\([0-9]+\\)\\] \\(.+\\)" line)
-         (push (cons (match-string 1 line) (match-string 2 line))
-               list)))
-    list))
-
-(defun org-export-docbook-format-image (src)
-  "Create image element in DocBook."
-  (save-match-data
-    (let* ((caption (org-find-text-property-in-string 'org-caption src))
-          (attr (or (org-find-text-property-in-string 'org-attributes src)
-                    ""))
-          (label (org-find-text-property-in-string 'org-label src))
-          (default-attr org-export-docbook-default-image-attributes)
-          tmp)
-      (setq caption (and caption (org-html-do-expand caption)))
-      (while (setq tmp (pop default-attr))
-       (if (not (string-match (concat (car tmp) "=") attr))
-           (setq attr (concat attr " " (car tmp) "=" (cdr tmp)))))
-      (format "<mediaobject%s>
-<imageobject>\n<imagedata fileref=\"%s\" %s/>\n</imageobject>
-%s</mediaobject>"
-             (if label (concat " xml:id=\"" label "\"") "")
-             src attr
-             (if caption
-                 (concat "<caption>\n<para>"
-                         caption
-                         "</para>\n</caption>\n")
-               "")
-             ))))
-
-(defun org-export-docbook-preprocess (parameters)
-  "Extra preprocessing work for DocBook export."
-  ;; Merge lines starting with "\par" to one line.  Such lines are
-  ;; regarded as the continuation of a long footnote.
-  (goto-char (point-min))
-  (while (re-search-forward "\n\\(\\\\par\\>\\)" nil t)
-    (if (not (get-text-property (match-beginning 1) 'org-protected))
-       (replace-match ""))))
-
-(defun org-export-docbook-finalize-table (table)
-  "Clean up TABLE and turn it into DocBook format.
-This function adds a label to the table if it is available, and
-also changes TABLE to informaltable if caption does not exist.
-TABLE is a string containing the HTML code generated by
-`org-format-table-html' for a table in Org-mode buffer."
-  (let (table-with-label)
-    ;; Get the label if it exists, and move it into the <table> element.
-    (setq table-with-label
-         (if (string-match
-              "^<table \\(\\(.\\|\n\\)+\\)<a name=\"\\(.+\\)\" id=\".+\"></a>\n\\(\\(.\\|\n\\)+\\)</table>"
-              table)
-             (replace-match (concat "<table xml:id=\"" (match-string 3 table) "\" "
-                                    (match-string 1 table)
-                                    (match-string 4 table)
-                                    "</table>")
-                            nil t table)
-           table))
-    ;; Change <table> into <informaltable> if caption does not exist.
-    (if (string-match
-        "^<table \\(\\(.\\|\n\\)+\\)<caption></caption>\n\\(\\(.\\|\n\\)+\\)</table>"
-        table-with-label)
-       (replace-match (concat "<informaltable "
-                              (match-string 1 table-with-label)
-                              (match-string 3 table-with-label)
-                              "</informaltable>")
-                      nil t table-with-label)
-      table-with-label)))
-
-;; Note: This function is very similar to
-;; org-export-html-convert-sub-super.  They can be merged in the future.
-(defun org-export-docbook-convert-sub-super (string)
-  "Convert sub- and superscripts in STRING for DocBook."
-  (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
-    (while (string-match org-match-substring-regexp string s)
-      (cond
-       ((and requireb (match-end 8)) (setq s (match-end 2)))
-       ((get-text-property  (match-beginning 2) 'org-protected string)
-       (setq s (match-end 2)))
-       (t
-       (setq s (match-end 1)
-             key (if (string= (match-string 2 string) "_")
-                     "subscript"
-                   "superscript")
-             c (or (match-string 8 string)
-                   (match-string 6 string)
-                   (match-string 5 string))
-             string (replace-match
-                     (concat (match-string 1 string)
-                             "<" key ">" c "</" key ">")
-                     t t string)))))
-    (while (string-match "\\\\\\([_^]\\)" string)
-      (setq string (replace-match (match-string 1 string) t t string)))
-    string))
-
-(defun org-export-docbook-protect-tags (string)
-  "Change ``<...>'' in string STRING into ``@<...>''.
-This is normally needed when STRING contains DocBook elements
-that need to be preserved in later phase of DocBook exporting."
-  (let ((start 0))
-    (while (string-match "<\\([^>]*\\)>" string start)
-      (setq string (replace-match
-                   "@<\\1>" t nil string)
-           start (match-end 0)))
-    string))
-
-(defun org-export-docbook-handle-time-stamps (line)
-  "Format time stamps in string LINE."
-  (let (replaced
-       (kw-markup (org-export-docbook-protect-tags
-                   org-export-docbook-keywords-markup))
-       (ts-markup (org-export-docbook-protect-tags
-                   org-export-docbook-timestamp-markup)))
-    (while (string-match org-maybe-keyword-time-regexp line)
-      (setq replaced
-           (concat replaced
-                   (substring line 0 (match-beginning 0))
-                   (if (match-end 1)
-                       (format kw-markup
-                               (match-string 1 line)))
-                   " "
-                   (format ts-markup
-                           (substring (org-translate-time
-                                       (match-string 3 line)) 1 -1)))
-           line (substring line (match-end 0))))
-    (concat replaced line)))
-
-(defun org-export-docbook-list-line (line pos struct prevs)
-  "Insert list syntax in export buffer.  Return LINE, maybe modified.
-
-POS is the item position or line position the line had before
-modifications to buffer.  STRUCT is the list structure.  PREVS is
-the alist of previous items."
-  (let* ((get-type
-         (function
-          ;; Translate type of list containing POS to "ordered",
-          ;; "variable" or "itemized".
-          (lambda (pos struct prevs)
-            (let ((type (org-list-get-list-type pos struct prevs)))
-              (cond
-               ((eq 'ordered type) "ordered")
-               ((eq 'descriptive type) "variable")
-               (t "itemized"))))))
-        (get-closings
-         (function
-          ;; Return list of all items and sublists ending at POS, in
-          ;; reverse order.
-          (lambda (pos)
-            (let (out)
-              (catch 'exit
-                (mapc (lambda (e)
-                        (let ((end (nth 6 e))
-                              (item (car e)))
-                          (cond
-                           ((= end pos) (push item out))
-                           ((>= item pos) (throw 'exit nil)))))
-                      struct))
-              out)))))
-    ;; First close any previous item, or list, ending at POS.
-    (mapc (lambda (e)
-           (let* ((lastp (= (org-list-get-last-item e struct prevs) e))
-                  (first-item (org-list-get-list-begin e struct prevs))
-                  (type (funcall get-type first-item struct prevs)))
-             ;; Ending for every item
-             (org-export-docbook-close-para-maybe)
-             (insert (if (equal type "variable")
-                         "</listitem></varlistentry>\n"
-                       "</listitem>\n"))
-             ;; We're ending last item of the list: end list.
-             (when lastp
-               (insert (format "</%slist>\n" type))
-               (org-export-docbook-open-para))))
-         (funcall get-closings pos))
-    (cond
-     ;; At an item: insert appropriate tags in export buffer.
-     ((assq pos struct)
-      (string-match (concat "[ \t]*\\(\\S-+[ \t]*\\)"
-                           "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[a-zA-Z]\\)\\][ \t]*\\)?"
-                           "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
-                           "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
-                           "\\(.*\\)")
-                   line)
-      (let* ((checkbox (match-string 3 line))
-            (desc-tag (or (match-string 4 line) "???"))
-            (body (match-string 5 line))
-            (list-beg (org-list-get-list-begin pos struct prevs))
-            (firstp (= list-beg pos))
-            ;; Always refer to first item to determine list type, in
-            ;; case list is ill-formed.
-            (type (funcall get-type list-beg struct prevs))
-            ;; Special variables for ordered lists.
-            (counter (let ((count-tmp (org-list-get-counter pos struct)))
-                       (cond
-                        ((not count-tmp) nil)
-                        ((string-match "[A-Za-z]" count-tmp)
-                         (- (string-to-char (upcase count-tmp)) 64))
-                        ((string-match "[0-9]+" count-tmp)
-                         count-tmp)))))
-       ;; When FIRSTP, a new list or sub-list is starting.
-       (when firstp
-         (org-export-docbook-close-para-maybe)
-         (insert (format "<%slist>\n" type)))
-       (insert (cond
-                ((equal type "variable")
-                 (format "<varlistentry><term>%s</term><listitem>" desc-tag))
-                ((and (equal type "ordered") counter)
-                 (format "<listitem override=\"%s\">" counter))
-                (t "<listitem>")))
-       ;; For DocBook, we need to open a para right after tag
-       ;; <listitem>.
-       (org-export-docbook-open-para)
-       ;; If line had a checkbox, some additional modification is required.
-       (when checkbox (setq body (concat checkbox " " body)))
-       ;; Return modified line
-       body))
-     ;; At a list ender:  normal text follows: need <para>.
-     ((equal "ORG-LIST-END-MARKER" line)
-      (org-export-docbook-open-para)
-      (throw 'nextline nil))
-     ;; Not at an item: return line unchanged (side-effects only).
-     (t line))))
-
-(provide 'org-docbook)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-docbook.el ends here
index be99ad99a69abb3a703624af590a8e3539e3e6a2..72ccc46d62a0f25dd8c3e67aeaf9ec142b8c9d03 100644 (file)
 
 (org-autoload "doc-view" '(doc-view-goto-page))
 
-(org-add-link-type "docview" 'org-docview-open)
+(org-add-link-type "docview" 'org-docview-open 'org-docview-export)
 (add-hook 'org-store-link-functions 'org-docview-store-link)
 
+(defun org-docview-export (link description format)
+  "Export a docview link from Org files."
+  (let* ((path (when (string-match "\\(.+\\)::.+" link)
+                (match-string 1 link)))
+         (desc (or description link)))
+    (when (stringp path)
+      (setq path (org-link-escape (expand-file-name path)))
+      (cond
+       ((eq format 'html) (format "<a href=\"%s\">%s</a>" path desc))
+       ((eq format 'latex) (format "\href{%s}{%s}" path desc))
+       ((eq format 'ascii) (format "%s (%s)" desc path))
+       (t path)))))
+
 (defun org-docview-open (link)
   (when (string-match "\\(.*\\)::\\([0-9]+\\)$"  link)
     (let* ((path (match-string 1 link))
index 5be1477196120edf7bf849ead294ada747a03d94..55efb50084374379980f8e419d98d70bcd706321 100644 (file)
 ;; to at least one element.
 ;;
 ;; An element always starts and ends at the beginning of a line.  With
-;; a few exceptions (namely `babel-call', `clock', `headline', `item',
-;; `keyword', `planning', `property-drawer' and `section' types), it
-;; can also accept a fixed set of keywords as attributes.  Those are
-;; called "affiliated keywords" to distinguish them from other
-;; keywords, which are full-fledged elements.  Almost all affiliated
-;; keywords are referenced in `org-element-affiliated-keywords'; the
-;; others are export attributes and start with "ATTR_" prefix.
+;; a few exceptions (`clock', `headline', `inlinetask', `item',
+;; `planning', `node-property', `quote-section' `section' and
+;; `table-row' types), it can also accept a fixed set of keywords as
+;; attributes.  Those are called "affiliated keywords" to distinguish
+;; them from other keywords, which are full-fledged elements.  Almost
+;; all affiliated keywords are referenced in
+;; `org-element-affiliated-keywords'; the others are export attributes
+;; and start with "ATTR_" prefix.
 ;;
 ;; Element containing other elements (and only elements) are called
 ;; greater elements.  Concerned types are: `center-block', `drawer',
 ;; `dynamic-block', `footnote-definition', `headline', `inlinetask',
-;; `item', `plain-list', `quote-block', `section' and `special-block'.
+;; `item', `plain-list', `property-drawer', `quote-block', `section'
+;; and `special-block'.
 ;;
 ;; Other element types are: `babel-call', `clock', `comment',
-;; `comment-block', `example-block', `export-block', `fixed-width',
-;; `horizontal-rule', `keyword', `latex-environment', `paragraph',
-;; `planning', `property-drawer', `quote-section', `src-block',
-;; `table', `table-row' and `verse-block'.  Among them, `paragraph'
-;; and `verse-block' types can contain Org objects and plain text.
+;; `comment-block', `diary-sexp', `example-block', `export-block',
+;; `fixed-width', `horizontal-rule', `keyword', `latex-environment',
+;; `node-property', `paragraph', `planning', `quote-section',
+;; `src-block', `table', `table-row' and `verse-block'.  Among them,
+;; `paragraph' and `verse-block' types can contain Org objects and
+;; plain text.
 ;;
 ;; Objects are related to document's contents.  Some of them are
 ;; recursive.  Associated types are of the following: `bold', `code',
@@ -59,7 +62,7 @@
 ;; `table-cell', `target', `timestamp', `underline' and `verbatim'.
 ;;
 ;; Some elements also have special properties whose value can hold
-;; objects themselves (i.e. an item tag or an headline name).  Such
+;; objects themselves (i.e. an item tag or a headline name).  Such
 ;; values are called "secondary strings".  Any object belongs to
 ;; either an element or a secondary string.
 ;;
 ;; refer to the beginning and ending buffer positions of the
 ;; considered element or object, `:post-blank', which holds the number
 ;; of blank lines, or white spaces, at its end and `:parent' which
-;; refers to the element or object containing it.  Greater elements
-;; and elements containing objects will also have `:contents-begin'
-;; and `:contents-end' properties to delimit contents.
+;; refers to the element or object containing it.  Greater elements,
+;; elements and objects containing objects will also have
+;; `:contents-begin' and `:contents-end' properties to delimit
+;; contents.  Eventually, greater elements and elements accepting
+;; affiliated keywords will have a `:post-affiliated' property,
+;; referring to the buffer position after all such keywords.
+;;
+;; At the lowest level, a `:parent' property is also attached to any
+;; string, as a text property.
 ;;
 ;; Lisp-wise, an element or an object can be represented as a list.
 ;; It follows the pattern (TYPE PROPERTIES CONTENTS), where:
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
-
+(eval-when-compile (require 'cl))
 (require 'org)
 
+
 \f
 ;;; Definitions And Rules
 ;;
           org-outline-regexp "\\|"
           ;; Footnote definitions.
          "\\[\\(?:[0-9]+\\|fn:[-_[:word:]]+\\)\\]" "\\|"
+         ;; Diary sexps.
+         "%%(" "\\|"
           "[ \t]*\\(?:"
           ;; Empty lines.
           "$" "\\|"
           ;; Lists.
           (let ((term (case org-plain-list-ordered-item-terminator
                         (?\) ")") (?. "\\.") (otherwise "[.)]")))
-                (alpha (and org-alphabetical-lists "\\|[A-Za-z]")))
+                (alpha (and org-list-allow-alphabetical "\\|[A-Za-z]")))
             (concat "\\(?:[-+*]\\|\\(?:[0-9]+" alpha "\\)" term "\\)"
                     "\\(?:[ \t]\\|$\\)"))
           "\\)\\)")
@@ -160,22 +170,23 @@ is not sufficient to know if point is at a paragraph ending.  See
 `org-element-paragraph-parser' for more information.")
 
 (defconst org-element-all-elements
-  '(center-block clock comment comment-block drawer dynamic-block example-block
-                export-block fixed-width footnote-definition headline
-                horizontal-rule inlinetask item keyword latex-environment
-                babel-call paragraph plain-list planning property-drawer
-                quote-block quote-section section special-block src-block table
-                table-row verse-block)
+  '(babel-call center-block clock comment comment-block diary-sexp drawer
+              dynamic-block example-block export-block fixed-width
+              footnote-definition headline horizontal-rule inlinetask item
+              keyword latex-environment node-property paragraph plain-list
+              planning property-drawer quote-block quote-section section
+              special-block src-block table table-row verse-block)
   "Complete list of element types.")
 
 (defconst org-element-greater-elements
   '(center-block drawer dynamic-block footnote-definition headline inlinetask
-                item plain-list quote-block section special-block table)
+                item plain-list property-drawer quote-block section
+                special-block table)
   "List of recursive element types aka Greater Elements.")
 
 (defconst org-element-all-successors
   '(export-snippet footnote-reference inline-babel-call inline-src-block
-                  latex-or-entity line-break link macro radio-target
+                  latex-or-entity line-break link macro plain-link radio-target
                   statistics-cookie sub/superscript table-cell target
                   text-markup timestamp)
   "Complete list of successors.")
@@ -187,7 +198,6 @@ is not sufficient to know if point is at a paragraph ending.  See
     (verbatim . text-markup) (entity . latex-or-entity)
     (latex-fragment . latex-or-entity))
   "Alist of translations between object type and successor name.
-
 Sharing the same successor comes handy when, for example, the
 regexp matching one object can also match the other object.")
 
@@ -199,11 +209,11 @@ regexp matching one object can also match the other object.")
   "Complete list of object types.")
 
 (defconst org-element-recursive-objects
-  '(bold italic link macro subscript radio-target strike-through superscript
+  '(bold italic link subscript radio-target strike-through superscript
         table-cell underline)
   "List of recursive object types.")
 
-(defconst org-element-block-name-alist
+(defvar org-element-block-name-alist
   '(("CENTER" . org-element-center-block-parser)
     ("COMMENT" . org-element-comment-block-parser)
     ("EXAMPLE" . org-element-example-block-parser)
@@ -214,6 +224,12 @@ regexp matching one object can also match the other object.")
 Names must be uppercase.  Any block whose name has no association
 is parsed with `org-element-special-block-parser'.")
 
+(defconst org-element-link-type-is-file
+  '("file" "file+emacs" "file+sys" "docview")
+  "List of link types equivalent to \"file\".
+Only these types can accept search options and an explicit
+application to open them.")
+
 (defconst org-element-affiliated-keywords
   '("CAPTION" "DATA" "HEADER" "HEADERS" "LABEL" "NAME" "PLOT" "RESNAME" "RESULT"
     "RESULTS" "SOURCE" "SRCNAME" "TBLNAME")
@@ -242,8 +258,8 @@ Don't modify it, set `org-element-affiliated-keywords' instead.")
 The key is the old name and the value the new one.  The property
 holding their value will be named after the translated name.")
 
-(defconst org-element-multiple-keywords '("HEADER")
-  "List of affiliated keywords that can occur more that once in an element.
+(defconst org-element-multiple-keywords '("CAPTION" "HEADER")
+  "List of affiliated keywords that can occur more than once in an element.
 
 Their value will be consed into a list of strings, which will be
 returned as the value of the property.
@@ -254,8 +270,8 @@ This list is checked after translations have been applied.  See
 By default, all keywords setting attributes (i.e. \"ATTR_LATEX\")
 allow multiple occurrences and need not to be in this list.")
 
-(defconst org-element-parsed-keywords '("AUTHOR" "CAPTION" "DATE" "TITLE")
-  "List of keywords whose value can be parsed.
+(defconst org-element-parsed-keywords '("CAPTION")
+  "List of affiliated keywords whose value can be parsed.
 
 Their value will be stored as a secondary string: a list of
 strings and objects.
@@ -264,10 +280,10 @@ This list is checked after translations have been applied.  See
 `org-element-keyword-translation-alist'.")
 
 (defconst org-element-dual-keywords '("CAPTION" "RESULTS")
-  "List of keywords which can have a secondary value.
+  "List of affiliated keywords which can have a secondary value.
 
 In Org syntax, they can be written with optional square brackets
-before the colons.  For example, results keyword can be
+before the colons.  For example, RESULTS keyword can be
 associated to a hash value with the following:
 
   #+RESULTS[hash-string]: some-source
@@ -275,46 +291,40 @@ associated to a hash value with the following:
 This list is checked after translations have been applied.  See
 `org-element-keyword-translation-alist'.")
 
+(defconst org-element-document-properties '("AUTHOR" "DATE" "TITLE")
+  "List of properties associated to the whole document.
+Any keyword in this list will have its value parsed and stored as
+a secondary string.")
+
 (defconst org-element-object-restrictions
-  '((bold export-snippet inline-babel-call inline-src-block latex-or-entity link
-         radio-target sub/superscript target text-markup timestamp)
-    (footnote-reference export-snippet footnote-reference inline-babel-call
-                       inline-src-block latex-or-entity line-break link macro
-                       radio-target sub/superscript target text-markup
-                       timestamp)
-    (headline inline-babel-call inline-src-block latex-or-entity link macro
-             radio-target statistics-cookie sub/superscript target text-markup
-             timestamp)
-    (inlinetask inline-babel-call inline-src-block latex-or-entity link macro
-               radio-target sub/superscript target text-markup timestamp)
-    (italic export-snippet inline-babel-call inline-src-block latex-or-entity
-           link radio-target sub/superscript target text-markup timestamp)
-    (item export-snippet footnote-reference inline-babel-call latex-or-entity
-         link macro radio-target sub/superscript target text-markup)
-    (keyword latex-or-entity macro sub/superscript text-markup)
-    (link export-snippet inline-babel-call inline-src-block latex-or-entity link
-         sub/superscript text-markup)
-    (macro macro)
-    (paragraph export-snippet footnote-reference inline-babel-call
-              inline-src-block latex-or-entity line-break link macro
-              radio-target statistics-cookie sub/superscript target text-markup
-              timestamp)
-    (radio-target export-snippet latex-or-entity sub/superscript)
-    (strike-through export-snippet inline-babel-call inline-src-block
-                   latex-or-entity link radio-target sub/superscript target
-                   text-markup timestamp)
-    (subscript export-snippet inline-babel-call inline-src-block latex-or-entity
-              sub/superscript target text-markup)
-    (superscript export-snippet inline-babel-call inline-src-block
-                latex-or-entity sub/superscript target text-markup)
-    (table-cell export-snippet latex-or-entity link macro radio-target
-               sub/superscript target text-markup timestamp)
-    (table-row table-cell)
-    (underline export-snippet inline-babel-call inline-src-block latex-or-entity
-              link radio-target sub/superscript target text-markup timestamp)
-    (verse-block footnote-reference inline-babel-call inline-src-block
-                latex-or-entity line-break link macro radio-target
-                sub/superscript target text-markup timestamp))
+  (let* ((standard-set
+         (remq 'plain-link (remq 'table-cell org-element-all-successors)))
+        (standard-set-no-line-break (remq 'line-break standard-set)))
+    `((bold ,@standard-set)
+      (footnote-reference ,@standard-set)
+      (headline ,@standard-set-no-line-break)
+      (inlinetask ,@standard-set-no-line-break)
+      (italic ,@standard-set)
+      (item ,@standard-set-no-line-break)
+      (keyword ,@standard-set)
+      ;; Ignore all links excepted plain links in a link description.
+      ;; Also ignore radio-targets and line breaks.
+      (link export-snippet inline-babel-call inline-src-block latex-or-entity
+           macro plain-link statistics-cookie sub/superscript text-markup)
+      (paragraph ,@standard-set)
+      ;; Remove any variable object from radio target as it would
+      ;; prevent it from being properly recognized.
+      (radio-target latex-or-entity sub/superscript)
+      (strike-through ,@standard-set)
+      (subscript ,@standard-set)
+      (superscript ,@standard-set)
+      ;; Ignore inline babel call and inline src block as formulas are
+      ;; possible.  Also ignore line breaks and statistics cookies.
+      (table-cell export-snippet footnote-reference latex-or-entity link macro
+                 radio-target sub/superscript target text-markup timestamp)
+      (table-row table-cell)
+      (underline ,@standard-set)
+      (verse-block ,@standard-set)))
   "Alist of objects restrictions.
 
 CAR is an element or object type containing objects and CDR is
@@ -322,8 +332,7 @@ a list of successors that will be called within an element or
 object of such type.
 
 For example, in a `radio-target' object, one can only find
-entities, export snippets, latex-fragments, subscript and
-superscript.
+entities, latex-fragments, subscript and superscript.
 
 This alist also applies to secondary string.  For example, an
 `headline' type element doesn't directly contain objects, but
@@ -336,6 +345,11 @@ still has an entry since one of its properties (`:title') does.")
     (footnote-reference . :inline-definition))
   "Alist between element types and location of secondary value.")
 
+(defconst org-element-object-variables '(org-link-abbrev-alist-local)
+  "List of buffer-local variables used when parsing objects.
+These variables are copied to the temporary buffer created by
+`org-export-secondary-string'.")
+
 
 \f
 ;;; Accessors and Setters
@@ -363,11 +377,14 @@ It can also return the following special value:
 
 (defsubst org-element-property (property element)
   "Extract the value from the PROPERTY of an ELEMENT."
-  (plist-get (nth 1 element) property))
+  (if (stringp element) (get-text-property 0 property element)
+    (plist-get (nth 1 element) property)))
 
 (defsubst org-element-contents (element)
   "Extract contents from an ELEMENT."
-  (and (consp element) (nthcdr 2 element)))
+  (cond ((not (consp element)) nil)
+       ((symbolp (car element)) (nthcdr 2 element))
+       (t element)))
 
 (defsubst org-element-restriction (element)
   "Return restriction associated to ELEMENT.
@@ -379,14 +396,15 @@ element or object type."
 (defsubst org-element-put-property (element property value)
   "In ELEMENT set PROPERTY to VALUE.
 Return modified element."
-  (when (consp element)
-    (setcar (cdr element) (plist-put (nth 1 element) property value)))
-  element)
+  (if (stringp element) (org-add-props element nil property value)
+    (setcar (cdr element) (plist-put (nth 1 element) property value))
+    element))
 
 (defsubst org-element-set-contents (element &rest contents)
   "Set ELEMENT contents to CONTENTS.
 Return modified element."
   (cond ((not element) (list contents))
+       ((not (symbolp (car element))) contents)
        ((cdr element) (setcdr (cdr element) contents))
        (t (nconc element contents))))
 
@@ -415,18 +433,18 @@ objects, or a strings.
 
 The function takes care of setting `:parent' property for CHILD.
 Return parent element."
-  (if (not parent) children
-    ;; Link every child to PARENT.
-    (mapc (lambda (child)
-           (unless (stringp child)
-             (org-element-put-property child :parent parent)))
-         children)
-    ;; Add CHILDREN at the end of PARENT contents.
+  ;; Link every child to PARENT. If PARENT is nil, it is a secondary
+  ;; string: parent is the list itself.
+  (mapc (lambda (child)
+         (org-element-put-property child :parent (or parent children)))
+       children)
+  ;; Add CHILDREN at the end of PARENT contents.
+  (when parent
     (apply 'org-element-set-contents
           parent
-          (nconc (org-element-contents parent) children))
-    ;; Return modified PARENT element.
-    parent))
+          (nconc (org-element-contents parent) children)))
+  ;; Return modified PARENT element.
+  (or parent children))
 
 
 \f
@@ -466,24 +484,27 @@ Return parent element."
 
 ;;;; Center Block
 
-(defun org-element-center-block-parser (limit)
+(defun org-element-center-block-parser (limit affiliated)
   "Parse a center block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `center-block' and CDR is a plist
 containing `:begin', `:end', `:hiddenp', `:contents-begin',
-`:contents-end' and `:post-blank' keywords.
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END_CENTER[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((block-end-line (match-beginning 0)))
-       (let* ((keywords (org-element--collect-affiliated-keywords))
-              (begin (car keywords))
+       (let* ((begin (car affiliated))
+              (post-affiliated (point))
               ;; Empty blocks have no contents.
               (contents-begin (progn (forward-line)
                                      (and (< (point) block-end-line)
@@ -493,9 +514,9 @@ Assume point is at the beginning of the block."
               (pos-before-blank (progn (goto-char block-end-line)
                                        (forward-line)
                                        (point)))
-              (end (save-excursion (skip-chars-forward " \r\t\n" limit)
-                                   (skip-chars-backward " \t")
-                                   (if (bolp) (point) (line-end-position)))))
+              (end (save-excursion
+                     (skip-chars-forward " \r\t\n" limit)
+                     (if (eobp) (point) (line-beginning-position)))))
          (list 'center-block
                (nconc
                 (list :begin begin
@@ -503,8 +524,9 @@ Assume point is at the beginning of the block."
                       :hiddenp hidden
                       :contents-begin contents-begin
                       :contents-end contents-end
-                      :post-blank (count-lines pos-before-blank end))
-                (cadr keywords))))))))
+                      :post-blank (count-lines pos-before-blank end)
+                      :post-affiliated post-affiliated)
+                (cdr affiliated))))))))
 
 (defun org-element-center-block-interpreter (center-block contents)
   "Interpret CENTER-BLOCK element as Org syntax.
@@ -514,49 +536,51 @@ CONTENTS is the contents of the element."
 
 ;;;; Drawer
 
-(defun org-element-drawer-parser (limit)
+(defun org-element-drawer-parser (limit affiliated)
   "Parse a drawer.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `drawer' and CDR is a plist containing
 `:drawer-name', `:begin', `:end', `:hiddenp', `:contents-begin',
-`:contents-end' and `:post-blank' keywords.
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at beginning of drawer."
   (let ((case-fold-search t))
     (if (not (save-excursion (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
        ;; Incomplete drawer: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
-      (let ((drawer-end-line (match-beginning 0)))
-       (save-excursion
-         (let* ((case-fold-search t)
-                (name (progn (looking-at org-drawer-regexp)
-                             (org-match-string-no-properties 1)))
-                (keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
-                ;; Empty drawers have no contents.
-                (contents-begin (progn (forward-line)
-                                       (and (< (point) drawer-end-line)
-                                            (point))))
-                (contents-end (and contents-begin drawer-end-line))
-                (hidden (org-invisible-p2))
-                (pos-before-blank (progn (goto-char drawer-end-line)
-                                         (forward-line)
-                                         (point)))
-                (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
-           (list 'drawer
-                 (nconc
-                  (list :begin begin
-                        :end end
-                        :drawer-name name
-                        :hiddenp hidden
-                        :contents-begin contents-begin
-                        :contents-end contents-end
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+       (org-element-paragraph-parser limit affiliated)
+      (save-excursion
+       (let* ((drawer-end-line (match-beginning 0))
+              (name (progn (looking-at org-drawer-regexp)
+                           (org-match-string-no-properties 1)))
+              (begin (car affiliated))
+              (post-affiliated (point))
+              ;; Empty drawers have no contents.
+              (contents-begin (progn (forward-line)
+                                     (and (< (point) drawer-end-line)
+                                          (point))))
+              (contents-end (and contents-begin drawer-end-line))
+              (hidden (org-invisible-p2))
+              (pos-before-blank (progn (goto-char drawer-end-line)
+                                       (forward-line)
+                                       (point)))
+              (end (progn (skip-chars-forward " \r\t\n" limit)
+                          (if (eobp) (point) (line-beginning-position)))))
+         (list 'drawer
+               (nconc
+                (list :begin begin
+                      :end end
+                      :drawer-name name
+                      :hiddenp hidden
+                      :contents-begin contents-begin
+                      :contents-end contents-end
+                      :post-blank (count-lines pos-before-blank end)
+                      :post-affiliated post-affiliated)
+                (cdr affiliated))))))))
 
 (defun org-element-drawer-interpreter (drawer contents)
   "Interpret DRAWER element as Org syntax.
@@ -568,29 +592,32 @@ CONTENTS is the contents of the element."
 
 ;;;; Dynamic Block
 
-(defun org-element-dynamic-block-parser (limit)
+(defun org-element-dynamic-block-parser (limit affiliated)
   "Parse a dynamic block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `dynamic-block' and CDR is a plist
 containing `:block-name', `:begin', `:end', `:hiddenp',
-`:contents-begin', `:contents-end', `:arguments' and
-`:post-blank' keywords.
+`:contents-begin', `:contents-end', `:arguments', `:post-blank'
+and `:post-affiliated' keywords.
 
 Assume point is at beginning of dynamic block."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END:?[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((block-end-line (match-beginning 0)))
        (save-excursion
          (let* ((name (progn (looking-at org-dblock-start-re)
                              (org-match-string-no-properties 1)))
                 (arguments (org-match-string-no-properties 3))
-                (keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+                (begin (car affiliated))
+                (post-affiliated (point))
                 ;; Empty blocks have no contents.
                 (contents-begin (progn (forward-line)
                                        (and (< (point) block-end-line)
@@ -601,8 +628,7 @@ Assume point is at beginning of dynamic block."
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'dynamic-block
                  (nconc
                   (list :begin begin
@@ -612,8 +638,9 @@ Assume point is at beginning of dynamic block."
                         :hiddenp hidden
                         :contents-begin contents-begin
                         :contents-end contents-end
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-dynamic-block-interpreter (dynamic-block contents)
   "Interpret DYNAMIC-BLOCK element as Org syntax.
@@ -627,38 +654,43 @@ CONTENTS is the contents of the element."
 
 ;;;; Footnote Definition
 
-(defun org-element-footnote-definition-parser (limit)
+(defun org-element-footnote-definition-parser (limit affiliated)
   "Parse a footnote definition.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `footnote-definition' and CDR is
 a plist containing `:label', `:begin' `:end', `:contents-begin',
-`:contents-end' and `:post-blank' keywords.
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at the beginning of the footnote definition."
   (save-excursion
     (let* ((label (progn (looking-at org-footnote-definition-re)
                         (org-match-string-no-properties 1)))
-          (keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+          (begin (car affiliated))
+          (post-affiliated (point))
           (ending (save-excursion
                     (if (progn
                           (end-of-line)
                           (re-search-forward
                            (concat org-outline-regexp-bol "\\|"
                                    org-footnote-definition-re "\\|"
-                                   "^[ \t]*$") limit 'move))
+                                   "^\\([ \t]*\n\\)\\{2,\\}") limit 'move))
                         (match-beginning 0)
                       (point))))
-          (contents-begin (progn (search-forward "]")
-                                 (skip-chars-forward " \r\t\n" ending)
-                                 (and (/= (point) ending) (point))))
+          (contents-begin (progn
+                            (search-forward "]")
+                            (skip-chars-forward " \r\t\n" ending)
+                            (cond ((= (point) ending) nil)
+                                  ((= (line-beginning-position) begin) (point))
+                                  (t (line-beginning-position)))))
           (contents-end (and contents-begin ending))
           (end (progn (goto-char ending)
                       (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (eobp) (point) (line-beginning-position)))))
       (list 'footnote-definition
            (nconc
             (list :label label
@@ -666,8 +698,9 @@ Assume point is at the beginning of the footnote definition."
                   :end end
                   :contents-begin contents-begin
                   :contents-end contents-end
-                  :post-blank (count-lines ending end))
-            (cadr keywords))))))
+                  :post-blank (count-lines ending end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-footnote-definition-interpreter (footnote-definition contents)
   "Interpret FOOTNOTE-DEFINITION element as Org syntax.
@@ -680,19 +713,19 @@ CONTENTS is the contents of the footnote-definition."
 ;;;; Headline
 
 (defun org-element-headline-parser (limit &optional raw-secondary-p)
-  "Parse an headline.
+  "Parse a headline.
 
 Return a list whose CAR is `headline' and CDR is a plist
-containing `:raw-value', `:title', `:begin', `:end',
-`:pre-blank', `:hiddenp', `:contents-begin' and `:contents-end',
-`:level', `:priority', `:tags', `:todo-keyword',`:todo-type',
-`:scheduled', `:deadline', `:timestamp', `:clock', `:category',
-`:quotedp', `:archivedp', `:commentedp' and `:footnote-section-p'
-keywords.
+containing `:raw-value', `:title', `:alt-title', `:begin',
+`:end', `:pre-blank', `:hiddenp', `:contents-begin' and
+`:contents-end', `:level', `:priority', `:tags',
+`:todo-keyword',`:todo-type', `:scheduled', `:deadline',
+`:closed', `:quotedp', `:archivedp', `:commentedp' and
+`:footnote-section-p' keywords.
 
 The plist also contains any property set in the property drawer,
-with its name in lowercase, the underscores replaced with hyphens
-and colons at the beginning (i.e. `:custom-id').
+with its name in upper cases and colons added at the
+beginning (i.e. `:CUSTOM_ID').
 
 When RAW-SECONDARY-P is non-nil, headline's title will not be
 parsed as a secondary string, but as a plain string instead.
@@ -718,25 +751,37 @@ Assume point is at beginning of the headline."
           (archivedp (member org-archive-tag tags))
           (footnote-section-p (and org-footnote-section
                                    (string= org-footnote-section raw-value)))
-          ;; Normalize property names: ":SOME_PROP:" becomes
-          ;; ":some-prop".
-          (standard-props (let (plist)
-                            (mapc
-                             (lambda (p)
-                               (let ((p-name (downcase (car p))))
-                                 (while (string-match "_" p-name)
-                                   (setq p-name
-                                         (replace-match "-" nil nil p-name)))
-                                 (setq p-name (intern (concat ":" p-name)))
-                                 (setq plist
-                                       (plist-put plist p-name (cdr p)))))
-                             (org-entry-properties nil 'standard))
-                            plist))
-          (time-props (org-entry-properties nil 'special "CLOCK"))
-          (scheduled (cdr (assoc "SCHEDULED" time-props)))
-          (deadline (cdr (assoc "DEADLINE" time-props)))
-          (clock (cdr (assoc "CLOCK" time-props)))
-          (timestamp (cdr (assoc "TIMESTAMP" time-props)))
+          ;; Upcase property names.  It avoids confusion between
+          ;; properties obtained through property drawer and default
+          ;; properties from the parser (e.g. `:end' and :END:)
+          (standard-props
+           (let (plist)
+             (mapc
+              (lambda (p)
+                (setq plist
+                      (plist-put plist
+                                 (intern (concat ":" (upcase (car p))))
+                                 (cdr p))))
+              (org-entry-properties nil 'standard))
+             plist))
+          (time-props
+           ;; Read time properties on the line below the headline.
+           (save-excursion
+             (when (progn (forward-line)
+                          (looking-at org-planning-or-clock-line-re))
+               (let ((end (line-end-position)) plist)
+                 (while (re-search-forward
+                         org-keyword-time-not-clock-regexp end t)
+                   (goto-char (match-end 1))
+                   (skip-chars-forward " \t")
+                   (let ((keyword (match-string 1))
+                         (time (org-element-timestamp-parser)))
+                     (cond ((equal keyword org-scheduled-string)
+                            (setq plist (plist-put plist :scheduled time)))
+                           ((equal keyword org-deadline-string)
+                            (setq plist (plist-put plist :deadline time)))
+                           (t (setq plist (plist-put plist :closed time))))))
+                 plist))))
           (begin (point))
           (end (save-excursion (goto-char (org-end-of-subtree t t))))
           (pos-after-head (progn (forward-line) (point)))
@@ -778,10 +823,6 @@ Assume point is at beginning of the headline."
                          :tags tags
                          :todo-keyword todo
                          :todo-type todo-type
-                         :scheduled scheduled
-                         :deadline deadline
-                         :timestamp timestamp
-                         :clock clock
                          :post-blank (count-lines
                                       (if (not contents-end) pos-after-head
                                         (goto-char contents-end)
@@ -792,7 +833,15 @@ Assume point is at beginning of the headline."
                          :archivedp archivedp
                          :commentedp commentedp
                          :quotedp quotedp)
+                   time-props
                    standard-props))))
+       (let ((alt-title (org-element-property :ALT_TITLE headline)))
+         (when alt-title
+           (org-element-put-property
+            headline :alt-title
+            (if raw-secondary-p alt-title
+              (org-element-parse-secondary-string
+               alt-title (org-element-restriction 'headline) headline)))))
        (org-element-put-property
         headline :title
         (if raw-secondary-p raw-value
@@ -816,7 +865,7 @@ CONTENTS is the contents of the element."
         (commentedp (org-element-property :commentedp headline))
         (quotedp (org-element-property :quotedp headline))
         (pre-blank (or (org-element-property :pre-blank headline) 0))
-        (heading (concat (make-string level ?*)
+        (heading (concat (make-string (org-reduced-level level) ?*)
                          (and todo (concat " " todo))
                          (and quotedp (concat " " org-quote-string))
                          (and commentedp (concat " " org-comment-string))
@@ -855,12 +904,11 @@ Return a list whose CAR is `inlinetask' and CDR is a plist
 containing `:title', `:begin', `:end', `:hiddenp',
 `:contents-begin' and `:contents-end', `:level', `:priority',
 `:raw-value', `:tags', `:todo-keyword', `:todo-type',
-`:scheduled', `:deadline', `:timestamp', `:clock' and
-`:post-blank' keywords.
+`:scheduled', `:deadline', `:closed' and `:post-blank' keywords.
 
 The plist also contains any property set in the property drawer,
-with its name in lowercase, the underscores replaced with hyphens
-and colons at the beginning (i.e. `:custom-id').
+with its name in upper cases and colons added at the
+beginning (i.e. `:CUSTOM_ID').
 
 When optional argument RAW-SECONDARY-P is non-nil, inline-task's
 title will not be parsed as a secondary string, but as a plain
@@ -868,8 +916,7 @@ string instead.
 
 Assume point is at beginning of the inline task."
   (save-excursion
-    (let* ((keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+    (let* ((begin (point))
           (components (org-heading-components))
           (todo (nth 2 components))
           (todo-type (and todo
@@ -877,25 +924,38 @@ Assume point is at beginning of the inline task."
           (tags (let ((raw-tags (nth 5 components)))
                   (and raw-tags (org-split-string raw-tags ":"))))
           (raw-value (or (nth 4 components) ""))
-          ;; Normalize property names: ":SOME_PROP:" becomes
-          ;; ":some-prop".
-          (standard-props (let (plist)
-                            (mapc
-                             (lambda (p)
-                               (let ((p-name (downcase (car p))))
-                                 (while (string-match "_" p-name)
-                                   (setq p-name
-                                         (replace-match "-" nil nil p-name)))
-                                 (setq p-name (intern (concat ":" p-name)))
-                                 (setq plist
-                                       (plist-put plist p-name (cdr p)))))
-                             (org-entry-properties nil 'standard))
-                            plist))
-          (time-props (org-entry-properties nil 'special "CLOCK"))
-          (scheduled (cdr (assoc "SCHEDULED" time-props)))
-          (deadline (cdr (assoc "DEADLINE" time-props)))
-          (clock (cdr (assoc "CLOCK" time-props)))
-          (timestamp (cdr (assoc "TIMESTAMP" time-props)))
+          ;; Upcase property names.  It avoids confusion between
+          ;; properties obtained through property drawer and default
+          ;; properties from the parser (e.g. `:end' and :END:)
+          (standard-props
+           (let (plist)
+             (mapc
+              (lambda (p)
+                (setq plist
+                      (plist-put plist
+                                 (intern (concat ":" (upcase (car p))))
+                                 (cdr p))))
+              (org-entry-properties nil 'standard))
+             plist))
+          (time-props
+           ;; Read time properties on the line below the inlinetask
+           ;; opening string.
+           (save-excursion
+             (when (progn (forward-line)
+                          (looking-at org-planning-or-clock-line-re))
+               (let ((end (line-end-position)) plist)
+                 (while (re-search-forward
+                         org-keyword-time-not-clock-regexp end t)
+                   (goto-char (match-end 1))
+                   (skip-chars-forward " \t")
+                   (let ((keyword (match-string 1))
+                         (time (org-element-timestamp-parser)))
+                     (cond ((equal keyword org-scheduled-string)
+                            (setq plist (plist-put plist :scheduled time)))
+                           ((equal keyword org-deadline-string)
+                            (setq plist (plist-put plist :deadline time)))
+                           (t (setq plist (plist-put plist :closed time))))))
+                 plist))))
           (task-end (save-excursion
                       (end-of-line)
                       (and (re-search-forward "^\\*+ END" limit t)
@@ -909,8 +969,7 @@ Assume point is at beginning of the inline task."
                           (forward-line)
                           (point)))
           (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position))))
+                      (if (eobp) (point) (line-beginning-position))))
           (inlinetask
            (list 'inlinetask
                  (nconc
@@ -925,13 +984,9 @@ Assume point is at beginning of the inline task."
                         :tags tags
                         :todo-keyword todo
                         :todo-type todo-type
-                        :scheduled scheduled
-                        :deadline deadline
-                        :timestamp timestamp
-                        :clock clock
                         :post-blank (count-lines before-blank end))
-                  standard-props
-                  (cadr keywords)))))
+                  time-props
+                  standard-props))))
       (org-element-put-property
        inlinetask :title
        (if raw-secondary-p raw-value
@@ -1063,7 +1118,11 @@ Assume point is at the beginning of the item."
 (defun org-element-item-interpreter (item contents)
   "Interpret ITEM element as Org syntax.
 CONTENTS is the contents of the element."
-  (let* ((bullet (org-list-bullet-string (org-element-property :bullet item)))
+  (let* ((bullet (let ((bullet (org-element-property :bullet item)))
+                  (org-list-bullet-string
+                   (cond ((not (string-match "[0-9a-zA-Z]" bullet)) "- ")
+                         ((eq org-plain-list-ordered-item-terminator ?\)) "1)")
+                         (t "1.")))))
         (checkbox (org-element-property :checkbox item))
         (counter (org-element-property :counter item))
         (tag (let ((tag (org-element-property :tag item)))
@@ -1082,40 +1141,127 @@ CONTENTS is the contents of the element."
        (off "[ ] ")
        (trans "[-] "))
      (and tag (format "%s :: " tag))
-     (let ((contents (replace-regexp-in-string
-                     "\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
-       (if item-starts-with-par-p (org-trim contents)
-        (concat "\n" contents))))))
+     (when contents
+       (let ((contents (replace-regexp-in-string
+                       "\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
+        (if item-starts-with-par-p (org-trim contents)
+          (concat "\n" contents)))))))
 
 
 ;;;; Plain List
 
-(defun org-element-plain-list-parser (limit &optional structure)
+(defun org-element--list-struct (limit)
+  ;; Return structure of list at point.  Internal function.  See
+  ;; `org-list-struct' for details.
+  (let ((case-fold-search t)
+       (top-ind limit)
+       (item-re (org-item-re))
+       (drawers-re (concat ":\\("
+                           (mapconcat 'regexp-quote org-drawers "\\|")
+                           "\\):[ \t]*$"))
+       (inlinetask-re (and (featurep 'org-inlinetask) "^\\*+ "))
+       items struct)
+    (save-excursion
+      (catch 'exit
+       (while t
+         (cond
+          ;; At limit: end all items.
+          ((>= (point) limit)
+           (throw 'exit
+                  (let ((end (progn (skip-chars-backward " \r\t\n")
+                                    (forward-line)
+                                    (point))))
+                    (dolist (item items (sort (nconc items struct)
+                                              'car-less-than-car))
+                      (setcar (nthcdr 6 item) end)))))
+          ;; At list end: end all items.
+          ((looking-at org-list-end-re)
+           (throw 'exit (dolist (item items (sort (nconc items struct)
+                                                  'car-less-than-car))
+                          (setcar (nthcdr 6 item) (point)))))
+          ;; At a new item: end previous sibling.
+          ((looking-at item-re)
+           (let ((ind (save-excursion (skip-chars-forward " \t")
+                                      (current-column))))
+             (setq top-ind (min top-ind ind))
+             (while (and items (<= ind (nth 1 (car items))))
+               (let ((item (pop items)))
+                 (setcar (nthcdr 6 item) (point))
+                 (push item struct)))
+             (push (progn (looking-at org-list-full-item-re)
+                          (let ((bullet (match-string-no-properties 1)))
+                            (list (point)
+                                  ind
+                                  bullet
+                                  (match-string-no-properties 2) ; counter
+                                  (match-string-no-properties 3) ; checkbox
+                                  ;; Description tag.
+                                  (and (save-match-data
+                                         (string-match "[-+*]" bullet))
+                                       (match-string-no-properties 4))
+                                  ;; Ending position, unknown so far.
+                                  nil)))
+                   items))
+           (forward-line 1))
+          ;; Skip empty lines.
+          ((looking-at "^[ \t]*$") (forward-line))
+          ;; Skip inline tasks and blank lines along the way.
+          ((and inlinetask-re (looking-at inlinetask-re))
+           (forward-line)
+           (let ((origin (point)))
+             (when (re-search-forward inlinetask-re limit t)
+               (if (looking-at "^\\*+ END[ \t]*$") (forward-line)
+                 (goto-char origin)))))
+          ;; At some text line.  Check if it ends any previous item.
+          (t
+           (let ((ind (progn (skip-chars-forward " \t") (current-column))))
+             (when (<= ind top-ind)
+               (skip-chars-backward " \r\t\n")
+               (forward-line))
+             (while (<= ind (nth 1 (car items)))
+               (let ((item (pop items)))
+                 (setcar (nthcdr 6 item) (line-beginning-position))
+                 (push item struct)
+                 (unless items
+                   (throw 'exit (sort struct 'car-less-than-car))))))
+           ;; Skip blocks (any type) and drawers contents.
+           (cond
+            ((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
+                  (re-search-forward
+                   (format "^[ \t]*#\\+END%s[ \t]*$"
+                           (org-match-string-no-properties 1))
+                   limit t)))
+            ((and (looking-at drawers-re)
+                  (re-search-forward "^[ \t]*:END:[ \t]*$" limit t))))
+           (forward-line))))))))
+
+(defun org-element-plain-list-parser (limit affiliated structure)
   "Parse a plain list.
 
-Optional argument STRUCTURE, when non-nil, is the structure of
-the plain list being parsed.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.  STRUCTURE is the structure of the plain list being
+parsed.
 
 Return a list whose CAR is `plain-list' and CDR is a plist
 containing `:type', `:begin', `:end', `:contents-begin' and
-`:contents-end', `:structure' and `:post-blank' keywords.
+`:contents-end', `:structure', `:post-blank' and
+`:post-affiliated' keywords.
 
 Assume point is at the beginning of the list."
   (save-excursion
-    (let* ((struct (or structure (org-list-struct)))
+    (let* ((struct (or structure (org-element--list-struct limit)))
           (prevs (org-list-prevs-alist struct))
-          (parents (org-list-parents-alist struct))
           (type (org-list-get-list-type (point) struct prevs))
           (contents-begin (point))
-          (keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+          (begin (car affiliated))
           (contents-end
            (progn (goto-char (org-list-get-list-end (point) struct prevs))
                   (unless (bolp) (forward-line))
                   (point)))
           (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (= (point) limit) limit (line-beginning-position)))))
       ;; Return value.
       (list 'plain-list
            (nconc
@@ -1125,8 +1271,9 @@ Assume point is at the beginning of the list."
                   :contents-begin contents-begin
                   :contents-end contents-end
                   :structure struct
-                  :post-blank (count-lines contents-end end))
-            (cadr keywords))))))
+                  :post-blank (count-lines contents-end end)
+                  :post-affiliated contents-begin)
+            (cdr affiliated))))))
 
 (defun org-element-plain-list-interpreter (plain-list contents)
   "Interpret PLAIN-LIST element as Org syntax.
@@ -1138,27 +1285,82 @@ CONTENTS is the contents of the element."
     (buffer-string)))
 
 
+;;;; Property Drawer
+
+(defun org-element-property-drawer-parser (limit affiliated)
+  "Parse a property drawer.
+
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
+
+Return a list whose CAR is `property-drawer' and CDR is a plist
+containing `:begin', `:end', `:hiddenp', `:contents-begin',
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
+
+Assume point is at the beginning of the property drawer."
+  (save-excursion
+    (let ((case-fold-search t))
+      (if (not (save-excursion
+                (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
+         ;; Incomplete drawer: parse it as a paragraph.
+         (org-element-paragraph-parser limit affiliated)
+       (save-excursion
+         (let* ((drawer-end-line (match-beginning 0))
+                (begin (car affiliated))
+                (post-affiliated (point))
+                (contents-begin (progn (forward-line)
+                                       (and (< (point) drawer-end-line)
+                                            (point))))
+                (contents-end (and contents-begin drawer-end-line))
+                (hidden (org-invisible-p2))
+                (pos-before-blank (progn (goto-char drawer-end-line)
+                                         (forward-line)
+                                         (point)))
+                (end (progn (skip-chars-forward " \r\t\n" limit)
+                            (if (eobp) (point) (line-beginning-position)))))
+           (list 'property-drawer
+                 (nconc
+                  (list :begin begin
+                        :end end
+                        :hiddenp hidden
+                        :contents-begin contents-begin
+                        :contents-end contents-end
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
+
+(defun org-element-property-drawer-interpreter (property-drawer contents)
+  "Interpret PROPERTY-DRAWER element as Org syntax.
+CONTENTS is the properties within the drawer."
+  (format ":PROPERTIES:\n%s:END:" contents))
+
+
 ;;;; Quote Block
 
-(defun org-element-quote-block-parser (limit)
+(defun org-element-quote-block-parser (limit affiliated)
   "Parse a quote block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `quote-block' and CDR is a plist
 containing `:begin', `:end', `:hiddenp', `:contents-begin',
-`:contents-end' and `:post-blank' keywords.
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END_QUOTE[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((block-end-line (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 ;; Empty blocks have no contents.
                 (contents-begin (progn (forward-line)
                                        (and (< (point) block-end-line)
@@ -1169,8 +1371,7 @@ Assume point is at the beginning of the block."
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'quote-block
                  (nconc
                   (list :begin begin
@@ -1178,8 +1379,9 @@ Assume point is at the beginning of the block."
                         :hiddenp hidden
                         :contents-begin contents-begin
                         :contents-end contents-end
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-quote-block-interpreter (quote-block contents)
   "Interpret QUOTE-BLOCK element as Org syntax.
@@ -1221,28 +1423,33 @@ CONTENTS is the contents of the element."
 
 ;;;; Special Block
 
-(defun org-element-special-block-parser (limit)
+(defun org-element-special-block-parser (limit affiliated)
   "Parse a special block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `special-block' and CDR is a plist
 containing `:type', `:begin', `:end', `:hiddenp',
-`:contents-begin', `:contents-end' and `:post-blank' keywords.
+`:contents-begin', `:contents-end', `:post-blank' and
+`:post-affiliated' keywords.
 
 Assume point is at the beginning of the block."
   (let* ((case-fold-search t)
-        (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(S-+\\)")
+        (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
                      (upcase (match-string-no-properties 1)))))
     (if (not (save-excursion
               (re-search-forward
-               (format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t)))
+               (format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type))
+               limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((block-end-line (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 ;; Empty blocks have no contents.
                 (contents-begin (progn (forward-line)
                                        (and (< (point) block-end-line)
@@ -1253,8 +1460,7 @@ Assume point is at the beginning of the block."
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'special-block
                  (nconc
                   (list :type type
@@ -1263,8 +1469,9 @@ Assume point is at the beginning of the block."
                         :hiddenp hidden
                         :contents-begin contents-begin
                         :contents-end contents-end
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-special-block-interpreter (special-block contents)
   "Interpret SPECIAL-BLOCK element as Org syntax.
@@ -1290,28 +1497,34 @@ CONTENTS is the contents of the element."
 
 ;;;; Babel Call
 
-(defun org-element-babel-call-parser (limit)
+(defun org-element-babel-call-parser (limit affiliated)
   "Parse a babel call.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `babel-call' and CDR is a plist
-containing `:begin', `:end', `:info' and `:post-blank' as
-keywords."
+containing `:begin', `:end', `:info', `:post-blank' and
+`:post-affiliated' as keywords."
   (save-excursion
     (let ((case-fold-search t)
          (info (progn (looking-at org-babel-block-lob-one-liner-regexp)
                       (org-babel-lob-get-info)))
-         (begin (point-at-bol))
+         (begin (car affiliated))
+         (post-affiliated (point))
          (pos-before-blank (progn (forward-line) (point)))
          (end (progn (skip-chars-forward " \r\t\n" limit)
-                     (skip-chars-backward " \t")
-                     (if (bolp) (point) (line-end-position)))))
+                     (if (eobp) (point) (line-beginning-position)))))
       (list 'babel-call
-           (list :begin begin
-                 :end end
-                 :info info
-                 :post-blank (count-lines pos-before-blank end))))))
+           (nconc
+            (list :begin begin
+                  :end end
+                  :info info
+                  :post-blank (count-lines pos-before-blank end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-babel-call-interpreter (babel-call contents)
   "Interpret BABEL-CALL element as Org syntax.
@@ -1340,13 +1553,13 @@ as keywords."
     (let* ((case-fold-search nil)
           (begin (point))
           (value (progn (search-forward org-clock-string (line-end-position) t)
-                        (org-skip-whitespace)
-                        (looking-at "\\[.*\\]")
-                        (org-match-string-no-properties 0)))
-          (time (and (progn (goto-char (match-end 0))
-                            (looking-at " +=> +\\(\\S-+\\)[ \t]*$"))
-                     (org-match-string-no-properties 1)))
-          (status (if time 'closed 'running))
+                        (skip-chars-forward " \t")
+                        (org-element-timestamp-parser)))
+          (duration (and (search-forward " => " (line-end-position) t)
+                         (progn (skip-chars-forward " \t")
+                                (looking-at "\\(\\S-+\\)[ \t]*$"))
+                         (org-match-string-no-properties 1)))
+          (status (if duration 'closed 'running))
           (post-blank (let ((before-blank (progn (forward-line) (point))))
                         (skip-chars-forward " \r\t\n" limit)
                         (skip-chars-backward " \t")
@@ -1356,7 +1569,7 @@ as keywords."
       (list 'clock
            (list :status status
                  :value value
-                 :time time
+                 :duration duration
                  :begin begin
                  :end end
                  :post-blank post-blank)))))
@@ -1365,30 +1578,34 @@ as keywords."
   "Interpret CLOCK element as Org syntax.
 CONTENTS is nil."
   (concat org-clock-string " "
-         (org-element-property :value clock)
-         (let ((time (org-element-property :time clock)))
-           (and time
+         (org-element-timestamp-interpreter
+          (org-element-property :value clock) nil)
+         (let ((duration (org-element-property :duration clock)))
+           (and duration
                 (concat " => "
                         (apply 'format
                                "%2s:%02s"
-                               (org-split-string time ":")))))))
+                               (org-split-string duration ":")))))))
 
 
 ;;;; Comment
 
-(defun org-element-comment-parser (limit)
+(defun org-element-comment-parser (limit affiliated)
   "Parse a comment.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `comment' and CDR is a plist
-containing `:begin', `:end', `:value' and `:post-blank'
-keywords.
+containing `:begin', `:end', `:value', `:post-blank',
+`:post-affiliated' keywords.
 
 Assume point is at comment beginning."
   (save-excursion
-    (let* ((keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+    (let* ((begin (car affiliated))
+          (post-affiliated (point))
           (value (prog2 (looking-at "[ \t]*# ?")
                      (buffer-substring-no-properties
                       (match-end 0) (line-end-position))
@@ -1408,15 +1625,15 @@ Assume point is at comment beginning."
              (point)))
           (end (progn (goto-char com-end)
                       (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (eobp) (point) (line-beginning-position)))))
       (list 'comment
            (nconc
             (list :begin begin
                   :end end
                   :value value
-                  :post-blank (count-lines com-end end))
-            (cadr keywords))))))
+                  :post-blank (count-lines com-end end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-comment-interpreter (comment contents)
   "Interpret COMMENT element as Org syntax.
@@ -1426,33 +1643,35 @@ CONTENTS is nil."
 
 ;;;; Comment Block
 
-(defun org-element-comment-block-parser (limit)
+(defun org-element-comment-block-parser (limit affiliated)
   "Parse an export block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `comment-block' and CDR is a plist
-containing `:begin', `:end', `:hiddenp', `:value' and
-`:post-blank' keywords.
+containing `:begin', `:end', `:hiddenp', `:value', `:post-blank'
+and `:post-affiliated' keywords.
 
 Assume point is at comment block beginning."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END_COMMENT[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((contents-end (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 (contents-begin (progn (forward-line) (point)))
                 (hidden (org-invisible-p2))
                 (pos-before-blank (progn (goto-char contents-end)
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position))))
+                            (if (eobp) (point) (line-beginning-position))))
                 (value (buffer-substring-no-properties
                         contents-begin contents-end)))
            (list 'comment-block
@@ -1461,8 +1680,9 @@ Assume point is at comment block beginning."
                         :end end
                         :value value
                         :hiddenp hidden
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-comment-block-interpreter (comment-block contents)
   "Interpret COMMENT-BLOCK element as Org syntax.
@@ -1471,32 +1691,105 @@ CONTENTS is nil."
          (org-remove-indentation (org-element-property :value comment-block))))
 
 
+;;;; Diary Sexp
+
+(defun org-element-diary-sexp-parser (limit affiliated)
+  "Parse a diary sexp.
+
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
+
+Return a list whose CAR is `diary-sexp' and CDR is a plist
+containing `:begin', `:end', `:value', `:post-blank' and
+`:post-affiliated' keywords."
+  (save-excursion
+    (let ((begin (car affiliated))
+         (post-affiliated (point))
+         (value (progn (looking-at "\\(%%(.*\\)[ \t]*$")
+                       (org-match-string-no-properties 1)))
+         (pos-before-blank (progn (forward-line) (point)))
+         (end (progn (skip-chars-forward " \r\t\n" limit)
+                     (if (eobp) (point) (line-beginning-position)))))
+      (list 'diary-sexp
+           (nconc
+            (list :value value
+                  :begin begin
+                  :end end
+                  :post-blank (count-lines pos-before-blank end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
+
+(defun org-element-diary-sexp-interpreter (diary-sexp contents)
+  "Interpret DIARY-SEXP as Org syntax.
+CONTENTS is nil."
+  (org-element-property :value diary-sexp))
+
+
 ;;;; Example Block
 
-(defun org-element-example-block-parser (limit)
+(defun org-element--remove-indentation (s &optional n)
+  "Remove maximum common indentation in string S and return it.
+When optional argument N is a positive integer, remove exactly
+that much characters from indentation, if possible, or return
+S as-is otherwise.  Unlike to `org-remove-indentation', this
+function doesn't call `untabify' on S."
+  (catch 'exit
+    (with-temp-buffer
+      (insert s)
+      (goto-char (point-min))
+      ;; Find maximum common indentation, if not specified.
+      (setq n (or n
+                  (let ((min-ind (point-max)))
+                   (save-excursion
+                     (while (re-search-forward "^[ \t]*\\S-" nil t)
+                       (let ((ind (1- (current-column))))
+                         (if (zerop ind) (throw 'exit s)
+                           (setq min-ind (min min-ind ind))))))
+                   min-ind)))
+      (if (zerop n) s
+       ;; Remove exactly N indentation, but give up if not possible.
+       (while (not (eobp))
+         (let ((ind (progn (skip-chars-forward " \t") (current-column))))
+           (cond ((eolp) (delete-region (line-beginning-position) (point)))
+                 ((< ind n) (throw 'exit s))
+                 (t (org-indent-line-to (- ind n))))
+           (forward-line)))
+       (buffer-string)))))
+
+(defun org-element-example-block-parser (limit affiliated)
   "Parse an example block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `example-block' and CDR is a plist
 containing `:begin', `:end', `:number-lines', `:preserve-indent',
 `:retain-labels', `:use-labels', `:label-fmt', `:hiddenp',
-`:switches', `:value' and `:post-blank' keywords."
+`:switches', `:value', `:post-blank' and `:post-affiliated'
+keywords."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END_EXAMPLE[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((contents-end (match-beginning 0)))
        (save-excursion
          (let* ((switches
-                 (progn (looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?")
-                        (org-match-string-no-properties 1)))
+                 (progn
+                   (looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?")
+                   (org-match-string-no-properties 1)))
                 ;; Switches analysis
-                (number-lines (cond ((not switches) nil)
-                                    ((string-match "-n\\>" switches) 'new)
-                                    ((string-match "+n\\>" switches) 'continued)))
-                (preserve-indent (and switches (string-match "-i\\>" switches)))
+                (number-lines
+                 (cond ((not switches) nil)
+                       ((string-match "-n\\>" switches) 'new)
+                       ((string-match "+n\\>" switches) 'continued)))
+                (preserve-indent
+                 (or org-src-preserve-indentation
+                     (and switches (string-match "-i\\>" switches))))
                 ;; Should labels be retained in (or stripped from) example
                 ;; blocks?
                 (retain-labels
@@ -1507,24 +1800,28 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
                 ;; line-numbers?
                 (use-labels
                  (or (not switches)
-                     (and retain-labels (not (string-match "-k\\>" switches)))))
-                (label-fmt (and switches
-                                (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
-                                (match-string 1 switches)))
+                     (and retain-labels
+                          (not (string-match "-k\\>" switches)))))
+                (label-fmt
+                 (and switches
+                      (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
+                      (match-string 1 switches)))
                 ;; Standard block parsing.
-                (keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+                (begin (car affiliated))
+                (post-affiliated (point))
+                (block-ind (progn (skip-chars-forward " \t") (current-column)))
                 (contents-begin (progn (forward-line) (point)))
                 (hidden (org-invisible-p2))
-                (value (org-unescape-code-in-string
-                        (buffer-substring-no-properties
-                         contents-begin contents-end)))
+                (value (org-element--remove-indentation
+                        (org-unescape-code-in-string
+                         (buffer-substring-no-properties
+                          contents-begin contents-end))
+                        (and preserve-indent block-ind)))
                 (pos-before-blank (progn (goto-char contents-end)
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'example-block
                  (nconc
                   (list :begin begin
@@ -1537,30 +1834,33 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
                         :use-labels use-labels
                         :label-fmt label-fmt
                         :hiddenp hidden
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-example-block-interpreter (example-block contents)
   "Interpret EXAMPLE-BLOCK element as Org syntax.
 CONTENTS is nil."
   (let ((switches (org-element-property :switches example-block)))
     (concat "#+BEGIN_EXAMPLE" (and switches (concat " " switches)) "\n"
-           (org-remove-indentation
-            (org-escape-code-in-string
-             (org-element-property :value example-block)))
+           (org-escape-code-in-string
+            (org-element-property :value example-block))
            "#+END_EXAMPLE")))
 
 
 ;;;; Export Block
 
-(defun org-element-export-block-parser (limit)
+(defun org-element-export-block-parser (limit affiliated)
   "Parse an export block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `export-block' and CDR is a plist
-containing `:begin', `:end', `:type', `:hiddenp', `:value' and
-`:post-blank' keywords.
+containing `:begin', `:end', `:type', `:hiddenp', `:value',
+`:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at export-block beginning."
   (let* ((case-fold-search t)
@@ -1570,19 +1870,18 @@ Assume point is at export-block beginning."
               (re-search-forward
                (format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((contents-end (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 (contents-begin (progn (forward-line) (point)))
                 (hidden (org-invisible-p2))
                 (pos-before-blank (progn (goto-char contents-end)
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position))))
+                            (if (eobp) (point) (line-beginning-position))))
                 (value (buffer-substring-no-properties contents-begin
                                                        contents-end)))
            (list 'export-block
@@ -1592,8 +1891,9 @@ Assume point is at export-block beginning."
                         :type type
                         :value value
                         :hiddenp hidden
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-export-block-interpreter (export-block contents)
   "Interpret EXPORT-BLOCK element as Org syntax.
@@ -1606,18 +1906,22 @@ CONTENTS is nil."
 
 ;;;; Fixed-width
 
-(defun org-element-fixed-width-parser (limit)
+(defun org-element-fixed-width-parser (limit affiliated)
   "Parse a fixed-width section.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `fixed-width' and CDR is a plist
-containing `:begin', `:end', `:value' and `:post-blank' keywords.
+containing `:begin', `:end', `:value', `:post-blank' and
+`:post-affiliated' keywords.
 
 Assume point is at the beginning of the fixed-width area."
   (save-excursion
-    (let* ((keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+    (let* ((begin (car affiliated))
+          (post-affiliated (point))
           value
           (end-area
            (progn
@@ -1632,45 +1936,52 @@ Assume point is at the beginning of the fixed-width area."
                (forward-line))
              (point)))
           (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (eobp) (point) (line-beginning-position)))))
       (list 'fixed-width
            (nconc
             (list :begin begin
                   :end end
                   :value value
-                  :post-blank (count-lines end-area end))
-            (cadr keywords))))))
+                  :post-blank (count-lines end-area end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-fixed-width-interpreter (fixed-width contents)
   "Interpret FIXED-WIDTH element as Org syntax.
 CONTENTS is nil."
-  (replace-regexp-in-string
-   "^" ": " (substring (org-element-property :value fixed-width) 0 -1)))
+  (let ((value (org-element-property :value fixed-width)))
+    (and value
+        (replace-regexp-in-string
+         "^" ": "
+         (if (string-match "\n\\'" value) (substring value 0 -1) value)))))
 
 
 ;;;; Horizontal Rule
 
-(defun org-element-horizontal-rule-parser (limit)
+(defun org-element-horizontal-rule-parser (limit affiliated)
   "Parse an horizontal rule.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `horizontal-rule' and CDR is a plist
-containing `:begin', `:end' and `:post-blank' keywords."
+containing `:begin', `:end', `:post-blank' and `:post-affiliated'
+keywords."
   (save-excursion
-    (let* ((keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
-          (post-hr (progn (forward-line) (point)))
-          (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+    (let ((begin (car affiliated))
+         (post-affiliated (point))
+         (post-hr (progn (forward-line) (point)))
+         (end (progn (skip-chars-forward " \r\t\n" limit)
+                     (if (eobp) (point) (line-beginning-position)))))
       (list 'horizontal-rule
            (nconc
             (list :begin begin
                   :end end
-                  :post-blank (count-lines post-hr end))
-            (cadr keywords))))))
+                  :post-blank (count-lines post-hr end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-horizontal-rule-interpreter (horizontal-rule contents)
   "Interpret HORIZONTAL-RULE element as Org syntax.
@@ -1680,31 +1991,36 @@ CONTENTS is nil."
 
 ;;;; Keyword
 
-(defun org-element-keyword-parser (limit)
+(defun org-element-keyword-parser (limit affiliated)
   "Parse a keyword at point.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `keyword' and CDR is a plist
-containing `:key', `:value', `:begin', `:end' and `:post-blank'
-keywords."
+containing `:key', `:value', `:begin', `:end', `:post-blank' and
+`:post-affiliated' keywords."
   (save-excursion
-    (let* ((case-fold-search t)
-          (begin (point))
-          (key (progn (looking-at "[ \t]*#\\+\\(\\S-+\\):")
-                      (upcase (org-match-string-no-properties 1))))
-          (value (org-trim (buffer-substring-no-properties
-                            (match-end 0) (point-at-eol))))
-          (pos-before-blank (progn (forward-line) (point)))
-          (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+    (let ((begin (car affiliated))
+         (post-affiliated (point))
+         (key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):")
+                     (upcase (org-match-string-no-properties 1))))
+         (value (org-trim (buffer-substring-no-properties
+                           (match-end 0) (point-at-eol))))
+         (pos-before-blank (progn (forward-line) (point)))
+         (end (progn (skip-chars-forward " \r\t\n" limit)
+                     (if (eobp) (point) (line-beginning-position)))))
       (list 'keyword
-           (list :key key
-                 :value value
-                 :begin begin
-                 :end end
-                 :post-blank (count-lines pos-before-blank end))))))
+           (nconc
+            (list :key key
+                  :value value
+                  :begin begin
+                  :end end
+                  :post-blank (count-lines pos-before-blank end)
+                  :post-affiliated post-affiliated)
+            (cdr affiliated))))))
 
 (defun org-element-keyword-interpreter (keyword contents)
   "Interpret KEYWORD element as Org syntax.
@@ -1716,39 +2032,41 @@ CONTENTS is nil."
 
 ;;;; Latex Environment
 
-(defun org-element-latex-environment-parser (limit)
+(defun org-element-latex-environment-parser (limit affiliated)
   "Parse a LaTeX environment.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `latex-environment' and CDR is a plist
-containing `:begin', `:end', `:value' and `:post-blank'
-keywords.
+containing `:begin', `:end', `:value', `:post-blank' and
+`:post-affiliated' keywords.
 
 Assume point is at the beginning of the latex environment."
   (save-excursion
-    (let* ((case-fold-search t)
-          (code-begin (point))
-          (keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
-          (env (progn (looking-at "^[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}")
-                      (regexp-quote (match-string 1))))
-          (code-end
-           (progn (re-search-forward
-                   (format "^[ \t]*\\\\end{%s}[ \t]*$" env) limit t)
-                  (forward-line)
-                  (point)))
-          (value (buffer-substring-no-properties code-begin code-end))
-          (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
-      (list 'latex-environment
-           (nconc
-            (list :begin begin
-                  :end end
-                  :value value
-                  :post-blank (count-lines code-end end))
-            (cadr keywords))))))
+    (let ((case-fold-search t)
+         (code-begin (point)))
+      (looking-at "[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}")
+      (if (not (re-search-forward (format "^[ \t]*\\\\end{%s}[ \t]*$"
+                                         (regexp-quote (match-string 1)))
+                                 limit t))
+         ;; Incomplete latex environment: parse it as a paragraph.
+         (org-element-paragraph-parser limit affiliated)
+       (let* ((code-end (progn (forward-line) (point)))
+              (begin (car affiliated))
+              (value (buffer-substring-no-properties code-begin code-end))
+              (end (progn (skip-chars-forward " \r\t\n" limit)
+                          (if (eobp) (point) (line-beginning-position)))))
+         (list 'latex-environment
+               (nconc
+                (list :begin begin
+                      :end end
+                      :value value
+                      :post-blank (count-lines code-end end)
+                      :post-affiliated code-begin)
+                (cdr affiliated))))))))
 
 (defun org-element-latex-environment-interpreter (latex-environment contents)
   "Interpret LATEX-ENVIRONMENT element as Org syntax.
@@ -1756,28 +2074,58 @@ CONTENTS is nil."
   (org-element-property :value latex-environment))
 
 
+;;;; Node Property
+
+(defun org-element-node-property-parser (limit)
+  "Parse a node-property at point.
+
+LIMIT bounds the search.
+
+Return a list whose CAR is `node-property' and CDR is a plist
+containing `:key', `:value', `:begin', `:end' and `:post-blank'
+keywords."
+  (save-excursion
+    (looking-at org-property-re)
+    (let ((case-fold-search t)
+         (begin (point))
+         (key   (org-match-string-no-properties 2))
+         (value (org-match-string-no-properties 3))
+         (pos-before-blank (progn (forward-line) (point)))
+         (end (progn (skip-chars-forward " \r\t\n" limit)
+                     (if (eobp) (point) (point-at-bol)))))
+      (list 'node-property
+           (list :key key
+                 :value value
+                 :begin begin
+                 :end end
+                 :post-blank (count-lines pos-before-blank end))))))
+
+(defun org-element-node-property-interpreter (node-property contents)
+  "Interpret NODE-PROPERTY element as Org syntax.
+CONTENTS is nil."
+  (format org-property-format
+         (format ":%s:" (org-element-property :key node-property))
+         (org-element-property :value node-property)))
+
+
 ;;;; Paragraph
 
-(defun org-element-paragraph-parser (limit)
+(defun org-element-paragraph-parser (limit affiliated)
   "Parse a paragraph.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `paragraph' and CDR is a plist
 containing `:begin', `:end', `:contents-begin' and
-`:contents-end' and `:post-blank' keywords.
+`:contents-end', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at the beginning of the paragraph."
   (save-excursion
-    (let* ((contents-begin (point))
-          ;; INNER-PAR-P is non-nil when paragraph is at the
-          ;; beginning of an item or a footnote reference. In that
-          ;; case, we mustn't look for affiliated keywords since they
-          ;; belong to the container.
-          (inner-par-p (not (bolp)))
-          (keywords (unless inner-par-p
-                      (org-element--collect-affiliated-keywords)))
-          (begin (if inner-par-p contents-begin (car keywords)))
+    (let* ((begin (car affiliated))
+          (contents-begin (point))
           (before-blank
            (let ((case-fold-search t))
              (end-of-line)
@@ -1811,20 +2159,21 @@ Assume point is at the beginning of the paragraph."
                                (re-search-forward
                                 "^[ \t]*#\\+END:?[ \t]*$" limit t)))
                         ;; Stop at valid blocks.
-                        (and (looking-at
-                              "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
+                        (and (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
                              (save-excursion
                                (re-search-forward
                                 (format "^[ \t]*#\\+END_%s[ \t]*$"
-                                        (match-string 1))
+                                        (regexp-quote
+                                         (org-match-string-no-properties 1)))
                                 limit t)))
                         ;; Stop at valid latex environments.
                         (and (looking-at
-                              "^[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}[ \t]*$")
+                              "[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}")
                              (save-excursion
                                (re-search-forward
                                 (format "^[ \t]*\\\\end{%s}[ \t]*$"
-                                        (match-string 1))
+                                        (regexp-quote
+                                         (org-match-string-no-properties 1)))
                                 limit t)))
                         ;; Stop at valid keywords.
                         (looking-at "[ \t]*#\\+\\S-+:")
@@ -1841,16 +2190,16 @@ Assume point is at the beginning of the paragraph."
                                (forward-line)
                                (point)))
           (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (eobp) (point) (line-beginning-position)))))
       (list 'paragraph
            (nconc
             (list :begin begin
                   :end end
                   :contents-begin contents-begin
                   :contents-end contents-end
-                  :post-blank (count-lines before-blank end))
-            (cadr keywords))))))
+                  :post-blank (count-lines before-blank end)
+                  :post-affiliated contents-begin)
+            (cdr affiliated))))))
 
 (defun org-element-paragraph-interpreter (paragraph contents)
   "Interpret PARAGRAPH element as Org syntax.
@@ -1879,13 +2228,11 @@ and `:post-blank' keywords."
           (end (point))
           closed deadline scheduled)
       (goto-char begin)
-      (while (re-search-forward org-keyword-time-not-clock-regexp
-                               (line-end-position) t)
+      (while (re-search-forward org-keyword-time-not-clock-regexp end t)
        (goto-char (match-end 1))
-       (org-skip-whitespace)
-       (let ((time (buffer-substring-no-properties
-                    (1+ (point)) (1- (match-end 0))))
-             (keyword (match-string 1)))
+       (skip-chars-forward " \t" end)
+       (let ((keyword (match-string 1))
+             (time (org-element-timestamp-parser)))
          (cond ((equal keyword org-closed-string) (setq closed time))
                ((equal keyword org-deadline-string) (setq deadline time))
                (t (setq scheduled time)))))
@@ -1903,69 +2250,21 @@ CONTENTS is nil."
   (mapconcat
    'identity
    (delq nil
-        (list (let ((closed (org-element-property :closed planning)))
-                (when closed (concat org-closed-string " [" closed "]")))
-              (let ((deadline (org-element-property :deadline planning)))
-                (when deadline (concat org-deadline-string " <" deadline ">")))
+        (list (let ((deadline (org-element-property :deadline planning)))
+                (when deadline
+                  (concat org-deadline-string " "
+                          (org-element-timestamp-interpreter deadline nil))))
               (let ((scheduled (org-element-property :scheduled planning)))
                 (when scheduled
-                  (concat org-scheduled-string " <" scheduled ">")))))
+                  (concat org-scheduled-string " "
+                          (org-element-timestamp-interpreter scheduled nil))))
+              (let ((closed (org-element-property :closed planning)))
+                (when closed
+                  (concat org-closed-string " "
+                          (org-element-timestamp-interpreter closed nil))))))
    " "))
 
 
-;;;; Property Drawer
-
-(defun org-element-property-drawer-parser (limit)
-  "Parse a property drawer.
-
-LIMIT bounds the search.
-
-Return a list whose CAR is `property-drawer' and CDR is a plist
-containing `:begin', `:end', `:hiddenp', `:contents-begin',
-`:contents-end', `:properties' and `:post-blank' keywords.
-
-Assume point is at the beginning of the property drawer."
-  (save-excursion
-    (let ((case-fold-search t)
-         (begin (point))
-         (prop-begin (progn (forward-line) (point)))
-         (hidden (org-invisible-p2))
-         (properties
-          (let (val)
-            (while (not (looking-at "^[ \t]*:END:[ \t]*$"))
-              (when (looking-at "[ \t]*:\\([A-Za-z][-_A-Za-z0-9]*\\):")
-                (push (cons (org-match-string-no-properties 1)
-                            (org-trim
-                             (buffer-substring-no-properties
-                              (match-end 0) (point-at-eol))))
-                      val))
-              (forward-line))
-            val))
-         (prop-end (progn (re-search-forward "^[ \t]*:END:" limit t)
-                          (point-at-bol)))
-         (pos-before-blank (progn (forward-line) (point)))
-         (end (progn (skip-chars-forward " \r\t\n" limit)
-                     (skip-chars-backward " \t")
-                     (if (bolp) (point) (line-end-position)))))
-      (list 'property-drawer
-           (list :begin begin
-                 :end end
-                 :hiddenp hidden
-                 :properties properties
-                 :post-blank (count-lines pos-before-blank end))))))
-
-(defun org-element-property-drawer-interpreter (property-drawer contents)
-  "Interpret PROPERTY-DRAWER element as Org syntax.
-CONTENTS is nil."
-  (let ((props (org-element-property :properties property-drawer)))
-    (concat
-     ":PROPERTIES:\n"
-     (mapconcat (lambda (p)
-                 (format org-property-format (format ":%s:" (car p)) (cdr p)))
-               (nreverse props) "\n")
-     "\n:END:")))
-
-
 ;;;; Quote Section
 
 (defun org-element-quote-section-parser (limit)
@@ -1999,28 +2298,30 @@ CONTENTS is nil."
 
 ;;;; Src Block
 
-(defun org-element-src-block-parser (limit)
+(defun org-element-src-block-parser (limit affiliated)
   "Parse a src block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `src-block' and CDR is a plist
 containing `:language', `:switches', `:parameters', `:begin',
 `:end', `:hiddenp', `:number-lines', `:retain-labels',
-`:use-labels', `:label-fmt', `:preserve-indent', `:value' and
-`:post-blank' keywords.
+`:use-labels', `:label-fmt', `:preserve-indent', `:value',
+`:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at the beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_SRC[ \t]*$"
                                                limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((contents-end (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                ;; Get beginning position.
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 ;; Get language as a string.
                 (language
                  (progn
@@ -2035,13 +2336,17 @@ Assume point is at the beginning of the block."
                 ;; Get parameters.
                 (parameters (org-match-string-no-properties 3))
                 ;; Switches analysis
-                (number-lines (cond ((not switches) nil)
-                                    ((string-match "-n\\>" switches) 'new)
-                                    ((string-match "+n\\>" switches) 'continued)))
-                (preserve-indent (and switches (string-match "-i\\>" switches)))
-                (label-fmt (and switches
-                                (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
-                                (match-string 1 switches)))
+                (number-lines
+                 (cond ((not switches) nil)
+                       ((string-match "-n\\>" switches) 'new)
+                       ((string-match "+n\\>" switches) 'continued)))
+                (preserve-indent (or org-src-preserve-indentation
+                                     (and switches
+                                          (string-match "-i\\>" switches))))
+                (label-fmt
+                 (and switches
+                      (string-match "-l +\"\\([^\"\n]+\\)\"" switches)
+                      (match-string 1 switches)))
                 ;; Should labels be retained in (or stripped from)
                 ;; src blocks?
                 (retain-labels
@@ -2052,19 +2357,24 @@ Assume point is at the beginning of the block."
                 ;; line-numbers?
                 (use-labels
                  (or (not switches)
-                     (and retain-labels (not (string-match "-k\\>" switches)))))
+                     (and retain-labels
+                          (not (string-match "-k\\>" switches)))))
+                ;; Indentation.
+                (block-ind (progn (skip-chars-forward " \t") (current-column)))
                 ;; Get visibility status.
                 (hidden (progn (forward-line) (org-invisible-p2)))
                 ;; Retrieve code.
-                (value (org-unescape-code-in-string
-                        (buffer-substring-no-properties (point) contents-end)))
+                (value (org-element--remove-indentation
+                        (org-unescape-code-in-string
+                         (buffer-substring-no-properties
+                          (point) contents-end))
+                        (and preserve-indent block-ind)))
                 (pos-before-blank (progn (goto-char contents-end)
                                          (forward-line)
                                          (point)))
                 ;; Get position after ending blank lines.
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'src-block
                  (nconc
                   (list :language language
@@ -2081,8 +2391,9 @@ Assume point is at the beginning of the block."
                         :label-fmt label-fmt
                         :hiddenp hidden
                         :value value
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-src-block-interpreter (src-block contents)
   "Interpret SRC-BLOCK element as Org syntax.
@@ -2092,15 +2403,13 @@ CONTENTS is nil."
        (params (org-element-property :parameters src-block))
        (value (let ((val (org-element-property :value src-block)))
                 (cond
-                 (org-src-preserve-indentation val)
-                 ((zerop org-edit-src-content-indentation)
-                  (org-remove-indentation val))
+                 ((org-element-property :preserve-indent src-block) val)
+                 ((zerop org-edit-src-content-indentation) val)
                  (t
                   (let ((ind (make-string
                               org-edit-src-content-indentation 32)))
                     (replace-regexp-in-string
-                     "\\(^\\)[ \t]*\\S-" ind
-                     (org-remove-indentation val) nil nil 1)))))))
+                     "\\(^\\)[ \t]*\\S-" ind val nil nil 1)))))))
     (concat (format "#+BEGIN_SRC%s\n"
                    (concat (and lang (concat " " lang))
                            (and switches (concat " " switches))
@@ -2111,22 +2420,25 @@ CONTENTS is nil."
 
 ;;;; Table
 
-(defun org-element-table-parser (limit)
+(defun org-element-table-parser (limit affiliated)
   "Parse a table at point.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `table' and CDR is a plist containing
 `:begin', `:end', `:tblfm', `:type', `:contents-begin',
-`:contents-end', `:value' and `:post-blank' keywords.
+`:contents-end', `:value', `:post-blank' and `:post-affiliated'
+keywords.
 
 Assume point is at the beginning of the table."
   (save-excursion
     (let* ((case-fold-search t)
           (table-begin (point))
           (type (if (org-at-table.el-p) 'table.el 'org))
-          (keywords (org-element--collect-affiliated-keywords))
-          (begin (car keywords))
+          (begin (car affiliated))
           (table-end
            (if (re-search-forward org-table-any-border-regexp limit 'm)
                (goto-char (match-beginning 0))
@@ -2138,8 +2450,7 @@ Assume point is at the beginning of the table."
                    acc))
           (pos-before-blank (point))
           (end (progn (skip-chars-forward " \r\t\n" limit)
-                      (skip-chars-backward " \t")
-                      (if (bolp) (point) (line-end-position)))))
+                      (if (eobp) (point) (line-beginning-position)))))
       (list 'table
            (nconc
             (list :begin begin
@@ -2154,8 +2465,9 @@ Assume point is at the beginning of the table."
                   :value (and (eq type 'table.el)
                               (buffer-substring-no-properties
                                table-begin table-end))
-                  :post-blank (count-lines pos-before-blank end))
-            (cadr keywords))))))
+                  :post-blank (count-lines pos-before-blank end)
+                  :post-affiliated table-begin)
+            (cdr affiliated))))))
 
 (defun org-element-table-interpreter (table contents)
   "Interpret TABLE element as Org syntax.
@@ -2211,33 +2523,35 @@ CONTENTS is the contents of the table row."
 
 ;;;; Verse Block
 
-(defun org-element-verse-block-parser (limit)
+(defun org-element-verse-block-parser (limit affiliated)
   "Parse a verse block.
 
-LIMIT bounds the search.
+LIMIT bounds the search.  AFFILIATED is a list of which CAR is
+the buffer position at the beginning of the first affiliated
+keyword and CDR is a plist of affiliated keywords along with
+their value.
 
 Return a list whose CAR is `verse-block' and CDR is a plist
 containing `:begin', `:end', `:contents-begin', `:contents-end',
-`:hiddenp' and `:post-blank' keywords.
+`:hiddenp', `:post-blank' and `:post-affiliated' keywords.
 
 Assume point is at beginning of the block."
   (let ((case-fold-search t))
     (if (not (save-excursion
               (re-search-forward "^[ \t]*#\\+END_VERSE[ \t]*$" limit t)))
        ;; Incomplete block: parse it as a paragraph.
-       (org-element-paragraph-parser limit)
+       (org-element-paragraph-parser limit affiliated)
       (let ((contents-end (match-beginning 0)))
        (save-excursion
-         (let* ((keywords (org-element--collect-affiliated-keywords))
-                (begin (car keywords))
+         (let* ((begin (car affiliated))
+                (post-affiliated (point))
                 (hidden (progn (forward-line) (org-invisible-p2)))
                 (contents-begin (point))
                 (pos-before-blank (progn (goto-char contents-end)
                                          (forward-line)
                                          (point)))
                 (end (progn (skip-chars-forward " \r\t\n" limit)
-                            (skip-chars-backward " \t")
-                            (if (bolp) (point) (line-end-position)))))
+                            (if (eobp) (point) (line-beginning-position)))))
            (list 'verse-block
                  (nconc
                   (list :begin begin
@@ -2245,8 +2559,9 @@ Assume point is at beginning of the block."
                         :contents-begin contents-begin
                         :contents-end contents-end
                         :hiddenp hidden
-                        :post-blank (count-lines pos-before-blank end))
-                  (cadr keywords)))))))))
+                        :post-blank (count-lines pos-before-blank end)
+                        :post-affiliated post-affiliated)
+                  (cdr affiliated)))))))))
 
 (defun org-element-verse-block-interpreter (verse-block contents)
   "Interpret VERSE-BLOCK element as Org syntax.
@@ -2312,17 +2627,15 @@ Assume point is at the first star marker."
 CONTENTS is the contents of the object."
   (format "*%s*" contents))
 
-(defun org-element-text-markup-successor (limit)
+(defun org-element-text-markup-successor ()
   "Search for the next text-markup object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is a symbol among `bold',
 `italic', `underline', `strike-through', `code' and `verbatim'
 and CDR is beginning position."
   (save-excursion
     (unless (bolp) (backward-char))
-    (when (re-search-forward org-emph-re limit t)
+    (when (re-search-forward org-emph-re nil t)
       (let ((marker (match-string 3)))
        (cons (cond
               ((equal marker "*") 'bold)
@@ -2404,25 +2717,19 @@ CONTENTS is nil."
          (org-element-property :name entity)
          (when (org-element-property :use-brackets-p entity) "{}")))
 
-(defun org-element-latex-or-entity-successor (limit)
+(defun org-element-latex-or-entity-successor ()
   "Search for the next latex-fragment or entity object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `entity' or
 `latex-fragment' and CDR is beginning position."
   (save-excursion
     (unless (bolp) (backward-char))
-    (let ((matchers
-          (remove "begin" (plist-get org-format-latex-options :matchers)))
+    (let ((matchers (cdr org-latex-regexps))
          ;; ENTITY-RE matches both LaTeX commands and Org entities.
          (entity-re
           "\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]]\\)"))
       (when (re-search-forward
-            (concat (mapconcat (lambda (e) (nth 1 (assoc e org-latex-regexps)))
-                               matchers "\\|")
-                    "\\|" entity-re)
-            limit t)
+            (concat (mapconcat #'cadr matchers "\\|") "\\|" entity-re) nil t)
        (goto-char (match-beginning 0))
        (if (looking-at entity-re)
            ;; Determine if it's a real entity or a LaTeX command.
@@ -2432,12 +2739,9 @@ Return value is a cons cell whose CAR is `entity' or
          ;; Determine its type to get the correct beginning position.
          (cons 'latex-fragment
                (catch 'return
-                 (mapc (lambda (e)
-                         (when (looking-at (nth 1 (assoc e org-latex-regexps)))
-                           (throw 'return
-                                  (match-beginning
-                                   (nth 2 (assoc e org-latex-regexps))))))
-                       matchers)
+                 (dolist (e matchers)
+                   (when (looking-at (nth 1 e))
+                     (throw 'return (match-beginning (nth 2 e)))))
                  (point))))))))
 
 
@@ -2474,18 +2778,16 @@ CONTENTS is nil."
          (org-element-property :back-end export-snippet)
          (org-element-property :value export-snippet)))
 
-(defun org-element-export-snippet-successor (limit)
+(defun org-element-export-snippet-successor ()
   "Search for the next export-snippet object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `export-snippet' and CDR
 its beginning position."
   (save-excursion
     (let (beg)
-      (when (and (re-search-forward "@@[-A-Za-z0-9]+:" limit t)
+      (when (and (re-search-forward "@@[-A-Za-z0-9]+:" nil t)
                 (setq beg (match-beginning 0))
-                (search-forward "@@" limit t))
+                (search-forward "@@" nil t))
        (cons 'export-snippet beg)))))
 
 
@@ -2541,21 +2843,19 @@ CONTENTS is nil."
             (concat ":" (org-element-interpret-data inline-def))))))
     (format "[%s]" (concat label def))))
 
-(defun org-element-footnote-reference-successor (limit)
+(defun org-element-footnote-reference-successor ()
   "Search for the next footnote-reference object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `footnote-reference' and
 CDR is beginning position."
   (save-excursion
     (catch 'exit
-      (while (re-search-forward org-footnote-re limit t)
+      (while (re-search-forward org-footnote-re nil t)
        (save-excursion
          (let ((beg (match-beginning 0))
                (count 1))
            (backward-char)
-           (while (re-search-forward "[][]" limit t)
+           (while (re-search-forward "[][]" nil t)
              (if (equal (match-string 0) "[") (incf count) (decf count))
              (when (zerop count)
                (throw 'exit (cons 'footnote-reference beg))))))))))
@@ -2598,11 +2898,9 @@ CONTENTS is nil."
              main-source)
            (and post-options (format "[%s]" post-options)))))
 
-(defun org-element-inline-babel-call-successor (limit)
+(defun org-element-inline-babel-call-successor ()
   "Search for the next inline-babel-call object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `inline-babel-call' and
 CDR is beginning position."
   (save-excursion
@@ -2610,7 +2908,7 @@ CDR is beginning position."
     ;; `org-babel-inline-lob-one-liner-regexp'.
     (when (re-search-forward
           "call_\\([^()\n]+?\\)\\(?:\\[.*?\\]\\)?([^\n]*?)\\(\\[.*?\\]\\)?"
-          limit t)
+          nil t)
       (cons 'inline-babel-call (match-beginning 0)))))
 
 
@@ -2619,8 +2917,6 @@ CDR is beginning position."
 (defun org-element-inline-src-block-parser ()
   "Parse inline source block at point.
 
-LIMIT bounds the search.
-
 Return a list whose CAR is `inline-src-block' and CDR a plist
 with `:begin', `:end', `:language', `:value', `:parameters' and
 `:post-blank' as keywords.
@@ -2655,16 +2951,14 @@ CONTENTS is nil."
            (if arguments (format "[%s]" arguments) "")
            body)))
 
-(defun org-element-inline-src-block-successor (limit)
+(defun org-element-inline-src-block-successor ()
   "Search for the next inline-babel-call element.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `inline-babel-call' and
 CDR is beginning position."
   (save-excursion
     (unless (bolp) (backward-char))
-    (when (re-search-forward org-babel-inline-src-block-regexp limit t)
+    (when (re-search-forward org-babel-inline-src-block-regexp nil t)
       (cons 'inline-src-block (match-beginning 1)))))
 
 ;;;; Italic
@@ -2702,29 +2996,28 @@ CONTENTS is the contents of the object."
 ;;;; Latex Fragment
 
 (defun org-element-latex-fragment-parser ()
-  "Parse latex fragment at point.
+  "Parse LaTeX fragment at point.
 
 Return a list whose CAR is `latex-fragment' and CDR a plist with
 `:value', `:begin', `:end', and `:post-blank' as keywords.
 
-Assume point is at the beginning of the latex fragment."
+Assume point is at the beginning of the LaTeX fragment."
   (save-excursion
     (let* ((begin (point))
           (substring-match
            (catch 'exit
-             (mapc (lambda (e)
-                     (let ((latex-regexp (nth 1 (assoc e org-latex-regexps))))
-                       (when (or (looking-at latex-regexp)
-                                 (and (not (bobp))
-                                      (save-excursion
-                                        (backward-char)
-                                        (looking-at latex-regexp))))
-                         (throw 'exit (nth 2 (assoc e org-latex-regexps))))))
-                   (plist-get org-format-latex-options :matchers))
+             (dolist (e (cdr org-latex-regexps))
+               (let ((latex-regexp (nth 1 e)))
+                 (when (or (looking-at latex-regexp)
+                           (and (not (bobp))
+                                (save-excursion
+                                  (backward-char)
+                                  (looking-at latex-regexp))))
+                   (throw 'exit (nth 2 e)))))
              ;; None found: it's a macro.
              (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")
              0))
-          (value (match-string-no-properties substring-match))
+          (value (org-match-string-no-properties substring-match))
           (post-blank (progn (goto-char (match-end substring-match))
                              (skip-chars-forward " \t")))
           (end (point)))
@@ -2748,22 +3041,23 @@ Return a list whose CAR is `line-break', and CDR a plist with
 `:begin', `:end' and `:post-blank' keywords.
 
 Assume point is at the beginning of the line break."
-  (list 'line-break (list :begin (point) :end (point-at-eol) :post-blank 0)))
+  (list 'line-break
+       (list :begin (point)
+             :end (progn (forward-line) (point))
+             :post-blank 0)))
 
 (defun org-element-line-break-interpreter (line-break contents)
   "Interpret LINE-BREAK object as Org syntax.
 CONTENTS is nil."
-  "\\\\")
+  "\\\\\n")
 
-(defun org-element-line-break-successor (limit)
+(defun org-element-line-break-successor ()
   "Search for the next line-break object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `line-break' and CDR is
 beginning position."
   (save-excursion
-    (let ((beg (and (re-search-forward "[^\\\\]\\(\\\\\\\\\\)[ \t]*$" limit t)
+    (let ((beg (and (re-search-forward "[^\\\\]\\(\\\\\\\\\\)[ \t]*$" nil t)
                    (goto-char (match-beginning 1)))))
       ;; A line break can only happen on a non-empty line.
       (when (and beg (re-search-backward "\\S-" (point-at-bol) t))
@@ -2776,14 +3070,15 @@ beginning position."
   "Parse link at point.
 
 Return a list whose CAR is `link' and CDR a plist with `:type',
-`:path', `:raw-link', `:begin', `:end', `:contents-begin',
-`:contents-end' and `:post-blank' as keywords.
+`:path', `:raw-link', `:application', `:search-option', `:begin',
+`:end', `:contents-begin', `:contents-end' and `:post-blank' as
+keywords.
 
 Assume point is at the beginning of the link."
   (save-excursion
     (let ((begin (point))
          end contents-begin contents-end link-end post-blank path type
-         raw-link link)
+         raw-link link search-option application)
       (cond
        ;; Type 1: Text targeted from a radio target.
        ((and org-target-link-regexp (looking-at org-target-link-regexp))
@@ -2795,53 +3090,70 @@ Assume point is at the beginning of the link."
        (setq contents-begin (match-beginning 3)
              contents-end (match-end 3)
              link-end (match-end 0)
-             ;; RAW-LINK is the original link.
-             raw-link (org-match-string-no-properties 1)
-             link (org-translate-link
-                   (org-link-expand-abbrev
-                    (org-link-unescape raw-link))))
+             ;; RAW-LINK is the original link.  Expand any
+             ;; abbreviation in it.
+             raw-link (org-translate-link
+                       (org-link-expand-abbrev
+                        (org-match-string-no-properties 1))))
        ;; Determine TYPE of link and set PATH accordingly.
        (cond
         ;; File type.
-        ((or (file-name-absolute-p link) (string-match "^\\.\\.?/" link))
-         (setq type "file" path link))
+        ((or (file-name-absolute-p raw-link)
+             (string-match "^\\.\\.?/" raw-link))
+         (setq type "file" path raw-link))
         ;; Explicit type (http, irc, bbdb...).  See `org-link-types'.
-        ((string-match org-link-re-with-space3 link)
-         (setq type (match-string 1 link) path (match-string 2 link)))
+        ((string-match org-link-re-with-space3 raw-link)
+         (setq type (match-string 1 raw-link) path (match-string 2 raw-link)))
         ;; Id type: PATH is the id.
-        ((string-match "^id:\\([-a-f0-9]+\\)" link)
-         (setq type "id" path (match-string 1 link)))
+        ((string-match "^id:\\([-a-f0-9]+\\)" raw-link)
+         (setq type "id" path (match-string 1 raw-link)))
         ;; Code-ref type: PATH is the name of the reference.
-        ((string-match "^(\\(.*\\))$" link)
-         (setq type "coderef" path (match-string 1 link)))
+        ((string-match "^(\\(.*\\))$" raw-link)
+         (setq type "coderef" path (match-string 1 raw-link)))
         ;; Custom-id type: PATH is the name of the custom id.
-        ((= (aref link 0) ?#)
-         (setq type "custom-id" path (substring link 1)))
+        ((= (aref raw-link 0) ?#)
+         (setq type "custom-id" path (substring raw-link 1)))
         ;; Fuzzy type: Internal link either matches a target, an
         ;; headline name or nothing.  PATH is the target or
         ;; headline's name.
-        (t (setq type "fuzzy" path link))))
+        (t (setq type "fuzzy" path raw-link))))
        ;; Type 3: Plain link, i.e. http://orgmode.org
        ((looking-at org-plain-link-re)
        (setq raw-link (org-match-string-no-properties 0)
              type (org-match-string-no-properties 1)
-             path (org-match-string-no-properties 2)
-             link-end (match-end 0)))
+             link-end (match-end 0)
+             path (org-match-string-no-properties 2)))
        ;; Type 4: Angular link, i.e. <http://orgmode.org>
        ((looking-at org-angle-link-re)
        (setq raw-link (buffer-substring-no-properties
                        (match-beginning 1) (match-end 2))
              type (org-match-string-no-properties 1)
-             path (org-match-string-no-properties 2)
-             link-end (match-end 0))))
+             link-end (match-end 0)
+             path (org-match-string-no-properties 2))))
       ;; In any case, deduce end point after trailing white space from
       ;; LINK-END variable.
       (setq post-blank (progn (goto-char link-end) (skip-chars-forward " \t"))
            end (point))
+      ;; Extract search option and opening application out of
+      ;; "file"-type links.
+      (when (member type org-element-link-type-is-file)
+       ;; Application.
+       (cond ((string-match "^file\\+\\(.*\\)$" type)
+              (setq application (match-string 1 type)))
+             ((not (string-match "^file" type))
+              (setq application type)))
+       ;; Extract search option from PATH.
+       (when (string-match "::\\(.*\\)$" path)
+         (setq search-option (match-string 1 path)
+               path (replace-match "" nil nil path)))
+       ;; Make sure TYPE always reports "file".
+       (setq type "file"))
       (list 'link
            (list :type type
                  :path path
                  :raw-link (or raw-link path)
+                 :application application
+                 :search-option search-option
                  :begin begin
                  :end end
                  :contents-begin contents-begin
@@ -2858,20 +3170,26 @@ CONTENTS is the contents of the object, or nil."
              raw-link
              (if contents (format "[%s]" contents) "")))))
 
-(defun org-element-link-successor (limit)
+(defun org-element-link-successor ()
   "Search for the next link object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `link' and CDR is
 beginning position."
   (save-excursion
     (let ((link-regexp
           (if (not org-target-link-regexp) org-any-link-re
             (concat org-any-link-re "\\|" org-target-link-regexp))))
-      (when (re-search-forward link-regexp limit t)
+      (when (re-search-forward link-regexp nil t)
        (cons 'link (match-beginning 0))))))
 
+(defun org-element-plain-link-successor ()
+  "Search for the next plain link object.
+
+Return value is a cons cell whose CAR is `link' and CDR is
+beginning position."
+  (and (save-excursion (re-search-forward org-plain-link-re nil t))
+       (cons 'link (match-beginning 0))))
+
 
 ;;;; Macro
 
@@ -2891,20 +3209,19 @@ Assume point is at the macro."
          (post-blank (progn (goto-char (match-end 0))
                             (skip-chars-forward " \t")))
          (end (point))
-         (args (let ((args (org-match-string-no-properties 3)) args2)
+         (args (let ((args (org-match-string-no-properties 3)))
                  (when args
                    ;; Do not use `org-split-string' since empty
                    ;; strings are meaningful here.
-                   (setq args (split-string args ","))
-                   (while args
-                     (while (string-match "\\\\\\'" (car args))
-                       ;; Repair bad splits, when comma is protected,
-                        ;; and thus not a real separator.
-                       (setcar (cdr args) (concat (substring (car args) 0 -1)
-                                                  "," (nth 1 args)))
-                       (pop args))
-                     (push (pop args) args2))
-                   (mapcar 'org-trim (nreverse args2))))))
+                   (split-string
+                    (replace-regexp-in-string
+                     "\\(\\\\*\\)\\(,\\)"
+                     (lambda (str)
+                       (let ((len (length (match-string 1 str))))
+                         (concat (make-string (/ len 2) ?\\)
+                                 (if (zerop (mod len 2)) "\000" ","))))
+                     args nil t)
+                    "\000")))))
       (list 'macro
            (list :key key
                  :value value
@@ -2918,17 +3235,15 @@ Assume point is at the macro."
 CONTENTS is nil."
   (org-element-property :value macro))
 
-(defun org-element-macro-successor (limit)
+(defun org-element-macro-successor ()
   "Search for the next macro object.
 
-LIMIT bounds the search.
-
 Return value is cons cell whose CAR is `macro' and CDR is
 beginning position."
   (save-excursion
     (when (re-search-forward
           "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
-          limit t)
+          nil t)
       (cons 'macro (match-beginning 0)))))
 
 
@@ -2964,15 +3279,13 @@ Assume point is at the radio target."
 CONTENTS is the contents of the object."
   (concat "<<<" contents ">>>"))
 
-(defun org-element-radio-target-successor (limit)
+(defun org-element-radio-target-successor ()
   "Search for the next radio-target object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `radio-target' and CDR
 is beginning position."
   (save-excursion
-    (when (re-search-forward org-radio-target-regexp limit t)
+    (when (re-search-forward org-radio-target-regexp nil t)
       (cons 'radio-target (match-beginning 0)))))
 
 
@@ -3004,15 +3317,13 @@ Assume point is at the beginning of the statistics-cookie."
 CONTENTS is nil."
   (org-element-property :value statistics-cookie))
 
-(defun org-element-statistics-cookie-successor (limit)
+(defun org-element-statistics-cookie-successor ()
   "Search for the next statistics cookie object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `statistics-cookie' and
 CDR is beginning position."
   (save-excursion
-    (when (re-search-forward "\\[[0-9]*\\(%\\|/[0-9]*\\)\\]" limit t)
+    (when (re-search-forward "\\[[0-9]*\\(%\\|/[0-9]*\\)\\]" nil t)
       (cons 'statistics-cookie (match-beginning 0)))))
 
 
@@ -3085,16 +3396,14 @@ CONTENTS is the contents of the object."
    (if (org-element-property :use-brackets-p subscript) "_{%s}" "_%s")
    contents))
 
-(defun org-element-sub/superscript-successor  (limit)
+(defun org-element-sub/superscript-successor ()
   "Search for the next sub/superscript object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is either `subscript' or
 `superscript' and CDR is beginning position."
   (save-excursion
     (unless (bolp) (backward-char))
-    (when (re-search-forward org-match-substring-regexp limit t)
+    (when (re-search-forward org-match-substring-regexp nil t)
       (cons (if (string= (match-string 2) "_") 'subscript 'superscript)
            (match-beginning 2)))))
 
@@ -3161,14 +3470,12 @@ and `:post-blank' keywords."
 CONTENTS is the contents of the cell, or nil."
   (concat  " " contents " |"))
 
-(defun org-element-table-cell-successor (limit)
+(defun org-element-table-cell-successor ()
   "Search for the next table-cell object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `table-cell' and CDR is
 beginning position."
-  (when (looking-at "[ \t]*.*?[ \t]+|") (cons 'table-cell (point))))
+  (when (looking-at "[ \t]*.*?[ \t]*|") (cons 'table-cell (point))))
 
 
 ;;;; Target
@@ -3198,15 +3505,13 @@ Assume point is at the target."
 CONTENTS is nil."
   (format "<<%s>>" (org-element-property :value target)))
 
-(defun org-element-target-successor (limit)
+(defun org-element-target-successor ()
   "Search for the next target object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `target' and CDR is
 beginning position."
   (save-excursion
-    (when (re-search-forward org-target-regexp limit t)
+    (when (re-search-forward org-target-regexp nil t)
       (cons 'target (match-beginning 0)))))
 
 
@@ -3216,51 +3521,202 @@ beginning position."
   "Parse time stamp at point.
 
 Return a list whose CAR is `timestamp', and CDR a plist with
-`:type', `:begin', `:end', `:value' and `:post-blank' keywords.
+`:type', `:raw-value', `:year-start', `:month-start',
+`:day-start', `:hour-start', `:minute-start', `:year-end',
+`:month-end', `:day-end', `:hour-end', `:minute-end',
+`:repeater-type', `:repeater-value', `:repeater-unit',
+`:warning-type', `:warning-value', `:warning-unit', `:begin',
+`:end', `:value' and `:post-blank' keywords.
 
 Assume point is at the beginning of the timestamp."
   (save-excursion
     (let* ((begin (point))
           (activep (eq (char-after) ?<))
-          (main-value
+          (raw-value
            (progn
-             (looking-at "[<[]\\(\\(%%\\)?.*?\\)[]>]\\(?:--[<[]\\(.*?\\)[]>]\\)?")
-             (match-string-no-properties 1)))
-          (range-end (match-string-no-properties 3))
-          (type (cond ((match-string 2) 'diary)
-                      ((and activep range-end) 'active-range)
-                      (activep 'active)
-                      (range-end 'inactive-range)
-                      (t 'inactive)))
+             (looking-at "\\([<[]\\(%%\\)?.*?\\)[]>]\\(?:--\\([<[].*?[]>]\\)\\)?")
+             (match-string-no-properties 0)))
+          (date-start (match-string-no-properties 1))
+          (date-end (match-string 3))
+          (diaryp (match-beginning 2))
           (post-blank (progn (goto-char (match-end 0))
                              (skip-chars-forward " \t")))
-          (end (point)))
+          (end (point))
+          (time-range
+           (and (not diaryp)
+                (string-match
+                 "[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)"
+                 date-start)
+                (cons (string-to-number (match-string 2 date-start))
+                      (string-to-number (match-string 3 date-start)))))
+          (type (cond (diaryp 'diary)
+                      ((and activep (or date-end time-range)) 'active-range)
+                      (activep 'active)
+                      ((or date-end time-range) 'inactive-range)
+                      (t 'inactive)))
+          (repeater-props
+           (and (not diaryp)
+                (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
+                              raw-value)
+                (list
+                 :repeater-type
+                 (let ((type (match-string 1 raw-value)))
+                   (cond ((equal "++" type) 'catch-up)
+                         ((equal ".+" type) 'restart)
+                         (t 'cumulate)))
+                 :repeater-value (string-to-number (match-string 2 raw-value))
+                 :repeater-unit
+                 (case (string-to-char (match-string 3 raw-value))
+                   (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (t 'year)))))
+          (warning-props
+           (and (not diaryp)
+                (string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value)
+                (list
+                 :warning-type (if (match-string 1 raw-value) 'first 'all)
+                 :warning-value (string-to-number (match-string 2 raw-value))
+                 :warning-unit
+                 (case (string-to-char (match-string 3 raw-value))
+                   (?h 'hour) (?d 'day) (?w 'week) (?m 'month) (t 'year)))))
+          year-start month-start day-start hour-start minute-start year-end
+          month-end day-end hour-end minute-end)
+      ;; Parse date-start.
+      (unless diaryp
+       (let ((date (org-parse-time-string date-start t)))
+         (setq year-start (nth 5 date)
+               month-start (nth 4 date)
+               day-start (nth 3 date)
+               hour-start (nth 2 date)
+               minute-start (nth 1 date))))
+      ;; Compute date-end.  It can be provided directly in time-stamp,
+      ;; or extracted from time range.  Otherwise, it defaults to the
+      ;; same values as date-start.
+      (unless diaryp
+       (let ((date (and date-end (org-parse-time-string date-end t))))
+         (setq year-end (or (nth 5 date) year-start)
+               month-end (or (nth 4 date) month-start)
+               day-end (or (nth 3 date) day-start)
+               hour-end (or (nth 2 date) (car time-range) hour-start)
+               minute-end (or (nth 1 date) (cdr time-range) minute-start))))
       (list 'timestamp
-           (list :type type
-                 :value main-value
-                 :range-end range-end
-                 :begin begin
-                 :end end
-                 :post-blank post-blank)))))
+           (nconc (list :type type
+                        :raw-value raw-value
+                        :year-start year-start
+                        :month-start month-start
+                        :day-start day-start
+                        :hour-start hour-start
+                        :minute-start minute-start
+                        :year-end year-end
+                        :month-end month-end
+                        :day-end day-end
+                        :hour-end hour-end
+                        :minute-end minute-end
+                        :begin begin
+                        :end end
+                        :post-blank post-blank)
+                  repeater-props
+                  warning-props)))))
 
 (defun org-element-timestamp-interpreter (timestamp contents)
   "Interpret TIMESTAMP object as Org syntax.
 CONTENTS is nil."
-  (let ((type (org-element-property :type timestamp) ))
-    (concat
-     (format (if (memq type '(inactive inactive-range)) "[%s]" "<%s>")
-            (org-element-property :value timestamp))
-     (let ((range-end (org-element-property :range-end timestamp)))
-       (when range-end
-        (concat "--"
-                (format (if (eq type 'inactive-range) "[%s]" "<%s>")
-                        range-end)))))))
-
-(defun org-element-timestamp-successor (limit)
+  ;; Use `:raw-value' if specified.
+  (or (org-element-property :raw-value timestamp)
+      ;; Otherwise, build timestamp string.
+      (let* ((repeat-string
+             (concat
+              (case (org-element-property :repeater-type timestamp)
+                (cumulate "+") (catch-up "++") (restart ".+"))
+              (let ((val (org-element-property :repeater-value timestamp)))
+                (and val (number-to-string val)))
+              (case (org-element-property :repeater-unit timestamp)
+                (hour "h") (day "d") (week "w") (month "m") (year "y"))))
+            (warning-string
+             (concat
+              (case (org-element-property :warning-type timestamp)
+                (first "--")
+                (all "-"))
+              (let ((val (org-element-property :warning-value timestamp)))
+                (and val (number-to-string val)))
+              (case (org-element-property :warning-unit timestamp)
+                (hour "h") (day "d") (week "w") (month "m") (year "y"))))
+            (build-ts-string
+             ;; Build an Org timestamp string from TIME.  ACTIVEP is
+             ;; non-nil when time stamp is active.  If WITH-TIME-P is
+             ;; non-nil, add a time part.  HOUR-END and MINUTE-END
+             ;; specify a time range in the timestamp.  REPEAT-STRING
+             ;; is the repeater string, if any.
+             (lambda (time activep &optional with-time-p hour-end minute-end)
+               (let ((ts (format-time-string
+                          (funcall (if with-time-p 'cdr 'car)
+                                   org-time-stamp-formats)
+                          time)))
+                 (when (and hour-end minute-end)
+                   (string-match "[012]?[0-9]:[0-5][0-9]" ts)
+                   (setq ts
+                         (replace-match
+                          (format "\\&-%02d:%02d" hour-end minute-end)
+                          nil nil ts)))
+                 (unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
+                 (dolist (s (list repeat-string warning-string))
+                   (when (org-string-nw-p s)
+                     (setq ts (concat (substring ts 0 -1)
+                                      " "
+                                      s
+                                      (substring ts -1)))))
+                 ;; Return value.
+                 ts)))
+            (type (org-element-property :type timestamp)))
+       (case type
+         ((active inactive)
+          (let* ((minute-start (org-element-property :minute-start timestamp))
+                 (minute-end (org-element-property :minute-end timestamp))
+                 (hour-start (org-element-property :hour-start timestamp))
+                 (hour-end (org-element-property :hour-end timestamp))
+                 (time-range-p (and hour-start hour-end minute-start minute-end
+                                    (or (/= hour-start hour-end)
+                                        (/= minute-start minute-end)))))
+            (funcall
+             build-ts-string
+             (encode-time 0
+                          (or minute-start 0)
+                          (or hour-start 0)
+                          (org-element-property :day-start timestamp)
+                          (org-element-property :month-start timestamp)
+                          (org-element-property :year-start timestamp))
+             (eq type 'active)
+             (and hour-start minute-start)
+             (and time-range-p hour-end)
+             (and time-range-p minute-end))))
+         ((active-range inactive-range)
+          (let ((minute-start (org-element-property :minute-start timestamp))
+                (minute-end (org-element-property :minute-end timestamp))
+                (hour-start (org-element-property :hour-start timestamp))
+                (hour-end (org-element-property :hour-end timestamp)))
+            (concat
+             (funcall
+              build-ts-string (encode-time
+                               0
+                               (or minute-start 0)
+                               (or hour-start 0)
+                               (org-element-property :day-start timestamp)
+                               (org-element-property :month-start timestamp)
+                               (org-element-property :year-start timestamp))
+              (eq type 'active-range)
+              (and hour-start minute-start))
+             "--"
+             (funcall build-ts-string
+                      (encode-time 0
+                                   (or minute-end 0)
+                                   (or hour-end 0)
+                                   (org-element-property :day-end timestamp)
+                                   (org-element-property :month-end timestamp)
+                                   (org-element-property :year-end timestamp))
+                      (eq type 'active-range)
+                      (and hour-end minute-end)))))))))
+
+(defun org-element-timestamp-successor ()
   "Search for the next timestamp object.
 
-LIMIT bounds the search.
-
 Return value is a cons cell whose CAR is `timestamp' and CDR is
 beginning position."
   (save-excursion
@@ -3270,7 +3726,7 @@ beginning position."
                   "\\(?:<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
                   "\\|"
                   "\\(?:<%%\\(?:([^>\n]+)\\)>\\)")
-          limit t)
+          nil t)
       (cons 'timestamp (match-beginning 0)))))
 
 
@@ -3345,21 +3801,21 @@ CONTENTS is nil."
 ;; `org-element--current-element' makes use of special modes.  They
 ;; are activated for fixed element chaining (i.e. `plain-list' >
 ;; `item') or fixed conditional element chaining (i.e. `headline' >
-;; `section'). Special modes are: `first-section', `section',
-;; `quote-section', `item' and `table-row'.
+;; `section').  Special modes are: `first-section', `item',
+;; `node-property', `quote-section', `section' and `table-row'.
 
 (defun org-element--current-element
   (limit &optional granularity special structure)
   "Parse the element starting at point.
 
-LIMIT bounds the search.
-
 Return value is a list like (TYPE PROPS) where TYPE is the type
 of the element and PROPS a plist of properties associated to the
 element.
 
 Possible types are defined in `org-element-all-elements'.
 
+LIMIT bounds the search.
+
 Optional argument GRANULARITY determines the depth of the
 recursion.  Allowed values are `headline', `greater-element',
 `element', `object' or nil.  When it is broader than `object' (or
@@ -3367,8 +3823,8 @@ nil), secondary values will not be parsed, since they only
 contain objects.
 
 Optional argument SPECIAL, when non-nil, can be either
-`first-section', `section', `quote-section', `table-row' and
-`item'.
+`first-section', `item', `node-property', `quote-section',
+`section', and `table-row'.
 
 If STRUCTURE isn't provided but SPECIAL is set to `item', it will
 be computed.
@@ -3376,13 +3832,6 @@ be computed.
 This function assumes point is always at the beginning of the
 element it has to parse."
   (save-excursion
-    ;; If point is at an affiliated keyword, try moving to the
-    ;; beginning of the associated element.  If none is found, the
-    ;; keyword is orphaned and will be treated as plain text.
-    (when (looking-at org-element--affiliated-re)
-      (let ((opoint (point)))
-        (while (looking-at org-element--affiliated-re) (forward-line))
-        (when (looking-at "[ \t]*$") (goto-char opoint))))
     (let ((case-fold-search t)
          ;; Determine if parsing depth allows for secondary strings
          ;; parsing.  It only applies to elements referenced in
@@ -3394,6 +3843,8 @@ element it has to parse."
        (org-element-item-parser limit structure raw-secondary-p))
        ;; Table Row.
        ((eq special 'table-row) (org-element-table-row-parser limit))
+       ;; Node Property.
+       ((eq special 'node-property) (org-element-node-property-parser limit))
        ;; Headline.
        ((org-with-limited-levels (org-at-heading-p))
         (org-element-headline-parser limit raw-secondary-p))
@@ -3406,180 +3857,146 @@ element it has to parse."
             limit)))
        ;; When not at bol, point is at the beginning of an item or
        ;; a footnote definition: next item is always a paragraph.
-       ((not (bolp)) (org-element-paragraph-parser limit))
+       ((not (bolp)) (org-element-paragraph-parser limit (list (point))))
        ;; Planning and Clock.
-       ((and (looking-at org-planning-or-clock-line-re))
+       ((looking-at org-planning-or-clock-line-re)
        (if (equal (match-string 1) org-clock-string)
            (org-element-clock-parser limit)
          (org-element-planning-parser limit)))
        ;; Inlinetask.
        ((org-at-heading-p)
        (org-element-inlinetask-parser limit raw-secondary-p))
-       ;; LaTeX Environment.
-       ((looking-at "[ \t]*\\\\begin{\\([A-Za-z0-9*]+\\)}")
-        (if (save-excursion
-              (re-search-forward
-              (format "[ \t]*\\\\end{%s}[ \t]*"
-                      (regexp-quote (match-string 1)))
-              nil t))
-            (org-element-latex-environment-parser limit)
-          (org-element-paragraph-parser limit)))
-       ;; Drawer and Property Drawer.
-       ((looking-at org-drawer-regexp)
-        (let ((name (match-string 1)))
-         (cond
-          ((not (save-excursion
-                  (re-search-forward "^[ \t]*:END:[ \t]*$" nil t)))
-           (org-element-paragraph-parser limit))
-          ((equal "PROPERTIES" name)
-           (org-element-property-drawer-parser limit))
-          (t (org-element-drawer-parser limit)))))
-       ;; Fixed Width
-       ((looking-at "[ \t]*:\\( \\|$\\)")
-       (org-element-fixed-width-parser limit))
-       ;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
-       ;; Keywords.
-       ((looking-at "[ \t]*#")
-       (goto-char (match-end 0))
-       (cond ((looking-at "\\(?: \\|$\\)")
-              (beginning-of-line)
-              (org-element-comment-parser limit))
-             ((looking-at "\\+BEGIN_\\(\\S-+\\)")
-              (beginning-of-line)
-              (let ((parser (assoc (upcase (match-string 1))
-                                   org-element-block-name-alist)))
-                (if parser (funcall (cdr parser) limit)
-                  (org-element-special-block-parser limit))))
-             ((looking-at "\\+CALL:")
-              (beginning-of-line)
-              (org-element-babel-call-parser limit))
-             ((looking-at "\\+BEGIN:? ")
-              (beginning-of-line)
-              (org-element-dynamic-block-parser limit))
-             ((looking-at "\\+\\S-+:")
-              (beginning-of-line)
-              (org-element-keyword-parser limit))
-             (t
-              (beginning-of-line)
-              (org-element-paragraph-parser limit))))
-       ;; Footnote Definition.
-       ((looking-at org-footnote-definition-re)
-        (org-element-footnote-definition-parser limit))
-       ;; Horizontal Rule.
-       ((looking-at "[ \t]*-\\{5,\\}[ \t]*$")
-        (org-element-horizontal-rule-parser limit))
-       ;; Table.
-       ((org-at-table-p t) (org-element-table-parser limit))
-       ;; List.
-       ((looking-at (org-item-re))
-        (org-element-plain-list-parser limit (or structure (org-list-struct))))
-       ;; Default element: Paragraph.
-       (t (org-element-paragraph-parser limit))))))
+       ;; From there, elements can have affiliated keywords.
+       (t (let ((affiliated (org-element--collect-affiliated-keywords limit)))
+           (cond
+            ;; Jumping over affiliated keywords put point off-limits.
+            ;; Parse them as regular keywords.
+            ((and (cdr affiliated) (>= (point) limit))
+             (goto-char (car affiliated))
+             (org-element-keyword-parser limit nil))
+            ;; LaTeX Environment.
+            ((looking-at
+              "[ \t]*\\\\begin{[A-Za-z0-9*]+}\\(\\[.*?\\]\\|{.*?}\\)*[ \t]*$")
+             (org-element-latex-environment-parser limit affiliated))
+            ;; Drawer and Property Drawer.
+            ((looking-at org-drawer-regexp)
+             (if (equal (match-string 1) "PROPERTIES")
+                 (org-element-property-drawer-parser limit affiliated)
+               (org-element-drawer-parser limit affiliated)))
+            ;; Fixed Width
+            ((looking-at "[ \t]*:\\( \\|$\\)")
+             (org-element-fixed-width-parser limit affiliated))
+            ;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
+            ;; Keywords.
+            ((looking-at "[ \t]*#")
+             (goto-char (match-end 0))
+             (cond ((looking-at "\\(?: \\|$\\)")
+                    (beginning-of-line)
+                    (org-element-comment-parser limit affiliated))
+                   ((looking-at "\\+BEGIN_\\(\\S-+\\)")
+                    (beginning-of-line)
+                    (let ((parser (assoc (upcase (match-string 1))
+                                         org-element-block-name-alist)))
+                      (if parser (funcall (cdr parser) limit affiliated)
+                        (org-element-special-block-parser limit affiliated))))
+                   ((looking-at "\\+CALL:")
+                    (beginning-of-line)
+                    (org-element-babel-call-parser limit affiliated))
+                   ((looking-at "\\+BEGIN:? ")
+                    (beginning-of-line)
+                    (org-element-dynamic-block-parser limit affiliated))
+                   ((looking-at "\\+\\S-+:")
+                    (beginning-of-line)
+                    (org-element-keyword-parser limit affiliated))
+                   (t
+                    (beginning-of-line)
+                    (org-element-paragraph-parser limit affiliated))))
+            ;; Footnote Definition.
+            ((looking-at org-footnote-definition-re)
+             (org-element-footnote-definition-parser limit affiliated))
+            ;; Horizontal Rule.
+            ((looking-at "[ \t]*-\\{5,\\}[ \t]*$")
+             (org-element-horizontal-rule-parser limit affiliated))
+            ;; Diary Sexp.
+            ((looking-at "%%(")
+             (org-element-diary-sexp-parser limit affiliated))
+            ;; Table.
+            ((org-at-table-p t) (org-element-table-parser limit affiliated))
+            ;; List.
+            ((looking-at (org-item-re))
+             (org-element-plain-list-parser
+              limit affiliated
+              (or structure (org-element--list-struct limit))))
+            ;; Default element: Paragraph.
+            (t (org-element-paragraph-parser limit affiliated)))))))))
 
 
 ;; Most elements can have affiliated keywords.  When looking for an
 ;; element beginning, we want to move before them, as they belong to
 ;; that element, and, in the meantime, collect information they give
 ;; into appropriate properties.  Hence the following function.
-;;
-;; Usage of optional arguments may not be obvious at first glance:
-;;
-;; - TRANS-LIST is used to polish keywords names that have evolved
-;;   during Org history.  In example, even though =result= and
-;;   =results= coexist, we want to have them under the same =result=
-;;   property.  It's also true for "srcname" and "name", where the
-;;   latter seems to be preferred nowadays (thus the "name" property).
-;;
-;; - CONSED allows to regroup multi-lines keywords under the same
-;;   property, while preserving their own identity.  This is mostly
-;;   used for "attr_latex" and al.
-;;
-;; - PARSED prepares a keyword value for export.  This is useful for
-;;   "caption".  Objects restrictions for such keywords are defined in
-;;   `org-element-object-restrictions'.
-;;
-;; - DUALS is used to take care of keywords accepting a main and an
-;;   optional secondary values.  For example "results" has its
-;;   source's name as the main value, and may have an hash string in
-;;   optional square brackets as the secondary one.
-;;
-;; A keyword may belong to more than one category.
-
-(defun org-element--collect-affiliated-keywords
-  (&optional key-re trans-list consed parsed duals)
-  "Collect affiliated keywords before point.
-
-Optional argument KEY-RE is a regexp matching keywords, which
-puts matched keyword in group 1.  It defaults to
-`org-element--affiliated-re'.
-
-TRANS-LIST is an alist where key is the keyword and value the
-property name it should be translated to, without the colons.  It
-defaults to `org-element-keyword-translation-alist'.
-
-CONSED is a list of strings.  Any keyword belonging to that list
-will have its value consed.  The check is done after keyword
-translation.  It defaults to `org-element-multiple-keywords'.
-
-PARSED is a list of strings.  Any keyword member of this list
-will have its value parsed.  The check is done after keyword
-translation.  If a keyword is a member of both CONSED and PARSED,
-it's value will be a list of parsed strings.  It defaults to
-`org-element-parsed-keywords'.
 
-DUALS is a list of strings.  Any keyword member of this list can
-have two parts: one mandatory and one optional.  Its value is
-a cons cell whose CAR is the former, and the CDR the latter.  If
-a keyword is a member of both PARSED and DUALS, both values will
-be parsed.  It defaults to `org-element-dual-keywords'.
+(defun org-element--collect-affiliated-keywords (limit)
+  "Collect affiliated keywords from point down to LIMIT.
 
 Return a list whose CAR is the position at the first of them and
-CDR a plist of keywords and values."
-  (save-excursion
+CDR a plist of keywords and values and move point to the
+beginning of the first line after them.
+
+As a special case, if element doesn't start at the beginning of
+the line (i.e. a paragraph starting an item), CAR is current
+position of point and CDR is nil."
+  (if (not (bolp)) (list (point))
     (let ((case-fold-search t)
-         (key-re (or key-re org-element--affiliated-re))
-         (trans-list (or trans-list org-element-keyword-translation-alist))
-         (consed (or consed org-element-multiple-keywords))
-         (parsed (or parsed org-element-parsed-keywords))
-         (duals (or duals org-element-dual-keywords))
+         (origin (point))
          ;; RESTRICT is the list of objects allowed in parsed
          ;; keywords value.
          (restrict (org-element-restriction 'keyword))
          output)
-      (unless (bobp)
-       (while (and (not (bobp)) (progn (forward-line -1) (looking-at key-re)))
-         (let* ((raw-kwd (upcase (match-string 1)))
-                ;; Apply translation to RAW-KWD.  From there, KWD is
-                ;; the official keyword.
-                (kwd (or (cdr (assoc raw-kwd trans-list)) raw-kwd))
-                ;; Find main value for any keyword.
-                (value
-                 (save-match-data
-                   (org-trim
-                    (buffer-substring-no-properties
-                     (match-end 0) (point-at-eol)))))
-                ;; If KWD is a dual keyword, find its secondary
-                ;; value.  Maybe parse it.
-                (dual-value
-                 (and (member kwd duals)
-                      (let ((sec (org-match-string-no-properties 2)))
-                        (if (or (not sec) (not (member kwd parsed))) sec
-                          (org-element-parse-secondary-string sec restrict)))))
-                ;; Attribute a property name to KWD.
-                (kwd-sym (and kwd (intern (concat ":" (downcase kwd))))))
-           ;; Now set final shape for VALUE.
-           (when (member kwd parsed)
-             (setq value (org-element-parse-secondary-string value restrict)))
-           (when (member kwd duals)
-             ;; VALUE is mandatory.  Set it to nil if there is none.
-             (setq value (and value (cons value dual-value))))
-           ;; Attributes are always consed.
-           (when (or (member kwd consed) (string-match "^ATTR_" kwd))
-             (setq value (cons value (plist-get output kwd-sym))))
-           ;; Eventually store the new value in OUTPUT.
-           (setq output (plist-put output kwd-sym value))))
-       (unless (looking-at key-re) (forward-line 1)))
-      (list (point) output))))
+      (while (and (< (point) limit) (looking-at org-element--affiliated-re))
+       (let* ((raw-kwd (upcase (match-string 1)))
+              ;; Apply translation to RAW-KWD.  From there, KWD is
+              ;; the official keyword.
+              (kwd (or (cdr (assoc raw-kwd
+                                   org-element-keyword-translation-alist))
+                       raw-kwd))
+              ;; Find main value for any keyword.
+              (value
+               (save-match-data
+                 (org-trim
+                  (buffer-substring-no-properties
+                   (match-end 0) (point-at-eol)))))
+              ;; PARSEDP is non-nil when keyword should have its
+              ;; value parsed.
+              (parsedp (member kwd org-element-parsed-keywords))
+              ;; If KWD is a dual keyword, find its secondary
+              ;; value.  Maybe parse it.
+              (dualp (member kwd org-element-dual-keywords))
+              (dual-value
+               (and dualp
+                    (let ((sec (org-match-string-no-properties 2)))
+                      (if (or (not sec) (not parsedp)) sec
+                        (org-element-parse-secondary-string sec restrict)))))
+              ;; Attribute a property name to KWD.
+              (kwd-sym (and kwd (intern (concat ":" (downcase kwd))))))
+         ;; Now set final shape for VALUE.
+         (when parsedp
+           (setq value (org-element-parse-secondary-string value restrict)))
+         (when dualp
+           (setq value (and (or value dual-value) (cons value dual-value))))
+         (when (or (member kwd org-element-multiple-keywords)
+                   ;; Attributes can always appear on multiple lines.
+                   (string-match "^ATTR_" kwd))
+           (setq value (cons value (plist-get output kwd-sym))))
+         ;; Eventually store the new value in OUTPUT.
+         (setq output (plist-put output kwd-sym value))
+         ;; Move to next keyword.
+         (forward-line)))
+      ;; If affiliated keywords are orphaned: move back to first one.
+      ;; They will be parsed as a paragraph.
+      (when (looking-at "[ \t]*$") (goto-char origin) (setq output nil))
+      ;; Return value.
+      (cons origin output))))
 
 
 \f
@@ -3658,19 +4075,30 @@ looked after.
 Optional argument PARENT, when non-nil, is the element or object
 containing the secondary string.  It is used to set correctly
 `:parent' property within the string."
-  (with-temp-buffer
-    (insert string)
-    (let ((secondary (org-element--parse-objects
-                     (point-min) (point-max) nil restriction)))
-      (mapc (lambda (obj) (org-element-put-property obj :parent parent))
-           secondary))))
-
-(defun org-element-map (data types fun &optional info first-match no-recursion)
+  ;; Copy buffer-local variables listed in
+  ;; `org-element-object-variables' into temporary buffer.  This is
+  ;; required since object parsing is dependent on these variables.
+  (let ((pairs (delq nil (mapcar (lambda (var)
+                                  (when (boundp var)
+                                    (cons var (symbol-value var))))
+                                org-element-object-variables))))
+    (with-temp-buffer
+      (mapc (lambda (pair) (org-set-local (car pair) (cdr pair))) pairs)
+      (insert string)
+      (let ((secondary (org-element--parse-objects
+                       (point-min) (point-max) nil restriction)))
+       (when parent
+         (mapc (lambda (obj) (org-element-put-property obj :parent parent))
+               secondary))
+       secondary))))
+
+(defun org-element-map
+  (data types fun &optional info first-match no-recursion with-affiliated)
   "Map a function on selected elements or objects.
 
-DATA is an Org buffer parse tree, as returned by, i.e.,
-`org-element-parse-buffer'.  TYPES is a symbol or list of symbols
-of elements or objects types (see `org-element-all-elements' and
+DATA is a parse tree, an element, an object, a string, or a list
+of such constructs.  TYPES is a symbol or list of symbols of
+elements or objects types (see `org-element-all-elements' and
 `org-element-all-objects' for a complete list of types).  FUN is
 the function called on the matching element or object.  It has to
 accept one argument: the element or object itself.
@@ -3687,11 +4115,15 @@ representing elements or objects types.  `org-element-map' won't
 enter any recursive element or object whose type belongs to that
 list.  Though, FUN can still be applied on them.
 
+When optional argument WITH-AFFILIATED is non-nil, FUN will also
+apply to matching objects within parsed affiliated keywords (see
+`org-element-parsed-keywords').
+
 Nil values returned from FUN do not appear in the results.
 
 
 Examples:
---------
+---------
 
 Assuming TREE is a variable containing an Org buffer parse tree,
 the following example will return a flat list of all `src-block'
@@ -3702,22 +4134,26 @@ and `example-block' elements in it:
 The following snippet will find the first headline with a level
 of 1 and a \"phone\" tag, and will return its beginning position:
 
-  \(org-element-map
-   tree 'headline
+  \(org-element-map tree 'headline
    \(lambda (hl)
      \(and (= (org-element-property :level hl) 1)
           \(member \"phone\" (org-element-property :tags hl))
           \(org-element-property :begin hl)))
    nil t)
 
-Eventually, this last example will return a flat list of all
-`bold' type objects containing a `latex-snippet' type object:
+The next example will return a flat list of all `plain-list' type
+elements in TREE that are not a sub-list themselves:
+
+  \(org-element-map tree 'plain-list 'identity nil nil 'plain-list)
+
+Eventually, this example will return a flat list of all `bold'
+type objects containing a `latex-snippet' type object, even
+looking into captions:
 
-  \(org-element-map
-   tree 'bold
+  \(org-element-map tree 'bold
    \(lambda (b)
-     \(and (org-element-map b 'latex-snippet 'identity nil t)
-          b)))"
+     \(and (org-element-map b 'latex-snippet 'identity nil t) b))
+   nil nil nil t)"
   ;; Ensure TYPES and NO-RECURSION are a list, even of one element.
   (unless (listp types) (setq types (list types)))
   (unless (listp no-recursion) (setq no-recursion (list no-recursion)))
@@ -3739,6 +4175,12 @@ Eventually, this last example will return a flat list of all
                                  (setq category 'elements)))))
                    types)
              category)))
+        ;; Compute properties for affiliated keywords if necessary.
+        (--affiliated-alist
+         (and with-affiliated
+              (mapcar (lambda (kwd)
+                        (cons kwd (intern (concat ":" (downcase kwd)))))
+                      org-element-affiliated-keywords)))
         --acc
         --walk-tree
         (--walk-tree
@@ -3751,9 +4193,8 @@ Eventually, this last example will return a flat list of all
                ((not --data))
                ;; Ignored element in an export context.
                ((and info (memq --data (plist-get info :ignore-list))))
-               ;; Secondary string: only objects can be found there.
-               ((not --type)
-                (when (eq --category 'objects) (mapc --walk-tree --data)))
+               ;; List of elements or objects.
+               ((not --type) (mapc --walk-tree --data))
                ;; Unconditionally enter parse trees.
                ((eq --type 'org-data)
                 (mapc --walk-tree (org-element-contents --data)))
@@ -3768,12 +4209,40 @@ Eventually, this last example will return a flat list of all
                           (t (push result --acc)))))
                 ;; If --DATA has a secondary string that can contain
                 ;; objects with their type among TYPES, look into it.
-                (when (eq --category 'objects)
+                (when (and (eq --category 'objects) (not (stringp --data)))
                   (let ((sec-prop
                          (assq --type org-element-secondary-value-alist)))
                     (when sec-prop
                       (funcall --walk-tree
                                (org-element-property (cdr sec-prop) --data)))))
+                ;; If --DATA has any affiliated keywords and
+                ;; WITH-AFFILIATED is non-nil, look for objects in
+                ;; them.
+                (when (and with-affiliated
+                           (eq --category 'objects)
+                           (memq --type org-element-all-elements))
+                  (mapc (lambda (kwd-pair)
+                          (let ((kwd (car kwd-pair))
+                                (value (org-element-property
+                                        (cdr kwd-pair) --data)))
+                            ;; Pay attention to the type of value.
+                            ;; Preserve order for multiple keywords.
+                            (cond
+                             ((not value))
+                             ((and (member kwd org-element-multiple-keywords)
+                                   (member kwd org-element-dual-keywords))
+                              (mapc (lambda (line)
+                                      (funcall --walk-tree (cdr line))
+                                      (funcall --walk-tree (car line)))
+                                    (reverse value)))
+                             ((member kwd org-element-multiple-keywords)
+                              (mapc (lambda (line) (funcall --walk-tree line))
+                                    (reverse value)))
+                             ((member kwd org-element-dual-keywords)
+                              (funcall --walk-tree (cdr value))
+                              (funcall --walk-tree (car value)))
+                             (t (funcall --walk-tree value)))))
+                        --affiliated-alist))
                 ;; Determine if a recursion into --DATA is possible.
                 (cond
                  ;; --TYPE is explicitly removed from recursion.
@@ -3793,6 +4262,7 @@ Eventually, this last example will return a flat list of all
       (funcall --walk-tree data)
       ;; Return value in a proper order.
       (nreverse --acc))))
+(put 'org-element-map 'lisp-indent-function 2)
 
 ;; The following functions are internal parts of the parser.
 ;;
@@ -3831,6 +4301,10 @@ elements.
 Elements are accumulated into ACC."
   (save-excursion
     (goto-char beg)
+    ;; Visible only: skip invisible parts at the beginning of the
+    ;; element.
+    (when (and visible-only (org-invisible-p2))
+      (goto-char (min (1+ (org-find-visible)) end)))
     ;; When parsing only headlines, skip any text before first one.
     (when (and (eq granularity 'headline) (not (org-at-heading-p)))
       (org-with-limited-levels (outline-next-heading)))
@@ -3843,15 +4317,16 @@ Elements are accumulated into ACC."
             (type (org-element-type element))
             (cbeg (org-element-property :contents-begin element)))
        (goto-char (org-element-property :end element))
+       ;; Visible only: skip invisible parts between siblings.
+       (when (and visible-only (org-invisible-p2))
+         (goto-char (min (1+ (org-find-visible)) end)))
        ;; Fill ELEMENT contents by side-effect.
        (cond
-        ;; If VISIBLE-ONLY is true and element is hidden or if it has
-        ;; no contents, don't modify it.
-        ((or (and visible-only (org-element-property :hiddenp element))
-             (not cbeg)))
+        ;; If element has no contents, don't modify it.
+        ((not cbeg))
         ;; Greater element: parse it between `contents-begin' and
         ;; `contents-end'.  Make sure GRANULARITY allows the
-        ;; recursion, or ELEMENT is an headline, in which case going
+        ;; recursion, or ELEMENT is a headline, in which case going
         ;; inside is mandatory, in order to get sub-level headings.
         ((and (memq type org-element-greater-elements)
               (or (memq granularity '(element object nil))
@@ -3866,6 +4341,7 @@ Elements are accumulated into ACC."
              (if (org-element-property :quotedp element) 'quote-section
                'section))
             (plain-list 'item)
+            (property-drawer 'node-property)
             (table 'table-row))
           (and (memq type '(item plain-list))
                (org-element-property :structure element))
@@ -3885,98 +4361,87 @@ Elements are accumulated into ACC."
 
 Objects are accumulated in ACC.
 
-RESTRICTION is a list of object types which are allowed in the
-current object."
-  (let (candidates)
+RESTRICTION is a list of object successors which are allowed in
+the current object."
+  (let ((candidates 'initial))
     (save-excursion
-      (goto-char beg)
-      (while (and (< (point) end)
-                 (setq candidates (org-element--get-next-object-candidates
-                                   end restriction candidates)))
-       (let ((next-object
-              (let ((pos (apply 'min (mapcar 'cdr candidates))))
-                (save-excursion
-                  (goto-char pos)
-                  (funcall (intern (format "org-element-%s-parser"
-                                           (car (rassq pos candidates)))))))))
-         ;; 1. Text before any object.  Untabify it.
-         (let ((obj-beg (org-element-property :begin next-object)))
-           (unless (= (point) obj-beg)
-             (setq acc
-                   (org-element-adopt-elements
-                    acc
-                    (replace-regexp-in-string
-                     "\t" (make-string tab-width ? )
-                     (buffer-substring-no-properties (point) obj-beg))))))
-         ;; 2. Object...
-         (let ((obj-end (org-element-property :end next-object))
-               (cont-beg (org-element-property :contents-begin next-object)))
-           ;; Fill contents of NEXT-OBJECT by side-effect, if it has
-           ;; a recursive type.
-           (when (and cont-beg
-                      (memq (car next-object) org-element-recursive-objects))
-             (save-restriction
-               (narrow-to-region
-                cont-beg
-                (org-element-property :contents-end next-object))
+      (save-restriction
+       (narrow-to-region beg end)
+       (goto-char (point-min))
+       (while (and (not (eobp))
+                   (setq candidates
+                         (org-element--get-next-object-candidates
+                          restriction candidates)))
+         (let ((next-object
+                (let ((pos (apply 'min (mapcar 'cdr candidates))))
+                  (save-excursion
+                    (goto-char pos)
+                    (funcall (intern (format "org-element-%s-parser"
+                                             (car (rassq pos candidates)))))))))
+           ;; 1. Text before any object.  Untabify it.
+           (let ((obj-beg (org-element-property :begin next-object)))
+             (unless (= (point) obj-beg)
+               (setq acc
+                     (org-element-adopt-elements
+                      acc
+                      (replace-regexp-in-string
+                       "\t" (make-string tab-width ? )
+                       (buffer-substring-no-properties (point) obj-beg))))))
+           ;; 2. Object...
+           (let ((obj-end (org-element-property :end next-object))
+                 (cont-beg (org-element-property :contents-begin next-object)))
+             ;; Fill contents of NEXT-OBJECT by side-effect, if it has
+             ;; a recursive type.
+             (when (and cont-beg
+                        (memq (car next-object) org-element-recursive-objects))
                (org-element--parse-objects
-                (point-min) (point-max) next-object
-                (org-element-restriction next-object))))
-           (setq acc (org-element-adopt-elements acc next-object))
-           (goto-char obj-end))))
-      ;; 3. Text after last object.  Untabify it.
-      (unless (= (point) end)
-       (setq acc
-             (org-element-adopt-elements
-              acc
-              (replace-regexp-in-string
-               "\t" (make-string tab-width ? )
-               (buffer-substring-no-properties (point) end)))))
-      ;; Result.
-      acc)))
-
-(defun org-element--get-next-object-candidates (limit restriction objects)
+                cont-beg (org-element-property :contents-end next-object)
+                next-object (org-element-restriction next-object)))
+             (setq acc (org-element-adopt-elements acc next-object))
+             (goto-char obj-end))))
+       ;; 3. Text after last object.  Untabify it.
+       (unless (eobp)
+         (setq acc
+               (org-element-adopt-elements
+                acc
+                (replace-regexp-in-string
+                 "\t" (make-string tab-width ? )
+                 (buffer-substring-no-properties (point) end)))))
+       ;; Result.
+       acc))))
+
+(defun org-element--get-next-object-candidates (restriction objects)
   "Return an alist of candidates for the next object.
 
-LIMIT bounds the search, and RESTRICTION narrows candidates to
-some object types.
-
-Return value is an alist whose CAR is position and CDR the object
-type, as a symbol.
-
-OBJECTS is the previous candidates alist."
-  ;; Filter out any object found but not belonging to RESTRICTION.
-  (setq objects
-       (org-remove-if-not
-        (lambda (obj)
-          (let ((type (car obj)))
-            (memq (or (cdr (assq type org-element-object-successor-alist))
-                      type)
-                  restriction)))
-        objects))
-  (let (next-candidates types-to-search)
-    ;; If no previous result, search every object type in RESTRICTION.
-    ;; Otherwise, keep potential candidates (old objects located after
-    ;; point) and ask to search again those which had matched before.
-    (if (not objects) (setq types-to-search restriction)
-      (mapc (lambda (obj)
-             (if (< (cdr obj) (point)) (push (car obj) types-to-search)
-               (push obj next-candidates)))
-           objects))
-    ;; Call the appropriate successor function for each type to search
-    ;; and accumulate matches.
-    (mapc
-     (lambda (type)
-       (let* ((successor-fun
-              (intern
-               (format "org-element-%s-successor"
-                       (or (cdr (assq type org-element-object-successor-alist))
-                           type))))
-             (obj (funcall successor-fun limit)))
-        (and obj (push obj next-candidates))))
-     types-to-search)
-    ;; Return alist.
-    next-candidates))
+RESTRICTION is a list of object types, as symbols.  Only
+candidates with such types are looked after.
+
+OBJECTS is the previous candidates alist.  If it is set to
+`initial', no search has been done before, and all symbols in
+RESTRICTION should be looked after.
+
+Return value is an alist whose CAR is the object type and CDR its
+beginning position."
+  (delq
+   nil
+   (if (eq objects 'initial)
+       ;; When searching for the first time, look for every successor
+       ;; allowed in RESTRICTION.
+       (mapcar
+       (lambda (res)
+         (funcall (intern (format "org-element-%s-successor" res))))
+       restriction)
+     ;; Focus on objects returned during last search.  Keep those
+     ;; still after point.  Search again objects before it.
+     (mapcar
+      (lambda (obj)
+       (if (>= (cdr obj) (point)) obj
+         (let* ((type (car obj))
+                (succ (or (cdr (assq type org-element-object-successor-alist))
+                          type)))
+           (and succ
+                (funcall (intern (format "org-element-%s-successor" succ)))))))
+      objects))))
 
 
 \f
@@ -4014,8 +4479,8 @@ Return Org syntax as a string."
            (mapconcat
             (lambda (obj) (org-element-interpret-data obj parent))
             (org-element-contents data) ""))
-          ;; Plain text.
-          ((stringp data) data)
+          ;; Plain text: remove `:parent' text property from output.
+          ((stringp data) (org-no-properties data))
           ;; Element/Object without contents.
           ((not (org-element-contents data))
            (funcall (intern (format "org-element-%s-interpreter" type))
@@ -4083,7 +4548,7 @@ If there is no affiliated keyword, return the empty string."
                   ;; All attribute keywords can have multiple lines.
                   (string-match "^ATTR_" keyword))
               (mapconcat (lambda (line) (funcall keyword-to-org keyword line))
-                         value
+                         (reverse value)
                          "")
             (funcall keyword-to-org keyword value)))))
      ;; List all ELEMENT's properties matching an attribute line or an
@@ -4242,7 +4707,7 @@ is always the element at point.  The following positions contain
 element's siblings, then parents, siblings of parents, until the
 first element of current section."
   (org-with-wide-buffer
-   ;; If at an headline, parse it.  It is the sole element that
+   ;; If at a headline, parse it.  It is the sole element that
    ;; doesn't require to know about context.  Be sure to disallow
    ;; secondary string parsing, though.
    (if (org-with-limited-levels (org-at-heading-p))
@@ -4252,27 +4717,41 @@ first element of current section."
           (list (org-element-headline-parser (point-max) t))))
      ;; Otherwise move at the beginning of the section containing
      ;; point.
-     (let ((origin (point))
-          (end (save-excursion
-                 (org-with-limited-levels (outline-next-heading)) (point)))
-          element type special-flag trail struct prevs parent)
-       (org-with-limited-levels
-       (if (org-with-limited-levels (org-before-first-heading-p))
-           (goto-char (point-min))
-         (org-back-to-heading)
-         (forward-line)))
-       (org-skip-whitespace)
-       (beginning-of-line)
-       ;; Parse successively each element, skipping those ending
-       ;; before original position.
-       (catch 'exit
-         (while t
-           (setq element
+     (catch 'exit
+       (let ((origin (point))
+            (end (save-excursion
+                   (org-with-limited-levels (outline-next-heading)) (point)))
+            element type special-flag trail struct prevs parent)
+        (org-with-limited-levels
+         (if (org-before-first-heading-p)
+             ;; In empty lines at buffer's beginning, return nil.
+             (progn (goto-char (point-min))
+                    (org-skip-whitespace)
+                    (when (or (eobp) (> (line-beginning-position) origin))
+                      (throw 'exit nil)))
+           (org-back-to-heading)
+           (forward-line)
+           (org-skip-whitespace)
+           (when (or (eobp) (> (line-beginning-position) origin))
+             ;; In blank lines just after the headline, point still
+             ;; belongs to the headline.
+             (throw 'exit
+                    (progn (skip-chars-backward " \r\t\n")
+                           (beginning-of-line)
+                           (if (not keep-trail)
+                               (org-element-headline-parser (point-max) t)
+                             (list (org-element-headline-parser
+                                    (point-max) t))))))))
+        (beginning-of-line)
+        ;; Parse successively each element, skipping those ending
+        ;; before original position.
+        (while t
+          (setq element
                 (org-element--current-element end 'element special-flag struct)
-                 type (car element))
+                type (car element))
           (org-element-put-property element :parent parent)
           (when keep-trail (push element trail))
-           (cond
+          (cond
            ;; 1. Skip any element ending before point.  Also skip
            ;;    element ending at point when we're sure that another
            ;;    element has started.
@@ -4299,10 +4778,18 @@ first element of current section."
                       ;; into elements with an explicit ending, but
                       ;; return that element instead.
                       (and (= cend origin)
-                           (memq type
-                                 '(center-block
-                                   drawer dynamic-block inlinetask item
-                                   plain-list quote-block special-block))))
+                           (or (memq type
+                                     '(center-block
+                                       drawer dynamic-block inlinetask
+                                       property-drawer quote-block
+                                       special-block))
+                               ;; Corner case: if a list ends at the
+                               ;; end of a buffer without a final new
+                               ;; line, return last element in last
+                               ;; item instead.
+                               (and (memq type '(item plain-list))
+                                    (progn (goto-char cend)
+                                           (or (bolp) (not (eobp))))))))
                   (throw 'exit (if keep-trail trail element))
                 (setq parent element)
                 (case type
@@ -4318,7 +4805,7 @@ first element of current section."
                 (goto-char cbeg)))))))))))
 
 ;;;###autoload
-(defun org-element-context ()
+(defun org-element-context (&optional element)
   "Return closest element or object around point.
 
 Return value is a list like (TYPE PROPS) where TYPE is the type
@@ -4328,81 +4815,117 @@ associated to it.
 Possible types are defined in `org-element-all-elements' and
 `org-element-all-objects'.  Properties depend on element or
 object type, but always include `:begin', `:end', `:parent' and
-`:post-blank'."
-  (org-with-wide-buffer
-   (let* ((origin (point))
-         (element (org-element-at-point))
-         (type (car element))
-         end)
-     ;; Check if point is inside an element containing objects or at
-     ;; a secondary string.  In that case, move to beginning of the
-     ;; element or secondary string and set END to the other side.
-     (if (not (or (and (eq type 'item)
-                      (let ((tag (org-element-property :tag element)))
-                        (and tag
-                             (progn
-                               (beginning-of-line)
-                               (search-forward tag (point-at-eol))
-                               (goto-char (match-beginning 0))
-                               (and (>= origin (point))
-                                    (<= origin
-                                        ;; `1+' is required so some
-                                        ;; successors can match
-                                        ;; properly their object.
-                                        (setq end (1+ (match-end 0)))))))))
-                 (and (memq type '(headline inlinetask))
-                      (progn (beginning-of-line)
-                             (skip-chars-forward "* ")
-                             (setq end (point-at-eol))))
-                 (and (memq type '(paragraph table-row verse-block))
-                      (let ((cbeg (org-element-property
-                                   :contents-begin element))
-                            (cend (org-element-property
-                                   :contents-end element)))
-                        (and (>= origin cbeg)
-                             (<= origin cend)
-                             (progn (goto-char cbeg) (setq end cend)))))))
-        element
-       (let ((restriction (org-element-restriction element))
-            (parent element)
-            candidates)
-        (catch 'exit
-          (while (setq candidates (org-element--get-next-object-candidates
-                                   end restriction candidates))
-            (let ((closest-cand (rassq (apply 'min (mapcar 'cdr candidates))
-                                       candidates)))
-              ;; If ORIGIN is before next object in element, there's
-              ;; no point in looking further.
-              (if (> (cdr closest-cand) origin) (throw 'exit parent)
-                (let* ((object
-                        (progn (goto-char (cdr closest-cand))
-                               (funcall (intern (format "org-element-%s-parser"
-                                                        (car closest-cand))))))
-                       (cbeg (org-element-property :contents-begin object))
-                       (cend (org-element-property :contents-end object))
-                       (obj-end (org-element-property :end object)))
-                  (cond
-                   ;; ORIGIN is after OBJECT, so skip it.
-                   ((<= obj-end origin)
-                    (if (/= obj-end end) (goto-char obj-end)
-                      (throw 'exit
-                             (org-element-put-property
-                              object :parent parent))))
-                   ;; ORIGIN is within a non-recursive object or at
-                   ;; an object boundaries: Return that object.
-                   ((or (not cbeg) (> cbeg origin) (< cend origin))
-                    (throw 'exit
-                           (org-element-put-property object :parent parent)))
-                   ;; Otherwise, move within current object and
-                   ;; restrict search to the end of its contents.
-                   (t (goto-char cbeg)
-                      (org-element-put-property object :parent parent)
-                      (setq parent object
-                            restriction (org-element-restriction object)
-                            end cend)))))))
-          parent))))))
-
-(defsubst org-element-nested-p (elem-A elem-B)
+`:post-blank'.
+
+Optional argument ELEMENT, when non-nil, is the closest element
+containing point, as returned by `org-element-at-point'.
+Providing it allows for quicker computation."
+  (catch 'objects-forbidden
+    (org-with-wide-buffer
+     (let* ((origin (point))
+            (element (or element (org-element-at-point)))
+            (type (org-element-type element))
+            context)
+       ;; Check if point is inside an element containing objects or at
+       ;; a secondary string.  In that case, narrow buffer to the
+       ;; containing area.  Otherwise, return ELEMENT.
+       (cond
+       ;; At a parsed affiliated keyword, check if we're inside main
+       ;; or dual value.
+       ((let ((post (org-element-property :post-affiliated element)))
+          (and post (< origin post)))
+        (beginning-of-line)
+        (let ((case-fold-search t)) (looking-at org-element--affiliated-re))
+        (cond
+         ((not (member-ignore-case (match-string 1)
+                                   org-element-parsed-keywords))
+          (throw 'objects-forbidden element))
+         ((< (match-end 0) origin)
+          (narrow-to-region (match-end 0) (line-end-position)))
+         ((and (match-beginning 2)
+               (>= origin (match-beginning 2))
+               (< origin (match-end 2)))
+          (narrow-to-region (match-beginning 2) (match-end 2)))
+         (t (throw 'objects-forbidden element)))
+        ;; Also change type to retrieve correct restrictions.
+        (setq type 'keyword))
+       ;; At an item, objects can only be located within tag, if any.
+       ((eq type 'item)
+        (let ((tag (org-element-property :tag element)))
+          (if (not tag) (throw 'objects-forbidden element)
+            (beginning-of-line)
+            (search-forward tag (line-end-position))
+            (goto-char (match-beginning 0))
+            (if (and (>= origin (point)) (< origin (match-end 0)))
+                (narrow-to-region (point) (match-end 0))
+              (throw 'objects-forbidden element)))))
+       ;; At an headline or inlinetask, objects are located within
+       ;; their title.
+       ((memq type '(headline inlinetask))
+        (goto-char (org-element-property :begin element))
+        (skip-chars-forward "* ")
+        (if (and (>= origin (point)) (< origin (line-end-position)))
+            (narrow-to-region (point) (line-end-position))
+          (throw 'objects-forbidden element)))
+       ;; At a paragraph, a table-row or a verse block, objects are
+       ;; located within their contents.
+       ((memq type '(paragraph table-row verse-block))
+        (let ((cbeg (org-element-property :contents-begin element))
+              (cend (org-element-property :contents-end element)))
+          ;; CBEG is nil for table rules.
+          (if (and cbeg cend (>= origin cbeg) (< origin cend))
+              (narrow-to-region cbeg cend)
+            (throw 'objects-forbidden element))))
+       ;; At a parsed keyword, objects are located within value.
+       ((eq type 'keyword)
+        (if (not (member (org-element-property :key element)
+                         org-element-document-properties))
+            (throw 'objects-forbidden element)
+          (beginning-of-line)
+          (search-forward ":")
+          (if (and (>= origin (point)) (< origin (line-end-position)))
+              (narrow-to-region (point) (line-end-position))
+            (throw 'objects-forbidden element))))
+       (t (throw 'objects-forbidden element)))
+       (goto-char (point-min))
+       (let ((restriction (org-element-restriction type))
+             (parent element)
+             (candidates 'initial))
+         (catch 'exit
+           (while (setq candidates
+                       (org-element--get-next-object-candidates
+                        restriction candidates))
+             (let ((closest-cand (rassq (apply 'min (mapcar 'cdr candidates))
+                                        candidates)))
+               ;; If ORIGIN is before next object in element, there's
+               ;; no point in looking further.
+               (if (> (cdr closest-cand) origin) (throw 'exit parent)
+                 (let* ((object
+                         (progn (goto-char (cdr closest-cand))
+                                (funcall (intern (format "org-element-%s-parser"
+                                                         (car closest-cand))))))
+                        (cbeg (org-element-property :contents-begin object))
+                        (cend (org-element-property :contents-end object))
+                        (obj-end (org-element-property :end object)))
+                   (cond
+                    ;; ORIGIN is after OBJECT, so skip it.
+                    ((<= obj-end origin) (goto-char obj-end))
+                    ;; ORIGIN is within a non-recursive object or at
+                    ;; an object boundaries: Return that object.
+                    ((or (not cbeg) (< origin cbeg) (>= origin cend))
+                     (throw 'exit
+                            (org-element-put-property object :parent parent)))
+                    ;; Otherwise, move within current object and
+                    ;; restrict search to the end of its contents.
+                    (t (goto-char cbeg)
+                       (narrow-to-region (point) cend)
+                       (org-element-put-property object :parent parent)
+                       (setq parent object
+                             restriction (org-element-restriction object)
+                             candidates 'initial)))))))
+           parent))))))
+
+(defun org-element-nested-p (elem-A elem-B)
   "Non-nil when elements ELEM-A and ELEM-B are nested."
   (let ((beg-A (org-element-property :begin elem-A))
        (beg-B (org-element-property :begin elem-B))
index 3f8cc9c6d6cfa7072829218bf183ab713830b7eb..638da7861bf1a5a351fcb3ac94ff21590be9f08a 100644 (file)
@@ -66,8 +66,8 @@ ASCII replacement    Plain ASCII, no extensions.  Symbols that cannot be
 Latin1 replacement   Use the special characters available in latin1.
 utf-8 replacement    Use the special characters available in utf-8.
 
-If you define new entities here that require specific LaTeX packages to be
-loaded, add these packages to `org-export-latex-packages-alist'."
+If you define new entities here that require specific LaTeX
+packages to be loaded, add these packages to `org-latex-packages-alist'."
   :group 'org-entities
   :version "24.1"
   :type '(repeat
@@ -154,6 +154,9 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("real" "\\Re" t "&real;" "R" "R" "ℜ")
     ("image" "\\Im" t "&image;" "I" "I" "ℑ")
     ("weierp" "\\wp" t "&weierp;" "P" "P" "℘")
+    ("ell" "\\ell" t "&ell;" "ell" "ell" "ℓ")
+    ("imath" "\\imath" t "&imath;" "[dotless i]" "dotless i" "ı")
+    ("jmath" "\\jmath" t "&jmath;" "[dotless j]" "dotless j" "ȷ")
 
     "** Greek"
     ("Alpha" "A" nil "&Alpha;" "Alpha" "Alpha" "Α")
@@ -203,6 +206,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("upsilon" "\\upsilon" t "&upsilon;" "upsilon" "upsilon" "υ")
     ("Phi" "\\Phi" t "&Phi;" "Phi" "Phi" "Φ")
     ("phi" "\\phi" t "&phi;" "phi" "phi" "φ")
+    ("varphi" "\\varphi" t "&varphi;" "varphi" "varphi" "ɸ")
     ("Chi" "X" nil "&Chi;" "Chi" "Chi" "Χ")
     ("chi" "\\chi" t "&chi;" "chi" "chi" "χ")
     ("acutex" "\\acute x" t "&acute;x" "'x" "'x" "𝑥́")
@@ -212,10 +216,15 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("Omega" "\\Omega" t "&Omega;" "Omega" "Omega" "Ω")
     ("omega" "\\omega" t "&omega;" "omega" "omega" "ω")
     ("piv" "\\varpi" t "&piv;" "omega-pi" "omega-pi" "ϖ")
+    ("varpi" "\\varpi" t "&piv;" "omega-pi" "omega-pi" "ϖ")
     ("partial" "\\partial" t "&part;" "[partial differential]" "[partial differential]" "∂")
 
     "** Hebrew"
     ("alefsym" "\\aleph" t "&alefsym;" "aleph" "aleph" "ℵ")
+    ("aleph" "\\aleph" t "&aleph;" "aleph" "aleph" "ℵ")
+    ("gimel" "\\gimel" t "&gimel;" "gimel" "gimel" "ℷ")
+    ("beth" "\\beth" t "&beth;" "beth" "beth" "ב")
+    ("dalet" "\\daleth" t "&daleth;" "dalet" "dalet" "ד")
 
     "** Dead languages"
     ("ETH" "\\DH{}" nil "&ETH;" "D" "Ð" "Ð")
@@ -226,6 +235,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     "* Punctuation"
     "** Dots and Marks"
     ("dots" "\\dots{}" nil "&hellip;" "..." "..." "…")
+    ("cdots" "\\cdots{}" t "&ctdot;" "..." "..." "⋯")
     ("hellip" "\\dots{}" nil "&hellip;" "..." "..." "…")
     ("middot" "\\textperiodcentered{}" nil "&middot;" "." "·" "·")
     ("iexcl" "!`" nil "&iexcl;" "!" "¡" "¡")
@@ -253,20 +263,23 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     "* Other"
     "** Misc. (often used)"
     ("circ" "\\^{}" nil "&circ;" "^" "^" "ˆ")
-    ("vert" "\\vert{}" t "&#124;" "|" "|" "|")
+    ("vert" "\\vert{}" t "&vert;" "|" "|" "|")
     ("brvbar" "\\textbrokenbar{}" nil "&brvbar;" "|" "¦" "¦")
+    ("S" "\\S" nil "&sect;" "paragraph" "§" "§")
     ("sect" "\\S" nil "&sect;" "paragraph" "§" "§")
     ("amp" "\\&" nil "&amp;" "&" "&" "&")
     ("lt" "\\textless{}" nil "&lt;" "<" "<" "<")
     ("gt" "\\textgreater{}" nil "&gt;" ">" ">" ">")
-    ("tilde" "\\~{}" nil "&tilde;" "~" "~" "~")
+    ("tilde" "\\textasciitilde{}" nil "~" "~" "~" "~")
     ("slash" "/" nil "/" "/" "/" "/")
     ("plus" "+" nil "+" "+" "+" "+")
     ("under" "\\_" nil "_" "_" "_" "_")
     ("equal" "=" nil "=" "=" "=" "=")
     ("asciicirc" "\\textasciicircum{}" nil "^" "^" "^" "^")
     ("dagger" "\\textdagger{}" nil "&dagger;" "[dagger]" "[dagger]" "†")
+    ("dag" "\\dag{}" nil "&dagger;" "[dagger]" "[dagger]" "†")
     ("Dagger" "\\textdaggerdbl{}" nil "&Dagger;" "[doubledagger]" "[doubledagger]" "‡")
+    ("ddag" "\\ddag{}" nil "&Dagger;" "[doubledagger]" "[doubledagger]" "‡")
 
     "** Whitespace"
     ("nbsp" "~" nil "&nbsp;" " " " " " ")
@@ -297,6 +310,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("plusmn" "\\textpm{}" nil "&plusmn;" "+-" "±" "±")
     ("times" "\\texttimes{}" nil "&times;" "*" "×" "×")
     ("frasl" "/" nil "&frasl;" "/" "/" "⁄")
+    ("colon" "\\colon" t ":" ":" ":" ":")
     ("div" "\\textdiv{}" nil "&divide;" "/" "÷" "÷")
     ("frac12" "\\textonehalf{}" nil "&frac12;" "1/2" "½" "½")
     ("frac14" "\\textonequarter{}" nil "&frac14;" "1/4" "¼" "¼")
@@ -318,6 +332,7 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("prop" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
     ("proptp" "\\propto" t "&prop;" "[proportional to]" "[proportional to]" "∝")
     ("not" "\\textlnot{}" nil "&not;" "[angled dash]" "¬" "¬")
+    ("neg" "\\neg{}" t "&not;" "[angled dash]" "¬" "¬")
     ("land" "\\land" t "&and;" "[logical and]" "[logical and]" "∧")
     ("wedge" "\\wedge" t "&and;" "[logical and]" "[logical and]" "∧")
     ("lor" "\\lor" t "&or;" "[logical or]" "[logical or]" "∨")
@@ -325,7 +340,9 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("cap" "\\cap" t "&cap;" "[intersection]" "[intersection]" "∩")
     ("cup" "\\cup" t "&cup;" "[union]" "[union]" "∪")
     ("int" "\\int" t "&int;" "[integral]" "[integral]" "∫")
+    ("therefore" "\\therefore" t "&there4;" "[therefore]" "[therefore]" "∴")
     ("there4" "\\therefore" t "&there4;" "[therefore]" "[therefore]" "∴")
+    ("because" "\\because" t "&because;" "[because]" "[because]" "∵")
     ("sim" "\\sim" t "&sim;" "~" "~" "∼")
     ("cong" "\\cong" t "&cong;" "[approx. equal to]" "[approx. equal to]" "≅")
     ("simeq" "\\simeq" t "&cong;"  "[approx. equal to]" "[approx. equal to]" "≅")
@@ -334,8 +351,26 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("ne" "\\ne" t "&ne;" "[not equal to]" "[not equal to]" "≠")
     ("neq" "\\neq" t "&ne;" "[not equal to]" "[not equal to]" "≠")
     ("equiv" "\\equiv" t "&equiv;" "[identical to]" "[identical to]" "≡")
+
+    ("triangleq" "\\triangleq" t "&triangleq;" "[defined to]" "[defined to]" "≜")
     ("le" "\\le" t "&le;" "<=" "<=" "≤")
+    ("leq" "\\le" t "&le;" "<=" "<=" "≤")
     ("ge" "\\ge" t "&ge;" ">=" ">=" "≥")
+    ("geq" "\\ge" t "&ge;" ">=" ">=" "≥")
+    ("lessgtr" "\\lessgtr" t "&lessgtr;" "[less than or greater than]" "[less than or greater than]" "≶")
+    ("lesseqgtr" "\\lesseqgtr" t "&lesseqgtr;" "[less than or equal or greater than or equal]" "[less than or equal or greater than or equal]" "⋚")
+    ("ll" "\\ll" t  "&Lt;" "<<" "<<" "≪")
+    ("Ll" "\lll" t "&Ll;" "<<<" "<<<" "⋘")
+    ("lll" "\lll" t "&Ll;" "<<<" "<<<" "⋘")
+    ("gg" "\\gg" t  "&Gt;" ">>" ">>" "≫")
+    ("Gg" "\\ggg" t "&Gg;" ">>>" ">>>" "⋙")
+    ("ggg" "\\ggg" t "&Gg;" ">>>" ">>>" "⋙")
+    ("prec" "\\prec" t "&pr;" "[precedes]" "[precedes]" "≺")
+    ("preceq" "\\preceq" t "&prcue;" "[precedes or equal]" "[precedes or equal]" "≼")
+    ("preccurlyeq" "\\preccurlyeq" t "&prcue;" "[precedes or equal]" "[precedes or equal]" "≼")
+    ("succ" "\\succ" t "&sc;" "[succeeds]" "[succeeds]" "≻")
+    ("succeq" "\\succeq" t "&sccue;" "[succeeds or equal]" "[succeeds or equal]" "≽")
+    ("succcurlyeq" "\\succcurlyeq" t "&sccue;" "[succeeds or equal]" "[succeeds or equal]" "≽")
     ("sub" "\\subset" t "&sub;" "[subset of]" "[subset of]" "⊂")
     ("subset" "\\subset" t "&sub;" "[subset of]" "[subset of]" "⊂")
     ("sup" "\\supset" t "&sup;" "[superset of]" "[superset of]" "⊃")
@@ -344,9 +379,12 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("sube" "\\subseteq" t "&sube;" "[subset of or equal to]" "[subset of or equal to]" "⊆")
     ("nsup" "\\not\\supset" t "&nsup;" "[not a superset of]" "[not a superset of]" "⊅")
     ("supe" "\\supseteq" t "&supe;" "[superset of or equal to]" "[superset of or equal to]" "⊇")
+    ("setminus" "\\setminus" t "&setminus;" "\" "\" "⧵")
     ("forall" "\\forall" t "&forall;" "[for all]" "[for all]" "∀")
     ("exist" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
     ("exists" "\\exists" t "&exist;" "[there exists]" "[there exists]" "∃")
+    ("nexist" "\\nexists" t "&exist;" "[there does not exists]" "[there does not  exists]" "∄")
+    ("nexists" "\\nexists" t "&exist;" "[there does not exists]" "[there does not  exists]" "∄")
     ("empty" "\\empty" t "&empty;" "[empty set]" "[empty set]" "∅")
     ("emptyset" "\\emptyset" t "&empty;" "[empty set]" "[empty set]" "∅")
     ("isin" "\\in" t "&isin;" "[element of]" "[element of]" "∈")
@@ -365,6 +403,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("rfloor" "\\rfloor" t "&rfloor;" "[right floor]" "[right floor]" "⌋")
     ("lang" "\\langle" t "&lang;" "<" "<" "⟨")
     ("rang" "\\rangle" t "&rang;" ">" ">" "⟩")
+    ("hbar" "\\hbar" t "&hbar;" "hbar" "hbar" "ℏ")
+    ("mho" "\\mho" t "&mho;" "mho" "mho" "℧")
 
     "** Arrows"
     ("larr" "\\leftarrow" t "&larr;" "<-" "<-" "←")
@@ -435,7 +475,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("odot" "\\odot" t "o" "[circled dot]" "[circled dot]" "ʘ")
     ("oplus" "\\oplus" t "&oplus;" "[circled plus]" "[circled plus]" "⊕")
     ("otimes" "\\otimes" t "&otimes;" "[circled times]" "[circled times]" "⊗")
-    ("checkmark" "\\checkmark" t "&#10003;" "[checkmark]" "[checkmark]" "✓")
+    ("check" "\\checkmark" t "&checkmark;" "[checkmark]" "[checkmark]" "✓")
+    ("checkmark" "\\checkmark" t "&check;" "[checkmark]" "[checkmark]" "✓")
 
     "** Miscellaneous (seldom used)"
     ("para" "\\P{}" nil "&para;" "[pilcrow]" "¶" "¶")
@@ -450,7 +491,8 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("rlm" "" nil "&rlm;" "" "" "‏")
 
     "** Smilies"
-    ("smile" "\\smile" t "&#9786;" ":-)" ":-)" "⌣")
+    ("smile" "\\smile" t "&smile;" ":-)" ":-)" "⌣")
+    ("frown" "\\frown" t "&frown;" ":-(" ":-(" "⌢")
     ("smiley" "\\smiley{}" nil "&#9786;" ":-)" ":-)" "☺")
     ("blacksmile" "\\blacksmiley{}" nil "&#9787;" ":-)" ":-)" "☻")
     ("sad" "\\frownie{}" nil "&#9785;" ":-(" ":-(" "☹")
@@ -462,10 +504,11 @@ loaded, add these packages to `org-export-latex-packages-alist'."
     ("spadesuit" "\\spadesuit" t "&spades;" "[spades]" "[spades]" "♠")
     ("hearts" "\\heartsuit" t "&hearts;" "[hearts]" "[hearts]" "♥")
     ("heartsuit" "\\heartsuit" t "&heartsuit;" "[hearts]" "[hearts]" "♥")
-    ("diams" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
-    ("diamondsuit" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "♦")
-    ("Diamond" "\\diamond" t "&diamond;" "[diamond]" "[diamond]" "⋄")
-    ("loz" "\\diamond" t "&loz;" "[lozenge]" "[lozenge]" "◊")
+    ("diams" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "◆")
+    ("diamondsuit" "\\diamondsuit" t "&diams;" "[diamonds]" "[diamonds]" "◆")
+    ("diamond" "\\diamondsuit" t "&diamond;" "[diamond]" "[diamond]" "◆")
+    ("Diamond" "\\diamondsuit" t "&diamond;" "[diamond]" "[diamond]" "◆")
+    ("loz" "\\lozenge" t "&loz;" "[lozenge]" "[lozenge]" "⧫")
     )
   "Default entities used in Org-mode to produce special characters.
 For details see `org-entities-user'.")
diff --git a/lisp/org/org-exp-blocks.el b/lisp/org/org-exp-blocks.el
deleted file mode 100644 (file)
index d3789ad..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-;;; org-exp-blocks.el --- pre-process blocks when exporting org files
-
-;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
-
-;; Author: Eric Schulte
-
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This is a utility for pre-processing blocks in org files before
-;; export using the `org-export-preprocess-hook'.  It can be used for
-;; exporting new types of blocks from org-mode files and also for
-;; changing the default export behavior of existing org-mode blocks.
-;; The `org-export-blocks' and `org-export-interblocks' variables can
-;; be used to control how blocks and the spaces between blocks
-;; respectively are processed upon export.
-;;
-;; The type of a block is defined as the string following =#+begin_=,
-;; so for example the following block would be of type ditaa.  Note
-;; that both upper or lower case are allowed in =#+BEGIN_= and
-;; =#+END_=.
-;;
-;; #+begin_ditaa blue.png -r -S
-;; +---------+
-;; | cBLU    |
-;; |         |
-;; |    +----+
-;; |    |cPNK|
-;; |    |    |
-;; +----+----+
-;; #+end_ditaa
-;;
-;;; Currently Implemented Block Types
-;;
-;; ditaa :: (DEPRECATED--use "#+begin_src ditaa" code blocks) Convert
-;;          ascii pictures to actual images using ditaa
-;;          http://ditaa.sourceforge.net/.  To use this set
-;;          `org-ditaa-jar-path' to the path to ditaa.jar on your
-;;          system (should be set automatically in most cases) .
-;;
-;; dot :: (DEPRECATED--use "#+begin_src dot" code blocks) Convert
-;;        graphs defined using the dot graphing language to images
-;;        using the dot utility.  For information on dot see
-;;        http://www.graphviz.org/
-;;
-;; export-comment :: Wrap comments with titles and author information,
-;;            in their own divs with author-specific ids allowing for
-;;            css coloring of comments based on the author.
-;;
-;;; Adding new blocks
-;;
-;; When adding a new block type first define a formatting function
-;; along the same lines as `org-export-blocks-format-dot' and then use
-;; `org-export-blocks-add-block' to add your block type to
-;; `org-export-blocks'.
-
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-(require 'find-func)
-(require 'org-compat)
-
-(declare-function org-split-string "org" (string &optional separators))
-(declare-function org-remove-indentation "org" (code &optional n))
-
-(defvar org-protecting-blocks nil) ; From org.el
-
-(defun org-export-blocks-set (var value)
-  "Set the value of `org-export-blocks' and install fontification."
-  (set var value)
-  (mapc (lambda (spec)
-         (if (nth 2 spec)
-             (setq org-protecting-blocks
-                   (delete (symbol-name (car spec))
-                           org-protecting-blocks))
-           (add-to-list 'org-protecting-blocks
-                        (symbol-name (car spec)))))
-       value))
-
-(defcustom org-export-blocks
-  '((export-comment org-export-blocks-format-comment t)
-    (ditaa org-export-blocks-format-ditaa nil)
-    (dot org-export-blocks-format-dot nil))
-  "Use this alist to associate block types with block exporting functions.
-The type of a block is determined by the text immediately
-following the '#+BEGIN_' portion of the block header.  Each block
-export function should accept three arguments."
-  :group 'org-export-general
-  :type '(repeat
-         (list
-          (symbol :tag "Block name")
-          (function :tag "Block formatter")
-          (boolean :tag "Fontify content as Org syntax")))
-  :set 'org-export-blocks-set)
-
-(defun org-export-blocks-add-block (block-spec)
-  "Add a new block type to `org-export-blocks'.
-BLOCK-SPEC should be a three element list the first element of
-which should indicate the name of the block, the second element
-should be the formatting function called by
-`org-export-blocks-preprocess' and the third element a flag
-indicating whether these types of blocks should be fontified in
-org-mode buffers (see `org-protecting-blocks').  For example the
-BLOCK-SPEC for ditaa blocks is as follows.
-
-  (ditaa org-export-blocks-format-ditaa nil)"
-  (unless (member block-spec org-export-blocks)
-    (setq org-export-blocks (cons block-spec org-export-blocks))
-    (org-export-blocks-set 'org-export-blocks org-export-blocks)))
-
-(defcustom org-export-interblocks
-  '()
-  "Use this a-list to associate block types with block exporting functions.
-The type of a block is determined by the text immediately
-following the '#+BEGIN_' portion of the block header.  Each block
-export function should accept three arguments."
-  :group 'org-export-general
-  :type 'alist)
-
-(defcustom org-export-blocks-witheld
-  '(hidden)
-  "List of block types (see `org-export-blocks') which should not be exported."
-  :group 'org-export-general
-  :type 'list)
-
-(defcustom org-export-blocks-postblock-hook nil
-  "Run after blocks have been processed with `org-export-blocks-preprocess'."
-  :group 'org-export-general
-  :version "24.1"
-  :type 'hook)
-
-(defun org-export-blocks-html-quote (body &optional open close)
-  "Protect BODY from org html export.
-The optional OPEN and CLOSE tags will be inserted around BODY."
-  (concat
-   "\n#+BEGIN_HTML\n"
-   (or open "")
-   body (if (string-match "\n$" body) "" "\n")
-   (or close "")
-   "#+END_HTML\n"))
-
-(defun org-export-blocks-latex-quote (body &optional open close)
-  "Protect BODY from org latex export.
-The optional OPEN and CLOSE tags will be inserted around BODY."
-  (concat
-   "\n#+BEGIN_LaTeX\n"
-   (or open "")
-   body (if (string-match "\n$" body) "" "\n")
-   (or close "")
-   "#+END_LaTeX\n"))
-
-(defvar org-src-preserve-indentation)     ; From org-src.el
-(defun org-export-blocks-preprocess ()
-  "Export all blocks according to the `org-export-blocks' block export alist.
-Does not export block types specified in specified in BLOCKS
-which defaults to the value of `org-export-blocks-witheld'."
-  (interactive)
-  (save-window-excursion
-    (let ((case-fold-search t)
-         (interblock (lambda (start end)
-                       (mapcar (lambda (pair) (funcall (second pair) start end))
-                               org-export-interblocks)))
-         matched indentation type types func
-         start end body headers preserve-indent progress-marker)
-      (goto-char (point-min))
-      (setq start (point))
-      (let ((beg-re "^\\([ \t]*\\)#\\+begin_\\(\\S-+\\)[ \t]*\\(.*\\)?[\r\n]"))
-       (while (re-search-forward beg-re nil t)
-         (let* ((match-start (copy-marker (match-beginning 0)))
-                (body-start (copy-marker (match-end 0)))
-                (indentation (length (match-string 1)))
-                (inner-re (format "^[ \t]*#\\+\\(begin\\|end\\)_%s"
-                                  (regexp-quote (downcase (match-string 2)))))
-                (type (intern (downcase (match-string 2))))
-                (headers (save-match-data
-                           (org-split-string (match-string 3) "[ \t]+")))
-                (balanced 1)
-                (preserve-indent (or org-src-preserve-indentation
-                                     (member "-i" headers)))
-                match-end)
-           (while (and (not (zerop balanced))
-                       (re-search-forward inner-re nil t))
-             (if (string= (downcase (match-string 1)) "end")
-                 (decf balanced)
-               (incf balanced)))
-           (when (not (zerop balanced))
-             (error "Unbalanced begin/end_%s blocks with %S"
-                    type (buffer-substring match-start (point))))
-           (setq match-end (copy-marker (match-end 0)))
-           (unless preserve-indent
-             (setq body (save-match-data (org-remove-indentation
-                                          (buffer-substring
-                                           body-start (match-beginning 0))))))
-           (unless (memq type types) (setq types (cons type types)))
-           (save-match-data (funcall interblock start match-start))
-           (when (setq func (cadr (assoc type org-export-blocks)))
-             (let ((replacement (save-match-data
-                                  (if (memq type org-export-blocks-witheld) ""
-                                    (apply func body headers)))))
-               ;; ;; un-comment this code after the org-element merge
-               ;; (save-match-data
-               ;;   (when (and replacement (string= replacement ""))
-               ;;     (delete-region
-               ;;      (car (org-element-collect-affiliated-keyword))
-               ;;      match-start)))
-               (when replacement
-                 (delete-region match-start match-end)
-                 (goto-char match-start) (insert replacement)
-                 (if preserve-indent
-                     ;; indent only the code block markers
-                     (save-excursion
-                       (indent-line-to indentation) ; indent end_block
-                       (goto-char match-start)
-                       (indent-line-to indentation))   ; indent begin_block
-                   ;; indent everything
-                   (indent-code-rigidly match-start (point) indentation)))))
-           ;; cleanup markers
-           (set-marker match-start nil)
-           (set-marker body-start nil)
-           (set-marker match-end nil))
-         (setq start (point))))
-      (funcall interblock start (point-max))
-      (run-hooks 'org-export-blocks-postblock-hook))))
-
-;;================================================================================
-;; type specific functions
-
-;;--------------------------------------------------------------------------------
-;; ditaa: create images from ASCII art using the ditaa utility
-(defcustom org-ditaa-jar-path (expand-file-name
-                              "ditaa.jar"
-                              (file-name-as-directory
-                               (expand-file-name
-                                "scripts"
-                                (file-name-as-directory
-                                 (expand-file-name
-                                  "../contrib"
-                                  (file-name-directory (org-find-library-dir "org")))))))
-  "Path to the ditaa jar executable."
-  :group 'org-babel
-  :type 'string)
-
-(defvar org-export-current-backend) ; dynamically bound in org-exp.el
-(defun org-export-blocks-format-ditaa (body &rest headers)
-  "DEPRECATED: use begin_src ditaa code blocks
-
-Pass block BODY to the ditaa utility creating an image.
-Specify the path at which the image should be saved as the first
-element of headers, any additional elements of headers will be
-passed to the ditaa utility as command line arguments."
-  (message "begin_ditaa blocks are DEPRECATED, use begin_src blocks")
-  (let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
-         (data-file (make-temp-file "org-ditaa"))
-        (hash (progn
-                (set-text-properties 0 (length body) nil body)
-                (sha1 (prin1-to-string (list body args)))))
-        (raw-out-file (if headers (car headers)))
-        (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file)
-                            (cons (match-string 1 raw-out-file)
-                                  (match-string 2 raw-out-file))
-                          (cons raw-out-file "png")))
-        (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts))))
-    (unless (file-exists-p org-ditaa-jar-path)
-      (error (format "Could not find ditaa.jar at %s" org-ditaa-jar-path)))
-    (setq body (if (string-match "^\\([^:\\|:[^ ]\\)" body)
-                  body
-                (mapconcat (lambda (x) (substring x (if (> (length x) 1) 2 1)))
-                           (org-split-string body "\n")
-                           "\n")))
-    (prog1
-       (cond
-        ((member org-export-current-backend '(html latex docbook))
-         (unless (file-exists-p out-file)
-           (mapc ;; remove old hashed versions of this file
-            (lambda (file)
-              (when (and (string-match (concat (regexp-quote (car out-file-parts))
-                                               "_\\([[:alnum:]]+\\)\\."
-                                               (regexp-quote (cdr out-file-parts)))
-                                       file)
-                         (= (length (match-string 1 out-file)) 40))
-                (delete-file (expand-file-name file
-                                               (file-name-directory out-file)))))
-            (directory-files (or (file-name-directory out-file)
-                                 default-directory)))
-           (with-temp-file data-file (insert body))
-           (message (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file))
-           (shell-command (concat "java -jar " org-ditaa-jar-path " " args " " data-file " " out-file)))
-         (format "\n[[file:%s]]\n" out-file))
-        (t (concat
-            "\n#+BEGIN_EXAMPLE\n"
-            body (if (string-match "\n$" body) "" "\n")
-            "#+END_EXAMPLE\n")))
-      (message "begin_ditaa blocks are DEPRECATED, use begin_src blocks"))))
-
-;;--------------------------------------------------------------------------------
-;; dot: create graphs using the dot graphing language
-;;      (require the dot executable to be in your path)
-(defun org-export-blocks-format-dot (body &rest headers)
-  "DEPRECATED: use \"#+begin_src dot\" code blocks
-
-Pass block BODY to the dot graphing utility creating an image.
-Specify the path at which the image should be saved as the first
-element of headers, any additional elements of headers will be
-passed to the dot utility as command line arguments.  Don't
-forget to specify the output type for the dot command, so if you
-are exporting to a file with a name like 'image.png' you should
-include a '-Tpng' argument, and your block should look like the
-following.
-
-#+begin_dot models.png -Tpng
-digraph data_relationships {
-  \"data_requirement\" [shape=Mrecord, label=\"{DataRequirement|description\lformat\l}\"]
-  \"data_product\" [shape=Mrecord, label=\"{DataProduct|name\lversion\lpoc\lformat\l}\"]
-  \"data_requirement\" -> \"data_product\"
-}
-#+end_dot"
-  (message "begin_dot blocks are DEPRECATED, use begin_src blocks")
-  (let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
-         (data-file (make-temp-file "org-ditaa"))
-        (hash (progn
-                (set-text-properties 0 (length body) nil body)
-                (sha1 (prin1-to-string (list body args)))))
-        (raw-out-file (if headers (car headers)))
-        (out-file-parts (if (string-match "\\(.+\\)\\.\\([^\\.]+\\)$" raw-out-file)
-                            (cons (match-string 1 raw-out-file)
-                                  (match-string 2 raw-out-file))
-                          (cons raw-out-file "png")))
-        (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts))))
-    (prog1
-       (cond
-        ((member org-export-current-backend '(html latex docbook))
-         (unless (file-exists-p out-file)
-           (mapc ;; remove old hashed versions of this file
-            (lambda (file)
-              (when (and (string-match (concat (regexp-quote (car out-file-parts))
-                                               "_\\([[:alnum:]]+\\)\\."
-                                               (regexp-quote (cdr out-file-parts)))
-                                       file)
-                         (= (length (match-string 1 out-file)) 40))
-                (delete-file (expand-file-name file
-                                               (file-name-directory out-file)))))
-            (directory-files (or (file-name-directory out-file)
-                                 default-directory)))
-           (with-temp-file data-file (insert body))
-           (message (concat "dot " data-file " " args " -o " out-file))
-           (shell-command (concat "dot " data-file " " args " -o " out-file)))
-         (format "\n[[file:%s]]\n" out-file))
-        (t (concat
-            "\n#+BEGIN_EXAMPLE\n"
-            body (if (string-match "\n$" body) "" "\n")
-            "#+END_EXAMPLE\n")))
-      (message "begin_dot blocks are DEPRECATED, use begin_src blocks"))))
-
-;;--------------------------------------------------------------------------------
-;; comment: export comments in author-specific css-stylable divs
-(defun org-export-blocks-format-comment (body &rest headers)
-  "Format comment BODY by OWNER and return it formatted for export.
-Currently, this only does something for HTML export, for all
-other backends, it converts the comment into an EXAMPLE segment."
-  (let ((owner (if headers (car headers)))
-       (title (if (cdr headers) (mapconcat 'identity (cdr headers) " "))))
-    (cond
-     ((eq org-export-current-backend 'html) ;; We are exporting to HTML
-      (concat "#+BEGIN_HTML\n"
-             "<div class=\"org-comment\""
-             (if owner (format " id=\"org-comment-%s\" " owner))
-             ">\n"
-             (if owner (concat "<b>" owner "</b> ") "")
-             (if (and title (> (length title) 0)) (concat " -- " title "<br/>\n") "<br/>\n")
-             "<p>\n"
-             "#+END_HTML\n"
-             body
-             "\n#+BEGIN_HTML\n"
-             "</p>\n"
-             "</div>\n"
-             "#+END_HTML\n"))
-     (t ;; This is not HTML, so just make it an example.
-      (concat "#+BEGIN_EXAMPLE\n"
-             (if title (concat "Title:" title "\n") "")
-             (if owner (concat "By:" owner "\n") "")
-             body
-             (if (string-match "\n\\'" body) "" "\n")
-             "#+END_EXAMPLE\n")))))
-
-(provide 'org-exp-blocks)
-
-;;; org-exp-blocks.el ends here
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el
deleted file mode 100644 (file)
index 82b9003..0000000
+++ /dev/null
@@ -1,3354 +0,0 @@
-;;; org-exp.el --- Export internals for Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;;; Code:
-
-(require 'org)
-(require 'org-macs)
-(require 'org-agenda)
-(require 'org-exp-blocks)
-(require 'ob-exp)
-(require 'org-src)
-
-(eval-when-compile
-  (require 'cl))
-
-(declare-function org-export-latex-preprocess "org-latex" (parameters))
-(declare-function org-export-ascii-preprocess "org-ascii" (parameters))
-(declare-function org-export-html-preprocess "org-html" (parameters))
-(declare-function org-export-docbook-preprocess "org-docbook" (parameters))
-(declare-function org-infojs-options-inbuffer-template "org-jsinfo" ())
-(declare-function org-export-htmlize-region-for-paste "org-html" (beg end))
-(declare-function htmlize-buffer "ext:htmlize" (&optional buffer))
-(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
-(declare-function org-table-cookie-line-p "org-table" (line))
-(declare-function org-table-colgroup-line-p "org-table" (line))
-(declare-function org-pop-to-buffer-same-window "org-compat"
-                 (&optional buffer-or-name norecord label))
-(declare-function org-unescape-code-in-region "org-src" (beg end))
-
-(autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t)
-
-(autoload 'org-export-as-odt "org-odt"
-  "Export the outline to a OpenDocument Text file." t)
-(autoload 'org-export-as-odt-and-open "org-odt"
-  "Export the outline to a OpenDocument Text file and open it." t)
-
-(defgroup org-export nil
-  "Options for exporting org-listings."
-  :tag "Org Export"
-  :group 'org)
-
-(defgroup org-export-general nil
-  "General options for exporting Org-mode files."
-  :tag "Org Export General"
-  :group 'org-export)
-
-(defcustom org-export-allow-BIND 'confirm
-  "Non-nil means allow #+BIND to define local variable values for export.
-This is a potential security risk, which is why the user must confirm the
-use of these lines."
-  :group 'org-export-general
-  :type '(choice
-         (const :tag "Never" nil)
-         (const :tag "Always" t)
-         (const :tag "Make the user confirm for each file" confirm)))
-
-;; FIXME
-(defvar org-export-publishing-directory nil)
-
-(defcustom org-export-show-temporary-export-buffer t
-  "Non-nil means show buffer after exporting to temp buffer.
-When Org exports to a file, the buffer visiting that file is ever
-shown, but remains buried.  However, when exporting to a temporary
-buffer, that buffer is popped up in a second window.  When this variable
-is nil, the buffer remains buried also in these cases."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-copy-to-kill-ring t
-  "Non-nil means exported stuff will also be pushed onto the kill ring."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-kill-product-buffer-when-displayed nil
-  "Non-nil means kill the product buffer if it is displayed immediately.
-This applied to the commands `org-export-as-html-and-open' and
-`org-export-as-pdf-and-open'."
-  :group 'org-export-general
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-run-in-background nil
-  "Non-nil means export and publishing commands will run in background.
-This works by starting up a separate Emacs process visiting the same file
-and doing the export from there.
-Not all export commands are affected by this - only the ones which
-actually write to a file, and that do not depend on the buffer state.
-\\<org-mode-map>
-If this option is nil, you can still get background export by calling
-`org-export' with a double prefix arg: \
-\\[universal-argument] \\[universal-argument] \\[org-export].
-
-If this option is t, the double prefix can be used to exceptionally
-force an export command into the current process."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-initial-scope 'buffer
-  "The initial scope when exporting with `org-export'.
-This variable can be either set to 'buffer or 'subtree."
-  :group 'org-export-general
-  :version "24.1"
-  :type '(choice
-         (const :tag "Export current buffer" 'buffer)
-         (const :tag "Export current subtree" 'subtree)))
-
-(defcustom org-export-select-tags '("export")
-  "Tags that select a tree for export.
-If any such tag is found in a buffer, all trees that do not carry one
-of these tags will be deleted before export.
-Inside trees that are selected like this, you can still deselect a
-subtree by tagging it with one of the `org-export-exclude-tags'."
-  :group 'org-export-general
-  :type '(repeat (string :tag "Tag")))
-
-(defcustom org-export-exclude-tags '("noexport")
-  "Tags that exclude a tree from export.
-All trees carrying any of these tags will be excluded from export.
-This is without condition, so even subtrees inside that carry one of the
-`org-export-select-tags' will be removed."
-  :group 'org-export-general
-  :type '(repeat (string :tag "Tag")))
-
-;; FIXME: rename, this is a general variable
-(defcustom org-export-html-expand t
-  "Non-nil means for HTML export, treat @<...> as HTML tag.
-When nil, these tags will be exported as plain text and therefore
-not be interpreted by a browser.
-
-This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
-  :group 'org-export-html
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-special-strings t
-  "Non-nil means interpret \"\-\", \"--\" and \"---\" for export.
-When this option is turned on, these strings will be exported as:
-
-  Org   HTML       LaTeX
- -----+----------+--------
-  \\-    &shy;      \\-
-  --    &ndash;    --
-  ---   &mdash;    ---
-  ...   &hellip;   \ldots
-
-This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
-  :group 'org-export-translation
-  :type 'boolean)
-
-(defcustom org-export-html-link-up ""
-  "Where should the \"UP\" link of exported HTML pages lead?"
-  :group 'org-export-html
-  :group 'org-export-general
-  :type '(string :tag "File or URL"))
-
-(defcustom org-export-html-link-home ""
-  "Where should the \"HOME\" link of exported HTML pages lead?"
-  :group 'org-export-html
-  :group 'org-export-general
-  :type '(string :tag "File or URL"))
-
-(defcustom org-export-language-setup
-  '(("en" "Author"     "Date"  "Table of Contents" "Footnotes")
-    ("ca"  "Autor"      "Data" "&Iacute;ndex" "Peus de p&agrave;gina")
-    ("cs" "Autor"      "Datum" "Obsah" "Pozn\xe1mky pod carou")
-    ("da" "Ophavsmand" "Dato"  "Indhold" "Fodnoter")
-    ("de" "Autor"      "Datum" "Inhaltsverzeichnis" "Fu&szlig;noten")
-    ("eo"  "A&#365;toro"      "Dato" "Enhavo" "Piednotoj")
-    ("es" "Autor"      "Fecha" "&Iacute;ndice" "Pies de p&aacute;gina")
-    ("fi" "Tekij&auml;"     "P&auml;iv&auml;m&auml;&auml;r&auml;"   "Sis&auml;llysluettelo"  "Alaviitteet")
-    ("fr" "Auteur"     "Date"  "Sommaire" "Notes de bas de page")
-    ("hu" "Szerz&otilde;" "D&aacute;tum" "Tartalomjegyz&eacute;k" "L&aacute;bjegyzet")
-    ("is" "H&ouml;fundur" "Dagsetning" "Efnisyfirlit" "Aftanm&aacute;lsgreinar")
-    ("it" "Autore"     "Data"  "Indice" "Note a pi&egrave; di pagina")
-    ;; Use numeric character entities for proper rendering of non-UTF8 documents
-    ;; ("ja" "著者"       "日付"  "目次"          "脚注")
-    ("ja" "&#33879;&#32773;" "&#26085;&#20184;" "&#30446;&#27425;" "&#33050;&#27880;")
-    ("nl" "Auteur"     "Datum" "Inhoudsopgave" "Voetnoten")
-    ("no" "Forfatter"  "Dato"  "Innhold" "Fotnoter")
-    ("nb" "Forfatter"  "Dato"  "Innhold" "Fotnoter")  ;; nb = Norsk (bokm.l)
-    ("nn" "Forfattar"  "Dato"  "Innhald" "Fotnotar")  ;; nn = Norsk (nynorsk)
-    ("pl" "Autor"      "Data" "Spis tre&#x015b;ci"  "Przypis")
-    ;; Use numeric character entities for proper rendering of non-UTF8 documents
-    ;; ("ru" "Автор"      "Дата"  "Содержание" "Сноски")
-    ("ru" "&#1040;&#1074;&#1090;&#1086;&#1088;"      "&#1044;&#1072;&#1090;&#1072;"  "&#1057;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1077;" "&#1057;&#1085;&#1086;&#1089;&#1082;&#1080;")
-    ("sv" "F&ouml;rfattare" "Datum" "Inneh&aring;ll" "Fotnoter")
-    ;; Use numeric character entities for proper rendering of non-UTF8 documents
-    ;; ("uk" "Автор" "Дата" "Зміст" "Примітки")
-    ("uk" "&#1040;&#1074;&#1090;&#1086;&#1088;" "&#1044;&#1072;&#1090;&#1072;" "&#1047;&#1084;&#1110;&#1089;&#1090;" "&#1055;&#1088;&#1080;&#1084;&#1110;&#1090;&#1082;&#1080;")
-    ;; Use numeric character entities for proper rendering of non-UTF8 documents
-    ;; ("zh-CN" "作者" "日期" "目录" "脚注")
-    ("zh-CN" "&#20316;&#32773;" "&#26085;&#26399;" "&#30446;&#24405;" "&#33050;&#27880;")
-    ;; Use numeric character entities for proper rendering of non-UTF8 documents
-    ;; ("zh-TW" "作者" "日期" "目錄" "腳註")
-    ("zh-TW" "&#20316;&#32773;" "&#26085;&#26399;" "&#30446;&#37636;" "&#33139;&#35387;"))
-  "Terms used in export text, translated to different languages.
-Use the variable `org-export-default-language' to set the language,
-or use the +OPTION lines for a per-file setting."
-  :group 'org-export-general
-  :type '(repeat
-         (list
-          (string :tag "HTML language tag")
-          (string :tag "Author")
-          (string :tag "Date")
-          (string :tag "Table of Contents")
-          (string :tag "Footnotes"))))
-
-(defcustom org-export-default-language "en"
-  "The default language for export and clocktable translations, as a string.
-This should have an association in `org-export-language-setup'
-and in `org-clock-clocktable-language-setup'."
-  :group 'org-export-general
-  :type 'string)
-
-(defcustom org-export-date-timestamp-format "%Y-%m-%d"
-  "Time string format for Org timestamps in the #+DATE option."
-  :group 'org-export-general
-  :version "24.1"
-  :type 'string)
-
-(defvar org-export-page-description ""
-  "The page description, for the XHTML meta tag.
-This is best set with the #+DESCRIPTION line in a file, it does not make
-sense to set this globally.")
-
-(defvar org-export-page-keywords ""
-  "The page description, for the XHTML meta tag.
-This is best set with the #+KEYWORDS line in a file, it does not make
-sense to set this globally.")
-
-(defcustom org-export-skip-text-before-1st-heading nil
-  "Non-nil means skip all text before the first headline when exporting.
-When nil, that text is exported as well."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-headline-levels 3
-  "The last level which is still exported as a headline.
-Inferior levels will produce itemize lists when exported.
-Note that a numeric prefix argument to an exporter function overrides
-this setting.
-
-This option can also be set with the +OPTIONS line, e.g. \"H:2\"."
-  :group 'org-export-general
-  :type 'integer)
-
-(defcustom org-export-with-section-numbers t
-  "Non-nil means add section numbers to headlines when exporting.
-
-This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-section-number-format '((("1" ".")) . "")
-  "Format of section numbers for export.
-The variable has two components.
-1. A list of lists, each indicating a counter type and a separator.
-   The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"i\".
-   It causes causes numeric, alphabetic, or roman counters, respectively.
-   The separator is only used if another counter for a subsection is being
-   added.
-   If there are more numbered section levels than entries in this lists,
-   then the last entry will be reused.
-2. A terminator string that will be added after the entire
-   section number."
-  :group 'org-export-general
-  :type '(cons
-         (repeat
-          (list
-           (string :tag "Counter Type")
-           (string :tag "Separator   ")))
-         (string :tag "Terminator")))
-
-(defcustom org-export-with-toc t
-  "Non-nil means create a table of contents in exported files.
-The TOC contains headlines with levels up to`org-export-headline-levels'.
-When an integer, include levels up to N in the toc, this may then be
-different from `org-export-headline-levels', but it will not be allowed
-to be larger than the number of headline levels.
-When nil, no table of contents is made.
-
-Headlines which contain any TODO items will be marked with \"(*)\" in
-ASCII export, and with red color in HTML output, if the option
-`org-export-mark-todo-in-toc' is set.
-
-In HTML output, the TOC will be clickable.
-
-This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"
-or \"toc:3\"."
-  :group 'org-export-general
-  :type '(choice
-         (const :tag "No Table of Contents" nil)
-         (const :tag "Full Table of Contents" t)
-         (integer :tag "TOC to level")))
-
-(defcustom org-export-mark-todo-in-toc nil
-  "Non-nil means mark TOC lines that contain any open TODO items."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-todo-keywords t
-  "Non-nil means include TODO keywords in export.
-When nil, remove all these keywords from the export."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-tasks t
-  "Non-nil means include TODO items for export.
-This may have the following values:
-t                    include tasks independent of state.
-todo                 include only tasks that are not yet done.
-done                 include only tasks that are already done.
-nil                  remove all tasks before export
-list of TODO kwds    keep only tasks with these keywords"
-  :group 'org-export-general
-  :version "24.1"
-  :type '(choice
-         (const :tag "All tasks" t)
-         (const :tag "No tasks" nil)
-         (const :tag "Not-done tasks" todo)
-         (const :tag "Only done tasks" done)
-         (repeat :tag "Specific TODO keywords"
-                 (string :tag "Keyword"))))
-
-(defcustom org-export-with-priority nil
-  "Non-nil means include priority cookies in export.
-When nil, remove priority cookies for export."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-preserve-breaks nil
-  "Non-nil means preserve all line breaks when exporting.
-Normally, in HTML output paragraphs will be reformatted.  In ASCII
-export, line breaks will always be preserved, regardless of this variable.
-
-This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-archived-trees 'headline
-  "Whether subtrees with the ARCHIVE tag should be exported.
-This can have three different values
-nil       Do not export, pretend this tree is not present
-t         Do export the entire tree
-headline  Only export the headline, but skip the tree below it."
-  :group 'org-export-general
-  :group 'org-archive
-  :type '(choice
-         (const :tag "not at all" nil)
-         (const :tag "headline only" 'headline)
-         (const :tag "entirely" t)))
-
-(defcustom org-export-author-info t
-  "Non-nil means insert author name and email into the exported file.
-
-This option can also be set with the +OPTIONS line,
-e.g. \"author:nil\"."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-email-info nil
-  "Non-nil means insert author name and email into the exported file.
-
-This option can also be set with the +OPTIONS line,
-e.g. \"email:t\"."
-  :group 'org-export-general
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-creator-info t
-  "Non-nil means the postamble should contain a creator sentence.
-This sentence is \"HTML generated by org-mode XX in emacs XXX\"."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-time-stamp-file t
-  "Non-nil means insert a time stamp into the exported file.
-The time stamp shows when the file was created.
-
-This option can also be set with the +OPTIONS line,
-e.g. \"timestamp:nil\"."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-timestamps t
-  "If nil, do not export time stamps and associated keywords."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-remove-timestamps-from-toc t
-  "If t, remove timestamps from the table of contents entries."
-  :group 'org-export-general
-  :type 'boolean)
-
-(defcustom org-export-with-tags 'not-in-toc
-  "If nil, do not export tags, just remove them from headlines.
-If this is the symbol `not-in-toc', tags will be removed from table of
-contents entries, but still be shown in the headlines of the document.
-
-This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"."
-  :group 'org-export-general
-  :type '(choice
-         (const :tag "Off" nil)
-         (const :tag "Not in TOC" not-in-toc)
-         (const :tag "On" t)))
-
-(defcustom org-export-with-drawers nil
-  "Non-nil means export with drawers like the property drawer.
-When t, all drawers are exported.  This may also be a list of
-drawer names to export."
-  :group 'org-export-general
-  :type '(choice
-         (const :tag "All drawers" t)
-         (const :tag "None" nil)
-         (repeat :tag "Selected drawers"
-                 (string :tag "Drawer name"))))
-
-(defvar org-export-first-hook nil
-  "Hook called as the first thing in each exporter.
-Point will be still in the original buffer.
-Good for general initialization")
-
-(defvar org-export-preprocess-hook nil
-  "Hook for preprocessing an export buffer.
-Pretty much the first thing when exporting is running this hook.
-Point will be in a temporary buffer that contains a copy of
-the original buffer, or of the section that is being exported.
-All the other hooks in the org-export-preprocess... category
-also work in that temporary buffer, already modified by various
-stages of the processing.")
-
-(defvar org-export-preprocess-after-include-files-hook nil
-  "Hook for preprocessing an export buffer.
-This is run after the contents of included files have been inserted.")
-
-(defvar org-export-preprocess-after-tree-selection-hook nil
-  "Hook for preprocessing an export buffer.
-This is run after selection of trees to be exported has happened.
-This selection includes tags-based selection, as well as removal
-of commented and archived trees.")
-
-(defvar org-export-preprocess-after-headline-targets-hook nil
-  "Hook for preprocessing export buffer.
-This is run just after the headline targets have been defined and
-the target-alist has been set up.")
-
-(defvar org-export-preprocess-before-selecting-backend-code-hook nil
-  "Hook for preprocessing an export buffer.
-This is run just before backend-specific blocks get selected.")
-
-(defvar org-export-preprocess-after-blockquote-hook nil
-  "Hook for preprocessing an export buffer.
-This is run after blockquote/quote/verse/center have been marked
-with cookies.")
-
-(defvar org-export-preprocess-after-radio-targets-hook nil
-  "Hook for preprocessing an export buffer.
-This is run after radio target processing.")
-
-(defvar org-export-preprocess-before-normalizing-links-hook nil
-  "Hook for preprocessing an export buffer.
-This hook is run before links are normalized.")
-
-(defvar org-export-preprocess-before-backend-specifics-hook nil
-  "Hook run before backend-specific functions are called during preprocessing.")
-
-(defvar org-export-preprocess-final-hook nil
-  "Hook for preprocessing an export buffer.
-This is run as the last thing in the preprocessing buffer, just before
-returning the buffer string to the backend.")
-
-(defgroup org-export-translation nil
-  "Options for translating special ascii sequences for the export backends."
-  :tag "Org Export Translation"
-  :group 'org-export)
-
-(defcustom org-export-with-emphasize t
-  "Non-nil means interpret *word*, /word/, and _word_ as emphasized text.
-If the export target supports emphasizing text, the word will be
-typeset in bold, italic, or underlined, respectively.  Works only for
-single words, but you can say: I *really* *mean* *this*.
-Not all export backends support this.
-
-This option can also be set with the +OPTIONS line, e.g. \"*:nil\"."
-  :group 'org-export-translation
-  :type 'boolean)
-
-(defcustom org-export-with-footnotes t
-  "If nil, export [1] as a footnote marker.
-Lines starting with [1] will be formatted as footnotes.
-
-This option can also be set with the +OPTIONS line, e.g. \"f:nil\"."
-  :group 'org-export-translation
-  :type 'boolean)
-
-(defcustom org-export-with-TeX-macros t
-  "Non-nil means interpret simple TeX-like macros when exporting.
-For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
-Not only real TeX macros will work here, but the standard HTML entities
-for math can be used as macro names as well.  For a list of supported
-names in HTML export, see the constant `org-entities' and the user option
-`org-entities-user'.
-Not all export backends support this.
-
-This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
-  :group 'org-export-translation
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-with-LaTeX-fragments t
-  "Non-nil means process LaTeX math fragments for HTML display.
-When set, the exporter will find and process LaTeX environments if the
-\\begin line is the first non-white thing on a line.  It will also find
-and process the math delimiters like $a=b$ and \\( a=b \\) for inline math,
-$$a=b$$ and \\=\\[ a=b \\] for display math.
-
-This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\".
-
-Allowed values are:
-
-nil             Don't do anything.
-verbatim        Keep everything in verbatim
-dvipng          Process the LaTeX fragments to images.
-                This will also include processing of non-math environments.
-imagemagick     Convert the LaTeX fragments to pdf files and use imagemagick
-                to convert pdf files to png files.
-t               Do MathJax preprocessing if there is at least on math snippet,
-                and arrange for MathJax.js to be loaded.
-
-The default is nil, because this option needs the `dvipng' program which
-is not available on all systems."
-  :group 'org-export-translation
-  :group 'org-export-latex
-  :type '(choice
-         (const :tag "Do not process math in any way" nil)
-         (const :tag "Obsolete, use dvipng setting" t)
-         (const :tag "Use dvipng to make images" dvipng)
-         (const :tag "Use imagemagick to make images" imagemagick)
-         (const :tag "Use MathJax to display math" mathjax)
-         (const :tag "Leave math verbatim" verbatim)))
-
-(defcustom org-export-with-fixed-width t
-  "Non-nil means lines starting with \":\" will be in fixed width font.
-This can be used to have pre-formatted text, fragments of code etc.  For
-example:
-  : ;; Some Lisp examples
-  : (while (defc cnt)
-  :   (ding))
-will be looking just like this in also HTML.  See also the QUOTE keyword.
-Not all export backends support this.
-
-This option can also be set with the +OPTIONS line, e.g. \"::nil\"."
-  :group 'org-export-translation
-  :type 'boolean)
-
-(defgroup org-export-tables nil
-  "Options for exporting tables in Org-mode."
-  :tag "Org Export Tables"
-  :group 'org-export)
-
-(defcustom org-export-with-tables t
-  "If non-nil, lines starting with \"|\" define a table.
-For example:
-
-  | Name        | Address  | Birthday  |
-  |-------------+----------+-----------|
-  | Arthur Dent | England  | 29.2.2100 |
-
-Not all export backends support this.
-
-This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
-  :group 'org-export-tables
-  :type 'boolean)
-
-(defcustom org-export-highlight-first-table-line t
-  "Non-nil means highlight the first table line.
-In HTML export, this means use <th> instead of <td>.
-In tables created with table.el, this applies to the first table line.
-In Org-mode tables, all lines before the first horizontal separator
-line will be formatted with <th> tags."
-  :group 'org-export-tables
-  :type 'boolean)
-
-(defcustom org-export-table-remove-special-lines t
-  "Remove special lines and marking characters in calculating tables.
-This removes the special marking character column from tables that are set
-up for spreadsheet calculations.  It also removes the entire lines
-marked with `!', `_', or `^'.  The lines with `$' are kept, because
-the values of constants may be useful to have."
-  :group 'org-export-tables
-  :type 'boolean)
-
-(defcustom org-export-table-remove-empty-lines t
-  "Remove empty lines when exporting tables.
-This is the global equivalent of the :remove-nil-lines option
-when locally sending a table with #+ORGTBL."
-  :group 'org-export-tables
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-prefer-native-exporter-for-tables nil
-  "Non-nil means always export tables created with table.el natively.
-Natively means use the HTML code generator in table.el.
-When nil, Org-mode's own HTML generator is used when possible (i.e. if
-the table does not use row- or column-spanning).  This has the
-advantage, that the automatic HTML conversions for math symbols and
-sub/superscripts can be applied.  Org-mode's HTML generator is also
-much faster.  The LaTeX exporter always use the native exporter for
-table.el tables."
-  :group 'org-export-tables
-  :type 'boolean)
-
-;;;; Exporting
-
-;;; Variables, constants, and parameter plists
-
-(defconst org-level-max 20)
-
-(defvar org-export-current-backend nil
-  "During export, this will be bound to a symbol such as 'html,
-  'latex, 'docbook, 'ascii, etc, indicating which of the export
-  backends is in use.  Otherwise it has the value nil.  Users
-  should not attempt to change the value of this variable
-  directly, but it can be used in code to test whether export is
-  in progress, and if so, what the backend is.")
-
-(defvar org-current-export-file nil) ; dynamically scoped parameter
-(defvar org-current-export-dir nil) ; dynamically scoped parameter
-(defvar org-export-opt-plist nil
-  "Contains the current option plist.")
-(defvar org-last-level nil) ; dynamically scoped variable
-(defvar org-min-level nil) ; dynamically scoped variable
-(defvar org-levels-open nil) ; dynamically scoped parameter
-(defvar org-export-footnotes-data nil
-  "Alist of labels used in buffers, along with their definition.")
-(defvar org-export-footnotes-seen nil
-  "Alist of labels encountered so far by the exporter, along with their definition.")
-
-
-(defconst org-export-plist-vars
-  '((:link-up                nil         org-export-html-link-up)
-    (:link-home                      nil         org-export-html-link-home)
-    (:language               nil         org-export-default-language)
-    (:keywords               nil         org-export-page-keywords)
-    (:description             nil        org-export-page-description)
-    (:customtime             nil         org-display-custom-times)
-    (:headline-levels        "H"         org-export-headline-levels)
-    (:section-numbers        "num"       org-export-with-section-numbers)
-    (:section-number-format   nil        org-export-section-number-format)
-    (:table-of-contents              "toc"       org-export-with-toc)
-    (:preserve-breaks        "\\n"       org-export-preserve-breaks)
-    (:archived-trees         nil         org-export-with-archived-trees)
-    (:emphasize                      "*"         org-export-with-emphasize)
-    (:sub-superscript        "^"         org-export-with-sub-superscripts)
-    (:special-strings        "-"         org-export-with-special-strings)
-    (:footnotes                      "f"         org-export-with-footnotes)
-    (:drawers                "d"         org-export-with-drawers)
-    (:tags                   "tags"      org-export-with-tags)
-    (:todo-keywords          "todo"      org-export-with-todo-keywords)
-    (:tasks                  "tasks"     org-export-with-tasks)
-    (:priority               "pri"       org-export-with-priority)
-    (:TeX-macros             "TeX"       org-export-with-TeX-macros)
-    (:LaTeX-fragments        "LaTeX"     org-export-with-LaTeX-fragments)
-    (:latex-listings         nil         org-export-latex-listings)
-    (:skip-before-1st-heading "skip"     org-export-skip-text-before-1st-heading)
-    (:fixed-width            ":"         org-export-with-fixed-width)
-    (:timestamps             "<"         org-export-with-timestamps)
-    (:author                 nil         user-full-name)
-    (:email                  nil         user-mail-address)
-    (:author-info            "author"    org-export-author-info)
-    (:email-info             "email"     org-export-email-info)
-    (:creator-info           "creator"   org-export-creator-info)
-    (:time-stamp-file        "timestamp" org-export-time-stamp-file)
-    (:tables                 "|"         org-export-with-tables)
-    (:table-auto-headline     nil        org-export-highlight-first-table-line)
-    (:style-include-default   nil        org-export-html-style-include-default)
-    (:style-include-scripts   nil        org-export-html-style-include-scripts)
-    (:style                  nil         org-export-html-style)
-    (:style-extra            nil         org-export-html-style-extra)
-    (:agenda-style           nil         org-agenda-export-html-style)
-    (:convert-org-links              nil         org-export-html-link-org-files-as-html)
-    (:inline-images          nil         org-export-html-inline-images)
-    (:html-extension         nil         org-export-html-extension)
-    (:html-preamble          nil         org-export-html-preamble)
-    (:html-postamble         nil         org-export-html-postamble)
-    (:xml-declaration         nil        org-export-html-xml-declaration)
-    (:html-table-tag         nil         org-export-html-table-tag)
-    (:expand-quoted-html      "@"        org-export-html-expand)
-    (:timestamp                      nil         org-export-html-with-timestamp)
-    (:publishing-directory    nil        org-export-publishing-directory)
-    (:select-tags            nil         org-export-select-tags)
-    (:exclude-tags           nil         org-export-exclude-tags)
-
-    (:latex-image-options     nil        org-export-latex-image-default-option))
-  "List of properties that represent export/publishing variables.
-Each element is a list of 3 items:
-1. The property that is used internally, and also for org-publish-project-alist
-2. The string that can be used in the OPTION lines to set this option,
-   or nil if this option cannot be changed in this way
-3. The customization variable that sets the default for this option."
-  )
-
-(defun org-default-export-plist ()
-  "Return the property list with default settings for the export variables."
-  (let* ((infile (org-infile-export-plist))
-        (letbind (plist-get infile :let-bind))
-        (l org-export-plist-vars) rtn e s v)
-    (while (setq e (pop l))
-      (setq s (nth 2 e)
-           v (cond
-              ((assq s letbind) (nth 1 (assq s letbind)))
-              ((boundp s) (symbol-value s)))
-           rtn (cons (car e) (cons v rtn))))
-    rtn))
-
-(defvar org-export-inbuffer-options-extra nil
-  "List of additional in-buffer options that should be detected.
-Just before export, the buffer is scanned for options like #+TITLE, #+EMAIL,
-etc.  Extensions can add to this list to get their options detected, and they
-can then add a function to `org-export-options-filters' to process these
-options.
-Each element in this list must be a list, with the in-buffer keyword as car,
-and a property (a symbol) as the next element.  All occurrences of the
-keyword will be found, the values concatenated with a space character
-in between, and the result stored in the export options property list.")
-
-(defvar org-export-options-filters nil
-  "Functions to be called to finalize the export/publishing options.
-All these options are stored in a property list, and each of the functions
-in this hook gets a chance to modify this property list.  Each function
-must accept the property list as an argument, and must return the (possibly
-modified) list.")
-
-;; FIXME: should we fold case here?
-
-(defun org-infile-export-plist ()
-  "Return the property list with file-local settings for export."
-  (save-excursion
-    (save-restriction
-      (widen)
-      (goto-char (point-min))
-      (let ((re (org-make-options-regexp
-                (append
-                 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
-                   "MATHJAX"
-                   "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE"
-                   "LATEX_HEADER" "LATEX_CLASS" "LATEX_CLASS_OPTIONS"
-                   "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS"
-                   "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT")
-                 (mapcar 'car org-export-inbuffer-options-extra))))
-           (case-fold-search t)
-           p key val text options mathjax a pr style
-           latex-header latex-class latex-class-options macros letbind
-           ext-setup-or-nil setup-file setup-dir setup-contents (start 0))
-       (while (or (and ext-setup-or-nil
-                       (string-match re ext-setup-or-nil start)
-                       (setq start (match-end 0)))
-                  (and (setq ext-setup-or-nil nil start 0)
-                       (re-search-forward re nil t)))
-         (setq key (upcase (org-match-string-no-properties 1 ext-setup-or-nil))
-               val (org-match-string-no-properties 2 ext-setup-or-nil))
-         (cond
-          ((setq a (assoc key org-export-inbuffer-options-extra))
-           (setq pr (nth 1 a))
-           (setq p (plist-put p pr (concat (plist-get p pr) " " val))))
-          ((string-equal key "TITLE") (setq p (plist-put p :title val)))
-          ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
-          ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
-          ((string-equal key "DATE")
-           ;; If date is an Org timestamp, convert it to a time
-           ;; string using `org-export-date-timestamp-format'
-           (when (string-match org-ts-regexp3 val)
-             (setq val (format-time-string
-                        org-export-date-timestamp-format
-                        (apply 'encode-time (org-parse-time-string
-                                             (match-string 0 val))))))
-           (setq p (plist-put p :date val)))
-          ((string-equal key "KEYWORDS") (setq p (plist-put p :keywords val)))
-          ((string-equal key "DESCRIPTION")
-           (setq p (plist-put p :description val)))
-          ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
-          ((string-equal key "STYLE")
-           (setq style (concat style "\n" val)))
-          ((string-equal key "LATEX_HEADER")
-           (setq latex-header (concat latex-header "\n" val)))
-          ((string-equal key "LATEX_CLASS")
-           (setq latex-class val))
-           ((string-equal key "LATEX_CLASS_OPTIONS")
-            (setq latex-class-options val))
-          ((string-equal key "TEXT")
-           (setq text (if text (concat text "\n" val) val)))
-          ((string-equal key "OPTIONS")
-           (setq options (concat val " " options)))
-          ((string-equal key "MATHJAX")
-           (setq mathjax (concat val " " mathjax)))
-          ((string-equal key "BIND")
-           (push (read (concat "(" val ")")) letbind))
-          ((string-equal key "XSLT")
-           (setq p (plist-put p :xslt val)))
-          ((string-equal key "LINK_UP")
-           (setq p (plist-put p :link-up val)))
-          ((string-equal key "LINK_HOME")
-           (setq p (plist-put p :link-home val)))
-          ((string-equal key "EXPORT_SELECT_TAGS")
-           (setq p (plist-put p :select-tags (org-split-string val))))
-          ((string-equal key "EXPORT_EXCLUDE_TAGS")
-           (setq p (plist-put p :exclude-tags (org-split-string val))))
-          ((string-equal key "MACRO")
-           (push val macros))
-          ((equal key "SETUPFILE")
-           (setq setup-file (org-remove-double-quotes (org-trim val))
-                 ;; take care of recursive inclusion of setupfiles
-                 setup-file (if (or (file-name-absolute-p val) (not setup-dir))
-                                (expand-file-name setup-file)
-                              (let ((default-directory setup-dir))
-                                (expand-file-name setup-file))))
-           (setq setup-dir (file-name-directory setup-file))
-           (setq setup-contents (org-file-contents setup-file 'noerror))
-           (if (not ext-setup-or-nil)
-               (setq ext-setup-or-nil setup-contents start 0)
-             (setq ext-setup-or-nil
-                   (concat (substring ext-setup-or-nil 0 start)
-                           "\n" setup-contents "\n"
-                           (substring ext-setup-or-nil start)))))))
-       (setq p (plist-put p :text text))
-       (when (and letbind (org-export-confirm-letbind))
-         (setq p (plist-put p :let-bind letbind)))
-       (when style (setq p (plist-put p :style-extra style)))
-       (when latex-header
-         (setq p (plist-put p :latex-header-extra (substring latex-header 1))))
-       (when latex-class
-         (setq p (plist-put p :latex-class latex-class)))
-        (when latex-class-options
-          (setq p (plist-put p :latex-class-options latex-class-options)))
-       (when options
-         (setq p (org-export-add-options-to-plist p options)))
-       (when mathjax
-         (setq p (plist-put p :mathjax mathjax)))
-       ;; Add macro definitions
-       (setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))"))
-       (setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))"))
-       (setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\" 'selective))"))
-       (setq p (plist-put
-                p :macro-modification-time
-                (and (buffer-file-name)
-                     (file-exists-p (buffer-file-name))
-                     (concat
-                      "(eval (format-time-string \"$1\" '"
-                      (prin1-to-string (nth 5 (file-attributes
-                                               (buffer-file-name))))
-                      "))"))))
-       (setq p (plist-put p :macro-input-file (and (buffer-file-name)
-                                                   (file-name-nondirectory
-                                                    (buffer-file-name)))))
-       (while (setq val (pop macros))
-         (when (string-match "^\\([-a-zA-Z0-9_]+\\)[ \t]+\\(.*?[ \t]*$\\)" val)
-           (setq p (plist-put
-                    p (intern
-                       (concat ":macro-" (downcase (match-string 1 val))))
-                    (org-export-interpolate-newlines (match-string 2 val))))))
-       p))))
-
-(defun org-export-interpolate-newlines (s)
-  (while (string-match "\\\\n" s)
-    (setq s (replace-match "\n" t t s)))
-  s)
-
-(defvar org-export-allow-BIND-local nil)
-(defun org-export-confirm-letbind ()
-  "Can we use #+BIND values during export?
-By default this will ask for confirmation by the user, to divert possible
-security risks."
-  (cond
-   ((not org-export-allow-BIND) nil)
-   ((eq org-export-allow-BIND t) t)
-   ((local-variable-p 'org-export-allow-BIND-local (current-buffer))
-    org-export-allow-BIND-local)
-   (t (org-set-local 'org-export-allow-BIND-local
-                    (yes-or-no-p "Allow BIND values in this buffer? ")))))
-
-(defun org-install-letbind ()
-  "Install the values from #+BIND lines as local variables."
-  (let ((letbind (plist-get org-export-opt-plist :let-bind))
-       pair)
-    (while (setq pair (pop letbind))
-      (org-set-local (car pair) (nth 1 pair)))))
-
-(defun org-export-add-options-to-plist (p options)
-  "Parse an OPTIONS line and set values in the property list P."
-  (let (o)
-    (when options
-      (let ((op org-export-plist-vars))
-       (while (setq o (pop op))
-         (if (and (nth 1 o)
-                  (string-match (concat "\\(\\`\\|[ \t]\\)"
-                                        (regexp-quote (nth 1 o))
-                                        ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)")
-                                options))
-             (setq p (plist-put p (car o)
-                                (car (read-from-string
-                                      (match-string 2 options))))))))))
-  p)
-
-(defun org-export-add-subtree-options (p pos)
-  "Add options in subtree at position POS to property list P."
-  (save-excursion
-    (goto-char pos)
-    (when (org-at-heading-p)
-      (let (a)
-       ;; This is actually read in `org-export-get-title-from-subtree'
-       ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
-       ;;   (setq p (plist-put p :title a)))
-       (when (setq a (org-entry-get pos "EXPORT_TEXT"))
-         (setq p (plist-put p :text a)))
-       (when (setq a (org-entry-get pos "EXPORT_AUTHOR"))
-         (setq p (plist-put p :author a)))
-       (when (setq a (org-entry-get pos "EXPORT_DATE"))
-         (setq p (plist-put p :date a)))
-       (when (setq a (org-entry-get pos "EXPORT_OPTIONS"))
-         (setq p (org-export-add-options-to-plist p a)))))
-    p))
-
-(defun org-export-directory (type plist)
-  (let* ((val (plist-get plist :publishing-directory))
-        (dir (if (listp val)
-                 (or (cdr (assoc type val)) ".")
-               val)))
-    dir))
-
-(defun org-export-process-option-filters (plist)
-  (let ((functions org-export-options-filters) f)
-    (while (setq f (pop functions))
-      (setq plist (funcall f plist))))
-  plist)
-
-;;;###autoload
-(defun org-export (&optional arg)
-  "Export dispatcher for Org-mode.
-When `org-export-run-in-background' is non-nil, try to run the command
-in the background.  This will be done only for commands that write
-to a file.  For details see the docstring of `org-export-run-in-background'.
-
-The prefix argument ARG will be passed to the exporter.  However, if
-ARG is a double universal prefix \\[universal-argument] \\[universal-argument], \
-that means to inverse the
-value of `org-export-run-in-background'.
-
-If `org-export-initial-scope' is set to 'subtree, try to export
-the current subtree, otherwise try to export the whole buffer.
-Pressing `1' will switch between these two options."
-  (interactive "P")
-  (let* ((bg (org-xor (equal arg '(16)) org-export-run-in-background))
-        (subtree-p (or (org-region-active-p)
-                       (eq org-export-initial-scope 'subtree)))
-        (regb (and (org-region-active-p) (region-beginning)))
-        (rege (and (org-region-active-p) (region-end)))
-        (help "[t]   insert the export option template
-\[v]   limit export to visible part of outline tree
-\[1]   switch buffer/subtree export
-\[SPC] publish enclosing subtree (with LaTeX_CLASS or EXPORT_FILE_NAME prop)
-
-\[a/n/u] export as ASCII/Latin-1/UTF-8         [A/N/U] to temporary buffer
-
-\[h] export as HTML      [H] to temporary buffer   [R] export region
-\[b] export as HTML and open in browser
-
-\[l] export as LaTeX     [L] to temporary buffer
-\[p] export as LaTeX and process to PDF            [d] ... and open PDF file
-
-\[D] export as DocBook   [V] export as DocBook, process to PDF, and open
-
-\[o] export as OpenDocument Text                   [O] ... and open
-
-\[j] export as TaskJuggler                         [J] ... and open
-
-\[m] export as Freemind mind map
-\[x] export as XOXO
-\[g] export using Wes Hardaker's generic exporter
-
-\[i] export current file as iCalendar file
-\[I] export all agenda files as iCalendar files   [c] ...as one combined file
-
-\[F] publish current file          [P] publish current project
-\[X] publish a project...          [E] publish every projects")
-        (cmds
-         '((?t org-insert-export-options-template nil)
-           (?v org-export-visible nil)
-           (?a org-export-as-ascii t)
-           (?A org-export-as-ascii-to-buffer t)
-           (?n org-export-as-latin1 t)
-           (?N org-export-as-latin1-to-buffer t)
-           (?u org-export-as-utf8 t)
-           (?U org-export-as-utf8-to-buffer t)
-           (?h org-export-as-html t)
-           (?b org-export-as-html-and-open t)
-           (?H org-export-as-html-to-buffer nil)
-           (?R org-export-region-as-html nil)
-           (?x org-export-as-xoxo t)
-           (?g org-export-generic t)
-           (?D org-export-as-docbook t)
-           (?V org-export-as-docbook-pdf-and-open t)
-           (?o org-export-as-odt t)
-           (?O org-export-as-odt-and-open t)
-           (?j org-export-as-taskjuggler t)
-           (?J org-export-as-taskjuggler-and-open t)
-           (?m org-export-as-freemind t)
-           (?l org-export-as-latex t)
-           (?p org-export-as-pdf t)
-           (?d org-export-as-pdf-and-open t)
-           (?L org-export-as-latex-to-buffer nil)
-           (?i org-export-icalendar-this-file t)
-           (?I org-export-icalendar-all-agenda-files t)
-           (?c org-export-icalendar-combine-agenda-files t)
-           (?F org-publish-current-file t)
-           (?P org-publish-current-project t)
-           (?X org-publish t)
-           (?E org-publish-all t)))
-        r1 r2 ass
-        (cpos (point)) (cbuf (current-buffer)) bpos)
-    (save-excursion
-      (save-window-excursion
-       (if subtree-p
-           (message "Export subtree: ")
-         (message "Export buffer: "))
-       (delete-other-windows)
-       (with-output-to-temp-buffer "*Org Export/Publishing Help*"
-         (princ help))
-       (org-fit-window-to-buffer (get-buffer-window
-                                  "*Org Export/Publishing Help*"))
-       (while (eq (setq r1 (read-char-exclusive)) ?1)
-         (cond (subtree-p
-                (setq subtree-p nil)
-                (message "Export buffer: "))
-               ((not subtree-p)
-                (setq subtree-p t)
-                (setq bpos (point))
-                (org-mark-subtree)
-                (org-activate-mark)
-                (setq regb (and (org-region-active-p) (region-beginning)))
-                (setq rege (and (org-region-active-p) (region-end)))
-                (message "Export subtree: "))))
-       (when (eq r1 ?\ )
-         (let ((case-fold-search t)
-               (end (save-excursion (while (org-up-heading-safe)) (point))))
-           (outline-next-heading)
-           (if (re-search-backward
-                "^[ \t]+\\(:latex_class:\\|:export_title:\\|:export_file_name:\\)[ \t]+\\S-"
-                end t)
-               (progn
-                 (org-back-to-heading t)
-                 (setq subtree-p t)
-                 (setq bpos (point))
-                 (message "Select command (for subtree): ")
-                 (setq r1 (read-char-exclusive)))
-             (error "No enclosing node with LaTeX_CLASS or EXPORT_TITLE or EXPORT_FILE_NAME")
-             )))))
-    (if (fboundp 'redisplay) (redisplay)) ;; XEmacs does not have/need (redisplay)
-    (and bpos (goto-char bpos))
-    (setq r2 (if (< r1 27) (+ r1 96) r1))
-    (unless (setq ass (assq r2 cmds))
-      (error "No command associated with key %c" r1))
-    (if (and bg (nth 2 ass)
-            (not (buffer-base-buffer))
-            (not (org-region-active-p)))
-       ;; execute in background
-       (let ((p (start-process
-                 (concat "Exporting " (file-name-nondirectory (buffer-file-name)))
-                 "*Org Processes*"
-                 (expand-file-name invocation-name invocation-directory)
-                 "-batch"
-                 "-l" user-init-file
-                 "--eval" "(require 'org-exp)"
-                 "--eval" "(setq org-wait .2)"
-                 (buffer-file-name)
-                 "-f" (symbol-name (nth 1 ass)))))
-         (set-process-sentinel p 'org-export-process-sentinel)
-         (message "Background process \"%s\": started" p))
-      ;; set the mark correctly when exporting a subtree
-      (if subtree-p (let (deactivate-mark) (push-mark rege t t) (goto-char regb)))
-
-      (call-interactively (nth 1 ass))
-      (when (and bpos (get-buffer-window cbuf))
-       (let ((cw (selected-window)))
-         (select-window (get-buffer-window cbuf))
-         (goto-char cpos)
-         (deactivate-mark)
-         (select-window cw))))))
-
-(defun org-export-process-sentinel (process status)
-  (if (string-match "\n+\\'" status)
-      (setq status (substring status 0 -1)))
-  (message "Background process \"%s\": %s" process status))
-
-;;; General functions for all backends
-
-(defvar org-export-target-aliases nil
-  "Alist of targets with invisible aliases.")
-(defvar org-export-preferred-target-alist nil
-  "Alist of section id's with preferred aliases.")
-(defvar org-export-id-target-alist nil
-  "Alist of section id's with preferred aliases.")
-(defvar org-export-code-refs nil
-  "Alist of code references and line numbers.")
-
-(defun org-export-preprocess-string (string &rest parameters)
-  "Cleanup STRING so that the true exported has a more consistent source.
-This function takes STRING, which should be a buffer-string of an org-file
-to export.  It then creates a temporary buffer where it does its job.
-The result is then again returned as a string, and the exporter works
-on this string to produce the exported version."
-  (interactive)
-  (let* ((org-export-current-backend (or (plist-get parameters :for-backend)
-                                        org-export-current-backend))
-        (archived-trees (plist-get parameters :archived-trees))
-        (inhibit-read-only t)
-        (drawers org-drawers)
-        (source-buffer (current-buffer))
-        target-alist rtn)
-
-    (setq org-export-target-aliases nil
-         org-export-preferred-target-alist nil
-         org-export-id-target-alist nil
-         org-export-code-refs nil)
-
-    (with-temp-buffer
-      (erase-buffer)
-      (insert string)
-      (setq case-fold-search t)
-
-      (let ((inhibit-read-only t))
-       (remove-text-properties (point-min) (point-max)
-                               '(read-only t)))
-
-      ;; Remove license-to-kill stuff
-      ;; The caller marks some stuff for killing, stuff that has been
-      ;; used to create the page title, for example.
-      (org-export-kill-licensed-text)
-
-      (let ((org-inhibit-startup t)) (org-mode))
-      (setq case-fold-search t)
-      (org-clone-local-variables source-buffer "^\\(org-\\|orgtbl-\\)")
-      (org-install-letbind)
-
-      ;; Call the hook
-      (run-hooks 'org-export-preprocess-hook)
-
-      (untabify (point-min) (point-max))
-
-      ;; Handle include files, and call a hook
-      (org-export-handle-include-files-recurse)
-      (run-hooks 'org-export-preprocess-after-include-files-hook)
-
-      ;; Get rid of archived trees
-      (org-export-remove-archived-trees archived-trees)
-
-      ;; Remove comment environment and comment subtrees
-      (org-export-remove-comment-blocks-and-subtrees)
-
-      ;; Get rid of excluded trees, and call a hook
-      (org-export-handle-export-tags (plist-get parameters :select-tags)
-                                    (plist-get parameters :exclude-tags))
-      (run-hooks 'org-export-preprocess-after-tree-selection-hook)
-
-      ;; Get rid of tasks, depending on configuration
-      (org-export-remove-tasks (plist-get parameters :tasks))
-
-      ;; Prepare footnotes for export.  During that process, footnotes
-      ;; actually included in the exported part of the buffer go
-      ;; though some transformations:
-
-      ;; 1. They have their label normalized (like "[N]");
-
-      ;; 2. They get moved at the same place in the buffer (usually at
-      ;;    its end, but backends may define another place via
-      ;;    `org-footnote-insert-pos-for-preprocessor');
-
-      ;; 3. The are stored in `org-export-footnotes-seen', while
-      ;;    `org-export-preprocess-string' is applied to their
-      ;;    definition.
-
-      ;; Line-wise exporters ignore `org-export-footnotes-seen', as
-      ;; they interpret footnotes at the moment they see them in the
-      ;; buffer.  Context-wise exporters grab all the info needed in
-      ;; that variable and delete moved definitions (as described in
-      ;; 2nd step).
-      (when (plist-get parameters :footnotes)
-       (org-footnote-normalize nil parameters))
-
-      ;; Change lists ending.  Other parts of export may insert blank
-      ;; lines and lists' structure could be altered.
-      (org-export-mark-list-end)
-
-      ;; Process the macros
-      (org-export-preprocess-apply-macros)
-      (run-hooks 'org-export-preprocess-after-macros-hook)
-
-      ;; Export code blocks
-      (org-export-blocks-preprocess)
-
-      ;; Mark lists with properties
-      (org-export-mark-list-properties)
-
-      ;; Handle source code snippets
-      (org-export-replace-src-segments-and-examples)
-
-      ;; Protect short examples marked by a leading colon
-      (org-export-protect-colon-examples)
-
-      ;; Protected spaces
-      (org-export-convert-protected-spaces)
-
-      ;; Find all headings and compute the targets for them
-      (setq target-alist (org-export-define-heading-targets target-alist))
-
-      (run-hooks 'org-export-preprocess-after-headline-targets-hook)
-
-      ;; Find HTML special classes for headlines
-      (org-export-remember-html-container-classes)
-
-      ;; Get rid of drawers
-      (org-export-remove-or-extract-drawers
-       drawers (plist-get parameters :drawers))
-
-      ;; Get the correct stuff before the first headline
-      (when (plist-get parameters :skip-before-1st-heading)
-       (goto-char (point-min))
-       (when (re-search-forward "^\\(#.*\n\\)?\\*+[ \t]" nil t)
-         (delete-region (point-min) (match-beginning 0))
-         (goto-char (point-min))
-         (insert "\n")))
-      (when (plist-get parameters :add-text)
-       (goto-char (point-min))
-       (insert (plist-get parameters :add-text) "\n"))
-
-      ;; Remove todo-keywords before exporting, if the user has requested so
-      (org-export-remove-headline-metadata parameters)
-
-      ;; Find targets in comments and move them out of comments,
-      ;; but mark them as targets that should be invisible
-      (setq target-alist (org-export-handle-invisible-targets target-alist))
-
-      ;; Select and protect backend specific stuff, throw away stuff
-      ;; that is specific for other backends
-      (run-hooks 'org-export-preprocess-before-selecting-backend-code-hook)
-      (org-export-select-backend-specific-text)
-
-      ;; Protect quoted subtrees
-      (org-export-protect-quoted-subtrees)
-
-      ;; Remove clock lines
-      (org-export-remove-clock-lines)
-
-      ;; Protect verbatim elements
-      (org-export-protect-verbatim)
-
-      ;; Blockquotes, verse, and center
-      (org-export-mark-blockquote-verse-center)
-      (run-hooks 'org-export-preprocess-after-blockquote-hook)
-
-      ;; Remove timestamps, if the user has requested so
-      (unless (plist-get parameters :timestamps)
-       (org-export-remove-timestamps))
-
-      ;; Attach captions to the correct object
-      (setq target-alist (org-export-attach-captions-and-attributes target-alist))
-
-      ;; Find matches for radio targets and turn them into internal links
-      (org-export-mark-radio-links)
-      (run-hooks 'org-export-preprocess-after-radio-targets-hook)
-
-      ;; Find all links that contain a newline and put them into a single line
-      (org-export-concatenate-multiline-links)
-
-      ;; Normalize links: Convert angle and plain links into bracket links
-      ;; and expand link abbreviations
-      (run-hooks 'org-export-preprocess-before-normalizing-links-hook)
-      (org-export-normalize-links)
-
-      ;; Find all internal links.  If they have a fuzzy match (i.e. not
-      ;; a *dedicated* target match, let the link  point to the
-      ;; corresponding section.
-      (org-export-target-internal-links target-alist)
-
-      ;; Find multiline emphasis and put them into single line
-      (when (plist-get parameters :emph-multiline)
-       (org-export-concatenate-multiline-emphasis))
-
-      ;; Remove special table lines, and store alignment information
-      (org-store-forced-table-alignment)
-      (when org-export-table-remove-special-lines
-       (org-export-remove-special-table-lines))
-
-      ;; Another hook
-      (run-hooks 'org-export-preprocess-before-backend-specifics-hook)
-
-      ;; Backend-specific preprocessing
-      (let* ((backend-name (symbol-name org-export-current-backend))
-            (f (intern (format "org-export-%s-preprocess" backend-name))))
-       (require (intern (concat "org-" backend-name)) nil)
-       (funcall f parameters))
-
-      ;; Remove or replace comments
-      (org-export-handle-comments (plist-get parameters :comments))
-
-      ;; Remove #+TBLFM #+TBLNAME #+NAME #+RESULTS lines
-      (org-export-handle-metalines)
-
-      ;; Run the final hook
-      (run-hooks 'org-export-preprocess-final-hook)
-
-      (setq rtn (buffer-string)))
-    rtn))
-
-(defun org-export-kill-licensed-text ()
-  "Remove all text that is marked with a :org-license-to-kill property."
-  (let (p)
-    (while (setq p (text-property-any (point-min) (point-max)
-                                     :org-license-to-kill t))
-      (delete-region
-       p (or (next-single-property-change p :org-license-to-kill)
-            (point-max))))))
-
-(defvar org-export-define-heading-targets-headline-hook nil
-  "Hook that is run when a headline was matched during target search.
-This is part of the preprocessing for export.")
-
-(defun org-export-define-heading-targets (target-alist)
-  "Find all headings and define the targets for them.
-The new targets are added to TARGET-ALIST, which is also returned.
-Also find all ID and CUSTOM_ID properties and store them."
-  (goto-char (point-min))
-  (org-init-section-numbers)
-  (let ((re (concat "^" org-outline-regexp
-                   "\\|"
-                   "^[ \t]*:\\(ID\\|CUSTOM_ID\\):[ \t]*\\([^ \t\r\n]+\\)"))
-       level target last-section-target a id)
-    (while (re-search-forward re nil t)
-      (org-if-unprotected-at (match-beginning 0)
-       (if (match-end 2)
-           (progn
-             (setq id (org-match-string-no-properties 2))
-             (push (cons id target) target-alist)
-             (setq a (or (assoc last-section-target org-export-target-aliases)
-                         (progn
-                           (push (list last-section-target)
-                                 org-export-target-aliases)
-                           (car org-export-target-aliases))))
-             (push (caar target-alist) (cdr a))
-             (when (equal (match-string 1) "CUSTOM_ID")
-               (if (not (assoc last-section-target
-                               org-export-preferred-target-alist))
-                   (push (cons last-section-target id)
-                         org-export-preferred-target-alist)))
-             (when (equal (match-string 1) "ID")
-               (if (not (assoc last-section-target
-                               org-export-id-target-alist))
-                   (push (cons last-section-target (concat "ID-" id))
-                         org-export-id-target-alist))))
-         (setq level (org-reduced-level
-                      (save-excursion (goto-char (point-at-bol))
-                                      (org-outline-level))))
-         (setq target (org-solidify-link-text
-                       (format "sec-%s" (replace-regexp-in-string
-                                         "\\." "-"
-                                         (org-section-number level)))))
-         (setq last-section-target target)
-         (push (cons target target) target-alist)
-         (add-text-properties
-          (point-at-bol) (point-at-eol)
-          (list 'target target))
-         (run-hooks 'org-export-define-heading-targets-headline-hook)))))
-  target-alist)
-
-(defun org-export-handle-invisible-targets (target-alist)
-  "Find targets in comments and move them out of comments.
-Mark them as invisible targets."
-  (let (target tmp a)
-    (goto-char (point-min))
-    (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
-      ;; Check if the line before or after is a headline with a target
-      (if (setq target (or (get-text-property (point-at-bol 0) 'target)
-                          (get-text-property (point-at-bol 2) 'target)))
-         (progn
-           ;; use the existing target in a neighboring line
-           (setq tmp (match-string 2))
-           (replace-match "")
-           (and (looking-at "\n") (delete-char 1))
-           (push (cons (setq tmp (org-solidify-link-text tmp)) target)
-                 target-alist)
-           (setq a (or (assoc target org-export-target-aliases)
-                       (progn
-                         (push (list target) org-export-target-aliases)
-                         (car org-export-target-aliases))))
-           (push tmp (cdr a)))
-       ;; Make an invisible target
-       (replace-match "\\1(INVISIBLE)"))))
-  target-alist)
-
-(defun org-export-target-internal-links (target-alist)
-  "Find all internal links and assign targets to them.
-If a link has a fuzzy match (i.e. not a *dedicated* target match),
-let the link  point to the corresponding section.
-This function also handles the id links, if they have a match in
-the current file."
-  (goto-char (point-min))
-  (while (re-search-forward org-bracket-link-regexp nil t)
-    (org-if-unprotected-at (1+ (match-beginning 0))
-      (let* ((org-link-search-must-match-exact-headline t)
-            (md (match-data))
-            (desc (match-end 2))
-            (link (org-link-unescape (match-string 1)))
-            (slink (org-solidify-link-text link))
-            found props pos cref
-            (target
-             (cond
-              ((= (string-to-char link) ?#)
-               ;; user wants exactly this link
-               link)
-              ((cdr (assoc slink target-alist))
-               (or (cdr (assoc (assoc slink target-alist)
-                               org-export-preferred-target-alist))
-                   (cdr (assoc slink target-alist))))
-              ((and (string-match "^id:" link)
-                    (cdr (assoc (substring link 3) target-alist))))
-              ((string-match "^(\\(.*\\))$" link)
-               (setq cref (match-string 1 link))
-               (concat "coderef:" cref))
-              ((string-match org-link-types-re link) nil)
-              ((or (file-name-absolute-p link)
-                   (string-match "^\\." link))
-               nil)
-              (t
-               (let ((org-link-search-inhibit-query t))
-                 (save-excursion
-                   (setq found (condition-case nil (org-link-search link)
-                                 (error nil)))
-                   (when (and found
-                              (or (org-at-heading-p)
-                                  (not (eq found 'dedicated))))
-                     (or (get-text-property (point) 'target)
-                         (get-text-property
-                          (max (point-min)
-                               (1- (or (previous-single-property-change
-                                        (point) 'target) 0)))
-                          'target)))))))))
-       (when target
-         (set-match-data md)
-         (goto-char (match-beginning 1))
-         (setq props (text-properties-at (point)))
-         (delete-region (match-beginning 1) (match-end 1))
-         (setq pos (point))
-         (insert target)
-         (unless desc (insert "][" link))
-         (add-text-properties pos (point) props))))))
-
-(defun org-export-remember-html-container-classes ()
-  "Store the HTML_CONTAINER_CLASS properties in a text property."
-  (goto-char (point-min))
-  (let (class)
-    (while (re-search-forward
-           "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t)
-      (setq class (match-string 1))
-      (save-excursion
-       (when (re-search-backward "^\\*" (point-min) t)
-         (org-back-to-heading t)
-         (put-text-property (point-at-bol) (point-at-eol)
-                            'html-container-class class))))))
-
-(defvar org-export-format-drawer-function nil
-  "Function to be called to format the contents of a drawer.
-The function must accept two parameters:
-  NAME     the drawer name, like \"PROPERTIES\"
-  CONTENT  the content of the drawer.
-You can check the export backend through `org-export-current-backend'.
-The function should return the text to be inserted into the buffer.
-If this is nil, `org-export-format-drawer' is used as a default.")
-
-(defun org-export-remove-or-extract-drawers (all-drawers exp-drawers)
-  "Remove drawers, or extract and format the content.
-ALL-DRAWERS is a list of all drawer names valid in the current buffer.
-EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
-whose content to keep.  Any drawers that are in ALL-DRAWERS but not in
-EXP-DRAWERS will be removed."
-  (goto-char (point-min))
-  (let ((re (concat "^[ \t]*:\\("
-                   (mapconcat 'identity all-drawers "\\|")
-                   "\\):[ \t]*$"))
-       name beg beg-content eol content)
-    (while (re-search-forward re nil t)
-      (org-if-unprotected
-       (setq name (match-string 1))
-       (setq beg (match-beginning 0)
-            beg-content (1+ (point-at-eol))
-            eol (point-at-eol))
-       (if (not (and (re-search-forward
-                     "^\\([ \t]*:END:[ \t]*\n?\\)\\|^\\*+[ \t]" nil t)
-                    (match-end 1)))
-          (goto-char eol)
-        (goto-char (match-beginning 0))
-        (and (looking-at ".*\n?") (replace-match ""))
-        (setq content (buffer-substring beg-content (point)))
-        (delete-region beg (point))
-        (when (or (eq exp-drawers t)
-                  (member name exp-drawers))
-          (setq content (funcall (or org-export-format-drawer-function
-                                     'org-export-format-drawer)
-                                 name content))
-          (insert content)))))))
-
-(defun org-export-format-drawer (name content)
-  "Format the content of a drawer as a colon example."
-  (if (string-match "[ \t]+\\'" content)
-      (setq content (substring content (match-beginning 0))))
-  (while (string-match "\\`[ \t]*\n" content)
-    (setq content (substring content (match-end 0))))
-  (setq content (org-remove-indentation content))
-  (setq content (concat ": " (mapconcat 'identity
-                                       (org-split-string content "\n")
-                                       "\n: ")
-                       "\n"))
-  (setq content (concat " : " (upcase name) "\n" content))
-  (org-add-props content nil 'org-protected t))
-
-(defun org-export-handle-export-tags (select-tags exclude-tags)
-  "Modify the buffer, honoring SELECT-TAGS and EXCLUDE-TAGS.
-Both arguments are lists of tags.
-If any of SELECT-TAGS is found, all trees not marked by a SELECT-TAG
-will be removed.
-After that, all subtrees that are marked by EXCLUDE-TAGS will be
-removed as well."
-  (remove-text-properties (point-min) (point-max) '(:org-delete t))
-  (let* ((re-sel (concat ":\\(" (mapconcat 'regexp-quote
-                                          select-tags "\\|")
-                        "\\):"))
-        (re-excl (concat ":\\(" (mapconcat 'regexp-quote
-                                           exclude-tags "\\|")
-                         "\\):"))
-        beg end cont)
-    (goto-char (point-min))
-    (when (and select-tags
-              (re-search-forward
-               (concat "^\\*+[ \t].*" re-sel "[^ \t\n]*[ \t]*$") nil t))
-      ;; At least one tree is marked for export, this means
-      ;; all the unmarked stuff needs to go.
-      ;; Dig out the trees that should be exported
-      (goto-char (point-min))
-      (outline-next-heading)
-      (setq beg (point))
-      (put-text-property beg (point-max) :org-delete t)
-      (while (re-search-forward re-sel nil t)
-       (when (org-at-heading-p)
-         (org-back-to-heading)
-         (remove-text-properties
-          (max (1- (point)) (point-min))
-          (setq cont (save-excursion (org-end-of-subtree t t)))
-          '(:org-delete t))
-         (while (and (org-up-heading-safe)
-                     (get-text-property (point) :org-delete))
-           (remove-text-properties (max (1- (point)) (point-min))
-                                   (point-at-eol) '(:org-delete t)))
-         (goto-char cont))))
-    ;; Remove the trees explicitly marked for noexport
-    (when exclude-tags
-      (goto-char (point-min))
-      (while (re-search-forward re-excl nil t)
-       (when (org-at-heading-p)
-         (org-back-to-heading t)
-         (setq beg (point))
-         (org-end-of-subtree t t)
-         (delete-region beg (point))
-         (when (featurep 'org-inlinetask)
-           (org-inlinetask-remove-END-maybe)))))
-    ;; Remove everything that is now still marked for deletion
-    (goto-char (point-min))
-    (while (setq beg (text-property-any (point-min) (point-max) :org-delete t))
-      (setq end (or (next-single-property-change beg :org-delete)
-                   (point-max)))
-      (delete-region beg end))))
-
-(defun org-export-remove-tasks (keep)
-  "Remove tasks depending on configuration.
-When KEEP is nil, remove all tasks.
-When KEEP is `todo', remove the tasks that are DONE.
-When KEEP is `done', remove the tasks that are not yet done.
-When it is a list of strings, keep only tasks with these TODO keywords."
-  (when (or (listp keep) (memq keep '(todo done nil)))
-    (let ((re (concat "^\\*+[ \t]+\\("
-                     (mapconcat
-                      'regexp-quote
-                      (cond ((not keep) org-todo-keywords-1)
-                            ((eq keep 'todo) org-done-keywords)
-                            ((eq keep 'done) org-not-done-keywords)
-                            ((listp keep)
-                             (org-delete-all keep (copy-sequence
-                                                   org-todo-keywords-1))))
-                      "\\|")
-                     "\\)\\($\\|[ \t]\\)"))
-         (case-fold-search nil)
-         beg)
-      (goto-char (point-min))
-      (while (re-search-forward re nil t)
-       (org-if-unprotected
-        (setq beg (match-beginning 0))
-        (org-end-of-subtree t t)
-        (if (looking-at "^\\*+[ \t]+END[ \t]*$")
-            ;; Kill the END line of the inline task
-            (goto-char (min (point-max) (1+ (match-end 0)))))
-        (delete-region beg (point)))))))
-
-(defun org-export-remove-archived-trees (export-archived-trees)
-  "Remove archived trees.
-When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
-When it is t, the entire archived tree will be exported.
-When it is nil the entire tree including the headline will be removed
-from the buffer."
-  (let ((re-archive (concat ":" org-archive-tag ":"))
-       a b)
-    (when (not (eq export-archived-trees t))
-      (goto-char (point-min))
-      (while (re-search-forward re-archive nil t)
-       (if (not (org-at-heading-p t))
-           (goto-char (point-at-eol))
-         (beginning-of-line 1)
-         (setq a (if export-archived-trees
-                     (1+ (point-at-eol)) (point))
-               b (org-end-of-subtree t))
-         (if (> b a) (delete-region a b)))))))
-
-(defun org-export-remove-headline-metadata (opts)
-  "Remove meta data from the headline, according to user options."
-  (let ((re org-complex-heading-regexp)
-       (todo (plist-get opts :todo-keywords))
-       (tags (plist-get opts :tags))
-       (pri  (plist-get opts :priority))
-       (elts '(1 2 3 4 5))
-       (case-fold-search nil)
-       rpl)
-    (setq elts (delq nil (list 1 (if todo 2) (if pri 3) 4 (if tags 5))))
-    (when (or (not todo) (not tags) (not pri))
-      (goto-char (point-min))
-      (while (re-search-forward re nil t)
-       (org-if-unprotected
-        (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) ""))
-                             elts " "))
-        (replace-match rpl t t))))))
-
-(defun org-export-remove-timestamps ()
-  "Remove timestamps and keywords for export."
-  (goto-char (point-min))
-  (while (re-search-forward org-maybe-keyword-time-regexp nil t)
-    (backward-char 1)
-    (org-if-unprotected
-     (unless (save-match-data (org-at-table-p))
-       (replace-match "")
-       (beginning-of-line 1)
-       (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
-          (replace-match ""))))))
-
-(defun org-export-remove-clock-lines ()
-  "Remove clock lines for export."
-  (goto-char (point-min))
-  (let ((re (concat "^[ \t]*" org-clock-string ".*\n?")))
-    (while (re-search-forward re nil t)
-      (org-if-unprotected
-       (replace-match "")))))
-
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
-(defun org-export-protect-quoted-subtrees ()
-  "Mark quoted subtrees with the protection property."
-  (let ((org-re-quote (format org-heading-keyword-regexp-format
-                             org-quote-string)))
-    (goto-char (point-min))
-    (while (re-search-forward org-re-quote nil t)
-      (goto-char (match-beginning 0))
-      (end-of-line 1)
-      (add-text-properties (point) (org-end-of-subtree t)
-                          '(org-protected t)))))
-
-(defun org-export-convert-protected-spaces ()
-  "Convert strings like \\____ to protected spaces in all backends."
-  (goto-char (point-min))
-  (while (re-search-forward "\\\\__+" nil t)
-    (org-if-unprotected-1
-     (replace-match
-      (org-add-props
-         (cond
-          ((eq org-export-current-backend 'latex)
-           (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
-          ((eq org-export-current-backend 'html)
-           (org-add-props (match-string 0) nil
-             'org-whitespace (- (match-end 0) (match-beginning 0))))
-          ;; ((eq org-export-current-backend 'docbook))
-          ((eq org-export-current-backend 'ascii)
-           (org-add-props (match-string 0) '(org-whitespace t)))
-          (t (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
-         '(org-protected t))
-      t t))))
-
-(defun org-export-protect-verbatim ()
-  "Mark verbatim snippets with the protection property."
-  (goto-char (point-min))
-  (while (re-search-forward org-verbatim-re nil t)
-    (org-if-unprotected
-     (add-text-properties (match-beginning 4) (match-end 4)
-                         '(org-protected t org-verbatim-emph t))
-     (goto-char (1+ (match-end 4))))))
-
-(defun org-export-protect-colon-examples ()
-  "Protect lines starting with a colon."
-  (goto-char (point-min))
-  (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg)
-    (while (re-search-forward re nil t)
-      (beginning-of-line 1)
-      (setq beg (point))
-      (while (looking-at re)
-       (end-of-line 1)
-       (or (eobp) (forward-char 1)))
-      (add-text-properties beg (if (bolp) (1- (point)) (point))
-                          '(org-protected t)))))
-
-(defvar org-export-backends
-  '(docbook html beamer ascii latex)
-  "List of Org supported export backends.")
-
-(defun org-export-select-backend-specific-text ()
-  (let ((formatters org-export-backends)
-       (case-fold-search t)
-       backend backend-name beg beg-content end end-content ind)
-
-    (while formatters
-      (setq backend (pop formatters)
-           backend-name (symbol-name backend))
-
-      ;; Handle #+BACKEND: stuff
-      (goto-char (point-min))
-      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" backend-name
-                                       ":[ \t]*\\(.*\\)") nil t)
-       (if (not (eq backend org-export-current-backend))
-           (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
-         (let ((ind (get-text-property (point-at-bol) 'original-indentation)))
-           (replace-match "\\1\\2" t)
-           (add-text-properties
-            (point-at-bol) (min (1+ (point-at-eol)) (point-max))
-            `(org-protected t original-indentation ,ind org-native-text t)))))
-      ;; Delete #+ATTR_BACKEND: stuff of another backend.  Those
-      ;; matching the current backend will be taken care of by
-      ;; `org-export-attach-captions-and-attributes'
-      (goto-char (point-min))
-      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+ATTR_" backend-name
-                                       ":[ \t]*\\(.*\\)") nil t)
-       (setq ind (org-get-indentation))
-       (when (not (eq backend org-export-current-backend))
-         (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
-      ;; Handle #+BEGIN_BACKEND and #+END_BACKEND stuff
-      (goto-char (point-min))
-      (while (re-search-forward (concat "^[ \t]*#\\+BEGIN_" backend-name "\\>.*\n?")
-                               nil t)
-       (setq beg (match-beginning 0) beg-content (match-end 0))
-       (setq ind (or (get-text-property beg 'original-indentation)
-                     (save-excursion (goto-char beg) (org-get-indentation))))
-       (when (re-search-forward (concat "^[ \t]*#\\+END_" backend-name "\\>.*\n?")
-                                nil t)
-         (setq end (match-end 0) end-content (match-beginning 0))
-         (if (eq backend org-export-current-backend)
-             ;; yes, keep this
-             (progn
-               (add-text-properties
-                beg-content end-content
-                `(org-protected t original-indentation ,ind org-native-text t))
-               ;; strip protective commas
-               (org-unescape-code-in-region beg-content end-content)
-               (delete-region (match-beginning 0) (match-end 0))
-               (save-excursion
-                 (goto-char beg)
-                 (delete-region (point) (1+ (point-at-eol)))))
-           ;; No, this is for a different backend, kill it
-           (delete-region beg end)))))))
-
-(defun org-export-mark-blockquote-verse-center ()
-  "Mark block quote and verse environments with special cookies.
-These special cookies will later be interpreted by the backend."
-  ;; Blockquotes
-  (let (type t1 ind beg end beg1 end1 content)
-    (goto-char (point-min))
-    (while (re-search-forward
-           "^\\([ \t]*\\)#\\+\\(begin_\\(\\(block\\)?quote\\|verse\\|center\\)\\>.*\\)"
-           nil t)
-      (setq ind (length (match-string 1))
-           type (downcase (match-string 3))
-           t1 (if (equal type "quote") "blockquote" type))
-      (setq beg (match-beginning 0)
-           beg1 (1+ (match-end 0)))
-      (when (re-search-forward (concat "^[ \t]*#\\+end_" type "\\>.*") nil t)
-       (setq end1 (1- (match-beginning 0))
-             end (+ (point-at-eol) (if (looking-at "\n$") 1 0)))
-       (setq content (org-remove-indentation (buffer-substring beg1 end1)))
-       (setq content (concat "ORG-" (upcase t1) "-START\n"
-                             content "\n"
-                             "ORG-" (upcase t1) "-END\n"))
-       (delete-region beg end)
-       (insert (org-add-props content nil 'original-indentation ind))))))
-
-(defun org-export-mark-list-end ()
-  "Mark all list endings with a special string."
-  (unless (eq org-export-current-backend 'ascii)
-    (mapc
-     (lambda (e)
-       ;; For each type allowing list export, find every list, remove
-       ;; ending regexp if needed, and insert org-list-end.
-       (goto-char (point-min))
-       (while (re-search-forward (org-item-beginning-re) nil t)
-        (when (eq (nth 2 (org-list-context)) e)
-          (let* ((struct (org-list-struct))
-                 (bottom (org-list-get-bottom-point struct))
-                 (top (point-at-bol))
-                 (top-ind (org-list-get-ind top struct)))
-            (goto-char bottom)
-            (when (and (not (looking-at "[ \t]*$"))
-                       (looking-at org-list-end-re))
-              (replace-match ""))
-            (unless (bolp) (insert "\n"))
-            ;; As org-list-end is inserted at column 0, it would end
-            ;; by indentation any list.  It can be problematic when
-            ;; there are lists within lists: the inner list end would
-            ;; also become the outer list end.  To avoid this, text
-            ;; property `original-indentation' is added, as
-            ;; `org-list-struct' pays attention to it when reading a
-            ;; list.
-            (insert (org-add-props
-                        "ORG-LIST-END-MARKER\n"
-                        (list 'original-indentation top-ind)))))))
-     (cons nil org-list-export-context))))
-
-(defun org-export-mark-list-properties ()
-  "Mark list with special properties.
-These special properties will later be interpreted by the backend."
-  (let ((mark-list
-        (function
-         ;; Mark a list with 3 properties: `list-item' which is
-         ;; position at beginning of line, `list-struct' which is
-         ;; list structure, and `list-prevs' which is the alist of
-         ;; item and its predecessor.  Leave point at list ending.
-         (lambda (ctxt)
-           (let* ((struct (org-list-struct))
-                  (top (org-list-get-top-point struct))
-                  (bottom (org-list-get-bottom-point struct))
-                  (prevs (org-list-prevs-alist struct))
-                  poi)
-             ;; Get every item and ending position, without dups and
-             ;; without bottom point of list.
-             (mapc (lambda (e)
-                     (let ((pos (car e))
-                           (end (nth 6 e)))
-                       (unless (memq pos poi)
-                         (push pos poi))
-                       (unless (or (= end bottom) (memq end poi))
-                         (push end poi))))
-                   struct)
-             (setq poi (sort poi '<))
-             ;; For every point of interest, mark the whole line with
-             ;; its position in list.
-             (mapc
-              (lambda (e)
-                (goto-char e)
-                (add-text-properties (point-at-bol) (point-at-eol)
-                                     (list 'list-item (point-at-bol)
-                                           'list-struct struct
-                                           'list-prevs prevs)))
-              poi)
-             ;; Take care of bottom point.  As babel may have inserted
-             ;; a new list in buffer, list ending isn't always
-             ;; marked.  Now mark every list ending and add properties
-             ;; useful to line processing exporters.
-             (goto-char bottom)
-             (when (or (looking-at "^ORG-LIST-END-MARKER\n")
-                       (and (not (looking-at "[ \t]*$"))
-                            (looking-at org-list-end-re)))
-               (replace-match ""))
-             (unless (bolp) (insert "\n"))
-             (insert
-              (org-add-props "ORG-LIST-END-MARKER\n" (list 'list-item bottom
-                                                           'list-struct struct
-                                                           'list-prevs prevs)))
-             ;; Following property is used by LaTeX exporter.
-             (add-text-properties top (point) (list 'list-context ctxt)))))))
-    ;; Mark lists except for backends not interpreting them.
-    (unless (eq org-export-current-backend 'ascii)
-      (let ((org-list-end-re "^ORG-LIST-END-MARKER\n"))
-       (mapc
-        (lambda (e)
-          (goto-char (point-min))
-          (while (re-search-forward (org-item-beginning-re) nil t)
-            (let ((context (nth 2 (org-list-context))))
-              (if (eq context e)
-                  (funcall mark-list e)
-                (put-text-property (point-at-bol) (point-at-eol)
-                                   'list-context context)))))
-        (cons nil org-list-export-context))))))
-
-(defun org-export-attach-captions-and-attributes (target-alist)
-  "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
-If the next thing following is a table, add the text properties to the first
-table line.  If it is a link, add it to the line containing the link."
-  (goto-char (point-min))
-  (remove-text-properties (point-min) (point-max)
-                         '(org-caption nil org-attributes nil))
-  (let ((case-fold-search t)
-       (re (concat "^[ \t]*#\\+caption:[ \t]+\\(.*\\)"
-                   "\\|"
-                   "^[ \t]*#\\+attr_" (symbol-name org-export-current-backend) ":[ \t]+\\(.*\\)"
-                   "\\|"
-                   "^[ \t]*#\\+label:[ \t]+\\(.*\\)"
-                   "\\|"
-                   "^[ \t]*\\(|[^-]\\)"
-                   "\\|"
-                   "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
-       cap shortn attr label end)
-    (while (re-search-forward re nil t)
-      (cond
-       ;; there is a caption
-       ((match-end 1)
-       (progn
-         (setq cap (concat cap (if cap " " "") (org-trim (match-string 1))))
-         (when (string-match "\\[\\(.*\\)\\]{\\(.*\\)}" cap)
-           (setq shortn (match-string 1 cap)
-                 cap (match-string 2 cap)))
-         (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
-       ;; there is an attribute
-       ((match-end 2)
-       (progn
-         (setq attr (concat attr (if attr " " "") (org-trim (match-string 2))))
-         (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
-       ;; there is a label
-       ((match-end 3)
-       (progn
-         (setq label (org-trim (match-string 3)))
-         (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
-       (t
-       (setq end (if (match-end 4)
-                     (let ((ee (org-table-end)))
-                       (prog1 (1- (marker-position ee)) (move-marker ee nil)))
-                   (point-at-eol)))
-       (add-text-properties (point-at-bol) end
-                            (list 'org-caption cap
-                                  'org-caption-shortn shortn
-                                  'org-attributes attr
-                                  'org-label label))
-       (if label (push (cons label label) target-alist))
-       (goto-char end)
-       (setq cap nil shortn nil attr nil label nil)))))
-  target-alist)
-
-(defun org-export-remove-comment-blocks-and-subtrees ()
-  "Remove the comment environment, and also commented subtrees."
-  (let ((re-commented (format org-heading-keyword-regexp-format
-                             org-comment-string))
-       case-fold-search)
-    ;; Remove comment environment
-    (goto-char (point-min))
-    (setq case-fold-search t)
-    (while (re-search-forward
-           "^#\\+begin_comment[ \t]*\n[^\000]*?\n#\\+end_comment\\>.*" nil t)
-      (replace-match "" t t))
-    ;; Remove subtrees that are commented
-    (goto-char (point-min))
-    (setq case-fold-search nil)
-    (while (re-search-forward re-commented nil t)
-      (goto-char (match-beginning 0))
-      (delete-region (point) (org-end-of-subtree t)))))
-
-(defun org-export-handle-comments (org-commentsp)
-  "Remove comments, or convert to backend-specific format.
-ORG-COMMENTSP can be a format string for publishing comments.
-When it is nil, all comments will be removed."
-  (let ((re "^[ \t]*#\\( \\|$\\)"))
-    (goto-char (point-min))
-    (while (re-search-forward re nil t)
-      (let ((pos (match-beginning 0))
-           (end (progn (forward-line) (point))))
-       (if (get-text-property pos 'org-protected)
-           (forward-line)
-         (if (not org-commentsp) (delete-region pos end)
-           (add-text-properties pos end '(org-protected t))
-           (replace-match
-            (org-add-props
-                (format org-commentsp (buffer-substring (match-end 0) end))
-                nil 'org-protected t)
-            t t)))))
-    ;; Hack attack: previous implementation also removed keywords at
-    ;; column 0. Brainlessly do it again.
-    (goto-char (point-min))
-    (while (re-search-forward "^#\\+" nil t)
-      (unless (get-text-property (point-at-bol) 'org-protected)
-       (delete-region (point-at-bol) (progn (forward-line) (point)))))))
-
-(defun org-export-handle-metalines ()
-  "Remove tables and source blocks metalines.
-This function should only be called after all block processing
-has taken place."
-  (let ((re "^[ \t]*#\\+\\(tbl\\(?:name\\|fm\\)\\|results\\(?:\\[[a-z0-9]+\\]\\)?\\|name\\):\\(.*\n?\\)")
-       (case-fold-search t)
-       pos)
-    (goto-char (point-min))
-    (while (or (looking-at re)
-              (re-search-forward re nil t))
-      (setq pos (match-beginning 0))
-      (if (get-text-property (match-beginning 1) 'org-protected)
-         (goto-char (1+ pos))
-       (goto-char (1+ pos))
-       (replace-match "")
-       (goto-char (max (point-min) (1- pos)))))))
-
-(defun org-export-mark-radio-links ()
-  "Find all matches for radio targets and turn them into internal links."
-  (let ((re-radio (and org-target-link-regexp
-                      (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)"))))
-    (goto-char (point-min))
-    (when re-radio
-      (while (re-search-forward re-radio nil t)
-       (unless
-           (save-match-data
-             (or (org-in-regexp org-bracket-link-regexp)
-                 (org-in-regexp org-plain-link-re)
-                 (org-in-regexp "<<[^<>]+>>")))
-         (org-if-unprotected
-          (replace-match "\\1[[\\2]]")))))))
-
-(defun org-store-forced-table-alignment ()
-  "Find table lines which force alignment, store the results in properties."
-  (let (line cnt cookies)
-    (goto-char (point-min))
-    (while (re-search-forward "|[ \t]*<\\([lrc]?[0-9]+\\|[lrc]\\)>[ \t]*|"
-                             nil t)
-      ;; OK, this looks like a table line with an alignment cookie
-      (org-if-unprotected
-       (setq line (buffer-substring (point-at-bol) (point-at-eol)))
-       (when (and (org-at-table-p)
-                 (org-table-cookie-line-p line))
-        (setq cnt 0 cookies nil)
-        (mapc
-         (lambda (x)
-           (setq cnt (1+ cnt))
-           (when (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'" x)
-             (let ((align (and (match-end 1)
-                               (downcase (match-string 1 x))))
-                   (width (and (match-end 2)
-                               (string-to-number (match-string 2 x)))))
-               (push (cons cnt (list align width)) cookies))))
-         (org-split-string line "[ \t]*|[ \t]*"))
-        (add-text-properties (org-table-begin) (org-table-end)
-                             (list 'org-col-cookies cookies))))
-      (goto-char (point-at-eol)))))
-
-(defun org-export-remove-special-table-lines ()
-  "Remove tables lines that are used for internal purposes.
-Also, store forced alignment information found in such lines."
-  (goto-char (point-min))
-  (while (re-search-forward "^[ \t]*|" nil t)
-    (org-if-unprotected-at (1- (point))
-      (beginning-of-line 1)
-      (if (or (looking-at "[ \t]*| *[!_^] *|")
-             (not
-              (memq
-               nil
-               (mapcar
-                (lambda (f)
-                  (or (and org-export-table-remove-empty-lines (= (length f) 0))
-                      (string-match
-                       "\\`<\\([0-9]\\|[lrc]\\|[lrc][0-9]+\\)>\\'" f)))
-                (org-split-string ;; FIXME, can't we do without splitting???
-                 (buffer-substring (point-at-bol) (point-at-eol))
-                 "[ \t]*|[ \t]*")))))
-         (delete-region (max (point-min) (1- (point-at-bol)))
-                        (point-at-eol))
-       (end-of-line 1)))))
-
-(defun org-export-protect-sub-super (s)
-  (save-match-data
-    (while (string-match "\\([^\\\\]\\)\\([_^]\\)" s)
-      (setq s (replace-match "\\1\\\\\\2" nil nil s)))
-    s))
-
-(defun org-export-normalize-links ()
-  "Convert all links to bracket links, and expand link abbreviations."
-  (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
-       (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
-       nodesc)
-    (goto-char (point-min))
-    (while (re-search-forward org-bracket-link-regexp nil t)
-      (put-text-property (match-beginning 0) (match-end 0) 'org-normalized-link t))
-    (goto-char (point-min))
-    (while (re-search-forward re-plain-link nil t)
-      (unless (get-text-property (match-beginning 0) 'org-normalized-link)
-       (goto-char (1- (match-end 0)))
-       (org-if-unprotected-at (1+ (match-beginning 0))
-         (let* ((s (concat (match-string 1)
-                           "[[" (match-string 2) ":" (match-string 3)
-                           "][" (match-string 2) ":" (org-export-protect-sub-super
-                                                      (match-string 3))
-                           "]]")))
-           ;; added 'org-link face to links
-           (put-text-property 0 (length s) 'face 'org-link s)
-           (replace-match s t t)))))
-    (goto-char (point-min))
-    (while (re-search-forward re-angle-link nil t)
-      (goto-char (1- (match-end 0)))
-      (org-if-unprotected
-       (let* ((s (concat (match-string 1)
-                        "[[" (match-string 2) ":" (match-string 3)
-                        "][" (match-string 2) ":" (org-export-protect-sub-super
-                                                   (match-string 3))
-                        "]]")))
-        (put-text-property 0 (length s) 'face 'org-link s)
-        (replace-match s t t))))
-    (goto-char (point-min))
-    (while (re-search-forward org-bracket-link-regexp nil t)
-      (goto-char (1- (match-end 0)))
-      (setq nodesc (not (match-end 3)))
-      (org-if-unprotected
-       (let* ((xx (save-match-data
-                   (org-translate-link
-                    (org-link-expand-abbrev (match-string 1)))))
-             (s (concat
-                 "[[" (org-add-props (copy-sequence xx)
-                          nil 'org-protected t 'org-no-description nodesc)
-                 "]"
-                 (if (match-end 3)
-                     (match-string 2)
-                   (concat "[" (copy-sequence xx)
-                           "]"))
-                 "]")))
-        (put-text-property 0 (length s) 'face 'org-link s)
-        (replace-match s t t))))))
-
-(defun org-export-concatenate-multiline-links ()
-  "Find multi-line links and put it all into a single line.
-This is to make sure that the line-processing export backends
-can work correctly."
-  (goto-char (point-min))
-  (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
-    (org-if-unprotected-at (match-beginning 1)
-      (replace-match "\\1 \\3")
-      (goto-char (match-beginning 0)))))
-
-(defun org-export-concatenate-multiline-emphasis ()
-  "Find multi-line emphasis and put it all into a single line.
-This is to make sure that the line-processing export backends
-can work correctly."
-  (goto-char (point-min))
-  (while (re-search-forward org-emph-re nil t)
-    (if (and (not (= (char-after (match-beginning 3))
-                    (char-after (match-beginning 4))))
-            (save-excursion (goto-char (match-beginning 0))
-                            (save-match-data
-                              (and (not (org-at-table-p))
-                                   (not (org-at-heading-p))))))
-       (org-if-unprotected
-        (subst-char-in-region (match-beginning 0) (match-end 0)
-                              ?\n ?\  t)
-        (goto-char (1- (match-end 0))))
-      (goto-char (1+ (match-beginning 0))))))
-
-(defun org-export-grab-title-from-buffer ()
-  "Get a title for the current document, from looking at the buffer."
-  (let ((inhibit-read-only t))
-    (save-excursion
-      (goto-char (point-min))
-      (let ((end (if (looking-at org-outline-regexp)
-                    (point)
-                  (save-excursion (outline-next-heading) (point)))))
-       (when (re-search-forward "^[ \t]*[^|# \t\r\n].*\n" end t)
-         ;; Mark the line so that it will not be exported as normal text.
-         (unless (org-in-block-p org-list-forbidden-blocks)
-           (org-unmodified
-            (add-text-properties (match-beginning 0) (match-end 0)
-                                 (list :org-license-to-kill t))))
-         ;; Return the title string
-         (org-trim (match-string 0)))))))
-
-(defun org-export-get-title-from-subtree ()
-  "Return subtree title and exclude it from export."
-  (let ((rbeg (region-beginning)) (rend (region-end))
-       (inhibit-read-only t)
-       (tags (plist-get (org-infile-export-plist) :tags))
-       title)
-    (save-excursion
-      (goto-char rbeg)
-      (when (and (org-at-heading-p)
-                (>= (org-end-of-subtree t t) rend))
-       (when (plist-member org-export-opt-plist :tags)
-         (setq tags (or (plist-get org-export-opt-plist :tags) tags)))
-       ;; This is a subtree, we take the title from the first heading
-       (goto-char rbeg)
-       (looking-at org-todo-line-tags-regexp)
-       (setq title (if (and (eq tags t) (match-string 4))
-                       (format "%s\t%s" (match-string 3) (match-string 4))
-                     (match-string 3)))
-       (org-unmodified
-        (add-text-properties (point) (1+ (point-at-eol))
-                             (list :org-license-to-kill t)))
-       (setq title (or (org-entry-get nil "EXPORT_TITLE") title))))
-    title))
-
-(defun org-solidify-link-text (s &optional alist)
-  "Take link text and make a safe target out of it."
-  (save-match-data
-    (let* ((rtn
-           (mapconcat
-            'identity
-            (org-split-string s "[^a-zA-Z0-9_\\.-]+") "-"))
-          (a (assoc rtn alist)))
-      (or (cdr a) rtn))))
-
-(defun org-get-min-level (lines &optional offset)
-  "Get the minimum level in LINES."
-  (let ((re "^\\(\\*+\\) ") l)
-    (catch 'exit
-      (while (setq l (pop lines))
-       (if (string-match re l)
-           (throw 'exit (org-tr-level (- (length (match-string 1 l))
-                                         (or offset 0))))))
-      1)))
-
-;; Variable holding the vector with section numbers
-(defvar org-section-numbers (make-vector org-level-max 0))
-
-(defun org-init-section-numbers ()
-  "Initialize the vector for the section numbers."
-  (let* ((level  -1)
-        (numbers (nreverse (org-split-string "" "\\.")))
-        (depth (1- (length org-section-numbers)))
-        (i depth) number-string)
-    (while (>= i 0)
-      (if (> i level)
-         (aset org-section-numbers i 0)
-       (setq number-string (or (car numbers) "0"))
-       (if (string-match "\\`[A-Z]\\'" number-string)
-           (aset org-section-numbers i
-                 (- (string-to-char number-string) ?A -1))
-         (aset org-section-numbers i (string-to-number number-string)))
-       (pop numbers))
-      (setq i (1- i)))))
-
-(defun org-section-number (&optional level)
-  "Return a string with the current section number.
-When LEVEL is non-nil, increase section numbers on that level."
-  (let* ((depth (1- (length org-section-numbers)))
-        (string "")
-        (fmts (car org-export-section-number-format))
-        (term (cdr org-export-section-number-format))
-        (sep "")
-        ctype fmt idx n)
-    (when level
-      (when (> level -1)
-       (aset org-section-numbers
-             level (1+ (aref org-section-numbers level))))
-      (setq idx (1+ level))
-      (while (<= idx depth)
-       (if (not (= idx 1))
-           (aset org-section-numbers idx 0))
-       (setq idx (1+ idx))))
-    (setq idx 0)
-    (while (<= idx depth)
-      (when (> (aref org-section-numbers idx) 0)
-       (setq fmt (or (pop fmts) fmt)
-             ctype (car fmt)
-             n (aref org-section-numbers idx)
-             string (if (> n 0)
-                        (concat string sep (org-number-to-counter n ctype))
-                      (concat string ".0"))
-             sep (nth 1 fmt)))
-      (setq idx (1+ idx)))
-    (save-match-data
-      (if (string-match "\\`\\([@0]\\.\\)+" string)
-         (setq string (replace-match "" t nil string)))
-      (if (string-match "\\(\\.0\\)+\\'" string)
-         (setq string (replace-match "" t nil string))))
-    (concat string term)))
-
-(defun org-number-to-counter (n type)
-  "Concert number N to a string counter, according to TYPE.
-TYPE must be a string, any of:
- 1  number
- A  A,B,....
- a  a,b,....
- I  upper case roman numeral
- i  lower case roman numeral"
-  (cond
-   ((equal type "1") (number-to-string n))
-   ((equal type "A") (char-to-string (+ ?A n -1)))
-   ((equal type "a") (char-to-string (+ ?a n -1)))
-   ((equal type "I") (org-number-to-roman n))
-   ((equal type "i") (downcase (org-number-to-roman n)))
-   (t (error "Invalid counter type `%s'" type))))
-
-(defun org-number-to-roman (n)
-  "Convert integer N into a roman numeral."
-  (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
-                ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
-                (  10 . "X") (  9 . "IX") (  5 . "V") (  4 . "IV")
-                (   1 . "I")))
-       (res ""))
-    (if (<= n 0)
-       (number-to-string n)
-      (while roman
-       (if (>= n (caar roman))
-           (setq n (- n (caar roman))
-                 res (concat res (cdar roman)))
-         (pop roman)))
-      res)))
-
-;;; Macros
-
-(defun org-export-preprocess-apply-macros ()
-  "Replace macro references."
-  (goto-char (point-min))
-  (let (sy val key args args2 ind-str s n)
-    (while (re-search-forward
-           "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}"
-           nil t)
-      (unless (save-match-data (save-excursion
-                                (goto-char (point-at-bol))
-                                (looking-at "[ \t]*#\\+macro")))
-       ;; Get macro name (KEY), arguments (ARGS), and indentation of
-       ;; current line (IND-STR) as strings.
-       (setq key (downcase (match-string 1))
-             args (match-string 3)
-             ind-str (save-match-data (save-excursion
-                                        (beginning-of-line)
-                                        (looking-at "^\\([ \t]*\\).*")
-                                        (match-string 1))))
-       ;; When macro is defined, retrieve replacement text in VAL,
-       ;; and proceed with expansion.
-       (when (setq val (or (plist-get org-export-opt-plist
-                                      (intern (concat ":macro-" key)))
-                           (plist-get org-export-opt-plist
-                                      (intern (concat ":" key)))))
-         (save-match-data
-           ;; If arguments are provided, first retrieve them properly
-           ;; (in ARGS, as a list), then replace them in VAL.
-           (when args
-             (setq args (org-split-string args ",") args2 nil)
-             (while args
-               (while (string-match "\\\\\\'" (car args))
-                 ;; Repair bad splits.
-                 (setcar (cdr args) (concat (substring (car args) 0 -1)
-                                            "," (nth 1 args)))
-                 (pop args))
-               (push (pop args) args2))
-             (setq args (mapcar 'org-trim (nreverse args2)))
-             (setq s 0)
-             (while (string-match "\\$\\([0-9]+\\)" val s)
-               (setq s (1+ (match-beginning 0))
-                     n (string-to-number (match-string 1 val)))
-               (and (>= (length args) n)
-                    (setq val (replace-match (nth (1- n) args) t t val)))))
-           ;; VAL starts with "(eval": it is a sexp, `eval' it.
-           (when (string-match "\\`(eval\\>" val)
-             (setq val (eval (read val))))
-           ;; Ensure VAL is a string (or nil) and that each new line
-           ;; is indented as the first one.
-           (setq val (and val
-                          (mapconcat 'identity
-                                     (org-split-string
-                                      (if (stringp val) val (format "%s" val))
-                                      "\n")
-                                     (concat "\n" ind-str)))))
-         ;; Eventually do the replacement, if VAL isn't nil.  Move
-         ;; point at beginning of macro for recursive expansions.
-         (when val
-           (replace-match val t t)
-           (goto-char (match-beginning 0))))))))
-
-(defun org-export-apply-macros-in-string (s)
-  "Apply the macros in string S."
-  (when s
-    (with-temp-buffer
-      (insert s)
-      (org-export-preprocess-apply-macros)
-      (buffer-string))))
-
-;;; Include files
-
-(defun org-export-handle-include-files ()
-  "Include the contents of include files, with proper formatting."
-  (let ((case-fold-search t)
-       params file markup lang start end prefix prefix1 switches all minlevel currentlevel addlevel lines)
-    (goto-char (point-min))
-    (while (re-search-forward "^#\\+include:[ \t]+\\(.*\\)" nil t)
-      (setq params (read (concat "(" (match-string 1) ")"))
-           prefix (org-get-and-remove-property 'params :prefix)
-           prefix1 (org-get-and-remove-property 'params :prefix1)
-           minlevel (org-get-and-remove-property 'params :minlevel)
-           addlevel (org-get-and-remove-property 'params :addlevel)
-           lines (org-get-and-remove-property 'params :lines)
-           file (org-symname-or-string (pop params))
-           markup (org-symname-or-string (pop params))
-           lang (and (member markup '("src" "SRC"))
-                     (org-symname-or-string (pop params)))
-           switches (mapconcat #'(lambda (x) (format "%s" x)) params " ")
-           start nil end nil)
-      (delete-region (match-beginning 0) (match-end 0))
-      (setq currentlevel (or (org-current-level) 0))
-      (if (or (not file)
-             (not (file-exists-p file))
-             (not (file-readable-p file)))
-         (insert (format "CANNOT INCLUDE FILE %s" file))
-       (setq all (cons file all))
-       (when markup
-         (if (equal (downcase markup) "src")
-             (setq start (format "#+begin_src %s %s\n"
-                                 (or lang "fundamental")
-                                 (or switches ""))
-                   end "#+end_src")
-           (setq start (format "#+begin_%s %s\n" markup switches)
-                 end  (format "#+end_%s" markup))))
-       (insert (or start ""))
-       (insert (org-get-file-contents (expand-file-name file)
-                                      prefix prefix1 markup currentlevel minlevel addlevel lines))
-       (or (bolp) (newline))
-       (insert (or end ""))))
-    all))
-
-(defun org-export-handle-include-files-recurse ()
-  "Recursively include files aborting on circular inclusion."
-  (let ((now (list org-current-export-file)) all)
-    (while now
-      (setq all (append now all))
-      (setq now (org-export-handle-include-files))
-      (let ((intersection
-            (delq nil
-                  (mapcar (lambda (el) (when (member el all) el)) now))))
-       (when intersection
-         (error "Recursive #+INCLUDE: %S" intersection))))))
-
-(defun org-get-file-contents (file &optional prefix prefix1 markup minlevel parentlevel addlevel lines)
-  "Get the contents of FILE and return them as a string.
-If PREFIX is a string, prepend it to each line.  If PREFIX1
-is a string, prepend it to the first line instead of PREFIX.
-If MARKUP, don't protect org-like lines, the exporter will
-take care of the block they are in.  If ADDLEVEL is a number,
-demote included file to current heading level+ADDLEVEL.
-If LINES is a string specifying a range of lines,
-include only those lines."
-  (if (stringp markup) (setq markup (downcase markup)))
-  (with-temp-buffer
-    (insert-file-contents file)
-    (when lines
-      (let* ((lines (split-string lines "-"))
-            (lbeg (string-to-number (car lines)))
-            (lend (string-to-number (cadr lines)))
-            (beg (if (zerop lbeg) (point-min)
-                   (goto-char (point-min))
-                   (forward-line (1- lbeg))
-                   (point)))
-            (end (if (zerop lend) (point-max)
-                   (goto-char (point-min))
-                   (forward-line (1- lend))
-                   (point))))
-       (narrow-to-region beg end)))
-    (when (or prefix prefix1)
-      (goto-char (point-min))
-      (while (not (eobp))
-       (insert (or prefix1 prefix))
-       (setq prefix1 "")
-       (beginning-of-line 2)))
-    (buffer-string)
-    (when (member markup '("src" "example"))
-      (goto-char (point-min))
-      (while (re-search-forward "^\\([*#]\\|[ \t]*#\\+\\)" nil t)
-       (goto-char (match-beginning 0))
-       (insert ",")
-       (end-of-line 1)))
-    (when minlevel
-      (dotimes (lvl minlevel)
-       (org-map-region 'org-demote (point-min) (point-max))))
-    (when addlevel
-      (let ((inclevel (or (if (org-before-first-heading-p)
-                             (1- (and (outline-next-heading)
-                                      (org-current-level)))
-                           (1- (org-current-level)))
-                         0)))
-       (dotimes (level (- (+ parentlevel addlevel) inclevel))
-         (org-map-region 'org-demote (point-min) (point-max)))))
-    (buffer-string)))
-
-(defun org-get-and-remove-property (listvar prop)
-  "Check if the value of LISTVAR contains PROP as a property.
-If yes, return the value of that property (i.e. the element following
-in the list) and remove property and value from the list in LISTVAR."
-  (let ((list (symbol-value listvar)) m v)
-    (when (setq m (member prop list))
-      (setq v (nth 1 m))
-      (if (equal (car list) prop)
-         (set listvar (cddr list))
-       (setcdr (nthcdr (- (length list) (length m) 1) list)
-               (cddr m))
-       (set listvar list)))
-    v))
-
-(defun org-symname-or-string (s)
-  (if (symbolp s)
-      (if s (symbol-name s) s)
-    s))
-
-;;; Fontification and line numbers for code examples
-
-(defvar org-export-last-code-line-counter-value 0)
-
-(defun org-export-replace-src-segments-and-examples ()
-  "Replace source code segments with special code for export."
-  (setq org-export-last-code-line-counter-value 0)
-  (let ((case-fold-search t)
-       lang code trans opts indent caption)
-    (goto-char (point-min))
-    (while (re-search-forward
-           "\\(^\\([ \t]*\\)#\\+BEGIN_SRC:?\\([ \t]+\\([^ \t\n]+\\)\\)?\\(.*\\)\n\\([^\000]+?\n\\)[ \t]*#\\+END_SRC.*\n?\\)\\|\\(^\\([ \t]*\\)#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)[ \t]*#\\+END_EXAMPLE.*\n?\\)"
-           nil t)
-      (if (match-end 1)
-         (if (not (match-string 4))
-             (error "Source block missing language specification: %s"
-                    (let* ((body (match-string 6))
-                           (nothing (message "body:%s" body))
-                           (preview (or (and (string-match
-                                              "^[ \t]*\\([^\n\r]*\\)" body)
-                                             (match-string 1 body)) body)))
-                      (if (> (length preview) 35)
-                          (concat (substring preview 0 32) "...")
-                        preview)))
-           ;; src segments
-           (setq lang (match-string 4)
-                 opts (match-string 5)
-                 code (match-string 6)
-                 indent (length (match-string 2))
-                 caption (get-text-property 0 'org-caption (match-string 0))))
-       (setq lang nil
-             opts (match-string 9)
-             code (match-string 10)
-             indent (length (match-string 8))
-              caption (get-text-property 0 'org-caption (match-string 0))))
-
-      (setq trans (org-export-format-source-code-or-example
-                  lang code opts indent caption))
-      (replace-match trans t t))))
-
-(defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el
-(defvar org-export-latex-listings) ;; defined in org-latex.el
-(defvar org-export-latex-listings-langs) ;; defined in org-latex.el
-(defvar org-export-latex-listings-w-names) ;; defined in org-latex.el
-(defvar org-export-latex-minted-langs) ;; defined in org-latex.el
-(defvar org-export-latex-custom-lang-environments) ;; defined in org-latex.el
-(defvar org-export-latex-listings-options) ;; defined in org-latex.el
-(defvar org-export-latex-minted-options) ;; defined in org-latex.el
-
-(defun org-remove-formatting-on-newlines-in-region (beg end)
-  "Remove formatting on newline characters."
-  (interactive "r")
-  (save-excursion
-    (goto-char beg)
-    (while (progn (end-of-line) (< (point) end))
-      (put-text-property (point) (1+ (point)) 'face nil)
-      (forward-char 1))))
-
-(defun org-export-format-source-code-or-example
-  (lang code &optional opts indent caption)
-  "Format CODE from language LANG and return it formatted for export.
-The CODE is marked up in `org-export-current-backend' format.
-
-Check if a function by name
-\"org-<backend>-format-source-code-or-example\" is bound.  If yes,
-use it as the custom formatter.  Otherwise, use the default
-formatter.  Default formatters are provided for docbook, html,
-latex and ascii backends.  For example, use
-`org-html-format-source-code-or-example' to provide a custom
-formatter for export to \"html\".
-
-If LANG is nil, do not add any fontification.
-OPTS contains formatting options, like `-n' for triggering numbering lines,
-and `+n' for continuing previous numbering.
-Code formatting according to language currently only works for HTML.
-Numbering lines works for all three major backends (html, latex, and ascii).
-INDENT was the original indentation of the block."
-  (save-match-data
-    (let* ((backend-name (symbol-name org-export-current-backend))
-          (backend-formatter
-           (intern (format "org-%s-format-source-code-or-example"
-                           backend-name)))
-          (backend-feature (intern (concat "org-" backend-name)))
-          (backend-formatter
-           (and (require (intern (concat "org-" backend-name)) nil)
-                (fboundp backend-formatter) backend-formatter))
-          num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt)
-      (setq opts (or opts "")
-           num (string-match "[-+]n\\>" opts)
-           cont (string-match "\\+n\\>" opts)
-           rpllbl (string-match "-r\\>" opts)
-           keepp (string-match "-k\\>" opts)
-           textareap (string-match "-t\\>" opts)
-           preserve-indentp (or org-src-preserve-indentation
-                                (string-match "-i\\>" opts))
-           cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts)
-                    (string-to-number (match-string 1 opts))
-                  80)
-           rows (if (string-match "-h[ \t]+\\([0-9]+\\)" opts)
-                    (string-to-number (match-string 1 opts))
-                  (org-count-lines code))
-           fmt (if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts)
-                   (match-string 1 opts)))
-      (when (and textareap (eq org-export-current-backend 'html))
-       ;; we cannot use numbering or highlighting.
-       (setq num nil cont nil lang nil))
-      (if keepp (setq rpllbl 'keep))
-      (setq rtn (if preserve-indentp code (org-remove-indentation code)))
-      (when (string-match "^," rtn)
-       (setq rtn (with-temp-buffer
-                   (insert rtn)
-                   ;; Free up the protected lines
-                   (goto-char (point-min))
-                   (while (re-search-forward "^," nil t)
-                     (if (or (equal lang "org")
-                             (save-match-data
-                               (looking-at "\\([*#]\\|[ \t]*#\\+\\)")))
-                         (replace-match ""))
-                     (end-of-line 1))
-                   (buffer-string))))
-      ;; Now backend-specific coding
-      (setq rtn
-           (cond
-            (backend-formatter
-             (funcall backend-formatter rtn lang caption textareap cols rows num
-                      cont rpllbl fmt))
-            ((eq org-export-current-backend 'docbook)
-             (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-             (concat "<programlisting><![CDATA["
-                     rtn
-                     "]]></programlisting>\n"))
-            ((eq org-export-current-backend 'html)
-             ;; We are exporting to HTML
-             (when lang
-               (if (featurep 'xemacs)
-                   (require 'htmlize)
-                 (require 'htmlize nil t))
-               (when (not (fboundp 'htmlize-region-for-paste))
-                 ;; we do not have htmlize.el, or an old version of it
-                 (setq lang nil)
-                 (message
-                  "htmlize.el 1.34 or later is needed for source code formatting")))
-
-             (if lang
-                 (let* ((lang-m (when lang
-                                   (or (cdr (assoc lang org-src-lang-modes))
-                                       lang)))
-                         (mode (and lang-m (intern
-                                           (concat
-                                            (if (symbolp lang-m)
-                                                (symbol-name lang-m)
-                                              lang-m)
-                                            "-mode"))))
-                        (org-inhibit-startup t)
-                        (org-startup-folded nil))
-                   (setq rtn
-                         (with-temp-buffer
-                           (insert rtn)
-                           (if (functionp mode)
-                               (funcall mode)
-                             (fundamental-mode))
-                           (font-lock-fontify-buffer)
-                           ;; markup each line separately
-                           (org-remove-formatting-on-newlines-in-region (point-min) (point-max))
-                           (org-src-mode)
-                           (set-buffer-modified-p nil)
-                           (org-export-htmlize-region-for-paste
-                            (point-min) (point-max))))
-                   (if (string-match "<pre\\([^>]*\\)>\n*" rtn)
-                       (setq rtn
-                              (concat
-                               (if caption
-                                   (concat
-                                    "<div class=\"org-src-container\">"
-                                    (format
-                                     "<label class=\"org-src-name\">%s</label>"
-                                     caption))
-                                 "")
-                               (replace-match
-                                (format "<pre class=\"src src-%s\">\n" lang)
-                                t t rtn)
-                               (if caption "</div>" "")))))
-               (if textareap
-                   (setq rtn (concat
-                              (format "<p>\n<textarea cols=\"%d\" rows=\"%d\">"
-                                      cols rows)
-                              rtn "</textarea>\n</p>\n"))
-                 (with-temp-buffer
-                   (insert rtn)
-                   (goto-char (point-min))
-                   (while (re-search-forward "[<>&]" nil t)
-                     (replace-match (cdr (assq (char-before)
-                                               '((?&."&amp;")(?<."&lt;")(?>."&gt;"))))
-                                    t t))
-                   (setq rtn (buffer-string)))
-                 (setq rtn (concat "<pre class=\"example\">\n" rtn "</pre>\n"))))
-             (unless textareap
-               (setq rtn (org-export-number-lines rtn 1 1 num cont rpllbl fmt)))
-             (if (string-match "\\(\\`<[^>]*>\\)\n" rtn)
-                 (setq rtn (replace-match "\\1" t nil rtn)))
-             rtn)
-            ((eq org-export-current-backend 'latex)
-             (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-             (cond
-              ((and lang org-export-latex-listings)
-               (let* ((make-option-string
-                       (lambda (pair)
-                         (concat (first pair)
-                                 (if (> (length (second pair)) 0)
-                                     (concat "=" (second pair))))))
-                      (lang-sym (intern lang))
-                      (minted-p (eq org-export-latex-listings 'minted))
-                      (listings-p (not minted-p))
-                      (backend-lang
-                       (or (cadr
-                            (assq
-                             lang-sym
-                             (cond
-                              (minted-p org-export-latex-minted-langs)
-                              (listings-p org-export-latex-listings-langs))))
-                           lang))
-                      (custom-environment
-                       (cadr
-                        (assq
-                         lang-sym
-                         org-export-latex-custom-lang-environments))))
-                 (concat
-                  (when (and listings-p (not custom-environment))
-                    (format
-                     "\\lstset{%s}\n"
-                     (mapconcat
-                      make-option-string
-                      (append org-export-latex-listings-options
-                              `(("language" ,backend-lang))) ",")))
-                  (when (and caption org-export-latex-listings-w-names)
-                    (format
-                     "\n%s $\\equiv$ \n"
-                     (replace-regexp-in-string "_" "\\\\_" caption)))
-                  (cond
-                   (custom-environment
-                    (format "\\begin{%s}\n%s\\end{%s}\n"
-                            custom-environment rtn custom-environment))
-                   (listings-p
-                    (format "\\begin{%s}\n%s\\end{%s}"
-                            "lstlisting" rtn "lstlisting"))
-                   (minted-p
-                    (format
-                     "\\begin{minted}[%s]{%s}\n%s\\end{minted}"
-                     (mapconcat make-option-string
-                                org-export-latex-minted-options ",")
-                     backend-lang rtn))))))
-              (t (concat (car org-export-latex-verbatim-wrap)
-                         rtn (cdr org-export-latex-verbatim-wrap)))))
-            ((eq org-export-current-backend 'ascii)
-             ;; This is not HTML or LaTeX, so just make it an example.
-             (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-             (concat caption "\n"
-                     (concat
-                      (mapconcat
-                       (lambda (l) (concat "  " l))
-                       (org-split-string rtn "\n")
-                       "\n")
-                      "\n")))
-            (t
-             (error "Don't know how to markup source or example block in %s"
-                    (upcase backend-name)))))
-      (setq rtn
-           (concat
-            "\n#+BEGIN_" backend-name "\n"
-            (org-add-props rtn
-                '(org-protected t org-example t org-native-text t))
-            "\n#+END_" backend-name "\n"))
-      (org-add-props rtn nil 'original-indentation indent))))
-
-(defun org-export-number-lines (text &optional skip1 skip2 number cont
-                                    replace-labels label-format preprocess)
-  "Apply line numbers to literal examples and handle code references.
-Handle user-specified options under info node `(org)Literal
-examples' and return the modified source block.
-
-TEXT contains the source or example block.
-
-SKIP1 and SKIP2 are the number of lines that are to be skipped at
-the beginning and end of TEXT.  Use these to skip over
-backend-specific lines pre-pended or appended to the original
-source block.
-
-NUMBER is non-nil if the literal example specifies \"+n\" or
-\"-n\" switch.  If NUMBER is non-nil add line numbers.
-
-CONT is non-nil if the literal example specifies \"+n\" switch.
-If CONT is nil, start numbering this block from 1.  Otherwise
-continue numbering from the last numbered block.
-
-REPLACE-LABELS is dual-purpose.
-1. It controls the retention of labels in the exported block.
-2. It specifies in what manner the links (or references) to a
-   labeled line be formatted.
-
-REPLACE-LABELS is the symbol `keep' if the literal example
-specifies \"-k\" option, is numeric if the literal example
-specifies \"-r\" option and is nil otherwise.
-
-Handle REPLACE-LABELS as below:
-- If nil, retain labels in the exported block and use
-  user-provided labels for referencing the labeled lines.
-- If it is a number, remove labels in the exported block and use
-  one of line numbers or labels for referencing labeled lines based
-  on NUMBER option.
-- If it is a keep, retain labels in the exported block and use
-  one of line numbers or labels for referencing labeled lines
-  based on NUMBER option.
-
-LABEL-FORMAT is the value of \"-l\" switch associated with
-literal example.  See `org-coderef-label-format'.
-
-PREPROCESS is intended for backend-agnostic handling of source
-block numbering.  When non-nil do the following:
-- do not number the lines
-- always strip the labels from exported block
-- do not make the labeled line a target of an incoming link.
-  Instead mark the labeled line with `org-coderef' property and
-  store the label in it."
-  (setq skip1 (or skip1 0) skip2 (or skip2 0))
-  (if (and number (not cont)) (setq org-export-last-code-line-counter-value 0))
-  (with-temp-buffer
-    (insert text)
-    (goto-char (point-max))
-    (skip-chars-backward " \t\n\r")
-    (delete-region (point) (point-max))
-    (beginning-of-line (- 1 skip2))
-    (let* ((last (org-current-line))
-          (n org-export-last-code-line-counter-value)
-          (nmax (+ n (- last skip1)))
-          (fmt (format "%%%dd:  " (length (number-to-string nmax))))
-          (fm
-           (cond
-            ((eq org-export-current-backend 'html) (format "<span class=\"linenr\">%s</span>"
-                                                           fmt))
-            ((eq org-export-current-backend 'ascii) fmt)
-            ((eq org-export-current-backend 'latex) fmt)
-            ((eq org-export-current-backend 'docbook) fmt)
-            (t "")))
-          (label-format (or label-format org-coderef-label-format))
-          (label-pre (if (string-match "%s" label-format)
-                         (substring label-format 0 (match-beginning 0))
-                       label-format))
-          (label-post (if (string-match "%s" label-format)
-                          (substring label-format (match-end 0))
-                        ""))
-          (lbl-re
-           (concat
-            ".*?\\S-.*?\\([ \t]*\\("
-            (regexp-quote label-pre)
-            "\\([-a-zA-Z0-9_ ]+\\)"
-            (regexp-quote label-post)
-            "\\)\\)"))
-          ref)
-
-      (org-goto-line (1+ skip1))
-      (while (and (re-search-forward "^" nil t) (not (eobp)) (< n nmax))
-       (when number (incf n))
-       (if (or preprocess (not number))
-           (forward-char 1)
-         (insert (format fm n)))
-       (when (looking-at lbl-re)
-         (setq ref (match-string 3))
-         (cond ((numberp replace-labels)
-                ;; remove labels; use numbers for references when lines
-                ;; are numbered, use labels otherwise
-                (delete-region (match-beginning 1) (match-end 1))
-                (push (cons ref (if (> n 0) n ref)) org-export-code-refs))
-               ((eq replace-labels 'keep)
-                ;; don't remove labels; use numbers for references when
-                ;; lines are numbered, use labels otherwise
-                (goto-char (match-beginning 2))
-                (delete-region (match-beginning 2) (match-end 2))
-                (unless preprocess
-                  (insert "(" ref ")"))
-                (push (cons ref (if (> n 0) n (concat "(" ref ")")))
-                      org-export-code-refs))
-               (t
-                ;; don't remove labels and don't use numbers for
-                ;; references
-                (goto-char (match-beginning 2))
-                (delete-region (match-beginning 2) (match-end 2))
-                (unless preprocess
-                  (insert "(" ref ")"))
-                (push (cons ref (concat "(" ref ")")) org-export-code-refs)))
-         (when (and (eq org-export-current-backend 'html) (not preprocess))
-           (save-excursion
-             (beginning-of-line 1)
-             (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
-                             ref))
-             (end-of-line 1)
-             (insert "</span>")))
-         (when preprocess
-           (add-text-properties
-            (point-at-bol) (point-at-eol) (list 'org-coderef ref)))))
-      (setq org-export-last-code-line-counter-value n)
-      (goto-char (point-max))
-      (newline)
-      (buffer-string))))
-
-(defun org-search-todo-below (line lines level)
-  "Search the subtree below LINE for any TODO entries."
-  (let ((rest (cdr (memq line lines)))
-       (re org-todo-line-regexp)
-       line lv todo)
-    (catch 'exit
-      (while (setq line (pop rest))
-       (if (string-match re line)
-           (progn
-             (setq lv (- (match-end 1) (match-beginning 1))
-                   todo (and (match-beginning 2)
-                             (not (member (match-string 2 line)
-                                          org-done-keywords))))
-                                       ; TODO, not DONE
-             (if (<= lv level) (throw 'exit nil))
-             (if todo (throw 'exit t))))))))
-
-;;;###autoload
-(defun org-export-visible (type arg)
-  "Create a copy of the visible part of the current buffer, and export it.
-The copy is created in a temporary buffer and removed after use.
-TYPE is the final key (as a string) that also selects the export command in
-the \\<org-mode-map>\\[org-export] export dispatcher.
-As a special case, if the you type SPC at the prompt, the temporary
-org-mode file will not be removed but presented to you so that you can
-continue to use it.  The prefix arg ARG is passed through to the exporting
-command."
-  (interactive
-   (list (progn
-          (message "Export visible: [a]SCII  [h]tml  [b]rowse HTML [H/R]buffer with HTML  [D]ocBook  [l]atex  [p]df  [d]view pdf  [L]atex buffer  [x]OXO  [ ]keep buffer")
-          (read-char-exclusive))
-        current-prefix-arg))
-  (if (not (member type '(?a ?n ?u ?\C-a ?b ?\C-b ?h ?D ?x ?\ ?l ?p ?d ?L ?H ?R)))
-      (error "Invalid export key"))
-  (let* ((binding (cdr (assoc type
-                             '(
-                               (?a . org-export-as-ascii)
-                               (?A . org-export-as-ascii-to-buffer)
-                               (?n . org-export-as-latin1)
-                               (?N . org-export-as-latin1-to-buffer)
-                               (?u . org-export-as-utf8)
-                               (?U . org-export-as-utf8-to-buffer)
-                               (?\C-a . org-export-as-ascii)
-                               (?b . org-export-as-html-and-open)
-                               (?\C-b . org-export-as-html-and-open)
-                               (?h . org-export-as-html)
-                               (?H . org-export-as-html-to-buffer)
-                               (?R . org-export-region-as-html)
-                               (?D . org-export-as-docbook)
-
-                               (?l . org-export-as-latex)
-                               (?p . org-export-as-pdf)
-                               (?d . org-export-as-pdf-and-open)
-                               (?L . org-export-as-latex-to-buffer)
-
-                               (?x . org-export-as-xoxo)))))
-        (keepp (equal type ?\ ))
-        (file buffer-file-name)
-        (buffer (get-buffer-create "*Org Export Visible*"))
-        s e)
-    ;; Need to hack the drawers here.
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward org-drawer-regexp nil t)
-       (goto-char (match-beginning 1))
-       (or (outline-invisible-p) (org-flag-drawer nil))))
-    (with-current-buffer buffer (erase-buffer))
-    (save-excursion
-      (setq s (goto-char (point-min)))
-      (while (not (= (point) (point-max)))
-       (goto-char (org-find-invisible))
-       (append-to-buffer buffer s (point))
-       (setq s (goto-char (org-find-visible))))
-      (org-cycle-hide-drawers 'all)
-      (goto-char (point-min))
-      (unless keepp
-       ;; Copy all comment lines to the end, to make sure #+ settings are
-       ;; still available for the second export step.  Kind of a hack, but
-       ;; does do the trick.
-       (if (looking-at "#[^\r\n]*")
-           (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0))))
-       (when (re-search-forward "^\\*+[ \t]+" nil t)
-         (while (re-search-backward "[\n\r]#[^\n\r]*" nil t)
-           (append-to-buffer buffer (1+ (match-beginning 0))
-                             (min (point-max) (1+ (match-end 0)))))))
-      (set-buffer buffer)
-      (let ((buffer-file-name file)
-           (org-inhibit-startup t))
-       (org-mode)
-       (show-all)
-       (unless keepp (funcall binding arg))))
-    (if (not keepp)
-       (kill-buffer buffer)
-      (switch-to-buffer-other-window buffer)
-      (goto-char (point-min)))))
-
-(defvar org-export-htmlized-org-css-url) ;; defined in org-html.el
-
-(defun org-export-string (string fmt &optional dir)
-  "Export STRING to FMT using existing export facilities.
-During export STRING is saved to a temporary file whose location
-could vary.  Optional argument DIR can be used to force the
-directory in which the temporary file is created during export
-which can be useful for resolving relative paths.  Dir defaults
-to the value of `temporary-file-directory'."
-  (let ((temporary-file-directory (or dir temporary-file-directory))
-       (tmp-file (make-temp-file "org-")))
-    (unwind-protect
-       (with-temp-buffer
-         (insert string)
-         (write-file tmp-file)
-         (org-load-modules-maybe)
-         (unless org-local-vars
-           (setq org-local-vars (org-get-local-variables)))
-         (eval ;; convert to fmt -- mimicking `org-run-like-in-org-mode'
-          (list 'let org-local-vars
-                (list (intern (format "org-export-as-%s" fmt))
-                      nil nil ''string t dir))))
-      (delete-file tmp-file))))
-
-;;;###autoload
-(defun org-export-as-org (arg &optional ext-plist to-buffer body-only pub-dir)
-  "Make a copy with not-exporting stuff removed.
-The purpose of this function is to provide a way to export the source
-Org file of a webpage in Org format, but with sensitive and/or irrelevant
-stuff removed.  This command will remove the following:
-
-- archived trees (if the variable `org-export-with-archived-trees' is nil)
-- comment blocks and trees starting with the COMMENT keyword
-- only trees that are consistent with `org-export-select-tags'
-  and `org-export-exclude-tags'.
-
-The only arguments that will be used are EXT-PLIST and PUB-DIR,
-all the others will be ignored (but are present so that the general
-mechanism to call publishing functions will work).
-
-EXT-PLIST is a property list with external parameters overriding
-org-mode's default settings, but still inferior to file-local
-settings.  When PUB-DIR is set, use this as the publishing
-directory."
-  (interactive "P")
-  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
-                                       ext-plist
-                                       (org-infile-export-plist)))
-        (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
-        (filename (concat (file-name-as-directory
-                           (or pub-dir
-                               (org-export-directory :org opt-plist)))
-                          (file-name-sans-extension
-                           (file-name-nondirectory bfname))
-                          ".org"))
-        (filename (and filename
-                       (if (equal (file-truename filename)
-                                  (file-truename bfname))
-                           (concat (file-name-sans-extension filename)
-                                   "-source."
-                                   (file-name-extension filename))
-                         filename)))
-        (backup-inhibited t)
-        (buffer (find-file-noselect filename))
-        (region (buffer-string))
-         str-ret)
-    (save-excursion
-      (org-pop-to-buffer-same-window buffer)
-      (erase-buffer)
-      (insert region)
-      (let ((org-inhibit-startup t)) (org-mode))
-      (org-install-letbind)
-
-      ;; Get rid of archived trees
-      (org-export-remove-archived-trees (plist-get opt-plist :archived-trees))
-
-      ;; Remove comment environment and comment subtrees
-      (org-export-remove-comment-blocks-and-subtrees)
-
-      ;; Get rid of excluded trees
-      (org-export-handle-export-tags (plist-get opt-plist :select-tags)
-                                    (plist-get opt-plist :exclude-tags))
-
-      (when (or (plist-get opt-plist :plain-source)
-               (not (or (plist-get opt-plist :plain-source)
-                        (plist-get opt-plist :htmlized-source))))
-       ;; Either nothing special is requested (default call)
-       ;; or the plain source is explicitly requested
-       ;; so: save it
-       (save-buffer))
-      (when (plist-get opt-plist :htmlized-source)
-       ;; Make the htmlized version
-       (require 'htmlize)
-       (require 'org-html)
-       (font-lock-fontify-buffer)
-       (let* ((htmlize-output-type 'css)
-              (newbuf (htmlize-buffer)))
-         (with-current-buffer newbuf
-           (when org-export-htmlized-org-css-url
-             (goto-char (point-min))
-             (and (re-search-forward
-                   "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*"
-                   nil t)
-                  (replace-match
-                   (format
-                    "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
-                    org-export-htmlized-org-css-url)
-                   t t)))
-           (write-file (concat filename ".html")))
-         (kill-buffer newbuf)))
-      (set-buffer-modified-p nil)
-      (if (equal to-buffer 'string)
-          (progn (setq str-ret (buffer-string))
-                 (kill-buffer (current-buffer))
-                 str-ret)
-        (kill-buffer (current-buffer))))))
-
-(defvar org-archive-location)  ;; gets loaded with the org-archive require.
-(defun org-get-current-options ()
-  "Return a string with current options as keyword options.
-Does include HTML export options as well as TODO and CATEGORY stuff."
-  (require 'org-archive)
-  (format
-   "#+TITLE:     %s
-#+AUTHOR:    %s
-#+EMAIL:     %s
-#+DATE:      %s
-#+DESCRIPTION:
-#+KEYWORDS:
-#+LANGUAGE:  %s
-#+OPTIONS:   H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
-#+OPTIONS:   TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
-%s
-#+EXPORT_SELECT_TAGS: %s
-#+EXPORT_EXCLUDE_TAGS: %s
-#+LINK_UP:   %s
-#+LINK_HOME: %s
-#+XSLT:
-#+CATEGORY:  %s
-#+SEQ_TODO:  %s
-#+TYP_TODO:  %s
-#+PRIORITIES: %c %c %c
-#+DRAWERS:   %s
-#+STARTUP:   %s %s %s %s %s
-#+TAGS:      %s
-#+FILETAGS:  %s
-#+ARCHIVE:   %s
-#+LINK:      %s
-"
-   (buffer-name) (user-full-name) user-mail-address
-   (format-time-string (substring (car org-time-stamp-formats) 1 -1))
-   org-export-default-language
-   org-export-headline-levels
-   org-export-with-section-numbers
-   org-export-with-toc
-   org-export-preserve-breaks
-   org-export-html-expand
-   org-export-with-fixed-width
-   org-export-with-tables
-   org-export-with-sub-superscripts
-   org-export-with-special-strings
-   org-export-with-footnotes
-   org-export-with-emphasize
-   org-export-with-timestamps
-   org-export-with-TeX-macros
-   org-export-with-LaTeX-fragments
-   org-export-skip-text-before-1st-heading
-   org-export-with-drawers
-   org-export-with-todo-keywords
-   org-export-with-priority
-   org-export-with-tags
-   (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
-   (mapconcat 'identity org-export-select-tags " ")
-   (mapconcat 'identity org-export-exclude-tags " ")
-   org-export-html-link-up
-   org-export-html-link-home
-   (or (ignore-errors
-        (file-name-sans-extension
-         (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
-       "NOFILENAME")
-   "TODO FEEDBACK VERIFY DONE"
-   "Me Jason Marie DONE"
-   org-highest-priority org-lowest-priority org-default-priority
-   (mapconcat 'identity org-drawers " ")
-   (cdr (assoc org-startup-folded
-              '((nil . "showall") (t . "overview") (content . "content"))))
-   (if org-odd-levels-only "odd" "oddeven")
-   (if org-hide-leading-stars "hidestars" "showstars")
-   (if org-startup-align-all-tables "align" "noalign")
-   (cond ((eq org-log-done t) "logdone")
-        ((equal org-log-done 'note) "lognotedone")
-        ((not org-log-done) "nologdone"))
-   (or (mapconcat (lambda (x)
-                   (cond
-                    ((equal :startgroup (car x)) "{")
-                    ((equal :endgroup (car x)) "}")
-                    ((equal :newline (car x)) "")
-                    ((cdr x) (format "%s(%c)" (car x) (cdr x)))
-                    (t (car x))))
-                 (or org-tag-alist (org-get-buffer-tags)) " ") "")
-   (mapconcat 'identity org-file-tags " ")
-   org-archive-location
-   "org file:~/org/%s.org"))
-
-(defun org-insert-export-options-template ()
-  "Insert into the buffer a template with information for exporting."
-  (interactive)
-  (if (not (bolp)) (newline))
-  (let ((s (org-get-current-options)))
-    (and (string-match "#\\+CATEGORY" s)
-        (setq s (substring s 0 (match-beginning 0))))
-    (insert s)))
-
-(defvar org-table-colgroup-info nil)
-
-(defun org-table-clean-before-export (lines &optional maybe-quoted)
-  "Check if the table has a marking column.
-If yes remove the column and the special lines."
-  (setq org-table-colgroup-info nil)
-  (if (memq nil
-           (mapcar
-            (lambda (x) (or (string-match "^[ \t]*|-" x)
-                            (string-match
-                             (if maybe-quoted
-                                 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
-                               "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
-                             x)))
-            lines))
-      ;; No special marking column
-      (progn
-       (setq org-table-clean-did-remove-column nil)
-       (delq nil
-             (mapcar
-              (lambda (x)
-                (cond
-                 ((org-table-colgroup-line-p x)
-                  ;; This line contains colgroup info, extract it
-                  ;; and then discard the line
-                  (setq org-table-colgroup-info
-                        (mapcar (lambda (x)
-                                  (cond ((member x '("<" "&lt;")) :start)
-                                        ((member x '(">" "&gt;")) :end)
-                                        ((member x '("<>" "&lt;&gt;")) :startend)))
-                                (org-split-string x "[ \t]*|[ \t]*")))
-                  nil)
-                 ((org-table-cookie-line-p x)
-                  ;; This line contains formatting cookies, discard it
-                  nil)
-                 (t x)))
-              lines)))
-    ;; there is a special marking column
-    (setq org-table-clean-did-remove-column t)
-    (delq nil
-         (mapcar
-          (lambda (x)
-            (cond
-             ((org-table-colgroup-line-p x)
-              ;; This line contains colgroup info, extract it
-              ;; and then discard the line
-              (setq org-table-colgroup-info
-                    (mapcar (lambda (x)
-                              (cond ((member x '("<" "&lt;")) :start)
-                                    ((member x '(">" "&gt;")) :end)
-                                    ((member x '("<>" "&lt;&gt;")) :startend)))
-                            (cdr (org-split-string x "[ \t]*|[ \t]*"))))
-              nil)
-             ((org-table-cookie-line-p x)
-              ;; This line contains formatting cookies, discard it
-              nil)
-             ((string-match "^[ \t]*| *\\([!_^/$]\\|\\\\\\$\\) *|" x)
-              ;; ignore this line
-              nil)
-             ((or (string-match "^\\([ \t]*\\)|-+\\+" x)
-                  (string-match "^\\([ \t]*\\)|[^|]*|" x))
-              ;; remove the first column
-              (replace-match "\\1|" t nil x))))
-          lines))))
-
-(defun org-export-cleanup-toc-line (s)
-  "Remove tags and timestamps from lines going into the toc."
-  (if (not s)
-      "" ; Return a string when argument is nil
-    (when (memq org-export-with-tags '(not-in-toc nil))
-      (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s)
-         (setq s (replace-match "" t t s))))
-    (when org-export-remove-timestamps-from-toc
-      (while (string-match org-maybe-keyword-time-regexp s)
-       (setq s (replace-match "" t t s))))
-    (while (string-match org-bracket-link-regexp s)
-      (setq s (replace-match (match-string (if (match-end 3) 3 1) s)
-                            t t s)))
-    (while (string-match "\\[\\([0-9]\\|fn:[^]]*\\)\\]" s)
-      (setq s (replace-match "" t t s)))
-    s))
-
-
-(defun org-get-text-property-any (pos prop &optional object)
-  (or (get-text-property pos prop object)
-      (and (setq pos (next-single-property-change pos prop object))
-          (get-text-property pos prop object))))
-
-(defun org-export-get-coderef-format (path desc)
-  (save-match-data
-    (if (and desc (string-match
-                  (regexp-quote (concat "(" path ")"))
-                  desc))
-       (replace-match "%s" t t desc)
-      (or desc "%s"))))
-
-(defun org-export-push-to-kill-ring (format)
-  "Push buffer content to kill ring.
-The depends on the variable `org-export-copy-to-kill-ring'."
-  (when org-export-copy-to-kill-ring
-    (org-kill-new (buffer-string))
-    (when (fboundp 'x-set-selection)
-      (ignore-errors (x-set-selection 'PRIMARY (buffer-string)))
-      (ignore-errors (x-set-selection 'CLIPBOARD (buffer-string))))
-    (message "%s export done, pushed to kill ring and clipboard" format)))
-
-(provide 'org-exp)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-exp.el ends here
index 606db0814c26c5a9fe5a8854c68e8667210811a9..d64fd0e1ac18071e5f24da32cf7f98ee431da264 100644 (file)
@@ -202,7 +202,7 @@ set the properties in the `org-column' face.  For example, set
 
 Under XEmacs, the rules are simpler, because the XEmacs version of
 column view defines special faces for each outline level.  See the file
-`org-colview-xemacs.el' for details."
+`org-colview-xemacs.el' in Org's contrib/ directory for details."
   :group 'org-faces)
 
 (defface org-column-title
@@ -217,12 +217,6 @@ column view defines special faces for each outline level.  See the file
   "Face for column display of entry properties."
   :group 'org-faces)
 
-(when (fboundp 'set-face-attribute)
-  ;; Make sure that a fixed-width face is used when we have a column table.
-  (set-face-attribute 'org-column nil
-                     :height (face-attribute 'default :height)
-                     :family (face-attribute 'default :family)))
-
 (defface org-agenda-column-dateline
   (org-compatible-face 'org-column
     '((t nil)))
@@ -264,7 +258,7 @@ column view defines special faces for each outline level.  See the file
   '((((class color) (background light)) (:foreground "Purple" :underline t))
     (((class color) (background dark)) (:foreground "Cyan" :underline t))
     (t (:underline t)))
-  "Face for links."
+  "Face for footnotes."
   :group 'org-faces)
 
 (defface org-ellipsis
@@ -394,6 +388,14 @@ determines if it is a foreground or a background color."
                   (string :tag "Color")
                   (sexp :tag "Face")))))
 
+(defface org-priority ;; originally copied from font-lock-string-face
+  (org-compatible-face 'font-lock-keyword-face
+    '((((class color) (min-colors 16) (background light)) (:foreground "RosyBrown"))
+      (((class color) (min-colors 16) (background dark)) (:foreground "LightSalmon"))
+      (t (:italic t))))
+  "Face used for priority cookies."
+  :group 'org-faces)
+
 (defcustom org-priority-faces nil
   "Faces for specific Priorities.
 This is a list of cons cells, with priority character in the car
@@ -685,25 +687,28 @@ month and 365.24 days for a year)."
 
 (defface org-agenda-restriction-lock
   (org-compatible-face nil
-    '((((class color) (min-colors 88) (background light)) (:background "yellow1"))
-      (((class color) (min-colors 88) (background dark))  (:background "skyblue4"))
-      (((class color) (min-colors 16) (background light)) (:background "yellow1"))
-      (((class color) (min-colors 16) (background dark))  (:background "skyblue4"))
+    '((((class color) (min-colors 88) (background light)) (:background "#eeeeee"))
+      (((class color) (min-colors 88) (background dark))  (:background "#1C1C1C"))
+      (((class color) (min-colors 16) (background light)) (:background "#eeeeee"))
+      (((class color) (min-colors 16) (background dark))  (:background "#1C1C1C"))
       (((class color) (min-colors 8)) (:background "cyan" :foreground "black"))
       (t (:inverse-video t))))
   "Face for showing the agenda restriction lock."
   :group 'org-faces)
 
 (defface org-agenda-filter-tags
-  (org-compatible-face 'mode-line
-    nil)
+  (org-compatible-face 'mode-line nil)
   "Face for tag(s) in the mode-line when filtering the agenda."
   :group 'org-faces)
 
+(defface org-agenda-filter-regexp
+  (org-compatible-face 'mode-line nil)
+  "Face for regexp(s) in the mode-line when filtering the agenda."
+  :group 'org-faces)
+
 (defface org-agenda-filter-category
-  (org-compatible-face 'mode-line
-    nil)
-  "Face for tag(s) in the mode-line when filtering the agenda."
+  (org-compatible-face 'mode-line nil)
+  "Face for categories(s) in the mode-line when filtering the agenda."
   :group 'org-faces)
 
 (defface org-time-grid ;; originally copied from font-lock-variable-name-face
@@ -718,20 +723,17 @@ month and 365.24 days for a year)."
   "Face used to show the current time in the time grid.")
 
 (defface org-agenda-diary
-  (org-compatible-face 'default
-    nil)
+  (org-compatible-face 'default nil)
   "Face used for agenda entries that come from the Emacs diary."
   :group 'org-faces)
 
 (defface org-agenda-calendar-event
-  (org-compatible-face 'default
-    nil)
+  (org-compatible-face 'default nil)
   "Face used to show events and appointments in the agenda."
   :group 'org-faces)
 
 (defface org-agenda-calendar-sexp
-  (org-compatible-face 'default
-    nil)
+  (org-compatible-face 'default nil)
   "Face used to show events computed from a S-expression."
   :group 'org-faces)
 
@@ -757,7 +759,7 @@ level org-n-level-faces"
   :version "24.1"
   :type 'boolean)
 
-(defface org-latex-and-export-specials
+(defface org-latex-and-related
   (let ((font (cond ((assq :inherit custom-face-attributes)
                     '(:inherit underline))
                    (t '(:underline t)))))
@@ -770,8 +772,24 @@ level org-n-level-faces"
       (((class color) (background dark))
        (:foreground "burlywood"))
       (t (,@font))))
-  "Face used to highlight math latex and other special exporter stuff."
-  :group 'org-faces)
+  "Face used to highlight LaTeX data, entities and sub/superscript."
+  :group 'org-faces
+  :version "24.4"
+  :package-version '(Org . "8.0"))
+
+(defface org-macro
+  (org-compatible-face 'org-latex-and-related nil)
+  "Face for macros."
+  :group 'org-faces
+  :version "24.4"
+  :package-version '(Org . "8.0"))
+
+(defface org-tag-group
+  (org-compatible-face 'org-tag nil)
+  "Face for group tags."
+  :group 'org-faces
+  :version "24.4"
+  :package-version '(Org . "8.0"))
 
 (org-copy-face 'mode-line 'org-mode-line-clock
   "Face used for clock display in mode line.")
index 4cde24bf57fc49d003e56f3304ddccb254925f5e..3c0d97c3a411bb90c3ddfe584fb6b65806449cfc 100644 (file)
@@ -42,8 +42,6 @@
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-combine-plists "org" (&rest plists))
 (declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading))
-(declare-function org-export-preprocess-string "org-exp"
-                 (string &rest parameters))
 (declare-function org-fill-paragraph "org" (&optional justify))
 (declare-function org-icompleting-read "org" (&rest args))
 (declare-function org-id-uuid "org-id" ())
@@ -87,7 +85,7 @@
   "Regular expression matching the definition of a footnote.")
 
 (defconst org-footnote-forbidden-blocks
-  '("ascii" "beamer" "comment" "docbook" "example" "html" "latex" "odt" "src")
+  '("ascii" "beamer" "comment" "example" "html" "latex" "odt" "src")
   "Names of blocks where footnotes are not allowed.")
 
 (defgroup org-footnote nil
   :group 'org)
 
 (defcustom org-footnote-section "Footnotes"
-  "Outline heading containing footnote definitions before export.
-This can be nil, to place footnotes locally at the end of the current
-outline node.  If can also be the name of a special outline heading
-under which footnotes should be put.
+  "Outline heading containing footnote definitions.
+
+This can be nil, to place footnotes locally at the end of the
+current outline node.  If can also be the name of a special
+outline heading under which footnotes should be put.
+
 This variable defines the place where Org puts the definition
-automatically, i.e. when creating the footnote, and when sorting the notes.
-However, by hand you may place definitions *anywhere*.
-If this is a string, during export, all subtrees starting with this
-heading will be removed after extracting footnote definitions."
+automatically, i.e. when creating the footnote, and when sorting
+the notes.  However, by hand you may place definitions
+*anywhere*.
+
+If this is a string, during export, all subtrees starting with
+this heading will be ignored."
   :group 'org-footnote
   :type '(choice
          (string :tag "Collect footnotes under heading")
@@ -136,13 +138,13 @@ will be used to define the footnote at the reference position."
   "Non-nil means define automatically new labels for footnotes.
 Possible values are:
 
-nil        prompt the user for each label
-t          create unique labels of the form [fn:1], [fn:2], ...
-confirm    like t, but let the user edit the created value.  In particular,
-           the label can be removed from the minibuffer, to create
+nil        Prompt the user for each label.
+t          Create unique labels of the form [fn:1], [fn:2], etc.
+confirm    Like t, but let the user edit the created value.
+           The label can be removed from the minibuffer to create
            an anonymous footnote.
 random    Automatically generate a unique, random label.
-plain      Automatically create plain number labels like [1]"
+plain      Automatically create plain number labels like [1]."
   :group 'org-footnote
   :type '(choice
          (const :tag "Prompt for label" nil)
@@ -164,6 +166,7 @@ The main values of this variable can be set with in-buffer options:
 #+STARTUP: nofnadjust"
   :group 'org-footnote
   :type '(choice
+         (const :tag "No adjustment" nil)
          (const :tag "Renumber" renumber)
          (const :tag "Sort" sort)
          (const :tag "Renumber and Sort" t)))
@@ -182,8 +185,6 @@ extracted will be filled again."
     (not (or (org-in-commented-line)
             (org-in-indented-comment-line)
             (org-inside-LaTeX-fragment-p)
-            ;; Avoid protected environments (LaTeX export)
-            (get-text-property (point) 'org-protected)
             ;; Avoid literal example.
             (org-in-verbatim-emphasis)
             (save-excursion
@@ -230,13 +231,7 @@ positions, and the definition, when inlined."
                                 (org-in-regexp org-bracket-link-regexp))))
                          (and linkp (< (point) (cdr linkp))))))
                 ;; Verify point doesn't belong to a LaTeX macro.
-                ;; Beware though, when two footnotes are side by
-                ;; side, once the first one is changed into LaTeX,
-                ;; the second one might then be considered as an
-                ;; optional argument of the command.  Thus, check
-                ;; the `org-protected' property of that command.
-                (or (not (org-inside-latex-macro-p))
-                    (get-text-property (1- beg) 'org-protected)))
+                (not (org-inside-latex-macro-p)))
        (list label beg end
              ;; Definition: ensure this is an inline footnote first.
              (and (or (not label) (match-string 1))
@@ -257,11 +252,12 @@ otherwise."
   (when (save-excursion (beginning-of-line) (org-footnote-in-valid-context-p))
     (save-excursion
       (end-of-line)
-      ;; Footnotes definitions are separated by new headlines or blank
-      ;; lines.
-      (let ((lim (save-excursion (re-search-backward
-                                 (concat org-outline-regexp-bol
-                                         "\\|^[ \t]*$") nil t))))
+      ;; Footnotes definitions are separated by new headlines, another
+      ;; footnote definition or 2 blank lines.
+      (let ((lim (save-excursion
+                  (re-search-backward
+                   (concat org-outline-regexp-bol
+                           "\\|^\\([ \t]*\n\\)\\{2,\\}") nil t))))
        (when (re-search-backward org-footnote-definition-re lim t)
          (let ((label (org-match-string-no-properties 1))
                (beg (match-beginning 0))
@@ -277,7 +273,7 @@ otherwise."
                             (re-search-forward
                              (concat org-outline-regexp-bol "\\|"
                                      org-footnote-definition-re "\\|"
-                                     "^[ \t]*$") bound 'move))
+                                     "^\\([ \t]*\n\\)\\{2,\\}") bound 'move))
                           (match-beginning 0)
                         (point)))))
            (list label beg end
@@ -602,38 +598,15 @@ With prefix arg SPECIAL, offer additional commands in a menu."
       (org-footnote-goto-previous-reference (car tmp)))
      (t (org-footnote-new)))))
 
-(defvar org-footnote-insert-pos-for-preprocessor 'point-max
-  "See `org-footnote-normalize'.")
-
-(defvar org-export-footnotes-seen) ; silence byte-compiler
-(defvar org-export-footnotes-data) ; silence byte-compiler
-
 ;;;###autoload
-(defun org-footnote-normalize (&optional sort-only export-props)
+(defun org-footnote-normalize (&optional sort-only)
   "Collect the footnotes in various formats and normalize them.
 
 This finds the different sorts of footnotes allowed in Org, and
-normalizes them to the usual [N] format that is understood by the
-Org-mode exporters.
+normalizes them to the usual [N] format.
 
 When SORT-ONLY is set, only sort the footnote definitions into the
-referenced sequence.
-
-If Org is amidst an export process, EXPORT-PROPS will hold the
-export properties of the buffer.
-
-When EXPORT-PROPS is non-nil, the default action is to insert
-normalized footnotes towards the end of the pre-processing
-buffer.  Some exporters (docbook, odt...) expect footnote
-definitions to be available before any references to them.  Such
-exporters can let bind `org-footnote-insert-pos-for-preprocessor'
-to symbol `point-min' to achieve the desired behaviour.
-
-Additional note on `org-footnote-insert-pos-for-preprocessor':
-1. This variable has not effect when FOR-PREPROCESSOR is nil.
-2. This variable (potentially) obviates the need for extra scan
-   of pre-processor buffer as witnessed in
-   `org-export-docbook-get-footnotes'."
+referenced sequence."
   ;; This is based on Paul's function, but rewritten.
   ;;
   ;; Re-create `org-with-limited-levels', but not limited to Org
@@ -643,17 +616,12 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
               org-inlinetask-min-level
               (1- org-inlinetask-min-level)))
         (nstars (and limit-level
-                     (if org-odd-levels-only
-                         (and limit-level (1- (* limit-level 2)))
+                     (if org-odd-levels-only (1- (* limit-level 2))
                        limit-level)))
         (org-outline-regexp
          (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ ")))
-        ;; Determine the highest marker used so far.
-        (ref-table (when export-props org-export-footnotes-seen))
-        (count (if (and export-props ref-table)
-                   (apply 'max (mapcar (lambda (e) (nth 1 e)) ref-table))
-                 0))
-        ins-point ref)
+        (count 0)
+        ins-point ref ref-table)
     (save-excursion
       ;; 1. Find every footnote reference, extract the definition, and
       ;;    collect that data in REF-TABLE.  If SORT-ONLY is nil, also
@@ -675,15 +643,10 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
          ;; Replace footnote reference with [MARKER].  Maybe fill
          ;; paragraph once done.  If SORT-ONLY is non-nil, only move
          ;; to the end of reference found to avoid matching it twice.
-         ;; If EXPORT-PROPS isn't nil, also add `org-footnote'
-         ;; property to it, so it can be easily recognized by
-         ;; exporters.
          (if sort-only (goto-char (nth 2 ref))
            (delete-region (nth 1 ref) (nth 2 ref))
            (goto-char (nth 1 ref))
-           (let ((new-ref (format "[%d]" marker)))
-             (when export-props (org-add-props new-ref '(org-footnote t)))
-             (insert new-ref))
+           (insert (format "[%d]" marker))
            (and inlinep
                 org-footnote-fill-after-inline-note-extraction
                 (org-fill-paragraph)))
@@ -691,22 +654,9 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
          ;; type (INLINEP) and position (POS) to REF-TABLE if data
          ;; was unknown.
          (unless a
-           (let ((def (or (nth 3 ref)  ; inline
-                          (and export-props
-                               (cdr (assoc lbl org-export-footnotes-data)))
+           (let ((def (or (nth 3 ref)  ; Inline definition.
                           (nth 3 (org-footnote-get-definition lbl)))))
-             (push (list lbl marker
-                         ;; When exporting, each definition goes
-                         ;; through `org-export-preprocess-string' so
-                         ;; it is ready to insert in the
-                         ;; backend-specific buffer.
-                         (if (and export-props def)
-                             (let ((parameters
-                                    (org-combine-plists
-                                     export-props
-                                     '(:todo-keywords t :tags t :priority t))))
-                               (apply #'org-export-preprocess-string def parameters))
-                           def)
+             (push (list lbl marker def
                          ;; Reference beginning position is a marker
                          ;; to preserve it during further buffer
                          ;; modifications.
@@ -728,14 +678,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
        (unless (bolp) (newline)))
        ;; No footnote section set: Footnotes will be added at the end
        ;; of the section containing their first reference.
-       ;; Nevertheless, in an export situation, set insertion point to
-       ;; `point-max' by default.
-       ((derived-mode-p 'org-mode)
-       (when export-props
-         (goto-char (point-max))
-         (skip-chars-backward " \r\t\n")
-         (forward-line)
-         (delete-region (point) (point-max))))
+       ((derived-mode-p 'org-mode))
        (t
        ;; Remove any left-over tag in the buffer, if one is set up.
        (when org-footnote-tag-for-non-org-mode-files
@@ -753,14 +696,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
                 (re-search-backward message-signature-separator nil t))
            (beginning-of-line)
          (goto-char (point-max)))))
-      ;; During export, `org-footnote-insert-pos-for-preprocessor' has
-      ;; precedence over previously found position.
-      (setq ins-point
-           (copy-marker
-            (if (and export-props
-                     (eq org-footnote-insert-pos-for-preprocessor 'point-min))
-                (point-min)
-              (point))))
+      (setq ins-point (point-marker))
       ;; 3. Clean-up REF-TABLE.
       (setq ref-table
            (delq nil
@@ -791,26 +727,22 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
        ;; No footnote: exit.
        ((not ref-table))
        ;; Cases when footnotes should be inserted in one place.
-       ((or (not (derived-mode-p 'org-mode))
-           org-footnote-section
-           export-props)
+       ((or (not (derived-mode-p 'org-mode)) org-footnote-section)
        ;; Insert again the section title, if any.  Ensure that title,
        ;; or the subsequent footnotes, will be separated by a blank
        ;; lines from the rest of the document.  In an Org buffer,
        ;; separate section with a blank line, unless explicitly
        ;; stated in `org-blank-before-new-entry'.
-       (cond
-        ((not (derived-mode-p 'org-mode))
-         (skip-chars-backward " \t\n\r")
-         (delete-region (point) ins-point)
-         (unless (bolp) (newline))
-         (when org-footnote-tag-for-non-org-mode-files
-           (insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
-        ((and org-footnote-section (not export-props))
+       (if (not (derived-mode-p 'org-mode))
+           (progn (skip-chars-backward " \t\n\r")
+                  (delete-region (point) ins-point)
+                  (unless (bolp) (newline))
+                  (when org-footnote-tag-for-non-org-mode-files
+                    (insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
          (when (and (cdr (assq 'heading org-blank-before-new-entry))
                     (zerop (save-excursion (org-back-over-empty-lines))))
            (insert "\n"))
-         (insert "* " org-footnote-section "\n")))
+         (insert "* " org-footnote-section "\n"))
        (set-marker ins-point nil)
        ;; Insert the footnotes, separated by a blank line.
        (insert
@@ -820,10 +752,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
            (set-marker (nth 4 x) nil)
            (format "\n[%s] %s" (nth (if sort-only 0 1) x) (nth 2 x)))
          ref-table "\n"))
-       (unless (eobp) (insert "\n\n"))
-       ;; When exporting, add newly inserted markers along with their
-       ;; associated definition to `org-export-footnotes-seen'.
-       (when export-props (setq org-export-footnotes-seen ref-table)))
+       (unless (eobp) (insert "\n\n")))
        ;; Each footnote definition has to be inserted at the end of
        ;; the section where its first reference belongs.
        (t
diff --git a/lisp/org/org-freemind.el b/lisp/org/org-freemind.el
deleted file mode 100644 (file)
index 2ee5850..0000000
+++ /dev/null
@@ -1,1227 +0,0 @@
-;;; org-freemind.el --- Export Org files to freemind
-
-;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
-
-;; Author: Lennart Borgman (lennart O borgman A gmail O com)
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;; --------------------------------------------------------------------
-;; Features that might be required by this library:
-;;
-;; `backquote', `bytecomp', `cl', `easymenu', `font-lock',
-;; `noutline', `org', `org-compat', `org-faces', `org-footnote',
-;; `org-list', `org-macs', `org-src', `outline', `syntax',
-;; `time-date', `xml'.
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-;;
-;; This file tries to implement some functions useful for
-;; transformation between org-mode and FreeMind files.
-;;
-;; Here are the commands you can use:
-;;
-;;    M-x `org-freemind-from-org-mode'
-;;    M-x `org-freemind-from-org-mode-node'
-;;    M-x `org-freemind-from-org-sparse-tree'
-;;
-;;    M-x `org-freemind-to-org-mode'
-;;
-;;    M-x `org-freemind-show'
-;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Change log:
-;;
-;; 2009-02-15: Added check for next level=current+1
-;; 2009-02-21: Fixed bug in `org-freemind-to-org-mode'.
-;; 2009-10-25: Added support for `org-odd-levels-only'.
-;;             Added y/n question before showing in FreeMind.
-;; 2009-11-04: Added support for #+BEGIN_HTML.
-;;
-;;; Code:
-
-(require 'xml)
-(require 'org)
-                                       ;(require 'rx)
-(require 'org-exp)
-(eval-when-compile (require 'cl))
-
-(defgroup org-freemind nil
-  "Customization group for org-freemind export/import."
-  :group 'org)
-
-;; Fix-me: I am not sure these are useful:
-;;
-;; (defcustom org-freemind-main-fgcolor "black"
-;;   "Color of main node's text."
-;;   :type 'color
-;;   :group 'org-freemind)
-
-;; (defcustom org-freemind-main-color "black"
-;;   "Background color of main node."
-;;   :type 'color
-;;   :group 'org-freemind)
-
-;; (defcustom org-freemind-child-fgcolor "black"
-;;   "Color of child nodes' text."
-;;   :type 'color
-;;   :group 'org-freemind)
-
-;; (defcustom org-freemind-child-color "black"
-;;   "Background color of child nodes."
-;;   :type 'color
-;;   :group 'org-freemind)
-
-(defvar org-freemind-node-style nil "Internal use.")
-
-(defcustom org-freemind-node-styles nil
-  "Styles to apply to node.
-NOT READY YET."
-  :type '(repeat
-          (list :tag "Node styles for file"
-                (regexp :tag "File name")
-                (repeat
-                 (list :tag "Node"
-                       (regexp :tag "Node name regexp")
-                       (set :tag "Node properties"
-                            (list :format "%v" (const :format "" node-style)
-                                  (choice :tag "Style"
-                                          :value bubble
-                                          (const bubble)
-                                          (const fork)))
-                            (list :format "%v" (const :format "" color)
-                                  (color :tag "Color" :value "red"))
-                            (list :format "%v" (const :format "" background-color)
-                                  (color :tag "Background color" :value "yellow"))
-                            (list :format "%v" (const :format "" edge-color)
-                                  (color :tag "Edge color" :value "green"))
-                            (list :format "%v" (const :format "" edge-style)
-                                  (choice :tag "Edge style" :value bezier
-                                          (const :tag "Linear" linear)
-                                          (const :tag "Bezier" bezier)
-                                          (const :tag "Sharp Linear" sharp-linear)
-                                          (const :tag "Sharp Bezier" sharp-bezier)))
-                            (list :format "%v" (const :format "" edge-width)
-                                  (choice :tag "Edge width" :value thin
-                                          (const :tag "Parent" parent)
-                                          (const :tag "Thin" thin)
-                                          (const 1)
-                                          (const 2)
-                                          (const 4)
-                                          (const 8)))
-                            (list :format "%v" (const :format "" italic)
-                                  (const :tag "Italic font" t))
-                            (list :format "%v" (const :format "" bold)
-                                  (const :tag "Bold font" t))
-                            (list :format "%v" (const :format "" font-name)
-                                  (string :tag "Font name" :value "SansSerif"))
-                            (list :format "%v" (const :format "" font-size)
-                                  (integer :tag "Font size" :value 12)))))))
-  :group 'org-freemind)
-
-;;;###autoload
-(defun org-export-as-freemind (&optional hidden ext-plist
-                                        to-buffer body-only pub-dir)
-  "Export the current buffer as a Freemind file.
-If there is an active region, export only the region.  HIDDEN is
-obsolete and does nothing.  EXT-PLIST is a property list with
-external parameters overriding org-mode's default settings, but
-still inferior to file-local settings.  When TO-BUFFER is
-non-nil, create a buffer with that name and export to that
-buffer.  If TO-BUFFER is the symbol `string', don't leave any
-buffer behind but just return the resulting HTML as a string.
-When BODY-ONLY is set, don't produce the file header and footer,
-simply return the content of the document (all top level
-sections).  When PUB-DIR is set, use this as the publishing
-directory.
-
-See `org-freemind-from-org-mode' for more information."
-  (interactive "P")
-  (let* ((opt-plist (org-combine-plists (org-default-export-plist)
-                                       ext-plist
-                                       (org-infile-export-plist)))
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
-        (filename (concat (file-name-as-directory
-                           (or pub-dir
-                               (org-export-directory :ascii opt-plist)))
-                          (file-name-sans-extension
-                           (or (and subtree-p
-                                    (org-entry-get (region-beginning)
-                                                   "EXPORT_FILE_NAME" t))
-                               (file-name-nondirectory bfname)))
-                          ".mm")))
-    (when (file-exists-p filename)
-      (delete-file filename))
-    (cond
-     (subtree-p
-      (org-freemind-from-org-mode-node (line-number-at-pos rbeg)
-                                      filename))
-     (t (org-freemind-from-org-mode bfname filename)))))
-
-;;;###autoload
-(defun org-freemind-show (mm-file)
-  "Show file MM-FILE in Freemind."
-  (interactive
-   (list
-    (save-match-data
-      (let ((name (read-file-name "FreeMind file: "
-                                  nil nil nil
-                                  (if (buffer-file-name)
-                                      (let* ((name-ext (file-name-nondirectory (buffer-file-name)))
-                                             (name (file-name-sans-extension name-ext))
-                                             (ext (file-name-extension name-ext)))
-                                        (cond
-                                         ((string= "mm" ext)
-                                          name-ext)
-                                         ((string= "org" ext)
-                                          (let ((name-mm (concat name ".mm")))
-                                            (if (file-exists-p name-mm)
-                                                name-mm
-                                              (message "Not exported to Freemind format yet")
-                                              "")))
-                                         (t
-                                          "")))
-                                    "")
-                                  ;; Fix-me: Is this an Emacs bug?
-                                  ;; This predicate function is never
-                                  ;; called.
-                                  (lambda (fn)
-                                    (string-match "^mm$" (file-name-extension fn))))))
-        (setq name (expand-file-name name))
-        name))))
-  (org-open-file mm-file))
-
-(defconst org-freemind-org-nfix "--org-mode: ")
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Format converters
-
-(defun org-freemind-escape-str-from-org (org-str)
-  "Do some html-escaping of ORG-STR and return the result.
-The characters \"&<> will be escaped."
-  (let ((chars (append org-str nil))
-        (fm-str ""))
-    (dolist (cc chars)
-      (setq fm-str
-            (concat fm-str
-                    (if (< cc 160)
-                        (cond
-                         ((= cc ?\") "&quot;")
-                         ((= cc ?\&) "&amp;")
-                         ((= cc ?\<) "&lt;")
-                         ((= cc ?\>) "&gt;")
-                         (t (char-to-string cc)))
-                      ;; Formatting as &#number; is maybe needed
-                      ;; according to a bug report from kazuo
-                      ;; fujimoto, but I have now instead added a xml
-                      ;; processing instruction saying that the mm
-                      ;; file is utf-8:
-                      ;;
-                      ;; (format "&#x%x;" (- cc ;; ?\x800))
-                     (format "&#x%x;" (encode-char cc 'ucs))
-                      ))))
-    fm-str))
-
-;;(org-freemind-unescape-str-to-org "&#x6d;A&#x224C;B&lt;C&#x3C;&#x3D;")
-;;(org-freemind-unescape-str-to-org "&#x3C;&lt;")
-(defun org-freemind-unescape-str-to-org (fm-str)
-  "Do some html-unescaping of FM-STR and return the result.
-This is the opposite of `org-freemind-escape-str-from-org' but it
-will also unescape &#nn;."
-  (let ((org-str fm-str))
-    (setq org-str (replace-regexp-in-string "&quot;" "\"" org-str))
-    (setq org-str (replace-regexp-in-string "&amp;" "&" org-str))
-    (setq org-str (replace-regexp-in-string "&lt;" "<" org-str))
-    (setq org-str (replace-regexp-in-string "&gt;" ">" org-str))
-    (setq org-str (replace-regexp-in-string
-                  "&#x\\([a-f0-9]\\{2,4\\}\\);"
-                  (lambda (m)
-                    (char-to-string
-                     (+ (string-to-number (match-string 1 m) 16)
-                        0 ;?\x800 ;; What is this for? Encoding?
-                        )))
-                  org-str))))
-
-;; (let* ((str1 "a quote: \", an amp: &, lt: <; over 256: öåäÖÅÄ")
-;;        (str2 (org-freemind-escape-str-from-org str1))
-;;        (str3 (org-freemind-unescape-str-to-org str2)))
-;;     (unless (string= str1 str3)
-;;       (error "Error str3=%s" str3)))
-
-(defun org-freemind-convert-links-helper (matched)
-  "Helper for `org-freemind-convert-links-from-org'.
-MATCHED is the link just matched."
-  (let* ((link (match-string 1 matched))
-         (text (match-string 2 matched))
-         (ext (file-name-extension link))
-         (col-pos (org-string-match-p ":" link))
-         (is-img (and (image-type-from-file-name link)
-                      (let ((url-type (substring link 0 col-pos)))
-                        (member url-type '("file" "http" "https")))))
-        )
-    (if is-img
-        ;; Fix-me: I can't find a way to get the border to "shrink
-        ;; wrap" around the image using <div>.
-        ;;
-        ;; (concat "<div style=\"border: solid 1px #ddd; width:auto;\">"
-        ;;         "<img src=\"" link "\" alt=\"" text "\" />"
-        ;;         "<br />"
-        ;;         "<i>" text "</i>"
-        ;;         "</div>")
-        (concat "<table border=\"0\" style=\"border: solid 1px #ddd;\"><tr><td>"
-                "<img src=\"" link "\" alt=\"" text "\" />"
-                "<br />"
-                "<i>" text "</i>"
-                "</td></tr></table>")
-      (concat "<a href=\"" link "\">" text "</a>"))))
-
-(defun org-freemind-convert-links-from-org (org-str)
-  "Convert org links in ORG-STR to freemind links and return the result."
-  (let ((fm-str (replace-regexp-in-string
-                 ;;(rx (not (any "[\""))
-                 ;;    (submatch
-                 ;;     "http"
-                 ;;     (opt ?\s)
-                 ;;     "://"
-                 ;;     (1+
-                 ;;      (any "-%.?@a-zA-Z0-9()_/:~=&#"))))
-                "[^\"[]\\(http ?://[--:#%&()=?-Z_a-z~]+\\)"
-                 "[[\\1][\\1]]"
-                 org-str
-                 nil ;; fixedcase
-                 nil ;; literal
-                 1   ;; subexp
-                 )))
-    (replace-regexp-in-string
-     ;;(rx "[["
-     ;;         (submatch (*? nonl))
-     ;; "]["
-     ;; (submatch (*? nonl))
-     ;; "]]")
-     "\\[\\[\\(.*?\\)]\\[\\(.*?\\)]]"
-     ;;"<a href=\"\\1\">\\2</a>"
-     'org-freemind-convert-links-helper
-     fm-str t t)))
-
-;;(org-freemind-convert-links-to-org "<a href=\"http://www.somewhere/\">link-text</a>")
-(defun org-freemind-convert-links-to-org (fm-str)
-  "Convert freemind links in FM-STR to org links and return the result."
-  (let ((org-str (replace-regexp-in-string
-                  ;;(rx "<a"
-                  ;;    space
-                  ;;    (0+
-                  ;;     (0+ (not (any ">")))
-                  ;;     space)
-                  ;;    "href=\""
-                  ;;    (submatch (0+ (not (any "\""))))
-                  ;;    "\""
-                  ;;    (0+ (not (any ">")))
-                  ;;     ">"
-                  ;;     (submatch (0+ (not (any "<"))))
-                  ;;     "</a>")
-                 "<a[[:space:]]\\(?:[^>]*[[:space:]]\\)*href=\"\\([^\"]*\\)\"[^>]*>\\([^<]*\\)</a>"
-                  "[[\\1][\\2]]"
-                  fm-str)))
-    org-str))
-
-;; Fix-me:
-;;(defun org-freemind-convert-drawers-from-org (text)
-;;  )
-
-;;   (let* ((str1 "[[http://www.somewhere/][link-text]")
-;;          (str2 (org-freemind-convert-links-from-org str1))
-;;        (str3 (org-freemind-convert-links-to-org str2)))
-;;     (unless (string= str1 str3)
-;;     (error "Error str3=%s" str3)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Org => FreeMind
-
-(defvar org-freemind-bol-helper-base-indent nil)
-
-(defun org-freemind-bol-helper (matched)
-  "Helper for `org-freemind-convert-text-p'.
-MATCHED is the link just matched."
-  (let ((res "")
-        (bi org-freemind-bol-helper-base-indent))
-    (dolist (cc (append matched nil))
-      (if (= 32 cc)
-          ;;(setq res (concat res "&nbsp;"))
-          ;; We need to use the numerical version.  Otherwise Freemind
-          ;; ver 0.9.0 RC9 can not export to html/javascript.
-          (progn
-            (if (< 0 bi)
-                (setq bi (1- bi))
-              (setq res (concat res "&#160;"))))
-        (setq res (concat res (char-to-string cc)))))
-    res))
-;; (setq x (replace-regexp-in-string "\n +" 'org-freemind-bol-nbsp-helper "\n  "))
-
-(defun org-freemind-convert-text-p (text)
-  "Convert TEXT to html with <p> paragraphs."
-  ;; (string-match-p "[^ ]" "  a")
-  (setq org-freemind-bol-helper-base-indent (org-string-match-p "[^ ]" text))
-  (setq text (org-freemind-escape-str-from-org text))
-
-  (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(/\\)\\([^/]+\\)\\(/\\)\\([[:space:]]\\)" "\\1<i>\\3</i>\\5" text))
-  (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(\*\\)\\([^*]+\\)\\(\*\\)\\([[:space:]]\\)" "\\1<b>\\3</b>\\5" text))
-
-  (setq text (concat "<p>" text))
-  (setq text (replace-regexp-in-string "\n[[:blank:]]*\n" "</p><p>" text))
-  (setq text (replace-regexp-in-string "\\(?:<p>\\|\n\\) +" 'org-freemind-bol-helper text))
-  (setq text (replace-regexp-in-string "\n" "<br />" text))
-  (setq text (concat text "</p>"))
-
-  (org-freemind-convert-links-from-org text))
-
-(defcustom org-freemind-node-css-style
-  "p { margin-top: 3px; margin-bottom: 3px; }"
-  "CSS style for Freemind nodes."
-  ;; Fix-me: I do not understand this.  It worked to export from Freemind
-  ;; with this setting now, but not before??? Was this perhaps a java
-  ;; bug or is it a windows xp bug (some resource gets exhausted if you
-  ;; use sticky keys which I do).
-  :version "24.1"
-  :group 'org-freemind)
-
-(defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp)
-  "Convert text part of org node to freemind subnode or note.
-Convert the text part of the org node named NODE-NAME. The text
-is in the current buffer between START and END. Drawers matching
-DRAWERS-REGEXP are converted to freemind notes."
-  ;; fix-me: doc
-  (let ((text (buffer-substring-no-properties start end))
-        (node-res "")
-        (note-res ""))
-    (save-match-data
-      ;;(setq text (org-freemind-escape-str-from-org text))
-      ;; First see if there is something that should be moved to the
-      ;; note part:
-      (let (drawers)
-        (while (string-match drawers-regexp text)
-          (setq drawers (cons (match-string 0 text) drawers))
-          (setq text
-                (concat (substring text 0 (match-beginning 0))
-                        (substring text (match-end 0))))
-          )
-        (when drawers
-          (dolist (drawer drawers)
-            (let ((lines (split-string drawer "\n")))
-              (dolist (line lines)
-                (setq note-res (concat
-                                note-res
-                                org-freemind-org-nfix line "<br />\n")))
-              ))))
-
-      (when (> (length note-res) 0)
-        (setq note-res (concat
-                        "<richcontent TYPE=\"NOTE\"><html>\n"
-                        "<head>\n"
-                        "</head>\n"
-                        "<body>\n"
-                        note-res
-                        "</body>\n"
-                        "</html>\n"
-                        "</richcontent>\n")))
-
-      ;; There is always an LF char:
-      (when (> (length text) 1)
-        (setq node-res (concat
-                        "<node style=\"bubble\" background_color=\"#eeee00\">\n"
-                        "<richcontent TYPE=\"NODE\"><html>\n"
-                        "<head>\n"
-                        (if (= 0 (length org-freemind-node-css-style))
-                            ""
-                          (concat
-                          "<style type=\"text/css\">\n"
-                          "<!--\n"
-                           org-freemind-node-css-style
-                          "-->\n"
-                           "</style>\n"))
-                        "</head>\n"
-                        "<body>\n"))
-        (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML"))
-              (end-html-mark   (regexp-quote "#+END_HTML"))
-              head
-              end-pos
-              end-pos-match
-              )
-          ;; Take care of #+BEGIN_HTML - #+END_HTML
-          (while (string-match begin-html-mark text)
-            (setq head (substring text 0 (match-beginning 0)))
-            (setq end-pos-match (match-end 0))
-            (setq node-res (concat node-res
-                                   (org-freemind-convert-text-p head)))
-            (setq text (substring text end-pos-match))
-            (setq end-pos (string-match end-html-mark text))
-            (if end-pos
-                (setq end-pos-match (match-end 0))
-              (message "org-freemind: Missing #+END_HTML")
-              (setq end-pos (length text))
-              (setq end-pos-match end-pos))
-            (setq node-res (concat node-res
-                                   (substring text 0 end-pos)))
-            (setq text (substring text end-pos-match)))
-          (setq node-res (concat node-res
-                                 (org-freemind-convert-text-p text))))
-        (setq node-res (concat
-                        node-res
-                        "</body>\n"
-                        "</html>\n"
-                        "</richcontent>\n"
-                        ;; Put a note that this is for the parent node
-                        ;; "<richcontent TYPE=\"NOTE\"><html>"
-                        ;; "<head>"
-                        ;; "</head>"
-                        ;; "<body>"
-                        ;; "<p>"
-                        ;; "-- This is more about \"" node-name "\" --"
-                        ;; "</p>"
-                        ;; "</body>"
-                        ;; "</html>"
-                        ;; "</richcontent>\n"
-                        note-res
-                        "</node>\n" ;; ok
-                        )))
-      (list node-res note-res))))
-
-(defun org-freemind-write-node (mm-buffer drawers-regexp
-                                         num-left-nodes base-level
-                                         current-level next-level this-m2
-                                         this-node-end
-                                         this-children-visible
-                                         next-node-start
-                                         next-has-some-visible-child)
-  (let* (this-icons
-         this-bg-color
-        this-m2-link
-         this-m2-escaped
-         this-rich-node
-         this-rich-note
-         )
-    (when (string-match "TODO" this-m2)
-      (setq this-m2 (replace-match "" nil nil this-m2))
-      (add-to-list 'this-icons "button_cancel")
-      (setq this-bg-color "#ffff88")
-      (when (string-match "\\[#\\(.\\)\\]" this-m2)
-        (let ((prior (string-to-char (match-string 1 this-m2))))
-          (setq this-m2 (replace-match "" nil nil this-m2))
-          (cond
-           ((= prior ?A)
-            (add-to-list 'this-icons "full-1")
-            (setq this-bg-color "#ff0000"))
-           ((= prior ?B)
-            (add-to-list 'this-icons "full-2")
-            (setq this-bg-color "#ffaa00"))
-           ((= prior ?C)
-            (add-to-list 'this-icons "full-3")
-            (setq this-bg-color "#ffdd00"))
-           ((= prior ?D)
-            (add-to-list 'this-icons "full-4")
-            (setq this-bg-color "#ffff00"))
-           ((= prior ?E)
-            (add-to-list 'this-icons "full-5"))
-           ((= prior ?F)
-            (add-to-list 'this-icons "full-6"))
-           ((= prior ?G)
-            (add-to-list 'this-icons "full-7"))
-           ))))
-    (setq this-m2 (org-trim this-m2))
-    (when (string-match org-bracket-link-analytic-regexp this-m2)
-      (setq this-m2-link (concat "link=\"" (match-string 1 this-m2)
-                                (match-string 3 this-m2) "\" ")
-           this-m2 (replace-match "\\5" nil nil this-m2 0)))
-    (setq this-m2-escaped (org-freemind-escape-str-from-org this-m2))
-    (let ((node-notes (org-freemind-org-text-to-freemind-subnode/note
-                       this-m2-escaped
-                       this-node-end
-                       (1- next-node-start)
-                       drawers-regexp)))
-      (setq this-rich-node (nth 0 node-notes))
-      (setq this-rich-note (nth 1 node-notes)))
-    (with-current-buffer mm-buffer
-      (insert "<node " (if this-m2-link this-m2-link "")
-             "text=\"" this-m2-escaped "\"")
-      (org-freemind-get-node-style this-m2)
-      (when (> next-level current-level)
-        (unless (or this-children-visible
-                    next-has-some-visible-child)
-          (insert " folded=\"true\"")))
-      (when (and (= current-level (1+ base-level))
-                 (> num-left-nodes 0))
-        (setq num-left-nodes (1- num-left-nodes))
-        (insert " position=\"left\""))
-      (when this-bg-color
-        (insert " background_color=\"" this-bg-color "\""))
-      (insert ">\n")
-      (when this-icons
-        (dolist (icon this-icons)
-          (insert "<icon builtin=\"" icon "\"/>\n")))
-      )
-    (with-current-buffer mm-buffer
-      ;;(when this-rich-note (insert this-rich-note))
-      (when this-rich-node (insert this-rich-node))))
-  num-left-nodes)
-
-(defun org-freemind-check-overwrite (file interactively)
-  "Check if file FILE already exists.
-If FILE does not exist return t.
-
-If INTERACTIVELY is non-nil ask if the file should be replaced
-and return t/nil if it should/should not be replaced.
-
-Otherwise give an error say the file exists."
-  (if (file-exists-p file)
-      (if interactively
-          (y-or-n-p (format "File %s exists, replace it? " file))
-        (error "File %s already exists" file))
-    t))
-
-(defvar org-freemind-node-pattern
-  ;;(rx bol
-  ;;    (submatch (1+ "*"))
-  ;;    (1+ space)
-  ;;    (submatch (*? nonl))
-  ;;    eol)
-  "^\\(\\*+\\)[[:space:]]+\\(.*?\\)$")
-
-(defun org-freemind-look-for-visible-child (node-level)
-  (save-excursion
-    (save-match-data
-      (let ((found-visible-child nil))
-        (while (and (not found-visible-child)
-                    (re-search-forward org-freemind-node-pattern nil t))
-          (let* ((m1 (match-string-no-properties 1))
-                 (level (length m1)))
-            (if (>= node-level level)
-                (setq found-visible-child 'none)
-              (unless (get-char-property (line-beginning-position) 'invisible)
-                (setq found-visible-child 'found)))))
-        (eq found-visible-child 'found)
-        ))))
-
-(defun org-freemind-goto-line (line)
-  "Go to line number LINE."
-  (save-restriction
-    (widen)
-    (goto-char (point-min))
-    (forward-line (1- line))))
-
-(defun org-freemind-write-mm-buffer (org-buffer mm-buffer node-at-line)
-  (with-current-buffer org-buffer
-    (dolist (node-style org-freemind-node-styles)
-      (when (org-string-match-p (car node-style) buffer-file-name)
-        (setq org-freemind-node-style (cadr node-style))))
-    ;;(message "org-freemind-node-style =%s" org-freemind-node-style)
-    (save-match-data
-      (let* ((drawers (copy-sequence org-drawers))
-             drawers-regexp
-             (num-top1-nodes 0)
-             (num-top2-nodes 0)
-             num-left-nodes
-             (unclosed-nodes 0)
-            (odd-only org-odd-levels-only)
-             (first-time t)
-             (current-level 1)
-             base-level
-             prev-node-end
-             rich-text
-             unfinished-tag
-             node-at-line-level
-             node-at-line-last)
-        (with-current-buffer mm-buffer
-          (erase-buffer)
-          (setq buffer-file-coding-system 'utf-8)
-          ;; Fix-me: Currently Freemind (ver 0.9.0 RC9) does not support this:
-          ;;(insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
-          (insert "<map version=\"0.9.0\">\n")
-          (insert "<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n"))
-        (save-excursion
-          ;; Get special buffer vars:
-          (goto-char (point-min))
-          (message "Writing Freemind file...")
-          (while (re-search-forward "^#\\+DRAWERS:" nil t)
-            (let ((dr-txt (buffer-substring-no-properties (match-end 0) (line-end-position))))
-              (setq drawers (append drawers (split-string dr-txt) nil))))
-          (setq drawers-regexp
-                (concat "^[[:blank:]]*:"
-                        (regexp-opt drawers)
-                        ;;(rx ":" (0+ blank)
-                        ;;    "\n"
-                        ;;    (*? anything)
-                        ;;    "\n"
-                        ;;    (0+ blank)
-                        ;;    ":END:"
-                        ;;    (0+ blank)
-                        ;;    eol)
-                       ":[[:blank:]]*\n\\(?:.\\|\n\\)*?\n[[:blank:]]*:END:[[:blank:]]*$"
-                       ))
-
-          (if node-at-line
-              ;; Get number of top nodes and last line for this node
-              (progn
-                (org-freemind-goto-line node-at-line)
-                (unless (looking-at org-freemind-node-pattern)
-                  (error "No node at line %s" node-at-line))
-                (setq node-at-line-level (length (match-string-no-properties 1)))
-                (forward-line)
-                (setq node-at-line-last
-                      (catch 'last-line
-                        (while (re-search-forward org-freemind-node-pattern nil t)
-                          (let* ((m1 (match-string-no-properties 1))
-                                 (level (length m1)))
-                            (if (<= level node-at-line-level)
-                                (progn
-                                  (beginning-of-line)
-                                  (throw 'last-line (1- (point))))
-                              (if (= level (1+ node-at-line-level))
-                                  (setq num-top2-nodes (1+ num-top2-nodes))))))))
-                (setq current-level node-at-line-level)
-                (setq num-top1-nodes 1)
-                (org-freemind-goto-line node-at-line))
-
-            ;; First get number of top nodes
-            (goto-char (point-min))
-            (while (re-search-forward org-freemind-node-pattern nil t)
-              (let* ((m1 (match-string-no-properties 1))
-                     (level (length m1)))
-                (if (= level 1)
-                    (setq num-top1-nodes (1+ num-top1-nodes))
-                  (if (= level 2)
-                      (setq num-top2-nodes (1+ num-top2-nodes))))))
-            ;; If there is more than one top node we need to insert a node
-            ;; to keep them together.
-            (goto-char (point-min))
-            (when (> num-top1-nodes 1)
-              (setq num-top2-nodes num-top1-nodes)
-              (setq current-level 0)
-              (let ((orig-name (if buffer-file-name
-                                   (file-name-nondirectory (buffer-file-name))
-                                 (buffer-name))))
-                (with-current-buffer mm-buffer
-                  (insert "<node text=\"" orig-name "\" background_color=\"#00bfff\">\n"
-                          ;; Put a note that this is for the parent node
-                          "<richcontent TYPE=\"NOTE\"><html>"
-                          "<head>"
-                          "</head>"
-                          "<body>"
-                          "<p>"
-                          org-freemind-org-nfix "WHOLE FILE"
-                          "</p>"
-                          "</body>"
-                          "</html>"
-                          "</richcontent>\n")))))
-
-          (setq num-left-nodes (floor num-top2-nodes 2))
-          (setq base-level current-level)
-          (let (this-m2
-                this-node-end
-                this-children-visible
-                next-m2
-                next-node-start
-                next-level
-                next-has-some-visible-child
-                next-children-visible
-                )
-            (while (and
-                    (re-search-forward org-freemind-node-pattern nil t)
-                    (if node-at-line-last (<= (point) node-at-line-last) t)
-                    )
-              (let* ((next-m1 (match-string-no-properties 1))
-                     (next-node-end (match-end 0))
-                     )
-                (setq next-node-start (match-beginning 0))
-                (setq next-m2 (match-string-no-properties 2))
-                (setq next-level (length next-m1))
-                (setq next-children-visible
-                      (not (eq 'outline
-                               (get-char-property (line-end-position) 'invisible))))
-                (setq next-has-some-visible-child
-                      (if next-children-visible t
-                        (org-freemind-look-for-visible-child next-level)))
-                (when this-m2
-                  (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child)))
-                (when (if (= num-top1-nodes 1) (> current-level base-level) t)
-                  (while (>= current-level next-level)
-                    (with-current-buffer mm-buffer
-                      (insert "</node>\n")
-                      (setq current-level
-                           (- current-level (if odd-only 2 1))))))
-                (setq this-node-end (1+ next-node-end))
-                (setq this-m2 next-m2)
-                (setq current-level next-level)
-                (setq this-children-visible next-children-visible)
-                (forward-char)
-                ))
-;;;             (unless (if node-at-line-last
-;;;                         (>= (point) node-at-line-last)
-;;;                       nil)
-           ;; Write last node:
-           (setq this-m2 next-m2)
-           (setq current-level next-level)
-           (setq next-node-start (if node-at-line-last
-                                     (1+ node-at-line-last)
-                                   (point-max)))
-           (setq num-left-nodes (org-freemind-write-node mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child))
-           (with-current-buffer mm-buffer (insert "</node>\n"))
-                                       ;)
-            )
-          (with-current-buffer mm-buffer
-            (while (> current-level base-level)
-              (insert "</node>\n")
-             (setq current-level
-                   (- current-level (if odd-only 2 1)))
-              ))
-          (with-current-buffer mm-buffer
-            (insert "</map>")
-            (delete-trailing-whitespace)
-            (goto-char (point-min))
-            ))))))
-
-(defun org-freemind-get-node-style (node-name)
-  "NOT READY YET."
-  ;;<node BACKGROUND_COLOR="#eeee00" CREATED="1234668815593" MODIFIED="1234668815593" STYLE="bubble">
-  ;;<font BOLD="true" NAME="SansSerif" SIZE="12"/>
-  (let (node-styles
-        node-style)
-    (dolist (style-list org-freemind-node-style)
-      (let ((node-regexp (car style-list)))
-        (message "node-regexp=%s node-name=%s" node-regexp node-name)
-        (when (org-string-match-p node-regexp node-name)
-          ;;(setq node-style (org-freemind-do-apply-node-style style-list))
-          (setq node-style (cadr style-list))
-          (when node-style
-            (message "node-style=%s" node-style)
-            (setq node-styles (append node-styles node-style)))
-          )))))
-
-(defun org-freemind-do-apply-node-style (style-list)
-  (message "style-list=%S" style-list)
-  (let ((node-style 'fork)
-        (color "red")
-        (background-color "yellow")
-        (edge-color "green")
-        (edge-style 'bezier)
-        (edge-width 'thin)
-        (italic t)
-        (bold t)
-        (font-name "SansSerif")
-        (font-size 12))
-    (dolist (style (cadr style-list))
-      (message "    style=%s" style)
-      (let ((what (car style)))
-        (cond
-         ((eq what 'node-style)
-          (setq node-style (cadr style)))
-         ((eq what 'color)
-          (setq color (cadr style)))
-         ((eq what 'background-color)
-          (setq background-color (cadr style)))
-
-         ((eq what 'edge-color)
-          (setq edge-color (cadr style)))
-
-         ((eq what 'edge-style)
-          (setq edge-style (cadr style)))
-
-         ((eq what 'edge-width)
-          (setq edge-width (cadr style)))
-
-         ((eq what 'italic)
-          (setq italic (cadr style)))
-
-         ((eq what 'bold)
-          (setq bold (cadr style)))
-
-         ((eq what 'font-name)
-          (setq font-name (cadr style)))
-
-         ((eq what 'font-size)
-          (setq font-size (cadr style)))
-         )
-        (insert (format " style=\"%s\"" node-style))
-        (insert (format " color=\"%s\"" color))
-        (insert (format " background_color=\"%s\"" background-color))
-        (insert ">\n")
-        (insert "<edge")
-        (insert (format " color=\"%s\"" edge-color))
-        (insert (format " style=\"%s\"" edge-style))
-        (insert (format " width=\"%s\"" edge-width))
-        (insert "/>\n")
-        (insert "<font")
-        (insert (format " italic=\"%s\"" italic))
-        (insert (format " bold=\"%s\"" bold))
-        (insert (format " name=\"%s\"" font-name))
-        (insert (format " size=\"%s\"" font-size))
-        ))))
-
-;;;###autoload
-(defun org-freemind-from-org-mode-node (node-line mm-file)
-  "Convert node at line NODE-LINE to the FreeMind file MM-FILE.
-See `org-freemind-from-org-mode' for more information."
-  (interactive
-   (progn
-     (unless (org-back-to-heading nil)
-       (error "Can't find org-mode node start"))
-     (let* ((line (line-number-at-pos))
-            (default-mm-file (concat (if buffer-file-name
-                                         (file-name-nondirectory buffer-file-name)
-                                       "nofile")
-                                     "-line-" (number-to-string line)
-                                     ".mm"))
-            (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
-       (list line mm-file))))
-  (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
-    (let ((org-buffer (current-buffer))
-          (mm-buffer (find-file-noselect mm-file)))
-      (org-freemind-write-mm-buffer org-buffer mm-buffer node-line)
-      (with-current-buffer mm-buffer
-        (basic-save-buffer)
-        (when (org-called-interactively-p 'any)
-          (switch-to-buffer-other-window mm-buffer)
-          (when (y-or-n-p "Show in FreeMind? ")
-            (org-freemind-show buffer-file-name)))))))
-
-;;;###autoload
-(defun org-freemind-from-org-mode (org-file mm-file)
-  "Convert the `org-mode' file ORG-FILE to the FreeMind file MM-FILE.
-All the nodes will be opened or closed in Freemind just as you
-have them in `org-mode'.
-
-Note that exporting to Freemind also gives you an alternative way
-to export from `org-mode' to html.  You can create a dynamic html
-version of the your org file, by first exporting to Freemind and
-then exporting from Freemind to html.  The 'As
-XHTML (JavaScript)' version in Freemind works very well \(and you
-can use a CSS stylesheet to style it)."
-  ;; Fix-me: better doc, include recommendations etc.
-  (interactive
-   (let* ((org-file buffer-file-name)
-          (default-mm-file (concat
-                            (if org-file
-                                (file-name-nondirectory org-file)
-                              "nofile")
-                            ".mm"))
-          (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
-     (list org-file mm-file)))
-  (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
-    (let ((org-buffer (if org-file (find-file-noselect org-file) (current-buffer)))
-          (mm-buffer (find-file-noselect mm-file)))
-      (org-freemind-write-mm-buffer org-buffer mm-buffer nil)
-      (with-current-buffer mm-buffer
-        (basic-save-buffer)
-        (when (org-called-interactively-p 'any)
-          (switch-to-buffer-other-window mm-buffer)
-          (when (y-or-n-p "Show in FreeMind? ")
-            (org-freemind-show buffer-file-name)))))))
-
-;;;###autoload
-(defun org-freemind-from-org-sparse-tree (org-buffer mm-file)
-  "Convert visible part of buffer ORG-BUFFER to FreeMind file MM-FILE."
-  (interactive
-   (let* ((org-file buffer-file-name)
-          (default-mm-file (concat
-                            (if org-file
-                                (file-name-nondirectory org-file)
-                              "nofile")
-                            "-sparse.mm"))
-          (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file)))
-     (list (current-buffer) mm-file)))
-  (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any))
-    (let (org-buffer
-          (mm-buffer (find-file-noselect mm-file)))
-      (save-window-excursion
-        (org-export-visible ?\  nil)
-        (setq org-buffer (current-buffer)))
-      (org-freemind-write-mm-buffer org-buffer mm-buffer nil)
-      (with-current-buffer mm-buffer
-        (basic-save-buffer)
-        (when (org-called-interactively-p 'any)
-          (switch-to-buffer-other-window mm-buffer)
-          (when (y-or-n-p "Show in FreeMind? ")
-            (org-freemind-show buffer-file-name)))))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; FreeMind => Org
-
-;; (sort '(b a c) 'org-freemind-lt-symbols)
-(defun org-freemind-lt-symbols (sym-a sym-b)
-  (string< (symbol-name sym-a) (symbol-name sym-b)))
-;; (sort '((b . 1) (a . 2) (c . 3)) 'org-freemind-lt-xml-attrs)
-(defun org-freemind-lt-xml-attrs (attr-a attr-b)
-  (string< (symbol-name (car attr-a)) (symbol-name (car attr-b))))
-
-;; xml-parse-region gives things like
-;; ((p nil "\n"
-;;     (a
-;;      ((href . "link"))
-;;      "text")
-;;     "\n"
-;;     (b nil "hej")
-;;     "\n"))
-
-;; '(a . nil)
-
-;; (org-freemind-symbols= 'a (car '(A B)))
-(defsubst org-freemind-symbols= (sym-a sym-b)
-  "Return t if downcased names of SYM-A and SYM-B are equal.
-SYM-A and SYM-B should be symbols."
-  (or (eq sym-a sym-b)
-      (string= (downcase (symbol-name sym-a))
-               (downcase (symbol-name sym-b)))))
-
-(defun org-freemind-get-children (parent path)
-  "Find children node to PARENT from PATH.
-PATH should be a list of steps, where each step has the form
-
-  '(NODE-NAME (ATTR-NAME . ATTR-VALUE))"
-  ;; Fix-me: maybe implement op? step: Name, number, attr, attr op val
-  ;; Fix-me: case insensitive version for children?
-  (let* ((children (if (not (listp (car parent)))
-                       (cddr parent)
-                     (let (cs)
-                       (dolist (p parent)
-                         (dolist (c (cddr p))
-                           (add-to-list 'cs c)))
-                       cs)
-                     ))
-         (step (car path))
-         (step-node (if (listp step) (car step) step))
-         (step-attr-list (when (listp step) (sort (cdr step) 'org-freemind-lt-xml-attrs)))
-         (path-tail (cdr path))
-         path-children)
-    (dolist (child children)
-      ;; skip xml.el formatting nodes
-      (unless (stringp child)
-        ;; compare node name
-        (when (if (not step-node)
-                  t ;; any node name
-                (org-freemind-symbols= step-node (car child)))
-          (if (not step-attr-list)
-              ;;(throw 'path-child child) ;; no attr to care about
-              (add-to-list 'path-children child)
-            (let* ((child-attr-list (cadr child))
-                   (step-attr-copy (copy-sequence step-attr-list)))
-              (dolist (child-attr child-attr-list)
-               ;; Compare attr names:
-                (when (org-freemind-symbols= (caar step-attr-copy) (car child-attr))
-                  ;; Compare values:
-                  (let ((step-val (cdar step-attr-copy))
-                        (child-val (cdr child-attr)))
-                    (when (if (not step-val)
-                              t ;; any value
-                            (string= step-val child-val))
-                      (setq step-attr-copy (cdr step-attr-copy))))))
-              ;; Did we find all?
-              (unless step-attr-copy
-                ;;(throw 'path-child child)
-                (add-to-list 'path-children child)
-                ))))))
-    (if path-tail
-        (org-freemind-get-children path-children path-tail)
-      path-children)))
-
-(defun org-freemind-get-richcontent-node (node)
-  (let ((rc-nodes
-         (org-freemind-get-children node '((richcontent (type . "NODE")) html body))))
-    (when (> (length rc-nodes) 1)
-      (lwarn t :warning "Unexpected structure: several <richcontent type=\"NODE\" ...>"))
-    (car rc-nodes)))
-
-(defun org-freemind-get-richcontent-note (node)
-  (let ((rc-notes
-         (org-freemind-get-children node '((richcontent (type . "NOTE")) html body))))
-    (when (> (length rc-notes) 1)
-      (lwarn t :warning "Unexpected structure: several <richcontent type=\"NOTE\" ...>"))
-    (car rc-notes)))
-
-(defun org-freemind-test-get-tree-text ()
-  (let ((node '(p nil "\n"
-                 (a
-                  ((href . "link"))
-                  "text")
-                 "\n"
-                 (b nil "hej")
-                 "\n")))
-    (org-freemind-get-tree-text node)))
-;; (org-freemind-test-get-tree-text)
-
-(defun org-freemind-get-tree-text (node)
-  (when node
-    (let ((ntxt "")
-          (link nil)
-          (lf-after nil))
-      (dolist (n node)
-        (case n
-          ;;(a (setq is-link t) )
-          ((h1 h2 h3 h4 h5 h6 p)
-           ;;(setq ntxt (concat "\n" ntxt))
-           (setq lf-after 2))
-          (br
-           (setq lf-after 1))
-          (t
-           (cond
-            ((stringp n)
-             (when (string= n "\n") (setq n ""))
-             (if link
-                 (setq ntxt (concat ntxt
-                                    "[[" link "][" n "]]"))
-               (setq ntxt (concat ntxt n))))
-            ((and n (listp n))
-             (if (symbolp (car n))
-                 (setq ntxt (concat ntxt (org-freemind-get-tree-text n)))
-               ;; This should be the attributes:
-               (dolist (att-val n)
-                 (let ((att (car att-val))
-                       (val (cdr att-val)))
-                   (when (eq att 'href)
-                     (setq link val))))))))))
-      (if lf-after
-          (setq ntxt (concat ntxt (make-string lf-after ?\n)))
-        (setq ntxt (concat ntxt " ")))
-      ;;(setq ntxt (concat ntxt (format "{%s}" n)))
-      ntxt)))
-
-(defun org-freemind-get-richcontent-node-text (node)
-  "Get the node text as from the richcontent node NODE."
-  (save-match-data
-    (let* ((rc (org-freemind-get-richcontent-node node))
-           (txt (org-freemind-get-tree-text rc)))
-      ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt)))
-      txt
-      )))
-
-(defun org-freemind-get-richcontent-note-text (node)
-  "Get the node text as from the richcontent note NODE."
-  (save-match-data
-    (let* ((rc (org-freemind-get-richcontent-note node))
-           (txt (when rc (org-freemind-get-tree-text rc))))
-      ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt)))
-      txt
-      )))
-
-(defun org-freemind-get-icon-names (node)
-  (let* ((icon-nodes (org-freemind-get-children node '((icon ))))
-         names)
-    (dolist (icn icon-nodes)
-      (setq names (cons (cdr (assq 'builtin (cadr icn))) names)))
-    ;; (icon (builtin . "full-1"))
-    names))
-
-(defun org-freemind-node-to-org (node level skip-levels)
-  (let ((qname (car node))
-        (attributes (cadr node))
-        text
-        ;; Fix-me: note is never inserted
-        (note (org-freemind-get-richcontent-note-text node))
-        (mark "-- This is more about ")
-        (icons (org-freemind-get-icon-names node))
-        (children (cddr node)))
-    (when (< 0 (- level skip-levels))
-      (dolist (attrib attributes)
-        (case (car attrib)
-          ('TEXT (setq text (cdr attrib)))
-          ('text (setq text (cdr attrib)))))
-      (unless text
-        ;; There should be a richcontent node holding the text:
-        (setq text (org-freemind-get-richcontent-node-text node)))
-      (when icons
-        (when (member "full-1" icons) (setq text (concat "[#A] " text)))
-        (when (member "full-2" icons) (setq text (concat "[#B] " text)))
-        (when (member "full-3" icons) (setq text (concat "[#C] " text)))
-        (when (member "full-4" icons) (setq text (concat "[#D] " text)))
-        (when (member "full-5" icons) (setq text (concat "[#E] " text)))
-        (when (member "full-6" icons) (setq text (concat "[#F] " text)))
-        (when (member "full-7" icons) (setq text (concat "[#G] " text)))
-        (when (member "button_cancel" icons) (setq text (concat "TODO " text)))
-        )
-      (if (and note
-               (string= mark (substring note 0 (length mark))))
-          (progn
-            (setq text (replace-regexp-in-string "\n $" "" text))
-            (insert text))
-        (case qname
-          ('node
-           (insert (make-string (- level skip-levels) ?*) " " text "\n")
-           (when note
-             (insert ":COMMENT:\n" note "\n:END:\n"))
-           ))))
-    (dolist (child children)
-      (unless (or (null child)
-                  (stringp child))
-        (org-freemind-node-to-org child (1+ level) skip-levels)))))
-
-;; Fix-me: put back special things, like drawers that are stored in
-;; the notes.  Should maybe all notes contents be put in drawers?
-;;;###autoload
-(defun org-freemind-to-org-mode (mm-file org-file)
-  "Convert FreeMind file MM-FILE to `org-mode' file ORG-FILE."
-  (interactive
-   (save-match-data
-     (let* ((mm-file (buffer-file-name))
-            (default-org-file (concat (file-name-nondirectory mm-file) ".org"))
-            (org-file (read-file-name "Output org-mode file: " nil nil nil default-org-file)))
-       (list mm-file org-file))))
-  (when (org-freemind-check-overwrite org-file (org-called-interactively-p 'any))
-    (let ((mm-buffer (find-file-noselect mm-file))
-          (org-buffer (find-file-noselect org-file)))
-      (with-current-buffer mm-buffer
-        (let* ((xml-list (xml-parse-file mm-file))
-               (top-node (cadr (cddar xml-list)))
-               (note (org-freemind-get-richcontent-note-text top-node))
-               (skip-levels
-                (if (and note
-                         (string-match "^--org-mode: WHOLE FILE$" note))
-                    1
-                  0)))
-          (with-current-buffer org-buffer
-            (erase-buffer)
-            (org-freemind-node-to-org top-node 1 skip-levels)
-            (goto-char (point-min))
-            (org-set-tags t t) ;; Align all tags
-            )
-          (switch-to-buffer-other-window org-buffer)
-          )))))
-
-(provide 'org-freemind)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; coding: utf-8
-;; End:
-
-;;; org-freemind.el ends here
index 4419fdbe85dd1dee2477e7b4138a409936e67bda..e368a14e2a95908e2b48f609fc42294dd9e96a8e 100644 (file)
@@ -43,8 +43,7 @@
 (declare-function gnus-summary-last-subject "gnus-sum" nil)
 ;; Customization variables
 
-(when (fboundp 'defvaralias)
-  (defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links))
+(org-defvaralias 'org-usenet-links-prefer-google 'org-gnus-prefer-web-links)
 
 (defcustom org-gnus-prefer-web-links nil
   "If non-nil, `org-store-link' creates web links to Google groups or Gmane.
@@ -66,6 +65,12 @@ this variable to `t'."
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-gnus-no-server nil
+  "Should Gnus be started using `gnus-no-server'?"
+  :group 'org-gnus
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
 
 ;; Install the link type
 (org-add-link-type "gnus" 'org-gnus-open)
@@ -287,7 +292,7 @@ If `org-store-link' was called with a prefix arg the meaning of
 
 (defun org-gnus-no-new-news ()
   "Like `M-x gnus' but doesn't check for new news."
-  (if (not (gnus-alive-p)) (gnus)))
+  (if (not (gnus-alive-p)) (if org-gnus-no-server (gnus-no-server) (gnus))))
 
 (provide 'org-gnus)
 
index 8465ba45a27a8f082d382a89553d09fedb09e8b7..eba90376deeafe854eb051ce1ae1e520ade43a11 100644 (file)
@@ -85,6 +85,12 @@ today's agenda, even if they are not scheduled."
   :version "24.1"
   :type 'character)
 
+(defcustom org-habit-show-done-always-green nil
+  "Non-nil means DONE days will always be green in the consistency graph.
+It will be green even if it was done after the deadline."
+  :group 'org-habit
+  :type 'boolean)
+
 (defface org-habit-clear-face
   '((((background light)) (:background "#8270f9"))
     (((background dark)) (:background "blue")))
@@ -272,8 +278,9 @@ Habits are assigned colors on the following basis:
       (if donep
          '(org-habit-ready-face . org-habit-ready-future-face)
        '(org-habit-alert-face . org-habit-alert-future-face)))
-     (t
-      '(org-habit-overdue-face . org-habit-overdue-future-face)))))
+     ((and org-habit-show-done-always-green donep)
+      '(org-habit-ready-face . org-habit-ready-future-face))
+     (t '(org-habit-overdue-face . org-habit-overdue-future-face)))))
 
 (defun org-habit-build-graph (habit starting current ending)
   "Build a graph for the given HABIT, from STARTING to ENDING.
diff --git a/lisp/org/org-html.el b/lisp/org/org-html.el
deleted file mode 100644 (file)
index ca90f85..0000000
+++ /dev/null
@@ -1,2761 +0,0 @@
-;;; org-html.el --- HTML export for Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;;; Code:
-
-(require 'org-exp)
-(require 'format-spec)
-
-(eval-when-compile (require 'cl))
-
-(declare-function org-id-find-id-file "org-id" (id))
-(declare-function htmlize-region "ext:htmlize" (beg end))
-(declare-function org-pop-to-buffer-same-window
-                 "org-compat" (&optional buffer-or-name norecord label))
-
-(defgroup org-export-html nil
-  "Options specific for HTML export of Org-mode files."
-  :tag "Org Export HTML"
-  :group 'org-export)
-
-(defcustom org-export-html-footnotes-section "<div id=\"footnotes\">
-<h2 class=\"footnotes\">%s: </h2>
-<div id=\"text-footnotes\">
-%s
-</div>
-</div>"
-  "Format for the footnotes section.
-Should contain a two instances of %s.  The first will be replaced with the
-language-specific word for \"Footnotes\", the second one will be replaced
-by the footnotes themselves."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-footnote-format "<sup>%s</sup>"
-  "The format for the footnote reference.
-%s will be replaced by the footnote reference itself."
-  :group 'org-export-html
-  :type 'string)
-
-
-(defcustom org-export-html-footnote-separator "<sup>, </sup>"
-  "Text used to separate footnotes."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-html-coding-system nil
-  "Coding system for HTML export, defaults to `buffer-file-coding-system'."
-  :group 'org-export-html
-  :type 'coding-system)
-
-(defcustom org-export-html-extension "html"
-  "The extension for exported HTML files."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-xml-declaration
-  '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
-    ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
-  "The extension for exported HTML files.
-%s will be replaced with the charset of the exported file.
-This may be a string, or an alist with export extensions
-and corresponding declarations."
-  :group 'org-export-html
-  :type '(choice
-         (string :tag "Single declaration")
-         (repeat :tag "Dependent on extension"
-                 (cons (string :tag "Extension")
-                       (string :tag "Declaration")))))
-
-(defcustom org-export-html-style-include-scripts t
-  "Non-nil means include the JavaScript snippets in exported HTML files.
-The actual script is defined in `org-export-html-scripts' and should
-not be modified."
-  :group 'org-export-html
-  :type 'boolean)
-
-(defvar org-export-html-scripts
-  "<script type=\"text/javascript\">
-/*
-@licstart  The following is the entire license notice for the
-JavaScript code in this tag.
-
-Copyright (C) 2012-2013 Free Software Foundation, Inc.
-
-The JavaScript code in this tag is free software: you can
-redistribute it and/or modify it under the terms of the GNU
-General Public License (GNU GPL) as published by the Free Software
-Foundation, either version 3 of the License, or (at your option)
-any later version.  The code is distributed WITHOUT ANY WARRANTY;
-without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
-
-As additional permission under GNU GPL version 3 section 7, you
-may distribute non-source (e.g., minimized or compacted) forms of
-that code without the copy of the GNU GPL normally required by
-section 4, provided you include this license notice and a URL
-through which recipients can access the Corresponding Source.
-
-
-@licend  The above is the entire license notice
-for the JavaScript code in this tag.
-*/
-<!--/*--><![CDATA[/*><!--*/
- function CodeHighlightOn(elem, id)
- {
-   var target = document.getElementById(id);
-   if(null != target) {
-     elem.cacheClassElem = elem.className;
-     elem.cacheClassTarget = target.className;
-     target.className = \"code-highlighted\";
-     elem.className   = \"code-highlighted\";
-   }
- }
- function CodeHighlightOff(elem, id)
- {
-   var target = document.getElementById(id);
-   if(elem.cacheClassElem)
-     elem.className = elem.cacheClassElem;
-   if(elem.cacheClassTarget)
-     target.className = elem.cacheClassTarget;
- }
-/*]]>*///-->
-</script>"
-  "Basic JavaScript that is needed by HTML files produced by Org-mode.")
-
-(defconst org-export-html-style-default
-  "<style type=\"text/css\">
- <!--/*--><![CDATA[/*><!--*/
-  html { font-family: Times, serif; font-size: 12pt; }
-  .title  { text-align: center; }
-  .todo   { color: red; }
-  .done   { color: green; }
-  .tag    { background-color: #add8e6; font-weight:normal }
-  .target { }
-  .timestamp { color: #bebebe; }
-  .timestamp-kwd { color: #5f9ea0; }
-  .right  {margin-left:auto; margin-right:0px;  text-align:right;}
-  .left   {margin-left:0px;  margin-right:auto; text-align:left;}
-  .center {margin-left:auto; margin-right:auto; text-align:center;}
-  p.verse { margin-left: 3% }
-  pre {
-       border: 1pt solid #AEBDCC;
-       background-color: #F3F5F7;
-       padding: 5pt;
-       font-family: courier, monospace;
-        font-size: 90%;
-        overflow:auto;
-  }
-  table { border-collapse: collapse; }
-  td, th { vertical-align: top;  }
-  th.right  { text-align:center;  }
-  th.left   { text-align:center;   }
-  th.center { text-align:center; }
-  td.right  { text-align:right;  }
-  td.left   { text-align:left;   }
-  td.center { text-align:center; }
-  dt { font-weight: bold; }
-  div.figure { padding: 0.5em; }
-  div.figure p { text-align: center; }
-  div.inlinetask {
-    padding:10px;
-    border:2px solid gray;
-    margin:10px;
-    background: #ffffcc;
-  }
-  textarea { overflow-x: auto; }
-  .linenr { font-size:smaller }
-  .code-highlighted {background-color:#ffff00;}
-  .org-info-js_info-navigation { border-style:none; }
-  #org-info-js_console-label { font-size:10px; font-weight:bold;
-                               white-space:nowrap; }
-  .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
-                                 font-weight:bold; }
-  /*]]>*/-->
-</style>"
-  "The default style specification for exported HTML files.
-Please use the variables `org-export-html-style' and
-`org-export-html-style-extra' to add to this style.  If you wish to not
-have the default style included, customize the variable
-`org-export-html-style-include-default'.")
-
-(defcustom org-export-html-style-include-default t
-  "Non-nil means include the default style in exported HTML files.
-The actual style is defined in `org-export-html-style-default' and should
-not be modified.  Use the variables `org-export-html-style' to add
-your own style information."
-  :group 'org-export-html
-  :type 'boolean)
-
-;;;###autoload
-(put 'org-export-html-style-include-default 'safe-local-variable 'booleanp)
-
-(defcustom org-export-html-style ""
-  "Org-wide style definitions for exported HTML files.
-
-This variable needs to contain the full HTML structure to provide a style,
-including the surrounding HTML tags.  If you set the value of this variable,
-you should consider to include definitions for the following classes:
- title, todo, done, timestamp, timestamp-kwd, tag, target.
-
-For example, a valid value would be:
-
-   <style type=\"text/css\">
-    <![CDATA[
-       p { font-weight: normal; color: gray; }
-       h1 { color: black; }
-      .title { text-align: center; }
-      .todo, .timestamp-kwd { color: red; }
-      .done { color: green; }
-    ]]>
-   </style>
-
-If you'd like to refer to an external style file, use something like
-
-   <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\">
-
-As the value of this option simply gets inserted into the HTML <head> header,
-you can \"misuse\" it to add arbitrary text to the header.
-See also the variable `org-export-html-style-extra'."
-  :group 'org-export-html
-  :type 'string)
-;;;###autoload
-(put 'org-export-html-style 'safe-local-variable 'stringp)
-
-(defcustom org-export-html-style-extra ""
-  "Additional style information for HTML export.
-The value of this variable is inserted into the HTML buffer right after
-the value of `org-export-html-style'.  Use this variable for per-file
-settings of style information, and do not forget to surround the style
-settings with <style>...</style> tags."
-  :group 'org-export-html
-  :type 'string)
-;;;###autoload
-(put 'org-export-html-style-extra 'safe-local-variable 'stringp)
-
-(defcustom org-export-html-mathjax-options
-  '((path  "http://orgmode.org/mathjax/MathJax.js")
-    (scale "100")
-    (align "center")
-    (indent "2em")
-    (mathml nil))
-  "Options for MathJax setup.
-
-path        The path where to find MathJax
-scale       Scaling for the HTML-CSS backend, usually between 100 and 133
-align       How to align display math: left, center, or right
-indent      If align is not center, how far from the left/right side?
-mathml      Should a MathML player be used if available?
-            This is faster and reduces bandwidth use, but currently
-            sometimes has lower spacing quality.  Therefore, the default is
-            nil.  When browsers get better, this switch can be flipped.
-
-You can also customize this for each buffer, using something like
-
-#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
-  :group 'org-export-html
-  :version "24.1"
-  :type '(list :greedy t
-              (list :tag "path   (the path from where to load MathJax.js)"
-                    (const :format "       " path) (string))
-              (list :tag "scale  (scaling for the displayed math)"
-                    (const :format "       " scale) (string))
-              (list :tag "align  (alignment of displayed equations)"
-                    (const :format "       " align) (string))
-              (list :tag "indent (indentation with left or right alignment)"
-                    (const :format "       " indent) (string))
-              (list :tag "mathml (should MathML display be used is possible)"
-                    (const :format "       " mathml) (boolean))))
-
-(defun org-export-html-mathjax-config (template options in-buffer)
-  "Insert the user setup into the matchjax template."
-  (let (name val (yes "   ") (no "// ") x)
-    (mapc
-     (lambda (e)
-       (setq name (car e) val (nth 1 e))
-       (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
-          (setq val (car (read-from-string
-                          (substring in-buffer (match-end 0))))))
-       (if (not (stringp val)) (setq val (format "%s" val)))
-       (setq template
-            (replace-regexp-in-string
-             (concat "%" (upcase (symbol-name name))) val template t t)))
-     options)
-    (setq val (nth 1 (assq 'mathml options)))
-    (if (string-match (concat "\\<mathml:") in-buffer)
-       (setq val (car (read-from-string
-                       (substring in-buffer (match-end 0))))))
-    ;; Exchange prefixes depending on mathml setting
-    (if (not val) (setq x yes yes no no x))
-    ;; Replace cookies to turn on or off the config/jax lines
-    (if (string-match ":MMLYES:" template)
-       (setq template (replace-match yes t t template)))
-    (if (string-match ":MMLNO:" template)
-       (setq template (replace-match no t t template)))
-    ;; Return the modified template
-    template))
-
-(defcustom org-export-html-mathjax-template
-  "<script type=\"text/javascript\" src=\"%PATH\">
-/**
- *
- * @source: %PATH
- *
- * @licstart  The following is the entire license notice for the
- *  JavaScript code in %PATH.
- *
- * Copyright (C) 2012-2013  MathJax
- *
- * Licensed under the Apache License, Version 2.0 (the \"License\");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an \"AS IS\" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @licend  The above is the entire license notice
- * for the JavaScript code in %PATH.
- *
- */
-
-/*
-@licstart  The following is the entire license notice for the
-JavaScript code below.
-
-Copyright (C) 2012-2013 Free Software Foundation, Inc.
-
-The JavaScript code below is free software: you can
-redistribute it and/or modify it under the terms of the GNU
-General Public License (GNU GPL) as published by the Free Software
-Foundation, either version 3 of the License, or (at your option)
-any later version.  The code is distributed WITHOUT ANY WARRANTY;
-without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
-
-As additional permission under GNU GPL version 3 section 7, you
-may distribute non-source (e.g., minimized or compacted) forms of
-that code without the copy of the GNU GPL normally required by
-section 4, provided you include this license notice and a URL
-through which recipients can access the Corresponding Source.
-
-
-@licend  The above is the entire license notice
-for the JavaScript code below.
-*/
-<!--/*--><![CDATA[/*><!--*/
-    MathJax.Hub.Config({
-        // Only one of the two following lines, depending on user settings
-        // First allows browser-native MathML display, second forces HTML/CSS
-        :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
-        :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
-        extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
-                     \"TeX/noUndefined.js\"],
-        tex2jax: {
-            inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
-            displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
-            skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
-            ignoreClass: \"tex2jax_ignore\",
-            processEscapes: false,
-            processEnvironments: true,
-            preview: \"TeX\"
-        },
-        showProcessingMessages: true,
-        displayAlign: \"%ALIGN\",
-        displayIndent: \"%INDENT\",
-
-        \"HTML-CSS\": {
-             scale: %SCALE,
-             availableFonts: [\"STIX\",\"TeX\"],
-             preferredFont: \"TeX\",
-             webFont: \"TeX\",
-             imageFont: \"TeX\",
-             showMathMenu: true,
-        },
-        MMLorHTML: {
-             prefer: {
-                 MSIE:    \"MML\",
-                 Firefox: \"MML\",
-                 Opera:   \"HTML\",
-                 other:   \"HTML\"
-             }
-        }
-    });
-/*]]>*///-->
-</script>"
-  "The MathJax setup for XHTML files."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-html-tag-class-prefix ""
-  "Prefix to class names for TODO keywords.
-Each tag gets a class given by the tag itself, with this prefix.
-The default prefix is empty because it is nice to just use the keyword
-as a class name.  But if you get into conflicts with other, existing
-CSS classes, then this prefix can be very useful."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-todo-kwd-class-prefix ""
-  "Prefix to class names for TODO keywords.
-Each TODO keyword gets a class given by the keyword itself, with this prefix.
-The default prefix is empty because it is nice to just use the keyword
-as a class name.  But if you get into conflicts with other, existing
-CSS classes, then this prefix can be very useful."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-headline-anchor-format "<a name=\"%s\" id=\"%s\"></a>"
-  "Format for anchors in HTML headlines.
-It requires to %s: both will be replaced by the anchor referring
-to the headline (e.g. \"sec-2\").  When set to `nil', don't insert
-HTML anchors in headlines."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-html-preamble t
-  "Non-nil means insert a preamble in HTML export.
-
-When `t', insert a string as defined by one of the formatting
-strings in `org-export-html-preamble-format'.  When set to a
-string, this string overrides `org-export-html-preamble-format'.
-When set to a function, apply this function and insert the
-returned string.  The function takes no argument, but you can
-use `opt-plist' to access the current export options.
-
-Setting :html-preamble in publishing projects will take
-precedence over this variable."
-  :group 'org-export-html
-  :type '(choice (const :tag "No preamble" nil)
-                (const :tag "Default preamble" t)
-                (string :tag "Custom format string")
-                (function :tag "Function (must return a string)")))
-
-(defcustom org-export-html-preamble-format '(("en" ""))
-  "Alist of languages and format strings for the HTML preamble.
-
-To enable the HTML exporter to use these formats, you need to set
-`org-export-html-preamble' to `t'.
-
-The first element of each list is the language code, as used for
-the #+LANGUAGE keyword.
-
-The second element of each list is a format string to format the
-preamble itself.  This format string can contain these elements:
-
-%t stands for the title.
-%a stands for the author's name.
-%e stands for the author's email.
-%d stands for the date.
-
-If you need to use a \"%\" character, you need to escape it
-like that: \"%%\"."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-html-postamble 'auto
-  "Non-nil means insert a postamble in HTML export.
-
-When `t', insert a string as defined by the format string in
-`org-export-html-postamble-format'.  When set to a string, this
-string overrides `org-export-html-postamble-format'.  When set to
-'auto, discard `org-export-html-postamble-format' and honor
-`org-export-author/email/creator-info' variables.  When set to a
-function, apply this function and insert the returned string.
-The function takes no argument, but you can use `opt-plist' to
-access the current export options.
-
-Setting :html-postamble in publishing projects will take
-precedence over this variable."
-  :group 'org-export-html
-  :type '(choice (const :tag "No postamble" nil)
-                (const :tag "Auto preamble" 'auto)
-                (const :tag "Default format string" t)
-                (string :tag "Custom format string")
-                (function :tag "Function (must return a string)")))
-
-(defcustom org-export-html-postamble-format
-  '(("en" "<p class=\"author\">Author: %a (%e)</p>
-<p class=\"date\">Date: %d</p>
-<p class=\"creator\">Generated by %c</p>
-<p class=\"xhtml-validation\">%v</p>
-"))
-  "Alist of languages and format strings for the HTML postamble.
-
-To enable the HTML exporter to use these formats, you need to set
-`org-export-html-postamble' to `t'.
-
-The first element of each list is the language code, as used for
-the #+LANGUAGE keyword.
-
-The second element of each list is a format string to format the
-postamble itself.  This format string can contain these elements:
-
-%a stands for the author's name.
-%e stands for the author's email.
-%d stands for the date.
-%c will be replaced by information about Org/Emacs versions.
-%v will be replaced by `org-export-html-validation-link'.
-
-If you need to use a \"%\" character, you need to escape it
-like that: \"%%\"."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-html-home/up-format
-  "<div id=\"org-div-home-and-up\" style=\"text-align:right;font-size:70%%;white-space:nowrap;\">
- <a accesskey=\"h\" href=\"%s\"> UP </a>
- |
- <a accesskey=\"H\" href=\"%s\"> HOME </a>
-</div>"
-  "Snippet used to insert the HOME and UP links.
-This is a format string, the first %s will receive the UP link,
-the second the HOME link.  If both `org-export-html-link-up' and
-`org-export-html-link-home' are empty, the entire snippet will be
-ignored."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-toplevel-hlevel 2
-  "The <H> level for level 1 headings in HTML export.
-This is also important for the classes that will be wrapped around headlines
-and outline structure.  If this variable is 1, the top-level headlines will
-be <h1>, and the corresponding classes will be outline-1, section-number-1,
-and outline-text-1.  If this is 2, all of these will get a 2 instead.
-The default for this variable is 2, because we use <h1> for formatting the
-document title."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-html-link-org-files-as-html t
-  "Non-nil means make file links to `file.org' point to `file.html'.
-When org-mode is exporting an org-mode file to HTML, links to
-non-html files are directly put into a href tag in HTML.
-However, links to other Org-mode files (recognized by the
-extension `.org.) should become links to the corresponding html
-file, assuming that the linked org-mode file will also be
-converted to HTML.
-When nil, the links still point to the plain `.org' file."
-  :group 'org-export-html
-  :type 'boolean)
-
-(defcustom org-export-html-inline-images 'maybe
-  "Non-nil means inline images into exported HTML pages.
-This is done using an <img> tag.  When nil, an anchor with href is used to
-link to the image.  If this option is `maybe', then images in links with
-an empty description will be inlined, while images with a description will
-be linked only."
-  :group 'org-export-html
-  :type '(choice (const :tag "Never" nil)
-                (const :tag "Always" t)
-                (const :tag "When there is no description" maybe)))
-
-(defcustom org-export-html-inline-image-extensions
-  '("png" "jpeg" "jpg" "gif" "svg")
-  "Extensions of image files that can be inlined into HTML."
-  :group 'org-export-html
-  :type '(repeat (string :tag "Extension")))
-
-(defcustom org-export-html-table-tag
-  "<table border=\"2\" cellspacing=\"0\" cellpadding=\"6\" rules=\"groups\" frame=\"hsides\">"
-  "The HTML tag that is used to start a table.
-This must be a <table> tag, but you may change the options like
-borders and spacing."
-  :group 'org-export-html
-  :type 'string)
-
-(defcustom org-export-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
-  "The opening tag for table header fields.
-This is customizable so that alignment options can be specified.
-The first %s will be filled with the scope of the field, either row or col.
-The second %s will be replaced by a style entry to align the field.
-See also the variable `org-export-html-table-use-header-tags-for-first-column'.
-See also the variable `org-export-html-table-align-individual-fields'."
-  :group 'org-export-tables
-  :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
-
-(defcustom org-export-table-data-tags '("<td%s>" . "</td>")
-  "The opening tag for table data fields.
-This is customizable so that alignment options can be specified.
-The first %s will be filled with the scope of the field, either row or col.
-The second %s will be replaced by a style entry to align the field.
-See also the variable `org-export-html-table-align-individual-fields'."
-  :group 'org-export-tables
-  :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
-
-(defcustom org-export-table-row-tags '("<tr>" . "</tr>")
-  "The opening tag for table data fields.
-This is customizable so that alignment options can be specified.
-Instead of strings, these can be Lisp forms that will be evaluated
-for each row in order to construct the table row tags.  During evaluation,
-the variable `head' will be true when this is a header line, nil when this
-is a body line.  And the variable `nline' will contain the line number,
-starting from 1 in the first header line.  For example
-
-  (setq org-export-table-row-tags
-        (cons '(if head
-                   \"<tr>\"
-                 (if (= (mod nline 2) 1)
-                     \"<tr class=\\\"tr-odd\\\">\"
-                   \"<tr class=\\\"tr-even\\\">\"))
-              \"</tr>\"))
-
-will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
-  :group 'org-export-tables
-  :type '(cons
-         (choice :tag "Opening tag"
-                 (string :tag "Specify")
-                 (sexp))
-         (choice :tag "Closing tag"
-                 (string :tag "Specify")
-                 (sexp))))
-
-(defcustom org-export-html-table-align-individual-fields t
-  "Non-nil means attach style attributes for alignment to each table field.
-When nil, alignment will only be specified in the column tags, but this
-is ignored by some browsers (like Firefox, Safari).  Opera does it right
-though."
-  :group 'org-export-tables
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-html-table-use-header-tags-for-first-column nil
-  "Non-nil means format column one in tables with header tags.
-When nil, also column one will use data tags."
-  :group 'org-export-tables
-  :type 'boolean)
-
-(defcustom org-export-html-validation-link
-  "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>"
-  "Link to HTML validation service."
-  :group 'org-export-html
-  :type 'string)
-
-;; FIXME Obsolete since Org 7.7
-;; Use the :timestamp option or `org-export-time-stamp-file' instead
-(defvar org-export-html-with-timestamp nil
-  "If non-nil, write container for HTML-helper-mode timestamp.")
-
-;; FIXME Obsolete since Org 7.7
-(defvar org-export-html-html-helper-timestamp
-  "\n<p><br/><br/>\n<!-- hhmts start --> <!-- hhmts end --></p>\n"
-  "The HTML tag used as timestamp delimiter for HTML-helper-mode.")
-
-(defcustom org-export-html-protect-char-alist
-  '(("&" . "&amp;")
-    ("<" . "&lt;")
-    (">" . "&gt;"))
-  "Alist of characters to be converted by `org-html-protect'."
-  :group 'org-export-html
-  :version "24.1"
-  :type '(repeat (cons (string :tag "Character")
-                      (string :tag "HTML equivalent"))))
-
-(defgroup org-export-htmlize nil
-  "Options for processing examples with htmlize.el."
-  :tag "Org Export Htmlize"
-  :group 'org-export-html)
-
-(defcustom org-export-htmlize-output-type 'inline-css
-  "Output type to be used by htmlize when formatting code snippets.
-Choices are `css', to export the CSS selectors only, or `inline-css', to
-export the CSS attribute values inline in the HTML.  We use as default
-`inline-css', in order to make the resulting HTML self-containing.
-
-However, this will fail when using Emacs in batch mode for export, because
-then no rich font definitions are in place.  It will also not be good if
-people with different Emacs setup contribute HTML files to a website,
-because the fonts will represent the individual setups.  In these cases,
-it is much better to let Org/Htmlize assign classes only, and to use
-a style file to define the look of these classes.
-To get a start for your css file, start Emacs session and make sure that
-all the faces you are interested in are defined, for example by loading files
-in all modes you want.  Then, use the command
-\\[org-export-htmlize-generate-css] to extract class definitions."
-  :group 'org-export-htmlize
-  :type '(choice (const css) (const inline-css)))
-
-(defcustom org-export-htmlize-css-font-prefix "org-"
-  "The prefix for CSS class names for htmlize font specifications."
-  :group 'org-export-htmlize
-  :type 'string)
-
-(defcustom org-export-htmlized-org-css-url nil
-  "URL pointing to a CSS file defining text colors for htmlized Emacs buffers.
-Normally when creating an htmlized version of an Org buffer, htmlize will
-create CSS to define the font colors.  However, this does not work when
-converting in batch mode, and it also can look bad if different people
-with different fontification setup work on the same website.
-When this variable is non-nil, creating an htmlized version of an Org buffer
-using `org-export-as-org' will remove the internal CSS section and replace it
-with a link to this URL."
-  :group 'org-export-htmlize
-  :type '(choice
-         (const :tag "Keep internal css" nil)
-         (string :tag "URL or local href")))
-
-;; FIXME: The following variable is obsolete since Org 7.7 but is
-;; still declared and checked within code for compatibility reasons.
-;; Use the custom variables `org-export-html-divs' instead.
-(defvar org-export-html-content-div "content"
-  "The name of the container DIV that holds all the page contents.
-
-This variable is obsolete since Org version 7.7.
-Please set `org-export-html-divs' instead.")
-
-(defcustom org-export-html-divs '("preamble" "content" "postamble")
-  "The name of the main divs for HTML export.
-This is a list of three strings, the first one for the preamble
-DIV, the second one for the content DIV and the third one for the
-postamble DIV."
-  :group 'org-export-html
-  :version "24.1"
-  :type '(list
-         (string :tag " Div for the preamble:")
-         (string :tag "  Div for the content:")
-         (string :tag "Div for the postamble:")))
-
-(defcustom org-export-html-date-format-string "%Y-%m-%dT%R%z"
-  "Format string to format the date and time.
-
-The default is an extended format of the ISO 8601 specification."
-  :group 'org-export-html
-  :version "24.1"
-  :type 'string)
-
-;;; Hooks
-
-(defvar org-export-html-after-blockquotes-hook nil
-  "Hook run during HTML export, after blockquote, verse, center are done.")
-
-(defvar org-export-html-final-hook nil
-  "Hook run at the end of HTML export, in the new buffer.")
-
-;;; HTML export
-
-(defun org-export-html-preprocess (parameters)
-  "Convert LaTeX fragments to images."
-  (when (and org-current-export-file
-            (plist-get parameters :LaTeX-fragments))
-    (org-format-latex
-     (concat org-latex-preview-ltxpng-directory (file-name-sans-extension
-                       (file-name-nondirectory
-                        org-current-export-file)))
-     org-current-export-dir nil "Creating LaTeX image %s"
-     nil nil
-     (cond
-      ((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim)
-      ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax)
-      ((eq (plist-get parameters :LaTeX-fragments) t        ) 'mathjax)
-      ((eq (plist-get parameters :LaTeX-fragments) 'imagemagick) 'imagemagick)
-      ((eq (plist-get parameters :LaTeX-fragments) 'dvipng  ) 'dvipng))))
-  (goto-char (point-min))
-  (let (label l1)
-    (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
-      (org-if-unprotected-at (match-beginning 1)
-       (setq label (match-string 1))
-       (save-match-data
-         (if (string-match "\\`[a-z]\\{1,10\\}:\\(.+\\)" label)
-             (setq l1 (substring label (match-beginning 1)))
-           (setq l1 label)))
-       (replace-match (format "[[#%s][%s]]" label l1) t t)))))
-
-;;;###autoload
-(defun org-export-as-html-and-open (arg)
-  "Export the outline as HTML and immediately open it with a browser.
-If there is an active region, export only the region.
-The prefix ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will become bulleted lists."
-  (interactive "P")
-  (org-export-as-html arg)
-  (org-open-file buffer-file-name)
-  (when org-export-kill-product-buffer-when-displayed
-    (kill-buffer (current-buffer))))
-
-;;;###autoload
-(defun org-export-as-html-batch ()
-  "Call the function `org-export-as-html'.
-This function can be used in batch processing as:
-emacs   --batch
-        --load=$HOME/lib/emacs/org.el
-        --eval \"(setq org-export-headline-levels 2)\"
-        --visit=MyFile --funcall org-export-as-html-batch"
-  (org-export-as-html org-export-headline-levels))
-
-;;;###autoload
-(defun org-export-as-html-to-buffer (arg)
-  "Call `org-export-as-html` with output to a temporary buffer.
-No file is created.  The prefix ARG is passed through to `org-export-as-html'."
-  (interactive "P")
-  (org-export-as-html arg nil "*Org HTML Export*")
-  (when org-export-show-temporary-export-buffer
-    (switch-to-buffer-other-window "*Org HTML Export*")))
-
-;;;###autoload
-(defun org-replace-region-by-html (beg end)
-  "Assume the current region has org-mode syntax, and convert it to HTML.
-This can be used in any buffer.  For example, you could write an
-itemized list in org-mode syntax in an HTML buffer and then use this
-command to convert it."
-  (interactive "r")
-  (let (reg html buf pop-up-frames)
-    (save-window-excursion
-      (if (derived-mode-p 'org-mode)
-         (setq html (org-export-region-as-html
-                     beg end t 'string))
-       (setq reg (buffer-substring beg end)
-             buf (get-buffer-create "*Org tmp*"))
-       (with-current-buffer buf
-         (erase-buffer)
-         (insert reg)
-         (org-mode)
-         (setq html (org-export-region-as-html
-                     (point-min) (point-max) t 'string)))
-       (kill-buffer buf)))
-    (delete-region beg end)
-    (insert html)))
-
-;;;###autoload
-(defun org-export-region-as-html (beg end &optional body-only buffer)
-  "Convert region from BEG to END in org-mode buffer to HTML.
-If prefix arg BODY-ONLY is set, omit file header, footer, and table of
-contents, and only produce the region of converted text, useful for
-cut-and-paste operations.
-If BUFFER is a buffer or a string, use/create that buffer as a target
-of the converted HTML.  If BUFFER is the symbol `string', return the
-produced HTML as a string and leave not buffer behind.  For example,
-a Lisp program could call this function in the following way:
-
-  (setq html (org-export-region-as-html beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (interactive "r\nP")
-  (when (org-called-interactively-p 'any)
-    (setq buffer "*Org HTML Export*"))
-  (let ((transient-mark-mode t) (zmacs-regions t)
-       ext-plist rtn)
-    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
-    (goto-char end)
-    (set-mark (point)) ;; to activate the region
-    (goto-char beg)
-    (setq rtn (org-export-as-html nil ext-plist buffer body-only))
-    (if (fboundp 'deactivate-mark) (deactivate-mark))
-    (if (and (org-called-interactively-p 'any) (bufferp rtn))
-       (switch-to-buffer-other-window rtn)
-      rtn)))
-
-(defvar html-table-tag nil) ; dynamically scoped into this.
-(defvar org-par-open nil)
-
-;;; org-html-cvt-link-fn
-(defconst org-html-cvt-link-fn
-  nil
-  "Function to convert link URLs to exportable URLs.
-Takes two arguments, TYPE and PATH.
-Returns exportable url as (TYPE PATH), or nil to signal that it
-didn't handle this case.
-Intended to be locally bound around a call to `org-export-as-html'." )
-
-(defun org-html-cvt-org-as-html (opt-plist type path)
-  "Convert an org filename to an equivalent html filename.
-If TYPE is not file, just return `nil'.
-See variable `org-export-html-link-org-files-as-html'"
-
-  (save-match-data
-    (and
-     org-export-html-link-org-files-as-html
-     (string= type "file")
-     (string-match "\\.org$" path)
-     (progn
-       (list
-       "file"
-       (concat
-        (substring path 0 (match-beginning 0))
-        "."
-        (plist-get opt-plist :html-extension)))))))
-
-
-;;; org-html-should-inline-p
-(defun org-html-should-inline-p (filename descp)
-  "Return non-nil if link FILENAME should be inlined.
-The decision to inline the FILENAME link is based on the current
-settings.  DESCP is the boolean of whether there was a link
-description.  See variables `org-export-html-inline-images' and
-`org-export-html-inline-image-extensions'."
-  (declare (special
-           org-export-html-inline-images
-           org-export-html-inline-image-extensions))
-  (and (or (eq t org-export-html-inline-images)
-          (and org-export-html-inline-images (not descp)))
-       (org-file-image-p
-       filename org-export-html-inline-image-extensions)))
-
-;;; org-html-make-link
-(defun org-html-make-link (opt-plist type path fragment desc attr
-                                    may-inline-p)
-  "Make an HTML link.
-OPT-PLIST is an options list.
-TYPE is the device-type of the link (THIS://foo.html).
-PATH is the path of the link (http://THIS#location).
-FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
-DESC is the link description, if any.
-ATTR is a string of other attributes of the \"a\" element.
-MAY-INLINE-P allows inlining it as an image."
-
-  (declare (special org-par-open))
-  (save-match-data
-    (let* ((filename path)
-          ;;First pass.  Just sanity stuff.
-          (components-1
-           (cond
-            ((string= type "file")
-             (list
-              type
-              ;;Substitute just if original path was absolute.
-              ;;(Otherwise path must remain relative)
-              (if (file-name-absolute-p path)
-                  (concat "file://" (expand-file-name path))
-                path)))
-            ((string= type "")
-             (list nil path))
-            (t (list type path))))
-
-          ;;Second pass.  Components converted so they can refer
-          ;;to a remote site.
-          (components-2
-           (or
-            (and org-html-cvt-link-fn
-                 (apply org-html-cvt-link-fn
-                        opt-plist components-1))
-            (apply #'org-html-cvt-org-as-html
-                   opt-plist components-1)
-            components-1))
-          (type    (first  components-2))
-          (thefile (second components-2)))
-
-
-      ;;Third pass.  Build final link except for leading type
-      ;;spec.
-      (cond
-       ((or
-        (not type)
-        (string= type "http")
-        (string= type "https")
-        (string= type "file")
-        (string= type "coderef"))
-       (if fragment
-           (setq thefile (concat thefile "#" fragment))))
-
-       (t))
-
-      ;;Final URL-build, for all types.
-      (setq thefile
-           (let
-               ((str (org-export-html-format-href thefile)))
-             (if (and type (not (or (string= "file" type)
-                                    (string= "coderef" type))))
-                 (concat type ":" str)
-               str)))
-
-      (if (and
-          may-inline-p
-          ;;Can't inline a URL with a fragment.
-          (not fragment))
-         (progn
-           (message "image %s %s" thefile org-par-open)
-           (org-export-html-format-image thefile org-par-open))
-       (concat
-        "<a href=\"" thefile "\"" (if attr (concat " " attr)) ">"
-        (org-export-html-format-desc desc)
-        "</a>")))))
-
-(defun org-html-handle-links (org-line opt-plist)
-  "Return ORG-LINE with markup of Org mode links.
-OPT-PLIST is the export options list."
-  (let ((start 0)
-       (current-dir (if buffer-file-name
-                        (file-name-directory buffer-file-name)
-                      default-directory))
-       (link-validate (plist-get opt-plist :link-validation-function))
-       type id-file fnc
-       rpl path attr desc descp desc1 desc2 link)
-    (while (string-match org-bracket-link-analytic-regexp++ org-line start)
-      (setq start (match-beginning 0))
-      (setq path (save-match-data (org-link-unescape
-                                  (match-string 3 org-line))))
-      (setq type (cond
-                 ((match-end 2) (match-string 2 org-line))
-                 ((save-match-data
-                    (or (file-name-absolute-p path)
-                        (string-match "^\\.\\.?/" path)))
-                  "file")
-                 (t "internal")))
-      (setq path (org-extract-attributes path))
-      (setq attr (get-text-property 0 'org-attributes path))
-      (setq desc1 (if (match-end 5) (match-string 5 org-line))
-           desc2 (if (match-end 2) (concat type ":" path) path)
-           descp (and desc1 (not (equal desc1 desc2)))
-           desc (or desc1 desc2))
-      ;; Make an image out of the description if that is so wanted
-      (when (and descp (org-file-image-p
-                       desc org-export-html-inline-image-extensions))
-       (save-match-data
-         (if (string-match "^file:" desc)
-             (setq desc (substring desc (match-end 0)))))
-       (setq desc (org-add-props
-                      (concat "<img src=\"" desc "\" "
-                              (when (save-match-data (string-match "width=" attr))
-                                (prog1 (concat attr " ") (setq attr "")))
-                              "alt=\""
-                              (file-name-nondirectory desc) "\"/>")
-                      '(org-protected t))))
-      (cond
-       ((equal type "internal")
-       (let
-           ((frag-0
-             (if (= (string-to-char path) ?#)
-                 (substring path 1)
-               path)))
-         (setq rpl
-               (org-html-make-link
-                opt-plist
-                ""
-                ""
-                (org-solidify-link-text
-                 (save-match-data (org-link-unescape frag-0))
-                 nil)
-                desc attr nil))))
-       ((and (equal type "id")
-            (setq id-file (org-id-find-id-file path)))
-       ;; This is an id: link to another file (if it was the same file,
-       ;; it would have become an internal link...)
-       (save-match-data
-         (setq id-file (file-relative-name
-                        id-file
-                        (file-name-directory org-current-export-file)))
-         (setq rpl
-               (org-html-make-link opt-plist
-                                   "file" id-file
-                                   (concat (if (org-uuidgen-p path) "ID-") path)
-                                   desc
-                                   attr
-                                   nil))))
-       ((member type '("http" "https"))
-       ;; standard URL, can inline as image
-       (setq rpl
-             (org-html-make-link opt-plist
-                                 type path nil
-                                 desc
-                                 attr
-                                 (org-html-should-inline-p path descp))))
-       ((member type '("ftp" "mailto" "news"))
-       ;; standard URL, can't inline as image
-       (setq rpl
-             (org-html-make-link opt-plist
-                                 type path nil
-                                 desc
-                                 attr
-                                 nil)))
-
-       ((string= type "coderef")
-       (let*
-           ((coderef-str (format "coderef-%s" path))
-            (attr-1
-             (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
-                     coderef-str coderef-str)))
-         (setq rpl
-               (org-html-make-link opt-plist
-                                   type "" coderef-str
-                                   (format
-                                    (org-export-get-coderef-format
-                                     path
-                                     (and descp desc))
-                                    (cdr (assoc path org-export-code-refs)))
-                                   attr-1
-                                   nil))))
-
-       ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
-       ;; The link protocol has a function for format the link
-       (setq rpl
-             (save-match-data
-               (funcall fnc (org-link-unescape path) desc1 'html))))
-
-       ((string= type "file")
-       ;; FILE link
-       (save-match-data
-         (let*
-             ((components
-               (if
-                   (string-match "::\\(.*\\)" path)
-                   (list
-                    (replace-match "" t nil path)
-                    (match-string 1 path))
-                 (list path nil)))
-
-              ;;The proper path, without a fragment
-              (path-1
-               (first components))
-
-              ;;The raw fragment
-              (fragment-0
-               (second components))
-
-              ;;Check the fragment.  If it can't be used as
-              ;;target fragment we'll pass nil instead.
-              (fragment-1
-               (if
-                   (and fragment-0
-                        (not (string-match "^[0-9]*$" fragment-0))
-                        (not (string-match "^\\*" fragment-0))
-                        (not (string-match "^/.*/$" fragment-0)))
-                   (org-solidify-link-text
-                    (org-link-unescape fragment-0))
-                 nil))
-              (desc-2
-               ;;Description minus "file:" and ".org"
-               (if (string-match "^file:" desc)
-                   (let
-                       ((desc-1 (replace-match "" t t desc)))
-                     (if (string-match "\\.org$" desc-1)
-                         (replace-match "" t t desc-1)
-                       desc-1))
-                 desc)))
-
-           (setq rpl
-                 (if
-                     (and
-                      (functionp link-validate)
-                      (not (funcall link-validate path-1 current-dir)))
-                     desc
-                   (org-html-make-link opt-plist
-                                       "file" path-1 fragment-1 desc-2 attr
-                                       (org-html-should-inline-p path-1 descp)))))))
-
-       (t
-       ;; just publish the path, as default
-       (setq rpl (concat "<i>&lt;" type ":"
-                         (save-match-data (org-link-unescape path))
-                         "&gt;</i>"))))
-      (setq org-line (replace-match rpl t t org-line)
-           start (+ start (length rpl))))
-    org-line))
-
-;;; org-export-as-html
-
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
-
-;;;###autoload
-(defun org-export-as-html (arg &optional ext-plist to-buffer body-only pub-dir)
-  "Export the outline as a pretty HTML file.
-If there is an active region, export only the region.  The prefix
-ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will become bulleted
-lists.  EXT-PLIST is a property list with external parameters overriding
-org-mode's default settings, but still inferior to file-local
-settings.  When TO-BUFFER is non-nil, create a buffer with that
-name and export to that buffer.  If TO-BUFFER is the symbol
-`string', don't leave any buffer behind but just return the
-resulting HTML as a string.  When BODY-ONLY is set, don't produce
-the file header and footer, simply return the content of
-<body>...</body>, without even the body tags themselves.  When
-PUB-DIR is set, use this as the publishing directory."
-  (interactive "P")
-  (run-hooks 'org-export-first-hook)
-
-  ;; Make sure we have a file name when we need it.
-  (when (and (not (or to-buffer body-only))
-            (not buffer-file-name))
-    (if (buffer-base-buffer)
-       (org-set-local 'buffer-file-name
-                      (with-current-buffer (buffer-base-buffer)
-                        buffer-file-name))
-      (error "Need a file name to be able to export")))
-
-  (message "Exporting...")
-  (setq-default org-todo-line-regexp org-todo-line-regexp)
-  (setq-default org-deadline-line-regexp org-deadline-line-regexp)
-  (setq-default org-done-keywords org-done-keywords)
-  (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
-  (let* ((opt-plist
-         (org-export-process-option-filters
-          (org-combine-plists (org-default-export-plist)
-                              ext-plist
-                              (org-infile-export-plist))))
-        (body-only (or body-only (plist-get opt-plist :body-only)))
-        (style (concat (if (plist-get opt-plist :style-include-default)
-                           org-export-html-style-default)
-                       (plist-get opt-plist :style)
-                       (plist-get opt-plist :style-extra)
-                       "\n"
-                       (if (plist-get opt-plist :style-include-scripts)
-                           org-export-html-scripts)))
-        (html-extension (plist-get opt-plist :html-extension))
-        valid thetoc have-headings first-heading-pos
-        (odd org-odd-levels-only)
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (level-offset (if subtree-p
-                          (save-excursion
-                            (goto-char rbeg)
-                            (+ (funcall outline-level)
-                               (if org-odd-levels-only 1 0)))
-                        0))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        ;; The following two are dynamically scoped into other
-        ;; routines below.
-        (org-current-export-dir
-         (or pub-dir (org-export-directory :html opt-plist)))
-        (org-current-export-file buffer-file-name)
-        (level 0) (org-line "") (origline "") txt todo
-        (umax nil)
-        (umax-toc nil)
-        (filename (if to-buffer nil
-                    (expand-file-name
-                     (concat
-                      (file-name-sans-extension
-                       (or (and subtree-p
-                                (org-entry-get (region-beginning)
-                                               "EXPORT_FILE_NAME" t))
-                           (file-name-nondirectory buffer-file-name)))
-                      "." html-extension)
-                     (file-name-as-directory
-                      (or pub-dir (org-export-directory :html opt-plist))))))
-        (current-dir (if buffer-file-name
-                         (file-name-directory buffer-file-name)
-                       default-directory))
-        (auto-insert nil); Avoid any auto-insert stuff for the new file
-        (buffer (if to-buffer
-                    (cond
-                     ((eq to-buffer 'string) (get-buffer-create "*Org HTML Export*"))
-                     (t (get-buffer-create to-buffer)))
-                  (find-file-noselect filename)))
-        (org-levels-open (make-vector org-level-max nil))
-        (date        (org-html-expand (plist-get opt-plist :date)))
-        (author      (org-html-expand (plist-get opt-plist :author)))
-        (html-validation-link (or org-export-html-validation-link ""))
-        (title       (org-html-expand
-                      (or (and subtree-p (org-export-get-title-from-subtree))
-                          (plist-get opt-plist :title)
-                          (and (not body-only)
-                               (not
-                                (plist-get opt-plist :skip-before-1st-heading))
-                               (org-export-grab-title-from-buffer))
-                          (and buffer-file-name
-                               (file-name-sans-extension
-                                (file-name-nondirectory buffer-file-name)))
-                          "UNTITLED")))
-        (link-up (and (plist-get opt-plist :link-up)
-                      (string-match "\\S-" (plist-get opt-plist :link-up))
-                      (plist-get opt-plist :link-up)))
-        (link-home (and (plist-get opt-plist :link-home)
-                        (string-match "\\S-" (plist-get opt-plist :link-home))
-                        (plist-get opt-plist :link-home)))
-        (dummy (setq opt-plist (plist-put opt-plist :title title)))
-        (html-table-tag (plist-get opt-plist :html-table-tag))
-        (quote-re0   (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
-        (quote-re    (format org-heading-keyword-regexp-format
-                             org-quote-string))
-        (inquote     nil)
-        (infixed     nil)
-        (inverse     nil)
-        (email       (plist-get opt-plist :email))
-        (language    (plist-get opt-plist :language))
-        (keywords    (org-html-expand (plist-get opt-plist :keywords)))
-        (description (org-html-expand (plist-get opt-plist :description)))
-        (num         (plist-get opt-plist :section-numbers))
-        (lang-words  nil)
-        (head-count  0) cnt
-        (start       0)
-        (coding-system (and (boundp 'buffer-file-coding-system)
-                            buffer-file-coding-system))
-        (coding-system-for-write (or org-export-html-coding-system
-                                     coding-system))
-        (save-buffer-coding-system (or org-export-html-coding-system
-                                       coding-system))
-        (charset (and coding-system-for-write
-                      (fboundp 'coding-system-get)
-                      (coding-system-get coding-system-for-write
-                                         'mime-charset)))
-        (region
-         (buffer-substring
-          (if region-p (region-beginning) (point-min))
-          (if region-p (region-end) (point-max))))
-        (org-export-have-math nil)
-        (org-export-footnotes-seen nil)
-        (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
-        (custom-id (or (org-entry-get nil "CUSTOM_ID" t) ""))
-        (footnote-def-prefix (format "fn-%s" custom-id))
-        (footnote-ref-prefix (format "fnr-%s" custom-id))
-        (lines
-         (org-split-string
-          (org-export-preprocess-string
-           region
-           :emph-multiline t
-           :for-backend 'html
-           :skip-before-1st-heading
-           (plist-get opt-plist :skip-before-1st-heading)
-           :drawers (plist-get opt-plist :drawers)
-           :todo-keywords (plist-get opt-plist :todo-keywords)
-           :tasks (plist-get opt-plist :tasks)
-           :tags (plist-get opt-plist :tags)
-           :priority (plist-get opt-plist :priority)
-           :footnotes (plist-get opt-plist :footnotes)
-           :timestamps (plist-get opt-plist :timestamps)
-           :archived-trees
-           (plist-get opt-plist :archived-trees)
-           :select-tags (plist-get opt-plist :select-tags)
-           :exclude-tags (plist-get opt-plist :exclude-tags)
-           :add-text
-           (plist-get opt-plist :text)
-           :LaTeX-fragments
-           (plist-get opt-plist :LaTeX-fragments))
-          "[\r\n]"))
-        (mathjax
-         (if (or (eq (plist-get opt-plist :LaTeX-fragments) 'mathjax)
-                 (and org-export-have-math
-                      (eq (plist-get opt-plist :LaTeX-fragments) t)))
-
-             (org-export-html-mathjax-config
-              org-export-html-mathjax-template
-              org-export-html-mathjax-options
-              (or (plist-get opt-plist :mathjax) ""))
-           ""))
-        table-open
-        table-buffer table-orig-buffer
-        ind
-        rpl path attr desc descp desc1 desc2 link
-        snumber fnc
-        footnotes footref-seen
-        href)
-
-    (let ((inhibit-read-only t))
-      (org-unmodified
-       (remove-text-properties (point-min) (point-max)
-                              '(:org-license-to-kill t))))
-
-    (message "Exporting...")
-
-    (setq org-min-level (org-get-min-level lines level-offset))
-    (setq org-last-level org-min-level)
-    (org-init-section-numbers)
-
-    (cond
-     ((and date (string-match "%" date))
-      (setq date (format-time-string date)))
-     (date)
-     (t (setq date (format-time-string org-export-html-date-format-string))))
-
-    ;; Get the language-dependent settings
-    (setq lang-words (or (assoc language org-export-language-setup)
-                        (assoc "en" org-export-language-setup)))
-
-    ;; Switch to the output buffer
-    (set-buffer buffer)
-    (let ((inhibit-read-only t)) (erase-buffer))
-    (fundamental-mode)
-    (org-install-letbind)
-
-    (and (fboundp 'set-buffer-file-coding-system)
-        (set-buffer-file-coding-system coding-system-for-write))
-
-    (let ((case-fold-search nil)
-         (org-odd-levels-only odd))
-      ;; create local variables for all options, to make sure all called
-      ;; functions get the correct information
-      (mapc (lambda (x)
-             (set (make-local-variable (nth 2 x))
-                  (plist-get opt-plist (car x))))
-           org-export-plist-vars)
-      (setq umax (if arg (prefix-numeric-value arg)
-                  org-export-headline-levels))
-      (setq umax-toc (if (integerp org-export-with-toc)
-                        (min org-export-with-toc umax)
-                      umax))
-      (unless body-only
-       ;; File header
-       (insert (format
-                "%s
-<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
-               \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
-<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">
-<head>
-<title>%s</title>
-<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
-<meta name=\"title\" content=\"%s\"/>
-<meta name=\"generator\" content=\"Org-mode\"/>
-<meta name=\"generated\" content=\"%s\"/>
-<meta name=\"author\" content=\"%s\"/>
-<meta name=\"description\" content=\"%s\"/>
-<meta name=\"keywords\" content=\"%s\"/>
-%s
-%s
-</head>
-<body>
-%s
-"
-                (format
-                 (or (and (stringp org-export-html-xml-declaration)
-                          org-export-html-xml-declaration)
-                     (cdr (assoc html-extension org-export-html-xml-declaration))
-                     (cdr (assoc "html" org-export-html-xml-declaration))
-
-                     "")
-                 (or charset "iso-8859-1"))
-                language language
-                title
-                (or charset "iso-8859-1")
-                title date author description keywords
-                style
-                mathjax
-                (if (or link-up link-home)
-                    (concat
-                     (format org-export-html-home/up-format
-                             (or link-up link-home)
-                             (or link-home link-up))
-                     "\n")
-                  "")))
-
-       ;; insert html preamble
-       (when (plist-get opt-plist :html-preamble)
-         (let ((html-pre (plist-get opt-plist :html-preamble))
-               (html-pre-real-contents ""))
-           (cond ((stringp html-pre)
-                  (setq html-pre-real-contents
-                        (format-spec html-pre `((?t . ,title) (?a . ,author)
-                                                (?d . ,date) (?e . ,email)))))
-                 ((functionp html-pre)
-                  (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
-                  (if (stringp (funcall html-pre)) (insert (funcall html-pre)))
-                  (insert "\n</div>\n"))
-                 (t
-                  (setq html-pre-real-contents
-                        (format-spec
-                         (or (cadr (assoc (nth 0 lang-words)
-                                          org-export-html-preamble-format))
-                             (cadr (assoc "en" org-export-html-preamble-format)))
-                         `((?t . ,title) (?a . ,author)
-                           (?d . ,date) (?e . ,email))))))
-           ;; don't output an empty preamble DIV
-           (unless (and (functionp html-pre)
-                        (equal html-pre-real-contents ""))
-             (insert "<div id=\"" (nth 0 org-export-html-divs) "\">\n")
-             (insert html-pre-real-contents)
-             (insert "\n</div>\n"))))
-
-       ;; begin wrap around body
-       (insert (format "\n<div id=\"%s\">"
-                       ;; FIXME org-export-html-content-div is obsolete since 7.7
-                       (or org-export-html-content-div
-                           (nth 1 org-export-html-divs)))
-               ;; FIXME this should go in the preamble but is here so
-               ;; that org-infojs can still find it
-               "\n<h1 class=\"title\">" title "</h1>\n"))
-
-      ;; insert body
-      (if org-export-with-toc
-         (progn
-           (push (format "<h%d>%s</h%d>\n"
-                         org-export-html-toplevel-hlevel
-                         (nth 3 lang-words)
-                         org-export-html-toplevel-hlevel)
-                 thetoc)
-           (push "<div id=\"text-table-of-contents\">\n" thetoc)
-           (push "<ul>\n<li>" thetoc)
-           (setq lines
-                 (mapcar
-                  #'(lambda (org-line)
-                      (if (and (string-match org-todo-line-regexp org-line)
-                               (not (get-text-property 0 'org-protected org-line)))
-                          ;; This is a headline
-                          (progn
-                            (setq have-headings t)
-                            (setq level (- (match-end 1) (match-beginning 1)
-                                           level-offset)
-                                  level (org-tr-level level)
-                                  txt (save-match-data
-                                        (org-html-expand
-                                         (org-export-cleanup-toc-line
-                                          (match-string 3 org-line))))
-                                  todo
-                                  (or (and org-export-mark-todo-in-toc
-                                           (match-beginning 2)
-                                           (not (member (match-string 2 org-line)
-                                                        org-done-keywords)))
-                                       ; TODO, not DONE
-                                      (and org-export-mark-todo-in-toc
-                                           (= level umax-toc)
-                                           (org-search-todo-below
-                                            org-line lines level))))
-                            (if (string-match
-                                 (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
-                                (setq txt (replace-match
-                                           "&nbsp;&nbsp;&nbsp;<span class=\"tag\">\\1</span>" t nil txt)))
-                            (if (string-match quote-re0 txt)
-                                (setq txt (replace-match "" t t txt)))
-                            (setq snumber (org-section-number level))
-                            (if (and num (if (integerp num)
-                                             (>= num level)
-                                           num))
-                                (setq txt (concat snumber " " txt)))
-                            (if (<= level (max umax umax-toc))
-                                (setq head-count (+ head-count 1)))
-                            (if (<= level umax-toc)
-                                (progn
-                                  (if (> level org-last-level)
-                                      (progn
-                                        (setq cnt (- level org-last-level))
-                                        (while (>= (setq cnt (1- cnt)) 0)
-                                          (push "\n<ul>\n<li>" thetoc))
-                                        (push "\n" thetoc)))
-                                  (if (< level org-last-level)
-                                      (progn
-                                        (setq cnt (- org-last-level level))
-                                        (while (>= (setq cnt (1- cnt)) 0)
-                                          (push "</li>\n</ul>" thetoc))
-                                        (push "\n" thetoc)))
-                                  ;; Check for targets
-                                  (while (string-match org-any-target-regexp org-line)
-                                    (setq org-line (replace-match
-                                                    (concat "@<span class=\"target\">"
-                                                            (match-string 1 org-line) "@</span> ")
-                                                    t t org-line)))
-                                  (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
-                                    (setq txt (replace-match "" t t txt)))
-                                  (setq href
-                                        (replace-regexp-in-string
-                                         "\\." "-" (format "sec-%s" snumber)))
-                                  (setq href (org-solidify-link-text
-                                              (or (cdr (assoc href
-                                                              org-export-preferred-target-alist)) href)))
-                                  (push
-                                   (format
-                                    (if todo
-                                        "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>"
-                                      "</li>\n<li><a href=\"#%s\">%s</a>")
-                                    href txt) thetoc)
-
-                                  (setq org-last-level level)))))
-                      org-line)
-                  lines))
-           (while (> org-last-level (1- org-min-level))
-             (setq org-last-level (1- org-last-level))
-             (push "</li>\n</ul>\n" thetoc))
-           (push "</div>\n" thetoc)
-           (setq thetoc (if have-headings (nreverse thetoc) nil))))
-
-      (setq head-count 0)
-      (org-init-section-numbers)
-
-      (org-open-par)
-
-      (while (setq org-line (pop lines) origline org-line)
-       (catch 'nextline
-
-         ;; end of quote section?
-         (when (and inquote (string-match org-outline-regexp-bol org-line))
-           (insert "</pre>\n")
-           (org-open-par)
-           (setq inquote nil))
-         ;; inside a quote section?
-         (when inquote
-           (insert (org-html-protect org-line) "\n")
-           (throw 'nextline nil))
-
-         ;; Fixed-width, verbatim lines (examples)
-         (when (and org-export-with-fixed-width
-                    (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" org-line))
-           (when (not infixed)
-             (setq infixed t)
-             (org-close-par-maybe)
-
-             (insert "<pre class=\"example\">\n"))
-           (insert (org-html-protect (match-string 3 org-line)) "\n")
-           (when (or (not lines)
-                     (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
-                                        (car lines))))
-             (setq infixed nil)
-             (insert "</pre>\n")
-             (org-open-par))
-           (throw 'nextline nil))
-
-         ;; Protected HTML
-         (when (and (get-text-property 0 'org-protected org-line)
-                    ;; Make sure it is the entire line that is protected
-                    (not (< (or (next-single-property-change
-                                 0 'org-protected org-line) 10000)
-                            (length org-line))))
-           (let (par (ind (get-text-property 0 'original-indentation org-line)))
-             (when (re-search-backward
-                    "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
-               (setq par (match-string 1))
-               (replace-match "\\2\n"))
-             (insert org-line "\n")
-             (while (and lines
-                         (or (= (length (car lines)) 0)
-                             (not ind)
-                             (equal ind (get-text-property 0 'original-indentation (car lines))))
-                         (or (= (length (car lines)) 0)
-                             (get-text-property 0 'org-protected (car lines))))
-               (insert (pop lines) "\n"))
-             (and par (insert "<p>\n")))
-           (throw 'nextline nil))
-
-         ;; Blockquotes, verse, and center
-         (when (equal "ORG-BLOCKQUOTE-START" org-line)
-           (org-close-par-maybe)
-           (insert "<blockquote>\n")
-           (org-open-par)
-           (throw 'nextline nil))
-         (when (equal "ORG-BLOCKQUOTE-END" org-line)
-           (org-close-par-maybe)
-           (insert "\n</blockquote>\n")
-           (org-open-par)
-           (throw 'nextline nil))
-         (when (equal "ORG-VERSE-START" org-line)
-           (org-close-par-maybe)
-           (insert "\n<p class=\"verse\">\n")
-           (setq org-par-open t)
-           (setq inverse t)
-           (throw 'nextline nil))
-         (when (equal "ORG-VERSE-END" org-line)
-           (insert "</p>\n")
-           (setq org-par-open nil)
-           (org-open-par)
-           (setq inverse nil)
-           (throw 'nextline nil))
-         (when (equal "ORG-CENTER-START" org-line)
-           (org-close-par-maybe)
-           (insert "\n<div style=\"text-align: center\">")
-           (org-open-par)
-           (throw 'nextline nil))
-         (when (equal "ORG-CENTER-END" org-line)
-           (org-close-par-maybe)
-           (insert "\n</div>")
-           (org-open-par)
-           (throw 'nextline nil))
-         (run-hooks 'org-export-html-after-blockquotes-hook)
-         (when inverse
-           (let ((i (org-get-string-indentation org-line)))
-             (if (> i 0)
-                 (setq org-line (concat (mapconcat 'identity
-                                                   (make-list (* 2 i) "\\nbsp") "")
-                                        " " (org-trim org-line))))
-             (unless (string-match "\\\\\\\\[ \t]*$" org-line)
-               (setq org-line (concat org-line "\\\\")))))
-
-         ;; make targets to anchors
-         (setq start 0)
-         (while (string-match
-                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" org-line start)
-           (cond
-            ((get-text-property (match-beginning 1) 'org-protected org-line)
-             (setq start (match-end 1)))
-            ((match-end 2)
-             (setq org-line (replace-match
-                             (format
-                              "@<a name=\"%s\" id=\"%s\">@</a>"
-                              (org-solidify-link-text (match-string 1 org-line))
-                              (org-solidify-link-text (match-string 1 org-line)))
-                             t t org-line)))
-            ((and org-export-with-toc (equal (string-to-char org-line) ?*))
-             ;; FIXME: NOT DEPENDENT on TOC?????????????????????
-             (setq org-line (replace-match
-                             (concat "@<span class=\"target\">"
-                                     (match-string 1 org-line) "@</span> ")
-                             ;; (concat "@<i>" (match-string 1 org-line) "@</i> ")
-                             t t org-line)))
-            (t
-             (setq org-line (replace-match
-                             (concat "@<a name=\""
-                                     (org-solidify-link-text (match-string 1 org-line))
-                                     "\" class=\"target\">" (match-string 1 org-line)
-                                     "@</a> ")
-                             t t org-line)))))
-
-         (setq org-line (org-html-handle-time-stamps org-line))
-
-         ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
-         ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
-         ;; Also handle sub_superscripts and checkboxes
-         (or (string-match org-table-hline-regexp org-line)
-             (string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" org-line)
-             (setq org-line (org-html-expand org-line)))
-
-         ;; Format the links
-         (setq org-line (org-html-handle-links org-line opt-plist))
-
-         ;; TODO items
-         (if (and org-todo-line-regexp
-                  (string-match org-todo-line-regexp org-line)
-                  (match-beginning 2))
-
-             (setq org-line
-                   (concat (substring org-line 0 (match-beginning 2))
-                           "<span class=\""
-                           (if (member (match-string 2 org-line)
-                                       org-done-keywords)
-                               "done" "todo")
-                           " " (org-export-html-get-todo-kwd-class-name
-                                (match-string 2 org-line))
-                           "\">" (match-string 2 org-line)
-                           "</span>" (substring org-line (match-end 2)))))
-
-         ;; Does this contain a reference to a footnote?
-         (when org-export-with-footnotes
-           (setq start 0)
-           (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" org-line start)
-             ;; Discard protected matches not clearly identified as
-             ;; footnote markers.
-             (if (or (get-text-property (match-beginning 2) 'org-protected org-line)
-                     (not (get-text-property (match-beginning 2) 'org-footnote org-line)))
-                 (setq start (match-end 2))
-               (let ((n (match-string 2 org-line)) extra a)
-                 (if (setq a (assoc n footref-seen))
-                     (progn
-                       (setcdr a (1+ (cdr a)))
-                       (setq extra (format ".%d" (cdr a))))
-                   (setq extra "")
-                   (push (cons n 1) footref-seen))
-                 (setq org-line
-                       (replace-match
-                        (concat
-                         (format
-                          (concat "%s"
-                                  (format org-export-html-footnote-format
-                                          (concat "<a class=\"footref\" name=\"" footnote-ref-prefix ".%s%s\" href=\"#" footnote-def-prefix ".%s\">%s</a>")))
-                          (or (match-string 1 org-line) "") n extra n n)
-                         ;; If another footnote is following the
-                         ;; current one, add a separator.
-                         (if (save-match-data
-                               (string-match "\\`\\[[0-9]+\\]"
-                                             (substring org-line (match-end 0))))
-                             org-export-html-footnote-separator
-                           ""))
-                        t t org-line))))))
-
-         (cond
-          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" org-line)
-           ;; This is a headline
-           (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
-                                        level-offset))
-                 txt (or (match-string 2 org-line) ""))
-           (if (string-match quote-re0 txt)
-               (setq txt (replace-match "" t t txt)))
-           (if (<= level (max umax umax-toc))
-               (setq head-count (+ head-count 1)))
-           (setq first-heading-pos (or first-heading-pos (point)))
-           (org-html-level-start level txt umax
-                                 (and org-export-with-toc (<= level umax))
-                                 head-count opt-plist)
-
-           ;; QUOTES
-           (when (string-match quote-re org-line)
-             (org-close-par-maybe)
-             (insert "<pre>")
-             (setq inquote t)))
-
-          ((and org-export-with-tables
-                (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" org-line))
-           (when (not table-open)
-             ;; New table starts
-             (setq table-open t table-buffer nil table-orig-buffer nil))
-
-           ;; Accumulate lines
-           (setq table-buffer (cons org-line table-buffer)
-                 table-orig-buffer (cons origline table-orig-buffer))
-           (when (or (not lines)
-                     (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
-                                        (car lines))))
-             (setq table-open nil
-                   table-buffer (nreverse table-buffer)
-                   table-orig-buffer (nreverse table-orig-buffer))
-             (org-close-par-maybe)
-             (insert (org-format-table-html table-buffer table-orig-buffer))))
-
-          ;; Normal lines
-
-          (t
-           ;; This line either is list item or end a list.
-           (when (get-text-property 0 'list-item org-line)
-             (setq org-line (org-html-export-list-line
-                             org-line
-                             (get-text-property 0 'list-item org-line)
-                             (get-text-property 0 'list-struct org-line)
-                             (get-text-property 0 'list-prevs org-line))))
-
-           ;; Horizontal line
-           (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" org-line)
-             (if org-par-open
-                 (insert "\n</p>\n<hr/>\n<p>\n")
-               (insert "\n<hr/>\n"))
-             (throw 'nextline nil))
-
-           ;; Empty lines start a new paragraph.  If hand-formatted lists
-           ;; are not fully interpreted, lines starting with "-", "+", "*"
-           ;; also start a new paragraph.
-           (if (string-match "^ [-+*]-\\|^[ \t]*$" org-line) (org-open-par))
-
-           ;; Is this the start of a footnote?
-           (when org-export-with-footnotes
-             (when (and (boundp 'footnote-section-tag-regexp)
-                        (string-match (concat "^" footnote-section-tag-regexp)
-                                      org-line))
-               ;; ignore this line
-               (throw 'nextline nil))
-             (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" org-line)
-               (org-close-par-maybe)
-               (let ((n (match-string 1 org-line)))
-                 (setq org-par-open t
-                       org-line (replace-match
-                                 (format
-                                  (concat "<p class=\"footnote\">"
-                                          (format org-export-html-footnote-format
-                                                  (concat
-                                                   "<a class=\"footnum\" name=\"" footnote-def-prefix ".%s\" href=\"#" footnote-ref-prefix ".%s\">%s</a>")))
-                                  n n n) t t org-line)))))
-           ;; Check if the line break needs to be conserved
-           (cond
-            ((string-match "\\\\\\\\[ \t]*$" org-line)
-             (setq org-line (replace-match "<br/>" t t org-line)))
-            (org-export-preserve-breaks
-             (setq org-line (concat org-line "<br/>"))))
-
-           ;; Check if a paragraph should be started
-           (let ((start 0))
-             (while (and org-par-open
-                         (string-match "\\\\par\\>" org-line start))
-               ;; Leave a space in the </p> so that the footnote matcher
-               ;; does not see this.
-               (if (not (get-text-property (match-beginning 0)
-                                           'org-protected org-line))
-                   (setq org-line (replace-match "</p ><p >" t t org-line)))
-               (setq start (match-end 0))))
-
-           (insert org-line "\n")))))
-
-      ;; Properly close all local lists and other lists
-      (when inquote
-       (insert "</pre>\n")
-       (org-open-par))
-
-      (org-html-level-start 1 nil umax
-                           (and org-export-with-toc (<= level umax))
-                           head-count opt-plist)
-      ;; the </div> to close the last text-... div.
-      (when (and (> umax 0) first-heading-pos) (insert "</div>\n"))
-
-      (save-excursion
-       (goto-char (point-min))
-       (while (re-search-forward
-               "\\(\\(<p class=\"footnote\">\\)[^\000]*?\\)\\(\\(\\2\\)\\|\\'\\)"
-               nil t)
-         (push (match-string 1) footnotes)
-         (replace-match "\\4" t nil)
-         (goto-char (match-beginning 0))))
-      (when footnotes
-       (insert (format org-export-html-footnotes-section
-                       (nth 4 lang-words)
-                       (mapconcat 'identity (nreverse footnotes) "\n"))
-               "\n"))
-      (let ((bib (org-export-html-get-bibliography)))
-       (when bib
-         (insert "\n" bib "\n")))
-
-      (unless body-only
-       ;; end wrap around body
-       (insert "</div>\n")
-
-       ;; export html postamble
-       (let ((html-post (plist-get opt-plist :html-postamble))
-             (email
-              (mapconcat (lambda(e)
-                           (format "<a href=\"mailto:%s\">%s</a>" e e))
-                         (split-string email ",+ *")
-                         ", "))
-             (creator-info
-              (concat "<a href=\"http://orgmode.org\">Org</a> version "
-                      (org-version) " with <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> version "
-                      (number-to-string emacs-major-version))))
-
-         (when (plist-get opt-plist :html-postamble)
-           (insert "\n<div id=\"" (nth 2 org-export-html-divs) "\">\n")
-           (cond ((stringp html-post)
-                  (insert (format-spec html-post
-                                       `((?a . ,author) (?e . ,email)
-                                         (?d . ,date)   (?c . ,creator-info)
-                                         (?v . ,html-validation-link)))))
-                 ((functionp html-post)
-                  (if (stringp (funcall html-post)) (insert (funcall html-post))))
-                 ((eq html-post 'auto)
-                  ;; fall back on default postamble
-                  (when (plist-get opt-plist :time-stamp-file)
-                    (insert "<p class=\"date\">" (nth 2 lang-words) ": " date "</p>\n"))
-                  (when (and (plist-get opt-plist :author-info) author)
-                    (insert "<p class=\"author\">" (nth 1 lang-words) ": " author "</p>\n"))
-                  (when (and (plist-get opt-plist :email-info) email)
-                    (insert "<p class=\"email\">" email "</p>\n"))
-                  (when (plist-get opt-plist :creator-info)
-                    (insert "<p class=\"creator\">"
-                            (concat "<a href=\"http://orgmode.org\">Org</a> version "
-                                    (org-version) " with <a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> version "
-                                    (number-to-string emacs-major-version) "</p>\n")))
-                  (insert html-validation-link "\n"))
-                 (t
-                  (insert (format-spec
-                           (or (cadr (assoc (nth 0 lang-words)
-                                            org-export-html-postamble-format))
-                               (cadr (assoc "en" org-export-html-postamble-format)))
-                           `((?a . ,author) (?e . ,email)
-                             (?d . ,date)   (?c . ,creator-info)
-                             (?v . ,html-validation-link))))))
-           (insert "\n</div>"))))
-
-      ;; FIXME `org-export-html-with-timestamp' has been declared
-      ;; obsolete since Org 7.7 -- don't forget to remove this.
-      (if org-export-html-with-timestamp
-         (insert org-export-html-html-helper-timestamp))
-
-      (unless body-only (insert "\n</body>\n</html>\n"))
-
-      (unless (plist-get opt-plist :buffer-will-be-killed)
-       (normal-mode)
-       (if (eq major-mode (default-value 'major-mode))
-           (html-mode)))
-
-      ;; insert the table of contents
-      (goto-char (point-min))
-      (when thetoc
-       (if (or (re-search-forward
-                "<p>\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*</p>" nil t)
-               (re-search-forward
-                "\\[TABLE-OF-CONTENTS\\]" nil t))
-           (progn
-             (goto-char (match-beginning 0))
-             (replace-match ""))
-         (goto-char first-heading-pos)
-         (when (looking-at "\\s-*</p>")
-           (goto-char (match-end 0))
-           (insert "\n")))
-       (insert "<div id=\"table-of-contents\">\n")
-       (let ((beg (point)))
-         (mapc 'insert thetoc)
-         (insert "</div>\n")
-         (while (re-search-backward "<li>[ \r\n\t]*</li>\n?" beg t)
-           (replace-match ""))))
-      ;; remove empty paragraphs
-      (goto-char (point-min))
-      (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t)
-       (replace-match ""))
-      (goto-char (point-min))
-      ;; Convert whitespace place holders
-      (goto-char (point-min))
-      (let (beg end n)
-       (while (setq beg (next-single-property-change (point) 'org-whitespace))
-         (setq n (get-text-property beg 'org-whitespace)
-               end (next-single-property-change beg 'org-whitespace))
-         (goto-char beg)
-         (delete-region beg end)
-         (insert (format "<span style=\"visibility:hidden;\">%s</span>"
-                         (make-string n ?x)))))
-      ;; Remove empty lines at the beginning of the file.
-      (goto-char (point-min))
-      (when (looking-at "\\s-+\n") (replace-match ""))
-      ;; Remove display properties
-      (remove-text-properties (point-min) (point-max) '(display t))
-      ;; Run the hook
-      (run-hooks 'org-export-html-final-hook)
-      (or to-buffer (save-buffer))
-      (goto-char (point-min))
-      (or (org-export-push-to-kill-ring "HTML")
-         (message "Exporting... done"))
-      (if (eq to-buffer 'string)
-         (prog1 (buffer-substring (point-min) (point-max))
-           (kill-buffer (current-buffer)))
-       (current-buffer)))))
-
-(defun org-export-html-format-href (s)
-  "Make sure the S is valid as a href reference in an XHTML document."
-  (save-match-data
-    (let ((start 0))
-      (while (string-match "&" s start)
-       (setq start (+ (match-beginning 0) 3)
-             s (replace-match "&amp;" t t s)))))
-  s)
-
-(defun org-export-html-format-desc (s)
-  "Make sure the S is valid as a description in a link."
-  (if (and s (not (get-text-property 1 'org-protected s)))
-      (save-match-data
-       (org-html-do-expand s))
-    s))
-
-(defun org-export-html-format-image (src par-open)
-  "Create image tag with source and attributes."
-  (save-match-data
-    (if (string-match (regexp-quote org-latex-preview-ltxpng-directory) src)
-       (format "<img src=\"%s\" alt=\"%s\"/>"
-                src (org-find-text-property-in-string 'org-latex-src src))
-      (let* ((caption (org-find-text-property-in-string 'org-caption src))
-            (attr (org-find-text-property-in-string 'org-attributes src))
-            (label (org-find-text-property-in-string 'org-label src)))
-       (setq caption (and caption (org-html-do-expand caption)))
-       (concat
-        (if caption
-            (format "%s<div %sclass=\"figure\">
-<p>"
-                    (if org-par-open "</p>\n" "")
-                    (if label (format "id=\"%s\" " (org-solidify-link-text label)) "")))
-        (format "<img src=\"%s\"%s />"
-                src
-                (if (string-match "\\<alt=" (or attr ""))
-                    (concat " " attr )
-                  (concat " " attr " alt=\"" src "\"")))
-        (if caption
-            (format "</p>%s
-</div>%s"
-                    (concat "\n<p>" caption "</p>")
-                    (if org-par-open "\n<p>" ""))))))))
-
-(defun org-export-html-get-bibliography ()
-  "Find bibliography, cut it out and return it."
-  (catch 'exit
-    (let (beg end (cnt 1) bib)
-      (save-excursion
-       (goto-char (point-min))
-       (when (re-search-forward "^[ \t]*<div \\(id\\|class\\)=\"bibliography\"" nil t)
-         (setq beg (match-beginning 0))
-         (while (re-search-forward "</?div\\>" nil t)
-           (setq cnt (+ cnt (if (string= (match-string 0) "<div") +1 -1)))
-           (when (= cnt 0)
-             (and (looking-at ">") (forward-char 1))
-             (setq bib (buffer-substring beg (point)))
-             (delete-region beg (point))
-             (throw 'exit bib))))
-       nil))))
-
-(defvar org-table-number-regexp) ; defined in org-table.el
-(defun org-format-table-html (lines olines &optional no-css)
-  "Find out which HTML converter to use and return the HTML code.
-NO-CSS is passed to the exporter."
-  (if (stringp lines)
-      (setq lines (org-split-string lines "\n")))
-  (if (string-match "^[ \t]*|" (car lines))
-      ;; A normal org table
-      (org-format-org-table-html lines nil no-css)
-    ;; Table made by table.el
-    (or (org-format-table-table-html-using-table-generate-source
-        olines (not org-export-prefer-native-exporter-for-tables))
-       ;; We are here only when table.el table has NO col or row
-       ;; spanning and the user prefers using org's own converter for
-       ;; exporting of such simple table.el tables.
-       (org-format-table-table-html lines))))
-
-(defvar org-table-number-fraction) ; defined in org-table.el
-(defun org-format-org-table-html (lines &optional splice no-css)
-  "Format a table into HTML.
-LINES is a list of lines.  Optional argument SPLICE means, do not
-insert header and surrounding <table> tags, just format the lines.
-Optional argument NO-CSS means use XHTML attributes instead of CSS
-for formatting.  This is required for the DocBook exporter."
-  (require 'org-table)
-  ;; Get rid of hlines at beginning and end
-  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-  (setq lines (nreverse lines))
-  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-  (setq lines (nreverse lines))
-  (when org-export-table-remove-special-lines
-    ;; Check if the table has a marking column.  If yes remove the
-    ;; column and the special lines
-    (setq lines (org-table-clean-before-export lines)))
-
-  (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
-        (label (org-find-text-property-in-string 'org-label (car lines)))
-        (col-cookies (org-find-text-property-in-string 'org-col-cookies
-                                                       (car lines)))
-        (attributes (org-find-text-property-in-string 'org-attributes
-                                                      (car lines)))
-        (html-table-tag (org-export-splice-attributes
-                         html-table-tag attributes))
-        (head (and org-export-highlight-first-table-line
-                   (delq nil (mapcar
-                              (lambda (x) (string-match "^[ \t]*|-" x))
-                              (cdr lines)))))
-        (nline 0) fnum nfields i (cnt 0)
-        tbopen org-line fields html gr colgropen rowstart rowend
-        ali align aligns n)
-    (setq caption (and caption (org-html-do-expand caption)))
-    (when (and col-cookies org-table-clean-did-remove-column)
-      (setq col-cookies
-           (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
-    (if splice (setq head nil))
-    (unless splice (push (if head "<thead>" "<tbody>") html))
-    (setq tbopen t)
-    (while (setq org-line (pop lines))
-      (catch 'next-line
-       (if (string-match "^[ \t]*|-" org-line)
-           (progn
-             (unless splice
-               (push (if head "</thead>" "</tbody>") html)
-               (if lines (push "<tbody>" html) (setq tbopen nil)))
-             (setq head nil)   ;; head ends here, first time around
-             ;; ignore this line
-             (throw 'next-line t)))
-       ;; Break the line into fields
-       (setq fields (org-split-string org-line "[ \t]*|[ \t]*"))
-       (unless fnum (setq fnum (make-vector (length fields) 0)
-                          nfields (length fnum)))
-       (setq nline (1+ nline) i -1
-             rowstart (eval (car org-export-table-row-tags))
-             rowend (eval (cdr org-export-table-row-tags)))
-       (push (concat rowstart
-                     (mapconcat
-                      (lambda (x)
-                        (setq i (1+ i) ali (format "@@class%03d@@" i))
-                        (if (and (< i nfields) ; make sure no rogue line causes an error here
-                                 (string-match org-table-number-regexp x))
-                            (incf (aref fnum i)))
-                        (cond
-                         (head
-                          (concat
-                           (format (car org-export-table-header-tags)
-                                   "col" ali)
-                           x
-                           (cdr org-export-table-header-tags)))
-                         ((and (= i 0) org-export-html-table-use-header-tags-for-first-column)
-                          (concat
-                           (format (car org-export-table-header-tags)
-                                   "row" ali)
-                           x
-                           (cdr org-export-table-header-tags)))
-                         (t
-                          (concat (format (car org-export-table-data-tags) ali)
-                                  x
-                                  (cdr org-export-table-data-tags)))))
-                      fields "")
-                     rowend)
-             html)))
-    (unless splice (if tbopen (push "</tbody>" html)))
-    (unless splice (push "</table>\n" html))
-    (setq html (nreverse html))
-    (unless splice
-      ;; Put in col tags with the alignment (unfortunately often ignored...)
-      (unless (car org-table-colgroup-info)
-       (setq org-table-colgroup-info
-             (cons :start (cdr org-table-colgroup-info))))
-      (setq i 0)
-      (push (mapconcat
-            (lambda (x)
-              (setq gr (pop org-table-colgroup-info)
-                    i (1+ i)
-                    align (if (nth 1 (assoc i col-cookies))
-                              (cdr (assoc (nth 1 (assoc i col-cookies))
-                                          '(("l" . "left") ("r" . "right")
-                                            ("c" . "center"))))
-                            (if (> (/ (float x) nline)
-                                   org-table-number-fraction)
-                                "right" "left")))
-              (push align aligns)
-              (format (if no-css
-                          "%s<col align=\"%s\" />%s"
-                        "%s<col class=\"%s\" />%s")
-                      (if (memq gr '(:start :startend))
-                          (prog1
-                              (if colgropen
-                                  "</colgroup>\n<colgroup>"
-                                "<colgroup>")
-                            (setq colgropen t))
-                        "")
-                      align
-                      (if (memq gr '(:end :startend))
-                          (progn (setq colgropen nil) "</colgroup>")
-                        "")))
-            fnum "")
-           html)
-      (setq aligns (nreverse aligns))
-      (if colgropen (setq html (cons (car html)
-                                    (cons "</colgroup>" (cdr html)))))
-      ;; Since the output of HTML table formatter can also be used in
-      ;; DocBook document, include empty captions for the DocBook
-      ;; export only so that it produces valid XML.
-      (when (or caption (eq org-export-current-backend 'docbook))
-       (push (format "<caption>%s</caption>" (or caption "")) html))
-      (when label
-       (setq html-table-tag (org-export-splice-attributes html-table-tag (format "id=\"%s\"" (org-solidify-link-text label)))))
-      (push html-table-tag html))
-    (setq html (mapcar
-               (lambda (x)
-                 (replace-regexp-in-string
-                  "@@class\\([0-9]+\\)@@"
-                  (lambda (txt)
-                    (if (not org-export-html-table-align-individual-fields)
-                        ""
-                      (setq n (string-to-number (match-string 1 txt)))
-                      (format (if no-css " align=\"%s\"" " class=\"%s\"")
-                              (or (nth n aligns) "left"))))
-                  x))
-               html))
-    (concat (mapconcat 'identity html "\n") "\n")))
-
-(defun org-export-splice-attributes (tag attributes)
-  "Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
-  (if (not attributes)
-      tag
-    (let (oldatt newatt)
-      (setq oldatt (org-extract-attributes-from-string tag)
-           tag (pop oldatt)
-           newatt (cdr (org-extract-attributes-from-string attributes)))
-      (while newatt
-       (setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
-      (if (string-match ">" tag)
-         (setq tag
-               (replace-match (concat (org-attributes-to-string oldatt) ">")
-                              t t tag)))
-      tag)))
-
-(defun org-format-table-table-html (lines)
-  "Format a table generated by table.el into HTML.
-This conversion does *not* use `table-generate-source' from table.el.
-This has the advantage that Org-mode's HTML conversions can be used.
-But it has the disadvantage, that no cell- or row-spanning is allowed."
-  (let (org-line field-buffer
-                (head org-export-highlight-first-table-line)
-                fields html empty i)
-    (setq html (concat html-table-tag "\n"))
-    (while (setq org-line (pop lines))
-      (setq empty "&nbsp;")
-      (catch 'next-line
-       (if (string-match "^[ \t]*\\+-" org-line)
-           (progn
-             (if field-buffer
-                 (progn
-                   (setq
-                    html
-                    (concat
-                     html
-                     "<tr>"
-                     (mapconcat
-                      (lambda (x)
-                        (if (equal x "") (setq x empty))
-                        (if head
-                            (concat
-                             (format (car org-export-table-header-tags) "col" "")
-                             x
-                             (cdr org-export-table-header-tags))
-                          (concat (format (car org-export-table-data-tags) "") x
-                                  (cdr org-export-table-data-tags))))
-                      field-buffer "\n")
-                     "</tr>\n"))
-                   (setq head nil)
-                   (setq field-buffer nil)))
-             ;; Ignore this line
-             (throw 'next-line t)))
-       ;; Break the line into fields and store the fields
-       (setq fields (org-split-string org-line "[ \t]*|[ \t]*"))
-       (if field-buffer
-           (setq field-buffer (mapcar
-                               (lambda (x)
-                                 (concat x "<br/>" (pop fields)))
-                               field-buffer))
-         (setq field-buffer fields))))
-    (setq html (concat html "</table>\n"))
-    html))
-
-(defun org-format-table-table-html-using-table-generate-source (lines
-                                                               &optional
-                                                               spanned-only)
-  "Format a table into html, using `table-generate-source' from table.el.
-Use SPANNED-ONLY to suppress exporting of simple table.el tables.
-
-When SPANNED-ONLY is nil, all table.el tables are exported.  When
-SPANNED-ONLY is non-nil, only tables with either row or column
-spans are exported.
-
-This routine returns the generated source or nil as appropriate.
-
-Refer docstring of `org-export-prefer-native-exporter-for-tables'
-for further information."
-  (require 'table)
-  (with-current-buffer (get-buffer-create " org-tmp1 ")
-    (erase-buffer)
-    (insert (mapconcat 'identity lines "\n"))
-    (goto-char (point-min))
-    (if (not (re-search-forward "|[^+]" nil t))
-       (error "Error processing table"))
-    (table-recognize-table)
-    (when (or (not spanned-only)
-             (let* ((dim (table-query-dimension))
-                    (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
-               (not (= (* c r) cells))))
-      (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
-      (table-generate-source 'html " org-tmp2 ")
-      (set-buffer " org-tmp2 ")
-      (buffer-substring (point-min) (point-max)))))
-
-(defun org-export-splice-style (style extra)
-  "Splice EXTRA into STYLE, just before \"</style>\"."
-  (if (and (stringp extra)
-          (string-match "\\S-" extra)
-          (string-match "</style>" style))
-      (concat (substring style 0 (match-beginning 0))
-             "\n" extra "\n"
-             (substring style (match-beginning 0)))
-    style))
-
-(defun org-html-handle-time-stamps (s)
-  "Format time stamps in string S, or remove them."
-  (catch 'exit
-    (let (r b)
-      (when org-maybe-keyword-time-regexp
-       (while (string-match org-maybe-keyword-time-regexp s)
-         (or b (setq b (substring s 0 (match-beginning 0))))
-         (setq r (concat
-                  r (substring s 0 (match-beginning 0))
-                  " @<span class=\"timestamp-wrapper\">"
-                  (if (match-end 1)
-                      (format "@<span class=\"timestamp-kwd\">%s @</span>"
-                              (match-string 1 s)))
-                  (format " @<span class=\"timestamp\">%s@</span>"
-                          (substring
-                           (org-translate-time (match-string 3 s)) 1 -1))
-                  "@</span>")
-               s (substring s (match-end 0)))))
-      ;; Line break if line started and ended with time stamp stuff
-      (if (not r)
-         s
-       (setq r (concat r s))
-       (unless (string-match "\\S-" (concat b s))
-         (setq r (concat r "@<br/>")))
-       r))))
-
-(defvar htmlize-buffer-places)  ; from htmlize.el
-(defun org-export-htmlize-region-for-paste (beg end)
-  "Convert the region to HTML, using htmlize.el.
-This is much like `htmlize-region-for-paste', only that it uses
-the settings define in the org-... variables."
-  (let* ((htmlize-output-type org-export-htmlize-output-type)
-        (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
-        (htmlbuf (htmlize-region beg end)))
-    (unwind-protect
-       (with-current-buffer htmlbuf
-         (buffer-substring (plist-get htmlize-buffer-places 'content-start)
-                           (plist-get htmlize-buffer-places 'content-end)))
-      (kill-buffer htmlbuf))))
-
-(defun org-export-htmlize-generate-css ()
-  "Create the CSS for all font definitions in the current Emacs session.
-Use this to create face definitions in your CSS style file that can then
-be used by code snippets transformed by htmlize.
-This command just produces a buffer that contains class definitions for all
-faces used in the current Emacs session.  You can copy and paste the ones you
-need into your CSS file.
-
-If you then set `org-export-htmlize-output-type' to `css', calls to
-the function `org-export-htmlize-region-for-paste' will produce code
-that uses these same face definitions."
-  (interactive)
-  (require 'htmlize)
-  (and (get-buffer "*html*") (kill-buffer "*html*"))
-  (with-temp-buffer
-    (let ((fl (face-list))
-         (htmlize-css-name-prefix "org-")
-         (htmlize-output-type 'css)
-         f i)
-      (while (setq f (pop fl)
-                  i (and f (face-attribute f :inherit)))
-       (when (and (symbolp f) (or (not i) (not (listp i))))
-         (insert (org-add-props (copy-sequence "1") nil 'face f))))
-      (htmlize-region (point-min) (point-max))))
-  (org-pop-to-buffer-same-window "*html*")
-  (goto-char (point-min))
-  (if (re-search-forward "<style" nil t)
-      (delete-region (point-min) (match-beginning 0)))
-  (if (re-search-forward "</style>" nil t)
-      (delete-region (1+ (match-end 0)) (point-max)))
-  (beginning-of-line 1)
-  (if (looking-at " +") (replace-match ""))
-  (goto-char (point-min)))
-
-(defun org-html-protect (s)
-  "Convert characters to HTML equivalent.
-Possible conversions are set in `org-export-html-protect-char-alist'."
-  (let ((cl org-export-html-protect-char-alist) c)
-    (while (setq c (pop cl))
-      (let ((start 0))
-       (while (string-match (car c) s start)
-         (setq s (replace-match (cdr c) t t s)
-               start (1+ (match-beginning 0))))))
-    s))
-
-(defun org-html-expand (string)
-  "Prepare STRING for HTML export.  Apply all active conversions.
-If there are links in the string, don't modify these.  If STRING
-is nil, return nil."
-  (when string
-    (let* ((re (concat org-bracket-link-regexp "\\|"
-                      (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
-          m s l res)
-      (while (setq m (string-match re string))
-       (setq s (substring string 0 m)
-             l (match-string 0 string)
-             string (substring string (match-end 0)))
-       (push (org-html-do-expand s) res)
-       (push l res))
-      (push (org-html-do-expand string) res)
-      (apply 'concat (nreverse res)))))
-
-(defun org-html-do-expand (s)
-  "Apply all active conversions to translate special ASCII to HTML."
-  (setq s (org-html-protect s))
-  (if org-export-html-expand
-      (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
-       (setq s (replace-match "<\\1>" t nil s))))
-  (if org-export-with-emphasize
-      (setq s (org-export-html-convert-emphasize s)))
-  (if org-export-with-special-strings
-      (setq s (org-export-html-convert-special-strings s)))
-  (if org-export-with-sub-superscripts
-      (setq s (org-export-html-convert-sub-super s)))
-  (if org-export-with-TeX-macros
-      (let ((start 0) wd rep)
-       (while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
-                                        s start))
-         (if (get-text-property (match-beginning 0) 'org-protected s)
-             (setq start (match-end 0))
-           (setq wd (match-string 1 s))
-           (if (setq rep (org-entity-get-representation wd 'html))
-               (setq s (replace-match rep t t s))
-             (setq start (+ start (length wd))))))))
-  s)
-
-(defun org-export-html-convert-special-strings (string)
-  "Convert special characters in STRING to HTML."
-  (let ((all org-export-html-special-string-regexps)
-       e a re rpl start)
-    (while (setq a (pop all))
-      (setq re (car a) rpl (cdr a) start 0)
-      (while (string-match re string start)
-       (if (get-text-property (match-beginning 0) 'org-protected string)
-           (setq start (match-end 0))
-         (setq string (replace-match rpl t nil string)))))
-    string))
-
-(defun org-export-html-convert-sub-super (string)
-  "Convert sub- and superscripts in STRING to HTML."
-  (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
-    (while (string-match org-match-substring-regexp string s)
-      (cond
-       ((and requireb (match-end 8)) (setq s (match-end 2)))
-       ((get-text-property  (match-beginning 2) 'org-protected string)
-       (setq s (match-end 2)))
-       (t
-       (setq s (match-end 1)
-             key (if (string= (match-string 2 string) "_") "sub" "sup")
-             c (or (match-string 8 string)
-                   (match-string 6 string)
-                   (match-string 5 string))
-             string (replace-match
-                     (concat (match-string 1 string)
-                             "<" key ">" c "</" key ">")
-                     t t string)))))
-    (while (string-match "\\\\\\([_^]\\)" string)
-      (setq string (replace-match (match-string 1 string) t t string)))
-    string))
-
-(defun org-export-html-convert-emphasize (string)
-  "Apply emphasis."
-  (let ((s 0) rpl)
-    (while (string-match org-emph-re string s)
-      (if (not (equal
-               (substring string (match-beginning 3) (1+ (match-beginning 3)))
-               (substring string (match-beginning 4) (1+ (match-beginning 4)))))
-         (setq s (match-beginning 0)
-               rpl
-               (concat
-                (match-string 1 string)
-                (nth 2 (assoc (match-string 3 string) org-emphasis-alist))
-                (match-string 4 string)
-                (nth 3 (assoc (match-string 3 string)
-                              org-emphasis-alist))
-                (match-string 5 string))
-               string (replace-match rpl t t string)
-               s (+ s (- (length rpl) 2)))
-       (setq s (1+ s))))
-    string))
-
-(defun org-open-par ()
-  "Insert <p>, but first close previous paragraph if any."
-  (org-close-par-maybe)
-  (insert "\n<p>")
-  (setq org-par-open t))
-(defun org-close-par-maybe ()
-  "Close paragraph if there is one open."
-  (when org-par-open
-    (insert "</p>")
-    (setq org-par-open nil)))
-(defun org-close-li (&optional type)
-  "Close <li> if necessary."
-  (org-close-par-maybe)
-  (insert (if (equal type "d") "</dd>\n" "</li>\n")))
-
-(defvar body-only) ; dynamically scoped into this.
-(defun org-html-level-start (level title umax with-toc head-count &optional opt-plist)
-  "Insert a new level in HTML export.
-When TITLE is nil, just close all open levels."
-  (org-close-par-maybe)
-  (let* ((target (and title (org-get-text-property-any 0 'target title)))
-        (extra-targets (and target
-                            (assoc target org-export-target-aliases)))
-        (extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
-        (preferred (and target
-                        (cdr (assoc target org-export-preferred-target-alist))))
-        (l org-level-max)
-        (num (plist-get opt-plist :section-numbers))
-        snumber snu href suffix)
-    (setq extra-targets (remove (or preferred target) extra-targets))
-    (setq extra-targets
-         (mapconcat (lambda (x)
-                      (setq x (org-solidify-link-text
-                               (if (org-uuidgen-p x) (concat "ID-" x) x)))
-                      (if (stringp org-export-html-headline-anchor-format)
-                          (format org-export-html-headline-anchor-format x x)
-                        ""))
-                    extra-targets
-                    ""))
-    (while (>= l level)
-      (if (aref org-levels-open (1- l))
-         (progn
-           (org-html-level-close l umax)
-           (aset org-levels-open (1- l) nil)))
-      (setq l (1- l)))
-    (when title
-      ;; If title is nil, this means this function is called to close
-      ;; all levels, so the rest is done only if title is given
-      (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
-       (setq title (replace-match
-                    (if org-export-with-tags
-                        (save-match-data
-                          (concat
-                           "&nbsp;&nbsp;&nbsp;<span class=\"tag\">"
-                           (mapconcat
-                            (lambda (x)
-                              (format "<span class=\"%s\">%s</span>"
-                                      (org-export-html-get-tag-class-name x)
-                                      x))
-                            (org-split-string (match-string 1 title) ":")
-                            "&nbsp;")
-                           "</span>"))
-                      "")
-                    t t title)))
-      (if (> level umax)
-         (progn
-           (if (aref org-levels-open (1- level))
-               (progn
-                 (org-close-li)
-                 (if target
-                     (insert (format "<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
-                             extra-targets title "<br/>\n")
-                   (insert "<li>" title "<br/>\n")))
-             (aset org-levels-open (1- level) t)
-             (org-close-par-maybe)
-             (if target
-                 (insert (format "<ul>\n<li id=\"%s\">" (org-solidify-link-text (or preferred target)))
-                         extra-targets title "<br/>\n")
-               (insert "<ul>\n<li>" title "<br/>\n"))))
-       (aset org-levels-open (1- level) t)
-       (setq snumber (org-section-number level)
-             snu (replace-regexp-in-string "\\." "-" snumber))
-       (setq level (+ level org-export-html-toplevel-hlevel -1))
-       (if (and num (not body-only))
-           (setq title (concat
-                        (format "<span class=\"section-number-%d\">%s</span>"
-                                level
-                                (if (and num
-                                         (if (integerp num)
-                                             ;; fix up num to take into
-                                             ;; account the top-level
-                                             ;; heading value
-                                             (>= (+ num org-export-html-toplevel-hlevel -1)
-                                                 level)
-                                           num))
-                                    snumber
-                                  ""))
-                        " " title)))
-       (unless (= head-count 1) (insert "\n</div>\n"))
-       (setq href (cdr (assoc (concat "sec-" snu) org-export-preferred-target-alist)))
-       (setq suffix (org-solidify-link-text (or href snu)))
-       (setq href (org-solidify-link-text (or href (concat "sec-" snu))))
-       (insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
-                       suffix level (if extra-class (concat " " extra-class) "")
-                       level href
-                       extra-targets
-                       title level level suffix))
-       (org-open-par)))))
-
-(defun org-export-html-get-tag-class-name (tag)
-  "Turn tag into a valid class name.
-Replaces invalid characters with \"_\" and then prepends a prefix."
-  (save-match-data
-    (while (string-match "[^a-zA-Z0-9_]" tag)
-      (setq tag (replace-match "_" t t tag))))
-  (concat org-export-html-tag-class-prefix tag))
-
-(defun org-export-html-get-todo-kwd-class-name (kwd)
-  "Turn todo keyword into a valid class name.
-Replaces invalid characters with \"_\" and then prepends a prefix."
-  (save-match-data
-    (while (string-match "[^a-zA-Z0-9_]" kwd)
-      (setq kwd (replace-match "_" t t kwd))))
-  (concat org-export-html-todo-kwd-class-prefix kwd))
-
-(defun org-html-level-close (level max-outline-level)
-  "Terminate one level in HTML export."
-  (if (<= level max-outline-level)
-      (insert "</div>\n")
-    (org-close-li)
-    (insert "</ul>\n")))
-
-(defun org-html-export-list-line (org-line pos struct prevs)
-  "Insert list syntax in export buffer.  Return ORG-LINE, maybe modified.
-
-POS is the item position or org-line position the org-line had before
-modifications to buffer.  STRUCT is the list structure.  PREVS is
-the alist of previous items."
-  (let* ((get-type
-         (function
-          ;; Translate type of list containing POS to "d", "o" or
-          ;; "u".
-          (lambda (pos struct prevs)
-            (let ((type (org-list-get-list-type pos struct prevs)))
-              (cond
-               ((eq 'ordered type) "o")
-               ((eq 'descriptive type) "d")
-               (t "u"))))))
-        (get-closings
-         (function
-          ;; Return list of all items and sublists ending at POS, in
-          ;; reverse order.
-          (lambda (pos)
-            (let (out)
-              (catch 'exit
-                (mapc (lambda (e)
-                        (let ((end (nth 6 e))
-                              (item (car e)))
-                          (cond
-                           ((= end pos) (push item out))
-                           ((>= item pos) (throw 'exit nil)))))
-                      struct))
-              out)))))
-    ;; First close any previous item, or list, ending at POS.
-    (mapc (lambda (e)
-           (let* ((lastp (= (org-list-get-last-item e struct prevs) e))
-                  (first-item (org-list-get-list-begin e struct prevs))
-                  (type (funcall get-type first-item struct prevs)))
-             (org-close-par-maybe)
-             ;; Ending for every item
-             (org-close-li type)
-             ;; We're ending last item of the list: end list.
-             (when lastp
-               (insert (format "</%sl>\n" type))
-               (org-open-par))))
-         (funcall get-closings pos))
-    (cond
-     ;; At an item: insert appropriate tags in export buffer.
-     ((assq pos struct)
-      (string-match
-       (concat "[ \t]*\\(\\S-+[ \t]*\\)"
-              "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
-              "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
-              "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
-              "\\(.*\\)") org-line)
-      (let* ((checkbox (match-string 3 org-line))
-            (desc-tag (or (match-string 4 org-line) "???"))
-            (body (or (match-string 5 org-line) ""))
-            (list-beg (org-list-get-list-begin pos struct prevs))
-            (firstp (= list-beg pos))
-            ;; Always refer to first item to determine list type, in
-            ;; case list is ill-formed.
-            (type (funcall get-type list-beg struct prevs))
-            (counter (let ((count-tmp (org-list-get-counter pos struct)))
-                       (cond
-                        ((not count-tmp) nil)
-                        ((string-match "[A-Za-z]" count-tmp)
-                         (- (string-to-char (upcase count-tmp)) 64))
-                        ((string-match "[0-9]+" count-tmp)
-                         count-tmp)))))
-       (when firstp
-         (org-close-par-maybe)
-         (insert (format "<%sl>\n" type)))
-       (insert (cond
-                ((equal type "d")
-                 (format "<dt>%s</dt><dd>" desc-tag))
-                ((and (equal type "o") counter)
-                 (format "<li value=\"%s\">" counter))
-                (t "<li>")))
-       ;; If line had a checkbox, some additional modification is required.
-       (when checkbox
-         (setq body
-               (concat
-                (cond
-                 ((string-match "X" checkbox) "<code>[X]</code> ")
-                 ((string-match " " checkbox) "<code>[&nbsp;]</code> ")
-                 (t "<code>[-]</code> "))
-                body)))
-       ;; Return modified line
-       body))
-     ;; At a list ender: go to next line (side-effects only).
-     ((equal "ORG-LIST-END-MARKER" org-line) (throw 'nextline nil))
-     ;; Not at an item: return line unchanged (side-effects only).
-     (t org-line))))
-
-(provide 'org-html)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-html.el ends here
diff --git a/lisp/org/org-icalendar.el b/lisp/org/org-icalendar.el
deleted file mode 100644 (file)
index 12cd058..0000000
+++ /dev/null
@@ -1,692 +0,0 @@
-;;; org-icalendar.el --- iCalendar export for Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;;; Code:
-
-(require 'org-exp)
-
-(eval-when-compile (require 'cl))
-
-(declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
-
-(defgroup org-export-icalendar nil
-  "Options specific for iCalendar export of Org-mode files."
-  :tag "Org Export iCalendar"
-  :group 'org-export)
-
-(defcustom org-combined-agenda-icalendar-file "~/org.ics"
-  "The file name for the iCalendar file covering all agenda files.
-This file is created with the command \\[org-export-icalendar-all-agenda-files].
-The file name should be absolute, the file will be overwritten without warning."
-  :group 'org-export-icalendar
-  :type 'file)
-
-(defcustom org-icalendar-alarm-time 0
-  "Number of minutes for triggering an alarm for exported timed events.
-A zero value (the default) turns off the definition of an alarm trigger
-for timed events.  If non-zero, alarms are created.
-
-- a single alarm per entry is defined
-- The alarm will go off N minutes before the event
-- only a DISPLAY action is defined."
-  :group 'org-export-icalendar
-  :version "24.1"
-  :type 'integer)
-
-(defcustom org-icalendar-combined-name "OrgMode"
-  "Calendar name for the combined iCalendar representing all agenda files."
-  :group 'org-export-icalendar
-  :type 'string)
-
-(defcustom org-icalendar-combined-description nil
-  "Calendar description for the combined iCalendar (all agenda files)."
-  :group 'org-export-icalendar
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-icalendar-use-plain-timestamp t
-  "Non-nil means make an event from every plain time stamp."
-  :group 'org-export-icalendar
-  :type 'boolean)
-
-(defcustom org-icalendar-honor-noexport-tag nil
-  "Non-nil means don't export entries with a tag in `org-export-exclude-tags'."
-  :group 'org-export-icalendar
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
-  "Contexts where iCalendar export should use a deadline time stamp.
-This is a list with several symbols in it.  Valid symbol are:
-
-event-if-todo       Deadlines in TODO entries become calendar events.
-event-if-not-todo   Deadlines in non-TODO entries become calendar events.
-todo-due            Use deadlines in TODO entries as due-dates"
-  :group 'org-export-icalendar
-  :type '(set :greedy t
-             (const :tag "Deadlines in non-TODO entries become events"
-                    event-if-not-todo)
-             (const :tag "Deadline in TODO entries become events"
-                    event-if-todo)
-             (const :tag "Deadlines in TODO entries become due-dates"
-                    todo-due)))
-
-(defcustom org-icalendar-use-scheduled '(todo-start)
-  "Contexts where iCalendar export should use a scheduling time stamp.
-This is a list with several symbols in it.  Valid symbol are:
-
-event-if-todo       Scheduling time stamps in TODO entries become an event.
-event-if-not-todo   Scheduling time stamps in non-TODO entries become an event.
-todo-start          Scheduling time stamps in TODO entries become start date.
-                    Some calendar applications show TODO entries only after
-                    that date."
-  :group 'org-export-icalendar
-  :type '(set :greedy t
-             (const :tag
-                    "SCHEDULED timestamps in non-TODO entries become events"
-                    event-if-not-todo)
-             (const :tag "SCHEDULED timestamps in TODO entries become events"
-                    event-if-todo)
-             (const :tag "SCHEDULED in TODO entries become start date"
-                    todo-start)))
-
-(defcustom org-icalendar-categories '(local-tags category)
-  "Items that should be entered into the categories field.
-This is a list of symbols, the following are valid:
-
-category    The Org-mode category of the current file or tree
-todo-state  The todo state, if any
-local-tags  The tags, defined in the current line
-all-tags    All tags, including inherited ones."
-  :group 'org-export-icalendar
-  :type '(repeat
-         (choice
-          (const :tag "The file or tree category" category)
-          (const :tag "The TODO state" todo-state)
-          (const :tag "Tags defined in current line" local-tags)
-          (const :tag "All tags, including inherited ones" all-tags))))
-
-(defcustom org-icalendar-include-todo nil
-  "Non-nil means export to iCalendar files should also cover TODO items.
-Valid values are:
-nil         don't include any TODO items
-t           include all TODO items that are not in a DONE state
-unblocked   include all TODO items that are not blocked
-all         include both done and not done items."
-  :group 'org-export-icalendar
-  :type '(choice
-         (const :tag "None" nil)
-         (const :tag "Unfinished" t)
-         (const :tag "Unblocked" unblocked)
-         (const :tag "All" all)))
-
-(defvar org-icalendar-verify-function nil
-  "Function to verify entries for iCalendar export.
-This can be set to a function that will be called at each entry that
-is considered for export to iCalendar.  When the function returns nil,
-the entry will be skipped.  When it returns a non-nil value, the entry
-will be considered for export.
-This is used internally when an agenda buffer is exported to an ics file,
-to make sure that only entries currently listed in the agenda will end
-up in the ics file.  But for normal iCalendar export, you can use this
-for whatever you need.")
-
-(defcustom org-icalendar-include-bbdb-anniversaries nil
-  "Non-nil means a combined iCalendar files should include anniversaries.
-The anniversaries are define in the BBDB database."
-  :group 'org-export-icalendar
-  :type 'boolean)
-
-(defcustom org-icalendar-include-sexps t
-  "Non-nil means export to iCalendar files should also cover sexp entries.
-These are entries like in the diary, but directly in an Org-mode file."
-  :group 'org-export-icalendar
-  :type 'boolean)
-
-(defcustom org-icalendar-include-body 100
-  "Amount of text below headline to be included in iCalendar export.
-This is a number of characters that should maximally be included.
-Properties, scheduling and clocking lines will always be removed.
-The text will be inserted into the DESCRIPTION field."
-  :group 'org-export-icalendar
-  :type '(choice
-         (const :tag "Nothing" nil)
-         (const :tag "Everything" t)
-         (integer :tag "Max characters")))
-
-(defcustom org-icalendar-store-UID nil
-  "Non-nil means store any created UIDs in properties.
-The iCalendar standard requires that all entries have a unique identifier.
-Org will create these identifiers as needed.  When this variable is non-nil,
-the created UIDs will be stored in the ID property of the entry.  Then the
-next time this entry is exported, it will be exported with the same UID,
-superseding the previous form of it.  This is essential for
-synchronization services.
-This variable is not turned on by default because we want to avoid creating
-a property drawer in every entry if people are only playing with this feature,
-or if they are only using it locally."
-  :group 'org-export-icalendar
-  :type 'boolean)
-
-(defcustom org-icalendar-timezone (getenv "TZ")
-  "The time zone string for iCalendar export.
-When nil or the empty string, use output from \(current-time-zone\)."
-  :group 'org-export-icalendar
-  :type '(choice
-         (const :tag "Unspecified" nil)
-         (string :tag "Time zone")))
-
-;; Backward compatibility with previous variable
-(defvar org-icalendar-use-UTC-date-time nil)
-(defcustom org-icalendar-date-time-format
-  (if org-icalendar-use-UTC-date-time
-      ":%Y%m%dT%H%M%SZ"
-    ":%Y%m%dT%H%M%S")
-  "Format-string for exporting icalendar DATE-TIME.
-See `format-time-string' for a full documentation.  The only
-difference is that `org-icalendar-timezone' is used for %Z.
-
-Interesting value are:
- - \":%Y%m%dT%H%M%S\" for local time
- - \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone
- - \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time"
-
-  :group 'org-export-icalendar
-  :version "24.1"
-  :type '(choice
-         (const :tag "Local time" ":%Y%m%dT%H%M%S")
-         (const :tag "Explicit local time" ";TZID=%Z:%Y%m%dT%H%M%S")
-         (const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
-         (string :tag "Explicit format")))
-
-(defun org-icalendar-use-UTC-date-timep ()
-  (char-equal (elt org-icalendar-date-time-format
-                  (1- (length org-icalendar-date-time-format))) ?Z))
-
-;;; iCalendar export
-
-;;;###autoload
-(defun org-export-icalendar-this-file ()
-  "Export current file as an iCalendar file.
-The iCalendar file will be located in the same directory as the Org-mode
-file, but with extension `.ics'."
-  (interactive)
-  (org-export-icalendar nil buffer-file-name))
-
-;;;###autoload
-(defun org-export-icalendar-all-agenda-files ()
-  "Export all files in the variable `org-agenda-files' to iCalendar .ics files.
-Each iCalendar file will be located in the same directory as the Org-mode
-file, but with extension `.ics'."
-  (interactive)
-  (apply 'org-export-icalendar nil (org-agenda-files t)))
-
-;;;###autoload
-(defun org-export-icalendar-combine-agenda-files ()
-  "Export all files in `org-agenda-files' to a single combined iCalendar file.
-The file is stored under the name `org-combined-agenda-icalendar-file'."
-  (interactive)
-  (apply 'org-export-icalendar t (org-agenda-files t)))
-
-(defun org-export-icalendar (combine &rest files)
-  "Create iCalendar files for all elements of FILES.
-If COMBINE is non-nil, combine all calendar entries into a single large
-file and store it under the name `org-combined-agenda-icalendar-file'."
-  (save-excursion
-    (org-agenda-prepare-buffers files)
-    (let* ((dir (org-export-directory
-                :ical (list :publishing-directory
-                            org-export-publishing-directory)))
-          file ical-file ical-buffer category started org-agenda-new-buffers)
-      (and (get-buffer "*ical-tmp*") (kill-buffer "*ical-tmp*"))
-      (when combine
-       (setq ical-file
-             (if (file-name-absolute-p org-combined-agenda-icalendar-file)
-                 org-combined-agenda-icalendar-file
-               (expand-file-name org-combined-agenda-icalendar-file dir))
-             ical-buffer (org-get-agenda-file-buffer ical-file))
-       (set-buffer ical-buffer) (erase-buffer))
-      (while (setq file (pop files))
-       (catch 'nextfile
-         (org-check-agenda-file file)
-         (set-buffer (org-get-agenda-file-buffer file))
-         (unless combine
-           (setq ical-file (concat (file-name-as-directory dir)
-                                   (file-name-sans-extension
-                                    (file-name-nondirectory buffer-file-name))
-                                   ".ics"))
-           (setq ical-buffer (org-get-agenda-file-buffer ical-file))
-           (with-current-buffer ical-buffer (erase-buffer)))
-         (setq category (or org-category
-                            (file-name-sans-extension
-                             (file-name-nondirectory buffer-file-name))))
-         (if (symbolp category) (setq category (symbol-name category)))
-         (let ((standard-output ical-buffer))
-           (if combine
-               (and (not started) (setq started t)
-                    (org-icalendar-start-file org-icalendar-combined-name))
-             (org-icalendar-start-file category))
-           (org-icalendar-print-entries combine)
-           (when (or (and combine (not files)) (not combine))
-             (when (and combine org-icalendar-include-bbdb-anniversaries)
-               (require 'org-bbdb)
-               (org-bbdb-anniv-export-ical))
-             (org-icalendar-finish-file)
-             (set-buffer ical-buffer)
-             (run-hooks 'org-before-save-iCalendar-file-hook)
-             (save-buffer)
-             (run-hooks 'org-after-save-iCalendar-file-hook)
-             (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))))
-      (org-release-buffers org-agenda-new-buffers))))
-
-(defvar org-before-save-iCalendar-file-hook nil
-  "Hook run before  an iCalendar file has been saved.
-This can be used to modify the result of the export.")
-
-(defvar org-after-save-iCalendar-file-hook nil
-  "Hook run after an iCalendar file has been saved.
-The iCalendar buffer is still current when this hook is run.
-A good way to use this is to tell a desktop calendar application to re-read
-the iCalendar file.")
-
-(defvar org-agenda-default-appointment-duration) ; defined in org-agenda.el
-(defun org-icalendar-print-entries (&optional combine)
-  "Print iCalendar entries for the current Org-mode file to `standard-output'.
-When COMBINE is non nil, add the category to each line."
-  (require 'org-agenda)
-  (let ((re1 (concat org-ts-regexp "\\|<%%([^>\n]+>"))
-       (re2 (concat "--?-?\\(" org-ts-regexp "\\)"))
-       (dts (org-icalendar-ts-to-string
-             (format-time-string (cdr org-time-stamp-formats) (current-time))
-             "DTSTART"))
-       hd ts ts2 state status (inc t) pos b sexp rrule
-       scheduledp deadlinep todo prefix due start tags
-       tmp pri categories location summary desc uid alarm alarm-time
-       (sexp-buffer (get-buffer-create "*ical-tmp*")))
-    (org-refresh-category-properties)
-    (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
-    (save-excursion
-      (goto-char (point-min))
-      (while (re-search-forward re1 nil t)
-       (catch :skip
-         (org-agenda-skip)
-         (when org-icalendar-verify-function
-           (unless (save-match-data (funcall org-icalendar-verify-function))
-             (outline-next-heading)
-             (backward-char 1)
-             (throw :skip nil)))
-         (setq pos (match-beginning 0)
-               ts (match-string 0)
-               tags (org-get-tags-at)
-               inc t
-               hd (condition-case nil
-                      (org-icalendar-cleanup-string
-                       (org-get-heading t))
-                    (error (throw :skip nil)))
-               summary (org-icalendar-cleanup-string
-                        (org-entry-get nil "SUMMARY"))
-               desc (org-icalendar-cleanup-string
-                     (or (org-entry-get nil "DESCRIPTION")
-                         (and org-icalendar-include-body (org-get-entry)))
-                     t org-icalendar-include-body)
-               location (org-icalendar-cleanup-string
-                         (org-entry-get nil "LOCATION" 'selective))
-               uid (if org-icalendar-store-UID
-                       (org-id-get-create)
-                     (or (org-id-get) (org-id-new)))
-               categories (org-export-get-categories)
-               alarm-time (get-text-property (point) 'org-appt-warntime)
-               alarm-time (if alarm-time (string-to-number alarm-time) 0)
-               alarm ""
-               deadlinep nil scheduledp nil)
-         (setq tmp (buffer-substring (max (point-min) (- pos org-ds-keyword-length)) pos)
-               deadlinep (string-match org-deadline-regexp tmp)
-               scheduledp (string-match org-scheduled-regexp tmp)
-               todo (org-get-todo-state))
-         ;; donep (org-entry-is-done-p)
-         (if (looking-at re2)
-             (progn
-               (goto-char (match-end 0))
-               (setq ts2 (match-string 1)
-                     inc (not (string-match "[0-9]\\{1,2\\}:[0-9][0-9]" ts2))))
-           (setq ts2 (if (string-match "[0-9]\\{1,2\\}:[0-9][0-9]-\\([0-9]\\{1,2\\}:[0-9][0-9]\\)" ts)
-                         (progn
-                           (setq inc nil)
-                           (replace-match "\\1" t nil ts))
-                       ts)))
-         (when (and (not org-icalendar-use-plain-timestamp)
-                    (not deadlinep) (not scheduledp))
-           (throw :skip t))
-         ;; don't export entries with a :noexport: tag
-         (when (and org-icalendar-honor-noexport-tag
-                    (delq nil (mapcar (lambda(x)
-                                        (member x org-export-exclude-tags)) tags)))
-           (throw :skip t))
-         (when (and
-                deadlinep
-                (if todo
-                    (not (memq 'event-if-todo org-icalendar-use-deadline))
-                  (not (memq 'event-if-not-todo org-icalendar-use-deadline))))
-           (throw :skip t))
-         (when (and
-                scheduledp
-                (if todo
-                    (not (memq 'event-if-todo org-icalendar-use-scheduled))
-                  (not (memq 'event-if-not-todo org-icalendar-use-scheduled))))
-           (throw :skip t))
-         (setq prefix (if deadlinep "DL-" (if scheduledp "SC-" "TS-")))
-         (if (or (string-match org-tr-regexp hd)
-                 (string-match org-ts-regexp hd))
-             (setq hd (replace-match "" t t hd)))
-         (if (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)>" ts)
-             (setq rrule
-                   (concat "\nRRULE:FREQ="
-                           (cdr (assoc
-                                 (match-string 2 ts)
-                                 '(("h" . "HOURLY")("d" . "DAILY")("w" . "WEEKLY")
-                                   ("m" . "MONTHLY")("y" . "YEARLY"))))
-                           ";INTERVAL=" (match-string 1 ts)))
-           (setq rrule ""))
-         (setq summary (or summary hd))
-         ;; create an alarm entry if the entry is timed.  this is not very general in that:
-         ;; (a) only one alarm per entry is defined,
-         ;; (b) only minutes are allowed for the trigger period ahead of the start time, and
-         ;; (c) only a DISPLAY action is defined.
-         ;; [ESF]
-         (let ((t1 (ignore-errors (org-parse-time-string ts 'nodefault))))
-           (if (and (or (> alarm-time 0) (> org-icalendar-alarm-time 0))
-                    (car t1) (nth 1 t1) (nth 2 t1))
-               (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0DT0H%dM0S\nEND:VALARM"
-                                   summary (or alarm-time org-icalendar-alarm-time)))
-             (setq alarm "")))
-         (if (string-match org-bracket-link-regexp summary)
-             (setq summary
-                   (replace-match (if (match-end 3)
-                                      (match-string 3 summary)
-                                    (match-string 1 summary))
-                                  t t summary)))
-         (if deadlinep (setq summary (concat "DL: " summary)))
-         (if scheduledp (setq summary (concat "S: " summary)))
-         (if (string-match "\\`<%%" ts)
-             (with-current-buffer sexp-buffer
-               (let ((entry (substring ts 1 -1)))
-                 (put-text-property 0 1 'uid
-                                    (concat " " prefix uid) entry)
-                 (insert entry " " summary "\n")))
-           (princ (format "BEGIN:VEVENT
-UID: %s
-%s
-%s%s
-SUMMARY:%s%s%s
-CATEGORIES:%s%s
-END:VEVENT\n"
-                          (concat prefix uid)
-                          (org-icalendar-ts-to-string ts "DTSTART")
-                          (org-icalendar-ts-to-string ts2 "DTEND" inc)
-                          rrule summary
-                          (if (and desc (string-match "\\S-" desc))
-                              (concat "\nDESCRIPTION: " desc) "")
-                          (if (and location (string-match "\\S-" location))
-                              (concat "\nLOCATION: " location) "")
-                          categories
-                          alarm)))))
-      (when (and org-icalendar-include-sexps
-                (condition-case nil (require 'icalendar) (error nil))
-                (fboundp 'icalendar-export-region))
-       ;; Get all the literal sexps
-       (goto-char (point-min))
-       (while (re-search-forward "^&?%%(" nil t)
-         (catch :skip
-           (org-agenda-skip)
-           (when org-icalendar-verify-function
-             (unless (save-match-data (funcall org-icalendar-verify-function))
-               (outline-next-heading)
-               (backward-char 1)
-               (throw :skip nil)))
-           (setq b (match-beginning 0))
-           (goto-char (1- (match-end 0)))
-           (forward-sexp 1)
-           (end-of-line 1)
-           (setq sexp (buffer-substring b (point)))
-           (with-current-buffer sexp-buffer
-             (insert sexp "\n"))))
-       (princ (org-diary-to-ical-string sexp-buffer))
-       (kill-buffer sexp-buffer))
-
-      (when org-icalendar-include-todo
-       (setq prefix "TODO-")
-       (goto-char (point-min))
-       (while (re-search-forward org-complex-heading-regexp nil t)
-         (catch :skip
-           (org-agenda-skip)
-           (when org-icalendar-verify-function
-             (unless (save-match-data
-                       (funcall org-icalendar-verify-function))
-               (outline-next-heading)
-               (backward-char 1)
-               (throw :skip nil)))
-           (setq state (match-string 2))
-           (setq status (if (member state org-done-keywords)
-                            "COMPLETED" "NEEDS-ACTION"))
-           (when (and state
-                      (cond
-                       ;; check if the state is one we should use
-                       ((eq org-icalendar-include-todo 'all)
-                        ;; all should be included
-                        t)
-                       ((eq org-icalendar-include-todo 'unblocked)
-                        ;; only undone entries that are not blocked
-                        (and (member state org-not-done-keywords)
-                             (or (not org-blocker-hook)
-                                 (save-match-data
-                                   (run-hook-with-args-until-failure
-                                    'org-blocker-hook
-                                    (list :type 'todo-state-change
-                                          :position (point-at-bol)
-                                          :from 'todo
-                                          :to 'done))))))
-                       ((eq org-icalendar-include-todo t)
-                        ;; include everything that is not done
-                        (member state org-not-done-keywords))))
-             (setq hd (match-string 4)
-                   summary (org-icalendar-cleanup-string
-                            (org-entry-get nil "SUMMARY"))
-                   desc (org-icalendar-cleanup-string
-                         (or (org-entry-get nil "DESCRIPTION")
-                             (and org-icalendar-include-body (org-get-entry)))
-                         t org-icalendar-include-body)
-                   location (org-icalendar-cleanup-string
-                             (org-entry-get nil "LOCATION" 'selective))
-                   due (and (member 'todo-due org-icalendar-use-deadline)
-                            (org-entry-get nil "DEADLINE"))
-                   start (and (member 'todo-start org-icalendar-use-scheduled)
-                              (org-entry-get nil "SCHEDULED"))
-                   categories (org-export-get-categories)
-                   uid (if org-icalendar-store-UID
-                           (org-id-get-create)
-                         (or (org-id-get) (org-id-new))))
-             (and due (setq due (org-icalendar-ts-to-string due "DUE")))
-             (and start (setq start (org-icalendar-ts-to-string start "DTSTART")))
-
-             (if (string-match org-bracket-link-regexp hd)
-                 (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
-                                           (match-string 1 hd))
-                                         t t hd)))
-             (if (string-match org-priority-regexp hd)
-                 (setq pri (string-to-char (match-string 2 hd))
-                       hd (concat (substring hd 0 (match-beginning 1))
-                                  (substring hd (match-end 1))))
-               (setq pri org-default-priority))
-             (setq pri (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
-                                            (- org-lowest-priority org-highest-priority))))))
-
-             (princ (format "BEGIN:VTODO
-UID: %s
-%s
-SUMMARY:%s%s%s%s
-CATEGORIES:%s
-SEQUENCE:1
-PRIORITY:%d
-STATUS:%s
-END:VTODO\n"
-                            (concat prefix uid)
-                            (or start dts)
-                            (or summary hd)
-                            (if (and location (string-match "\\S-" location))
-                                (concat "\nLOCATION: " location) "")
-                            (if (and desc (string-match "\\S-" desc))
-                                (concat "\nDESCRIPTION: " desc) "")
-                            (if due (concat "\n" due) "")
-                            categories
-                            pri status)))))))))
-
-(defun org-export-get-categories ()
-  "Get categories according to `org-icalendar-categories'."
-  (let ((cs org-icalendar-categories) c rtn tmp)
-    (while (setq c (pop cs))
-      (cond
-       ((eq c 'category) (push (org-get-category) rtn))
-       ((eq c 'todo-state)
-       (setq tmp (org-get-todo-state))
-       (and tmp (push tmp rtn)))
-       ((eq c 'local-tags)
-       (setq rtn (append (nreverse (org-get-local-tags-at (point))) rtn)))
-       ((eq c 'all-tags)
-       (setq rtn (append (nreverse (org-get-tags-at (point))) rtn)))))
-    (mapconcat 'identity (nreverse rtn) ",")))
-
-(defun org-icalendar-cleanup-string (s &optional is-body maxlength)
-  "Take out stuff and quote what needs to be quoted.
-When IS-BODY is non-nil, assume that this is the body of an item, clean up
-whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
-characters."
-  (if (not s)
-      nil
-    (if is-body
-       (let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
-             (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
-         (while (string-match re s) (setq s (replace-match "" t t s)))
-         (while (string-match re2 s) (setq s (replace-match "" t t s))))
-      (setq s (replace-regexp-in-string "[[:space:]]+" " " s)))
-    (let ((start 0))
-      (while (string-match "\\([,;]\\)" s start)
-       (setq start (+ (match-beginning 0) 2)
-             s (replace-match "\\\\\\1" nil nil s))))
-    (setq s (org-trim s))
-    (when is-body
-      (while (string-match "[ \t]*\n[ \t]*" s)
-       (setq s (replace-match "\\n" t t s))))
-    (if is-body
-       (if maxlength
-           (if (and (numberp maxlength)
-                    (> (length s) maxlength))
-               (setq s (substring s 0 maxlength)))))
-    s))
-
-(defun org-icalendar-cleanup-string-rfc2455 (s &optional is-body maxlength)
-  "Take out stuff and quote what needs to be quoted.
-When IS-BODY is non-nil, assume that this is the body of an item, clean up
-whitespace, newlines, drawers, and timestamps, and cut it down to MAXLENGTH
-characters.
-This seems to be more like RFC 2455, but it causes problems, so it is
-not used right now."
-  (if (not s)
-      nil
-    (if is-body
-       (let ((re (concat "\\(" org-drawer-regexp "\\)[^\000]*?:END:.*\n?"))
-             (re2 (concat "^[ \t]*" org-keyword-time-regexp ".*\n?")))
-         (while (string-match re s) (setq s (replace-match "" t t s)))
-         (while (string-match re2 s) (setq s (replace-match "" t t s)))
-         (setq s (org-trim s))
-         (while (string-match "[ \t]*\n[ \t]*" s)
-           (setq s (replace-match "\\n" t t s)))
-         (if maxlength
-             (if (and (numberp maxlength)
-                      (> (length s) maxlength))
-                 (setq s (substring s 0 maxlength)))))
-      (setq s (org-trim s)))
-    (while (string-match "\"" s) (setq s (replace-match "''" t t s)))
-    (when (string-match "[;,:]" s) (setq s (concat "\"" s "\"")))
-    s))
-
-(defun org-icalendar-start-file (name)
-  "Start an iCalendar file by inserting the header."
-  (let ((user user-full-name)
-       (name (or name "unknown"))
-       (timezone (if (> (length org-icalendar-timezone) 0)
-                     org-icalendar-timezone
-                   (cadr (current-time-zone))))
-       (description org-icalendar-combined-description))
-    (princ
-     (format "BEGIN:VCALENDAR
-VERSION:2.0
-X-WR-CALNAME:%s
-PRODID:-//%s//Emacs with Org-mode//EN
-X-WR-TIMEZONE:%s
-X-WR-CALDESC:%s
-CALSCALE:GREGORIAN\n" name user timezone description))))
-
-(defun org-icalendar-finish-file ()
-  "Finish an iCalendar file by inserting the END statement."
-  (princ "END:VCALENDAR\n"))
-
-(defun org-icalendar-ts-to-string (s keyword &optional inc)
-  "Take a time string S and convert it to iCalendar format.
-KEYWORD is added in front, to make a complete line like DTSTART....
-When INC is non-nil, increase the hour by two (if time string contains
-a time), or the day by one (if it does not contain a time)."
-  (let ((t1 (ignore-errors (org-parse-time-string s 'nodefault)))
-       t2 fmt have-time time)
-    (if (not t1)
-       ""
-      (if (and (car t1) (nth 1 t1) (nth 2 t1))
-         (setq t2 t1 have-time t)
-       (setq t2 (org-parse-time-string s)))
-      (let ((s (car t2))   (mi (nth 1 t2)) (h (nth 2 t2))
-           (d (nth 3 t2)) (m  (nth 4 t2)) (y (nth 5 t2)))
-       (when inc
-         (if have-time
-             (if org-agenda-default-appointment-duration
-                 (setq mi (+ org-agenda-default-appointment-duration mi))
-               (setq h (+ 2 h)))
-           (setq d (1+ d))))
-       (setq time (encode-time s mi h d m y)))
-      (setq fmt (if have-time
-                   (replace-regexp-in-string "%Z"
-                                             org-icalendar-timezone
-                                             org-icalendar-date-time-format t)
-                 ";VALUE=DATE:%Y%m%d"))
-      (concat keyword (format-time-string fmt time
-                                         (and (org-icalendar-use-UTC-date-timep)
-                                              have-time))))))
-
-(provide 'org-icalendar)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-icalendar.el ends here
index ecf67f72f3acf986dd054c796441528bd11332c2..f1fa05bdc70aab76ad3c2ed73f6add04a1358808 100644 (file)
@@ -186,7 +186,7 @@ the link."
   :type 'boolean)
 
 (defcustom org-id-locations-file (convert-standard-filename
-                                 "~/.emacs.d/.org-id-locations")
+                                 (concat user-emacs-directory ".org-id-locations"))
   "The file for remembering in which file an ID was defined.
 This variable is only relevant when `org-id-track-globally' is set."
   :group 'org-id
@@ -343,7 +343,7 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
       (unless (org-uuidgen-p unique)
        (setq unique (org-id-uuid))))
      ((eq org-id-method 'org)
-      (let* ((etime (org-id-reverse-string (org-id-time-to-b36)))
+      (let* ((etime (org-reverse-string (org-id-time-to-b36)))
             (postfix (if org-id-include-domain
                          (progn
                            (require 'message)
@@ -376,9 +376,6 @@ So a typical ID could look like \"Org:4nd91V40HI\"."
            (substring rnd 18 20)
            (substring rnd 20 32))))
 
-(defun org-id-reverse-string (s)
-  (mapconcat 'char-to-string (nreverse (string-to-list s)) ""))
-
 (defun org-id-int-to-b36-one-digit (i)
   "Turn an integer between 0 and 61 into a single character 0..9, A..Z, a..z."
   (cond
@@ -432,7 +429,7 @@ and time is the usual three-integer representation of time."
     (if (= 2 (length parts))
        (setq prefix (car parts) time (nth 1 parts))
       (setq prefix nil time (nth 0 parts)))
-    (setq time (org-id-reverse-string time))
+    (setq time (org-reverse-string time))
     (setq time (list (org-id-b36-to-int (substring time 0 4))
                     (org-id-b36-to-int (substring time 4 8))
                     (org-id-b36-to-int (substring time 8 12))))
@@ -440,6 +437,7 @@ and time is the usual three-integer representation of time."
 
 ;; Storing ID locations (files)
 
+;;;###autoload
 (defun org-id-update-id-locations (&optional files silent)
   "Scan relevant files for IDs.
 Store the relation between files and corresponding IDs.
@@ -530,7 +528,9 @@ When CHECK is given, prepare detailed information about duplicate IDs."
                   (org-id-hash-to-alist org-id-locations)
                 org-id-locations)))
       (with-temp-file org-id-locations-file
-       (print out (current-buffer))))))
+       (let ((print-level nil)
+             (print-length nil))
+         (print out (current-buffer)))))))
 
 (defun org-id-locations-load ()
   "Read the data from `org-id-locations-file'."
index 9719a1fa035a1c0fd0e166e46d1f1a599d5026f5..44311e388270e1b993e377b2c140d654cfe2ef29 100644 (file)
@@ -88,7 +88,7 @@ This is used locally in each buffer being initialized.")
 (defvar org-hide-leading-stars-before-indent-mode nil
   "Used locally.")
 (defvar org-indent-modified-headline-flag nil
-  "Non-nil means the last deletion operated on an headline.
+  "Non-nil means the last deletion operated on a headline.
 It is modified by `org-indent-notify-modified-headline'.")
 
 
@@ -147,8 +147,8 @@ useful to make it ever so slightly different."
 
 (defsubst org-indent-remove-properties (beg end)
   "Remove indentations between BEG and END."
-  (with-silent-modifications
-    (remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
+  (org-with-silent-modifications
+   (remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))
 
 ;;;###autoload
 (define-minor-mode org-indent-mode
@@ -182,11 +182,11 @@ during idle time."
       (org-set-local 'org-hide-leading-stars-before-indent-mode
                     org-hide-leading-stars)
       (org-set-local 'org-hide-leading-stars t))
-    (add-hook 'filter-buffer-substring-functions
-             (lambda (fun start end delete)
-               (org-indent-remove-properties-from-string
-                (funcall fun start end delete)))
-              nil t)
+    (org-add-hook 'filter-buffer-substring-functions
+                 (lambda (fun start end delete)
+                   (org-indent-remove-properties-from-string
+                    (funcall fun start end delete)))
+                 nil t)
     (org-add-hook 'after-change-functions 'org-indent-refresh-maybe nil 'local)
     (org-add-hook 'before-change-functions
                  'org-indent-notify-modified-headline nil 'local)
@@ -213,8 +213,7 @@ during idle time."
     (remove-hook 'filter-buffer-substring-functions
                 (lambda (fun start end delete)
                   (org-indent-remove-properties-from-string
-                   (funcall fun start end delete)))
-                 t)
+                   (funcall fun start end delete))))
     (remove-hook 'after-change-functions 'org-indent-refresh-maybe 'local)
     (remove-hook 'before-change-functions
                 'org-indent-notify-modified-headline 'local)
@@ -343,50 +342,50 @@ stopped."
        ;; 2. For each line, set `line-prefix' and `wrap-prefix'
        ;;    properties depending on the type of line (headline,
        ;;    inline task, item or other).
-       (with-silent-modifications
-        (while (and (<= (point) end) (not (eobp)))
-          (cond
-           ;; When in asynchronous mode, check if interrupt is
-           ;; required.
-           ((and delay (input-pending-p)) (throw 'interrupt (point)))
-           ;; In asynchronous mode, take a break of
-           ;; `org-indent-agent-resume-delay' every DELAY to avoid
-           ;; blocking any other idle timer or process output.
-           ((and delay (time-less-p time-limit (current-time)))
-            (setq org-indent-agent-resume-timer
-                  (run-with-idle-timer
-                   (time-add (current-idle-time)
-                             org-indent-agent-resume-delay)
-                   nil #'org-indent-initialize-agent))
-            (throw 'interrupt (point)))
-           ;; Headline or inline task.
-           ((looking-at org-outline-regexp)
-            (let* ((nstars (- (match-end 0) (match-beginning 0) 1))
-                   (line (* added-ind-per-lvl (1- nstars)))
-                   (wrap (+ line (1+ nstars))))
-              (cond
-               ;; Headline: new value for PF.
-               ((looking-at limited-re)
-                (org-indent-set-line-properties line wrap t)
-                (setq pf wrap))
-               ;; End of inline task: PF-INLINE is now nil.
-               ((looking-at "\\*+ end[ \t]*$")
-                (org-indent-set-line-properties line wrap 'inline)
-                (setq pf-inline nil))
-               ;; Start of inline task.  Determine if it contains
-               ;; text, or if it is only one line long.  Set
-               ;; PF-INLINE accordingly.
-               (t (org-indent-set-line-properties line wrap 'inline)
-                  (setq pf-inline (and (org-inlinetask-in-task-p) wrap))))))
-           ;; List item: `wrap-prefix' is set where body starts.
-           ((org-at-item-p)
-            (let* ((line (or pf-inline pf 0))
-                   (wrap (+ (org-list-item-body-column (point)) line)))
-              (org-indent-set-line-properties line wrap nil)))
-           ;; Normal line: use PF-INLINE, PF or nil as prefixes.
-           (t (let* ((line (or pf-inline pf 0))
-                     (wrap (+ line (org-get-indentation))))
-                (org-indent-set-line-properties line wrap nil))))))))))
+       (org-with-silent-modifications
+       (while (and (<= (point) end) (not (eobp)))
+         (cond
+          ;; When in asynchronous mode, check if interrupt is
+          ;; required.
+          ((and delay (input-pending-p)) (throw 'interrupt (point)))
+          ;; In asynchronous mode, take a break of
+          ;; `org-indent-agent-resume-delay' every DELAY to avoid
+          ;; blocking any other idle timer or process output.
+          ((and delay (time-less-p time-limit (current-time)))
+           (setq org-indent-agent-resume-timer
+                 (run-with-idle-timer
+                  (time-add (current-idle-time)
+                            org-indent-agent-resume-delay)
+                  nil #'org-indent-initialize-agent))
+           (throw 'interrupt (point)))
+          ;; Headline or inline task.
+          ((looking-at org-outline-regexp)
+           (let* ((nstars (- (match-end 0) (match-beginning 0) 1))
+                  (line (* added-ind-per-lvl (1- nstars)))
+                  (wrap (+ line (1+ nstars))))
+             (cond
+              ;; Headline: new value for PF.
+              ((looking-at limited-re)
+               (org-indent-set-line-properties line wrap t)
+               (setq pf wrap))
+              ;; End of inline task: PF-INLINE is now nil.
+              ((looking-at "\\*+ end[ \t]*$")
+               (org-indent-set-line-properties line wrap 'inline)
+               (setq pf-inline nil))
+              ;; Start of inline task.  Determine if it contains
+              ;; text, or if it is only one line long.  Set
+              ;; PF-INLINE accordingly.
+              (t (org-indent-set-line-properties line wrap 'inline)
+                 (setq pf-inline (and (org-inlinetask-in-task-p) wrap))))))
+          ;; List item: `wrap-prefix' is set where body starts.
+          ((org-at-item-p)
+           (let* ((line (or pf-inline pf 0))
+                  (wrap (+ (org-list-item-body-column (point)) line)))
+             (org-indent-set-line-properties line wrap nil)))
+          ;; Normal line: use PF-INLINE, PF or nil as prefixes.
+          (t (let* ((line (or pf-inline pf 0))
+                    (wrap (+ line (org-get-indentation))))
+               (org-indent-set-line-properties line wrap nil))))))))))
 
 (defun org-indent-notify-modified-headline (beg end)
   "Set `org-indent-modified-headline-flag' depending on context.
@@ -413,7 +412,7 @@ range of inserted text.  DUMMY is an unused argument.
 This function is meant to be called by `after-change-functions'."
   (when org-indent-mode
     (save-match-data
-      ;; If an headline was modified or inserted, set properties until
+      ;; If a headline was modified or inserted, set properties until
       ;; next headline.
       (if (or org-indent-modified-headline-flag
              (save-excursion
index 43913acacdea02879a6cf1bf99be0675425213e4..ca7572bcc374449ab6cefe564163cfd5a4424149 100644 (file)
 ;;; Commentary:
 ;;
 ;; This module implements inline tasks in Org-mode.  Inline tasks are
-;; tasks that have all the properties of normal outline nodes, including
-;; the ability to store meta data like scheduling dates, TODO state, tags
-;; and properties.  However, these nodes are treated specially by the
-;; visibility cycling and export commands.
+;; tasks that have all the properties of normal outline nodes,
+;; including the ability to store meta data like scheduling dates,
+;; TODO state, tags and properties.  However, these nodes are treated
+;; specially by the visibility cycling.
 ;;
-;; Visibility cycling exempts these nodes from cycling.  So whenever their
-;; parent is opened, so are these tasks.  This will only work with
-;; `org-cycle', so if you are also using other commands to show/hide
-;; entries, you will occasionally find these tasks to behave like
-;; all other outline nodes, seemingly splitting the text of the parent
-;; into children.
+;; Visibility cycling exempts these nodes from cycling.  So whenever
+;; their parent is opened, so are these tasks.  This will only work
+;; with `org-cycle', so if you are also using other commands to
+;; show/hide entries, you will occasionally find these tasks to behave
+;; like all other outline nodes, seemingly splitting the text of the
+;; parent into children.
 ;;
-;; Export commands do not treat these nodes as part of the sectioning
-;; structure, but as a special inline text that is either removed, or
-;; formatted in some special way.  This in handled by
-;; `org-inlinetask-export' and `org-inlinetask-export-templates'
-;; variables.
+;; Special fontification of inline tasks, so that they can be
+;; immediately recognized.  From the stars of the headline, only the
+;; first and the last two will be visible, the others will be hidden
+;; using the `org-hide' face.
 ;;
-;; Special fontification of inline tasks, so that they can be immediately
-;; recognized.  From the stars of the headline, only the first and the
-;; last two will be visible, the others will be hidden using the
-;; `org-hide' face.
-;;
-;; An inline task is identified solely by a minimum outline level, given
-;; by the variable `org-inlinetask-min-level', default 15.
+;; An inline task is identified solely by a minimum outline level,
+;; given by the variable `org-inlinetask-min-level', default 15.
 ;;
 ;; If you need to have a time planning line (DEADLINE etc), drawers,
 ;; for example LOGBOOK of PROPERTIES, or even normal text as part of
@@ -111,69 +105,6 @@ When nil, the first star is not shown."
   :tag "Org Inline Tasks"
   :group 'org-structure)
 
-(defcustom org-inlinetask-export t
-  "Non-nil means export inline tasks.
-When nil, they will not be exported."
-  :group 'org-inlinetask
-  :type 'boolean)
-
-(defvar org-inlinetask-export-templates
-  '((html "<div class=\"inlinetask\"><b>%s%s</b><br />%s</div>"
-         '((unless (eq todo "")
-             (format "<span class=\"%s %s\">%s%s</span> "
-                     class todo todo priority))
-           heading content))
-    (odt "%s" '((org-odt-format-inlinetask heading content
-                                          todo priority tags)))
-
-    (latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}"
-          '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
-            heading content))
-    (ascii "     -- %s%s%s"
-          '((unless (eq todo "") (format "%s%s " todo priority))
-            heading
-            (unless (eq content "")
-              (format "\n         ¦ %s"
-                      (mapconcat 'identity (org-split-string content "\n")
-                                 "\n         ¦ ")))))
-    (docbook "<variablelist>
-<varlistentry>
-<term>%s%s</term>
-<listitem><para>%s</para></listitem>
-</varlistentry>
-</variablelist>"
-            '((unless (eq todo "") (format "%s%s " todo priority))
-              heading content)))
-  "Templates for inline tasks in various exporters.
-
-This variable is an alist in the shape of \(BACKEND STRING OBJECTS\).
-
-BACKEND is the name of the backend for the template \(ascii, html...\).
-
-STRING is a format control string.
-
-OBJECTS is a list of elements to be substituted into the format
-string.  They can be of any type, from a string to a form
-returning a value (thus allowing conditional insertion).  A nil
-object will be substituted as the empty string.  Obviously, there
-must be at least as many objects as %-sequences in the format
-string.
-
-Moreover, the following special keywords are provided: `todo',
-`priority', `heading', `content', `tags'.  If some of them are not
-defined in an inline task, their value is the empty string.
-
-As an example, valid associations are:
-
-\(html \"<ul><li>%s <p>%s</p></li></ul>\" \(heading content\)\)
-
-or, with the additional package \"todonotes\" for LaTeX,
-
-\(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
-       '\(\(unless \(eq todo \"\"\)
-          \(format \"\\textsc{%s%s}\" todo priority\)\)
-        heading content\)\)\)")
-
 (defvar org-odd-levels-only)
 (defvar org-keyword-time-regexp)
 (defvar org-drawer-regexp)
@@ -328,89 +259,6 @@ If the task has an end part, also demote it."
            (goto-char beg)
            (org-fixup-indentation diff)))))))
 
-(defvar org-export-current-backend) ; dynamically bound in org-exp.el
-(defun org-inlinetask-export-handler ()
-  "Handle headlines with level larger or equal to `org-inlinetask-min-level'.
-Either remove headline and meta data, or do special formatting."
-  (goto-char (point-min))
-  (let* ((keywords-re (concat "^[ \t]*" org-keyword-time-regexp))
-        (inline-re (concat (org-inlinetask-outline-regexp) ".*")))
-    (while (re-search-forward inline-re nil t)
-      (let ((headline (match-string 0))
-           (beg (point-at-bol))
-           (end (copy-marker (save-excursion
-                               (org-inlinetask-goto-end) (point))))
-           content)
-       ;; Delete SCHEDULED, DEADLINE...
-       (while (re-search-forward keywords-re end t)
-         (delete-region (point-at-bol) (1+ (point-at-eol))))
-       (goto-char beg)
-       ;; Delete drawers
-       (while (re-search-forward org-drawer-regexp end t)
-         (when (save-excursion (re-search-forward org-property-end-re nil t))
-           (delete-region beg (1+ (match-end 0)))))
-       ;; Get CONTENT, if any.
-       (goto-char beg)
-       (forward-line 1)
-       (unless (= (point) end)
-         (setq content (buffer-substring (point)
-                                         (save-excursion (goto-char end)
-                                                         (forward-line -1)
-                                                         (point)))))
-       ;; Remove the task.
-       (goto-char beg)
-       (delete-region beg end)
-       (when (and org-inlinetask-export
-                  (assq org-export-current-backend
-                        org-inlinetask-export-templates))
-         ;; Format CONTENT, if appropriate.
-         (setq content
-               (if (not (and content (string-match "\\S-" content)))
-                   ""
-                 ;; Ensure CONTENT has minimal indentation, a single
-                 ;; newline character at its boundaries, and isn't
-                 ;; protected.
-                 (when (string-match "\\`\\([ \t]*\n\\)+" content)
-                   (setq content (substring content (match-end 0))))
-                 (when (string-match "[ \t\n]+\\'" content)
-                   (setq content (substring content 0 (match-beginning 0))))
-                 (org-add-props
-                     (concat "\n\n" (org-remove-indentation content) "\n\n")
-                     '(org-protected nil org-native-text nil))))
-
-         (when (string-match org-complex-heading-regexp headline)
-           (let* ((nil-to-str
-                   (function
-                    ;; Change nil arguments into empty strings.
-                    (lambda (el) (or (eval el) ""))))
-                  ;;  Set up keywords provided to templates.
-                  (todo (or (match-string 2 headline) ""))
-                  (class (or (and (eq "" todo) "")
-                             (if (member todo org-done-keywords) "done" "todo")))
-                  (priority (or (match-string 3 headline) ""))
-                  (heading (or (match-string 4 headline) ""))
-                  (tags (or (match-string 5 headline) ""))
-                  ;; Read `org-inlinetask-export-templates'.
-                  (backend-spec (assq org-export-current-backend
-                                      org-inlinetask-export-templates))
-                  (format-str (org-add-props (nth 1 backend-spec)
-                                  '(org-protected t org-native-text t)))
-                  (tokens (cadr (nth 2 backend-spec)))
-                  ;; Build export string.  Ensure it won't break
-                  ;; surrounding lists by giving it arbitrary high
-                  ;; indentation.
-                  (export-str (org-add-props
-                                  (eval (append '(format format-str)
-                                                (mapcar nil-to-str tokens)))
-                                  '(original-indentation 1000))))
-             ;; Ensure task starts a new paragraph.
-             (unless (or (bobp)
-                         (save-excursion (forward-line -1)
-                                         (looking-at "[ \t]*$")))
-               (insert "\n"))
-             (insert export-str)
-             (unless (bolp) (insert "\n")))))))))
-
 (defun org-inlinetask-get-current-indentation ()
   "Get the indentation of the last non-while line above this one."
   (save-excursion
@@ -467,7 +315,8 @@ Either remove headline and meta data, or do special formatting."
      ((= end start))
      ;; Inlinetask was folded: expand it.
      ((get-char-property (1+ start) 'invisible)
-      (org-show-entry))
+      (outline-flag-region start end nil)
+      (org-cycle-hide-drawers 'children))
      (t (outline-flag-region start end t)))))
 
 (defun org-inlinetask-remove-END-maybe ()
@@ -476,9 +325,6 @@ Either remove headline and meta data, or do special formatting."
                            org-inlinetask-min-level))
     (replace-match "")))
 
-(eval-after-load "org-exp"
-  '(add-hook 'org-export-preprocess-before-backend-specifics-hook
-            'org-inlinetask-export-handler))
 (eval-after-load "org"
   '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
 
diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el
deleted file mode 100644 (file)
index 08c0110..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-;;; org-jsinfo.el --- Support for org-info.js Javascript in Org HTML export
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file implements the support for Sebastian Rose's JavaScript
-;; org-info.js to display an org-mode file exported to HTML in an
-;; Info-like way, or using folding similar to the outline structure
-;; org org-mode itself.
-
-;; Documentation for using this module is in the Org manual.  The script
-;; itself is documented by Sebastian Rose in a file distributed with
-;; the script.  FIXME: Accurate pointers!
-
-;; Org-mode loads this module by default - if this is not what you want,
-;; configure the variable `org-modules'.
-
-;;; Code:
-
-(require 'org-exp)
-(require 'org-html)
-
-(add-to-list 'org-export-inbuffer-options-extra '("INFOJS_OPT" :infojs-opt))
-(add-hook 'org-export-options-filters 'org-infojs-handle-options)
-
-(defgroup org-infojs nil
-  "Options specific for using org-info.js in HTML export of Org-mode files."
-  :tag "Org Export HTML INFOJS"
-  :group 'org-export-html)
-
-(defcustom org-export-html-use-infojs 'when-configured
-  "Should Sebastian Rose's Java Script org-info.js be linked into HTML files?
-This option can be nil or t to never or always use the script.  It can
-also be the symbol `when-configured', meaning that the script will be
-linked into the export file if and only if there is a \"#+INFOJS_OPT:\"
-line in the buffer.  See also the variable `org-infojs-options'."
-  :group 'org-export-html
-  :group 'org-infojs
-  :type '(choice
-         (const :tag "Never" nil)
-         (const :tag "When configured in buffer" when-configured)
-         (const :tag "Always" t)))
-
-(defconst org-infojs-opts-table
-  '((path PATH "http://orgmode.org/org-info.js")
-    (view VIEW "info")
-    (toc TOC :table-of-contents)
-    (ftoc FIXED_TOC "0")
-    (tdepth TOC_DEPTH "max")
-    (sdepth SECTION_DEPTH "max")
-    (mouse MOUSE_HINT "underline")
-    (buttons VIEW_BUTTONS "0")
-    (ltoc LOCAL_TOC "1")
-    (up LINK_UP :link-up)
-    (home LINK_HOME :link-home))
-  "JavaScript options, long form for script, default values.")
-
-(defvar org-infojs-options)
-(when (and (boundp 'org-infojs-options)
-          (assq 'runs org-infojs-options))
-  (setq org-infojs-options (delq (assq 'runs org-infojs-options)
-                                org-infojs-options)))
-
-(defcustom org-infojs-options
-  (mapcar (lambda (x) (cons (car x) (nth 2 x)))
-         org-infojs-opts-table)
-  "Options settings for the INFOJS JavaScript.
-Each of the options must have an entry in `org-export-html/infojs-opts-table'.
-The value can either be a string that will be passed to the script, or
-a property.  This property is then assumed to be a property that is defined
-by the Export/Publishing setup of Org.
-The `sdepth' and `tdepth' parameters can also be set to \"max\", which
-means to use the maximum value consistent with other options."
-  :group 'org-infojs
-  :type
-  `(set :greedy t :inline t
-       ,@(mapcar
-          (lambda (x)
-            (list 'cons (list 'const (car x))
-                  '(choice
-                    (symbol :tag "Publishing/Export property")
-                    (string :tag "Value"))))
-          org-infojs-opts-table)))
-
-(defcustom org-infojs-template
-  "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
-/**
- *
- * @source: %SCRIPT_PATH
- *
- * @licstart  The following is the entire license notice for the
- *  JavaScript code in %SCRIPT_PATH.
- *
- * Copyright (C) 2012-2013  Sebastian Rose
- *
- *
- * The JavaScript code in this tag is free software: you can
- * redistribute it and/or modify it under the terms of the GNU
- * General Public License (GNU GPL) as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option)
- * any later version.  The code is distributed WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
- *
- * As additional permission under GNU GPL version 3 section 7, you
- * may distribute non-source (e.g., minimized or compacted) forms of
- * that code without the copy of the GNU GPL normally required by
- * section 4, provided you include this license notice and a URL
- * through which recipients can access the Corresponding Source.
- *
- * @licend  The above is the entire license notice
- * for the JavaScript code in %SCRIPT_PATH.
- *
- */
-</script>
-
-<script type=\"text/javascript\">
-
-/*
-@licstart  The following is the entire license notice for the
-JavaScript code in this tag.
-
-Copyright (C) 2012-2013 Free Software Foundation, Inc.
-
-The JavaScript code in this tag is free software: you can
-redistribute it and/or modify it under the terms of the GNU
-General Public License (GNU GPL) as published by the Free Software
-Foundation, either version 3 of the License, or (at your option)
-any later version.  The code is distributed WITHOUT ANY WARRANTY;
-without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
-
-As additional permission under GNU GPL version 3 section 7, you
-may distribute non-source (e.g., minimized or compacted) forms of
-that code without the copy of the GNU GPL normally required by
-section 4, provided you include this license notice and a URL
-through which recipients can access the Corresponding Source.
-
-
-@licend  The above is the entire license notice
-for the JavaScript code in this tag.
-*/
-
-<!--/*--><![CDATA[/*><!--*/
-%MANAGER_OPTIONS
-org_html_manager.setup();  // activate after the parameters are set
-/*]]>*///-->
-</script>"
-  "The template for the export style additions when org-info.js is used.
-Option settings will replace the %MANAGER-OPTIONS cookie."
-  :group 'org-infojs
-  :type 'string)
-
-(defun org-infojs-handle-options (exp-plist)
-  "Analyze JavaScript options in INFO-PLIST and modify EXP-PLIST accordingly."
-  (if (or (not org-export-html-use-infojs)
-         (and (eq org-export-html-use-infojs 'when-configured)
-              (or (not (plist-get exp-plist :infojs-opt))
-                  (string-match "\\<view:nil\\>"
-                                (plist-get exp-plist :infojs-opt)))))
-      ;; We do not want to use the script
-      exp-plist
-    ;; We do want to use the script, set it up
-    (let ((template org-infojs-template)
-         (ptoc (plist-get exp-plist :table-of-contents))
-         (hlevels (plist-get exp-plist :headline-levels))
-         tdepth sdepth s v e opt var val table default)
-      (setq sdepth hlevels
-           tdepth hlevels)
-      (if (integerp ptoc) (setq tdepth (min ptoc tdepth)))
-      (setq v (plist-get exp-plist :infojs-opt)
-           table org-infojs-opts-table)
-      (while (setq e (pop table))
-       (setq opt (car e) var (nth 1 e)
-             default (cdr (assoc opt org-infojs-options)))
-       (and (symbolp default) (not (memq default '(t nil)))
-            (setq default (plist-get exp-plist default)))
-       (if (and v (string-match (format " %s:\\(\\S-+\\)" opt) v))
-           (setq val (match-string 1 v))
-         (setq val default))
-       (cond
-        ((eq opt 'path)
-         (setq template
-               (replace-regexp-in-string "%SCRIPT_PATH" val template t t)))
-        ((eq opt 'sdepth)
-         (if (integerp (read val))
-             (setq sdepth (min (read val) hlevels))))
-        ((eq opt 'tdepth)
-         (if (integerp (read val))
-             (setq tdepth (min (read val) hlevels))))
-        (t
-         (setq val
-               (cond
-                ((or (eq val t) (equal val "t")) "1")
-                ((or (eq val nil) (equal val "nil")) "0")
-                ((stringp val) val)
-                (t (format "%s" val))))
-         (push (cons var val) s))))
-
-      ;; Now we set the depth of the *generated* TOC to SDEPTH, because the
-      ;; toc will actually determine the splitting.  How much of the toc will
-      ;; actually be displayed is governed by the TDEPTH option.
-      (setq exp-plist (plist-put exp-plist :table-of-contents sdepth))
-
-      ;; The table of contents should not show more sections then we generate
-      (setq tdepth (min tdepth sdepth))
-      (push (cons "TOC_DEPTH" tdepth) s)
-
-      (setq s (mapconcat
-              (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
-                                  (car x) (cdr x)))
-              s "\n"))
-      (when (and s (> (length s) 0))
-       (and (string-match "%MANAGER_OPTIONS" template)
-            (setq s (replace-match s t t template))
-            (setq exp-plist
-                  (plist-put
-                   exp-plist :style-extra
-                   (concat (or (plist-get exp-plist :style-extra) "") "\n" s)))))
-      ;; This script absolutely needs the table of contents, to we change that
-      ;; setting
-      (if (not (plist-get exp-plist :table-of-contents))
-         (setq exp-plist (plist-put exp-plist :table-of-contents t)))
-      ;; Return the modified property list
-      exp-plist)))
-
-(defun org-infojs-options-inbuffer-template ()
-  (format "#+INFOJS_OPT: view:%s toc:%s ltoc:%s mouse:%s buttons:%s path:%s"
-         (if (eq t org-export-html-use-infojs) (cdr (assoc 'view org-infojs-options)) nil)
-         (let ((a (cdr (assoc 'toc org-infojs-options))))
-           (cond ((memq a '(nil t)) a)
-                 (t (plist-get (org-infile-export-plist) :table-of-contents))))
-         (if (equal (cdr (assoc 'ltoc org-infojs-options)) "1") t nil)
-         (cdr (assoc 'mouse org-infojs-options))
-         (cdr (assoc 'buttons org-infojs-options))
-         (cdr (assoc 'path org-infojs-options))))
-
-(provide 'org-infojs)
-(provide 'org-jsinfo)
-
-;;; org-jsinfo.el ends here
diff --git a/lisp/org/org-latex.el b/lisp/org/org-latex.el
deleted file mode 100644 (file)
index 609bcbe..0000000
+++ /dev/null
@@ -1,2901 +0,0 @@
-;;; org-latex.el --- LaTeX exporter for org-mode
-;;
-;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
-;;
-;; Emacs Lisp Archive Entry
-;; Filename: org-latex.el
-;; Author: Bastien Guerry <bzg AT gnu DOT org>
-;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
-;; Keywords: org, wp, tex
-;; Description: Converts an org-mode buffer into LaTeX
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This library implements a LaTeX exporter for org-mode.
-;;
-;; It is part of Org and will be autoloaded
-;;
-;; The interactive functions are similar to those of the HTML exporter:
-;;
-;; M-x `org-export-as-latex'
-;; M-x `org-export-as-pdf'
-;; M-x `org-export-as-pdf-and-open'
-;; M-x `org-export-as-latex-batch'
-;; M-x `org-export-as-latex-to-buffer'
-;; M-x `org-export-region-as-latex'
-;; M-x `org-replace-region-by-latex'
-;;
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-
-(require 'footnote)
-(require 'org)
-(require 'org-exp)
-(require 'org-macs)
-(require 'org-beamer)
-
-;;; Variables:
-(defvar org-export-latex-class nil)
-(defvar org-export-latex-class-options nil)
-(defvar org-export-latex-header nil)
-(defvar org-export-latex-append-header nil)
-(defvar org-export-latex-options-plist nil)
-(defvar org-export-latex-todo-keywords-1 nil)
-(defvar org-export-latex-complex-heading-re nil)
-(defvar org-export-latex-not-done-keywords nil)
-(defvar org-export-latex-done-keywords nil)
-(defvar org-export-latex-display-custom-times nil)
-(defvar org-export-latex-all-targets-re nil)
-(defvar org-export-latex-add-level 0)
-(defvar org-export-latex-footmark-seen nil
-  "List of footnotes markers seen so far by exporter.")
-(defvar org-export-latex-sectioning "")
-(defvar org-export-latex-sectioning-depth 0)
-(defvar org-export-latex-special-keyword-regexp
-  (concat "\\<\\(" org-scheduled-string "\\|"
-         org-deadline-string "\\|"
-         org-closed-string"\\)")
-  "Regexp matching special time planning keywords plus the time after it.")
-(defvar org-re-quote)  ; dynamically scoped from org.el
-(defvar org-commentsp) ; dynamically scoped from org.el
-
-;;; User variables:
-
-(defgroup org-export-latex nil
-  "Options for exporting Org-mode files to LaTeX."
-  :tag "Org Export LaTeX"
-  :group 'org-export)
-
-(defcustom org-export-latex-default-class "article"
-  "The default LaTeX class."
-  :group 'org-export-latex
-  :type '(string :tag "LaTeX class"))
-
-(defcustom org-export-latex-classes
-  '(("article"
-     "\\documentclass[11pt]{article}"
-     ("\\section{%s}" . "\\section*{%s}")
-     ("\\subsection{%s}" . "\\subsection*{%s}")
-     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
-     ("\\paragraph{%s}" . "\\paragraph*{%s}")
-     ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
-    ("report"
-     "\\documentclass[11pt]{report}"
-     ("\\part{%s}" . "\\part*{%s}")
-     ("\\chapter{%s}" . "\\chapter*{%s}")
-     ("\\section{%s}" . "\\section*{%s}")
-     ("\\subsection{%s}" . "\\subsection*{%s}")
-     ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
-    ("book"
-     "\\documentclass[11pt]{book}"
-     ("\\part{%s}" . "\\part*{%s}")
-     ("\\chapter{%s}" . "\\chapter*{%s}")
-     ("\\section{%s}" . "\\section*{%s}")
-     ("\\subsection{%s}" . "\\subsection*{%s}")
-     ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
-    ("beamer"
-     "\\documentclass{beamer}"
-     org-beamer-sectioning
-     ))
-  "Alist of LaTeX classes and associated header and structure.
-If #+LaTeX_CLASS is set in the buffer, use its value and the
-associated information.  Here is the structure of each cell:
-
-  \(class-name
-    header-string
-    (numbered-section . unnumbered-section\)
-    ...\)
-
-The header string
------------------
-
-The HEADER-STRING is the header that will be inserted into the LaTeX file.
-It should contain the \\documentclass macro, and anything else that is needed
-for this setup.  To this header, the following commands will be added:
-
-- Calls to \\usepackage for all packages mentioned in the variables
-  `org-export-latex-default-packages-alist' and
-  `org-export-latex-packages-alist'.  Thus, your header definitions should
-  avoid to also request these packages.
-
-- Lines specified via \"#+LaTeX_HEADER:\"
-
-If you need more control about the sequence in which the header is built
-up, or if you want to exclude one of these building blocks for a particular
-class, you can use the following macro-like placeholders.
-
- [DEFAULT-PACKAGES]      \\usepackage statements for default packages
- [NO-DEFAULT-PACKAGES]   do not include any of the default packages
- [PACKAGES]              \\usepackage statements for packages
- [NO-PACKAGES]           do not include the packages
- [EXTRA]                 the stuff from #+LaTeX_HEADER
- [NO-EXTRA]              do not include #+LaTeX_HEADER stuff
- [BEAMER-HEADER-EXTRA]   the beamer extra headers
-
-So a header like
-
-  \\documentclass{article}
-  [NO-DEFAULT-PACKAGES]
-  [EXTRA]
-  \\providecommand{\\alert}[1]{\\textbf{#1}}
-  [PACKAGES]
-
-will omit the default packages, and will include the #+LaTeX_HEADER lines,
-then have a call to \\providecommand, and then place \\usepackage commands
-based on the content of `org-export-latex-packages-alist'.
-
-If your header or `org-export-latex-default-packages-alist' inserts
-\"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be replaced with
-a coding system derived from `buffer-file-coding-system'.  See also the
-variable `org-export-latex-inputenc-alist' for a way to influence this
-mechanism.
-
-The sectioning structure
-------------------------
-
-The sectioning structure of the class is given by the elements following
-the header string.  For each sectioning level, a number of strings is
-specified.  A %s formatter is mandatory in each section string and will
-be replaced by the title of the section.
-
-Instead of a cons cell (numbered . unnumbered), you can also provide a list
-of 2 or 4 elements,
-
-  (numbered-open numbered-close)
-
-or
-
-  (numbered-open numbered-close unnumbered-open unnumbered-close)
-
-providing opening and closing strings for a LaTeX environment that should
-represent the document section.  The opening clause should have a %s
-to represent the section title.
-
-Instead of a list of sectioning commands, you can also specify a
-function name.  That function will be called with two parameters,
-the (reduced) level of the headline, and the headline text.  The function
-must return a cons cell with the (possibly modified) headline text, and the
-sectioning list in the cdr."
-  :group 'org-export-latex
-  :type '(repeat
-         (list (string :tag "LaTeX class")
-               (string :tag "LaTeX header")
-               (repeat :tag "Levels" :inline t
-                       (choice
-                        (cons :tag "Heading"
-                              (string :tag "  numbered")
-                              (string :tag "unnumbered"))
-                        (list :tag "Environment"
-                              (string :tag "Opening   (numbered)")
-                              (string :tag "Closing   (numbered)")
-                              (string :tag "Opening (unnumbered)")
-                              (string :tag "Closing (unnumbered)"))
-                        (function :tag "Hook computing sectioning"))))))
-
-(defcustom org-export-latex-inputenc-alist nil
-  "Alist of inputenc coding system names, and what should really be used.
-For example, adding an entry
-
-      (\"utf8\" . \"utf8x\")
-
-will cause \\usepackage[utf8x]{inputenc} to be used for buffers that
-are written as utf8 files."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(repeat
-         (cons
-          (string :tag "Derived from buffer")
-          (string :tag "Use this instead"))))
-
-
-(defcustom org-export-latex-emphasis-alist
-  '(("*" "\\textbf{%s}" nil)
-    ("/" "\\emph{%s}" nil)
-    ("_" "\\underline{%s}" nil)
-    ("+" "\\st{%s}" nil)
-    ("=" "\\protectedtexttt" t)
-    ("~" "\\verb" t))
-  "Alist of LaTeX expressions to convert emphasis fontifiers.
-Each element of the list is a list of three elements.
-The first element is the character used as a marker for fontification.
-The second element is a format string to wrap fontified text with.
-If it is \"\\verb\", Org will automatically select a delimiter
-character that is not in the string.  \"\\protectedtexttt\" will use \\texttt
-to typeset and try to protect special characters.
-The third element decides whether to protect converted text from other
-conversions."
-  :group 'org-export-latex
-  :type 'alist)
-
-(defcustom org-export-latex-title-command "\\maketitle"
-  "The command used to insert the title just after \\begin{document}.
-If this string contains the formatting specification \"%s\" then
-it will be used as a format string, passing the title as an
-argument."
-  :group 'org-export-latex
-  :type 'string)
-
-(defcustom org-export-latex-import-inbuffer-stuff nil
-  "Non-nil means define TeX macros for Org's inbuffer definitions.
-For example \orgTITLE for #+TITLE."
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-latex-date-format
-  "\\today"
-  "Format string for \\date{...}."
-  :group 'org-export-latex
-  :type 'string)
-
-(defcustom org-export-latex-todo-keyword-markup "\\textbf{%s}"
-  "Markup for TODO keywords, as a printf format.
-This can be a single format for all keywords, a cons cell with separate
-formats for not-done and done states, or an association list with setup
-for individual keywords.  If a keyword shows up for which there is no
-markup defined, the first one in the association list will be used."
-  :group 'org-export-latex
-  :type '(choice
-         (string :tag "Default")
-         (cons :tag "Distinguish undone and done"
-               (string :tag "Not-DONE states")
-               (string :tag "DONE states"))
-         (repeat :tag "Per keyword markup"
-                 (cons
-                  (string :tag "Keyword")
-                  (string :tag "Markup")))))
-
-(defcustom org-export-latex-tag-markup "\\textbf{%s}"
-  "Markup for tags, as a printf format."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-timestamp-markup "\\textit{%s}"
-  "A printf format string to be applied to time stamps."
-  :group 'org-export-latex
-  :type 'string)
-
-(defcustom org-export-latex-timestamp-inactive-markup "\\textit{%s}"
-  "A printf format string to be applied to inactive time stamps."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-timestamp-keyword-markup "\\texttt{%s}"
-  "A printf format string to be applied to time stamps."
-  :group 'org-export-latex
-  :type 'string)
-
-(defcustom org-export-latex-href-format "\\href{%s}{%s}"
-  "A printf format string to be applied to href links.
-The format must contain either two %s instances or just one.
-If it contains two %s instances, the first will be filled with
-the link, the second with the link description.  If it contains
-only one, the %s will be filled with the link."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-hyperref-format "\\hyperref[%s]{%s}"
-  "A printf format string to be applied to hyperref links.
-The format must contain one or two %s instances.  The first one
-will be filled with the link, the second with its description."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-hyperref-options-format
-  "\\hypersetup{\n  pdfkeywords={%s},\n  pdfsubject={%s},\n  pdfcreator={Emacs Org-mode version %s}}\n"
-  "A format string for hyperref options.
-When non-nil, it must contain three %s format specifications
-which will respectively be replaced by the document's keywords,
-its description and the Org's version number, as a string.  Set
-this option to the empty string if you don't want to include
-hyperref options altogether."
-  :type 'string
-  :version "24.3"
-  :group 'org-export-latex)
-
-(defcustom org-export-latex-footnote-separator "\\textsuperscript{,}\\,"
-  "Text used to separate footnotes."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-quotes
-  '(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "~»") ("\\(\\s-\\|(\\)'" . "'"))
-    ("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
-  "Alist for quotes to use when converting english double-quotes.
-
-The CAR of each item in this alist is the language code.
-The CDR of each item in this alist is a list of three CONS:
-- the first CONS defines the opening quote;
-- the second CONS defines the closing quote;
-- the last CONS defines single quotes.
-
-For each item in a CONS, the first string is a regexp
-for allowed characters before/after the quote, the second
-string defines the replacement string for this quote."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(list
-         (cons :tag "Opening quote"
-               (string :tag "Regexp for char before")
-               (string :tag "Replacement quote     "))
-         (cons :tag "Closing quote"
-               (string :tag "Regexp for char after ")
-               (string :tag "Replacement quote     "))
-         (cons :tag "Single quote"
-               (string :tag "Regexp for char before")
-               (string :tag "Replacement quote     "))))
-
-(defcustom org-export-latex-tables-verbatim nil
-  "When non-nil, tables are exported verbatim."
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-latex-tables-centered t
-  "When non-nil, tables are exported in a center environment."
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-latex-table-caption-above t
-  "When non-nil, the caption is set above the table.  When nil,
-the caption is set below the table."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-latex-tables-column-borders nil
-  "When non-nil, grouping columns can cause outer vertical lines in tables.
-When nil, grouping causes only separation lines between groups."
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-latex-tables-tstart nil
-  "LaTeX command for top rule for tables."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(choice
-          (const :tag "Nothing" nil)
-          (string :tag "String")
-          (const  :tag "Booktabs default: \\toprule" "\\toprule")))
-
-(defcustom org-export-latex-tables-hline "\\hline"
-  "LaTeX command to use for a rule somewhere in the middle of a table."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(choice
-          (string :tag "String")
-          (const  :tag "Standard: \\hline" "\\hline")
-          (const  :tag "Booktabs default: \\midrule" "\\midrule")))
-
-(defcustom org-export-latex-tables-tend nil
-  "LaTeX command for bottom rule for tables."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(choice
-          (const :tag "Nothing" nil)
-          (string :tag "String")
-          (const  :tag "Booktabs default: \\bottomrule" "\\bottomrule")))
-
-(defcustom org-export-latex-low-levels 'itemize
-  "How to convert sections below the current level of sectioning.
-This is specified by the `org-export-headline-levels' option or the
-value of \"H:\" in Org's #+OPTION line.
-
-This can be either nil (skip the sections), `description', `itemize',
-or `enumerate' (convert the sections as the corresponding list type), or
-a string to be used instead of \\section{%s}.  In this latter case,
-the %s stands here for the inserted headline and is mandatory.
-
-It may also be a list of three string to define a user-defined environment
-that should be used.  The first string should be the like
-\"\\begin{itemize}\", the second should be like \"\\item %s %s\" with up
-to two occurrences of %s for the title and a label, respectively.  The third
-string should be like \"\\end{itemize\"."
-  :group 'org-export-latex
-  :type '(choice (const :tag "Ignore" nil)
-                (const :tag "Convert as descriptive list" description)
-                (const :tag "Convert as itemized list" itemize)
-                (const :tag "Convert as enumerated list" enumerate)
-                (list  :tag "User-defined environment"
-                       :value ("\\begin{itemize}" "\\end{itemize}" "\\item %s")
-                       (string :tag "Start")
-                       (string :tag "End")
-                       (string :tag "item"))
-                (string :tag "Use a section string" :value "\\subparagraph{%s}")))
-
-(defcustom org-export-latex-list-parameters
-  '(:cbon "$\\boxtimes$" :cboff "$\\Box$" :cbtrans "$\\boxminus$")
-  "Parameters for the LaTeX list exporter.
-These parameters will be passed on to `org-list-to-latex', which in turn
-will pass them (combined with the LaTeX default list parameters) to
-`org-list-to-generic'."
-  :group 'org-export-latex
-  :type 'plist)
-
-(defcustom org-export-latex-verbatim-wrap
-  '("\\begin{verbatim}\n" . "\\end{verbatim}")
-  "Environment to be wrapped around a fixed-width section in LaTeX export.
-This is a cons with two strings, to be added before and after the
-fixed-with text.
-
-Defaults to \\begin{verbatim} and \\end{verbatim}."
-  :group 'org-export-translation
-  :group 'org-export-latex
-  :type '(cons (string :tag "Open")
-              (string :tag "Close")))
-
-(defcustom org-export-latex-listings nil
-  "Non-nil means export source code using the listings package.
-This package will fontify source code, possibly even with color.
-If you want to use this, you also need to make LaTeX use the
-listings package, and if you want to have color, the color
-package.  Just add these to `org-export-latex-packages-alist',
-for example using customize, or with something like
-
-  (require 'org-latex)
-  (add-to-list 'org-export-latex-packages-alist '(\"\" \"listings\"))
-  (add-to-list 'org-export-latex-packages-alist '(\"\" \"color\"))
-
-Alternatively,
-
-  (setq org-export-latex-listings 'minted)
-
-causes source code to be exported using the minted package as
-opposed to listings.  If you want to use minted, you need to add
-the minted package to `org-export-latex-packages-alist', for
-example using customize, or with
-
-  (require 'org-latex)
-  (add-to-list 'org-export-latex-packages-alist '(\"\" \"minted\"))
-
-In addition, it is necessary to install
-pygments (http://pygments.org), and to configure the variable
-`org-latex-to-pdf-process' so that the -shell-escape option is
-passed to pdflatex.
-"
-  :group 'org-export-latex
-  :type 'boolean)
-
-(defcustom org-export-latex-listings-langs
-  '((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp")
-    (c "C") (cc "C++")
-    (fortran "fortran")
-    (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby")
-    (html "HTML") (xml "XML")
-    (tex "TeX") (latex "TeX")
-    (shell-script "bash")
-    (gnuplot "Gnuplot")
-    (ocaml "Caml") (caml "Caml")
-    (sql "SQL") (sqlite "sql"))
-  "Alist mapping languages to their listing language counterpart.
-The key is a symbol, the major mode symbol without the \"-mode\".
-The value is the string that should be inserted as the language parameter
-for the listings package.  If the mode name and the listings name are
-the same, the language does not need an entry in this list - but it does not
-hurt if it is present."
-  :group 'org-export-latex
-  :type '(repeat
-         (list
-          (symbol :tag "Major mode       ")
-          (string :tag "Listings language"))))
-
-(defcustom org-export-latex-listings-w-names t
-  "Non-nil means export names of named code blocks.
-Code blocks exported with the listings package (controlled by the
-`org-export-latex-listings' variable) can be named in the style
-of noweb."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-export-latex-minted-langs
-  '((emacs-lisp "common-lisp")
-    (cc "c++")
-    (cperl "perl")
-    (shell-script "bash")
-    (caml "ocaml"))
-  "Alist mapping languages to their minted language counterpart.
-The key is a symbol, the major mode symbol without the \"-mode\".
-The value is the string that should be inserted as the language parameter
-for the minted package.  If the mode name and the listings name are
-the same, the language does not need an entry in this list - but it does not
-hurt if it is present.
-
-Note that minted uses all lower case for language identifiers,
-and that the full list of language identifiers can be obtained
-with:
-pygmentize -L lexers
-"
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(repeat
-         (list
-          (symbol :tag "Major mode       ")
-          (string :tag "Listings language"))))
-
-(defcustom org-export-latex-listings-options nil
-  "Association list of options for the latex listings package.
-
-These options are supplied as a comma-separated list to the
-\\lstset command.  Each element of the association list should be
-a list containing two strings: the name of the option, and the
-value.  For example,
-
-  (setq org-export-latex-listings-options
-    '((\"basicstyle\" \"\\small\")
-      (\"keywordstyle\" \"\\color{black}\\bfseries\\underbar\")))
-
-will typeset the code in a small size font with underlined, bold
-black keywords.
-
-Note that the same options will be applied to blocks of all
-languages."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(repeat
-         (list
-          (string :tag "Listings option name ")
-          (string :tag "Listings option value"))))
-
-(defcustom org-export-latex-minted-options nil
-  "Association list of options for the latex minted package.
-
-These options are supplied within square brackets in
-\\begin{minted} environments.  Each element of the alist should be
-a list containing two strings: the name of the option, and the
-value.  For example,
-
-  (setq org-export-latex-minted-options
-    '((\"bgcolor\" \"bg\") (\"frame\" \"lines\")))
-
-will result in src blocks being exported with
-
-\\begin{minted}[bgcolor=bg,frame=lines]{<LANG>}
-
-as the start of the minted environment.  Note that the same
-options will be applied to blocks of all languages."
-  :group 'org-export-latex
-  :version "24.1"
-  :type '(repeat
-         (list
-          (string :tag "Minted option name ")
-          (string :tag "Minted option value"))))
-
-(defvar org-export-latex-custom-lang-environments nil
-  "Association list mapping languages to language-specific latex
-  environments used during export of src blocks by the listings
-  and minted latex packages.  For example,
-
-  (setq org-export-latex-custom-lang-environments
-     '((python \"pythoncode\")))
-
-  would have the effect that if org encounters begin_src python
-  during latex export it will output
-
-  \\begin{pythoncode}
-  <src block body>
-  \\end{pythoncode}")
-
-(defcustom org-export-latex-remove-from-headlines
-  '(:todo nil :priority nil :tags nil)
-  "A plist of keywords to remove from headlines.  OBSOLETE.
-Non-nil means remove this keyword type from the headline.
-
-Don't remove the keys, just change their values.
-
-Obsolete, this variable is no longer used.  Use the separate
-variables `org-export-with-todo-keywords', `org-export-with-priority',
-and `org-export-with-tags' instead."
-  :type 'plist
-  :group 'org-export-latex)
-
-(defcustom org-export-latex-image-default-option "width=.9\\linewidth"
-  "Default option for images."
-  :group 'org-export-latex
-  :type 'string)
-
-(defcustom org-latex-default-figure-position "htb"
-  "Default position for latex figures."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-tabular-environment "tabular"
-  "Default environment used to build tables."
-  :group 'org-export-latex
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-latex-link-with-unknown-path-format "\\texttt{%s}"
-  "Format string for links with unknown path type."
-  :group 'org-export-latex
-  :version "24.3"
-  :type 'string)
-
-(defcustom org-export-latex-inline-image-extensions
-  '("pdf" "jpeg" "jpg" "png" "ps" "eps")
-  "Extensions of image files that can be inlined into LaTeX.
-Note that the image extension *actually* allowed depend on the way the
-LaTeX file is processed.  When used with pdflatex, pdf, jpg and png images
-are OK.  When processing through dvi to Postscript, only ps and eps are
-allowed.  The default we use here encompasses both."
-  :group 'org-export-latex
-  :type '(repeat (string :tag "Extension")))
-
-(defcustom org-export-latex-coding-system nil
-  "Coding system for the exported LaTeX file."
-  :group 'org-export-latex
-  :type 'coding-system)
-
-(defgroup org-export-pdf nil
-  "Options for exporting Org-mode files to PDF, via LaTeX."
-  :tag "Org Export PDF"
-  :group 'org-export-latex
-  :group 'org-export)
-
-(defcustom org-latex-to-pdf-process
-  '("pdflatex -interaction nonstopmode -output-directory %o %f"
-    "pdflatex -interaction nonstopmode -output-directory %o %f"
-    "pdflatex -interaction nonstopmode -output-directory %o %f")
-  "Commands to process a LaTeX file to a PDF file and process latex
-fragments to pdf files.By default,this is a list of strings,and each of
-strings will be given to the shell as a command. %f in the command will
-be replaced by the full file name, %b by the file base name (i.e. without
-extension) and %o by the base directory of the file.
-
-If you set `org-create-formula-image-program'
-`org-export-with-LaTeX-fragments' to 'imagemagick, you can add a
-sublist which contains your own command(s) for LaTeX fragments
-previewing, like this:
-
-   '(\"xelatex -interaction nonstopmode -output-directory %o %f\"
-     \"xelatex -interaction nonstopmode -output-directory %o %f\"
-     ;; use below command(s) to convert latex fragments
-     (\"xelatex %f\"))
-
-With no such sublist, the default command used to convert LaTeX
-fragments will be the first string in the list.
-
-The reason why this is a list is that it usually takes several runs of
-`pdflatex', maybe mixed with a call to `bibtex'.  Org does not have a clever
-mechanism to detect which of these commands have to be run to get to a stable
-result, and it also does not do any error checking.
-
-By default, Org uses 3 runs of `pdflatex' to do the processing.  If you
-have texi2dvi on your system and if that does not cause the infamous
-egrep/locale bug:
-
-     http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html
-
-then `texi2dvi' is the superior choice.  Org does offer it as one
-of the customize options.
-
-Alternatively, this may be a Lisp function that does the processing, so you
-could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode.
-This function should accept the file name as its single argument."
-  :group 'org-export-pdf
-  :type '(choice
-         (repeat :tag "Shell command sequence"
-                 (string :tag "Shell command"))
-         (const :tag "2 runs of pdflatex"
-                ("pdflatex -interaction nonstopmode -output-directory %o %f"
-                 "pdflatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "3 runs of pdflatex"
-                ("pdflatex -interaction nonstopmode -output-directory %o %f"
-                 "pdflatex -interaction nonstopmode -output-directory %o %f"
-                 "pdflatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "pdflatex,bibtex,pdflatex,pdflatex"
-                ("pdflatex -interaction nonstopmode -output-directory %o %f"
-                 "bibtex %b"
-                 "pdflatex -interaction nonstopmode -output-directory %o %f"
-                 "pdflatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "2 runs of xelatex"
-                ("xelatex -interaction nonstopmode -output-directory %o %f"
-                 "xelatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "3 runs of xelatex"
-                ("xelatex -interaction nonstopmode -output-directory %o %f"
-                 "xelatex -interaction nonstopmode -output-directory %o %f"
-                 "xelatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "xelatex,bibtex,xelatex,xelatex"
-                ("xelatex -interaction nonstopmode -output-directory %o %f"
-                 "bibtex %b"
-                 "xelatex -interaction nonstopmode -output-directory %o %f"
-                 "xelatex -interaction nonstopmode -output-directory %o %f"))
-         (const :tag "texi2dvi"
-                ("texi2dvi -p -b -c -V %f"))
-         (const :tag "rubber"
-                ("rubber -d --into %o %f"))
-         (function)))
-
-(defcustom org-export-pdf-logfiles
-  '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb")
-  "The list of file extensions to consider as LaTeX logfiles."
-  :group 'org-export-pdf
-  :version "24.1"
-  :type '(repeat (string :tag "Extension")))
-
-(defcustom org-export-pdf-remove-logfiles t
-  "Non-nil means remove the logfiles produced by PDF production.
-These are the .aux, .log, .out, and .toc files."
-  :group 'org-export-pdf
-  :type 'boolean)
-
-;;; Hooks
-
-(defvar org-export-latex-after-initial-vars-hook nil
-  "Hook run before LaTeX export.
-The exact moment is after the initial variables like org-export-latex-class
-have been determined from the environment.")
-
-(defvar org-export-latex-after-blockquotes-hook nil
-  "Hook run during LaTeX export, after blockquote, verse, center are done.")
-
-(defvar org-export-latex-final-hook nil
-  "Hook run in the finalized LaTeX buffer.")
-
-(defvar org-export-latex-after-save-hook nil
-  "Hook run in the finalized LaTeX buffer, after it has been saved.")
-
-;;; Autoload functions:
-
-;;;###autoload
-(defun org-export-as-latex-batch ()
-  "Call `org-export-as-latex', may be used in batch processing.
-For example:
-
-emacs   --batch
-        --load=$HOME/lib/emacs/org.el
-        --eval \"(setq org-export-headline-levels 2)\"
-        --visit=MyFile --funcall org-export-as-latex-batch"
-  (org-export-as-latex org-export-headline-levels))
-
-;;;###autoload
-(defun org-export-as-latex-to-buffer (arg)
-  "Call `org-export-as-latex` with output to a temporary buffer.
-No file is created.  The prefix ARG is passed through to `org-export-as-latex'."
-  (interactive "P")
-  (org-export-as-latex arg nil "*Org LaTeX Export*")
-  (when org-export-show-temporary-export-buffer
-    (switch-to-buffer-other-window "*Org LaTeX Export*")))
-
-;;;###autoload
-(defun org-replace-region-by-latex (beg end)
-  "Replace the region from BEG to END with its LaTeX export.
-It assumes the region has `org-mode' syntax, and then convert it to
-LaTeX.  This can be used in any buffer.  For example, you could
-write an itemized list in `org-mode' syntax in an LaTeX buffer and
-then use this command to convert it."
-  (interactive "r")
-  (let (reg latex buf)
-    (save-window-excursion
-      (if (derived-mode-p 'org-mode)
-         (setq latex (org-export-region-as-latex
-                      beg end t 'string))
-       (setq reg (buffer-substring beg end)
-             buf (get-buffer-create "*Org tmp*"))
-       (with-current-buffer buf
-         (erase-buffer)
-         (insert reg)
-         (org-mode)
-         (setq latex (org-export-region-as-latex
-                      (point-min) (point-max) t 'string)))
-       (kill-buffer buf)))
-    (delete-region beg end)
-    (insert latex)))
-
-;;;###autoload
-(defun org-export-region-as-latex (beg end &optional body-only buffer)
-  "Convert region from BEG to END in `org-mode' buffer to LaTeX.
-If prefix arg BODY-ONLY is set, omit file header, footer, and table of
-contents, and only produce the region of converted text, useful for
-cut-and-paste operations.
-If BUFFER is a buffer or a string, use/create that buffer as a target
-of the converted LaTeX.  If BUFFER is the symbol `string', return the
-produced LaTeX as a string and leave no buffer behind.  For example,
-a Lisp program could call this function in the following way:
-
-  (setq latex (org-export-region-as-latex beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (interactive "r\nP")
-  (when (org-called-interactively-p 'any)
-    (setq buffer "*Org LaTeX Export*"))
-  (let ((transient-mark-mode t) (zmacs-regions t)
-       ext-plist rtn)
-    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
-    (goto-char end)
-    (set-mark (point)) ;; to activate the region
-    (goto-char beg)
-    (setq rtn (org-export-as-latex
-              nil ext-plist
-              buffer body-only))
-    (if (fboundp 'deactivate-mark) (deactivate-mark))
-    (if (and (org-called-interactively-p 'any) (bufferp rtn))
-       (switch-to-buffer-other-window rtn)
-      rtn)))
-
-;;;###autoload
-(defun org-export-as-latex (arg &optional ext-plist to-buffer body-only pub-dir)
-  "Export current buffer to a LaTeX file.
-If there is an active region, export only the region.  The prefix
-ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will be exported
-depending on `org-export-latex-low-levels'.  The default is to
-convert them as description lists.
-EXT-PLIST is a property list with external parameters overriding
-org-mode's default settings, but still inferior to file-local settings.
-When TO-BUFFER is non-nil, create a buffer with that name and export
-to that buffer.  If TO-BUFFER is the symbol `string', don't leave any
-buffer behind and just return the resulting LaTeX as a string, with
-no LaTeX header.
-When BODY-ONLY is set, don't produce the file header and footer,
-simply return the content of \\begin{document}...\\end{document},
-without even the \\begin{document} and \\end{document} commands.
-When PUB-DIR is set, use this as the publishing directory."
-  (interactive "P")
-  (when (and (not body-only) arg (listp arg)) (setq body-only t))
-  (run-hooks 'org-export-first-hook)
-
-  ;; Make sure we have a file name when we need it.
-  (when (and (not (or to-buffer body-only))
-            (not buffer-file-name))
-    (if (buffer-base-buffer)
-       (org-set-local 'buffer-file-name
-                      (with-current-buffer (buffer-base-buffer)
-                        buffer-file-name))
-      (error "Need a file name to be able to export")))
-
-  (message "Exporting to LaTeX...")
-  (org-unmodified
-   (let ((inhibit-read-only t))
-     (remove-text-properties (point-min) (point-max)
-                            '(:org-license-to-kill nil))))
-  (org-update-radio-target-regexp)
-  (org-export-latex-set-initial-vars ext-plist arg)
-  (setq org-export-opt-plist org-export-latex-options-plist
-       org-export-footnotes-data (org-footnote-all-labels 'with-defs)
-       org-export-footnotes-seen nil
-       org-export-latex-footmark-seen nil)
-  (org-install-letbind)
-  (run-hooks 'org-export-latex-after-initial-vars-hook)
-  (let* ((wcf (current-window-configuration))
-        (opt-plist
-         (org-export-process-option-filters org-export-latex-options-plist))
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        ;; Make sure the variable contains the updated values.
-        (org-export-latex-options-plist (setq org-export-opt-plist opt-plist))
-        ;; The following two are dynamically scoped into other
-        ;; routines below.
-        (org-current-export-dir
-         (or pub-dir (org-export-directory :html opt-plist)))
-        (org-current-export-file buffer-file-name)
-        (title (or (and subtree-p (org-export-get-title-from-subtree))
-                   (plist-get opt-plist :title)
-                   (and (not
-                         (plist-get opt-plist :skip-before-1st-heading))
-                        (org-export-grab-title-from-buffer))
-                   (and buffer-file-name
-                        (file-name-sans-extension
-                         (file-name-nondirectory buffer-file-name)))
-                   "No Title"))
-        (filename
-         (and (not to-buffer)
-              (concat
-               (file-name-as-directory
-                (or pub-dir
-                    (org-export-directory :LaTeX org-export-latex-options-plist)))
-               (file-name-sans-extension
-                (or (and subtree-p
-                         (org-entry-get rbeg "EXPORT_FILE_NAME" t))
-                    (file-name-nondirectory ;sans-extension
-                     (or buffer-file-name
-                         (error "Don't know which export file to use")))))
-               ".tex")))
-        (filename
-         (and filename
-              (if (equal (file-truename filename)
-                         (file-truename (or buffer-file-name "dummy.org")))
-                  (concat filename ".tex")
-                filename)))
-        (auto-insert nil); Avoid any auto-insert stuff for the new file
-        (TeX-master (boundp 'TeX-master))
-        (buffer (if to-buffer
-                    (if (eq to-buffer 'string)
-                        (get-buffer-create "*Org LaTeX Export*")
-                      (get-buffer-create to-buffer))
-                  (find-file-noselect filename)))
-        (odd org-odd-levels-only)
-        (header (org-export-latex-make-header title opt-plist))
-        (skip (cond (subtree-p nil)
-                    (region-p nil)
-                    (t (plist-get opt-plist :skip-before-1st-heading))))
-        (text (plist-get opt-plist :text))
-        (org-export-preprocess-hook
-         (cons
-          `(lambda () (org-set-local 'org-complex-heading-regexp
-                                     ,org-export-latex-complex-heading-re))
-          org-export-preprocess-hook))
-        (first-lines (if skip "" (org-export-latex-first-lines
-                                  opt-plist
-                                  (if subtree-p
-                                      (save-excursion
-                                        (goto-char rbeg)
-                                        (point-at-bol 2))
-                                    rbeg)
-                                  (if region-p rend))))
-        (coding-system (and (boundp 'buffer-file-coding-system)
-                            buffer-file-coding-system))
-        (coding-system-for-write (or org-export-latex-coding-system
-                                     coding-system))
-        (save-buffer-coding-system (or org-export-latex-coding-system
-                                       coding-system))
-        (region (buffer-substring
-                 (if region-p (region-beginning) (point-min))
-                 (if region-p (region-end) (point-max))))
-        (text
-         (and text (string-match "\\S-" text)
-              (org-export-preprocess-string
-               text
-               :emph-multiline t
-               :for-backend 'latex
-               :comments nil
-               :tags (plist-get opt-plist :tags)
-               :priority (plist-get opt-plist :priority)
-               :footnotes (plist-get opt-plist :footnotes)
-               :drawers (plist-get opt-plist :drawers)
-               :timestamps (plist-get opt-plist :timestamps)
-               :todo-keywords (plist-get opt-plist :todo-keywords)
-               :tasks (plist-get opt-plist :tasks)
-               :add-text nil
-               :skip-before-1st-heading skip
-               :select-tags nil
-               :exclude-tags nil
-               :LaTeX-fragments nil)))
-        (string-for-export
-         (org-export-preprocess-string
-          region
-          :emph-multiline t
-          :for-backend 'latex
-          :comments nil
-          :tags (plist-get opt-plist :tags)
-          :priority (plist-get opt-plist :priority)
-          :footnotes (plist-get opt-plist :footnotes)
-          :drawers (plist-get opt-plist :drawers)
-          :timestamps (plist-get opt-plist :timestamps)
-          :todo-keywords (plist-get opt-plist :todo-keywords)
-          :tasks (plist-get opt-plist :tasks)
-          :add-text (if (eq to-buffer 'string) nil text)
-          :skip-before-1st-heading skip
-          :select-tags (plist-get opt-plist :select-tags)
-          :exclude-tags (plist-get opt-plist :exclude-tags)
-          :LaTeX-fragments nil)))
-
-    (set-buffer buffer)
-    (erase-buffer)
-    (org-install-letbind)
-
-    (and (fboundp 'set-buffer-file-coding-system)
-        (set-buffer-file-coding-system coding-system-for-write))
-
-    ;; insert the header and initial document commands
-    (unless (or (eq to-buffer 'string) body-only)
-      (insert header))
-
-    ;; insert text found in #+TEXT
-    (when (and text (not (eq to-buffer 'string)))
-      (insert (org-export-latex-content
-              text '(lists tables fixed-width keywords))
-             "\n\n"))
-
-    ;; insert lines before the first headline
-    (unless (or skip (string-match "^\\*" first-lines))
-      (insert first-lines))
-
-    ;; export the content of headlines
-    (org-export-latex-global
-     (with-temp-buffer
-       (insert string-for-export)
-       (goto-char (point-min))
-       (when (re-search-forward "^\\(\\*+\\) " nil t)
-        (let* ((asters (length (match-string 1)))
-               (level (if odd (- asters 2) (- asters 1))))
-          (setq org-export-latex-add-level
-                (if odd (1- (/ (1+ asters) 2)) (1- asters)))
-          (org-export-latex-parse-global level odd)))))
-
-    ;; finalization
-    (unless body-only (insert "\n\\end{document}"))
-
-    ;; Attach description terms to the \item macro
-    (goto-char (point-min))
-    (while (re-search-forward "^[ \t]*\\\\item\\([ \t]+\\)\\[" nil t)
-      (delete-region (match-beginning 1) (match-end 1)))
-
-    ;; Relocate the table of contents
-    (goto-char (point-min))
-    (when (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\tableofcontents\\>[ \t]*\n?" nil t)
-       (replace-match ""))
-      (goto-char (point-min))
-      (and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
-          (replace-match "\\tableofcontents" t t)))
-
-    ;; Cleanup forced line ends in items where they are not needed
-    (goto-char (point-min))
-    (while (re-search-forward
-           "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*\n\\\\begin"
-           nil t)
-      (delete-region (match-beginning 1) (match-end 1)))
-    (goto-char (point-min))
-    (while (re-search-forward
-           "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*"
-           nil t)
-      (if (looking-at "[\n \t]+")
-         (replace-match "\n")))
-
-    ;; Ensure we have a final newline
-    (goto-char (point-max))
-    (or (eq (char-before) ?\n)
-       (insert ?\n))
-
-    (run-hooks 'org-export-latex-final-hook)
-    (if to-buffer
-       (unless (eq major-mode 'latex-mode) (latex-mode))
-      (save-buffer))
-    (org-export-latex-fix-inputenc)
-    (run-hooks 'org-export-latex-after-save-hook)
-    (goto-char (point-min))
-    (or (org-export-push-to-kill-ring "LaTeX")
-       (message "Exporting to LaTeX...done"))
-    (prog1
-       (if (eq to-buffer 'string)
-           (prog1 (buffer-substring (point-min) (point-max))
-             (kill-buffer (current-buffer)))
-         (current-buffer))
-      (set-window-configuration wcf))))
-
-;;;###autoload
-(defun org-export-as-pdf (arg &optional hidden ext-plist
-                             to-buffer body-only pub-dir)
-  "Export as LaTeX, then process through to PDF."
-  (interactive "P")
-  (message "Exporting to PDF...")
-  (let* ((wconfig (current-window-configuration))
-        (lbuf (org-export-as-latex arg ext-plist to-buffer body-only pub-dir))
-        (file (buffer-file-name lbuf))
-        (base (file-name-sans-extension (buffer-file-name lbuf)))
-        (pdffile (concat base ".pdf"))
-        (cmds (if (eq org-export-latex-listings 'minted)
-                  ;; automatically add -shell-escape when needed
-                  (mapcar (lambda (cmd)
-                            (replace-regexp-in-string
-                             "pdflatex " "pdflatex -shell-escape " cmd))
-                          org-latex-to-pdf-process)
-                org-latex-to-pdf-process))
-        (outbuf (get-buffer-create "*Org PDF LaTeX Output*"))
-        (bibtex-p (with-current-buffer lbuf
-                    (save-excursion
-                      (goto-char (point-min))
-                      (re-search-forward "\\\\bibliography{" nil t))))
-        cmd output-dir errors)
-    (with-current-buffer outbuf (erase-buffer))
-    (message (concat "Processing LaTeX file " file "..."))
-    (setq output-dir (file-name-directory file))
-    (with-current-buffer lbuf
-      (save-excursion
-       (if (and cmds (symbolp cmds))
-           (funcall cmds (shell-quote-argument file))
-         (while cmds
-           (setq cmd (pop cmds))
-           (cond
-            ((not (listp cmd))
-             (while (string-match "%b" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument base))
-                          t t cmd)))
-             (while (string-match "%f" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument file))
-                          t t cmd)))
-             (while (string-match "%o" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument output-dir))
-                          t t cmd)))
-             (shell-command cmd outbuf)))))))
-    (message (concat "Processing LaTeX file " file "...done"))
-    (setq errors (org-export-latex-get-error outbuf))
-    (if (not (file-exists-p pdffile))
-       (error (concat "PDF file " pdffile " was not produced"
-                      (if errors (concat ":" errors "") "")))
-      (set-window-configuration wconfig)
-      (when org-export-pdf-remove-logfiles
-       (dolist (ext org-export-pdf-logfiles)
-         (setq file (concat base "." ext))
-         (and (file-exists-p file) (delete-file file))))
-      (message (concat
-               "Exporting to PDF...done"
-               (if errors
-                   (concat ", with some errors:" errors)
-                 "")))
-      pdffile)))
-
-(defun org-export-latex-get-error (buf)
-  "Collect the kinds of errors that remain in pdflatex processing."
-  (with-current-buffer buf
-    (save-excursion
-      (goto-char (point-max))
-      (when (re-search-backward "^[ \t]*This is pdf.*?TeX.*?Version" nil t)
-       ;; OK, we are at the location of the final run
-       (let ((pos (point)) (errors "") (case-fold-search t))
-         (if (re-search-forward "Reference.*?undefined" nil t)
-             (setq errors (concat errors " [undefined reference]")))
-         (goto-char pos)
-         (if (re-search-forward "Citation.*?undefined" nil t)
-             (setq errors (concat errors " [undefined citation]")))
-         (goto-char pos)
-         (if (re-search-forward "Undefined control sequence" nil t)
-             (setq errors (concat errors " [undefined control sequence]")))
-         (and (org-string-nw-p errors) errors))))))
-
-;;;###autoload
-(defun org-export-as-pdf-and-open (arg)
-  "Export as LaTeX, then process through to PDF, and open."
-  (interactive "P")
-  (let ((pdffile (org-export-as-pdf arg)))
-    (if pdffile
-       (progn
-         (org-open-file pdffile)
-         (when org-export-kill-product-buffer-when-displayed
-           (kill-buffer (find-buffer-visiting
-                         (concat (file-name-sans-extension (buffer-file-name))
-                                 ".tex")))))
-      (error "PDF file was not produced"))))
-
-;;; Parsing functions:
-
-(defun org-export-latex-parse-global (level odd)
-  "Parse the current buffer recursively, starting at LEVEL.
-If ODD is non-nil, assume the buffer only contains odd sections.
-Return a list reflecting the document structure."
-  (save-excursion
-    (goto-char (point-min))
-    (let* ((cnt 0) output
-          (depth org-export-latex-sectioning-depth))
-      (while (org-re-search-forward-unprotected
-             (concat "^\\(\\(?:\\*\\)\\{"
-                     (number-to-string (+ (if odd 2 1) level))
-                     "\\}\\) \\(.*\\)$")
-             ;; make sure that there is no upper heading
-             (when (> level 0)
-               (save-excursion
-                 (save-match-data
-                   (org-re-search-forward-unprotected
-                    (concat "^\\(\\(?:\\*\\)\\{"
-                            (number-to-string level)
-                            "\\}\\) \\(.*\\)$") nil t)))) t)
-       (setq cnt (1+ cnt))
-       (let* ((pos (match-beginning 0))
-              (heading (match-string 2))
-              (nlevel (if odd (/ (+ 3 level) 2) (1+ level))))
-         (save-excursion
-           (narrow-to-region
-            (point)
-            (save-match-data
-              (if (org-re-search-forward-unprotected
-                   (concat "^\\(\\(?:\\*\\)\\{"
-                           (number-to-string (+ (if odd 2 1) level))
-                           "\\}\\) \\(.*\\)$") nil t)
-                  (match-beginning 0)
-                (point-max))))
-           (goto-char (point-min))
-           (setq output
-                 (append output
-                         (list
-                          (list
-                           `(pos . ,pos)
-                           `(level . ,nlevel)
-                           `(occur . ,cnt)
-                           `(heading . ,heading)
-                           `(content . ,(org-export-latex-parse-content))
-                           `(subcontent . ,(org-export-latex-parse-subcontent
-                                            level odd)))))))
-         (widen)))
-      (list output))))
-
-(defun org-export-latex-parse-content ()
-  "Extract the content of a section."
-  (let ((beg (point))
-       (end (if (org-re-search-forward-unprotected "^\\(\\*\\)+ .*$" nil t)
-                (progn (beginning-of-line) (point))
-              (point-max))))
-    (buffer-substring beg end)))
-
-(defun org-export-latex-parse-subcontent (level odd)
-  "Extract the subcontent of a section at LEVEL.
-If ODD Is non-nil, assume subcontent only contains odd sections."
-  (if (not (org-re-search-forward-unprotected
-           (concat "^\\(\\(?:\\*\\)\\{"
-                   (number-to-string (+ (if odd 4 2) level))
-                   "\\}\\) \\(.*\\)$")
-           nil t))
-      nil ; subcontent is nil
-    (org-export-latex-parse-global (+ (if odd 2 1) level) odd)))
-
-;;; Rendering functions:
-(defun org-export-latex-global (content)
-  "Export CONTENT to LaTeX.
-CONTENT is an element of the list produced by
-`org-export-latex-parse-global'."
-  (if (eq (car content) 'subcontent)
-      (mapc 'org-export-latex-sub (cdr content))
-    (org-export-latex-sub (car content))))
-
-(defun org-export-latex-sub (subcontent)
-  "Export the list SUBCONTENT to LaTeX.
-SUBCONTENT is an alist containing information about the headline
-and its content."
-  (let ((num (plist-get org-export-latex-options-plist :section-numbers)))
-    (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
-
-(defun org-export-latex-subcontent (subcontent num)
-  "Export each cell of SUBCONTENT to LaTeX.
-If NUM is non-nil export numbered sections, otherwise use unnumbered
-sections.  If NUM is an integer, export the highest NUM levels as
-numbered sections and lower levels as unnumbered sections."
-  (let* ((heading (cdr (assoc 'heading subcontent)))
-        (level (- (cdr (assoc 'level subcontent))
-                  org-export-latex-add-level))
-        (occur (number-to-string (cdr (assoc 'occur subcontent))))
-        (content (cdr (assoc 'content subcontent)))
-        (subcontent (cadr (assoc 'subcontent subcontent)))
-        (label (org-get-text-property-any 0 'target heading))
-        (label-list (cons label (cdr (assoc label
-                                            org-export-target-aliases))))
-        (sectioning org-export-latex-sectioning)
-        (depth org-export-latex-sectioning-depth)
-        main-heading sub-heading ctnt)
-    (when (symbolp (car sectioning))
-      (setq sectioning (funcall (car sectioning) level heading))
-      (when sectioning
-       (setq heading (car sectioning)
-             sectioning (cdr sectioning)
-             ;; target property migh have changed...
-             label (org-get-text-property-any 0 'target heading)
-             label-list (cons label (cdr (assoc label
-                                                org-export-target-aliases)))))
-      (if sectioning (setq sectioning (make-list 10 sectioning)))
-      (setq depth (if sectioning 10000 0)))
-    (if (string-match "[ \t]*\\\\\\\\[ \t]*" heading)
-       (setq main-heading (substring heading 0 (match-beginning 0))
-             sub-heading (substring heading (match-end 0))))
-    (setq heading (org-export-latex-fontify-headline heading)
-         sub-heading (and sub-heading
-                          (org-export-latex-fontify-headline sub-heading))
-         main-heading (and main-heading
-                           (org-export-latex-fontify-headline main-heading)))
-    (cond
-     ;; Normal conversion
-     ((<= level depth)
-      (let* ((sec (nth (1- level) sectioning))
-            (num (if (integerp num)
-                     (>= num level)
-                   num))
-            start end)
-       (if (consp (cdr sec))
-           (setq start (nth (if num 0 2) sec)
-                 end (nth (if num 1 3) sec))
-         (setq start (if num (car sec) (cdr sec))))
-       (insert (format start (if main-heading main-heading heading)
-                       (or sub-heading "")))
-       (insert "\n")
-       (when label
-         (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
-                            label-list "\n") "\n"))
-       (insert (org-export-latex-content content))
-       (cond ((stringp subcontent) (insert subcontent))
-             ((listp subcontent)
-              (while (org-looking-back "\n\n") (backward-delete-char 1))
-              (org-export-latex-sub subcontent)))
-       (when (and end (string-match "[^ \t]" end))
-         (let ((hook (org-get-text-property-any 0 'org-insert-hook end)))
-           (and (functionp hook) (funcall hook)))
-         (insert end "\n"))))
-     ;; At a level under the hl option: we can drop this subsection
-     ((> level depth)
-      (cond ((eq org-export-latex-low-levels 'description)
-            (if (string-match "% ends low level$"
-                              (buffer-substring (point-at-bol 0) (point)))
-                (delete-region (point-at-bol 0) (point))
-              (insert "\\begin{description}\n"))
-            (insert (format "\n\\item[%s]%s~\n"
-                            heading
-                            (if label (format "\\label{%s}" label) "")))
-            (insert (org-export-latex-content content))
-            (cond ((stringp subcontent) (insert subcontent))
-                  ((listp subcontent) (org-export-latex-sub subcontent)))
-            (insert "\\end{description} % ends low level\n"))
-           ((memq org-export-latex-low-levels '(itemize enumerate))
-            (if (string-match "% ends low level$"
-                              (buffer-substring (point-at-bol 0) (point)))
-                (delete-region (point-at-bol 0) (point))
-              (insert (format "\\begin{%s}\n"
-                              (symbol-name org-export-latex-low-levels))))
-            (let ((ctnt (org-export-latex-content content)))
-              (insert (format (if (not (equal (replace-regexp-in-string "\n" "" ctnt) ""))
-                                  "\n\\item %s\\\\\n%s%%"
-                                "\n\\item %s\n%s%%")
-                              heading
-                              (if label (format "\\label{%s}" label) "")))
-              (insert ctnt))
-            (cond ((stringp subcontent) (insert subcontent))
-                  ((listp subcontent) (org-export-latex-sub subcontent)))
-            (insert (format "\\end{%s} %% ends low level\n"
-                            (symbol-name org-export-latex-low-levels))))
-
-           ((and (listp org-export-latex-low-levels)
-                 org-export-latex-low-levels)
-            (if (string-match "% ends low level$"
-                              (buffer-substring (point-at-bol 0) (point)))
-                (delete-region (point-at-bol 0) (point))
-              (insert (car org-export-latex-low-levels) "\n"))
-            (insert (format (nth 2 org-export-latex-low-levels)
-                            heading
-                            (if label (format "\\label{%s}" label) "")))
-            (insert (org-export-latex-content content))
-            (cond ((stringp subcontent) (insert subcontent))
-                  ((listp subcontent) (org-export-latex-sub subcontent)))
-            (insert (nth 1 org-export-latex-low-levels)
-                    " %% ends low level\n"))
-
-           ((stringp org-export-latex-low-levels)
-            (insert (format org-export-latex-low-levels heading) "\n")
-            (when label (insert (format "\\label{%s}\n" label)))
-            (insert (org-export-latex-content content))
-            (cond ((stringp subcontent) (insert subcontent))
-                  ((listp subcontent) (org-export-latex-sub subcontent)))))))))
-
-;;; Exporting internals:
-(defun org-export-latex-set-initial-vars (ext-plist level)
-  "Store org local variables required for LaTeX export.
-EXT-PLIST is an optional additional plist.
-LEVEL indicates the default depth for export."
-  (setq org-export-latex-todo-keywords-1 org-todo-keywords-1
-       org-export-latex-done-keywords org-done-keywords
-       org-export-latex-not-done-keywords org-not-done-keywords
-       org-export-latex-complex-heading-re org-complex-heading-regexp
-       org-export-latex-display-custom-times org-display-custom-times
-       org-export-latex-all-targets-re
-       (org-make-target-link-regexp (org-all-targets))
-       org-export-latex-options-plist
-       (org-combine-plists (org-default-export-plist) ext-plist
-                           (org-infile-export-plist))
-       org-export-latex-class
-       (or (and (org-region-active-p)
-                (save-excursion
-                  (goto-char (region-beginning))
-                  (and (looking-at org-complex-heading-regexp)
-                       (org-entry-get nil "LaTeX_CLASS" 'selective))))
-           (save-excursion
-             (save-restriction
-               (widen)
-               (goto-char (point-min))
-               (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([-/a-zA-Z]+\\)" nil t)
-                    (match-string 1))))
-           (plist-get org-export-latex-options-plist :latex-class)
-           org-export-latex-default-class)
-       org-export-latex-class-options
-       (or (and (org-region-active-p)
-                (save-excursion
-                  (goto-char (region-beginning))
-                  (and (looking-at org-complex-heading-regexp)
-                       (org-entry-get nil "LaTeX_CLASS_OPTIONS" 'selective))))
-           (save-excursion
-             (save-restriction
-               (widen)
-               (goto-char (point-min))
-               (and (re-search-forward "^#\\+LaTeX_CLASS_OPTIONS:[ \t]*\\(.*?\\)[ \t]*$" nil t)
-                    (match-string 1))))
-           (plist-get org-export-latex-options-plist :latex-class-options))
-       org-export-latex-class
-       (or (car (assoc org-export-latex-class org-export-latex-classes))
-           (error "No definition for class `%s' in `org-export-latex-classes'"
-                  org-export-latex-class))
-       org-export-latex-header
-       (cadr (assoc org-export-latex-class org-export-latex-classes))
-       org-export-latex-sectioning
-       (cddr (assoc org-export-latex-class org-export-latex-classes))
-       org-export-latex-sectioning-depth
-       (or level
-           (let ((hl-levels
-                  (plist-get org-export-latex-options-plist :headline-levels))
-                 (sec-depth (length org-export-latex-sectioning)))
-             (if (> hl-levels sec-depth) sec-depth hl-levels))))
-  (when (and org-export-latex-class-options
-            (string-match "\\S-" org-export-latex-class-options)
-            (string-match "^[ \t]*\\(\\\\documentclass\\)\\(\\[.*?\\]\\)?"
-                          org-export-latex-header))
-    (setq org-export-latex-header
-         (concat (substring org-export-latex-header 0 (match-end 1))
-                 org-export-latex-class-options
-                 (substring org-export-latex-header (match-end 0))))))
-
-(defvar org-export-latex-format-toc-function
-  'org-export-latex-format-toc-default
-  "The function formatting returning the string to create the table of contents.
-The function mus take one parameter, the depth of the table of contents.")
-
-(defun org-export-latex-make-header (title opt-plist)
-  "Make the LaTeX header and return it as a string.
-TITLE is the current title from the buffer or region.
-OPT-PLIST is the options plist for current buffer."
-  (let ((toc (plist-get opt-plist :table-of-contents))
-       (author (org-export-apply-macros-in-string
-                (plist-get opt-plist :author)))
-       (email (replace-regexp-in-string
-               "_" "\\\\_"
-               (org-export-apply-macros-in-string
-                (plist-get opt-plist :email))))
-       (description (org-export-apply-macros-in-string
-                     (plist-get opt-plist :description)))
-       (keywords (org-export-apply-macros-in-string
-                  (plist-get opt-plist :keywords))))
-    (concat
-     (if (plist-get opt-plist :time-stamp-file)
-        (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
-     ;; insert LaTeX custom header and packages from the list
-     (org-splice-latex-header
-      (org-export-apply-macros-in-string org-export-latex-header)
-      org-export-latex-default-packages-alist
-      org-export-latex-packages-alist nil
-      (org-export-apply-macros-in-string
-       (plist-get opt-plist :latex-header-extra)))
-     ;; append another special variable
-     (org-export-apply-macros-in-string org-export-latex-append-header)
-     ;; define alert if not yet defined
-     "\n\\providecommand{\\alert}[1]{\\textbf{#1}}"
-     ;; insert the title
-     (format
-      "\n\n\\title{%s}\n"
-      (org-export-latex-fontify-headline title))
-     ;; insert author info
-     (if (plist-get opt-plist :author-info)
-        (format "\\author{%s%s}\n"
-                (org-export-latex-fontify-headline (or author user-full-name))
-                (if (and (plist-get opt-plist :email-info) email
-                         (string-match "\\S-" email))
-                    (format "\\thanks{%s}" email)
-                  ""))
-       (format "%%\\author{%s}\n"
-              (org-export-latex-fontify-headline (or author user-full-name))))
-     ;; insert the date
-     (format "\\date{%s}\n"
-            (format-time-string
-             (or (plist-get opt-plist :date)
-                 org-export-latex-date-format)))
-     ;; add some hyperref options
-     (format org-export-latex-hyperref-options-format
-            (org-export-latex-fontify-headline keywords)
-            (org-export-latex-fontify-headline description)
-            (org-version))
-     ;; beginning of the document
-     "\n\\begin{document}\n\n"
-     ;; insert the title command
-     (when (string-match "\\S-" title)
-       (if (string-match "%s" org-export-latex-title-command)
-          (format org-export-latex-title-command title)
-        org-export-latex-title-command))
-     "\n\n"
-     ;; table of contents
-     (when (and org-export-with-toc
-               (plist-get opt-plist :section-numbers))
-       (funcall org-export-latex-format-toc-function
-               (cond ((numberp toc)
-                      (min toc (plist-get opt-plist :headline-levels)))
-                     (toc  (plist-get opt-plist :headline-levels))))))))
-
-(defun org-export-latex-format-toc-default (depth)
-  (when depth
-    (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
-           depth)))
-
-(defun org-export-latex-first-lines (opt-plist &optional beg end)
-  "Export the first lines before first headline.
-If BEG is non-nil, it is the beginning of the region.
-If END is non-nil, it is the end of the region."
-  (save-excursion
-    (goto-char (or beg (point-min)))
-    (let* ((pt (point))
-          (end (if (re-search-forward
-                    (concat "^" (org-get-limited-outline-regexp)) end t)
-                   (goto-char (match-beginning 0))
-                 (goto-char (or end (point-max))))))
-      (prog1
-         (org-export-latex-content
-          (org-export-preprocess-string
-           (buffer-substring pt end)
-           :for-backend 'latex
-           :emph-multiline t
-           :add-text nil
-           :comments nil
-           :skip-before-1st-heading nil
-           :LaTeX-fragments nil
-           :timestamps (plist-get opt-plist :timestamps)
-           :footnotes (plist-get opt-plist :footnotes)))
-       (org-unmodified
-        (let ((inhibit-read-only t)
-              (limit (max pt (1- end))))
-          (add-text-properties pt limit
-                               '(:org-license-to-kill t))
-          (save-excursion
-            (goto-char pt)
-            (while (re-search-forward "^[ \t]*#\\+.*\n?" limit t)
-              (let ((case-fold-search t))
-                (unless (org-string-match-p
-                         "^[ \t]*#\\+\\(attr_\\|caption\\>\\|label\\>\\)"
-                         (match-string 0))
-                  (remove-text-properties (match-beginning 0) (match-end 0)
-                                          '(:org-license-to-kill t))))))))))))
-
-
-(defvar org-export-latex-header-defs nil
-  "The header definitions that might be used in the LaTeX body.")
-
-(defun org-export-latex-content (content &optional exclude-list)
-  "Convert CONTENT string to LaTeX.
-Don't perform conversions that are in EXCLUDE-LIST.  Recognized
-conversion types are: quotation-marks, emphasis, sub-superscript,
-links, keywords, lists, tables, fixed-width"
-  (with-temp-buffer
-    (org-install-letbind)
-    (insert content)
-    (unless (memq 'timestamps exclude-list)
-      (org-export-latex-time-stamps))
-    (unless (memq 'quotation-marks exclude-list)
-      (org-export-latex-quotation-marks))
-    (unless (memq 'emphasis exclude-list)
-      (when (plist-get org-export-latex-options-plist :emphasize)
-       (org-export-latex-fontify)))
-    (unless (memq 'sub-superscript exclude-list)
-      (org-export-latex-special-chars
-       (plist-get org-export-latex-options-plist :sub-superscript)))
-    (unless (memq 'links exclude-list)
-      (org-export-latex-links))
-    (unless (memq 'keywords exclude-list)
-      (org-export-latex-keywords))
-    (unless (memq 'lists exclude-list)
-      (org-export-latex-lists))
-    (unless (memq 'tables exclude-list)
-      (org-export-latex-tables
-       (plist-get org-export-latex-options-plist :tables)))
-    (unless (memq 'fixed-width exclude-list)
-      (org-export-latex-fixed-width
-       (plist-get org-export-latex-options-plist :fixed-width)))
-    ;; return string
-    (buffer-substring (point-min) (point-max))))
-
-(defun org-export-latex-protect-string (s)
-  "Add the org-protected property to string S."
-  (add-text-properties 0 (length s) '(org-protected t) s) s)
-
-(defun org-export-latex-protect-char-in-string (char-list string)
-  "Add org-protected text-property to char from CHAR-LIST in STRING."
-  (with-temp-buffer
-    (save-match-data
-      (insert string)
-      (goto-char (point-min))
-      (while (re-search-forward (regexp-opt char-list) nil t)
-       (add-text-properties (match-beginning 0)
-                            (match-end 0) '(org-protected t)))
-      (buffer-string))))
-
-(defun org-export-latex-keywords-maybe (&optional remove-list)
-  "Maybe remove keywords depending on rules in REMOVE-LIST."
-  (goto-char (point-min))
-  (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
-       (case-fold-search nil)
-       (todo-markup org-export-latex-todo-keyword-markup)
-       fmt)
-    ;; convert TODO keywords
-    (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
-      (if (plist-get remove-list :todo)
-         (replace-match "")
-       (setq fmt (cond
-                  ((stringp todo-markup) todo-markup)
-                  ((and (consp todo-markup) (stringp (car todo-markup)))
-                   (if (member (match-string 1) org-export-latex-done-keywords)
-                       (cdr todo-markup) (car todo-markup)))
-                  (t (cdr (or (assoc (match-string 1) todo-markup)
-                              (car todo-markup))))))
-       (replace-match (org-export-latex-protect-string
-                       (format fmt (match-string 1))) t t)))
-    ;; convert priority string
-    (when (re-search-forward "\\[\\\\#.\\]" nil t)
-      (if (plist-get remove-list :priority)
-         (replace-match "")
-       (replace-match (format "\\textbf{%s}" (match-string 0)) t t)))
-    ;; convert tags
-    (when (re-search-forward "\\(:[a-zA-Z0-9_@#%]+\\)+:" nil t)
-      (if (or (not org-export-with-tags)
-             (plist-get remove-list :tags))
-         (replace-match "")
-       (replace-match
-        (org-export-latex-protect-string
-         (format org-export-latex-tag-markup
-                 (save-match-data
-                   (replace-regexp-in-string
-                    "\\([_#]\\)" "\\\\\\1" (match-string 0)))))
-        t t)))))
-
-(defun org-export-latex-fontify-headline (string)
-  "Fontify special words in STRING."
-  (with-temp-buffer
-    ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
-    ;; the beginning of the buffer - inserting "\n" is safe here though.
-    (insert "\n" string)
-
-    ;; Preserve math snippets
-
-    (let* ((matchers (plist-get org-format-latex-options :matchers))
-          (re-list org-latex-regexps)
-          beg end re e m n block off)
-      ;; Check the different regular expressions
-      (while (setq e (pop re-list))
-       (setq m (car e) re (nth 1 e) n (nth 2 e)
-             block (if (nth 3 e) "\n\n" ""))
-       (setq off (if (member m '("$" "$1")) 1 0))
-       (when (and (member m matchers) (not (equal m "begin")))
-         (goto-char (point-min))
-         (while (re-search-forward re nil t)
-           (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
-           (add-text-properties beg end
-                                '(org-protected t org-latex-math t))))))
-
-    ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
-    (goto-char (point-min))
-    (let ((case-fold-search nil))
-      (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
-       (unless (eq (char-before (match-beginning 1)) ?\\)
-         (org-if-unprotected-1
-          (replace-match (org-export-latex-protect-string
-                          (concat "\\" (match-string 1)
-                                  "{}")) t t)))))
-    (goto-char (point-min))
-    (let ((re (concat "\\\\\\([a-zA-Z]+\\)"
-                     "\\(?:<[^<>\n]*>\\)*"
-                     "\\(?:\\[[^][\n]*?\\]\\)*"
-                     "\\(?:<[^<>\n]*>\\)*"
-                     "\\("
-                     (org-create-multibrace-regexp "{" "}" 3)
-                     "\\)\\{1,3\\}")))
-      (while (re-search-forward re nil t)
-       (unless (or
-                ;; check for comment line
-                (save-excursion (goto-char (match-beginning 0))
-                                (org-in-indented-comment-line))
-                ;; Check if this is a defined entity, so that is may need conversion
-                (org-entity-get (match-string 1)))
-         (add-text-properties (match-beginning 0) (match-end 0)
-                              '(org-protected t)))))
-    (when (plist-get org-export-latex-options-plist :emphasize)
-      (org-export-latex-fontify))
-    (org-export-latex-time-stamps)
-    (org-export-latex-quotation-marks)
-    (org-export-latex-keywords-maybe)
-    (org-export-latex-special-chars
-     (plist-get org-export-latex-options-plist :sub-superscript))
-    (org-export-latex-links)
-    (org-trim (buffer-string))))
-
-(defun org-export-latex-time-stamps ()
-  "Format time stamps."
-  (goto-char (point-min))
-  (let ((org-display-custom-times org-export-latex-display-custom-times))
-    (while (re-search-forward org-ts-regexp-both nil t)
-      (org-if-unprotected-at (1- (point))
-       (replace-match
-        (org-export-latex-protect-string
-         (format (if (string= "<" (substring (match-string 0) 0 1))
-                     org-export-latex-timestamp-markup
-                   org-export-latex-timestamp-inactive-markup)
-                 (substring (org-translate-time (match-string 0)) 1 -1)))
-        t t)))))
-
-(defun org-export-latex-quotation-marks ()
-  "Export quotation marks depending on language conventions."
-  (mapc (lambda(l)
-         (goto-char (point-min))
-         (while (re-search-forward (car l) nil t)
-           (let ((rpl (concat (match-string 1)
-                              (org-export-latex-protect-string
-                               (copy-sequence (cdr l))))))
-             (org-if-unprotected-1
-              (replace-match rpl t t)))))
-       (cdr (or (assoc (plist-get org-export-latex-options-plist :language)
-                       org-export-latex-quotes)
-                ;; falls back on english
-                (assoc "en" org-export-latex-quotes)))))
-
-(defun org-export-latex-special-chars (sub-superscript)
-  "Export special characters to LaTeX.
-If SUB-SUPERSCRIPT is non-nil, convert \\ and ^.
-See the `org-export-latex.el' code for a complete conversion table."
-  (goto-char (point-min))
-  (mapc (lambda(c)
-         (goto-char (point-min))
-         (while (re-search-forward c nil t)
-           ;; Put the point where to check for org-protected
-           (unless (get-text-property (match-beginning 2) 'org-protected)
-             (cond ((member (match-string 2) '("\\$" "$"))
-                    (if (equal (match-string 2) "\\$")
-                        nil
-                      (replace-match "\\$" t t)))
-                   ((member (match-string 2) '("&" "%" "#"))
-                    (if (equal (match-string 1) "\\")
-                        (replace-match (match-string 2) t t)
-                      (replace-match (concat (match-string 1) "\\"
-                                             (match-string 2)) t t)
-                      (backward-char 1)))
-                   ((equal (match-string 2) "...")
-                    (replace-match
-                     (concat (match-string 1)
-                             (org-export-latex-protect-string "\\ldots{}")) t t))
-                   ((equal (match-string 2) "~")
-                    (cond ((equal (match-string 1) "\\") nil)
-                          ((eq 'org-link (get-text-property 0 'face (match-string 2)))
-                           (replace-match (concat (match-string 1) "\\~") t t))
-                          (t (replace-match
-                              (org-export-latex-protect-string
-                               (concat (match-string 1) "\\~{}")) t t))))
-                   ((member (match-string 2) '("{" "}"))
-                    (unless (save-match-data (org-inside-latex-math-p))
-                      (if (equal (match-string 1) "\\")
-                          (replace-match (match-string 2) t t)
-                        (replace-match (concat (match-string 1) "\\"
-                                               (match-string 2)) t t)))))
-             (unless (save-match-data (or (org-inside-latex-math-p) (org-at-table-p)))
-               (cond ((equal (match-string 2) "\\")
-                      (replace-match (or (save-match-data
-                                           (org-export-latex-treat-backslash-char
-                                            (match-string 1)
-                                            (or (match-string 3) "")))
-                                         "") t t)
-                      (when (and (get-text-property (1- (point)) 'org-entity)
-                                 (looking-at "{}"))
-                        ;; OK, this was an entity replacement, and the user
-                        ;; had terminated the entity with {}.  Make sure
-                        ;; {} is protected as well, and remove the extra {}
-                        ;; inserted by the conversion.
-                        (put-text-property (point) (+ 2 (point)) 'org-protected t)
-                        (if (save-excursion (goto-char (max (- (point) 2) (point-min)))
-                                            (looking-at "{}"))
-                            (replace-match ""))
-                        (forward-char 2))
-                      (backward-char 1))
-                     ((member (match-string 2) '("_" "^"))
-                      (replace-match (or (save-match-data
-                                           (org-export-latex-treat-sub-super-char
-                                            sub-superscript
-                                            (match-string 2)
-                                            (match-string 1)
-                                            (match-string 3))) "") t t)
-                      (backward-char 1)))))))
-       '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
-         "\\(\\(\\\\?\\$\\)\\)"
-         "\\([a-zA-Z0-9()]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-zA-Z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-zA-Z0-9]+}\\|([a-zA-Z0-9]+)\\)"
-         "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|\\([&#%{}\"]\\|[a-zA-Z][a-zA-Z0-9]*\\)\\)"
-         "\\(^\\|.\\)\\([&#%{}~]\\|\\.\\.\\.\\)"
-         ;; (?\< . "\\textless{}")
-         ;; (?\> . "\\textgreater{}")
-         )))
-
-(defun org-inside-latex-math-p ()
-  (get-text-property (point) 'org-latex-math))
-
-(defun org-export-latex-treat-sub-super-char
-  (subsup char string-before string-after)
-  "Convert the \"_\" and \"^\" characters to LaTeX.
-SUBSUP corresponds to the ^: option in the #+OPTIONS line.
-Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
-  (cond ((equal string-before "\\")
-        (concat string-before char string-after))
-       ((and (string-match "\\S-+" string-after))
-        ;; this is part of a math formula
-        (cond ((eq 'org-link (get-text-property 0 'face char))
-               (concat string-before "\\" char string-after))
-              ((save-match-data (org-inside-latex-math-p))
-               (if subsup
-                   (cond ((eq 1 (length string-after))
-                          (concat string-before char string-after))
-                         ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
-                          (format "%s%s{%s}" string-before char
-                                  (match-string 1 string-after))))))
-              ((and (> (length string-after) 1)
-                    (or (eq subsup t)
-                        (and (equal subsup '{}) (eq (string-to-char string-after) ?\{)))
-                    (or (string-match "[{]?\\([^}]+\\)[}]?" string-after)
-                        (string-match "[(]?\\([^)]+\\)[)]?" string-after)))
-
-               (org-export-latex-protect-string
-                (format "%s$%s{%s}$" string-before char
-                        (if (and (> (match-end 1) (1+ (match-beginning 1)))
-                                 (not (equal (substring string-after 0 2) "{\\")))
-                            (concat "\\mathrm{" (match-string 1 string-after) "}")
-                          (match-string 1 string-after)))))
-              ((eq subsup t) (concat string-before "$" char string-after "$"))
-              (t (org-export-latex-protect-string
-                  (concat string-before "\\" char "{}" string-after)))))
-       (t (org-export-latex-protect-string
-           (concat string-before "\\" char "{}" string-after)))))
-
-(defun org-export-latex-treat-backslash-char (string-before string-after)
-  "Convert the \"$\" special character to LaTeX.
-The conversion is made depending of STRING-BEFORE and STRING-AFTER."
-  (let  ((ass (org-entity-get string-after)))
-    (cond
-     (ass (org-add-props
-             (if (nth 2 ass)
-                 (concat string-before
-                         (org-export-latex-protect-string
-                          (concat "$" (nth 1 ass) "$")))
-               (concat string-before (org-export-latex-protect-string
-                                      (nth 1 ass))))
-             nil 'org-entity t))
-     ((and (not (string-match "^[ \n\t]" string-after))
-          (not (string-match "[ \t]\\'\\|^" string-before)))
-      ;; backslash is inside a word
-      (concat string-before
-             (org-export-latex-protect-string
-              (concat "\\textbackslash{}" string-after))))
-     ((not (or (equal string-after "")
-              (string-match "^[ \t\n]" string-after)))
-      ;; backslash might escape a character (like \#) or a user TeX
-      ;; macro (like \setcounter)
-      (concat string-before
-             (org-export-latex-protect-string (concat "\\" string-after))))
-     ((and (string-match "^[ \t\n]" string-after)
-          (string-match "[ \t\n]\\'" string-before))
-      ;; backslash is alone, convert it to $\backslash$
-      (org-export-latex-protect-string
-       (concat string-before "\\textbackslash{}" string-after)))
-     (t (org-export-latex-protect-string
-        (concat string-before "\\textbackslash{}" string-after))))))
-
-(defun org-export-latex-keywords ()
-  "Convert special keywords to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward org-export-latex-special-keyword-regexp nil t)
-    (replace-match (format org-export-latex-timestamp-keyword-markup
-                          (match-string 0)) t t)
-    (save-excursion
-      (beginning-of-line 1)
-      (unless (looking-at ".*\n[ \t]*\n")
-       (end-of-line 1)
-       (insert "\n")))))
-
-(defun org-export-latex-fixed-width (opt)
-  "When OPT is non-nil convert fixed-width sections to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t)
-    (unless (get-text-property (point) 'org-example)
-      (if opt
-         (progn (goto-char (match-beginning 0))
-                (insert "\\begin{verbatim}\n")
-                (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
-                  (replace-match (concat (match-string 1)
-                                         (match-string 2)) t t)
-                  (forward-line))
-                (insert "\\end{verbatim}\n"))
-       (progn (goto-char (match-beginning 0))
-              (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
-                (replace-match (concat "%" (match-string 1)
-                                       (match-string 2)) t t)
-                (forward-line)))))))
-
-(defvar org-table-last-alignment) ; defined in org-table.el
-(defvar org-table-last-column-widths) ; defined in org-table.el
-(declare-function orgtbl-to-latex "org-table" (table params) t)
-(defun org-export-latex-tables (insert)
-  "Convert tables to LaTeX and INSERT it."
-  ;; First, get the table.el tables
-  (goto-char (point-min))
-  (while (re-search-forward "^[ \t]*\\(\\+-[-+]*\\+\\)[ \t]*\n[ \t]*|" nil t)
-    (org-if-unprotected
-     (require 'table)
-     (org-export-latex-convert-table.el-table)))
-
-  ;; And now the Org-mode tables
-  (goto-char (point-min))
-  (while (re-search-forward "^\\([ \t]*\\)|" nil t)
-    (org-if-unprotected-at (1- (point))
-      (org-table-align)
-      (let* ((beg (org-table-begin))
-             (end (org-table-end))
-             (raw-table (buffer-substring beg end))
-             (org-table-last-alignment (copy-sequence org-table-last-alignment))
-             (org-table-last-column-widths (copy-sequence
-                                            org-table-last-column-widths))
-             fnum fields line lines olines gr colgropen line-fmt align
-             caption width shortn label attr hfmt floatp placement
-            longtblp tblenv tabular-env)
-        (if org-export-latex-tables-verbatim
-            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
-                                "\\end{verbatim}\n")))
-              (apply 'delete-region (list beg end))
-              (insert (org-export-latex-protect-string tbl)))
-          (progn
-            (setq caption (org-find-text-property-in-string
-                           'org-caption raw-table)
-                 shortn (org-find-text-property-in-string
-                         'org-caption-shortn raw-table)
-                  attr (org-find-text-property-in-string
-                        'org-attributes raw-table)
-                  label (org-find-text-property-in-string
-                         'org-label raw-table)
-                  longtblp (and attr (stringp attr)
-                                (string-match "\\<longtable\\>" attr))
-                 tblenv (if (and attr (stringp attr))
-                            (cond ((string-match "\\<sidewaystable\\>" attr)
-                                   "sidewaystable")
-                                  ((or (string-match (regexp-quote "table*") attr)
-                                       (string-match "\\<multicolumn\\>" attr))
-                                   "table*")
-                                  (t "table"))
-                          "table")
-                 tabular-env
-                 (if (and attr (stringp attr)
-                          (string-match "\\(tabular.\\)" attr))
-                     (match-string 1 attr)
-                   org-export-latex-tabular-environment)
-                 width (and attr (stringp attr)
-                             (string-match "\\<width=\\([^ \t\n\r]+\\)" attr)
-                             (match-string 1 attr))
-                  align (and attr (stringp attr)
-                             (string-match "\\<align=\\([^ \t\n\r]+\\)" attr)
-                             (match-string 1 attr))
-                 hfmt (and attr (stringp attr)
-                           (string-match "\\<hfmt=\\(\\S-+\\)" attr)
-                           (match-string 1 attr))
-                  floatp (or caption label (string= "table*" tblenv))
-                 placement     (if (and attr
-                                        (stringp attr)
-                                        (string-match "[ \t]*\\<placement=\\(\\S-+\\)" attr))
-                                   (match-string 1 attr)
-                                 (concat
-                                  "[" org-latex-default-figure-position "]")))
-           (setq caption (and caption (org-export-latex-fontify-headline caption)))
-            (setq lines (org-split-string raw-table "\n"))
-            (apply 'delete-region (list beg end))
-            (when org-export-table-remove-special-lines
-              (setq lines (org-table-clean-before-export lines 'maybe-quoted)))
-            (when org-table-clean-did-remove-column
-             (pop org-table-last-alignment)
-             (pop org-table-last-column-widths))
-            ;; make a format string to reflect alignment
-            (setq olines lines)
-            (while (and (not line-fmt) (setq line (pop olines)))
-              (unless (string-match "^[ \t]*|-" line)
-                (setq fields (org-split-string line "[ \t]*|[ \t]*"))
-                (setq fnum (make-vector (length fields) 0))
-                (setq line-fmt
-                      (mapconcat
-                       (lambda (x)
-                         (setq gr (pop org-table-colgroup-info))
-                         (format "%s%%s%s"
-                                 (cond ((eq gr :start)
-                                        (prog1 (if colgropen "|" "|")
-                                          (setq colgropen t)))
-                                       ((eq gr :startend)
-                                        (prog1 (if colgropen "|" "|")
-                                          (setq colgropen nil)))
-                                       (t ""))
-                                 (if (memq gr '(:end :startend))
-                                     (progn (setq colgropen nil) "|")
-                                   "")))
-                       fnum ""))))
-            ;; fix double || in line-fmt
-            (setq line-fmt (replace-regexp-in-string "||" "|" line-fmt))
-            ;; maybe remove the first and last "|"
-            (when (and (not org-export-latex-tables-column-borders)
-                       (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
-              (setq line-fmt (match-string 2 line-fmt)))
-            ;; format alignment
-            (unless align
-              (setq align (apply 'format
-                                 (cons line-fmt
-                                       (mapcar (lambda (x) (if x "r" "l"))
-                                               org-table-last-alignment)))))
-            ;; prepare the table to send to orgtbl-to-latex
-            (setq lines
-                  (mapcar
-                   (lambda(elem)
-                     (or (and (string-match "[ \t]*|-+" elem) 'hline)
-                         (org-split-string
-                         (progn (set-text-properties 0 (length elem) nil elem)
-                                (org-trim elem)) "|")))
-                   lines))
-            (when insert
-              (insert (org-export-latex-protect-string
-                       (concat
-                        (if longtblp
-                            (concat "\\begin{longtable}{" align "}\n")
-                          (if floatp
-                             (format "\\begin{%s}%s\n" tblenv placement)))
-                        (if (and floatp org-export-latex-table-caption-above)
-                            (format
-                             "\\caption%s{%s} %s"
-                             (if shortn (concat "[" shortn "]") "")
-                             (or caption "")
-                            (if label (format "\\label{%s}" label) "")))
-                       (if (and longtblp caption org-export-latex-table-caption-above)
-                           "\\\\\n" "\n")
-                        (if (and org-export-latex-tables-centered (not longtblp))
-                            "\\begin{center}\n")
-                        (if (not longtblp)
-                           (format "\\begin{%s}%s{%s}\n"
-                                   tabular-env
-                                   (if width (format "{%s}" width) "")
-                                   align))
-                        (orgtbl-to-latex
-                         lines
-                         `(:tstart ,org-export-latex-tables-tstart
-                                  :tend ,org-export-latex-tables-tend
-                                  :hline ,org-export-latex-tables-hline
-                                   :skipheadrule ,longtblp
-                                  :hfmt ,hfmt
-                                   :hlend ,(if longtblp
-                                               (format "\\\\
-%s
-\\endhead
-%s\\multicolumn{%d}{r}{Continued on next page}\\
-\\endfoot
-\\endlastfoot"
-                                                      org-export-latex-tables-hline
-                                                      org-export-latex-tables-hline
-                                                      (length org-table-last-alignment))
-                                             nil)))
-                        (if (not longtblp) (format "\n\\end{%s}" tabular-env))
-                        (if longtblp "\n" (if org-export-latex-tables-centered
-                                              "\n\\end{center}\n" "\n"))
-                        (if (and floatp (not org-export-latex-table-caption-above))
-                            (format
-                             "\\caption%s{%s} %s"
-                             (if shortn (concat "[" shortn "]") "")
-                             (or caption "")
-                            (if label (format "\\label{%s}" label) "")))
-                        (if longtblp
-                            "\\end{longtable}"
-                          (if floatp (format "\\end{%s}" tblenv)))))
-                      "\n\n"))))))))
-
-(defun org-export-latex-convert-table.el-table ()
-  "Replace table.el table at point with LaTeX code."
-  (let (tbl caption shortn label line floatp attr align rmlines)
-    (setq line (buffer-substring (point-at-bol) (point-at-eol))
-         label (org-get-text-property-any 0 'org-label line)
-         caption (org-get-text-property-any 0 'org-caption line)
-         shortn (org-get-text-property-any 0 'org-caption-shortn line)
-         attr (org-get-text-property-any 0 'org-attributes line)
-         align (and attr (stringp attr)
-                    (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
-                    (match-string 1 attr))
-         rmlines (and attr (stringp attr)
-                      (string-match "\\<rmlines\\>" attr))
-         floatp (or label caption))
-    (and (get-buffer "*org-export-table*")
-        (kill-buffer (get-buffer "*org-export-table*")))
-    (table-generate-source 'latex "*org-export-table*" "caption")
-    (setq tbl (with-current-buffer "*org-export-table*"
-               (buffer-string)))
-    (while (string-match "^%.*\n" tbl)
-      (setq tbl (replace-match "" t t tbl)))
-    ;; fix the hlines
-    (when rmlines
-      (let ((n 0) lines)
-       (setq lines (mapcar (lambda (x)
-                             (if (string-match "^\\\\hline$" x)
-                                 (progn
-                                   (setq n (1+ n))
-                                   (if (= n 2) x nil))
-                               x))
-                           (org-split-string tbl "\n")))
-       (setq tbl (mapconcat 'identity (delq nil lines) "\n"))))
-    (when (and align (string-match "\\\\begin{tabular}{.*}" tbl))
-      (setq tbl (replace-match (concat "\\begin{tabular}{" align "}")
-                              t t tbl)))
-    (and (get-buffer "*org-export-table*")
-        (kill-buffer (get-buffer "*org-export-table*")))
-    (beginning-of-line 0)
-    (while (looking-at "[ \t]*\\(|\\|\\+-\\)")
-      (delete-region (point) (1+ (point-at-eol))))
-    (when org-export-latex-tables-centered
-      (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
-    (when floatp
-      (setq tbl (concat "\\begin{table}\n"
-                       (if (not org-export-latex-table-caption-above) tbl)
-                       (format "\\caption%s{%s%s}\n"
-                               (if shortn (format "[%s]" shortn) "")
-                               (if label (format "\\label{%s}" label) "")
-                               (or caption ""))
-                       (if org-export-latex-table-caption-above tbl)
-                       "\n\\end{table}\n")))
-    (insert (org-export-latex-protect-string tbl))))
-
-(defun org-export-latex-fontify ()
-  "Convert fontification to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward org-emph-re nil t)
-    ;; The match goes one char after the *string*, except at the end of a line
-    (let ((emph (assoc (match-string 3)
-                      org-export-latex-emphasis-alist))
-         (beg (match-beginning 0))
-         (end (match-end 0))
-         rpl s)
-      (unless emph
-       (message "`org-export-latex-emphasis-alist' has no entry for formatting triggered by \"%s\""
-                (match-string 3)))
-      (unless (or (and (get-text-property (- (point) 2) 'org-protected)
-                      (not (get-text-property
-                            (- (point) 2) 'org-verbatim-emph)))
-                 (equal (char-after (match-beginning 3))
-                        (char-after (1+ (match-beginning 3))))
-                 (save-excursion
-                   (goto-char (match-beginning 1))
-                   (save-match-data
-                     (and (org-at-table-p)
-                          (string-match
-                           "[|\n]" (buffer-substring beg end)))))
-                 (and (equal (match-string 3) "+")
-                      (save-match-data
-                        (string-match "\\`-+\\'" (match-string 4)))))
-       (setq s (match-string 4))
-       (setq rpl (concat (match-string 1)
-                         (org-export-latex-emph-format (cadr emph)
-                                                       (match-string 4))
-                         (match-string 5)))
-       (if (caddr emph)
-           (setq rpl (org-export-latex-protect-string rpl))
-         (save-match-data
-           (if (string-match "\\`.?\\(\\\\[a-z]+{\\)\\(.*\\)\\(}\\).?\\'" rpl)
-               (progn
-                 (add-text-properties (match-beginning 1) (match-end 1)
-                                      '(org-protected t) rpl)
-                 (add-text-properties (match-beginning 3) (match-end 3)
-                                      '(org-protected t) rpl)))))
-       (replace-match rpl t t)))
-    (backward-char)))
-
-(defun org-export-latex-emph-format (format string)
-  "Format an emphasis string and handle the \\verb special case."
-  (when (member format '("\\verb" "\\protectedtexttt"))
-    (save-match-data
-      (if (equal format "\\verb")
-         (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
-           (catch 'exit
-             (loop for i from 0 to (1- (length ll)) do
-                   (if (not (string-match (regexp-quote (substring ll i (1+ i)))
-                                          string))
-                       (progn
-                         (setq format (concat "\\verb" (substring ll i (1+ i))
-                                              "%s" (substring ll i (1+ i))))
-                         (throw 'exit nil))))))
-       (let ((start 0)
-             (trans '(("\\" . "\\textbackslash{}")
-                      ("~" . "\\textasciitilde{}")
-                      ("^" . "\\textasciicircum{}")))
-             (rtn "") char)
-         (while (string-match "[\\{}$%&_#~^]" string)
-           (setq char (match-string 0 string))
-           (if (> (match-beginning 0) 0)
-               (setq rtn (concat rtn (substring string
-                                                0 (match-beginning 0)))))
-           (setq string (substring string (1+ (match-beginning 0))))
-           (setq char (or (cdr (assoc char trans)) (concat "\\" char))
-                 rtn (concat rtn char)))
-         (setq string (concat rtn string) format "\\texttt{%s}")
-         (while (string-match "--" string)
-           (setq string (replace-match "-{}-" t t string)))))))
-  (format format string))
-
-(defun org-export-latex-links ()
-  ;; Make sure to use the LaTeX hyperref and graphicx package
-  ;; or send some warnings.
-  "Convert links to LaTeX."
-  (goto-char (point-min))
-  (while (re-search-forward org-bracket-link-analytic-regexp++ nil t)
-    (org-if-unprotected-1
-     (goto-char (match-beginning 0))
-     (let* ((re-radio org-export-latex-all-targets-re)
-           (remove (list (match-beginning 0) (match-end 0)))
-           (raw-path (org-extract-attributes (match-string 3)))
-           (full-raw-path (concat (match-string 1) raw-path))
-           (desc (match-string 5))
-           (type (or (match-string 2)
-                     (if (or (file-name-absolute-p raw-path)
-                             (string-match "^\\.\\.?/" raw-path))
-                         "file")))
-           (coderefp (equal type "coderef"))
-           (caption (org-find-text-property-in-string 'org-caption raw-path))
-           (shortn (org-find-text-property-in-string 'org-caption-shortn raw-path))
-           (attr (or (org-find-text-property-in-string 'org-attributes raw-path)
-                     (plist-get org-export-latex-options-plist :latex-image-options)))
-           (label (org-find-text-property-in-string 'org-label raw-path))
-           imgp radiop fnc
-           ;; define the path of the link
-           (path (cond
-                  ((member type '("coderef"))
-                   raw-path)
-                  ((member type '("http" "https" "ftp"))
-                   (concat type ":" raw-path))
-                  ((and re-radio (string-match re-radio raw-path))
-                   (setq radiop t))
-                  ((equal type "mailto")
-                   (concat type ":" raw-path))
-                  ((equal type "file")
-                   (if (and (org-file-image-p
-                             (expand-file-name (org-link-unescape raw-path))
-                             org-export-latex-inline-image-extensions)
-                            (or (get-text-property 0 'org-no-description raw-path)
-                                (equal desc full-raw-path)))
-                       (setq imgp t)
-                     (progn (setq raw-path (org-link-unescape raw-path))
-                            (when (string-match "\\(.+\\)::.+" raw-path)
-                              (setq raw-path (match-string 1 raw-path)))
-                            (if (file-exists-p raw-path)
-                                (concat type "://" (expand-file-name raw-path))
-                              (concat type "://" (org-export-directory
-                                                  :LaTeX org-export-latex-options-plist)
-                                      raw-path))))))))
-       ;; process with link inserting
-       (apply 'delete-region remove)
-       (setq caption (and caption (org-export-latex-fontify-headline caption)))
-       (cond ((and imgp
-                  (plist-get org-export-latex-options-plist :inline-images))
-             ;; OK, we need to inline an image
-             (insert
-              (org-export-latex-format-image raw-path caption label attr shortn)))
-            (coderefp
-             (insert (format
-                      (org-export-get-coderef-format path desc)
-                      (cdr (assoc path org-export-code-refs)))))
-            (radiop (insert (format org-export-latex-hyperref-format
-                                    (org-solidify-link-text raw-path) desc)))
-            ((not type)
-             (insert (format org-export-latex-hyperref-format
-                             (org-remove-initial-hash
-                              (org-solidify-link-text raw-path))
-                             desc)))
-            (path
-             (when (org-at-table-p)
-               ;; There is a strange problem when we have a link in a table,
-               ;; ampersands then cause a problem.  I think this must be
-               ;; a LaTeX issue, but we here implement a work-around anyway.
-               (setq path (org-export-latex-protect-amp path)
-                     desc (org-export-latex-protect-amp desc)))
-             (insert
-              (if (string-match "%s.*%s" org-export-latex-href-format)
-                  (format org-export-latex-href-format path desc)
-                (format org-export-latex-href-format path))))
-
-            ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
-             ;; The link protocol has a function for formatting the link
-             (insert
-              (save-match-data
-                (funcall fnc (org-link-unescape raw-path) desc 'latex))))
-            ;; Unrecognized path type
-            (t (insert (format org-export-latex-link-with-unknown-path-format desc))))))))
-
-
-(defun org-export-latex-format-image (path caption label attr &optional shortn)
-  "Format the image element, depending on user settings."
-  (let (ind floatp wrapp multicolumnp placement figenv)
-    (setq floatp (or caption label))
-    (setq ind (org-get-text-property-any 0 'original-indentation path))
-    (when (and attr (stringp attr))
-      (if (string-match "[ \t]*\\<wrap\\>" attr)
-         (setq wrapp t floatp nil attr (replace-match "" t t attr)))
-      (if (string-match "[ \t]*\\<float\\>" attr)
-         (setq wrapp nil floatp t attr (replace-match "" t t attr)))
-      (if (string-match "[ \t]*\\<multicolumn\\>" attr)
-         (setq multicolumnp t attr (replace-match "" t t attr))))
-
-    (setq placement
-         (cond
-          (wrapp "{l}{0.5\\textwidth}")
-          (floatp (concat "[" org-latex-default-figure-position "]"))
-          (t "")))
-
-    (when (and attr (stringp attr)
-              (string-match "[ \t]*\\<placement=\\(\\S-+\\)" attr))
-      (setq placement (match-string 1 attr)
-           attr (replace-match "" t t attr)))
-    (setq attr (and attr (org-trim attr)))
-    (when (or (not attr) (= (length attr) 0))
-      (setq attr (cond (floatp "width=0.7\\textwidth")
-                      (wrapp "width=0.48\\textwidth")
-                      (t attr))))
-    (setq figenv
-         (cond
-          (wrapp "\\begin{wrapfigure}%placement
-\\centering
-\\includegraphics[%attr]{%path}
-\\caption%shortn{%labelcmd%caption}
-\\end{wrapfigure}")
-          (multicolumnp "\\begin{figure*}%placement
-\\centering
-\\includegraphics[%attr]{%path}
-\\caption%shortn{%labelcmd%caption}
-\\end{figure*}")
-          (floatp "\\begin{figure}%placement
-\\centering
-\\includegraphics[%attr]{%path}
-\\caption%shortn{%labelcmd%caption}
-\\end{figure}")
-          (t "\\includegraphics[%attr]{%path}")))
-
-
-    (setq figenv (mapconcat 'identity (split-string figenv "\n")
-                           (save-excursion (beginning-of-line 1)
-                                           (looking-at "[ \t]*")
-                                           (concat "\n" (match-string 0)))))
-
-    (if (and (not label) (not caption)
-            (string-match "^\\\\caption{.*\n" figenv))
-       (setq figenv (replace-match "" t t figenv)))
-    (org-add-props
-       (org-fill-template
-        figenv
-        (list (cons "path"
-                    (if (file-name-absolute-p path)
-                        (expand-file-name path)
-                      path))
-              (cons "attr" attr)
-              (cons "shortn" (if shortn (format "[%s]" shortn) ""))
-              (cons "labelcmd" (if label (format "\\label{%s}"
-                                                 label)""))
-              (cons "caption" (or caption ""))
-              (cons "placement" (or placement ""))))
-       nil 'original-indentation ind)))
-
-(defun org-export-latex-protect-amp (s)
-  (while (string-match "\\([^\\\\]\\)\\(&\\)" s)
-    (setq s (replace-match (concat (match-string 1 s) "\\" (match-string 2 s))
-                          t t s)))
-  s)
-
-(defun org-remove-initial-hash (s)
-  (if (string-match "\\`#" s)
-      (substring s 1)
-    s))
-(defvar org-latex-entities)   ; defined below
-(defvar org-latex-entities-regexp)   ; defined below
-
-(defun org-export-latex-preprocess (parameters)
-  "Clean stuff in the LaTeX export."
-  ;; Replace footnotes.
-  (when (plist-get parameters :footnotes)
-    (goto-char (point-min))
-    (let (ref)
-      (while (setq ref (org-footnote-get-next-reference))
-       (let* ((beg (nth 1 ref))
-              (lbl (car ref))
-              (def (nth 1 (assoc (string-to-number lbl)
-                                 (mapcar (lambda (e) (cdr e))
-                                         org-export-footnotes-seen)))))
-         ;; Fix body for footnotes ending on a link or a list and
-         ;; remove definition from buffer.
-         (setq def
-               (concat def
-                       (if (string-match "ORG-LIST-END-MARKER\\'" def)
-                           "\n" " ")))
-         (org-footnote-delete-definitions lbl)
-         ;; Compute string to insert (FNOTE), and protect the outside
-         ;; macro from further transformation.  When footnote at
-         ;; point is referring to a previously defined footnote, use
-         ;; \footnotemark.  Otherwise, use \footnote.
-         (let ((fnote (if (member lbl org-export-latex-footmark-seen)
-                          (org-export-latex-protect-string
-                           (format "\\footnotemark[%s]" lbl))
-                        (push lbl org-export-latex-footmark-seen)
-                        (concat (org-export-latex-protect-string "\\footnote{")
-                                def
-                                (org-export-latex-protect-string "}"))))
-               ;; Check if another footnote is immediately following.
-               ;; If so, add a separator in-between.
-               (sep (org-export-latex-protect-string
-                     (if (save-excursion (goto-char (1- (nth 2 ref)))
-                                         (let ((next (org-footnote-get-next-reference)))
-                                           (and next (= (nth 1 next) (nth 2 ref)))))
-                         org-export-latex-footnote-separator ""))))
-           (when (org-at-heading-p)
-             (setq fnote (concat (org-export-latex-protect-string "\\protect")
-                                 fnote)))
-           ;; Ensure a footnote at column 0 cannot end a list
-           ;; containing it.
-           (put-text-property 0 (length fnote) 'original-indentation 1000 fnote)
-           ;; Replace footnote reference with FNOTE and, maybe, SEP.
-           ;; `save-excursion' is required if there are two footnotes
-           ;; in a row.  In that case, point would be left at the
-           ;; beginning of the second one, and
-           ;; `org-footnote-get-next-reference' would then skip it.
-           (goto-char beg)
-           (delete-region beg (nth 2 ref))
-           (save-excursion (insert fnote sep)))))))
-
-  ;; Remove footnote section tag for LaTeX
-  (goto-char (point-min))
-  (while (re-search-forward
-         (concat "^" footnote-section-tag-regexp) nil t)
-    (org-if-unprotected
-     (replace-match "")))
-  ;; Remove any left-over footnote definition.
-  (mapc (lambda (fn) (org-footnote-delete-definitions (car fn)))
-       org-export-footnotes-data)
-  (mapc (lambda (fn) (org-footnote-delete-definitions fn))
-       org-export-latex-footmark-seen)
-
-  ;; Preserve line breaks
-  (goto-char (point-min))
-  (while (re-search-forward "\\\\\\\\" nil t)
-    (add-text-properties (match-beginning 0) (match-end 0)
-                        '(org-protected t)))
-
-  ;; Preserve latex environments
-  (goto-char (point-min))
-  (while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\*?\\)}" nil t)
-    (org-if-unprotected
-     (let* ((start (progn (beginning-of-line) (point)))
-           (end (and (re-search-forward
-                      (concat "^[ \t]*\\\\end{"
-                              (regexp-quote (match-string 1))
-                              "}") nil t)
-                     (point-at-eol))))
-       (if end
-          (add-text-properties start end '(org-protected t))
-        (goto-char (point-at-eol))))))
-
-  ;; Preserve math snippets
-  (let* ((matchers (plist-get org-format-latex-options :matchers))
-        (re-list org-latex-regexps)
-        beg end re e m n block off)
-    ;; Check the different regular expressions
-    (while (setq e (pop re-list))
-      (setq m (car e) re (nth 1 e) n (nth 2 e)
-           block (if (nth 3 e) "\n\n" ""))
-      (setq off (if (member m '("$" "$1")) 1 0))
-      (when (and (member m matchers) (not (equal m "begin")))
-       (goto-char (point-min))
-       (while (re-search-forward re nil t)
-         (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
-         (add-text-properties beg end '(org-protected t org-latex-math t))))))
-
-  ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
-  (goto-char (point-min))
-  (let ((case-fold-search nil))
-    (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
-      (unless (eq (char-before (match-beginning 1)) ?\\)
-       (org-if-unprotected-1
-        (replace-match (org-export-latex-protect-string
-                        (concat "\\" (match-string 1)
-                                "{}")) t t)))))
-
-  ;; Convert blockquotes
-  (goto-char (point-min))
-  (while (search-forward "ORG-BLOCKQUOTE-START" nil t)
-    (org-replace-match-keep-properties "\\begin{quote}" t t))
-  (goto-char (point-min))
-  (while (search-forward "ORG-BLOCKQUOTE-END" nil t)
-    (org-replace-match-keep-properties "\\end{quote}" t t))
-
-  ;; Convert verse
-  (goto-char (point-min))
-  (while (search-forward "ORG-VERSE-START" nil t)
-    (org-replace-match-keep-properties "\\begin{verse}" t t)
-    (beginning-of-line 2)
-    (while (and (not (looking-at "[ \t]*ORG-VERSE-END.*")) (not (eobp)))
-      (when (looking-at "\\([ \t]+\\)\\([^ \t\n]\\)")
-       (goto-char (match-end 1))
-       (org-replace-match-keep-properties
-        (org-export-latex-protect-string
-         (concat "\\hspace*{1cm}" (match-string 2))) t t)
-       (beginning-of-line 1))
-      (if (looking-at "[ \t]*$")
-         (insert (org-export-latex-protect-string "\\vspace*{1em}"))
-       (unless (looking-at ".*?[^ \t\n].*?\\\\\\\\[ \t]*$")
-         (end-of-line 1)
-         (insert "\\\\")))
-      (beginning-of-line 2))
-    (and (looking-at "[ \t]*ORG-VERSE-END.*")
-        (org-replace-match-keep-properties "\\end{verse}" t t)))
-
-  ;; Convert #+INDEX to LaTeX \\index.
-  (goto-char (point-min))
-  (let ((case-fold-search t) entry)
-    (while (re-search-forward
-           "^[ \t]*#\\+index:[ \t]*\\([^ \t\r\n].*?\\)[ \t]*$"
-           nil t)
-      (setq entry
-           (save-match-data
-             (org-export-latex-protect-string
-              (org-export-latex-fontify-headline (match-string 1)))))
-      (replace-match (format "\\index{%s}" entry) t t)))
-
-  ;; Convert center
-  (goto-char (point-min))
-  (while (search-forward "ORG-CENTER-START" nil t)
-    (org-replace-match-keep-properties "\\begin{center}" t t))
-  (goto-char (point-min))
-  (while (search-forward "ORG-CENTER-END" nil t)
-    (org-replace-match-keep-properties "\\end{center}" t t))
-
-  (run-hooks 'org-export-latex-after-blockquotes-hook)
-
-  ;; Convert horizontal rules
-  (goto-char (point-min))
-  (while (re-search-forward "^[ \t]*-\\{5,\\}[ \t]*$" nil t)
-    (org-if-unprotected
-     (replace-match (org-export-latex-protect-string "\\hrule") t t)))
-
-  ;; Protect LaTeX commands like \command[...]{...} or \command{...}
-  (goto-char (point-min))
-  (let ((re (concat
-            "\\\\\\([a-zA-Z]+\\*?\\)"
-            "\\(?:<[^<>\n]*>\\)*"
-            "\\(?:\\[[^][\n]*?\\]\\)*"
-            "\\(?:<[^<>\n]*>\\)*"
-            "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")))
-    (while (re-search-forward re nil t)
-      (unless (or
-              ;; Check for comment line.
-              (save-excursion (goto-char (match-beginning 0))
-                              (org-in-indented-comment-line))
-              ;; Check if this is a defined entity, so that is may
-              ;; need conversion.
-              (org-entity-get (match-string 1))
-              ;; Do not protect interior of footnotes.  Those have
-              ;; already been taken care of earlier in the function.
-              ;; Yet, keep looking inside them for more commands.
-              (and (equal (match-string 1) "footnote")
-                   (goto-char (match-end 1))))
-       (add-text-properties (match-beginning 0) (match-end 0)
-                            '(org-protected t)))))
-
-  ;; Special case for \nbsp
-  (goto-char (point-min))
-  (while (re-search-forward "\\\\nbsp\\({}\\|\\>\\)" nil t)
-    (org-if-unprotected
-     (replace-match (org-export-latex-protect-string "~"))))
-
-  ;; Protect LaTeX entities
-  (goto-char (point-min))
-  (while (re-search-forward org-latex-entities-regexp nil t)
-    (org-if-unprotected
-     (add-text-properties (match-beginning 0) (match-end 0)
-                         '(org-protected t))))
-
-  ;; Replace radio links
-  (goto-char (point-min))
-  (while (re-search-forward
-         (concat "<<<?" org-export-latex-all-targets-re
-                 ">>>?\\((INVISIBLE)\\)?") nil t)
-    (org-if-unprotected-at (+ (match-beginning 0) 2)
-      (replace-match
-       (concat
-       (org-export-latex-protect-string
-        (format "\\label{%s}" (save-match-data (org-solidify-link-text
-                                                (match-string 1)))))
-       (if (match-string 2) "" (match-string 1)))
-       t t)))
-
-  ;; Delete @<...> constructs
-  ;; Thanks to Daniel Clemente for this regexp
-  (goto-char (point-min))
-  (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
-    (org-if-unprotected
-     (replace-match ""))))
-
-(defun org-export-latex-fix-inputenc ()
-  "Set the coding system in inputenc to what the buffer is."
-  (let* ((cs buffer-file-coding-system)
-        (opt (or (ignore-errors (latexenc-coding-system-to-inputenc cs))
-                 "utf8")))
-    (when opt
-      ;; Translate if that is requested
-      (setq opt (or (cdr (assoc opt org-export-latex-inputenc-alist)) opt))
-      ;; find the \usepackage statement and replace the option
-      (goto-char (point-min))
-      (while (re-search-forward "\\\\usepackage\\[\\(AUTO\\)\\]{inputenc}"
-                               nil t)
-       (goto-char (match-beginning 1))
-       (delete-region (match-beginning 1) (match-end 1))
-       (insert opt))
-      (and buffer-file-name
-          (save-buffer)))))
-
-;;; List handling:
-
-(defun org-export-latex-lists ()
-  "Convert plain text lists in current buffer into LaTeX lists."
-  ;; `org-list-end-re' output has changed since preprocess from
-  ;; org-exp.el.  Make sure it is taken into account.
-  (let ((org-list-end-re "^ORG-LIST-END-MARKER\n"))
-    (mapc
-     (lambda (e)
-       ;; For each type of context allowed for list export (E), find
-       ;; every list, parse it, delete it and insert resulting
-       ;; conversion to latex (RES), while keeping the same
-       ;; `original-indentation' property.
-       (let (res)
-        (goto-char (point-min))
-        (while (re-search-forward (org-item-beginning-re) nil t)
-          (when (and (eq (get-text-property (point) 'list-context) e)
-                     (not (get-text-property (point) 'org-example)))
-            (beginning-of-line)
-            (setq res
-                  (org-list-to-latex
-                   ;; Narrowing is needed because we're converting
-                   ;; from inner functions to outer ones.
-                   (save-restriction
-                     (narrow-to-region (point) (point-max))
-                     (org-list-parse-list t))
-                   org-export-latex-list-parameters))
-            ;; Extend previous value of original-indentation to the
-            ;; whole string
-            (insert (org-add-props res nil 'original-indentation
-                                   (org-find-text-property-in-string
-                                    'original-indentation res)))))))
-     ;; List of allowed contexts for export, and the default one.
-     (append org-list-export-context '(nil)))))
-
-(defconst org-latex-entities
-  '("\\!"
-    "\\'"
-    "\\+"
-    "\\,"
-    "\\-"
-    "\\:"
-    "\\;"
-    "\\<"
-    "\\="
-    "\\>"
-    "\\Huge"
-    "\\LARGE"
-    "\\Large"
-    "\\Styles"
-    "\\\\"
-    "\\`"
-    "\\\""
-    "\\addcontentsline"
-    "\\address"
-    "\\addtocontents"
-    "\\addtocounter"
-    "\\addtolength"
-    "\\addvspace"
-    "\\alph"
-    "\\appendix"
-    "\\arabic"
-    "\\author"
-    "\\begin{array}"
-    "\\begin{center}"
-    "\\begin{description}"
-    "\\begin{enumerate}"
-    "\\begin{eqnarray}"
-    "\\begin{equation}"
-    "\\begin{figure}"
-    "\\begin{flushleft}"
-    "\\begin{flushright}"
-    "\\begin{itemize}"
-    "\\begin{list}"
-    "\\begin{minipage}"
-    "\\begin{picture}"
-    "\\begin{quotation}"
-    "\\begin{quote}"
-    "\\begin{tabbing}"
-    "\\begin{table}"
-    "\\begin{tabular}"
-    "\\begin{thebibliography}"
-    "\\begin{theorem}"
-    "\\begin{titlepage}"
-    "\\begin{verbatim}"
-    "\\begin{verse}"
-    "\\bf"
-    "\\bf"
-    "\\bibitem"
-    "\\bigskip"
-    "\\cdots"
-    "\\centering"
-    "\\circle"
-    "\\cite"
-    "\\cleardoublepage"
-    "\\clearpage"
-    "\\cline"
-    "\\closing"
-    "\\dashbox"
-    "\\date"
-    "\\ddots"
-    "\\dotfill"
-    "\\em"
-    "\\fbox"
-    "\\flushbottom"
-    "\\fnsymbol"
-    "\\footnote"
-    "\\footnotemark"
-    "\\footnotesize"
-    "\\footnotetext"
-    "\\frac"
-    "\\frame"
-    "\\framebox"
-    "\\hfill"
-    "\\hline"
-    "\\hrulespace"
-    "\\hspace"
-    "\\huge"
-    "\\hyphenation"
-    "\\include"
-    "\\includeonly"
-    "\\indent"
-    "\\input"
-    "\\it"
-    "\\kill"
-    "\\label"
-    "\\large"
-    "\\ldots"
-    "\\line"
-    "\\linebreak"
-    "\\linethickness"
-    "\\listoffigures"
-    "\\listoftables"
-    "\\location"
-    "\\makebox"
-    "\\maketitle"
-    "\\mark"
-    "\\mbox"
-    "\\medskip"
-    "\\multicolumn"
-    "\\multiput"
-    "\\newcommand"
-    "\\newcounter"
-    "\\newenvironment"
-    "\\newfont"
-    "\\newlength"
-    "\\newline"
-    "\\newpage"
-    "\\newsavebox"
-    "\\newtheorem"
-    "\\nocite"
-    "\\nofiles"
-    "\\noindent"
-    "\\nolinebreak"
-    "\\nopagebreak"
-    "\\normalsize"
-    "\\onecolumn"
-    "\\opening"
-    "\\oval"
-    "\\overbrace"
-    "\\overline"
-    "\\pagebreak"
-    "\\pagenumbering"
-    "\\pageref"
-    "\\pagestyle"
-    "\\par"
-    "\\parbox"
-    "\\put"
-    "\\raggedbottom"
-    "\\raggedleft"
-    "\\raggedright"
-    "\\raisebox"
-    "\\ref"
-    "\\rm"
-    "\\roman"
-    "\\rule"
-    "\\savebox"
-    "\\sc"
-    "\\scriptsize"
-    "\\setcounter"
-    "\\setlength"
-    "\\settowidth"
-    "\\sf"
-    "\\shortstack"
-    "\\signature"
-    "\\sl"
-    "\\small"
-    "\\smallskip"
-    "\\sqrt"
-    "\\tableofcontents"
-    "\\telephone"
-    "\\thanks"
-    "\\thispagestyle"
-    "\\tiny"
-    "\\title"
-    "\\tt"
-    "\\twocolumn"
-    "\\typein"
-    "\\typeout"
-    "\\underbrace"
-    "\\underline"
-    "\\usebox"
-    "\\usecounter"
-    "\\value"
-    "\\vdots"
-    "\\vector"
-    "\\verb"
-    "\\vfill"
-    "\\vline"
-    "\\vspace")
-  "A list of LaTeX commands to be protected when performing conversion.")
-
-(defconst org-latex-entities-regexp
-  (let (names rest)
-    (dolist (x org-latex-entities)
-      (if (string-match "[a-zA-Z]$" x)
-         (push x names)
-       (push x rest)))
-    (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)"
-           "\\|\\(" (regexp-opt (nreverse rest)) "\\)")))
-
-(provide 'org-export-latex)
-(provide 'org-latex)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-latex.el ends here
index 47476481625971aca6e348158d3f002273af6c7b..4a3d471f0600fb1158d8bd1e5406b98729cb8db9 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
-;;        Bastien Guerry <bzg AT gnu DOT org>
+;;        Bastien Guerry <bzg@gnu.org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
 ;;
 (defvar org-ts-regexp)
 (defvar org-ts-regexp-both)
 
+(declare-function outline-invisible-p "outline" (&optional pos))
+(declare-function outline-flag-region "outline" (from to flag))
+(declare-function outline-next-heading "outline" ())
+(declare-function outline-previous-heading "outline" ())
+
 (declare-function org-at-heading-p "org" (&optional ignored))
 (declare-function org-before-first-heading-p "org" ())
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-icompleting-read "org" (&rest args))
 (declare-function org-in-block-p "org" (names))
 (declare-function org-in-regexp "org" (re &optional nlines visually))
-(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
-(declare-function org-inlinetask-goto-end "org-inlinetask" ())
-(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
-(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function org-level-increment "org" ())
 (declare-function org-narrow-to-subtree "org" ())
 (declare-function org-at-heading-p "org" (&optional invisible-ok))
 (declare-function org-remove-if "org" (predicate seq))
 (declare-function org-reduced-level "org" (L))
 (declare-function org-show-subtree "org" ())
+(declare-function org-sort-remove-invisible "org" (S))
 (declare-function org-time-string-to-seconds "org" (s))
 (declare-function org-timer-hms-to-secs "org-timer" (hms))
 (declare-function org-timer-item "org-timer" (&optional arg))
 (declare-function org-trim "org" (s))
 (declare-function org-uniquify "org" (list))
-(declare-function outline-invisible-p "outline" (&optional pos))
-(declare-function outline-flag-region "outline" (from to flag))
-(declare-function outline-next-heading "outline" ())
-(declare-function outline-previous-heading "outline" ())
+
+(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
+(declare-function org-inlinetask-goto-end "org-inlinetask" ())
+(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
+(declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
+
+(declare-function org-export-string-as "ox"
+                 (string backend &optional body-only ext-plist))
+
 
 
 \f
@@ -154,6 +161,7 @@ plain list item with an implied large level number, all true
 children and grand children of the outline heading will be
 exposed in a children' view."
   :group 'org-plain-lists
+  :group 'org-cycle
   :type '(choice
          (const :tag "Never" nil)
          (const :tag "With cursor in plain list (recommended)" t)
@@ -209,14 +217,26 @@ Valid values are ?. and ?\).  To get both terminators, use t."
                 (const :tag "paren like in \"2)\"" ?\))
                 (const :tag "both" t)))
 
-(defcustom org-alphabetical-lists nil
+(define-obsolete-variable-alias 'org-alphabetical-lists
+  'org-list-allow-alphabetical "24.4") ; Since 8.0
+(defcustom org-list-allow-alphabetical nil
   "Non-nil means single character alphabetical bullets are allowed.
+
 Both uppercase and lowercase are handled.  Lists with more than
 26 items will fallback to standard numbering.  Alphabetical
-counters like \"[@c]\" will be recognized."
+counters like \"[@c]\" will be recognized.
+
+This variable needs to be set before org.el is loaded.  If you
+need to make a change while Emacs is running, use the customize
+interface or run the following code after updating it:
+
+  \(when (featurep 'org-element) (load \"org-element\" t t))"
   :group 'org-plain-lists
   :version "24.1"
-  :type 'boolean)
+  :type 'boolean
+  :set (lambda (var val)
+        (when (featurep 'org-element) (load "org-element" t t))
+        (set var val)))
 
 (defcustom org-list-two-spaces-after-bullet-regexp nil
   "A regular expression matching bullets that should have 2 spaces after them.
@@ -230,7 +250,9 @@ spaces instead of one after the bullet in each item of the list."
          (const :tag "never" nil)
          (regexp)))
 
-(defcustom org-empty-line-terminates-plain-lists nil
+(define-obsolete-variable-alias 'org-empty-line-terminates-plain-lists
+  'org-list-empty-line-terminates-plain-lists "24.4") ;; Since 8.0
+(defcustom org-list-empty-line-terminates-plain-lists nil
   "Non-nil means an empty line ends all plain list levels.
 Otherwise, two of them will be necessary."
   :group 'org-plain-lists
@@ -282,7 +304,9 @@ This hook runs even if checkbox rule in
 implement alternative ways of collecting statistics
 information.")
 
-(defcustom org-hierarchical-checkbox-statistics t
+(define-obsolete-variable-alias 'org-hierarchical-checkbox-statistics
+  'org-checkbox-hierarchical-statistics "24.4") ;; Since 8.0
+(defcustom org-checkbox-hierarchical-statistics t
   "Non-nil means checkbox statistics counts only the state of direct children.
 When nil, all boxes below the cookie are counted.
 This can be set to nil on a per-node basis using a COOKIE_DATA property
@@ -290,7 +314,9 @@ with the word \"recursive\" in the value."
   :group 'org-plain-lists
   :type 'boolean)
 
-(defcustom org-description-max-indent 20
+(org-defvaralias 'org-description-max-indent
+  'org-list-description-max-indent) ;; Since 8.0
+(defcustom org-list-description-max-indent 20
   "Maximum indentation for the second line of a description list.
 When the indentation would be larger than this, it will become
 5 characters instead."
@@ -333,7 +359,7 @@ list, obtained by prompting the user."
                (string :tag "Format"))))
 
 (defvar org-list-forbidden-blocks '("example" "verse" "src" "ascii" "beamer"
-                                   "docbook" "html" "latex" "odt")
+                                   "html" "latex" "odt")
   "Names of blocks where lists are not allowed.
 Names must be in lower case.")
 
@@ -348,10 +374,10 @@ specifically, type `block' is determined by the variable
 \f
 ;;; Predicates and regexps
 
-(defconst org-list-end-re (if org-empty-line-terminates-plain-lists "^[ \t]*\n"
+(defconst org-list-end-re (if org-list-empty-line-terminates-plain-lists "^[ \t]*\n"
                            "^[ \t]*\n[ \t]*\n")
   "Regex corresponding to the end of a list.
-It depends on `org-empty-line-terminates-plain-lists'.")
+It depends on `org-list-empty-line-terminates-plain-lists'.")
 
 (defconst org-list-full-item-re
   (concat "^[ \t]*\\(\\(?:[-+*]\\|\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\)\\(?:[ \t]+\\|$\\)\\)"
@@ -371,7 +397,7 @@ group 4: description tag")
               ((= org-plain-list-ordered-item-terminator ?\)) ")")
               ((= org-plain-list-ordered-item-terminator ?.) "\\.")
               (t "[.)]")))
-       (alpha (if org-alphabetical-lists "\\|[A-Za-z]" "")))
+       (alpha (if org-list-allow-alphabetical "\\|[A-Za-z]" "")))
     (concat "\\([ \t]*\\([-+]\\|\\(\\([0-9]+" alpha "\\)" term
            "\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)")))
 
@@ -385,7 +411,7 @@ group 4: description tag")
        (save-excursion
         (goto-char (match-end 0))
         (let ((counter-re (concat "\\(?:\\[@\\(?:start:\\)?"
-                                  (if org-alphabetical-lists
+                                  (if org-list-allow-alphabetical
                                       "\\([0-9]+\\|[A-Za-z]\\)"
                                     "[0-9]+")
                                   "\\][ \t]*\\)")))
@@ -642,8 +668,7 @@ Assume point is at an item."
       (save-excursion
        (catch 'exit
          (while t
-           (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
-                         (org-get-indentation))))
+           (let ((ind (org-get-indentation)))
              (cond
               ((<= (point) lim-up)
                ;; At upward limit: if we ended at an item, store it,
@@ -651,18 +676,10 @@ Assume point is at an item."
                ;; Jump to part 2.
                (throw 'exit
                       (setq itm-lst
-                            (if (or (not (looking-at item-re))
-                                    (get-text-property (point) 'org-example))
+                            (if (not (looking-at item-re))
                                 (memq (assq (car beg-cell) itm-lst) itm-lst)
                               (setq beg-cell (cons (point) ind))
                               (cons (funcall assoc-at-point ind) itm-lst)))))
-              ;; At a verbatim block, go before its beginning.  Move
-              ;; from eol to ensure `previous-single-property-change'
-              ;; will return a value.
-              ((get-text-property (point) 'org-example)
-               (goto-char (previous-single-property-change
-                           (point-at-eol) 'org-example nil lim-up))
-               (forward-line -1))
               ;; Looking at a list ending regexp.  Dismiss useless
               ;; data recorded above BEG-CELL.  Jump to part 2.
               ((looking-at org-list-end-re)
@@ -711,8 +728,7 @@ Assume point is at an item."
       ;;    position of items in END-LST-2.
       (catch 'exit
        (while t
-         (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
-                       (org-get-indentation))))
+         (let ((ind (org-get-indentation)))
            (cond
             ((>= (point) lim-down)
              ;; At downward limit: this is de facto the end of the
@@ -720,12 +736,6 @@ Assume point is at an item."
              ;; part 3.
              (throw 'exit
                     (push (cons 0 (funcall end-before-blank)) end-lst-2)))
-            ;; At a verbatim block, move to its end.  Point is at bol
-            ;; and 'org-example property is set by whole lines:
-            ;; `next-single-property-change' always return a value.
-            ((get-text-property (point) 'org-example)
-             (goto-char
-              (next-single-property-change (point) 'org-example nil lim-down)))
             ;; Looking at a list ending regexp.  Save point as an
             ;; ending position and jump to part 3.
             ((looking-at org-list-end-re)
@@ -1097,8 +1107,9 @@ It determines the number of whitespaces to append by looking at
                            org-list-two-spaces-after-bullet-regexp bullet))
                      "  "
                    " ")))
-      (string-match "\\S-+\\([ \t]*\\)" bullet)
-      (replace-match spaces nil nil bullet 1))))
+      (if (string-match "\\S-+\\([ \t]*\\)" bullet)
+         (replace-match spaces nil nil bullet 1)
+       bullet))))
 
 (defun org-list-swap-items (beg-A beg-B struct)
   "Swap item starting at BEG-A with item starting at BEG-B in STRUCT.
@@ -1208,7 +1219,7 @@ some heuristics to guess the result."
                                    (point))))))))
       (cond
        ;; Trivial cases where there should be none.
-       ((or org-empty-line-terminates-plain-lists (not insert-blank-p)) 0)
+       ((or org-list-empty-line-terminates-plain-lists (not insert-blank-p)) 0)
        ;; When `org-blank-before-new-entry' says so, it is 1.
        ((eq insert-blank-p t) 1)
        ;; `plain-list-item' is 'auto.  Count blank lines separating
@@ -1613,7 +1624,7 @@ bullets between START and END."
 
 STRUCT is list structure.  PREVS is the alist of previous items,
 as returned by `org-list-prevs-alist'."
-  (and org-alphabetical-lists
+  (and org-list-allow-alphabetical
        (catch 'exit
         (let ((item first) (ascii 64) (case-fold-search nil))
           ;; Pretend that bullets are uppercase and check if alphabet
@@ -1851,9 +1862,10 @@ Initial position of cursor is restored after the changes."
         (item-re (org-item-re))
         (shift-body-ind
          (function
-          ;; Shift the indentation between END and BEG by DELTA.
-          ;; Start from the line before END.
-          (lambda (end beg delta)
+          ;; Shift the indentation between END and BEG by DELTA.  If
+          ;; MAX-IND is non-nil, ensure that no line will be indented
+          ;; more than that number.  Start from the line before END.
+          (lambda (end beg delta max-ind)
             (goto-char end)
             (skip-chars-backward " \r\t\n")
             (beginning-of-line)
@@ -1867,7 +1879,8 @@ Initial position of cursor is restored after the changes."
                ;; Shift only non-empty lines.
                ((org-looking-at-p "^[ \t]*\\S-")
                 (let ((i (org-get-indentation)))
-                  (org-indent-line-to (+ i delta)))))
+                  (org-indent-line-to
+                   (if max-ind (min (+ i delta) max-ind) (+ i delta))))))
               (forward-line -1)))))
          (modify-item
           (function
@@ -1903,53 +1916,60 @@ Initial position of cursor is restored after the changes."
                 (indent-to new-ind)))))))
     ;; 1. First get list of items and position endings.  We maintain
     ;;    two alists: ITM-SHIFT, determining indentation shift needed
-    ;;    at item, and END-POS, a pseudo-alist where key is ending
+    ;;    at item, and END-LIST, a pseudo-alist where key is ending
     ;;    position and value point.
     (let (end-list acc-end itm-shift all-ends sliced-struct)
-      (mapc (lambda (e)
-             (let* ((pos (car e))
-                    (ind-pos (org-list-get-ind pos struct))
-                    (ind-old (org-list-get-ind pos old-struct))
-                    (bul-pos (org-list-get-bullet pos struct))
-                    (bul-old (org-list-get-bullet pos old-struct))
-                    (ind-shift (- (+ ind-pos (length bul-pos))
-                                  (+ ind-old (length bul-old))))
-                    (end-pos (org-list-get-item-end pos old-struct)))
-               (push (cons pos ind-shift) itm-shift)
-               (unless (assq end-pos old-struct)
-                 ;; To determine real ind of an ending position that
-                 ;; is not at an item, we have to find the item it
-                 ;; belongs to: it is the last item (ITEM-UP), whose
-                 ;; ending is further than the position we're
-                 ;; interested in.
-                 (let ((item-up (assoc-default end-pos acc-end '>)))
-                   (push (cons end-pos item-up) end-list)))
-               (push (cons end-pos pos) acc-end)))
-           old-struct)
+      (dolist (e old-struct)
+       (let* ((pos (car e))
+              (ind-pos (org-list-get-ind pos struct))
+              (ind-old (org-list-get-ind pos old-struct))
+              (bul-pos (org-list-get-bullet pos struct))
+              (bul-old (org-list-get-bullet pos old-struct))
+              (ind-shift (- (+ ind-pos (length bul-pos))
+                            (+ ind-old (length bul-old))))
+              (end-pos (org-list-get-item-end pos old-struct)))
+         (push (cons pos ind-shift) itm-shift)
+         (unless (assq end-pos old-struct)
+           ;; To determine real ind of an ending position that
+           ;; is not at an item, we have to find the item it
+           ;; belongs to: it is the last item (ITEM-UP), whose
+           ;; ending is further than the position we're
+           ;; interested in.
+           (let ((item-up (assoc-default end-pos acc-end '>)))
+             (push (cons end-pos item-up) end-list)))
+         (push (cons end-pos pos) acc-end)))
       ;; 2. Slice the items into parts that should be shifted by the
-      ;;    same amount of indentation.  The slices are returned in
-      ;;    reverse order so changes modifying buffer do not change
-      ;;    positions they refer to.
+      ;;    same amount of indentation.  Each slice follow the pattern
+      ;;    (END BEG DELTA MAX-IND-OR-NIL).  Slices are returned in
+      ;;    reverse order.
       (setq all-ends (sort (append (mapcar 'car itm-shift)
                                   (org-uniquify (mapcar 'car end-list)))
                           '<))
       (while (cdr all-ends)
        (let* ((up (pop all-ends))
               (down (car all-ends))
-              (ind (if (assq up struct)
-                       (cdr (assq up itm-shift))
-                     (cdr (assq (cdr (assq up end-list)) itm-shift)))))
-         (push (list down up ind) sliced-struct)))
+              (itemp (assq up struct))
+              (item (if itemp up (cdr (assq up end-list))))
+              (ind (cdr (assq item itm-shift)))
+              ;; If we're not at an item, there's a child of the item
+              ;; point belongs to above.  Make sure this slice isn't
+              ;; moved within that child by specifying a maximum
+              ;; indentation.
+              (max-ind (and (not itemp)
+                            (+ (org-list-get-ind item struct)
+                               (length (org-list-get-bullet item struct))
+                               org-list-indent-offset))))
+         (push (list down up ind max-ind) sliced-struct)))
       ;; 3. Shift each slice in buffer, provided delta isn't 0, from
       ;;    end to beginning.  Take a special action when beginning is
       ;;    at item bullet.
-      (mapc (lambda (e)
-             (unless (zerop (nth 2 e)) (apply shift-body-ind e))
-             (let* ((beg (nth 1 e))
-                    (cell (assq beg struct)))
-               (unless (or (not cell) (equal cell (assq beg old-struct)))
-                 (funcall modify-item beg))))
-           sliced-struct))
+      (dolist (e sliced-struct)
+       (unless (and (zerop (nth 2 e)) (not (nth 3 e)))
+         (apply shift-body-ind e))
+       (let* ((beg (nth 1 e))
+              (cell (assq beg struct)))
+         (unless (or (not cell) (equal cell (assq beg old-struct)))
+           (funcall modify-item beg)))))
     ;; 4. Go back to initial position and clean marker.
     (goto-char origin)
     (move-marker origin nil)))
@@ -2148,7 +2168,7 @@ the item, so this really moves item trees."
         (prevs (org-list-prevs-alist struct))
         (next-item (org-list-get-next-item (point-at-bol) struct prevs)))
     (unless (or next-item org-list-use-circular-motion)
-      (error "Cannot move this item further down"))
+      (user-error "Cannot move this item further down"))
     (if (not next-item)
        (setq struct (org-list-send-item item 'begin struct))
       (setq struct (org-list-swap-items item next-item struct))
@@ -2169,7 +2189,7 @@ the item, so this really moves item trees."
         (prevs (org-list-prevs-alist struct))
         (prev-item (org-list-get-prev-item (point-at-bol) struct prevs)))
     (unless (or prev-item org-list-use-circular-motion)
-      (error "Cannot move this item further up"))
+      (user-error "Cannot move this item further up"))
     (if (not prev-item)
        (setq struct (org-list-send-item item 'end struct))
       (setq struct (org-list-swap-items prev-item item struct)))
@@ -2203,9 +2223,8 @@ item is invisible."
               ;; If we're in a description list, ask for the new term.
               (desc (when (eq (org-list-get-list-type itemp struct prevs)
                               'descriptive)
-                      (concat (read-string "Term: ") " :: "))))
-         (setq struct
-               (org-list-insert-item pos struct prevs checkbox desc))
+                      " :: ")))
+         (setq struct (org-list-insert-item pos struct prevs checkbox desc))
          (org-list-write-struct struct (org-list-parents-alist struct))
          (when checkbox (org-update-checkbox-count-maybe))
          (looking-at org-list-full-item-re)
@@ -2214,6 +2233,7 @@ item is invisible."
                                (string-match "[.)]" (match-string 1))))
                         (match-beginning 4)
                       (match-end 0)))
+         (if desc (backward-char 1))
          t)))))
 
 (defun org-list-repair ()
@@ -2429,7 +2449,7 @@ With optional prefix argument ALL, do this for the whole buffer."
     (let ((cookie-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
          (box-re "^[ \t]*\\([-+*]\\|\\([0-9]+\\|[A-Za-z]\\)[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
          (recursivep
-          (or (not org-hierarchical-checkbox-statistics)
+          (or (not org-checkbox-hierarchical-statistics)
               (string-match "\\<recursive\\>"
                             (or (org-entry-get nil "COOKIE_DATA") ""))))
          (bounds (if all
@@ -2771,7 +2791,7 @@ Return t at each successful move."
          (cond
           ((ignore-errors (org-list-indent-item-generic 1 t struct)))
           ((ignore-errors (org-list-indent-item-generic -1 t struct)))
-          (t (error "Cannot move item"))))
+          (t (user-error "Cannot move item"))))
        t))))
 
 (defun org-sort-list (&optional with-case sorting-type getkey-func compare-func)
@@ -2787,13 +2807,14 @@ optional argument WITH-CASE, the sorting considers case as well.
 
 The command prompts for the sorting type unless it has been given
 to the function through the SORTING-TYPE argument, which needs to
-be a character, \(?n ?N ?a ?A ?t ?T ?f ?F).  Here is the precise
-meaning of each character:
+be a character, \(?n ?N ?a ?A ?t ?T ?f ?F ?x ?X).  Here is the
+detailed meaning of each character:
 
 n   Numerically, by converting the beginning of the item to a number.
 a   Alphabetically.  Only the first line of item is checked.
 t   By date/time, either the first active time stamp in the entry, if
     any, or by the first inactive one.  In a timer list, sort the timers.
+x   By \"checked\" status of a check list.
 
 Capital letters will reverse the sort order.
 
@@ -2801,7 +2822,10 @@ If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies
 a function to be called with point at the beginning of the
 record.  It must return either a string or a number that should
 serve as the sorting key for that record.  It will then use
-COMPARE-FUNC to compare entries."
+COMPARE-FUNC to compare entries.
+
+Sorting is done against the visible part of the headlines, it
+ignores hidden links."
   (interactive "P")
   (let* ((case-func (if with-case 'identity 'downcase))
          (struct (org-list-struct))
@@ -2809,13 +2833,16 @@ COMPARE-FUNC to compare entries."
         (start (org-list-get-list-begin (point-at-bol) struct prevs))
         (end (org-list-get-list-end (point-at-bol) struct prevs))
         (sorting-type
-         (progn
-           (message
-            "Sort plain list: [a]lpha  [n]umeric  [t]ime  [f]unc   A/N/T/F means reversed:")
-           (read-char-exclusive)))
-        (getkey-func (and (= (downcase sorting-type) ?f)
-                          (intern (org-icompleting-read "Sort using function: "
-                                                        obarray 'fboundp t nil nil)))))
+         (or sorting-type
+             (progn
+               (message
+                "Sort plain list: [a]lpha  [n]umeric  [t]ime  [f]unc  [x]checked  A/N/T/F/X means reversed:")
+               (read-char-exclusive))))
+        (getkey-func
+         (or getkey-func
+             (and (= (downcase sorting-type) ?f)
+                  (intern (org-icompleting-read "Sort using function: "
+                                                obarray 'fboundp t nil nil))))))
     (message "Sorting items...")
     (save-restriction
       (narrow-to-region start end)
@@ -2826,10 +2853,11 @@ COMPARE-FUNC to compare entries."
             (sort-func (cond
                         ((= dcst ?a) 'string<)
                         ((= dcst ?f) compare-func)
-                        ((= dcst ?t) '<)))
+                        ((= dcst ?t) '<)
+                        ((= dcst ?x) 'string<)))
             (next-record (lambda ()
                            (skip-chars-forward " \r\t\n")
-                           (beginning-of-line)))
+                           (or (eobp) (beginning-of-line))))
             (end-record (lambda ()
                           (goto-char (org-list-get-item-end-before-blank
                                       (point) struct))))
@@ -2838,21 +2866,28 @@ COMPARE-FUNC to compare entries."
                (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+")
                  (cond
                   ((= dcst ?n)
-                   (string-to-number (buffer-substring (match-end 0)
-                                                       (point-at-eol))))
+                   (string-to-number
+                    (org-sort-remove-invisible
+                     (buffer-substring (match-end 0) (point-at-eol)))))
                   ((= dcst ?a)
                    (funcall case-func
-                            (buffer-substring (match-end 0) (point-at-eol))))
+                            (org-sort-remove-invisible
+                             (buffer-substring
+                              (match-end 0) (point-at-eol)))))
                   ((= dcst ?t)
                    (cond
                     ;; If it is a timer list, convert timer to seconds
                     ((org-at-item-timer-p)
                      (org-timer-hms-to-secs (match-string 1)))
-                    ((or (re-search-forward org-ts-regexp (point-at-eol) t)
-                         (re-search-forward org-ts-regexp-both
-                                            (point-at-eol) t))
+                    ((or (save-excursion
+                           (re-search-forward org-ts-regexp (point-at-eol) t))
+                         (save-excursion (re-search-forward org-ts-regexp-both
+                                                            (point-at-eol) t)))
                      (org-time-string-to-seconds (match-string 0)))
                     (t (org-float-time now))))
+                  ((= dcst ?x) (or (and (stringp (match-string 1))
+                                        (match-string 1))
+                                   ""))
                   ((= dcst ?f)
                    (if getkey-func
                        (let ((value (funcall getkey-func)))
@@ -3021,9 +3056,8 @@ for this list."
     (unless (org-at-item-p) (error "Not at a list item"))
     (save-excursion
       (re-search-backward "#\\+ORGLST" nil t)
-      (unless (looking-at "[ \t]*#\\+ORGLST[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
-       (if maybe
-           (throw 'exit nil)
+      (unless (looking-at "#\\+ORGLST:[ \t]+SEND[ \t]+\\(\\S-+\\)[ \t]+\\(\\S-+\\)")
+       (if maybe (throw 'exit nil)
          (error "Don't know how to transform this list"))))
     (let* ((name (match-string 1))
           (transform (intern (match-string 2)))
@@ -3037,13 +3071,11 @@ for this list."
              (re-search-backward "#\\+ORGLST" nil t)
              (re-search-forward (org-item-beginning-re) bottom-point t)
              (match-beginning 0)))
-          (list (save-restriction
-                  (narrow-to-region top-point bottom-point)
-                  (org-list-parse-list)))
+          (plain-list (buffer-substring-no-properties top-point bottom-point))
           beg txt)
       (unless (fboundp transform)
        (error "No such transformation function %s" transform))
-      (let ((txt (funcall transform list)))
+      (let ((txt (funcall transform plain-list)))
        ;; Find the insertion place
        (save-excursion
          (goto-char (point-min))
@@ -3200,65 +3232,24 @@ items."
 
 (defun org-list-to-latex (list &optional params)
   "Convert LIST into a LaTeX list.
-LIST is as returned by `org-list-parse-list'.  PARAMS is a property list
-with overruling parameters for `org-list-to-generic'."
-  (org-list-to-generic
-   list
-   (org-combine-plists
-    '(:splice nil :ostart "\\begin{enumerate}\n" :oend "\\end{enumerate}"
-             :ustart "\\begin{itemize}\n" :uend "\\end{itemize}"
-             :dstart "\\begin{description}\n" :dend "\\end{description}"
-             :dtstart "[" :dtend "] "
-             :istart "\\item " :iend "\n"
-             :icount (let ((enum (nth depth '("i" "ii" "iii" "iv"))))
-                       (if enum
-                           ;; LaTeX increments counter just before
-                           ;; using it, so set it to the desired
-                           ;; value, minus one.
-                           (format "\\setcounter{enum%s}{%s}\n\\item "
-                                   enum (1- counter))
-                         "\\item "))
-             :csep "\n"
-             :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}"
-             :cbtrans "\\texttt{[-]}")
-    params)))
-
-(defun org-list-to-html (list &optional params)
+LIST is as string representing the list to transform, as Org
+syntax.  Return converted list as a string."
+  (require 'ox-latex)
+  (org-export-string-as list 'latex t))
+
+(defun org-list-to-html (list)
   "Convert LIST into a HTML list.
-LIST is as returned by `org-list-parse-list'.  PARAMS is a property list
-with overruling parameters for `org-list-to-generic'."
-  (org-list-to-generic
-   list
-   (org-combine-plists
-    '(:splice nil :ostart "<ol>\n" :oend "\n</ol>"
-             :ustart "<ul>\n" :uend "\n</ul>"
-             :dstart "<dl>\n" :dend "\n</dl>"
-             :dtstart "<dt>" :dtend "</dt>\n"
-             :ddstart "<dd>" :ddend "</dd>"
-             :istart "<li>" :iend "</li>"
-             :icount (format "<li value=\"%s\">" counter)
-             :isep "\n" :lsep "\n" :csep "\n"
-             :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>"
-             :cbtrans "<code>[-]</code>")
-    params)))
+LIST is as string representing the list to transform, as Org
+syntax.  Return converted list as a string."
+  (require 'ox-html)
+  (org-export-string-as list 'html t))
 
 (defun org-list-to-texinfo (list &optional params)
   "Convert LIST into a Texinfo list.
-LIST is as returned by `org-list-parse-list'.  PARAMS is a property list
-with overruling parameters for `org-list-to-generic'."
-  (org-list-to-generic
-   list
-   (org-combine-plists
-    '(:splice nil :ostart "@itemize @minus\n" :oend "@end itemize"
-             :ustart "@enumerate\n" :uend "@end enumerate"
-             :dstart "@table @asis\n" :dend "@end table"
-             :dtstart " " :dtend "\n"
-             :istart "@item\n" :iend "\n"
-             :icount "@item\n"
-             :csep "\n"
-             :cbon "@code{[X]}" :cboff "@code{[ ]}"
-             :cbtrans "@code{[-]}")
-    params)))
+LIST is as string representing the list to transform, as Org
+syntax.  Return converted list as a string."
+  (require 'ox-texinfo)
+  (org-export-string-as list 'texinfo t))
 
 (defun org-list-to-subtree (list &optional params)
   "Convert LIST into an Org subtree.
diff --git a/lisp/org/org-lparse.el b/lisp/org/org-lparse.el
deleted file mode 100644 (file)
index 1171135..0000000
+++ /dev/null
@@ -1,2303 +0,0 @@
-;;; org-lparse.el --- Line-oriented parser-exporter for Org-mode
-
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
-
-;; Author: Jambunathan K <kjambunathan at gmail dot com>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; `org-lparse' is the entry point for the generic line-oriented
-;; exporter.  `org-do-lparse' is the genericized version of the
-;; original `org-export-as-html' routine.
-
-;; `org-lparse-native-backends' is a good starting point for
-;; exploring the generic exporter.
-
-;; Following new interactive commands are provided by this library.
-;; `org-lparse', `org-lparse-and-open', `org-lparse-to-buffer'
-;; `org-replace-region-by', `org-lparse-region'.
-
-;; Note that the above routines correspond to the following routines
-;; in the html exporter `org-export-as-html',
-;; `org-export-as-html-and-open', `org-export-as-html-to-buffer',
-;; `org-replace-region-by-html' and `org-export-region-as-html'.
-
-;; The new interactive command `org-lparse-convert' can be used to
-;; convert documents between various formats.  Use this to command,
-;; for example, to convert odt file to doc or pdf format.
-
-;;; Code:
-(eval-when-compile
-  (require 'cl))
-(require 'org-exp)
-(require 'org-list)
-(require 'format-spec)
-
-(defun org-lparse-and-open (target-backend native-backend arg
-                                          &optional file-or-buf)
-  "Export outline to TARGET-BACKEND via NATIVE-BACKEND and open exported file.
-If there is an active region, export only the region.  The prefix
-ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will become bulleted
-lists."
-  (let (f (file-or-buf (or file-or-buf
-                          (org-lparse target-backend native-backend
-                                      arg 'hidden))))
-    (when file-or-buf
-      (setq f (cond
-              ((bufferp file-or-buf) buffer-file-name)
-              ((file-exists-p file-or-buf) file-or-buf)
-              (t (error "org-lparse-and-open: This shouldn't happen"))))
-      (message "Opening file %s" f)
-      (org-open-file f 'system)
-      (when org-export-kill-product-buffer-when-displayed
-       (kill-buffer (current-buffer))))))
-
-(defun org-lparse-batch (target-backend &optional native-backend)
-  "Call the function `org-lparse'.
-This function can be used in batch processing as:
-emacs   --batch
-        --load=$HOME/lib/emacs/org.el
-        --eval \"(setq org-export-headline-levels 2)\"
-        --visit=MyFile --funcall org-lparse-batch"
-  (setq native-backend (or native-backend target-backend))
-  (org-lparse target-backend native-backend
-             org-export-headline-levels 'hidden))
-
-(defun org-lparse-to-buffer (backend arg)
-  "Call `org-lparse' with output to a temporary buffer.
-No file is created.  The prefix ARG is passed through to
-`org-lparse'."
-  (let ((tempbuf (format "*Org %s Export*" (upcase backend))))
-    (org-lparse backend backend arg nil nil tempbuf)
-    (when org-export-show-temporary-export-buffer
-      (switch-to-buffer-other-window tempbuf))))
-
-(defun org-replace-region-by (backend beg end)
-  "Assume the current region has org-mode syntax, and convert it to HTML.
-This can be used in any buffer.  For example, you could write an
-itemized list in org-mode syntax in an HTML buffer and then use
-this command to convert it."
-  (let (reg backend-string buf pop-up-frames)
-    (save-window-excursion
-      (if (derived-mode-p 'org-mode)
-         (setq backend-string (org-lparse-region backend beg end t 'string))
-       (setq reg (buffer-substring beg end)
-             buf (get-buffer-create "*Org tmp*"))
-       (with-current-buffer buf
-         (erase-buffer)
-         (insert reg)
-         (org-mode)
-         (setq backend-string (org-lparse-region backend (point-min)
-                                                 (point-max) t 'string)))
-       (kill-buffer buf)))
-    (delete-region beg end)
-    (insert backend-string)))
-
-(defun org-lparse-region (backend beg end &optional body-only buffer)
-  "Convert region from BEG to END in org-mode buffer to HTML.
-If prefix arg BODY-ONLY is set, omit file header, footer, and table of
-contents, and only produce the region of converted text, useful for
-cut-and-paste operations.
-If BUFFER is a buffer or a string, use/create that buffer as a target
-of the converted HTML.  If BUFFER is the symbol `string', return the
-produced HTML as a string and leave not buffer behind.  For example,
-a Lisp program could call this function in the following way:
-
-  (setq html (org-lparse-region \"html\" beg end t 'string))
-
-When called interactively, the output buffer is selected, and shown
-in a window.  A non-interactive call will only return the buffer."
-  (let ((transient-mark-mode t) (zmacs-regions t)
-       ext-plist rtn)
-    (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
-    (goto-char end)
-    (set-mark (point)) ;; to activate the region
-    (goto-char beg)
-    (setq rtn (org-lparse backend backend nil nil ext-plist buffer body-only))
-    (if (fboundp 'deactivate-mark) (deactivate-mark))
-    (if (and (org-called-interactively-p 'any) (bufferp rtn))
-       (switch-to-buffer-other-window rtn)
-      rtn)))
-
-(defvar org-lparse-par-open nil)
-
-(defun org-lparse-should-inline-p (filename descp)
-  "Return non-nil if link FILENAME should be inlined.
-The decision to inline the FILENAME link is based on the current
-settings.  DESCP is the boolean of whether there was a link
-description.  See variables `org-export-html-inline-images' and
-`org-export-html-inline-image-extensions'."
-  (let ((inline-images (org-lparse-get 'INLINE-IMAGES))
-       (inline-image-extensions
-        (org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
-    (and (or (eq t inline-images) (and inline-images (not descp)))
-        (org-file-image-p filename inline-image-extensions))))
-
-(defun org-lparse-format-org-link (line opt-plist)
-  "Return LINE with markup of Org mode links.
-OPT-PLIST is the export options list."
-  (let ((start 0)
-       (current-dir (if buffer-file-name
-                        (file-name-directory buffer-file-name)
-                      default-directory))
-       (link-validate (plist-get opt-plist :link-validation-function))
-       type id-file fnc
-       rpl path attr desc descp desc1 desc2 link
-       org-lparse-link-description-is-image)
-    (while (string-match org-bracket-link-analytic-regexp++ line start)
-      (setq org-lparse-link-description-is-image nil)
-      (setq start (match-beginning 0))
-      (setq path (save-match-data (org-link-unescape
-                                  (match-string 3 line))))
-      (setq type (cond
-                 ((match-end 2) (match-string 2 line))
-                 ((save-match-data
-                    (or (file-name-absolute-p path)
-                        (string-match "^\\.\\.?/" path)))
-                  "file")
-                 (t "internal")))
-      (setq path (org-extract-attributes path))
-      (setq attr (get-text-property 0 'org-attributes path))
-      (setq desc1 (if (match-end 5) (match-string 5 line))
-           desc2 (if (match-end 2) (concat type ":" path) path)
-           descp (and desc1 (not (equal desc1 desc2)))
-           desc (or desc1 desc2))
-      ;; Make an image out of the description if that is so wanted
-      (when (and descp (org-file-image-p
-                       desc (org-lparse-get 'INLINE-IMAGE-EXTENSIONS)))
-       (setq org-lparse-link-description-is-image t)
-       (save-match-data
-         (if (string-match "^file:" desc)
-             (setq desc (substring desc (match-end 0)))))
-       (save-match-data
-         (setq desc (org-add-props
-                        (org-lparse-format 'INLINE-IMAGE desc)
-                        '(org-protected t)))))
-      (cond
-       ((equal type "internal")
-       (let
-           ((frag-0
-             (if (= (string-to-char path) ?#)
-                 (substring path 1)
-               path)))
-         (setq rpl
-               (org-lparse-format
-                'ORG-LINK opt-plist "" "" (org-solidify-link-text
-                                           (save-match-data
-                                             (org-link-unescape frag-0))
-                                           nil) desc attr descp))))
-       ((and (equal type "id")
-            (setq id-file (org-id-find-id-file path)))
-       ;; This is an id: link to another file (if it was the same file,
-       ;; it would have become an internal link...)
-       (save-match-data
-         (setq id-file (file-relative-name
-                        id-file
-                        (file-name-directory org-current-export-file)))
-         (setq rpl
-               (org-lparse-format
-                'ORG-LINK opt-plist type id-file
-                (concat (if (org-uuidgen-p path) "ID-") path)
-                desc attr descp))))
-       ((member type '("http" "https"))
-       ;; standard URL, can inline as image
-       (setq rpl
-             (org-lparse-format
-              'ORG-LINK opt-plist type path nil desc attr descp)))
-       ((member type '("ftp" "mailto" "news"))
-       ;; standard URL, can't inline as image
-       (setq rpl
-             (org-lparse-format
-              'ORG-LINK opt-plist type path nil desc attr descp)))
-
-       ((string= type "coderef")
-       (setq rpl (org-lparse-format
-                  'ORG-LINK opt-plist type "" path desc nil descp)))
-
-       ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
-       ;; The link protocol has a function for format the link
-       (setq rpl (save-match-data
-                   (funcall fnc (org-link-unescape path)
-                            desc1 (and (boundp 'org-lparse-backend)
-                                       (case org-lparse-backend
-                                         (xhtml 'html)
-                                         (t org-lparse-backend)))))))
-       ((string= type "file")
-       ;; FILE link
-       (save-match-data
-         (let*
-             ((components
-               (if
-                   (string-match "::\\(.*\\)" path)
-                   (list
-                    (replace-match "" t nil path)
-                    (match-string 1 path))
-                 (list path nil)))
-
-              ;;The proper path, without a fragment
-              (path-1
-               (first components))
-
-              ;;The raw fragment
-              (fragment-0
-               (second components))
-
-              ;;Check the fragment.  If it can't be used as
-              ;;target fragment we'll pass nil instead.
-              (fragment-1
-               (if
-                   (and fragment-0
-                        (not (string-match "^[0-9]*$" fragment-0))
-                        (not (string-match "^\\*" fragment-0))
-                        (not (string-match "^/.*/$" fragment-0)))
-                   (org-solidify-link-text
-                    (org-link-unescape fragment-0))
-                 nil))
-              (desc-2
-               ;;Description minus "file:" and ".org"
-               (if (string-match "^file:" desc)
-                   (let
-                       ((desc-1 (replace-match "" t t desc)))
-                     (if (string-match "\\.org$" desc-1)
-                         (replace-match "" t t desc-1)
-                       desc-1))
-                 desc)))
-
-           (setq rpl
-                 (if
-                     (and
-                      (functionp link-validate)
-                      (not (funcall link-validate path-1 current-dir)))
-                     desc
-                   (org-lparse-format
-                    'ORG-LINK opt-plist "file" path-1 fragment-1
-                    desc-2 attr descp))))))
-
-       (t
-       ;; just publish the path, as default
-       (setq rpl (concat "<i>&lt;" type ":"
-                         (save-match-data (org-link-unescape path))
-                         "&gt;</i>"))))
-      (setq line (replace-match rpl t t line)
-           start (+ start (length rpl))))
-    line))
-
-(defvar org-lparse-par-open-stashed)   ; bound during `org-do-lparse'
-(defun org-lparse-stash-save-paragraph-state ()
-  (assert (zerop org-lparse-par-open-stashed))
-  (setq org-lparse-par-open-stashed org-lparse-par-open)
-  (setq org-lparse-par-open nil))
-
-(defun org-lparse-stash-pop-paragraph-state ()
-  (setq org-lparse-par-open org-lparse-par-open-stashed)
-  (setq org-lparse-par-open-stashed 0))
-
-(defmacro with-org-lparse-preserve-paragraph-state (&rest body)
-  `(let ((org-lparse-do-open-par org-lparse-par-open))
-     (org-lparse-end-paragraph)
-     ,@body
-     (when org-lparse-do-open-par
-       (org-lparse-begin-paragraph))))
-(def-edebug-spec with-org-lparse-preserve-paragraph-state (body))
-
-(defvar org-lparse-native-backends nil
-  "List of native backends registered with `org-lparse'.
-A backend can use `org-lparse-register-backend' to add itself to
-this list.
-
-All native backends must implement a get routine and a mandatory
-set of callback routines.
-
-The get routine must be named as org-<backend>-get where backend
-is the name of the backend.  The exporter uses `org-lparse-get'
-and retrieves the backend-specific callback by querying for
-ENTITY-CONTROL and ENTITY-FORMAT variables.
-
-For the sake of illustration, the html backend implements
-`org-xhtml-get'.  It returns
-`org-xhtml-entity-control-callbacks-alist' and
-`org-xhtml-entity-format-callbacks-alist' as the values of
-ENTITY-CONTROL and ENTITY-FORMAT settings.")
-
-(defun org-lparse-register-backend (backend)
-  "Make BACKEND known to `org-lparse' library.
-Add BACKEND to `org-lparse-native-backends'."
-  (when backend
-    (setq backend (cond
-                  ((symbolp backend) (symbol-name backend))
-                  ((stringp backend) backend)
-                  (t (error "Error while registering backend: %S" backend))))
-    (add-to-list 'org-lparse-native-backends backend)))
-
-(defun org-lparse-unregister-backend (backend)
-  (setq org-lparse-native-backends
-       (remove (cond
-                ((symbolp backend) (symbol-name backend))
-                ((stringp backend) backend))
-               org-lparse-native-backends))
-  (message "Unregistered backend %S" backend))
-
-(defun org-lparse-do-reachable-formats (in-fmt)
-  "Return verbose info about formats to which IN-FMT can be converted.
-Return a list where each element is of the
-form (CONVERTER-PROCESS . OUTPUT-FMT-ALIST).  See
-`org-export-odt-convert-processes' for CONVERTER-PROCESS and see
-`org-export-odt-convert-capabilities' for OUTPUT-FMT-ALIST."
-  (let (reachable-formats)
-    (dolist (backend org-lparse-native-backends reachable-formats)
-      (let* ((converter (org-lparse-backend-get
-                        backend 'CONVERT-METHOD))
-            (capabilities (org-lparse-backend-get
-                           backend 'CONVERT-CAPABILITIES)))
-       (when converter
-         (dolist (c capabilities)
-           (when (member in-fmt (nth 1 c))
-             (push (cons converter (nth 2 c)) reachable-formats))))))))
-
-(defun org-lparse-reachable-formats (in-fmt)
-  "Return list of formats to which IN-FMT can be converted.
-The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
-  (let (l)
-    (mapc (lambda (e) (add-to-list 'l e))
-         (apply 'append (mapcar
-                         (lambda (e) (mapcar 'car (cdr e)))
-                         (org-lparse-do-reachable-formats in-fmt))))
-    l))
-
-(defun org-lparse-reachable-p (in-fmt out-fmt)
-  "Return non-nil if IN-FMT can be converted to OUT-FMT."
-  (catch 'done
-    (let ((reachable-formats (org-lparse-do-reachable-formats in-fmt)))
-      (dolist (e reachable-formats)
-       (let ((out-fmt-spec (assoc out-fmt (cdr e))))
-         (when out-fmt-spec
-           (throw 'done (cons (car e) out-fmt-spec))))))))
-
-(defun org-lparse-backend-is-native-p (backend)
-  (member backend org-lparse-native-backends))
-
-(defun org-lparse (target-backend native-backend arg
-                                 &optional hidden ext-plist
-                                 to-buffer body-only pub-dir)
-  "Export the outline to various formats.
-If there is an active region, export only the region.  The
-outline is first exported to NATIVE-BACKEND and optionally
-converted to TARGET-BACKEND.  See `org-lparse-native-backends'
-for list of known native backends.  Each native backend can
-specify a converter and list of target backends it exports to
-using the CONVERT-PROCESS and OTHER-BACKENDS settings of it's get
-method.  See `org-xhtml-get' for an illustrative example.
-
-ARG is a prefix argument that specifies how many levels of
-outline should become headlines.  The default is 3.  Lower levels
-will become bulleted lists.
-
-HIDDEN is obsolete and does nothing.
-
-EXT-PLIST is a property list that controls various aspects of
-export.  The settings here override org-mode's default settings
-and but are inferior to file-local settings.
-
-TO-BUFFER dumps the exported lines to a buffer or a string
-instead of a file.  If TO-BUFFER is the symbol `string' return the
-exported lines as a string.  If TO-BUFFER is non-nil, create a
-buffer with that name and export to that buffer.
-
-BODY-ONLY controls the presence of header and footer lines in
-exported text.  If BODY-ONLY is non-nil, don't produce the file
-header and footer, simply return the content of <body>...</body>,
-without even the body tags themselves.
-
-PUB-DIR specifies the publishing directory."
-  (let* ((org-lparse-backend (intern native-backend))
-        (org-lparse-other-backend (and target-backend
-                                       (intern target-backend))))
-    (add-hook 'org-export-preprocess-hook
-             'org-lparse-strip-experimental-blocks-maybe)
-    (add-hook 'org-export-preprocess-after-blockquote-hook
-             'org-lparse-preprocess-after-blockquote)
-    (unless (org-lparse-backend-is-native-p native-backend)
-      (error "Don't know how to export natively to backend %s" native-backend))
-
-    (unless (or (equal native-backend target-backend)
-               (org-lparse-reachable-p native-backend target-backend))
-      (error "Don't know how to export to backend %s %s" target-backend
-            (format "via %s" native-backend)))
-    (run-hooks 'org-export-first-hook)
-    (prog1
-       (org-do-lparse arg hidden ext-plist to-buffer body-only pub-dir)
-      (remove-hook 'org-export-preprocess-hook
-                  'org-lparse-strip-experimental-blocks-maybe)
-      (remove-hook 'org-export-preprocess-after-blockquote-hook
-                  'org-lparse-preprocess-after-blockquote))))
-
-(defcustom org-lparse-use-flashy-warning nil
-  "Control flashing of messages logged with `org-lparse-warn'.
-When non-nil, messages are fontified with warning face and the
-exporter lingers for a while to catch user's attention."
-  :type 'boolean
-  :group 'org-lparse)
-
-(defun org-lparse-convert-read-params ()
-  "Return IN-FILE and OUT-FMT params for `org-lparse-do-convert'.
-This is a helper routine for interactive use."
-  (let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
-        (in-file (read-file-name "File to be converted: "
-                                 nil buffer-file-name t))
-        (in-fmt (file-name-extension in-file))
-        (out-fmt-choices (org-lparse-reachable-formats in-fmt))
-        (out-fmt
-         (or (and out-fmt-choices
-                  (funcall input "Output format:  "
-                           out-fmt-choices nil nil nil))
-             (error
-              "No known converter or no known output formats for %s files"
-              in-fmt))))
-    (list in-file out-fmt)))
-
-(eval-when-compile
-  (require 'browse-url))
-
-(declare-function browse-url-file-url "browse-url" (file))
-
-(defun org-lparse-do-convert (in-file out-fmt &optional prefix-arg)
-  "Workhorse routine for `org-export-odt-convert'."
-  (require 'browse-url)
-  (let* ((in-file (expand-file-name (or in-file buffer-file-name)))
-        (dummy (or (file-readable-p in-file)
-                   (error "Cannot read %s" in-file)))
-        (in-fmt (file-name-extension in-file))
-        (out-fmt (or out-fmt (error "Output format unspecified")))
-        (how (or (org-lparse-reachable-p in-fmt out-fmt)
-                 (error "Cannot convert from %s format to %s format?"
-                        in-fmt out-fmt)))
-        (convert-process (car how))
-        (out-file (concat (file-name-sans-extension in-file) "."
-                          (nth 1 (or (cdr how) out-fmt))))
-        (extra-options (or (nth 2 (cdr how)) ""))
-        (out-dir (file-name-directory in-file))
-        (cmd (format-spec convert-process
-                          `((?i . ,(shell-quote-argument in-file))
-                            (?I . ,(browse-url-file-url in-file))
-                            (?f . ,out-fmt)
-                            (?o . ,out-file)
-                            (?O . ,(browse-url-file-url out-file))
-                            (?d . , (shell-quote-argument out-dir))
-                            (?D . ,(browse-url-file-url out-dir))
-                            (?x . ,extra-options)))))
-    (when (file-exists-p out-file)
-      (delete-file out-file))
-
-    (message "Executing %s" cmd)
-    (let ((cmd-output (shell-command-to-string cmd)))
-      (message "%s" cmd-output))
-
-    (cond
-     ((file-exists-p out-file)
-      (message "Exported to %s" out-file)
-      (when prefix-arg
-       (message "Opening %s..."  out-file)
-       (org-open-file out-file 'system))
-      out-file)
-     (t
-      (message "Export to %s failed" out-file)
-      nil))))
-
-(defvar org-lparse-insert-tag-with-newlines 'both)
-
-;; Following variables are let-bound during `org-lparse'
-(defvar org-lparse-dyn-first-heading-pos)
-(defvar org-lparse-toc)
-(defvar org-lparse-entity-control-callbacks-alist)
-(defvar org-lparse-entity-format-callbacks-alist)
-(defvar org-lparse-backend nil
-  "The native backend to which the document is currently exported.
-This variable is let bound during `org-lparse'.  Valid values are
-one of the symbols corresponding to `org-lparse-native-backends'.
-
-Compare this variable with `org-export-current-backend' which is
-bound only during `org-export-preprocess-string' stage of the
-export process.
-
-See also `org-lparse-other-backend'.")
-
-(defvar org-lparse-other-backend nil
-  "The target backend to which the document is currently exported.
-This variable is let bound during `org-lparse'.  This variable is
-set to either `org-lparse-backend' or one of the symbols
-corresponding to OTHER-BACKENDS specification of the
-org-lparse-backend.
-
-For example, if a document is exported to \"odt\" then both
-org-lparse-backend and org-lparse-other-backend are bound to
-'odt.  On the other hand, if a document is exported to \"odt\"
-and then converted to \"doc\" then org-lparse-backend is set to
-'odt and org-lparse-other-backend is set to 'doc.")
-
-(defvar org-lparse-body-only nil
-  "Bind this to BODY-ONLY arg of `org-lparse'.")
-
-(defvar org-lparse-to-buffer nil
-  "Bind this to TO-BUFFER arg of `org-lparse'.")
-
-(defun org-lparse-get-block-params (params)
-  (save-match-data
-    (when params
-      (setq params (org-trim params))
-      (unless (string-match "\\`(.*)\\'" params)
-       (setq params (format "(%s)" params)))
-      (ignore-errors (read params)))))
-
-(defvar org-heading-keyword-regexp-format) ; defined in org.el
-(defvar org-lparse-special-blocks '("list-table" "annotation"))
-(defun org-do-lparse (arg &optional hidden ext-plist
-                         to-buffer body-only pub-dir)
-  "Export the outline to various formats.
-See `org-lparse' for more information.  This function is a
-html-agnostic version of the `org-export-as-html' function in 7.5
-version."
-  ;; Make sure we have a file name when we need it.
-  (when (and (not (or to-buffer body-only))
-            (not buffer-file-name))
-    (if (buffer-base-buffer)
-       (org-set-local 'buffer-file-name
-                      (with-current-buffer (buffer-base-buffer)
-                        buffer-file-name))
-      (error "Need a file name to be able to export")))
-
-  (org-lparse-warn
-   (format "Exporting to %s using org-lparse..."
-          (upcase (symbol-name
-                   (or org-lparse-backend org-lparse-other-backend)))))
-
-  (setq-default org-todo-line-regexp org-todo-line-regexp)
-  (setq-default org-deadline-line-regexp org-deadline-line-regexp)
-  (setq-default org-done-keywords org-done-keywords)
-  (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
-  (let* (hfy-user-sheet-assoc          ; let `htmlfontify' know that
-                                       ; we are interested in
-                                       ; collecting styles
-        org-lparse-encode-pending
-        org-lparse-par-open
-        (org-lparse-par-open-stashed 0)
-
-        ;; list related vars
-        (org-lparse-list-stack '())
-
-        ;; list-table related vars
-        org-lparse-list-table-p
-        org-lparse-list-table:table-cell-open
-        org-lparse-list-table:table-row
-        org-lparse-list-table:lines
-
-        org-lparse-outline-text-open
-        (org-lparse-latex-fragment-fallback ; currently used only by
-                                       ; odt exporter
-         (or (ignore-errors (org-lparse-get 'LATEX-FRAGMENT-FALLBACK))
-             (if (and (org-check-external-command "latex" "" t)
-                      (org-check-external-command "dvipng" "" t))
-                 'dvipng
-               'verbatim)))
-        (org-lparse-insert-tag-with-newlines 'both)
-        (org-lparse-to-buffer to-buffer)
-        (org-lparse-body-only body-only)
-        (org-lparse-entity-control-callbacks-alist
-         (org-lparse-get 'ENTITY-CONTROL))
-        (org-lparse-entity-format-callbacks-alist
-         (org-lparse-get 'ENTITY-FORMAT))
-        (opt-plist
-         (org-export-process-option-filters
-          (org-combine-plists (org-default-export-plist)
-                              ext-plist
-                              (org-infile-export-plist))))
-        (body-only (or body-only (plist-get opt-plist :body-only)))
-        valid org-lparse-dyn-first-heading-pos
-        (odd org-odd-levels-only)
-        (region-p (org-region-active-p))
-        (rbeg (and region-p (region-beginning)))
-        (rend (and region-p (region-end)))
-        (subtree-p
-         (if (plist-get opt-plist :ignore-subtree-p)
-             nil
-           (when region-p
-             (save-excursion
-               (goto-char rbeg)
-               (and (org-at-heading-p)
-                    (>= (org-end-of-subtree t t) rend))))))
-        (level-offset (if subtree-p
-                          (save-excursion
-                            (goto-char rbeg)
-                            (+ (funcall outline-level)
-                               (if org-odd-levels-only 1 0)))
-                        0))
-        (opt-plist (setq org-export-opt-plist
-                         (if subtree-p
-                             (org-export-add-subtree-options opt-plist rbeg)
-                           opt-plist)))
-        ;; The following two are dynamically scoped into other
-        ;; routines below.
-        (org-current-export-dir
-         (or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist)))
-        (org-current-export-file buffer-file-name)
-        (level 0) (line "") (origline "") txt todo
-        (umax nil)
-        (umax-toc nil)
-        (filename (if to-buffer nil
-                    (expand-file-name
-                     (concat
-                      (file-name-sans-extension
-                       (or (and subtree-p
-                                (org-entry-get (region-beginning)
-                                               "EXPORT_FILE_NAME" t))
-                           (file-name-nondirectory buffer-file-name)))
-                      "." (org-lparse-get 'FILE-NAME-EXTENSION opt-plist))
-                     (file-name-as-directory
-                      (or pub-dir (org-lparse-get 'EXPORT-DIR opt-plist))))))
-        (current-dir (if buffer-file-name
-                         (file-name-directory buffer-file-name)
-                       default-directory))
-        (auto-insert nil) ; Avoid any auto-insert stuff for the new file
-        (buffer (if to-buffer
-                    (cond
-                     ((eq to-buffer 'string)
-                      (get-buffer-create (org-lparse-get 'EXPORT-BUFFER-NAME)))
-                     (t (get-buffer-create to-buffer)))
-                  (find-file-noselect
-                   (or (let ((f (org-lparse-get 'INIT-METHOD)))
-                         (and f (functionp f) (funcall f filename)))
-                       filename))))
-        (org-levels-open (make-vector org-level-max nil))
-        (dummy (mapc
-                (lambda(p)
-                  (let* ((val (plist-get opt-plist p))
-                         (val (org-xml-encode-org-text-skip-links val)))
-                    (setq opt-plist (plist-put opt-plist p val))))
-                '(:date :author :keywords :description)))
-        (date (plist-get opt-plist :date))
-        (date (cond
-               ((and date (string-match "%" date))
-                (format-time-string date))
-               (date date)
-               (t (format-time-string "%Y-%m-%d %T %Z"))))
-        (dummy (setq opt-plist (plist-put opt-plist :effective-date date)))
-        (title       (org-xml-encode-org-text-skip-links
-                      (or (and subtree-p (org-export-get-title-from-subtree))
-                          (plist-get opt-plist :title)
-                          (and (not body-only)
-                               (not
-                                (plist-get opt-plist :skip-before-1st-heading))
-                               (org-export-grab-title-from-buffer))
-                          (and buffer-file-name
-                               (file-name-sans-extension
-                                (file-name-nondirectory buffer-file-name)))
-                          "UNTITLED")))
-        (dummy (setq opt-plist (plist-put opt-plist :title title)))
-        (html-table-tag (plist-get opt-plist :html-table-tag))
-        (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)"))
-        (quote-re (format org-heading-keyword-regexp-format
-                          org-quote-string))
-        (org-lparse-dyn-current-environment nil)
-        ;; Get the language-dependent settings
-        (lang-words (or (assoc (plist-get opt-plist :language)
-                               org-export-language-setup)
-                        (assoc "en" org-export-language-setup)))
-        (dummy (setq opt-plist (plist-put opt-plist :lang-words lang-words)))
-        (head-count  0) cnt
-        (start       0)
-        (coding-system-for-write
-         (or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-WRITE))
-             (and (boundp 'buffer-file-coding-system)
-                  buffer-file-coding-system)))
-        (save-buffer-coding-system
-         (or (ignore-errors (org-lparse-get 'CODING-SYSTEM-FOR-SAVE))
-             (and (boundp 'buffer-file-coding-system)
-                  buffer-file-coding-system)))
-        (region
-         (buffer-substring
-          (if region-p (region-beginning) (point-min))
-          (if region-p (region-end) (point-max))))
-        (org-export-have-math nil)
-        (org-export-footnotes-seen nil)
-        (org-export-footnotes-data (org-footnote-all-labels 'with-defs))
-        (org-footnote-insert-pos-for-preprocessor 'point-min)
-        (org-lparse-opt-plist opt-plist)
-        (lines
-         (org-split-string
-          (org-export-preprocess-string
-           region
-           :emph-multiline t
-           :for-backend (if (equal org-lparse-backend 'xhtml) ; hack
-                            'html
-                          org-lparse-backend)
-           :skip-before-1st-heading
-           (plist-get opt-plist :skip-before-1st-heading)
-           :drawers (plist-get opt-plist :drawers)
-           :todo-keywords (plist-get opt-plist :todo-keywords)
-           :tasks (plist-get opt-plist :tasks)
-           :tags (plist-get opt-plist :tags)
-           :priority (plist-get opt-plist :priority)
-           :footnotes (plist-get opt-plist :footnotes)
-           :timestamps (plist-get opt-plist :timestamps)
-           :archived-trees
-           (plist-get opt-plist :archived-trees)
-           :select-tags (plist-get opt-plist :select-tags)
-           :exclude-tags (plist-get opt-plist :exclude-tags)
-           :add-text
-           (plist-get opt-plist :text)
-           :LaTeX-fragments
-           (plist-get opt-plist :LaTeX-fragments))
-          "[\r\n]"))
-        table-open
-        table-buffer table-orig-buffer
-        ind
-        rpl path attr desc descp desc1 desc2 link
-        snumber fnc
-        footnotes footref-seen
-        org-lparse-output-buffer
-        org-lparse-footnote-definitions
-        org-lparse-footnote-number
-        ;; collection
-        org-lparse-collect-buffer
-        (org-lparse-collect-count 0)   ; things will get haywire if
-                                       ; collections are chained.  Use
-                                       ; this variable to assert this
-                                       ; pre-requisite
-        org-lparse-toc
-        href
-        )
-
-    (let ((inhibit-read-only t))
-      (org-unmodified
-       (remove-text-properties (point-min) (point-max)
-                              '(:org-license-to-kill t))))
-
-    (message "Exporting...")
-    (org-init-section-numbers)
-
-    ;; Switch to the output buffer
-    (setq org-lparse-output-buffer buffer)
-    (set-buffer org-lparse-output-buffer)
-    (let ((inhibit-read-only t)) (erase-buffer))
-    (fundamental-mode)
-    (org-install-letbind)
-
-    (and (fboundp 'set-buffer-file-coding-system)
-        (set-buffer-file-coding-system coding-system-for-write))
-
-    (let ((case-fold-search nil)
-         (org-odd-levels-only odd))
-      ;; create local variables for all options, to make sure all called
-      ;; functions get the correct information
-      (mapc (lambda (x)
-             (set (make-local-variable (nth 2 x))
-                  (plist-get opt-plist (car x))))
-           org-export-plist-vars)
-      (setq umax (if arg (prefix-numeric-value arg)
-                  org-export-headline-levels))
-      (setq umax-toc (if (integerp org-export-with-toc)
-                        (min org-export-with-toc umax)
-                      umax))
-      (setq org-lparse-opt-plist
-           (plist-put org-lparse-opt-plist :headline-levels  umax))
-
-      (when (and org-export-with-toc (not body-only))
-       (setq lines (org-lparse-prepare-toc
-                    lines level-offset opt-plist umax-toc)))
-
-      (unless body-only
-       (org-lparse-begin 'DOCUMENT-CONTENT opt-plist)
-       (org-lparse-begin 'DOCUMENT-BODY opt-plist))
-
-      (setq head-count 0)
-      (org-init-section-numbers)
-
-      (org-lparse-begin-paragraph)
-
-      (while (setq line (pop lines) origline line)
-       (catch 'nextline
-         (when (and (org-lparse-current-environment-p 'quote)
-                    (string-match org-outline-regexp-bol line))
-           (org-lparse-end-environment 'quote))
-
-         (when (org-lparse-current-environment-p 'quote)
-           (org-lparse-insert 'LINE line)
-           (throw 'nextline nil))
-
-         ;; Fixed-width, verbatim lines (examples)
-         (when (and org-export-with-fixed-width
-                    (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
-           (when (not (org-lparse-current-environment-p 'fixedwidth))
-             (org-lparse-begin-environment 'fixedwidth))
-           (org-lparse-insert 'LINE (match-string 3 line))
-           (when (or (not lines)
-                     (not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
-                                        (car lines))))
-             (org-lparse-end-environment 'fixedwidth))
-           (throw 'nextline nil))
-
-         ;; Native Text
-         (when (and (get-text-property 0 'org-native-text line)
-                    ;; Make sure it is the entire line that is protected
-                    (not (< (or (next-single-property-change
-                                 0 'org-native-text line) 10000)
-                            (length line))))
-           (let ((ind (get-text-property 0 'original-indentation line)))
-             (org-lparse-begin-environment 'native)
-             (org-lparse-insert 'LINE line)
-             (while (and lines
-                         (or (= (length (car lines)) 0)
-                             (not ind)
-                             (equal ind (get-text-property
-                                         0 'original-indentation (car lines))))
-                         (or (= (length (car lines)) 0)
-                             (get-text-property 0 'org-native-text (car lines))))
-               (org-lparse-insert 'LINE (pop lines)))
-             (org-lparse-end-environment 'native))
-           (throw 'nextline nil))
-
-         ;; Protected HTML
-         (when (and (get-text-property 0 'org-protected line)
-                    ;; Make sure it is the entire line that is protected
-                    (not (< (or (next-single-property-change
-                                 0 'org-protected line) 10000)
-                            (length line))))
-           (let ((ind (get-text-property 0 'original-indentation line)))
-             (org-lparse-insert 'LINE line)
-             (while (and lines
-                         (or (= (length (car lines)) 0)
-                             (not ind)
-                             (equal ind (get-text-property
-                                         0 'original-indentation (car lines))))
-                         (or (= (length (car lines)) 0)
-                             (get-text-property 0 'org-protected (car lines))))
-               (org-lparse-insert 'LINE (pop lines))))
-           (throw 'nextline nil))
-
-         ;; Blockquotes, verse, and center
-         (when (string-match
-                "^ORG-\\(.+\\)-\\(START\\|END\\)\\([ \t]+.*\\)?$" line)
-           (let* ((style (intern (downcase (match-string 1 line))))
-                  (env-options-plist (org-lparse-get-block-params
-                                      (match-string 3 line)))
-                  (f (cdr (assoc (match-string 2 line)
-                                 '(("START" . org-lparse-begin-environment)
-                                   ("END" . org-lparse-end-environment))))))
-             (when (memq style
-                         (append
-                          '(blockquote verse center)
-                          (mapcar 'intern org-lparse-special-blocks)))
-               (funcall f style env-options-plist)
-               (throw 'nextline nil))))
-
-         (when (org-lparse-current-environment-p 'verse)
-           (let ((i (org-get-string-indentation line)))
-             (if (> i 0)
-                 (setq line (concat
-                             (let ((org-lparse-encode-pending t))
-                               (org-lparse-format 'SPACES (* 2 i)))
-                             " " (org-trim line))))
-             (unless (string-match "\\\\\\\\[ \t]*$" line)
-               (setq line (concat line "\\\\")))))
-
-         ;; make targets to anchors
-         (setq start 0)
-         (while (string-match
-                 "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
-           (cond
-            ((get-text-property (match-beginning 1) 'org-protected line)
-             (setq start (match-end 1)))
-            ((match-end 2)
-             (setq line (replace-match
-                         (let ((org-lparse-encode-pending t))
-                           (org-lparse-format
-                            'ANCHOR "" (org-solidify-link-text
-                                        (match-string 1 line))))
-                         t t line)))
-            ((and org-export-with-toc (equal (string-to-char line) ?*))
-             ;; FIXME: NOT DEPENDENT on TOC?????????????????????
-             (setq line (replace-match
-                         (let ((org-lparse-encode-pending t))
-                           (org-lparse-format
-                            'FONTIFY (match-string 1 line) "target"))
-                         ;; (concat "@<i>" (match-string 1 line) "@</i> ")
-                         t t line)))
-            (t
-             (setq line (replace-match
-                         (concat
-                          (let ((org-lparse-encode-pending t))
-                            (org-lparse-format
-                             'ANCHOR (match-string 1 line)
-                             (org-solidify-link-text (match-string 1 line))
-                             "target")) " ")
-                         t t line)))))
-
-         (let ((org-lparse-encode-pending t))
-           (setq line (org-lparse-handle-time-stamps line)))
-
-         ;; replace "&" by "&amp;", "<" and ">" by "&lt;" and "&gt;"
-         ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
-         ;; Also handle sub_superscripts and checkboxes
-         (or (string-match org-table-hline-regexp line)
-             (string-match "^[ \t]*\\([+]-\\||[ ]\\)[-+ |]*[+|][ \t]*$" line)
-             (setq line (org-xml-encode-org-text-skip-links line)))
-
-         (setq line (org-lparse-format-org-link line opt-plist))
-
-         ;; TODO items
-         (if (and org-todo-line-regexp
-                  (string-match org-todo-line-regexp line)
-                  (match-beginning 2))
-             (setq line (concat
-                         (substring line 0 (match-beginning 2))
-                         (org-lparse-format 'TODO (match-string 2 line))
-                         (substring line (match-end 2)))))
-
-         ;; Does this contain a reference to a footnote?
-         (when org-export-with-footnotes
-           (setq start 0)
-           (while (string-match "\\([^* \t].*?\\)[ \t]*\\[\\([0-9]+\\)\\]" line start)
-             ;; Discard protected matches not clearly identified as
-             ;; footnote markers.
-             (if (or (get-text-property (match-beginning 2) 'org-protected line)
-                     (not (get-text-property (match-beginning 2) 'org-footnote line)))
-                 (setq start (match-end 2))
-               (let ((n (match-string 2 line)) refcnt a)
-                 (if (setq a (assoc n footref-seen))
-                     (progn
-                       (setcdr a (1+ (cdr a)))
-                       (setq refcnt (cdr a)))
-                   (setq refcnt 1)
-                   (push (cons n 1) footref-seen))
-                 (setq line
-                       (replace-match
-                        (concat
-                         (or (match-string 1 line) "")
-                         (org-lparse-format
-                          'FOOTNOTE-REFERENCE
-                          n (cdr (assoc n org-lparse-footnote-definitions))
-                          refcnt)
-                         ;; If another footnote is following the
-                         ;; current one, add a separator.
-                         (if (save-match-data
-                               (string-match "\\`\\[[0-9]+\\]"
-                                             (substring line (match-end 0))))
-                             (ignore-errors
-                               (org-lparse-get 'FOOTNOTE-SEPARATOR))
-                           ""))
-                        t t line))))))
-
-         (cond
-          ((string-match "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line)
-           ;; This is a headline
-           (setq level (org-tr-level (- (match-end 1) (match-beginning 1)
-                                        level-offset))
-                 txt (match-string 2 line))
-           (if (string-match quote-re0 txt)
-               (setq txt (replace-match "" t t txt)))
-           (if (<= level (max umax umax-toc))
-               (setq head-count (+ head-count 1)))
-           (unless org-lparse-dyn-first-heading-pos
-             (setq org-lparse-dyn-first-heading-pos (point)))
-           (org-lparse-begin-level level txt umax head-count)
-
-           ;; QUOTES
-           (when (string-match quote-re line)
-             (org-lparse-begin-environment 'quote)))
-
-          ((and org-export-with-tables
-                (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
-           (when (not table-open)
-             ;; New table starts
-             (setq table-open t table-buffer nil table-orig-buffer nil))
-
-           ;; Accumulate lines
-           (setq table-buffer (cons line table-buffer)
-                 table-orig-buffer (cons origline table-orig-buffer))
-           (when (or (not lines)
-                     (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
-                                        (car lines))))
-             (setq table-open nil
-                   table-buffer (nreverse table-buffer)
-                   table-orig-buffer (nreverse table-orig-buffer))
-             (org-lparse-end-paragraph)
-             (when org-lparse-list-table-p
-               (error "Regular tables are not allowed in a list-table block"))
-             (org-lparse-insert 'TABLE table-buffer table-orig-buffer)))
-
-          ;; Normal lines
-          (t
-           ;; This line either is list item or end a list.
-           (when (get-text-property 0 'list-item line)
-             (setq line (org-lparse-export-list-line
-                         line
-                         (get-text-property 0 'list-item line)
-                         (get-text-property 0 'list-struct line)
-                         (get-text-property 0 'list-prevs line))))
-
-           ;; Horizontal line
-           (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
-             (with-org-lparse-preserve-paragraph-state
-              (org-lparse-insert 'HORIZONTAL-LINE))
-             (throw 'nextline nil))
-
-           ;; Empty lines start a new paragraph.  If hand-formatted lists
-           ;; are not fully interpreted, lines starting with "-", "+", "*"
-           ;; also start a new paragraph.
-           (when (string-match "^ [-+*]-\\|^[ \t]*$" line)
-             (when org-lparse-footnote-number
-               (org-lparse-end-footnote-definition org-lparse-footnote-number)
-               (setq org-lparse-footnote-number nil))
-             (org-lparse-begin-paragraph))
-
-           ;; Is this the start of a footnote?
-           (when org-export-with-footnotes
-             (when (and (boundp 'footnote-section-tag-regexp)
-                        (string-match (concat "^" footnote-section-tag-regexp)
-                                      line))
-               ;; ignore this line
-               (throw 'nextline nil))
-             (when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
-               (org-lparse-end-paragraph)
-               (setq org-lparse-footnote-number (match-string 1 line))
-               (setq line (replace-match "" t t line))
-               (org-lparse-begin-footnote-definition org-lparse-footnote-number)))
-           ;; Check if the line break needs to be conserved
-           (cond
-            ((string-match "\\\\\\\\[ \t]*$" line)
-             (setq line (replace-match
-                         (org-lparse-format 'LINE-BREAK)
-                         t t line)))
-            (org-export-preserve-breaks
-             (setq line (concat line (org-lparse-format 'LINE-BREAK)))))
-
-           ;; Check if a paragraph should be started
-           (let ((start 0))
-             (while (and org-lparse-par-open
-                         (string-match "\\\\par\\>" line start))
-               (error "FIXME")
-               ;; Leave a space in the </p> so that the footnote matcher
-               ;; does not see this.
-               (if (not (get-text-property (match-beginning 0)
-                                           'org-protected line))
-                   (setq line (replace-match "</p ><p >" t t line)))
-               (setq start (match-end 0))))
-
-           (org-lparse-insert 'LINE line)))))
-
-      ;; Properly close all local lists and other lists
-      (when (org-lparse-current-environment-p 'quote)
-       (org-lparse-end-environment 'quote))
-
-      (org-lparse-end-level 1 umax)
-
-      ;; the </div> to close the last text-... div.
-      (when (and (> umax 0) org-lparse-dyn-first-heading-pos)
-       (org-lparse-end-outline-text-or-outline))
-
-      (org-lparse-end 'DOCUMENT-BODY opt-plist)
-      (unless body-only
-       (org-lparse-end 'DOCUMENT-CONTENT))
-
-      (org-lparse-end 'EXPORT)
-
-      ;; kill collection buffer
-      (when org-lparse-collect-buffer
-       (kill-buffer org-lparse-collect-buffer))
-
-      (goto-char (point-min))
-      (or (org-export-push-to-kill-ring
-          (upcase (symbol-name org-lparse-backend)))
-         (message "Exporting... done"))
-
-      (cond
-       ((not to-buffer)
-       (let ((f (org-lparse-get 'SAVE-METHOD)))
-         (or (and f (functionp f) (funcall f filename opt-plist))
-             (save-buffer)))
-       (or (and (boundp 'org-lparse-other-backend)
-                org-lparse-other-backend
-                (not (equal org-lparse-backend org-lparse-other-backend))
-                (org-lparse-do-convert
-                 buffer-file-name (symbol-name org-lparse-other-backend)))
-           (current-buffer)))
-       ((eq to-buffer 'string)
-       (prog1 (buffer-substring (point-min) (point-max))
-         (kill-buffer (current-buffer))))
-       (t (current-buffer))))))
-
-(defun org-lparse-format-table (lines olines)
-  "Returns backend-specific code for org-type and table-type tables."
-  (if (stringp lines)
-      (setq lines (org-split-string lines "\n")))
-  (if (string-match "^[ \t]*|" (car lines))
-      ;; A normal org table
-      (org-lparse-format-org-table lines nil)
-    ;; Table made by table.el
-    (or (org-lparse-format-table-table-using-table-generate-source
-        ;; FIXME: Need to take care of this during merge
-        (if (eq org-lparse-backend 'xhtml) 'html org-lparse-backend)
-        olines
-        (not org-export-prefer-native-exporter-for-tables))
-       ;; We are here only when table.el table has NO col or row
-       ;; spanning and the user prefers using org's own converter for
-       ;; exporting of such simple table.el tables.
-       (org-lparse-format-table-table lines))))
-
-(defun org-lparse-table-get-colalign-info (lines)
-  (let ((col-cookies (org-find-text-property-in-string
-                     'org-col-cookies (car lines))))
-    (when (and col-cookies org-table-clean-did-remove-column)
-      (setq col-cookies
-           (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) col-cookies)))
-    col-cookies))
-
-(defvar org-lparse-table-style)
-(defvar org-lparse-table-ncols)
-(defvar org-lparse-table-rownum)
-(defvar org-lparse-table-is-styled)
-(defvar org-lparse-table-begin-marker)
-(defvar org-lparse-table-num-numeric-items-per-column)
-(defvar org-lparse-table-colalign-info)
-(defvar org-lparse-table-colalign-vector)
-
-;; Following variables are defined in org-table.el
-(defvar org-table-number-fraction)
-(defvar org-table-number-regexp)
-(defun org-lparse-org-table-to-list-table (lines &optional splice)
-  "Convert org-table to list-table.
-LINES is a list of the form (ROW1 ROW2 ROW3 ...) where each
-element is a `string' representing a single row of org-table.
-Thus each ROW has vertical separators \"|\" separating the table
-fields.  A ROW could also be a row-group separator of the form
-\"|---...|\".  Return a list of the form (ROW1 ROW2 ROW3
-...). ROW could either be symbol `:hrule' or a list of the
-form (FIELD1 FIELD2 FIELD3 ...) as appropriate."
-  (let (line lines-1)
-    (cond
-     (splice
-      (while (setq line (pop lines))
-       (unless (string-match "^[ \t]*|-" line)
-         (push (org-split-string line "[ \t]*|[ \t]*") lines-1))))
-     (t
-      (while (setq line (pop lines))
-       (cond
-        ((string-match "^[ \t]*|-" line)
-         (when lines
-           (push :hrule lines-1)))
-        (t
-         (push (org-split-string line "[ \t]*|[ \t]*") lines-1))))))
-    (nreverse lines-1)))
-
-(defun org-lparse-insert-org-table (lines &optional splice)
-  "Format a org-type table into backend-specific code.
-LINES is a list of lines.  Optional argument SPLICE means, do not
-insert header and surrounding <table> tags, just format the lines.
-Optional argument NO-CSS means use XHTML attributes instead of CSS
-for formatting.  This is required for the DocBook exporter."
-  (require 'org-table)
-  ;; Get rid of hlines at beginning and end
-  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-  (setq lines (nreverse lines))
-  (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
-  (setq lines (nreverse lines))
-  (when org-export-table-remove-special-lines
-    ;; Check if the table has a marking column.  If yes remove the
-    ;; column and the special lines
-    (setq lines (org-table-clean-before-export lines)))
-  (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
-        (short-caption (or (org-find-text-property-in-string
-                            'org-caption-shortn (car lines)) caption))
-        (caption (and caption (org-xml-encode-org-text caption)))
-        (short-caption (and short-caption
-                            (org-xml-encode-plain-text short-caption)))
-        (label (org-find-text-property-in-string 'org-label (car lines)))
-        (org-lparse-table-colalign-info (org-lparse-table-get-colalign-info lines))
-        (attributes (org-find-text-property-in-string 'org-attributes
-                                                      (car lines)))
-        (head (and org-export-highlight-first-table-line
-                   (delq nil (mapcar
-                              (lambda (x) (string-match "^[ \t]*|-" x))
-                              (cdr lines))))))
-    (setq lines (org-lparse-org-table-to-list-table lines splice))
-    (org-lparse-insert-list-table
-     lines splice caption label attributes head org-lparse-table-colalign-info
-     short-caption)))
-
-(defun org-lparse-insert-list-table (lines &optional splice
-                                          caption label attributes head
-                                          org-lparse-table-colalign-info
-                                          short-caption)
-  (or (featurep 'org-table)            ; required for
-      (require 'org-table))            ; `org-table-number-regexp'
-  (let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0)
-        tbopen fields line
-        org-lparse-table-cur-rowgrp-is-hdr
-        org-lparse-table-rowgrp-open
-        org-lparse-table-num-numeric-items-per-column
-        org-lparse-table-colalign-vector n
-        org-lparse-table-rowgrp-info
-        org-lparse-table-begin-marker
-        (org-lparse-table-style 'org-table)
-        org-lparse-table-is-styled)
-    (cond
-     (splice
-      (setq org-lparse-table-is-styled nil)
-      (while (setq line (pop lines))
-       (insert (org-lparse-format-table-row line) "\n")))
-     (t
-      (setq org-lparse-table-is-styled t)
-      (org-lparse-begin 'TABLE caption label attributes short-caption)
-      (setq org-lparse-table-begin-marker (point))
-      (org-lparse-begin-table-rowgroup head)
-      (while (setq line (pop lines))
-       (cond
-        ((equal line :hrule)
-         (org-lparse-begin-table-rowgroup))
-        (t
-         (insert (org-lparse-format-table-row line) "\n"))))
-      (org-lparse-end 'TABLE-ROWGROUP)
-      (org-lparse-end-table)))))
-
-(defun org-lparse-format-org-table (lines &optional splice)
-  (with-temp-buffer
-    (org-lparse-insert-org-table lines splice)
-    (buffer-substring-no-properties (point-min) (point-max))))
-
-(defun org-lparse-format-list-table (lines &optional splice)
-  (with-temp-buffer
-    (org-lparse-insert-list-table lines splice)
-    (buffer-substring-no-properties (point-min) (point-max))))
-
-(defun org-lparse-insert-table-table (lines)
-  "Format a table generated by table.el into backend-specific code.
-This conversion does *not* use `table-generate-source' from table.el.
-This has the advantage that Org-mode's HTML conversions can be used.
-But it has the disadvantage, that no cell- or row-spanning is allowed."
-  (let (line field-buffer
-            (org-lparse-table-cur-rowgrp-is-hdr
-             org-export-highlight-first-table-line)
-            (caption nil)
-            (short-caption nil)
-            (attributes nil)
-            (label nil)
-            (org-lparse-table-style 'table-table)
-            (org-lparse-table-is-styled nil)
-            fields org-lparse-table-ncols i (org-lparse-table-rownum -1)
-            (empty (org-lparse-format 'SPACES 1)))
-    (org-lparse-begin 'TABLE caption label attributes short-caption)
-    (while (setq line (pop lines))
-      (cond
-       ((string-match "^[ \t]*\\+-" line)
-       (when field-buffer
-         (let ((org-export-table-row-tags '("<tr>" . "</tr>"))
-               ;; (org-export-html-table-use-header-tags-for-first-column nil)
-               )
-           (insert (org-lparse-format-table-row field-buffer empty)))
-         (setq org-lparse-table-cur-rowgrp-is-hdr nil)
-         (setq field-buffer nil)))
-       (t
-       ;; Break the line into fields and store the fields
-       (setq fields (org-split-string line "[ \t]*|[ \t]*"))
-       (if field-buffer
-           (setq field-buffer (mapcar
-                               (lambda (x)
-                                 (concat x (org-lparse-format 'LINE-BREAK)
-                                         (pop fields)))
-                               field-buffer))
-         (setq field-buffer fields)))))
-    (org-lparse-end-table)))
-
-(defun org-lparse-format-table-table (lines)
-  (with-temp-buffer
-    (org-lparse-insert-table-table lines)
-    (buffer-substring-no-properties (point-min) (point-max))))
-
-(defvar table-source-languages)                ; defined in table.el
-(defun org-lparse-format-table-table-using-table-generate-source (backend
-                                                                 lines
-                                                                 &optional
-                                                                 spanned-only)
-  "Format a table into BACKEND, using `table-generate-source' from table.el.
-Use SPANNED-ONLY to suppress exporting of simple table.el tables.
-
-When SPANNED-ONLY is nil, all table.el tables are exported.  When
-SPANNED-ONLY is non-nil, only tables with either row or column
-spans are exported.
-
-This routine returns the generated source or nil as appropriate.
-
-Refer docstring of `org-export-prefer-native-exporter-for-tables'
-for further information."
-  (require 'table)
-  (with-current-buffer (get-buffer-create " org-tmp1 ")
-    (erase-buffer)
-    (insert (mapconcat 'identity lines "\n"))
-    (goto-char (point-min))
-    (if (not (re-search-forward "|[^+]" nil t))
-       (error "Error processing table"))
-    (table-recognize-table)
-    (when (or (not spanned-only)
-             (let* ((dim (table-query-dimension))
-                    (c (nth 4 dim)) (r (nth 5 dim)) (cells (nth 6 dim)))
-               (not (= (* c r) cells))))
-      (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
-      (cond
-       ((member backend table-source-languages)
-       (table-generate-source backend " org-tmp2 ")
-       (set-buffer " org-tmp2 ")
-       (buffer-substring (point-min) (point-max)))
-       (t
-       ;; table.el doesn't support the given backend.  Currently this
-       ;; happens in case of odt export.  Strip the table from the
-       ;; generated document.  A better alternative would be to embed
-       ;; the table as ascii text in the output document.
-       (org-lparse-warn
-        (concat
-         "Found table.el-type table in the source org file. "
-         (format "table.el doesn't support %s backend. "
-                 (upcase (symbol-name backend)))
-         "Skipping ahead ..."))
-       "")))))
-
-(defun org-lparse-handle-time-stamps (s)
-  "Format time stamps in string S, or remove them."
-  (catch 'exit
-    (let (r b)
-      (when org-maybe-keyword-time-regexp
-       (while (string-match org-maybe-keyword-time-regexp s)
-         (or b (setq b (substring s 0 (match-beginning 0))))
-         (setq r (concat
-                  r (substring s 0 (match-beginning 0)) " "
-                  (org-lparse-format
-                   'FONTIFY
-                   (concat
-                    (if (match-end 1)
-                        (org-lparse-format
-                         'FONTIFY
-                         (match-string 1 s) "timestamp-kwd"))
-                    " "
-                    (org-lparse-format
-                     'FONTIFY
-                     (substring (org-translate-time (match-string 3 s)) 1 -1)
-                     "timestamp"))
-                   "timestamp-wrapper"))
-               s (substring s (match-end 0)))))
-
-      ;; Line break if line started and ended with time stamp stuff
-      (if (not r)
-         s
-       (setq r (concat r s))
-       (unless (string-match "\\S-" (concat b s))
-         (setq r (concat r (org-lparse-format 'LINE-BREAK))))
-       r))))
-
-(defun org-xml-encode-plain-text (s)
-  "Convert plain text characters to HTML equivalent.
-Possible conversions are set in `org-export-html-protect-char-alist'."
-  (let ((cl (org-lparse-get 'PLAIN-TEXT-MAP)) c)
-    (while (setq c (pop cl))
-      (let ((start 0))
-       (while (string-match (car c) s start)
-         (setq s (replace-match (cdr c) t t s)
-               start (1+ (match-beginning 0))))))
-    s))
-
-(defun org-xml-encode-org-text-skip-links (string)
-  "Prepare STRING for HTML export.  Apply all active conversions.
-If there are links in the string, don't modify these.  If STRING
-is nil, return nil."
-  (when string
-    (let* ((re (concat org-bracket-link-regexp "\\|"
-                      (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")))
-          m s l res)
-      (while (setq m (string-match re string))
-       (setq s (substring string 0 m)
-             l (match-string 0 string)
-             string (substring string (match-end 0)))
-       (push (org-xml-encode-org-text s) res)
-       (push l res))
-      (push (org-xml-encode-org-text string) res)
-      (apply 'concat (nreverse res)))))
-
-(defun org-xml-encode-org-text (s)
-  "Apply all active conversions to translate special ASCII to HTML."
-  (setq s (org-xml-encode-plain-text s))
-  (if org-export-html-expand
-      (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
-       (setq s (replace-match "<\\1>" t nil s))))
-  (if org-export-with-emphasize
-      (setq s (org-lparse-apply-char-styles s)))
-  (if org-export-with-special-strings
-      (setq s (org-lparse-convert-special-strings s)))
-  (if org-export-with-sub-superscripts
-      (setq s (org-lparse-apply-sub-superscript-styles s)))
-  (if org-export-with-TeX-macros
-      (let ((start 0) wd rep)
-       (while (setq start (string-match "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?"
-                                        s start))
-         (if (get-text-property (match-beginning 0) 'org-protected s)
-             (setq start (match-end 0))
-           (setq wd (match-string 1 s))
-           (if (setq rep (org-lparse-format 'ORG-ENTITY wd))
-               (setq s (replace-match rep t t s))
-             (setq start (+ start (length wd))))))))
-  s)
-
-(defun org-lparse-convert-special-strings (string)
-  "Convert special characters in STRING to HTML."
-  (let ((all (org-lparse-get 'SPECIAL-STRING-REGEXPS))
-       e a re rpl start)
-    (while (setq a (pop all))
-      (setq re (car a) rpl (cdr a) start 0)
-      (while (string-match re string start)
-       (if (get-text-property (match-beginning 0) 'org-protected string)
-           (setq start (match-end 0))
-         (setq string (replace-match rpl t nil string)))))
-    string))
-
-(defun org-lparse-apply-sub-superscript-styles (string)
-  "Apply subscript and superscript styles to STRING.
-Use `org-export-with-sub-superscripts' to control application of
-sub and superscript styles."
-  (let (key c (s 0) (requireb (eq org-export-with-sub-superscripts '{})))
-    (while (string-match org-match-substring-regexp string s)
-      (cond
-       ((and requireb (match-end 8)) (setq s (match-end 2)))
-       ((get-text-property  (match-beginning 2) 'org-protected string)
-       (setq s (match-end 2)))
-       (t
-       (setq s (match-end 1)
-             key (if (string= (match-string 2 string) "_")
-                     'subscript 'superscript)
-             c (or (match-string 8 string)
-                   (match-string 6 string)
-                   (match-string 5 string))
-             string (replace-match
-                     (concat (match-string 1 string)
-                             (org-lparse-format 'FONTIFY c key))
-                     t t string)))))
-    (while (string-match "\\\\\\([_^]\\)" string)
-      (setq string (replace-match (match-string 1 string) t t string)))
-    string))
-
-(defvar org-lparse-char-styles
-  `(("*" bold)
-    ("/" emphasis)
-    ("_" underline)
-    ("=" code)
-    ("~" verbatim)
-    ("+" strike))
-  "Map Org emphasis markers to char styles.
-This is an alist where each element is of the
-form (ORG-EMPHASIS-CHAR . CHAR-STYLE).")
-
-(defun org-lparse-apply-char-styles (string)
-  "Apply char styles to STRING.
-The variable `org-lparse-char-styles' controls how the Org
-emphasis markers are interpreted."
-  (let ((s 0) rpl)
-    (while (string-match org-emph-re string s)
-      (if (not (equal
-               (substring string (match-beginning 3) (1+ (match-beginning 3)))
-               (substring string (match-beginning 4) (1+ (match-beginning 4)))))
-         (setq s (match-beginning 0)
-               rpl
-               (concat
-                (match-string 1 string)
-                (org-lparse-format
-                 'FONTIFY (match-string 4 string)
-                 (nth 1 (assoc (match-string 3 string)
-                               org-lparse-char-styles)))
-                (match-string 5 string))
-               string (replace-match rpl t t string)
-               s (+ s (- (length rpl) 2)))
-       (setq s (1+ s))))
-    string))
-
-(defun org-lparse-export-list-line (line pos struct prevs)
-  "Insert list syntax in export buffer.  Return LINE, maybe modified.
-
-POS is the item position or line position the line had before
-modifications to buffer.  STRUCT is the list structure.  PREVS is
-the alist of previous items."
-  (let* ((get-type
-         (function
-          ;; Translate type of list containing POS to "d", "o" or
-          ;; "u".
-          (lambda (pos struct prevs)
-            (let ((type (org-list-get-list-type pos struct prevs)))
-              (cond
-               ((eq 'ordered type) "o")
-               ((eq 'descriptive type) "d")
-               (t "u"))))))
-        (get-closings
-         (function
-          ;; Return list of all items and sublists ending at POS, in
-          ;; reverse order.
-          (lambda (pos)
-            (let (out)
-              (catch 'exit
-                (mapc (lambda (e)
-                        (let ((end (nth 6 e))
-                              (item (car e)))
-                          (cond
-                           ((= end pos) (push item out))
-                           ((>= item pos) (throw 'exit nil)))))
-                      struct))
-              out)))))
-    ;; First close any previous item, or list, ending at POS.
-    (mapc (lambda (e)
-           (let* ((lastp (= (org-list-get-last-item e struct prevs) e))
-                  (first-item (org-list-get-list-begin e struct prevs))
-                  (type (funcall get-type first-item struct prevs)))
-             (org-lparse-end-paragraph)
-             ;; Ending for every item
-             (org-lparse-end-list-item-1 type)
-             ;; We're ending last item of the list: end list.
-             (when lastp
-               (org-lparse-end-list type)
-               (org-lparse-begin-paragraph))))
-         (funcall get-closings pos))
-    (cond
-     ;; At an item: insert appropriate tags in export buffer.
-     ((assq pos struct)
-      (string-match
-       (concat "[ \t]*\\(\\S-+[ \t]*\\)"
-              "\\(?:\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*\\)?"
-              "\\(?:\\(\\[[ X-]\\]\\)[ \t]+\\)?"
-              "\\(?:\\(.*\\)[ \t]+::\\(?:[ \t]+\\|$\\)\\)?"
-              "\\(.*\\)") line)
-      (let* ((checkbox (match-string 3 line))
-            (desc-tag (or (match-string 4 line) "???"))
-            (body (or (match-string 5 line) ""))
-            (list-beg (org-list-get-list-begin pos struct prevs))
-            (firstp (= list-beg pos))
-            ;; Always refer to first item to determine list type, in
-            ;; case list is ill-formed.
-            (type (funcall get-type list-beg struct prevs))
-            (counter (let ((count-tmp (org-list-get-counter pos struct)))
-                       (cond
-                        ((not count-tmp) nil)
-                        ((string-match "[A-Za-z]" count-tmp)
-                         (- (string-to-char (upcase count-tmp)) 64))
-                        ((string-match "[0-9]+" count-tmp)
-                         count-tmp)))))
-       (when firstp
-         (org-lparse-end-paragraph)
-         (org-lparse-begin-list type))
-
-       (let ((arg (cond ((equal type "d") desc-tag)
-                        ((equal type "o") counter))))
-         (org-lparse-begin-list-item type arg))
-
-       ;; If line had a checkbox, some additional modification is required.
-       (when checkbox
-         (setq body
-               (concat
-                (org-lparse-format
-                 'FONTIFY (concat
-                           "["
-                           (cond
-                            ((string-match "X" checkbox) "X")
-                            ((string-match " " checkbox)
-                             (org-lparse-format 'SPACES 1))
-                            (t "-"))
-                           "]")
-                 'code)
-                " "
-                body)))
-       ;; Return modified line
-       body))
-     ;; At a list ender: go to next line (side-effects only).
-     ((equal "ORG-LIST-END-MARKER" line) (throw 'nextline nil))
-     ;; Not at an item: return line unchanged (side-effects only).
-     (t line))))
-
-(defun org-lparse-bind-local-variables (opt-plist)
-  (mapc (lambda (x)
-         (set (make-local-variable (nth 2 x))
-              (plist-get opt-plist (car x))))
-       org-export-plist-vars))
-
-(defvar org-lparse-table-rowgrp-open)
-(defvar org-lparse-table-cur-rowgrp-is-hdr)
-(defvar org-lparse-footnote-number)
-(defvar org-lparse-footnote-definitions)
-(defvar org-lparse-output-buffer nil
-  "Buffer to which `org-do-lparse' writes to.
-This buffer contains the contents of the to-be-created exported
-document.")
-
-(defcustom org-lparse-debug nil
-  "Enable or Disable logging of `org-lparse' callbacks.
-The parameters passed to the backend-registered ENTITY-CONTROL
-and ENTITY-FORMAT callbacks are logged as comment strings in the
-exported buffer.  (org-lparse-format 'COMMENT fmt args) is used
-for logging.  Customize this variable only if you are an expert
-user.  Valid values of this variable are:
-nil     : Disable logging
-control : Log all invocations of `org-lparse-begin' and
-          `org-lparse-end' callbacks.
-format  : Log invocations of `org-lparse-format' callbacks.
-t       : Log all invocations of `org-lparse-begin', `org-lparse-end'
-          and `org-lparse-format' callbacks,"
-  :group 'org-lparse
-  :type '(choice
-         (const :tag "Disable" nil)
-         (const :tag "Format callbacks" format)
-         (const :tag "Control callbacks" control)
-         (const :tag "Format and Control callbacks" t)))
-
-(defun org-lparse-begin (entity &rest args)
-  "Begin ENTITY in current buffer.  ARGS is entity specific.
-ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM etc.
-
-Use (org-lparse-begin 'LIST \"o\") to begin a list in current
-buffer.
-
-See `org-xhtml-entity-control-callbacks-alist' for more
-information."
-  (when (and (member org-lparse-debug '(t control))
-            (not (eq entity 'DOCUMENT-CONTENT)))
-    (insert (org-lparse-format 'COMMENT "%s BEGIN %S" entity args)))
-
-  (let ((f (cadr (assoc entity org-lparse-entity-control-callbacks-alist))))
-    (unless f (error "Unknown entity: %s" entity))
-    (apply f args)))
-
-(defun org-lparse-end (entity &rest args)
-  "Close ENTITY in current buffer.  ARGS is entity specific.
-ENTITY can be one of PARAGRAPH, LIST, LIST-ITEM
-etc.
-
-Use (org-lparse-end 'LIST \"o\") to close a list in current
-buffer.
-
-See `org-xhtml-entity-control-callbacks-alist' for more
-information."
-  (when (and (member org-lparse-debug '(t control))
-            (not (eq entity 'DOCUMENT-CONTENT)))
-    (insert (org-lparse-format 'COMMENT "%s END %S" entity args)))
-
-  (let ((f (caddr (assoc entity org-lparse-entity-control-callbacks-alist))))
-    (unless f (error "Unknown entity: %s" entity))
-    (apply f args)))
-
-(defun org-lparse-begin-paragraph (&optional style)
-  "Insert <p>, but first close previous paragraph if any."
-  (org-lparse-end-paragraph)
-  (org-lparse-begin 'PARAGRAPH style)
-  (setq org-lparse-par-open t))
-
-(defun org-lparse-end-paragraph ()
-  "Close paragraph if there is one open."
-  (when org-lparse-par-open
-    (org-lparse-end 'PARAGRAPH)
-    (setq org-lparse-par-open nil)))
-
-(defun org-lparse-end-list-item-1 (&optional type)
-  "Close <li> if necessary."
-  (org-lparse-end-paragraph)
-  (org-lparse-end-list-item (or type "u")))
-
-(define-obsolete-function-alias
-  'org-lparse-preprocess-after-blockquote-hook
-  'org-lparse-preprocess-after-blockquote
-  "24.3")
-
-(defun org-lparse-preprocess-after-blockquote ()
-  "Treat `org-lparse-special-blocks' specially."
-  (goto-char (point-min))
-  (while (re-search-forward
-         "^[ \t]*#\\+\\(begin\\|end\\)_\\(\\S-+\\)[ \t]*\\(.*\\)$" nil t)
-    (when (member (downcase (match-string 2)) org-lparse-special-blocks)
-      (replace-match
-       (if (equal (downcase (match-string 1)) "begin")
-          (format "ORG-%s-START %s" (upcase (match-string 2))
-                  (match-string 3))
-        (format "ORG-%s-END %s" (upcase (match-string 2))
-                (match-string 3))) t t))))
-
-(define-obsolete-function-alias
-  'org-lparse-strip-experimental-blocks-maybe-hook
-  'org-lparse-strip-experimental-blocks-maybe
-  "24.3")
-
-(defun org-lparse-strip-experimental-blocks-maybe ()
-  "Strip \"list-table\" and \"annotation\" blocks.
-Stripping happens only when the exported backend is not one of
-\"odt\" or \"xhtml\"."
-  (when (not org-lparse-backend)
-    (message "Stripping following blocks - %S" org-lparse-special-blocks)
-    (goto-char (point-min))
-    (let ((case-fold-search t))
-      (while
-         (re-search-forward
-          "^[ \t]*#\\+begin_\\(\\S-+\\)\\([ \t]+.*\\)?\n\\([^\000]*?\\)\n[ \t]*#\\+end_\\1\\>.*"
-          nil t)
-       (when (member (match-string 1) org-lparse-special-blocks)
-         (replace-match "" t t))))))
-
-(defvar org-lparse-list-table-p nil
-  "Non-nil if `org-do-lparse' is within a list-table.")
-
-(defvar org-lparse-dyn-current-environment nil)
-(defun org-lparse-begin-environment (style &optional env-options-plist)
-  (case style
-    (list-table
-     (setq org-lparse-list-table-p t))
-    (t (setq org-lparse-dyn-current-environment style)
-       (org-lparse-begin 'ENVIRONMENT  style env-options-plist))))
-
-(defun org-lparse-end-environment (style &optional env-options-plist)
-  (case style
-    (list-table
-     (setq org-lparse-list-table-p nil))
-    (t (org-lparse-end 'ENVIRONMENT style env-options-plist)
-       (setq org-lparse-dyn-current-environment nil))))
-
-(defun org-lparse-current-environment-p (style)
-  (eq org-lparse-dyn-current-environment style))
-
-(defun org-lparse-begin-footnote-definition (n)
-  (org-lparse-begin-collect)
-  (setq org-lparse-insert-tag-with-newlines nil)
-  (org-lparse-begin 'FOOTNOTE-DEFINITION n))
-
-(defun org-lparse-end-footnote-definition (n)
-  (org-lparse-end 'FOOTNOTE-DEFINITION n)
-  (setq org-lparse-insert-tag-with-newlines 'both)
-  (let ((footnote-def (org-lparse-end-collect)))
-    ;; Cleanup newlines in footnote definition.  This ensures that a
-    ;; transcoded line is never (wrongly) broken in to multiple lines.
-    (let ((pos 0))
-      (while (string-match "[\r\n]+" footnote-def pos)
-       (setq pos (1+ (match-beginning 0)))
-       (setq footnote-def (replace-match " " t t footnote-def))))
-    (push (cons n footnote-def) org-lparse-footnote-definitions)))
-
-(defvar org-lparse-collect-buffer nil
-  "An auxiliary buffer named \"*Org Lparse Collect*\".
-`org-do-lparse' uses this as output buffer while collecting
-footnote definitions and table-cell contents of list-tables.  See
-`org-lparse-begin-collect' and `org-lparse-end-collect'.")
-
-(defvar org-lparse-collect-count nil
-  "Count number of calls to `org-lparse-begin-collect'.
-Use this counter to catch chained collections if they ever
-happen.")
-
-(defun org-lparse-begin-collect ()
-  "Temporarily switch to `org-lparse-collect-buffer'.
-Also erase it's contents."
-  (unless (zerop org-lparse-collect-count)
-    (error "FIXME (org-lparse.el): Encountered chained collections"))
-  (incf org-lparse-collect-count)
-  (unless org-lparse-collect-buffer
-    (setq org-lparse-collect-buffer
-         (get-buffer-create "*Org Lparse Collect*")))
-  (set-buffer org-lparse-collect-buffer)
-  (erase-buffer))
-
-(defun org-lparse-end-collect ()
-  "Switch to `org-lparse-output-buffer'.
-Return contents of `org-lparse-collect-buffer' as a `string'."
-  (assert (> org-lparse-collect-count 0))
-  (decf org-lparse-collect-count)
-  (prog1 (buffer-string)
-    (erase-buffer)
-    (set-buffer org-lparse-output-buffer)))
-
-(defun org-lparse-format (entity &rest args)
-  "Format ENTITY in backend-specific way and return it.
-ARGS is specific to entity being formatted.
-
-Use (org-lparse-format 'HEADING \"text\" 1) to format text as
-level 1 heading.
-
-See `org-xhtml-entity-format-callbacks-alist' for more information."
-  (when (and (member org-lparse-debug '(t format))
-            (not (equal entity 'COMMENT)))
-    (insert (org-lparse-format 'COMMENT "%s: %S" entity args)))
-  (cond
-   ((consp entity)
-    (let ((text (pop args)))
-      (apply 'org-lparse-format 'TAGS entity text args)))
-   (t
-    (let ((f (cdr (assoc entity org-lparse-entity-format-callbacks-alist))))
-      (unless f (error "Unknown entity: %s" entity))
-      (apply f args)))))
-
-(defun org-lparse-insert (entity &rest args)
-  (insert (apply 'org-lparse-format entity args)))
-
-(defun org-lparse-prepare-toc (lines level-offset opt-plist umax-toc)
-  (let* ((quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
-        (org-min-level (org-get-min-level lines level-offset))
-        (org-last-level org-min-level)
-        level)
-    (with-temp-buffer
-      (org-lparse-bind-local-variables opt-plist)
-      (erase-buffer)
-      (org-lparse-begin 'TOC (nth 3 (plist-get opt-plist :lang-words)) umax-toc)
-      (setq
-       lines
-       (mapcar
-       #'(lambda (line)
-           (when (and (string-match org-todo-line-regexp line)
-                      (not (get-text-property 0 'org-protected line))
-                      (<= (setq level (org-tr-level
-                                       (- (match-end 1) (match-beginning 1)
-                                          level-offset)))
-                          umax-toc))
-             (let ((txt (save-match-data
-                          (org-xml-encode-org-text-skip-links
-                           (org-export-cleanup-toc-line
-                            (match-string 3 line)))))
-                   (todo (and
-                          org-export-mark-todo-in-toc
-                          (or (and (match-beginning 2)
-                                   (not (member (match-string 2 line)
-                                                org-done-keywords)))
-                              (and (= level umax-toc)
-                                   (org-search-todo-below
-                                    line lines level)))))
-                   tags)
-               ;; Check for targets
-               (while (string-match org-any-target-regexp line)
-                 (setq line
-                       (replace-match
-                        (let ((org-lparse-encode-pending t))
-                          (org-lparse-format 'FONTIFY
-                                             (match-string 1 line) "target"))
-                        t t line)))
-               (when (string-match
-                      (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
-                 (setq tags (match-string 1 txt)
-                       txt (replace-match "" t nil txt)))
-               (when (string-match quote-re0 txt)
-                 (setq txt (replace-match "" t t txt)))
-               (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
-                 (setq txt (replace-match "" t t txt)))
-               (org-lparse-format
-                'TOC-ITEM
-                (let* ((snumber (org-section-number level))
-                       (href (replace-regexp-in-string
-                              "\\." "-" (format "sec-%s" snumber)))
-                       (href
-                        (or
-                         (cdr (assoc
-                               href org-export-preferred-target-alist))
-                         href))
-                       (href (org-solidify-link-text href)))
-                  (org-lparse-format 'TOC-ENTRY snumber todo txt tags href))
-                level org-last-level)
-               (setq org-last-level level)))
-           line)
-       lines))
-      (org-lparse-end 'TOC)
-      (setq org-lparse-toc (buffer-string))))
-  lines)
-
-(defun org-lparse-format-table-row (fields &optional text-for-empty-fields)
-  (if org-lparse-table-ncols
-      ;; second and subsequent rows of the table
-      (when (and org-lparse-list-table-p
-                (> (length fields) org-lparse-table-ncols))
-       (error "Table row has %d columns but header row claims %d columns"
-              (length fields) org-lparse-table-ncols))
-    ;; first row of the table
-    (setq org-lparse-table-ncols (length fields))
-    (when org-lparse-table-is-styled
-      (setq org-lparse-table-num-numeric-items-per-column
-           (make-vector org-lparse-table-ncols 0))
-      (setq org-lparse-table-colalign-vector
-           (make-vector org-lparse-table-ncols nil))
-      (let ((c -1))
-       (while  (< (incf c) org-lparse-table-ncols)
-         (let* ((col-cookie (cdr (assoc (1+ c) org-lparse-table-colalign-info)))
-                (align (nth 0 col-cookie)))
-           (setf (aref org-lparse-table-colalign-vector c)
-                 (cond
-                  ((string= align "l") "left")
-                  ((string= align "r") "right")
-                  ((string= align "c") "center"))))))))
-  (incf org-lparse-table-rownum)
-  (let ((i -1))
-    (org-lparse-format
-     'TABLE-ROW
-     (mapconcat
-      (lambda (x)
-       (when (and (string= x "") text-for-empty-fields)
-         (setq x text-for-empty-fields))
-       (incf i)
-       (let (col-cookie horiz-span)
-         (when org-lparse-table-is-styled
-           (when (and (< i org-lparse-table-ncols)
-                      (string-match org-table-number-regexp x))
-             (incf (aref org-lparse-table-num-numeric-items-per-column i)))
-           (setq col-cookie (cdr (assoc (1+ i) org-lparse-table-colalign-info))
-                 horiz-span (nth 1 col-cookie)))
-         (org-lparse-format
-          'TABLE-CELL x org-lparse-table-rownum i (or horiz-span 0))))
-      fields "\n"))))
-
-(defun org-lparse-get (what &optional opt-plist)
-  "Query for value of WHAT for the current backend `org-lparse-backend'.
-See also `org-lparse-backend-get'."
-  (if (boundp 'org-lparse-backend)
-      (org-lparse-backend-get (symbol-name org-lparse-backend) what opt-plist)
-    (error "org-lparse-backend is not bound yet")))
-
-(defun org-lparse-backend-get (backend what &optional opt-plist)
-  "Query BACKEND for value of WHAT.
-Dispatch the call to `org-<backend>-user-get'.  If that throws an
-error, dispatch the call to `org-<backend>-get'.  See
-`org-xhtml-get' for all known settings queried for by
-`org-lparse' during the course of export."
-  (assert (stringp backend) t)
-  (unless (org-lparse-backend-is-native-p backend)
-    (error "Unknown native backend %s" backend))
-  (let ((backend-get-method (intern (format "org-%s-get" backend)))
-       (backend-user-get-method (intern (format "org-%s-user-get" backend))))
-    (cond
-     ((functionp backend-get-method)
-      (condition-case nil
-         (funcall backend-user-get-method what opt-plist)
-       (error (funcall backend-get-method what opt-plist))))
-     (t
-      (error "Native backend %s doesn't define %s" backend backend-get-method)))))
-
-(defun org-lparse-insert-tag (tag &rest args)
-  (when (member org-lparse-insert-tag-with-newlines '(lead both))
-    (insert  "\n"))
-  (insert (apply 'format tag args))
-  (when (member org-lparse-insert-tag-with-newlines '(trail both))
-    (insert  "\n")))
-
-(defun org-lparse-get-targets-from-title (title)
-  (let* ((target (org-get-text-property-any 0 'target title))
-        (extra-targets (assoc target org-export-target-aliases))
-        (target (or (cdr (assoc target org-export-preferred-target-alist))
-                    target)))
-    (cons target (remove target extra-targets))))
-
-(defun org-lparse-suffix-from-snumber (snumber)
-  (let* ((snu (replace-regexp-in-string "\\." "-" snumber))
-        (href (cdr (assoc (concat "sec-" snu)
-                          org-export-preferred-target-alist))))
-    (org-solidify-link-text (or href snu))))
-
-(defun org-lparse-begin-level (level title umax head-count)
-  "Insert a new LEVEL in HTML export.
-When TITLE is nil, just close all open levels."
-  (org-lparse-end-level level umax)
-  (unless title (error "Why is heading nil"))
-  (let* ((targets (org-lparse-get-targets-from-title title))
-        (target (car targets)) (extra-targets (cdr targets))
-        (target (and target (org-solidify-link-text target)))
-        (extra-class (org-get-text-property-any 0 'html-container-class title))
-        snumber tags level1 class)
-    (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title)
-      (setq tags (and org-export-with-tags (match-string 1 title)))
-      (setq title (replace-match "" t t title)))
-    (if (> level umax)
-       (progn
-         (if (aref org-levels-open (1- level))
-             (org-lparse-end-list-item-1)
-           (aset org-levels-open (1- level) t)
-           (org-lparse-end-paragraph)
-           (org-lparse-begin-list 'unordered))
-         (org-lparse-begin-list-item
-          'unordered target (org-lparse-format
-                             'HEADLINE title extra-targets tags)))
-      (aset org-levels-open (1- level) t)
-      (setq snumber (org-section-number level))
-      (setq level1 (+ level (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1) -1))
-      (unless (= head-count 1)
-       (org-lparse-end-outline-text-or-outline))
-      (org-lparse-begin-outline-and-outline-text
-       level1 snumber title tags target extra-targets extra-class)
-      (org-lparse-begin-paragraph))))
-
-(defun org-lparse-end-level (level umax)
-  (org-lparse-end-paragraph)
-  (loop for l from org-level-max downto level
-       do (when (aref org-levels-open (1- l))
-            ;; Terminate one level in HTML export
-            (if (<= l umax)
-                (org-lparse-end-outline-text-or-outline)
-              (org-lparse-end-list-item-1)
-              (org-lparse-end-list 'unordered))
-            (aset org-levels-open (1- l) nil))))
-
-(defvar org-lparse-outline-text-open)
-(defun org-lparse-begin-outline-and-outline-text (level1 snumber title tags
-                                                        target extra-targets
-                                                        extra-class)
-  (org-lparse-begin
-   'OUTLINE level1 snumber title tags target extra-targets extra-class)
-  (org-lparse-begin-outline-text level1 snumber extra-class))
-
-(defun org-lparse-end-outline-text-or-outline ()
-  (cond
-   (org-lparse-outline-text-open
-    (org-lparse-end 'OUTLINE-TEXT)
-    (setq org-lparse-outline-text-open nil))
-   (t (org-lparse-end 'OUTLINE))))
-
-(defun org-lparse-begin-outline-text (level1 snumber extra-class)
-  (assert (not org-lparse-outline-text-open) t)
-  (setq org-lparse-outline-text-open t)
-  (org-lparse-begin 'OUTLINE-TEXT level1 snumber extra-class))
-
-(defun org-lparse-html-list-type-to-canonical-list-type (ltype)
-  (cdr (assoc ltype '(("o" . ordered)
-                     ("u" . unordered)
-                     ("d" . description)))))
-
-;; following vars are bound during `org-do-lparse'
-(defvar org-lparse-list-stack)
-(defvar org-lparse-list-table:table-row)
-(defvar org-lparse-list-table:lines)
-
-;; Notes on LIST-TABLES
-;; ====================
-;; Lists withing "list-table" blocks (as shown below)
-;;
-;; #+begin_list-table
-;; - Row 1
-;;   - 1.1
-;;   - 1.2
-;;   - 1.3
-;; - Row 2
-;;   - 2.1
-;;   - 2.2
-;;   - 2.3
-;; #+end_list-table
-;;
-;; will be exported as though it were a table as shown below.
-;;
-;; | Row 1 | 1.1 | 1.2 | 1.3 |
-;; | Row 2 | 2.1 | 2.2 | 2.3 |
-;;
-;; Note that org-tables are NOT multi-line and each line is mapped to
-;; a unique row in the exported document.  So if an exported table
-;; needs to contain a single paragraph (with copious text) it needs to
-;; be typed up in a single line.  Editing such long lines using the
-;; table editor will be a cumbersome task.  Furthermore inclusion of
-;; multi-paragraph text in a table cell is well-nigh impossible.
-;;
-;; LIST-TABLEs are meant to circumvent the above problems with
-;; org-tables.
-;;
-;; Note that in the example above the list items could be paragraphs
-;; themselves and the list can be arbitrarily deep.
-;;
-;; Inspired by following thread:
-;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html
-
-(defun org-lparse-begin-list (ltype)
-  (push ltype org-lparse-list-stack)
-  (let ((list-level (length org-lparse-list-stack)))
-    (cond
-     ((not org-lparse-list-table-p)
-      (org-lparse-begin 'LIST ltype))
-     ;; process LIST-TABLE
-     ((= 1 list-level)
-      ;; begin LIST-TABLE
-      (setq org-lparse-list-table:lines nil)
-      (setq org-lparse-list-table:table-row nil))
-     ((= 2 list-level)
-      (ignore))
-     (t
-      (org-lparse-begin 'LIST ltype)))))
-
-(defun org-lparse-end-list (ltype)
-  (pop org-lparse-list-stack)
-  (let ((list-level (length org-lparse-list-stack)))
-    (cond
-     ((not org-lparse-list-table-p)
-      (org-lparse-end 'LIST ltype))
-     ;; process LIST-TABLE
-     ((= 0 list-level)
-      ;; end LIST-TABLE
-      (insert (org-lparse-format-list-table
-              (nreverse org-lparse-list-table:lines))))
-     ((= 1 list-level)
-      (ignore))
-     (t
-      (org-lparse-end 'LIST ltype)))))
-
-(defun org-lparse-begin-list-item (ltype &optional arg headline)
-  (let ((list-level (length org-lparse-list-stack)))
-    (cond
-     ((not org-lparse-list-table-p)
-      (org-lparse-begin 'LIST-ITEM ltype arg headline))
-     ;; process LIST-TABLE
-     ((= 1 list-level)
-      ;; begin TABLE-ROW for LIST-TABLE
-      (setq org-lparse-list-table:table-row nil)
-      (org-lparse-begin-list-table:table-cell))
-     ((= 2 list-level)
-      ;; begin TABLE-CELL for LIST-TABLE
-      (org-lparse-begin-list-table:table-cell))
-     (t
-      (org-lparse-begin 'LIST-ITEM ltype arg headline)))))
-
-(defun org-lparse-end-list-item (ltype)
-  (let ((list-level (length org-lparse-list-stack)))
-    (cond
-     ((not org-lparse-list-table-p)
-      (org-lparse-end 'LIST-ITEM ltype))
-     ;; process LIST-TABLE
-     ((= 1 list-level)
-      ;; end TABLE-ROW for LIST-TABLE
-      (org-lparse-end-list-table:table-cell)
-      (push (nreverse org-lparse-list-table:table-row)
-           org-lparse-list-table:lines))
-     ((= 2 list-level)
-      ;; end TABLE-CELL for LIST-TABLE
-      (org-lparse-end-list-table:table-cell))
-     (t
-      (org-lparse-end 'LIST-ITEM ltype)))))
-
-(defvar org-lparse-list-table:table-cell-open)
-(defun org-lparse-begin-list-table:table-cell ()
-  (org-lparse-end-list-table:table-cell)
-  (setq org-lparse-list-table:table-cell-open t)
-  (org-lparse-begin-collect)
-  (org-lparse-begin-paragraph))
-
-(defun org-lparse-end-list-table:table-cell ()
-  (when org-lparse-list-table:table-cell-open
-    (setq org-lparse-list-table:table-cell-open nil)
-    (org-lparse-end-paragraph)
-    (push (org-lparse-end-collect)
-         org-lparse-list-table:table-row)))
-
-(defvar org-lparse-table-rowgrp-info)
-(defun org-lparse-begin-table-rowgroup (&optional is-header-row)
-  (push (cons (1+ org-lparse-table-rownum) :start) org-lparse-table-rowgrp-info)
-  (org-lparse-begin 'TABLE-ROWGROUP is-header-row))
-
-(defun org-lparse-end-table ()
-  (when org-lparse-table-is-styled
-    ;; column groups
-    (unless (car org-table-colgroup-info)
-      (setq org-table-colgroup-info
-           (cons :start (cdr org-table-colgroup-info))))
-
-    ;; column alignment
-    (let ((c -1))
-      (mapc
-       (lambda (x)
-        (incf c)
-        (setf (aref org-lparse-table-colalign-vector c)
-              (or (aref org-lparse-table-colalign-vector c)
-                  (if (> (/ (float x) (1+ org-lparse-table-rownum))
-                         org-table-number-fraction)
-                      "right" "left"))))
-       org-lparse-table-num-numeric-items-per-column)))
-  (org-lparse-end 'TABLE))
-
-(defvar org-lparse-encode-pending nil)
-
-(defun org-lparse-format-tags (tag text prefix suffix &rest args)
-  (cond
-   ((consp tag)
-    (concat prefix (apply 'format (car tag) args) text suffix
-           (format (cdr tag))))
-   ((stringp tag)                      ; singleton tag
-    (concat prefix (apply 'format tag args) text))))
-
-(defun org-xml-fix-class-name (kwd)    ; audit callers of this function
-  "Turn todo keyword into a valid class name.
-Replaces invalid characters with \"_\"."
-  (save-match-data
-    (while (string-match "[^a-zA-Z0-9_]" kwd)
-      (setq kwd (replace-match "_" t t kwd))))
-  kwd)
-
-(defun org-lparse-format-todo (todo)
-  (org-lparse-format 'FONTIFY
-                    (concat
-                     (ignore-errors (org-lparse-get 'TODO-KWD-CLASS-PREFIX))
-                     (org-xml-fix-class-name todo))
-                    (list (if (member todo org-done-keywords) "done" "todo")
-                          todo)))
-
-(defun org-lparse-format-extra-targets (extra-targets)
-  (if (not extra-targets) ""
-    (mapconcat (lambda (x)
-                (setq x (org-solidify-link-text
-                         (if (org-uuidgen-p x) (concat "ID-" x) x)))
-                (org-lparse-format 'ANCHOR "" x))
-              extra-targets "")))
-
-(defun org-lparse-format-org-tags (tags)
-  (if (not tags) ""
-    (org-lparse-format
-     'FONTIFY (mapconcat
-              (lambda (x)
-                (org-lparse-format
-                 'FONTIFY x
-                 (concat
-                  (ignore-errors (org-lparse-get 'TAG-CLASS-PREFIX))
-                  (org-xml-fix-class-name x))))
-              (org-split-string tags ":")
-              (org-lparse-format 'SPACES 1)) "tag")))
-
-(defun org-lparse-format-section-number (&optional snumber level)
-  (and org-export-with-section-numbers
-       (not org-lparse-body-only) snumber level
-       (org-lparse-format 'FONTIFY snumber (format "section-number-%d" level))))
-
-(defun org-lparse-warn (msg)
-  (if (not org-lparse-use-flashy-warning)
-      (message msg)
-    (put-text-property 0 (length msg) 'face 'font-lock-warning-face msg)
-    (message msg)
-    (sleep-for 3)))
-
-(defun org-xml-format-href (s)
-  "Make sure the S is valid as a href reference in an XHTML document."
-  (save-match-data
-    (let ((start 0))
-      (while (string-match "&" s start)
-       (setq start (+ (match-beginning 0) 3)
-             s (replace-match "&amp;" t t s)))))
-  s)
-
-(defun org-xml-format-desc (s)
-  "Make sure the S is valid as a description in a link."
-  (if (and s (not (get-text-property 1 'org-protected s)))
-      (save-match-data
-       (org-xml-encode-org-text s))
-    s))
-
-(provide 'org-lparse)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-lparse.el ends here
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el
deleted file mode 100644 (file)
index 5df68f5..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-;;; org-mac-message.el --- Links to Apple Mail.app messages from within Org-mode
-
-;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
-
-;; Authors: John Wiegley <johnw@gnu.org>
-;;       Christopher Suckling <suckling at gmail dot com>
-
-;; Keywords: outlines, hypermedia, calendar, wp
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;; This file implements links to Apple Mail.app messages from within Org-mode.
-;; Org-mode does not load this module by default - if you would actually like
-;; this to happen then configure the variable `org-modules'.
-
-;; If you would like to create links to all flagged messages in an
-;; Apple Mail.app account, please customize the variable
-;; `org-mac-mail-account' and then call one of the following functions:
-
-;; (org-mac-message-insert-selected) copies a formatted list of links to
-;; the kill ring.
-
-;; (org-mac-message-insert-selected) inserts at point links to any
-;; messages selected in Mail.app.
-
-;; (org-mac-message-insert-flagged) searches within an org-mode buffer
-;; for a specific heading, creating it if it doesn't exist.  Any
-;; message:// links within the first level of the heading are deleted
-;; and replaced with links to flagged messages.
-
-;;; Code:
-
-(require 'org)
-
-(defgroup org-mac-flagged-mail nil
-  "Options concerning linking to flagged Mail.app messages."
-  :tag "Org Mail.app"
-  :group 'org-link)
-
-(defcustom org-mac-mail-account "customize"
-  "The Mail.app account in which to search for flagged messages."
-  :group 'org-mac-flagged-mail
-  :type 'string)
-
-(org-add-link-type "message" 'org-mac-message-open)
-
-;; In mac.c, removed in Emacs 23.
-(declare-function do-applescript "org-mac-message" (script))
-(unless (fboundp 'do-applescript)
-  ;; Need to fake this using shell-command-to-string
-  (defun do-applescript (script)
-    (let (start cmd return)
-      (while (string-match "\n" script)
-       (setq script (replace-match "\r" t t script)))
-      (while (string-match "'" script start)
-       (setq start (+ 2 (match-beginning 0))
-             script (replace-match "\\'" t t script)))
-      (setq cmd (concat "osascript -e '" script "'"))
-      (setq return (shell-command-to-string cmd))
-      (concat "\"" (org-trim return) "\""))))
-
-(defun org-mac-message-open (message-id)
-  "Visit the message with the given MESSAGE-ID.
-This will use the command `open' with the message URL."
-  (start-process (concat "open message:" message-id) nil
-                "open" (concat "message://<" (substring message-id 2) ">")))
-
-(defun as-get-selected-mail ()
-  "AppleScript to create links to selected messages in Mail.app."
-  (do-applescript
-   (concat
-    "tell application \"Mail\"\n"
-    "set theLinkList to {}\n"
-    "set theSelection to selection\n"
-    "repeat with theMessage in theSelection\n"
-    "set theID to message id of theMessage\n"
-    "set theSubject to subject of theMessage\n"
-    "set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
-    "copy theLink to end of theLinkList\n"
-    "end repeat\n"
-    "return theLinkList as string\n"
-    "end tell")))
-
-(defun as-get-flagged-mail ()
-  "AppleScript to create links to flagged messages in Mail.app."
-  (do-applescript
-   (concat
-    ;; Is Growl installed?
-    "tell application \"System Events\"\n"
-    "set growlHelpers to the name of every process whose creator type contains \"GRRR\"\n"
-    "if (count of growlHelpers) > 0 then\n"
-    "set growlHelperApp to item 1 of growlHelpers\n"
-    "else\n"
-    "set growlHelperApp to \"\"\n"
-    "end if\n"
-    "end tell\n"
-
-    ;; Get links
-    "tell application \"Mail\"\n"
-    "set theMailboxes to every mailbox of account \"" org-mac-mail-account "\"\n"
-    "set theLinkList to {}\n"
-    "repeat with aMailbox in theMailboxes\n"
-    "set theSelection to (every message in aMailbox whose flagged status = true)\n"
-    "repeat with theMessage in theSelection\n"
-    "set theID to message id of theMessage\n"
-    "set theSubject to subject of theMessage\n"
-    "set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
-    "copy theLink to end of theLinkList\n"
-
-    ;; Report progress through Growl
-    ;; This "double tell" idiom is described in detail at
-    ;; http://macscripter.net/viewtopic.php?id=24570 The
-    ;; script compiler needs static knowledge of the
-    ;; growlHelperApp.  Hmm, since we're compiling
-    ;; on-the-fly here, this is likely to be way less
-    ;; portable than I'd hoped.  It'll work when the name
-    ;; is still "GrowlHelperApp", though.
-    "if growlHelperApp is not \"\" then\n"
-    "tell application \"GrowlHelperApp\"\n"
-    "tell application growlHelperApp\n"
-    "set the allNotificationsList to {\"FlaggedMail\"}\n"
-    "set the enabledNotificationsList to allNotificationsList\n"
-    "register as application \"FlaggedMail\" all notifications allNotificationsList default notifications enabledNotificationsList icon of application \"Mail\"\n"
-    "notify with name \"FlaggedMail\" title \"Importing flagged message\" description theSubject application name \"FlaggedMail\"\n"
-    "end tell\n"
-    "end tell\n"
-    "end if\n"
-    "end repeat\n"
-    "end repeat\n"
-    "return theLinkList as string\n"
-    "end tell")))
-
-(defun org-mac-message-get-links (&optional select-or-flag)
-  "Create links to the messages currently selected or flagged in Mail.app.
-This will use AppleScript to get the message-id and the subject of the
-messages in Mail.app and make a link out of it.
-When SELECT-OR-FLAG is \"s\", get the selected messages (this is also
-the default).  When SELECT-OR-FLAG is \"f\", get the flagged messages.
-The Org-syntax text will be pushed to the kill ring, and also returned."
-  (interactive "sLink to (s)elected or (f)lagged messages: ")
-  (setq select-or-flag (or select-or-flag "s"))
-  (message "AppleScript: searching mailboxes...")
-  (let* ((as-link-list
-         (if (string= select-or-flag "s")
-             (as-get-selected-mail)
-           (if (string= select-or-flag "f")
-               (as-get-flagged-mail)
-             (error "Please select \"s\" or \"f\""))))
-        (link-list
-         (mapcar
-          (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x)
-          (split-string as-link-list "[\r\n]+")))
-        split-link URL description orglink orglink-insert rtn orglink-list)
-    (while link-list
-      (setq split-link (split-string (pop link-list) "::split::"))
-      (setq URL (car split-link))
-      (setq description (cadr split-link))
-      (when (not (string= URL ""))
-       (setq orglink (org-make-link-string URL description))
-       (push orglink orglink-list)))
-    (setq rtn (mapconcat 'identity orglink-list "\n"))
-    (kill-new rtn)
-    rtn))
-
-(defun org-mac-message-insert-selected ()
-  "Insert a link to the messages currently selected in Mail.app.
-This will use AppleScript to get the message-id and the subject of the
-active mail in Mail.app and make a link out of it."
-  (interactive)
-  (insert (org-mac-message-get-links "s")))
-
-;; The following line is for backward compatibility
-(defalias 'org-mac-message-insert-link 'org-mac-message-insert-selected)
-
-(defun org-mac-message-insert-flagged (org-buffer org-heading)
-  "Asks for an org buffer and a heading within it, and replace message links.
-If heading exists, delete all message:// links within heading's first
-level.  If heading doesn't exist, create it at point-max.  Insert
-list of message:// links to flagged mail after heading."
-  (interactive "bBuffer in which to insert links: \nsHeading after which to insert links: ")
-  (with-current-buffer org-buffer
-    (goto-char (point-min))
-    (let ((isearch-forward t)
-         (message-re "\\[\\[\\(message:\\)\\([^]]+\\)\\]\\(\\[\\([^]]+\\)\\]\\)?\\]"))
-      (if (org-goto-local-search-headings org-heading nil t)
-         (if (not (eobp))
-             (progn
-               (save-excursion
-                 (while (re-search-forward
-                         message-re (save-excursion (outline-next-heading)) t)
-                   (delete-region (match-beginning 0) (match-end 0)))
-                 (insert "\n" (org-mac-message-get-links "f")))
-               (flush-lines "^$" (point) (outline-next-heading)))
-           (insert "\n" (org-mac-message-get-links "f")))
-       (goto-char (point-max))
-       (insert "\n")
-       (org-insert-heading nil t)
-       (insert org-heading "\n" (org-mac-message-get-links "f"))))))
-
-(provide 'org-mac-message)
-
-;;; org-mac-message.el ends here
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
new file mode 100644 (file)
index 0000000..61e9243
--- /dev/null
@@ -0,0 +1,193 @@
+;;; org-macro.el --- Macro Replacement Code for Org Mode
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Macros are expanded with `org-macro-replace-all', which relies
+;; internally on `org-macro-expand'.
+
+;; Default templates for expansion are stored in the buffer-local
+;; variable `org-macro-templates'.  This variable is updated by
+;; `org-macro-initialize-templates', which recursively calls
+;; `org-macro--collect-macros' in order to read setup files.
+
+;; Along with macros defined through #+MACRO: keyword, default
+;; templates include the following hard-coded macros:
+;; {{{time(format-string)}}}, {{{property(node-property)}}},
+;; {{{input-file}}} and {{{modification-time(format-string)}}}.
+
+;; Upon exporting, "ox.el" will also provide {{{author}}}, {{{date}}},
+;; {{{email}}} and {{{title}}} macros.
+
+;;; Code:
+(require 'org-macs)
+
+(declare-function org-element-at-point "org-element" (&optional keep-trail))
+(declare-function org-element-context "org-element" (&optional element))
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-type "org-element" (element))
+(declare-function org-remove-double-quotes "org" (s))
+(declare-function org-mode "org" ())
+(declare-function org-file-contents "org" (file &optional noerror))
+(declare-function org-with-wide-buffer "org-macs" (&rest body))
+
+;;; Variables
+
+(defvar org-macro-templates nil
+  "Alist containing all macro templates in current buffer.
+Associations are in the shape of (NAME . TEMPLATE) where NAME
+stands for macro's name and template for its replacement value,
+both as strings.  This is an internal variable.  Do not set it
+directly, use instead:
+
+  #+MACRO: name template")
+(make-variable-buffer-local 'org-macro-templates)
+
+
+;;; Functions
+
+(defun org-macro--collect-macros ()
+  "Collect macro definitions in current buffer and setup files.
+Return an alist containing all macro templates found."
+  (let* (collect-macros                        ; For byte-compiler.
+        (collect-macros
+         (lambda (files templates)
+           ;; Return an alist of macro templates.  FILES is a list of
+           ;; setup files names read so far, used to avoid circular
+           ;; dependencies.  TEMPLATES is the alist collected so far.
+           (let ((case-fold-search t))
+             (org-with-wide-buffer
+              (goto-char (point-min))
+              (while (re-search-forward
+                      "^[ \t]*#\\+\\(MACRO\\|SETUPFILE\\):" nil t)
+                (let ((element (org-element-at-point)))
+                  (when (eq (org-element-type element) 'keyword)
+                    (let ((val (org-element-property :value element)))
+                      (if (equal (org-element-property :key element) "MACRO")
+                          ;; Install macro in TEMPLATES.
+                          (when (string-match
+                                 "^\\(.*?\\)\\(?:\\s-+\\(.*\\)\\)?\\s-*$" val)
+                            (let* ((name (match-string 1 val))
+                                   (template (or (match-string 2 val) ""))
+                                   (old-cell (assoc name templates)))
+                              (if old-cell (setcdr old-cell template)
+                                (push (cons name template) templates))))
+                        ;; Enter setup file.
+                        (let ((file (expand-file-name
+                                     (org-remove-double-quotes val))))
+                          (unless (member file files)
+                            (with-temp-buffer
+                              (org-mode)
+                              (insert (org-file-contents file 'noerror))
+                              (setq templates
+                                    (funcall collect-macros (cons file files)
+                                             templates)))))))))))
+             templates))))
+    (funcall collect-macros nil nil)))
+
+(defun org-macro-initialize-templates ()
+  "Collect macro templates defined in current buffer.
+Templates are stored in buffer-local variable
+`org-macro-templates'.  In addition to buffer-defined macros, the
+function installs the following ones: \"property\",
+\"time\". and, if the buffer is associated to a file,
+\"input-file\" and \"modification-time\"."
+  (let* ((templates (org-macro--collect-macros))
+        (update-templates
+         (lambda (cell)
+           (let ((old-template (assoc (car cell) templates)))
+             (if old-template (setcdr old-template (cdr cell))
+               (push cell templates))))))
+    ;; Install hard-coded macros.
+    (mapc (lambda (cell) (funcall update-templates cell))
+         (list (cons "property" "(eval (org-entry-get nil \"$1\" 'selective))")
+               (cons "time" "(eval (format-time-string \"$1\"))")))
+    (let ((visited-file (buffer-file-name (buffer-base-buffer))))
+      (when (and visited-file (file-exists-p visited-file))
+       (mapc (lambda (cell) (funcall update-templates cell))
+             (list (cons "input-file" (file-name-nondirectory visited-file))
+                   (cons "modification-time"
+                         (format "(eval (format-time-string \"$1\" '%s))"
+                                 (prin1-to-string
+                                  (nth 5 (file-attributes visited-file)))))))))
+    (setq org-macro-templates templates)))
+
+(defun org-macro-expand (macro templates)
+  "Return expanded MACRO, as a string.
+MACRO is an object, obtained, for example, with
+`org-element-context'.  TEMPLATES is an alist of templates used
+for expansion.  See `org-macro-templates' for a buffer-local
+default value.  Return nil if no template was found."
+  (let ((template
+        ;; Macro names are case-insensitive.
+        (cdr (assoc-string (org-element-property :key macro) templates t))))
+    (when template
+      (let ((value (replace-regexp-in-string
+                    "\\$[0-9]+"
+                    (lambda (arg)
+                      (or (nth (1- (string-to-number (substring arg 1)))
+                               (org-element-property :args macro))
+                          ;; No argument: remove place-holder.
+                          ""))
+                    template nil 'literal)))
+        ;; VALUE starts with "(eval": it is a s-exp, `eval' it.
+        (when (string-match "\\`(eval\\>" value)
+          (setq value (eval (read value))))
+        ;; Return string.
+        (format "%s" (or value ""))))))
+
+(defun org-macro-replace-all (templates)
+  "Replace all macros in current buffer by their expansion.
+TEMPLATES is an alist of templates used for expansion.  See
+`org-macro-templates' for a buffer-local default value."
+  (save-excursion
+    (goto-char (point-min))
+    (let (record)
+      (while (re-search-forward "{{{[-A-Za-z0-9_]" nil t)
+       (let ((object (org-element-context)))
+         (when (eq (org-element-type object) 'macro)
+           (let* ((value (org-macro-expand object templates))
+                  (begin (org-element-property :begin object))
+                  (signature (list begin
+                                   object
+                                   (org-element-property :args object))))
+             ;; Avoid circular dependencies by checking if the same
+             ;; macro with the same arguments is expanded at the same
+             ;; position twice.
+             (if (member signature record)
+                 (error "Circular macro expansion: %s"
+                        (org-element-property :key object))
+               (when value
+                 (push signature record)
+                 (delete-region
+                  begin
+                  ;; Preserve white spaces after the macro.
+                  (progn (goto-char (org-element-property :end object))
+                         (skip-chars-backward " \t")
+                         (point)))
+                 ;; Leave point before replacement in case of recursive
+                 ;; expansions.
+                 (save-excursion (insert value)))))))))))
+
+
+(provide 'org-macro)
+;;; org-macro.el ends here
index 57b2d8a577e9ed3573181e737091aed081bc7883..0083d293edc48fce8491c1c641ce3bc91dc1623d 100644 (file)
@@ -33,7 +33,9 @@
 
 (eval-and-compile
   (unless (fboundp 'declare-function)
-    (defmacro declare-function (fn file &optional arglist fileonly)))
+    (defmacro declare-function (fn file &optional arglist fileonly)
+      `(autoload ',fn ,file)))
+
   (if (>= emacs-major-version 23)
       (defsubst org-char-to-string(c)
        "Defsubst to decode UTF-8 character values in emacs 23 and beyond."
       `(interactive-p))))
 (def-edebug-spec org-called-interactively-p (&optional ("quote" symbolp)))
 
-(when (and (not (fboundp 'with-silent-modifications))
-          (or (< emacs-major-version 23)
-              (and (= emacs-major-version 23)
-                   (< emacs-minor-version 2))))
-  (defmacro with-silent-modifications (&rest body)
-    `(org-unmodified ,@body))
-  (def-edebug-spec with-silent-modifications (body)))
-
 (defmacro org-bound-and-true-p (var)
   "Return the value of symbol VAR if it is bound, else nil."
   `(and (boundp (quote ,var)) ,var))
 Otherwise return nil."
   (and v (not (equal v "nil")) v))
 
-(defmacro org-unmodified (&rest body)
-  "Execute body without changing `buffer-modified-p'.
-Also, do not record undo information."
-  `(set-buffer-modified-p
-    (prog1 (buffer-modified-p)
-      (let ((buffer-undo-list t)
-           (inhibit-modification-hooks t))
-       ,@body))))
-(def-edebug-spec org-unmodified (body))
-
 (defun org-substitute-posix-classes (re)
   "Substitute posix classes in regular expression RE."
   (let ((ss re))
@@ -126,14 +110,18 @@ Also, do not record undo information."
         (org-move-to-column ,col)))))
 (def-edebug-spec org-preserve-lc (body))
 
-;; Copied from bookmark.el
-(defmacro org-with-buffer-modified-unmodified (&rest body)
+;; Use `org-with-silent-modifications' to ignore cosmetic changes and
+;; `org-unmodified' to ignore real text modifications
+(defmacro org-unmodified (&rest body)
   "Run BODY while preserving the buffer's `buffer-modified-p' state."
   (org-with-gensyms (was-modified)
     `(let ((,was-modified (buffer-modified-p)))
        (unwind-protect
-           (progn ,@body)
-         (set-buffer-modified-p ,was-modified)))))
+           (let ((buffer-undo-list t)
+                (inhibit-modification-hooks t))
+            ,@body)
+        (set-buffer-modified-p ,was-modified)))))
+(def-edebug-spec org-unmodified (body))
 
 (defmacro org-without-partial-completion (&rest body)
   `(if (and (boundp 'partial-completion-mode)
@@ -176,46 +164,17 @@ We use a macro so that the test can happen at compilation time."
   (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
 (def-edebug-spec org-no-warnings (body))
 
-(defmacro org-if-unprotected (&rest body)
-  "Execute BODY if there is no `org-protected' text property at point."
-  `(unless (get-text-property (point) 'org-protected)
-     ,@body))
-(def-edebug-spec org-if-unprotected (body))
-
-(defmacro org-if-unprotected-1 (&rest body)
-  "Execute BODY if there is no `org-protected' text property at point-1."
-  `(unless (get-text-property (1- (point)) 'org-protected)
-     ,@body))
-(def-edebug-spec org-if-unprotected-1 (body))
-
-(defmacro org-if-unprotected-at (pos &rest body)
-  "Execute BODY if there is no `org-protected' text property at POS."
-  `(unless (get-text-property ,pos 'org-protected)
-     ,@body))
-(def-edebug-spec org-if-unprotected-at (form body))
-(put 'org-if-unprotected-at 'lisp-indent-function 1)
-
-(defun org-re-search-forward-unprotected (&rest args)
-  "Like re-search-forward, but stop only in unprotected places."
-  (catch 'exit
-    (while t
-      (unless (apply 're-search-forward args)
-       (throw 'exit nil))
-      (unless (get-text-property (match-beginning 0) 'org-protected)
-       (throw 'exit (point))))))
-
-;; FIXME: Normalize argument names
-(defmacro org-with-remote-undo (_buffer &rest _body)
+(defmacro org-with-remote-undo (buffer &rest body)
   "Execute BODY while recording undo information in two buffers."
   (org-with-gensyms (cline cmd buf1 buf2 undo1 undo2 c1 c2)
     `(let ((,cline (org-current-line))
           (,cmd this-command)
           (,buf1 (current-buffer))
-          (,buf2 ,_buffer)
+          (,buf2 ,buffer)
           (,undo1 buffer-undo-list)
-          (,undo2 (with-current-buffer ,_buffer buffer-undo-list))
+          (,undo2 (with-current-buffer ,buffer buffer-undo-list))
           ,c1 ,c2)
-       ,@_body
+       ,@body
        (when org-agenda-allow-remote-undo
         (setq ,c1 (org-verify-change-for-undo
                    ,undo1 (with-current-buffer ,buf1 buffer-undo-list))
@@ -427,6 +386,13 @@ the value in cdr."
     (cons (list (car flat) (cadr flat))
          (org-make-parameter-alist (cddr flat)))))
 
+;;;###autoload
+(defmacro org-load-noerror-mustsuffix (file)
+  "Load FILE with optional arguments NOERROR and MUSTSUFFIX.  Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it."
+  (if (featurep 'xemacs)
+      `(load ,file 'noerror)
+    `(load ,file 'noerror nil nil 'mustsuffix)))
+
 (provide 'org-macs)
 
 ;;; org-macs.el ends here
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el
deleted file mode 100644 (file)
index 820988b..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-;;; org-mew.el --- Support for links to Mew messages from within Org-mode
-
-;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
-
-;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file implements links to Mew messages from within Org-mode.
-;; Org-mode loads this module by default - if this is not what you want,
-;; configure the variable `org-modules'.
-
-;;; Code:
-
-(require 'org)
-
-(defgroup org-mew nil
-  "Options concerning the Mew link."
-  :tag "Org Startup"
-  :group 'org-link)
-
-(defcustom org-mew-link-to-refile-destination t
-  "Create a link to the refile destination if the message is marked as refile."
-  :group 'org-mew
-  :type 'boolean)
-
-;; Declare external functions and variables
-(declare-function mew-cache-hit "ext:mew-cache" (fld msg &optional must-hit))
-(declare-function mew-case-folder "ext:mew-func" (case folder))
-(declare-function mew-header-get-value "ext:mew-header"
-                 (field &optional as-list))
-(declare-function mew-init "ext:mew" ())
-(declare-function mew-refile-get "ext:mew-refile" (msg))
-(declare-function mew-sinfo-get-case "ext:mew-summary" ())
-(declare-function mew-summary-display "ext:mew-summary2" (&optional redisplay))
-(declare-function mew-summary-folder-name "ext:mew-syntax" (&optional ext))
-(declare-function mew-summary-get-mark "ext:mew-mark" ())
-(declare-function mew-summary-message-number2 "ext:mew-syntax" ())
-(declare-function mew-summary-pick-with-mewl "ext:mew-pick"
-                 (pattern folder src-msgs))
-(declare-function mew-summary-search-msg "ext:mew-const" (msg))
-(declare-function mew-summary-set-message-buffer "ext:mew-summary3" (fld msg))
-(declare-function mew-summary-visit-folder "ext:mew-summary4"
-                 (folder &optional goend no-ls))
-(declare-function mew-window-push "ext:mew" ())
-(defvar mew-init-p)
-(defvar mew-summary-goto-line-then-display)
-
-;; Install the link type
-(org-add-link-type "mew" 'org-mew-open)
-(add-hook 'org-store-link-functions 'org-mew-store-link)
-
-;; Implementation
-(defun org-mew-store-link ()
-  "Store a link to a Mew folder or message."
-  (when (memq major-mode '(mew-summary-mode mew-virtual-mode))
-    (let* ((msgnum (mew-summary-message-number2))
-          (mark-info (mew-summary-get-mark))
-          (folder-name
-           (if (and org-mew-link-to-refile-destination
-                    (eq mark-info ?o)) ; marked as refile
-               (mew-case-folder (mew-sinfo-get-case)
-                                (nth 1 (mew-refile-get msgnum)))
-             (mew-summary-folder-name)))
-          message-id from to subject desc link date date-ts date-ts-ia)
-      (save-window-excursion
-       (if (fboundp 'mew-summary-set-message-buffer)
-           (mew-summary-set-message-buffer folder-name msgnum)
-         (set-buffer (mew-cache-hit folder-name msgnum t)))
-       (setq message-id (mew-header-get-value "Message-Id:"))
-       (setq from (mew-header-get-value "From:"))
-       (setq to (mew-header-get-value "To:"))
-       (setq date (mew-header-get-value "Date:"))
-       (setq date-ts (and date (format-time-string
-                                (org-time-stamp-format t)
-                                (date-to-time date))))
-       (setq date-ts-ia (and date (format-time-string
-                                   (org-time-stamp-format t t)
-                                   (date-to-time date))))
-       (setq subject (mew-header-get-value "Subject:")))
-      (org-store-link-props :type "mew" :from from :to to
-                           :subject subject :message-id message-id)
-      (when date
-       (org-add-link-props :date date :date-timestamp date-ts
-                           :date-timestamp-inactive date-ts-ia))
-      (setq message-id (org-remove-angle-brackets message-id))
-      (setq desc (org-email-link-description))
-      (setq link (concat "mew:" folder-name "#" message-id))
-      (org-add-link-props :link link :description desc)
-      link)))
-
-(defun org-mew-open (path)
-  "Follow the Mew message link specified by PATH."
-  (let (folder msgnum)
-    (cond ((string-match "\\`\\(+.*\\)+\\+\\([0-9]+\\)\\'" path) ; for Bastien's
-          (setq folder (match-string 1 path))
-          (setq msgnum (match-string 2 path)))
-         ((string-match "\\`\\(\\(%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path)
-          (setq folder (match-string 1 path))
-          (setq msgnum (match-string 4 path)))
-         (t (error "Error in Mew link")))
-    (require 'mew)
-    (mew-window-push)
-    (unless mew-init-p (mew-init))
-    (mew-summary-visit-folder folder)
-    (when msgnum
-      (if (not (string-match "\\`[0-9]+\\'" msgnum))
-         (let* ((pattern (concat "message-id=" msgnum))
-                (msgs (mew-summary-pick-with-mewl pattern folder nil)))
-           (setq msgnum (car msgs))))
-      (if (mew-summary-search-msg msgnum)
-         (if mew-summary-goto-line-then-display
-             (mew-summary-display))
-       (error "Message not found")))))
-
-(provide 'org-mew)
-
-;;; org-mew.el ends here
index 48767b7b797b9c35711cd682733b0face952c6f8..7d6e4ec9fb060bf5bc5821ed8eac160d664d5524 100644 (file)
@@ -30,6 +30,7 @@
 
 ;;; Code:
 
+(require 'org-macs)
 (require 'org)
 
 ;; Customization variables
diff --git a/lisp/org/org-mks.el b/lisp/org/org-mks.el
deleted file mode 100644 (file)
index c614799..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-;;; org-mks.el --- Multi-key-selection for Org-mode
-
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
-;;; Commentary:
-;;
-
-;;; Code:
-
-(require 'org)
-(eval-when-compile
-  (require 'cl))
-
-(defun org-mks (table title &optional prompt specials)
-  "Select a member of an alist with multiple keys.
-TABLE is the alist which should contain entries where the car is a string.
-There should be two types of entries.
-
-1. prefix descriptions like (\"a\" \"Description\")
-   This indicates that `a' is a prefix key for multi-letter selection, and
-   that there are entries following with keys like \"ab\", \"ax\"...
-
-2. Selectable members must have more than two elements, with the first
-   being the string of keys that lead to selecting it, and the second a
-   short description string of the item.
-
-The command will then make a temporary buffer listing all entries
-that can be selected with a single key, and all the single key
-prefixes.  When you press the key for a single-letter entry, it is selected.
-When you press a prefix key, the commands (and maybe further prefixes)
-under this key will be shown and offered for selection.
-
-TITLE will be placed over the selection in the temporary buffer,
-PROMPT will be used when prompting for a key.  SPECIAL is an alist with
-also (\"key\" \"description\") entries.  When one of these is selection,
-only the bare key is returned."
-  (setq prompt (or prompt "Select: "))
-  (let (tbl orig-table dkey ddesc des-keys allowed-keys
-           current prefix rtn re pressed buffer (inhibit-quit t))
-    (save-window-excursion
-      (setq buffer (org-switch-to-buffer-other-window "*Org Select*"))
-      (setq orig-table table)
-      (catch 'exit
-       (while t
-         (erase-buffer)
-         (insert title "\n\n")
-         (setq tbl table
-               des-keys nil
-               allowed-keys nil)
-         (setq prefix (if current (concat current " ") ""))
-         (while tbl
-           (cond
-            ((and (= 2 (length (car tbl))) (= (length (caar tbl)) 1))
-             ;; This is a description on this level
-             (setq dkey (caar tbl) ddesc (cadar tbl))
-             (pop tbl)
-             (push dkey des-keys)
-             (push dkey allowed-keys)
-             (insert prefix "[" dkey "]" "..." "  " ddesc "..." "\n")
-             ;; Skip keys which are below this prefix
-             (setq re (concat "\\`" (regexp-quote dkey)))
-             (while (and tbl (string-match re (caar tbl))) (pop tbl)))
-            ((= 2 (length (car tbl)))
-             ;; Not yet a usable description, skip it
-             )
-            (t
-             ;; usable entry on this level
-             (insert prefix "[" (caar tbl) "]" "     " (nth 1 (car tbl)) "\n")
-             (push (caar tbl) allowed-keys)
-             (pop tbl))))
-         (when specials
-           (insert "-------------------------------------------------------------------------------\n")
-           (let ((sp specials))
-             (while sp
-               (insert (format "[%s]     %s\n"
-                               (caar sp) (nth 1 (car sp))))
-               (push (caar sp) allowed-keys)
-               (pop sp))))
-         (push "\C-g" allowed-keys)
-         (goto-char (point-min))
-         (if (not (pos-visible-in-window-p (point-max)))
-             (org-fit-window-to-buffer))
-         (message prompt)
-         (setq pressed (char-to-string (read-char-exclusive)))
-         (while (not (member pressed allowed-keys))
-           (message "Invalid key `%s'" pressed) (sit-for 1)
-           (message prompt)
-           (setq pressed (char-to-string (read-char-exclusive))))
-         (when (equal pressed "\C-g")
-           (kill-buffer buffer)
-           (error "Abort"))
-         (when (and (not (assoc pressed table))
-                    (not (member pressed des-keys))
-                    (assoc pressed specials))
-           (throw 'exit (setq rtn pressed)))
-         (unless (member pressed des-keys)
-           (throw 'exit (setq rtn (rassoc (cdr (assoc pressed table))
-                                          orig-table))))
-         (setq current (concat current pressed))
-         (setq table (mapcar
-                      (lambda (x)
-                        (if (and (> (length (car x)) 1)
-                                 (equal (substring (car x) 0 1) pressed))
-                            (cons (substring (car x) 1) (cdr x))
-                          nil))
-                      table))
-         (setq table (remove nil table)))))
-    (when buffer (kill-buffer buffer))
-    rtn))
-
-(provide 'org-mks)
-
-;;; org-mks.el ends here
index 293d2a000c02b706bf5001edfe843ab876356017..a43896bdd7258d5e949c50fca8a4b31b2e7e30d0 100644 (file)
@@ -76,6 +76,13 @@ org-agenda-text-search-extra-files
   :group 'org-mobile
   :type 'directory)
 
+(defcustom org-mobile-allpriorities "A B C"
+  "Default set of priority cookies for the index file."
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string
+  :group 'org-mobile)
+
 (defcustom org-mobile-use-encryption nil
   "Non-nil means keep only encrypted files on the WebDAV server.
 Encryption uses AES-256, with a password given in
@@ -276,7 +283,7 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
                      (list f))
                     (t nil)))
                  org-mobile-files)))
-        (files (delete
+        (files (delq
                 nil
                 (mapcar (lambda (f)
                           (unless (and (not (string= org-mobile-files-exclude-regexp ""))
@@ -300,8 +307,6 @@ Also exclude files matching `org-mobile-files-exclude-regexp'."
        (push (cons file link-name) rtn)))
     (nreverse rtn)))
 
-(defvar org-agenda-filter)
-
 ;;;###autoload
 (defun org-mobile-push ()
   "Push the current state of Org affairs to the target directory.
@@ -314,23 +319,24 @@ create all custom agenda views, for upload to the mobile phone."
          (org-agenda-tag-filter org-agenda-tag-filter)
          (org-agenda-redo-command org-agenda-redo-command))
       (save-excursion
-       (save-window-excursion
-         (run-hooks 'org-mobile-pre-push-hook)
-         (org-mobile-check-setup)
-         (org-mobile-prepare-file-lists)
-         (message "Creating agendas...")
-         (let ((inhibit-redisplay t)
-               (org-agenda-files (mapcar 'car org-mobile-files-alist)))
-           (org-mobile-create-sumo-agenda))
-         (message "Creating agendas...done")
-         (org-save-all-org-buffers) ; to save any IDs created by this process
-         (message "Copying files...")
-         (org-mobile-copy-agenda-files)
-         (message "Writing index file...")
-         (org-mobile-create-index-file)
-         (message "Writing checksums...")
-         (org-mobile-write-checksums)
-         (run-hooks 'org-mobile-post-push-hook)))
+       (save-restriction
+         (save-window-excursion
+           (run-hooks 'org-mobile-pre-push-hook)
+           (org-mobile-check-setup)
+           (org-mobile-prepare-file-lists)
+           (message "Creating agendas...")
+           (let ((inhibit-redisplay t)
+                 (org-agenda-files (mapcar 'car org-mobile-files-alist)))
+             (org-mobile-create-sumo-agenda))
+           (message "Creating agendas...done")
+           (org-save-all-org-buffers) ; to save any IDs created by this process
+           (message "Copying files...")
+           (org-mobile-copy-agenda-files)
+           (message "Writing index file...")
+           (org-mobile-create-index-file)
+           (message "Writing checksums...")
+           (org-mobile-write-checksums)
+           (run-hooks 'org-mobile-post-push-hook))))
       (setq org-agenda-buffer-name org-agenda-curbuf-name
            org-agenda-this-buffer-name org-agenda-curbuf-name))
     (redraw-display)
@@ -463,7 +469,7 @@ agenda view showing the flagged items."
       (setq tags (append def-tags tags nil))
       (insert "#+TAGS: " (mapconcat 'identity tags " ") "\n")
       (insert "#+DRAWERS: " (mapconcat 'identity drawers " ") "\n")
-      (insert "#+ALLPRIORITIES: A B C" "\n")
+      (insert "#+ALLPRIORITIES: " org-mobile-allpriorities "\n")
       (when (file-exists-p (expand-file-name
                            org-mobile-directory "agendas.org"))
        (insert "* [[file:agendas.org][Agenda Views]]\n"))
@@ -1061,10 +1067,13 @@ be returned that indicates what went wrong."
         (t (error "Heading changed in MobileOrg and on the computer")))))
 
      ((eq what 'addheading)
-      (if (org-on-heading-p) ; if false we are in top-level of file
+      (if (org-at-heading-p) ; if false we are in top-level of file
          (progn
+           ;; Workaround a `org-insert-heading-respect-content' bug
+           ;; which prevents correct insertion when point is invisible
+           (org-show-subtree)
            (end-of-line 1)
-           (org-insert-heading-respect-content t)
+           (org-insert-heading-respect-content '(16) t)
            (org-demote))
        (beginning-of-line)
        (insert "* "))
@@ -1073,7 +1082,7 @@ be returned that indicates what went wrong."
      ((eq what 'refile)
       (org-copy-subtree)
       (org-with-point-at (org-mobile-locate-entry new)
-       (if (org-on-heading-p) ; if false we are in top-level of file
+       (if (org-at-heading-p) ; if false we are in top-level of file
            (progn
              (setq level (org-get-valid-level (funcall outline-level) 1))
              (org-end-of-subtree t t)
index fac43e4bc4937e514582283d70340bcaf5054150..c8a6c86cad11e9fb99a9ec40a1c7fcf2af6bd85d 100644 (file)
@@ -656,11 +656,11 @@ This means, between the beginning of line and the point."
         ["All Clear" (org-mouse-for-each-item
                       (lambda ()
                         (when (save-excursion (org-at-item-checkbox-p))
-                          (replace-match "[ ]"))))]
+                          (replace-match "[ ] "))))]
         ["All Set" (org-mouse-for-each-item
                     (lambda ()
                       (when (save-excursion (org-at-item-checkbox-p))
-                        (replace-match "[X]"))))]
+                        (replace-match "[X] "))))]
         ["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t]
         ["All Remove" (org-mouse-for-each-item
                        (lambda ()
@@ -1056,7 +1056,7 @@ This means, between the beginning of line and the point."
          ["Convert" org-agenda-convert-date
           (org-agenda-check-type nil 'agenda 'timeline)]
          "--"
-         ["Create iCalendar file" org-export-icalendar-combine-agenda-files t])
+         ["Create iCalendar file" org-icalendar-combine-agenda-files t])
         "--"
         ["Day View" org-agenda-day-view
          :active (org-agenda-check-type nil 'agenda)
diff --git a/lisp/org/org-odt.el b/lisp/org/org-odt.el
deleted file mode 100644 (file)
index 92228f3..0000000
+++ /dev/null
@@ -1,2859 +0,0 @@
-;;; org-odt.el --- OpenDocument Text exporter for Org-mode
-
-;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
-
-;; Author: Jambunathan K <kjambunathan at gmail dot com>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;; Code:
-(eval-when-compile
-  (require 'cl))
-(require 'org-lparse)
-
-(defgroup org-export-odt nil
-  "Options specific for ODT export of Org-mode files."
-  :tag "Org Export ODT"
-  :group 'org-export
-  :version "24.1")
-
-(defvar org-lparse-dyn-first-heading-pos) ; let bound during org-do-lparse
-(defun org-odt-insert-toc ()
-  (goto-char (point-min))
-  (cond
-   ((re-search-forward
-     "\\(<text:p [^>]*>\\)?\\s-*\\[TABLE-OF-CONTENTS\\]\\s-*\\(</text:p>\\)?"
-     nil t)
-    (replace-match ""))
-   (t
-    (goto-char org-lparse-dyn-first-heading-pos)))
-  (insert (org-odt-format-toc)))
-
-(defun org-odt-end-export ()
-  (org-odt-insert-toc)
-  (org-odt-fixup-label-references)
-
-  ;; remove empty paragraphs
-  (goto-char (point-min))
-  (while (re-search-forward
-         "<text:p\\( text:style-name=\"Text_20_body\"\\)?>[ \r\n\t]*</text:p>"
-         nil t)
-    (replace-match ""))
-  (goto-char (point-min))
-
-  ;; Convert whitespace place holders
-  (goto-char (point-min))
-  (let (beg end n)
-    (while (setq beg (next-single-property-change (point) 'org-whitespace))
-      (setq n (get-text-property beg 'org-whitespace)
-           end (next-single-property-change beg 'org-whitespace))
-      (goto-char beg)
-      (delete-region beg end)
-      (insert (format "<span style=\"visibility:hidden;\">%s</span>"
-                     (make-string n ?x)))))
-
-  ;; Remove empty lines at the beginning of the file.
-  (goto-char (point-min))
-  (when (looking-at "\\s-+\n") (replace-match ""))
-
-  ;; Remove display properties
-  (remove-text-properties (point-min) (point-max) '(display t)))
-
-(defvar org-odt-suppress-xref nil)
-(defconst org-export-odt-special-string-regexps
-  '(("\\\\-" . "&#x00ad;\\1")          ; shy
-    ("---\\([^-]\\)" . "&#x2014;\\1")  ; mdash
-    ("--\\([^-]\\)" . "&#x2013;\\1")   ; ndash
-    ("\\.\\.\\." . "&#x2026;"))                ; hellip
-  "Regular expressions for special string conversion.")
-
-(defconst org-odt-lib-dir (file-name-directory load-file-name)
-  "Location of ODT exporter.
-Use this to infer values of `org-odt-styles-dir' and
-`org-export-odt-schema-dir'.")
-
-(defvar org-odt-data-dir nil
-  "Data directory for ODT exporter.
-Use this to infer values of `org-odt-styles-dir' and
-`org-export-odt-schema-dir'.")
-
-(defconst org-odt-schema-dir-list
-  (list
-   (and org-odt-data-dir
-       (expand-file-name "./schema/" org-odt-data-dir)) ; bail out
-   (eval-when-compile
-     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
-         (expand-file-name "./schema/" org-odt-data-dir))))
-  "List of directories to search for OpenDocument schema files.
-Use this list to set the default value of
-`org-export-odt-schema-dir'.  The entries in this list are
-populated heuristically based on the values of `org-odt-lib-dir'
-and `org-odt-data-dir'.")
-
-(defcustom org-export-odt-schema-dir
-  (let* ((schema-dir
-         (catch 'schema-dir
-           (message "Debug (org-odt): Searching for OpenDocument schema files...")
-           (mapc
-            (lambda (schema-dir)
-              (when schema-dir
-                (message "Debug (org-odt): Trying %s..." schema-dir)
-                (when (and (file-readable-p
-                            (expand-file-name "od-manifest-schema-v1.2-cs01.rnc"
-                                              schema-dir))
-                           (file-readable-p
-                            (expand-file-name "od-schema-v1.2-cs01.rnc"
-                                              schema-dir))
-                           (file-readable-p
-                            (expand-file-name "schemas.xml" schema-dir)))
-                  (message "Debug (org-odt): Using schema files under %s"
-                           schema-dir)
-                  (throw 'schema-dir schema-dir))))
-            org-odt-schema-dir-list)
-           (message "Debug (org-odt): No OpenDocument schema files installed")
-           nil)))
-    schema-dir)
-  "Directory that contains OpenDocument schema files.
-
-This directory contains:
-1. rnc files for OpenDocument schema
-2. a \"schemas.xml\" file that specifies locating rules needed
-   for auto validation of OpenDocument XML files.
-
-Use the customize interface to set this variable.  This ensures
-that `rng-schema-locating-files' is updated and auto-validation
-of OpenDocument XML takes place based on the value
-`rng-nxml-auto-validate-flag'.
-
-The default value of this variable varies depending on the
-version of org in use and is initialized from
-`org-odt-schema-dir-list'.  The OASIS schema files are available
-only in the org's private git repository.  It is *not* bundled
-with GNU ELPA tar or standard Emacs distribution."
-  :type '(choice
-         (const :tag "Not set" nil)
-         (directory :tag "Schema directory"))
-  :group 'org-export-odt
-  :version "24.1"
-  :set
-  (lambda (var value)
-    "Set `org-export-odt-schema-dir'.
-Also add it to `rng-schema-locating-files'."
-    (let ((schema-dir value))
-      (set var
-          (if (and
-               (file-readable-p
-                (expand-file-name "od-manifest-schema-v1.2-cs01.rnc" schema-dir))
-               (file-readable-p
-                (expand-file-name "od-schema-v1.2-cs01.rnc" schema-dir))
-               (file-readable-p
-                (expand-file-name "schemas.xml" schema-dir)))
-              schema-dir
-            (when value
-              (message "Error (org-odt): %s has no OpenDocument schema files"
-                       value))
-            nil)))
-    (when org-export-odt-schema-dir
-      (eval-after-load 'rng-loc
-       '(add-to-list 'rng-schema-locating-files
-                     (expand-file-name "schemas.xml"
-                                       org-export-odt-schema-dir))))))
-
-(defconst org-odt-styles-dir-list
-  (list
-   (and org-odt-data-dir
-       (expand-file-name "./styles/" org-odt-data-dir)) ; bail out
-   (eval-when-compile
-     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
-         (expand-file-name "./styles/" org-odt-data-dir)))
-   (expand-file-name "../etc/styles/" org-odt-lib-dir) ; git
-   (expand-file-name "./etc/styles/" org-odt-lib-dir)  ; elpa
-   (expand-file-name "./org/" data-directory)         ; system
-   )
-  "List of directories to search for OpenDocument styles files.
-See `org-odt-styles-dir'.  The entries in this list are populated
-heuristically based on the values of `org-odt-lib-dir' and
-`org-odt-data-dir'.")
-
-(defconst org-odt-styles-dir
-  (let* ((styles-dir
-         (catch 'styles-dir
-           (message "Debug (org-odt): Searching for OpenDocument styles files...")
-           (mapc (lambda (styles-dir)
-                   (when styles-dir
-                     (message "Debug (org-odt): Trying %s..." styles-dir)
-                     (when (and (file-readable-p
-                                 (expand-file-name
-                                  "OrgOdtContentTemplate.xml" styles-dir))
-                                (file-readable-p
-                                 (expand-file-name
-                                  "OrgOdtStyles.xml" styles-dir)))
-                       (message "Debug (org-odt): Using styles under %s"
-                                styles-dir)
-                       (throw 'styles-dir styles-dir))))
-                 org-odt-styles-dir-list)
-           nil)))
-    (unless styles-dir
-      (error "Error (org-odt): Cannot find factory styles files, aborting"))
-    styles-dir)
-  "Directory that holds auxiliary XML files used by the ODT exporter.
-
-This directory contains the following XML files -
- \"OrgOdtStyles.xml\" and \"OrgOdtContentTemplate.xml\".  These
- XML files are used as the default values of
- `org-export-odt-styles-file' and
- `org-export-odt-content-template-file'.
-
-The default value of this variable varies depending on the
-version of org in use and is initialized from
-`org-odt-styles-dir-list'.  Note that the user could be using org
-from one of: org's own private git repository, GNU ELPA tar or
-standard Emacs.")
-
-(defvar org-odt-file-extensions
-  '(("odt" . "OpenDocument Text")
-    ("ott" . "OpenDocument Text Template")
-    ("odm" . "OpenDocument Master Document")
-    ("ods" . "OpenDocument Spreadsheet")
-    ("ots" . "OpenDocument Spreadsheet Template")
-    ("odg" . "OpenDocument Drawing (Graphics)")
-    ("otg" . "OpenDocument Drawing Template")
-    ("odp" . "OpenDocument Presentation")
-    ("otp" . "OpenDocument Presentation Template")
-    ("odi" . "OpenDocument Image")
-    ("odf" . "OpenDocument Formula")
-    ("odc" . "OpenDocument Chart")))
-
-(mapc
- (lambda (desc)
-   ;; Let Emacs open all OpenDocument files in archive mode
-   (add-to-list 'auto-mode-alist
-               (cons (concat  "\\." (car desc) "\\'") 'archive-mode)))
- org-odt-file-extensions)
-
-;; register the odt exporter with the pre-processor
-(add-to-list 'org-export-backends 'odt)
-
-;; register the odt exporter with org-lparse library
-(org-lparse-register-backend 'odt)
-
-(defun org-odt-unload-function ()
-  (org-lparse-unregister-backend 'odt)
-  (remove-hook 'org-export-preprocess-after-blockquote-hook
-              'org-export-odt-preprocess-latex-fragments)
-  nil)
-
-(defcustom org-export-odt-content-template-file nil
-  "Template file for \"content.xml\".
-The exporter embeds the exported content just before
-\"</office:text>\" element.
-
-If unspecified, the file named \"OrgOdtContentTemplate.xml\"
-under `org-odt-styles-dir' is used."
-  :type 'file
-  :group 'org-export-odt
-  :version "24.1")
-
-(defcustom org-export-odt-styles-file nil
-  "Default styles file for use with ODT export.
-Valid values are one of:
-1. nil
-2. path to a styles.xml file
-3. path to a *.odt or a *.ott file
-4. list of the form (ODT-OR-OTT-FILE (FILE-MEMBER-1 FILE-MEMBER-2
-...))
-
-In case of option 1, an in-built styles.xml is used.  See
-`org-odt-styles-dir' for more information.
-
-In case of option 3, the specified file is unzipped and the
-styles.xml embedded therein is used.
-
-In case of option 4, the specified ODT-OR-OTT-FILE is unzipped
-and FILE-MEMBER-1, FILE-MEMBER-2 etc are copied in to the
-generated odt file.  Use relative path for specifying the
-FILE-MEMBERS.  styles.xml must be specified as one of the
-FILE-MEMBERS.
-
-Use options 1, 2 or 3 only if styles.xml alone suffices for
-achieving the desired formatting.  Use option 4, if the styles.xml
-references additional files like header and footer images for
-achieving the desired formatting.
-
-Use \"#+ODT_STYLES_FILE: ...\" directive to set this variable on
-a per-file basis.  For example,
-
-#+ODT_STYLES_FILE: \"/path/to/styles.xml\" or
-#+ODT_STYLES_FILE: (\"/path/to/file.ott\" (\"styles.xml\" \"image/hdr.png\"))."
-  :group 'org-export-odt
-  :version "24.1"
-  :type
-  '(choice
-    (const :tag "Factory settings" nil)
-    (file :must-match t :tag "styles.xml")
-    (file :must-match t :tag "ODT or OTT file")
-    (list :tag "ODT or OTT file + Members"
-         (file :must-match t :tag "ODF Text or Text Template file")
-         (cons :tag "Members"
-               (file :tag "    Member" "styles.xml")
-               (repeat (file :tag "Member"))))))
-
-(eval-after-load 'org-exp
-  '(add-to-list 'org-export-inbuffer-options-extra
-               '("ODT_STYLES_FILE" :odt-styles-file)))
-
-(defconst org-export-odt-tmpdir-prefix "%s-")
-(defconst org-export-odt-bookmark-prefix "OrgXref.")
-(defvar org-odt-zip-dir nil
-  "Temporary directory that holds XML files during export.")
-
-(defvar org-export-odt-embed-images t
-  "Should the images be copied in to the odt file or just linked?")
-
-(defvar org-export-odt-inline-images 'maybe)
-(defcustom org-export-odt-inline-image-extensions
-  '("png" "jpeg" "jpg" "gif")
-  "Extensions of image files that can be inlined into HTML."
-  :type '(repeat (string :tag "Extension"))
-  :group 'org-export-odt
-  :version "24.1")
-
-(defcustom org-export-odt-pixels-per-inch display-pixels-per-inch
-  "Scaling factor for converting images pixels to inches.
-Use this for sizing of embedded images.  See Info node `(org)
-Images in ODT export' for more information."
-  :type 'float
-  :group 'org-export-odt
-  :version "24.1")
-
-(defcustom org-export-odt-create-custom-styles-for-srcblocks t
-  "Whether custom styles for colorized source blocks be automatically created.
-When this option is turned on, the exporter creates custom styles
-for source blocks based on the advice of `htmlfontify'.  Creation
-of custom styles happen as part of `org-odt-hfy-face-to-css'.
-
-When this option is turned off exporter does not create such
-styles.
-
-Use the latter option if you do not want the custom styles to be
-based on your current display settings.  It is necessary that the
-styles.xml already contains needed styles for colorizing to work.
-
-This variable is effective only if
-`org-export-odt-fontify-srcblocks' is turned on."
-  :group 'org-export-odt
-  :version "24.1"
-  :type 'boolean)
-
-(defvar org-export-odt-default-org-styles-alist
-  '((paragraph . ((default . "Text_20_body")
-                 (fixedwidth . "OrgFixedWidthBlock")
-                 (verse . "OrgVerse")
-                 (quote . "Quotations")
-                 (blockquote . "Quotations")
-                 (center . "OrgCenter")
-                 (left . "OrgLeft")
-                 (right . "OrgRight")
-                 (title . "OrgTitle")
-                 (subtitle . "OrgSubtitle")
-                 (footnote . "Footnote")
-                 (src . "OrgSrcBlock")
-                 (illustration . "Illustration")
-                 (table . "Table")
-                 (definition-term . "Text_20_body_20_bold")
-                 (horizontal-line . "Horizontal_20_Line")))
-    (character . ((default . "Default")
-                 (bold . "Bold")
-                 (emphasis . "Emphasis")
-                 (code . "OrgCode")
-                 (verbatim . "OrgCode")
-                 (strike . "Strikethrough")
-                 (underline . "Underline")
-                 (subscript . "OrgSubscript")
-                 (superscript . "OrgSuperscript")))
-    (list . ((ordered . "OrgNumberedList")
-            (unordered . "OrgBulletedList")
-            (description . "OrgDescriptionList"))))
-  "Default styles for various entities.")
-
-(defvar org-export-odt-org-styles-alist org-export-odt-default-org-styles-alist)
-(defun org-odt-get-style-name-for-entity (category &optional entity)
-  (let ((entity (or entity 'default)))
-    (or
-     (cdr (assoc entity (cdr (assoc category
-                                   org-export-odt-org-styles-alist))))
-     (cdr (assoc entity (cdr (assoc category
-                                   org-export-odt-default-org-styles-alist))))
-     (error "Cannot determine style name for entity %s of type %s"
-           entity category))))
-
-(defcustom org-export-odt-preferred-output-format nil
-  "Automatically post-process to this format after exporting to \"odt\".
-Interactive commands `org-export-as-odt' and
-`org-export-as-odt-and-open' export first to \"odt\" format and
-then use `org-export-odt-convert-process' to convert the
-resulting document to this format.  During customization of this
-variable, the list of valid values are populated based on
-`org-export-odt-convert-capabilities'.
-
-You can set this option on per-file basis using file local
-values.  See Info node `(emacs) File Variables'."
-  :group 'org-export-odt
-  :version "24.1"
-  :type '(choice :convert-widget
-                (lambda (w)
-                  (apply 'widget-convert (widget-type w)
-                         (eval (car (widget-get w :args)))))
-                `((const :tag "None" nil)
-                  ,@(mapcar (lambda (c)
-                              `(const :tag ,c ,c))
-                            (org-lparse-reachable-formats "odt")))))
-;;;###autoload
-(put 'org-export-odt-preferred-output-format 'safe-local-variable 'stringp)
-
-(defmacro org-odt-cleanup-xml-buffers (&rest body)
-  `(let ((org-odt-zip-dir
-         (make-temp-file
-          (format org-export-odt-tmpdir-prefix "odf") t))
-        (--cleanup-xml-buffers
-         (function
-          (lambda nil
-            (let ((xml-files '("mimetype" "META-INF/manifest.xml" "content.xml"
-                               "meta.xml" "styles.xml")))
-              ;; kill all xml buffers
-              (mapc (lambda (file)
-                      (with-current-buffer
-                          (find-file-noselect
-                           (expand-file-name file org-odt-zip-dir) t)
-                        (set-buffer-modified-p nil)
-                        (kill-buffer)))
-                    xml-files))
-            ;; delete temporary directory.
-            (org-delete-directory org-odt-zip-dir t)))))
-     (condition-case err
-        (prog1 (progn ,@body)
-          (funcall --cleanup-xml-buffers))
-       ((quit error)
-       (funcall --cleanup-xml-buffers)
-       (message "OpenDocument export failed: %s"
-                (error-message-string err))))))
-
-;;;###autoload
-(defun org-export-as-odt-and-open (arg)
-  "Export the outline as ODT and immediately open it with a browser.
-If there is an active region, export only the region.
-The prefix ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will become bulleted lists."
-  (interactive "P")
-  (org-odt-cleanup-xml-buffers
-   (org-lparse-and-open
-    (or org-export-odt-preferred-output-format "odt") "odt" arg)))
-
-;;;###autoload
-(defun org-export-as-odt-batch ()
-  "Call the function `org-lparse-batch'.
-This function can be used in batch processing as:
-emacs   --batch
-        --load=$HOME/lib/emacs/org.el
-        --eval \"(setq org-export-headline-levels 2)\"
-        --visit=MyFile --funcall org-export-as-odt-batch"
-  (org-odt-cleanup-xml-buffers (org-lparse-batch "odt")))
-
-;;; org-export-as-odt
-;;;###autoload
-(defun org-export-as-odt (arg &optional hidden ext-plist
-                             to-buffer body-only pub-dir)
-  "Export the outline as a OpenDocumentText file.
-If there is an active region, export only the region.  The prefix
-ARG specifies how many levels of the outline should become
-headlines.  The default is 3.  Lower levels will become bulleted
-lists.  HIDDEN is obsolete and does nothing.
-EXT-PLIST is a property list with external parameters overriding
-org-mode's default settings, but still inferior to file-local
-settings.  When TO-BUFFER is non-nil, create a buffer with that
-name and export to that buffer.  If TO-BUFFER is the symbol
-`string', don't leave any buffer behind but just return the
-resulting XML as a string.  When BODY-ONLY is set, don't produce
-the file header and footer, simply return the content of
-<body>...</body>, without even the body tags themselves.  When
-PUB-DIR is set, use this as the publishing directory."
-  (interactive "P")
-  (org-odt-cleanup-xml-buffers
-   (org-lparse (or org-export-odt-preferred-output-format "odt")
-              "odt" arg hidden ext-plist to-buffer body-only pub-dir)))
-
-(defvar org-odt-entity-control-callbacks-alist
-  `((EXPORT
-     . (org-odt-begin-export org-odt-end-export))
-    (DOCUMENT-CONTENT
-     . (org-odt-begin-document-content org-odt-end-document-content))
-    (DOCUMENT-BODY
-     . (org-odt-begin-document-body org-odt-end-document-body))
-    (TOC
-     . (org-odt-begin-toc org-odt-end-toc))
-    (ENVIRONMENT
-     . (org-odt-begin-environment org-odt-end-environment))
-    (FOOTNOTE-DEFINITION
-     . (org-odt-begin-footnote-definition org-odt-end-footnote-definition))
-    (TABLE
-     . (org-odt-begin-table org-odt-end-table))
-    (TABLE-ROWGROUP
-     . (org-odt-begin-table-rowgroup org-odt-end-table-rowgroup))
-    (LIST
-     . (org-odt-begin-list org-odt-end-list))
-    (LIST-ITEM
-     . (org-odt-begin-list-item org-odt-end-list-item))
-    (OUTLINE
-     . (org-odt-begin-outline org-odt-end-outline))
-    (OUTLINE-TEXT
-     . (org-odt-begin-outline-text org-odt-end-outline-text))
-    (PARAGRAPH
-     . (org-odt-begin-paragraph org-odt-end-paragraph)))
-  "")
-
-(defvar org-odt-entity-format-callbacks-alist
-  `((EXTRA-TARGETS . org-lparse-format-extra-targets)
-    (ORG-TAGS . org-lparse-format-org-tags)
-    (SECTION-NUMBER . org-lparse-format-section-number)
-    (HEADLINE . org-odt-format-headline)
-    (TOC-ENTRY . org-odt-format-toc-entry)
-    (TOC-ITEM . org-odt-format-toc-item)
-    (TAGS . org-odt-format-tags)
-    (SPACES . org-odt-format-spaces)
-    (TABS . org-odt-format-tabs)
-    (LINE-BREAK . org-odt-format-line-break)
-    (FONTIFY . org-odt-format-fontify)
-    (TODO . org-lparse-format-todo)
-    (LINK . org-odt-format-link)
-    (INLINE-IMAGE . org-odt-format-inline-image)
-    (ORG-LINK . org-odt-format-org-link)
-    (HEADING . org-odt-format-heading)
-    (ANCHOR . org-odt-format-anchor)
-    (TABLE . org-lparse-format-table)
-    (TABLE-ROW . org-odt-format-table-row)
-    (TABLE-CELL . org-odt-format-table-cell)
-    (FOOTNOTES-SECTION . ignore)
-    (FOOTNOTE-REFERENCE . org-odt-format-footnote-reference)
-    (HORIZONTAL-LINE . org-odt-format-horizontal-line)
-    (COMMENT . org-odt-format-comment)
-    (LINE . org-odt-format-line)
-    (ORG-ENTITY . org-odt-format-org-entity))
-  "")
-
-;;;_. callbacks
-;;;_. control callbacks
-;;;_ , document body
-(defun org-odt-begin-office-body ()
-  ;; automatic styles
-  (insert-file-contents
-   (or org-export-odt-content-template-file
-       (expand-file-name "OrgOdtContentTemplate.xml"
-                        org-odt-styles-dir)))
-  (goto-char (point-min))
-  (re-search-forward "</office:text>" nil nil)
-  (delete-region (match-beginning 0) (point-max)))
-
-;; Following variable is let bound when `org-do-lparse' is in
-;; progress.  See org-html.el.
-(defvar org-lparse-toc)
-(defun org-odt-format-toc ()
-  (if (not org-lparse-toc) "" (concat  "\n" org-lparse-toc "\n")))
-
-(defun org-odt-format-preamble (opt-plist)
-  (let* ((title (plist-get opt-plist :title))
-        (author (plist-get opt-plist :author))
-        (date (plist-get opt-plist :date))
-        (iso-date (org-odt-format-date date))
-        (date (org-odt-format-date date "%d %b %Y"))
-        (email (plist-get opt-plist :email))
-        ;; switch on or off above vars based on user settings
-        (author (and (plist-get opt-plist :author-info) (or author email)))
-        (email (and (plist-get opt-plist :email-info) email))
-        (date (and (plist-get opt-plist :time-stamp-file) date)))
-    (concat
-     ;; title
-     (when title
-       (concat
-       (org-odt-format-stylized-paragraph
-        'title (org-odt-format-tags
-                '("<text:title>" . "</text:title>") title))
-       ;; separator
-       "<text:p text:style-name=\"OrgTitle\"/>"))
-     (cond
-      ((and author (not email))
-       ;; author only
-       (concat
-       (org-odt-format-stylized-paragraph
-        'subtitle
-        (org-odt-format-tags
-         '("<text:initial-creator>" . "</text:initial-creator>")
-         author))
-       ;; separator
-       "<text:p text:style-name=\"OrgSubtitle\"/>"))
-      ((and author email)
-       ;; author and email
-       (concat
-       (org-odt-format-stylized-paragraph
-        'subtitle
-        (org-odt-format-link
-         (org-odt-format-tags
-          '("<text:initial-creator>" . "</text:initial-creator>")
-          author) (concat "mailto:" email)))
-       ;; separator
-       "<text:p text:style-name=\"OrgSubtitle\"/>")))
-     ;; date
-     (when date
-       (concat
-       (org-odt-format-stylized-paragraph
-        'subtitle
-        (org-odt-format-tags
-         '("<text:date style:data-style-name=\"%s\" text:date-value=\"%s\">"
-           . "</text:date>") date "N75" iso-date))
-       ;; separator
-       "<text:p text:style-name=\"OrgSubtitle\"/>")))))
-
-(defun org-odt-begin-document-body (opt-plist)
-  (org-odt-begin-office-body)
-  (insert (org-odt-format-preamble opt-plist))
-  (setq org-lparse-dyn-first-heading-pos (point)))
-
-(defvar org-lparse-body-only)          ; let bound during org-do-lparse
-(defvar org-lparse-to-buffer)          ; let bound during org-do-lparse
-(defun org-odt-end-document-body (opt-plist)
-  (unless org-lparse-body-only
-    (org-lparse-insert-tag "</office:text>")
-    (org-lparse-insert-tag "</office:body>")))
-
-(defun org-odt-begin-document-content (opt-plist)
-  (ignore))
-
-(defun org-odt-end-document-content ()
-  (org-lparse-insert-tag "</office:document-content>"))
-
-(defun org-odt-begin-outline (level1 snumber title tags
-                                    target extra-targets class)
-  (org-lparse-insert
-   'HEADING (org-lparse-format
-            'HEADLINE title extra-targets tags snumber level1)
-   level1 target))
-
-(defun org-odt-end-outline ()
-  (ignore))
-
-(defun org-odt-begin-outline-text (level1 snumber class)
-  (ignore))
-
-(defun org-odt-end-outline-text ()
-  (ignore))
-
-(defun org-odt-begin-section (style &optional name)
-  (let ((default-name (car (org-odt-add-automatic-style "Section"))))
-    (org-lparse-insert-tag
-     "<text:section text:style-name=\"%s\" text:name=\"%s\">"
-     style (or name default-name))))
-
-(defun org-odt-end-section ()
-  (org-lparse-insert-tag "</text:section>"))
-
-(defun org-odt-begin-paragraph (&optional style)
-  (org-lparse-insert-tag
-   "<text:p%s>" (org-odt-get-extra-attrs-for-paragraph-style style)))
-
-(defun org-odt-end-paragraph ()
-  (org-lparse-insert-tag "</text:p>"))
-
-(defun org-odt-get-extra-attrs-for-paragraph-style (style)
-  (let (style-name)
-    (setq style-name
-         (cond
-          ((stringp style) style)
-          ((symbolp style) (org-odt-get-style-name-for-entity
-                            'paragraph style))))
-    (unless style-name
-      (error "Don't know how to handle paragraph style %s" style))
-    (format " text:style-name=\"%s\"" style-name)))
-
-(defun org-odt-format-stylized-paragraph (style text)
-  (org-odt-format-tags
-   '("<text:p%s>" . "</text:p>") text
-   (org-odt-get-extra-attrs-for-paragraph-style style)))
-
-(defvar org-lparse-opt-plist)              ; bound during org-do-lparse
-(defun org-odt-format-author (&optional author)
-  (when (setq author (or author (plist-get org-lparse-opt-plist :author)))
-    (org-odt-format-tags '("<dc:creator>" . "</dc:creator>") author)))
-
-(defun org-odt-format-date (&optional org-ts fmt)
-  (save-match-data
-    (let* ((time
-           (and (stringp org-ts)
-                (string-match org-ts-regexp0 org-ts)
-                (apply 'encode-time
-                       (org-fix-decoded-time
-                        (org-parse-time-string (match-string 0 org-ts) t)))))
-          date)
-      (cond
-       (fmt (format-time-string fmt time))
-       (t (setq date (format-time-string "%Y-%m-%dT%H:%M:%S%z" time))
-         (format "%s:%s" (substring date 0 -2) (substring date -2)))))))
-
-(defun org-odt-begin-annotation (&optional author date)
-  (org-lparse-insert-tag "<office:annotation>")
-  (when (setq author (org-odt-format-author author))
-    (insert author))
-  (insert (org-odt-format-tags
-          '("<dc:date>" . "</dc:date>")
-          (org-odt-format-date
-           (or date (plist-get org-lparse-opt-plist :date)))))
-  (org-lparse-begin-paragraph))
-
-(defun org-odt-end-annotation ()
-  (org-lparse-insert-tag  "</office:annotation>"))
-
-(defun org-odt-begin-environment (style env-options-plist)
-  (case style
-    (annotation
-     (org-lparse-stash-save-paragraph-state)
-     (org-odt-begin-annotation (plist-get env-options-plist 'author)
-                              (plist-get env-options-plist 'date)))
-    ((blockquote verse center quote)
-     (org-lparse-begin-paragraph style)
-     (list))
-    ((fixedwidth native)
-     (org-lparse-end-paragraph)
-     (list))
-    (t (error "Unknown environment %s" style))))
-
-(defun org-odt-end-environment (style env-options-plist)
-  (case style
-    (annotation
-     (org-lparse-end-paragraph)
-     (org-odt-end-annotation)
-     (org-lparse-stash-pop-paragraph-state))
-    ((blockquote verse center quote)
-     (org-lparse-end-paragraph)
-     (list))
-    ((fixedwidth native)
-     (org-lparse-begin-paragraph)
-     (list))
-    (t (error "Unknown environment %s" style))))
-
-(defvar org-lparse-list-stack) ; dynamically bound in org-do-lparse
-(defvar org-odt-list-stack-stashed)
-(defun org-odt-begin-list (ltype)
-  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
-                 ltype))
-  (let* ((style-name (org-odt-get-style-name-for-entity 'list ltype))
-        (extra (concat (if (or org-lparse-list-table-p
-                               (and (= 1 (length org-lparse-list-stack))
-                                    (null org-odt-list-stack-stashed)))
-                           " text:continue-numbering=\"false\""
-                         " text:continue-numbering=\"true\"")
-                       (when style-name
-                         (format " text:style-name=\"%s\""  style-name)))))
-    (case ltype
-      ((ordered unordered description)
-       (org-lparse-end-paragraph)
-       (org-lparse-insert-tag "<text:list%s>" extra))
-      (t (error "Unknown list type: %s"  ltype)))))
-
-(defun org-odt-end-list (ltype)
-  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
-                 ltype))
-  (if ltype
-      (org-lparse-insert-tag "</text:list>")
-    (error "Unknown list type: %s" ltype)))
-
-(defun org-odt-begin-list-item (ltype &optional arg headline)
-  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
-                 ltype))
-  (case ltype
-    (ordered
-     (assert (not headline) t)
-     (let* ((counter arg) (extra ""))
-       (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
-                                    (length org-odt-list-stack-stashed))
-                                 "<text:list-header>" "<text:list-item>"))
-       (org-lparse-begin-paragraph)))
-    (unordered
-     (let* ((id arg) (extra ""))
-       (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
-                                    (length org-odt-list-stack-stashed))
-                                 "<text:list-header>" "<text:list-item>"))
-       (org-lparse-begin-paragraph)
-       (insert (if headline (org-odt-format-target headline id)
-                (org-odt-format-bookmark "" id)))))
-    (description
-     (assert (not headline) t)
-     (let ((term (or arg "(no term)")))
-       (insert
-       (org-odt-format-tags
-        '("<text:list-item>" . "</text:list-item>")
-        (org-odt-format-stylized-paragraph 'definition-term term)))
-       (org-lparse-begin-list-item 'unordered)
-       (org-lparse-begin-list 'description)
-       (org-lparse-begin-list-item 'unordered)))
-    (t (error "Unknown list type"))))
-
-(defun org-odt-end-list-item (ltype)
-  (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
-                 ltype))
-  (case ltype
-    ((ordered unordered)
-     (org-lparse-insert-tag (if (= (length org-lparse-list-stack)
-                                  (length org-odt-list-stack-stashed))
-                               (prog1 "</text:list-header>"
-                                 (setq org-odt-list-stack-stashed nil))
-                             "</text:list-item>")))
-    (description
-     (org-lparse-end-list-item-1)
-     (org-lparse-end-list 'description)
-     (org-lparse-end-list-item-1))
-    (t (error "Unknown list type"))))
-
-(defun org-odt-discontinue-list ()
-  (let ((stashed-stack org-lparse-list-stack))
-    (loop for list-type in stashed-stack
-         do (org-lparse-end-list-item-1 list-type)
-         (org-lparse-end-list list-type))
-    (setq org-odt-list-stack-stashed stashed-stack)))
-
-(defun org-odt-continue-list ()
-  (setq org-odt-list-stack-stashed (nreverse org-odt-list-stack-stashed))
-  (loop for list-type in org-odt-list-stack-stashed
-       do (org-lparse-begin-list list-type)
-       (org-lparse-begin-list-item list-type)))
-
-;; Following variables are let bound when table emission is in
-;; progress.  See org-lparse.el.
-(defvar org-lparse-table-begin-marker)
-(defvar org-lparse-table-ncols)
-(defvar org-lparse-table-rowgrp-open)
-(defvar org-lparse-table-rownum)
-(defvar org-lparse-table-cur-rowgrp-is-hdr)
-(defvar org-lparse-table-is-styled)
-(defvar org-lparse-table-rowgrp-info)
-(defvar org-lparse-table-colalign-vector)
-
-(defvar org-odt-table-style nil
-  "Table style specified by \"#+ATTR_ODT: <style-name>\" line.
-This is set during `org-odt-begin-table'.")
-
-(defvar org-odt-table-style-spec nil
-  "Entry for `org-odt-table-style' in `org-export-odt-table-styles'.")
-
-(defcustom org-export-odt-table-styles
-  '(("OrgEquation" "OrgEquation"
-     ((use-first-column-styles . t)
-      (use-last-column-styles . t))))
-  "Specify how Table Styles should be derived from a Table Template.
-This is a list where each element is of the
-form (TABLE-STYLE-NAME TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS).
-
-TABLE-STYLE-NAME is the style associated with the table through
-`org-odt-table-style'.
-
-TABLE-TEMPLATE-NAME is a set of - upto 9 - automatic
-TABLE-CELL-STYLE-NAMEs and PARAGRAPH-STYLE-NAMEs (as defined
-below) that is included in
-`org-export-odt-content-template-file'.
-
-TABLE-CELL-STYLE-NAME := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
-                         \"TableCell\"
-PARAGRAPH-STYLE-NAME  := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
-                         \"TableParagraph\"
-TABLE-CELL-TYPE       := \"FirstRow\"   | \"LastColumn\" |
-                         \"FirstRow\"   | \"LastRow\"    |
-                         \"EvenRow\"    | \"OddRow\"     |
-                         \"EvenColumn\" | \"OddColumn\"  | \"\"
-where \"+\" above denotes string concatenation.
-
-TABLE-CELL-OPTIONS is an alist where each element is of the
-form (TABLE-CELL-STYLE-SELECTOR . ON-OR-OFF).
-TABLE-CELL-STYLE-SELECTOR := `use-first-row-styles'       |
-                             `use-last-row-styles'        |
-                             `use-first-column-styles'    |
-                             `use-last-column-styles'     |
-                             `use-banding-rows-styles'    |
-                             `use-banding-columns-styles' |
-                             `use-first-row-styles'
-ON-OR-OFF                 := `t' | `nil'
-
-For example, with the following configuration
-
-\(setq org-export-odt-table-styles
-      '\(\(\"TableWithHeaderRowsAndColumns\" \"Custom\"
-         \(\(use-first-row-styles . t\)
-          \(use-first-column-styles . t\)\)\)
-        \(\"TableWithHeaderColumns\" \"Custom\"
-         \(\(use-first-column-styles . t\)\)\)\)\)
-
-1. A table associated with \"TableWithHeaderRowsAndColumns\"
-   style will use the following table-cell styles -
-   \"CustomFirstRowTableCell\", \"CustomFirstColumnTableCell\",
-   \"CustomTableCell\" and the following paragraph styles
-   \"CustomFirstRowTableParagraph\",
-   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
-   as appropriate.
-
-2. A table associated with \"TableWithHeaderColumns\" style will
-   use the following table-cell styles -
-   \"CustomFirstColumnTableCell\", \"CustomTableCell\" and the
-   following paragraph styles
-   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
-   as appropriate..
-
-Note that TABLE-TEMPLATE-NAME corresponds to the
-\"<table:table-template>\" elements contained within
-\"<office:styles>\".  The entries (TABLE-STYLE-NAME
-TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS) correspond to
-\"table:template-name\" and \"table:use-first-row-styles\" etc
-attributes of \"<table:table>\" element.  Refer ODF-1.2
-specification for more information.  Also consult the
-implementation filed under `org-odt-get-table-cell-styles'.
-
-The TABLE-STYLE-NAME \"OrgEquation\" is used internally for
-formatting of numbered display equations.  Do not delete this
-style from the list."
-  :group 'org-export-odt
-  :version "24.1"
-  :type '(choice
-          (const :tag "None" nil)
-          (repeat :tag "Table Styles"
-                  (list :tag "Table Style Specification"
-                       (string :tag "Table Style Name")
-                       (string  :tag "Table Template Name")
-                       (alist :options (use-first-row-styles
-                                        use-last-row-styles
-                                        use-first-column-styles
-                                        use-last-column-styles
-                                        use-banding-rows-styles
-                                        use-banding-columns-styles)
-                              :key-type symbol
-                              :value-type (const :tag "True" t))))))
-
-(defvar org-odt-table-style-format
-  "
-<style:style style:name=\"%s\" style:family=\"table\">
-  <style:table-properties style:rel-width=\"%d%%\" fo:margin-top=\"0cm\" fo:margin-bottom=\"0.20cm\" table:align=\"center\"/>
-</style:style>
-"
-  "Template for auto-generated Table styles.")
-
-(defvar org-odt-automatic-styles '()
-  "Registry of automatic styles for various OBJECT-TYPEs.
-The variable has the following form:
-\(\(OBJECT-TYPE-A
-  \(\(OBJECT-NAME-A.1 OBJECT-PROPS-A.1\)
-   \(OBJECT-NAME-A.2 OBJECT-PROPS-A.2\) ...\)\)
- \(OBJECT-TYPE-B
-  \(\(OBJECT-NAME-B.1 OBJECT-PROPS-B.1\)
-   \(OBJECT-NAME-B.2 OBJECT-PROPS-B.2\) ...\)\)
- ...\).
-
-OBJECT-TYPEs could be \"Section\", \"Table\", \"Figure\" etc.
-OBJECT-PROPS is (typically) a plist created by passing
-\"#+ATTR_ODT: \" option to `org-lparse-get-block-params'.
-
-Use `org-odt-add-automatic-style' to add update this variable.'")
-
-(defvar org-odt-object-counters nil
-  "Running counters for various OBJECT-TYPEs.
-Use this to generate automatic names and style-names.  See
-`org-odt-add-automatic-style'.")
-
-(defun org-odt-write-automatic-styles ()
-  "Write automatic styles to \"content.xml\"."
-  (with-current-buffer
-      (find-file-noselect (expand-file-name "content.xml") t)
-    ;; position the cursor
-    (goto-char (point-min))
-    (re-search-forward "  </office:automatic-styles>" nil t)
-    (goto-char (match-beginning 0))
-    ;; write automatic table styles
-    (loop for (style-name props) in
-         (plist-get org-odt-automatic-styles 'Table) do
-         (when (setq props (or (plist-get props :rel-width) 96))
-           (insert (format org-odt-table-style-format style-name props))))))
-
-(defun org-odt-add-automatic-style (object-type &optional object-props)
-  "Create an automatic style of type OBJECT-TYPE with param OBJECT-PROPS.
-OBJECT-PROPS is (typically) a plist created by passing
-\"#+ATTR_ODT: \" option of the object in question to
-`org-lparse-get-block-params'.
-
-Use `org-odt-object-counters' to generate an automatic
-OBJECT-NAME and STYLE-NAME.  If OBJECT-PROPS is non-nil, add a
-new entry in `org-odt-automatic-styles'.  Return (OBJECT-NAME
-. STYLE-NAME)."
-  (assert (stringp object-type))
-  (let* ((object (intern object-type))
-        (seqvar object)
-        (seqno (1+ (or (plist-get org-odt-object-counters seqvar) 0)))
-        (object-name (format "%s%d" object-type seqno)) style-name)
-    (setq org-odt-object-counters
-         (plist-put org-odt-object-counters seqvar seqno))
-    (when object-props
-      (setq style-name (format "Org%s" object-name))
-      (setq org-odt-automatic-styles
-           (plist-put org-odt-automatic-styles object
-                      (append (list (list style-name object-props))
-                              (plist-get org-odt-automatic-styles object)))))
-    (cons object-name style-name)))
-
-(defvar org-odt-table-indentedp nil)
-(defun org-odt-begin-table (caption label attributes short-caption)
-  (setq org-odt-table-indentedp (not (null org-lparse-list-stack)))
-  (when org-odt-table-indentedp
-    ;; Within the Org file, the table is appearing within a list item.
-    ;; OpenDocument doesn't allow table to appear within list items.
-    ;; Temporarily terminate the list, emit the table and then
-    ;; re-continue the list.
-    (org-odt-discontinue-list)
-    ;; Put the Table in an indented section.
-    (let ((level (length org-odt-list-stack-stashed)))
-      (org-odt-begin-section (format "OrgIndentedSection-Level-%d" level))))
-  (setq attributes (org-lparse-get-block-params attributes))
-  (setq org-odt-table-style (plist-get attributes :style))
-  (setq org-odt-table-style-spec
-       (assoc org-odt-table-style org-export-odt-table-styles))
-  (when (or label caption)
-    (insert
-     (org-odt-format-stylized-paragraph
-      'table (org-odt-format-entity-caption label caption "__Table__"))))
-  (let ((automatic-name (org-odt-add-automatic-style "Table" attributes)))
-    (org-lparse-insert-tag
-     "<table:table table:name=\"%s\" table:style-name=\"%s\">"
-     (or short-caption (car automatic-name))
-     (or (nth 1 org-odt-table-style-spec)
-        (cdr automatic-name) "OrgTable")))
-  (setq org-lparse-table-begin-marker (point)))
-
-(defvar org-lparse-table-colalign-info)
-(defun org-odt-end-table ()
-  (goto-char org-lparse-table-begin-marker)
-  (loop for level from 0 below org-lparse-table-ncols
-       do (let* ((col-cookie (and org-lparse-table-is-styled
-                                  (cdr (assoc (1+ level)
-                                              org-lparse-table-colalign-info))))
-                 (extra-columns (or (nth 1 col-cookie) 0)))
-            (dotimes (i (1+ extra-columns))
-              (insert
-               (org-odt-format-tags
-                "<table:table-column table:style-name=\"%sColumn\"/>"
-                "" (or (nth 1 org-odt-table-style-spec) "OrgTable"))))
-            (insert "\n")))
-  ;; fill style attributes for table cells
-  (when org-lparse-table-is-styled
-    (while (re-search-forward "@@\\(table-cell:p\\|table-cell:style-name\\)@@\\([0-9]+\\)@@\\([0-9]+\\)@@" nil t)
-      (let* ((spec (match-string 1))
-            (r (string-to-number (match-string 2)))
-            (c (string-to-number (match-string 3)))
-            (cell-styles (org-odt-get-table-cell-styles
-                          r c org-odt-table-style-spec))
-            (table-cell-style (car cell-styles))
-            (table-cell-paragraph-style (cdr cell-styles)))
-       (cond
-        ((equal spec "table-cell:p")
-         (replace-match table-cell-paragraph-style t t))
-        ((equal spec "table-cell:style-name")
-         (replace-match table-cell-style t t))))))
-  (goto-char (point-max))
-  (org-lparse-insert-tag "</table:table>")
-  (when org-odt-table-indentedp
-    (org-odt-end-section)
-    (org-odt-continue-list)))
-
-(defun org-odt-begin-table-rowgroup (&optional is-header-row)
-  (when org-lparse-table-rowgrp-open
-    (org-lparse-end 'TABLE-ROWGROUP))
-  (org-lparse-insert-tag (if is-header-row
-                            "<table:table-header-rows>"
-                          "<table:table-rows>"))
-  (setq org-lparse-table-rowgrp-open t)
-  (setq org-lparse-table-cur-rowgrp-is-hdr is-header-row))
-
-(defun org-odt-end-table-rowgroup ()
-  (when org-lparse-table-rowgrp-open
-    (setq org-lparse-table-rowgrp-open nil)
-    (org-lparse-insert-tag
-     (if org-lparse-table-cur-rowgrp-is-hdr
-        "</table:table-header-rows>" "</table:table-rows>"))))
-
-(defun org-odt-format-table-row (row)
-  (org-odt-format-tags
-   '("<table:table-row>" . "</table:table-row>") row))
-
-(defun org-odt-get-table-cell-styles (r c &optional style-spec)
-  "Retrieve styles applicable to a table cell.
-R and C are (zero-based) row and column numbers of the table
-cell.  STYLE-SPEC is an entry in `org-export-odt-table-styles'
-applicable to the current table.  It is `nil' if the table is not
-associated with any style attributes.
-
-Return a cons of (TABLE-CELL-STYLE-NAME . PARAGRAPH-STYLE-NAME).
-
-When STYLE-SPEC is nil, style the table cell the conventional way
-- choose cell borders based on row and column groupings and
-choose paragraph alignment based on `org-col-cookies' text
-property.  See also
-`org-odt-get-paragraph-style-cookie-for-table-cell'.
-
-When STYLE-SPEC is non-nil, ignore the above cookie and return
-styles congruent with the ODF-1.2 specification."
-  (cond
-   (style-spec
-
-    ;; LibreOffice - particularly the Writer - honors neither table
-    ;; templates nor custom table-cell styles.  Inorder to retain
-    ;; inter-operability with LibreOffice, only automatic styles are
-    ;; used for styling of table-cells.  The current implementation is
-    ;; congruent with ODF-1.2 specification and hence is
-    ;; future-compatible.
-
-    ;; Additional Note: LibreOffice's AutoFormat facility for tables -
-    ;; which recognizes as many as 16 different cell types - is much
-    ;; richer.  Unfortunately it is NOT amenable to easy configuration
-    ;; by hand.
-
-    (let* ((template-name (nth 1 style-spec))
-          (cell-style-selectors (nth 2 style-spec))
-          (cell-type
-           (cond
-            ((and (cdr (assoc 'use-first-column-styles cell-style-selectors))
-                  (= c 0)) "FirstColumn")
-            ((and (cdr (assoc 'use-last-column-styles cell-style-selectors))
-                  (= c (1- org-lparse-table-ncols))) "LastColumn")
-            ((and (cdr (assoc 'use-first-row-styles cell-style-selectors))
-                  (= r 0)) "FirstRow")
-            ((and (cdr (assoc 'use-last-row-styles cell-style-selectors))
-                  (= r org-lparse-table-rownum))
-             "LastRow")
-            ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
-                  (= (% r 2) 1)) "EvenRow")
-            ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
-                  (= (% r 2) 0)) "OddRow")
-            ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
-                  (= (% c 2) 1)) "EvenColumn")
-            ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
-                  (= (% c 2) 0)) "OddColumn")
-            (t ""))))
-      (cons
-       (concat template-name cell-type "TableCell")
-       (concat template-name cell-type "TableParagraph"))))
-   (t
-    (cons
-     (concat
-      "OrgTblCell"
-      (cond
-       ((= r 0) "T")
-       ((eq (cdr (assoc r org-lparse-table-rowgrp-info))  :start) "T")
-       (t ""))
-      (when (= r org-lparse-table-rownum) "B")
-      (cond
-       ((= c 0) "")
-       ((or (memq (nth c org-table-colgroup-info) '(:start :startend))
-           (memq (nth (1- c) org-table-colgroup-info) '(:end :startend))) "L")
-       (t "")))
-     (capitalize (aref org-lparse-table-colalign-vector c))))))
-
-(defun org-odt-get-paragraph-style-cookie-for-table-cell (r c)
-  (concat
-   (and (not org-odt-table-style-spec)
-       (cond
-        (org-lparse-table-cur-rowgrp-is-hdr "OrgTableHeading")
-        ((and (= c 0) (org-lparse-get 'TABLE-FIRST-COLUMN-AS-LABELS))
-         "OrgTableHeading")
-        (t "OrgTableContents")))
-   (and org-lparse-table-is-styled
-       (format "@@table-cell:p@@%03d@@%03d@@" r c))))
-
-(defun org-odt-get-style-name-cookie-for-table-cell (r c)
-  (when org-lparse-table-is-styled
-    (format "@@table-cell:style-name@@%03d@@%03d@@" r c)))
-
-(defun org-odt-format-table-cell (data r c horiz-span)
-  (concat
-   (let* ((paragraph-style-cookie
-          (org-odt-get-paragraph-style-cookie-for-table-cell r c))
-         (style-name-cookie
-          (org-odt-get-style-name-cookie-for-table-cell r c))
-         (extra (and style-name-cookie
-                     (format " table:style-name=\"%s\""  style-name-cookie)))
-         (extra (concat extra
-                        (and (> horiz-span 0)
-                             (format " table:number-columns-spanned=\"%d\""
-                                     (1+ horiz-span))))))
-     (org-odt-format-tags
-      '("<table:table-cell%s>" . "</table:table-cell>")
-      (if org-lparse-list-table-p data
-       (org-odt-format-stylized-paragraph paragraph-style-cookie data)) extra))
-   (let (s)
-     (dotimes (i horiz-span)
-       (setq s (concat s "\n<table:covered-table-cell/>"))) s)
-   "\n"))
-
-(defun org-odt-begin-footnote-definition (n)
-  (org-lparse-begin-paragraph 'footnote))
-
-(defun org-odt-end-footnote-definition (n)
-  (org-lparse-end-paragraph))
-
-(defun org-odt-begin-toc (lang-specific-heading max-level)
-  ;; Strings in `org-export-language-setup' can contain named html
-  ;; entities.  Replace those with utf-8 equivalents.
-  (let ((i 0) entity rpl)
-    (while (string-match "&\\([^#].*?\\);" lang-specific-heading i)
-      (setq entity (match-string 1 lang-specific-heading))
-      (if (not (setq rpl (org-entity-get-representation entity 'utf8)))
-         (setq i (match-end 0))
-       (setq i (+ (match-beginning 0) (length rpl)))
-       (setq lang-specific-heading
-             (replace-match rpl t t lang-specific-heading)))))
-  (insert
-   (format "
-    <text:table-of-content text:style-name=\"Sect2\" text:protected=\"true\" text:name=\"Table of Contents1\">
-     <text:table-of-content-source text:outline-level=\"%d\">
-      <text:index-title-template text:style-name=\"Contents_20_Heading\">%s</text:index-title-template>
-" max-level lang-specific-heading))
-  (loop for level from 1 upto 10
-       do (insert (format
-                   "
-      <text:table-of-content-entry-template text:outline-level=\"%d\" text:style-name=\"Contents_20_%d\">
-       <text:index-entry-link-start text:style-name=\"Internet_20_link\"/>
-       <text:index-entry-chapter/>
-       <text:index-entry-text/>
-       <text:index-entry-link-end/>
-      </text:table-of-content-entry-template>
-" level level)))
-
-  (insert
-   (format  "
-     </text:table-of-content-source>
-
-     <text:index-body>
-      <text:index-title text:style-name=\"Sect1\" text:name=\"Table of Contents1_Head\">
-       <text:p text:style-name=\"Contents_20_Heading\">%s</text:p>
-      </text:index-title>
-" lang-specific-heading)))
-
-(defun org-odt-end-toc ()
-  (insert "
-     </text:index-body>
-    </text:table-of-content>
-"))
-
-(defun org-odt-format-toc-entry (snumber todo headline tags href)
-  (setq headline (concat
-                 (and org-export-with-section-numbers
-                      (concat snumber ". "))
-                 headline
-                 (and tags
-                      (concat
-                       (org-lparse-format 'SPACES 3)
-                       (org-lparse-format 'FONTIFY tags "tag")))))
-  (when todo
-    (setq headline (org-lparse-format 'FONTIFY headline "todo")))
-
-  (let ((org-odt-suppress-xref t))
-    (org-odt-format-link headline (concat  "#" href))))
-
-(defun org-odt-format-toc-item (toc-entry level org-last-level)
-  (let ((style (format "Contents_20_%d"
-                      (+ level (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1) -1))))
-    (insert "\n" (org-odt-format-stylized-paragraph style toc-entry) "\n")))
-
-;; Following variable is let bound during 'ORG-LINK callback.  See
-;; org-html.el
-(defvar org-lparse-link-description-is-image nil)
-(defun org-odt-format-link (desc href &optional attr)
-  (cond
-   ((and (= (string-to-char href) ?#) (not org-odt-suppress-xref))
-    (setq href (substring href 1))
-    (let ((xref-format "text"))
-      (when (numberp desc)
-       (setq desc (format "%d" desc) xref-format "number"))
-      (when (listp desc)
-       (setq desc (mapconcat 'identity desc ".") xref-format "chapter"))
-      (setq href (concat org-export-odt-bookmark-prefix href))
-      (org-odt-format-tags
-       '("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
-        "</text:bookmark-ref>")
-       desc xref-format href)))
-   (org-lparse-link-description-is-image
-    (org-odt-format-tags
-     '("<draw:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</draw:a>")
-     desc href (or attr "")))
-   (t
-    (org-odt-format-tags
-     '("<text:a xlink:type=\"simple\" xlink:href=\"%s\" %s>" . "</text:a>")
-     desc href (or attr "")))))
-
-(defun org-odt-format-spaces (n)
-  (cond
-   ((= n 1) " ")
-   ((> n 1) (concat
-            " " (org-odt-format-tags "<text:s text:c=\"%d\"/>" "" (1- n))))
-   (t "")))
-
-(defun org-odt-format-tabs (&optional n)
-  (let ((tab "<text:tab/>")
-       (n (or n 1)))
-    (insert tab)))
-
-(defun org-odt-format-line-break ()
-  (org-odt-format-tags "<text:line-break/>" ""))
-
-(defun org-odt-format-horizontal-line ()
-  (org-odt-format-stylized-paragraph 'horizontal-line ""))
-
-(defun org-odt-encode-plain-text (line &optional no-whitespace-filling)
-  (setq line (org-xml-encode-plain-text line))
-  (if no-whitespace-filling line
-    (org-odt-fill-tabs-and-spaces line)))
-
-(defun org-odt-format-line (line)
-  (case org-lparse-dyn-current-environment
-    (fixedwidth (concat
-                (org-odt-format-stylized-paragraph
-                 'fixedwidth (org-odt-encode-plain-text line)) "\n"))
-    (t (concat line "\n"))))
-
-(defun org-odt-format-comment (fmt &rest args)
-  (let ((comment (apply 'format fmt args)))
-    (format "\n<!-- %s  -->\n" comment)))
-
-(defun org-odt-format-org-entity (wd)
-  (org-entity-get-representation wd 'utf8))
-
-(defun org-odt-fill-tabs-and-spaces (line)
-  (replace-regexp-in-string
-   "\\([\t]\\|\\([ ]+\\)\\)" (lambda (s)
-                              (cond
-                               ((string= s "\t") (org-odt-format-tabs))
-                               (t (org-odt-format-spaces (length s))))) line))
-
-(defcustom org-export-odt-fontify-srcblocks t
-  "Specify whether or not source blocks need to be fontified.
-Turn this option on if you want to colorize the source code
-blocks in the exported file.  For colorization to work, you need
-to make available an enhanced version of `htmlfontify' library."
-  :type 'boolean
-  :group 'org-export-odt
-  :version "24.1")
-
-(defun org-odt-format-source-line-with-line-number-and-label
-  (line rpllbl num fontifier par-style)
-
-  (let ((keep-label (not (numberp rpllbl)))
-       (ref (org-find-text-property-in-string 'org-coderef line)))
-    (setq line (concat line (and keep-label ref (format "(%s)" ref))))
-    (setq line (funcall fontifier line))
-    (when ref
-      (setq line (org-odt-format-target line (concat "coderef-" ref))))
-    (setq line (org-odt-format-stylized-paragraph par-style line))
-    (if (not num) line
-      (org-odt-format-tags '("<text:list-item>" . "</text:list-item>") line))))
-
-(defun org-odt-format-source-code-or-example-plain
-  (lines lang caption textareap cols rows num cont rpllbl fmt)
-  "Format source or example blocks much like fixedwidth blocks.
-Use this when `org-export-odt-fontify-srcblocks' option is turned
-off."
-  (let* ((lines (org-split-string lines "[\r\n]"))
-        (line-count (length lines))
-        (i 0))
-    (mapconcat
-     (lambda (line)
-       (incf i)
-       (org-odt-format-source-line-with-line-number-and-label
-       line rpllbl num 'org-odt-encode-plain-text
-       (if (= i line-count) "OrgFixedWidthBlockLastLine"
-         "OrgFixedWidthBlock")))
-     lines "\n")))
-
-(defvar org-src-block-paragraph-format
-  "<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
-   <style:paragraph-properties fo:background-color=\"%s\" fo:padding=\"0.049cm\" fo:border=\"0.51pt solid #000000\" style:shadow=\"none\">
-    <style:background-image/>
-   </style:paragraph-properties>
-   <style:text-properties fo:color=\"%s\"/>
-  </style:style>"
-  "Custom paragraph style for colorized source and example blocks.
-This style is much the same as that of \"OrgFixedWidthBlock\"
-except that the foreground and background colors are set
-according to the default face identified by the `htmlfontify'.")
-
-(defvar hfy-optimisations)
-(declare-function hfy-face-to-style "htmlfontify" (fn))
-(declare-function hfy-face-or-def-to-name "htmlfontify" (fn))
-
-(defun org-odt-hfy-face-to-css (fn)
-  "Create custom style for face FN.
-When FN is the default face, use it's foreground and background
-properties to create \"OrgSrcBlock\" paragraph style.  Otherwise
-use it's color attribute to create a character style whose name
-is obtained from FN.  Currently all attributes of FN other than
-color are ignored.
-
-The style name for a face FN is derived using the following
-operations on the face name in that order - de-dash, CamelCase
-and prefix with \"OrgSrc\".  For example,
-`font-lock-function-name-face' is associated with
-\"OrgSrcFontLockFunctionNameFace\"."
-  (let* ((css-list (hfy-face-to-style fn))
-        (style-name ((lambda (fn)
-                       (concat "OrgSrc"
-                               (mapconcat
-                                'capitalize (split-string
-                                             (hfy-face-or-def-to-name fn) "-")
-                                ""))) fn))
-        (color-val (cdr (assoc "color" css-list)))
-        (background-color-val (cdr (assoc "background" css-list)))
-        (style (and org-export-odt-create-custom-styles-for-srcblocks
-                    (cond
-                     ((eq fn 'default)
-                      (format org-src-block-paragraph-format
-                              background-color-val color-val))
-                     (t
-                      (format
-                       "
-<style:style style:name=\"%s\" style:family=\"text\">
-  <style:text-properties fo:color=\"%s\"/>
- </style:style>" style-name color-val))))))
-    (cons style-name style)))
-
-(defun org-odt-insert-custom-styles-for-srcblocks (styles)
-  "Save STYLES used for colorizing of source blocks.
-Update styles.xml with styles that were collected as part of
-`org-odt-hfy-face-to-css' callbacks."
-  (when styles
-    (with-current-buffer
-       (find-file-noselect (expand-file-name "styles.xml") t)
-      (goto-char (point-min))
-      (when (re-search-forward "</office:styles>" nil t)
-       (goto-char (match-beginning 0))
-       (insert "\n<!-- Org Htmlfontify Styles -->\n" styles "\n")))))
-
-(defun org-odt-format-source-code-or-example-colored
-  (lines lang caption textareap cols rows num cont rpllbl fmt)
-  "Format source or example blocks using `htmlfontify-string'.
-Use this routine when `org-export-odt-fontify-srcblocks' option
-is turned on."
-  (let* ((lang-m (and lang (or (cdr (assoc lang org-src-lang-modes)) lang)))
-        (mode (and lang-m (intern (concat (if (symbolp lang-m)
-                                              (symbol-name lang-m)
-                                            lang-m) "-mode"))))
-        (org-inhibit-startup t)
-        (org-startup-folded nil)
-        (lines (with-temp-buffer
-                 (insert lines)
-                 (if (functionp mode) (funcall mode) (fundamental-mode))
-                 (font-lock-fontify-buffer)
-                 (buffer-string)))
-        (hfy-html-quote-regex "\\([<\"&>       ]\\)")
-        (hfy-html-quote-map '(("\"" "&quot;")
-                              ("<" "&lt;")
-                              ("&" "&amp;")
-                              (">" "&gt;")
-                              (" " "<text:s/>")
-                              ("       " "<text:tab/>")))
-        (hfy-face-to-css 'org-odt-hfy-face-to-css)
-        (hfy-optimisations-1 (copy-sequence hfy-optimisations))
-        (hfy-optimisations (add-to-list 'hfy-optimisations-1
-                                        'body-text-only))
-        (hfy-begin-span-handler
-         (lambda (style text-block text-id text-begins-block-p)
-           (insert (format "<text:span text:style-name=\"%s\">" style))))
-        (hfy-end-span-handler (lambda nil (insert "</text:span>"))))
-    (when (fboundp 'htmlfontify-string)
-      (let* ((lines (org-split-string lines "[\r\n]"))
-            (line-count (length lines))
-            (i 0))
-       (mapconcat
-        (lambda (line)
-          (incf i)
-          (org-odt-format-source-line-with-line-number-and-label
-           line rpllbl num 'htmlfontify-string
-           (if (= i line-count) "OrgSrcBlockLastLine" "OrgSrcBlock")))
-        lines "\n")))))
-
-(defun org-odt-format-source-code-or-example (lines lang caption textareap
-                                                   cols rows num cont
-                                                   rpllbl fmt)
-  "Format source or example blocks for export.
-Use `org-odt-format-source-code-or-example-plain' or
-`org-odt-format-source-code-or-example-colored' depending on the
-value of `org-export-odt-fontify-srcblocks."
-  (setq lines (org-export-number-lines
-              lines 0 0 num cont rpllbl fmt 'preprocess)
-       lines (funcall
-              (or (and org-export-odt-fontify-srcblocks
-                       (or (featurep 'htmlfontify)
-                           ;; htmlfontify.el was introduced in Emacs 23.2
-                           ;; So load it with some caution
-                           (require 'htmlfontify nil t))
-                       (fboundp 'htmlfontify-string)
-                       'org-odt-format-source-code-or-example-colored)
-                  'org-odt-format-source-code-or-example-plain)
-              lines lang caption textareap cols rows num cont rpllbl fmt))
-  (if (not num) lines
-    (let ((extra (format " text:continue-numbering=\"%s\""
-                        (if cont "true" "false"))))
-      (org-odt-format-tags
-       '("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
-        . "</text:list>") lines extra))))
-
-(defun org-odt-remap-stylenames (style-name)
-  (or
-   (cdr (assoc style-name '(("timestamp-wrapper" . "OrgTimestampWrapper")
-                           ("timestamp" . "OrgTimestamp")
-                           ("timestamp-kwd" . "OrgTimestampKeyword")
-                           ("tag" . "OrgTag")
-                           ("todo" . "OrgTodo")
-                           ("done" . "OrgDone")
-                           ("target" . "OrgTarget"))))
-   style-name))
-
-(defun org-odt-format-fontify (text style &optional id)
-  (let* ((style-name
-         (cond
-          ((stringp style)
-           (org-odt-remap-stylenames style))
-          ((symbolp style)
-           (org-odt-get-style-name-for-entity 'character style))
-          ((listp style)
-           (assert (< 1 (length style)))
-           (let ((parent-style (pop style)))
-             (mapconcat (lambda (s)
-                          ;; (assert (stringp s) t)
-                          (org-odt-remap-stylenames s)) style "")
-             (org-odt-remap-stylenames parent-style)))
-          (t (error "Don't how to handle style %s"  style)))))
-    (org-odt-format-tags
-     '("<text:span text:style-name=\"%s\">" . "</text:span>")
-     text style-name)))
-
-(defun org-odt-relocate-relative-path (path dir)
-  (if (file-name-absolute-p path) path
-    (file-relative-name (expand-file-name path dir)
-                       (expand-file-name "eyecandy" dir))))
-
-(defun org-odt-format-inline-image (thefile)
-  (let* ((thelink (if (file-name-absolute-p thefile) thefile
-                   (org-xml-format-href
-                    (org-odt-relocate-relative-path
-                     thefile org-current-export-file))))
-        (href
-         (org-odt-format-tags
-          "<draw:image xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" ""
-          (if org-export-odt-embed-images
-              (org-odt-copy-image-file thefile) thelink))))
-    (org-export-odt-format-image thefile href)))
-
-(defvar org-odt-entity-labels-alist nil
-  "Associate Labels with the Labeled entities.
-Each element of the alist is of the form (LABEL-NAME
-CATEGORY-NAME SEQNO LABEL-STYLE-NAME).  LABEL-NAME is same as
-that specified by \"#+LABEL: ...\" line.  CATEGORY-NAME is the
-type of the entity that LABEL-NAME is attached to.  CATEGORY-NAME
-can be one of \"Table\", \"Figure\" or \"Equation\".  SEQNO is
-the unique number assigned to the referenced entity on a
-per-CATEGORY basis.  It is generated sequentially and is 1-based.
-LABEL-STYLE-NAME is a key `org-odt-label-styles'.
-
-See `org-odt-add-label-definition' and
-`org-odt-fixup-label-references'.")
-
-(defun org-export-odt-format-formula (src href)
-  (save-match-data
-    (let* ((caption (org-find-text-property-in-string 'org-caption src))
-          (short-caption
-           (or (org-find-text-property-in-string 'org-caption-shortn src)
-               caption))
-          (caption (and caption (org-xml-format-desc caption)))
-          (short-caption (and short-caption
-                              (org-xml-encode-plain-text short-caption)))
-          (label (org-find-text-property-in-string 'org-label src))
-          (latex-frag (org-find-text-property-in-string 'org-latex-src src))
-          (embed-as (or (and latex-frag
-                             (org-find-text-property-in-string
-                              'org-latex-src-embed-type src))
-                        (if (or caption label) 'paragraph 'character)))
-          width height)
-      (when latex-frag
-       (setq href (org-propertize href :title "LaTeX Fragment"
-                                  :description latex-frag)))
-      (cond
-       ((eq embed-as 'character)
-       (org-odt-format-entity "InlineFormula" href width height))
-       (t
-       (org-lparse-end-paragraph)
-       (org-lparse-insert-list-table
-        `((,(org-odt-format-entity
-             (if (not (or caption label)) "DisplayFormula"
-               "CaptionedDisplayFormula")
-             href width height :caption caption :label label
-             :short-caption short-caption)
-           ,(if (not (or caption label)) ""
-              (let* ((label-props (car org-odt-entity-labels-alist)))
-                (setcar (last label-props) "math-label")
-                (apply 'org-odt-format-label-definition
-                       caption label-props)))))
-        nil nil nil ":style \"OrgEquation\"" nil '((1 "c" 8) (2 "c" 1)))
-       (throw 'nextline nil))))))
-
-(defvar org-odt-embedded-formulas-count 0)
-(defun org-odt-copy-formula-file (path)
-  "Returns the internal name of the file"
-  (let* ((src-file (expand-file-name
-                   path (file-name-directory org-current-export-file)))
-        (target-dir (format "Formula-%04d/"
-                            (incf org-odt-embedded-formulas-count)))
-        (target-file (concat target-dir "content.xml")))
-    (when (not org-lparse-to-buffer)
-      (message "Embedding %s as %s ..."
-              (substring-no-properties path) target-file)
-
-      (make-directory target-dir)
-      (org-odt-create-manifest-file-entry
-       "application/vnd.oasis.opendocument.formula" target-dir "1.2")
-
-      (case (org-odt-is-formula-link-p src-file)
-       (mathml
-        (copy-file src-file target-file 'overwrite))
-       (odf
-        (org-odt-zip-extract-one src-file "content.xml" target-dir))
-       (t
-        (error "%s is not a formula file" src-file)))
-
-      (org-odt-create-manifest-file-entry "text/xml" target-file))
-    target-file))
-
-(defun org-odt-format-inline-formula (thefile)
-  (let* ((thelink (if (file-name-absolute-p thefile) thefile
-                   (org-xml-format-href
-                    (org-odt-relocate-relative-path
-                     thefile org-current-export-file))))
-        (href
-         (org-odt-format-tags
-          "<draw:object xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" ""
-          (file-name-directory (org-odt-copy-formula-file thefile)))))
-    (org-export-odt-format-formula thefile href)))
-
-(defun org-odt-is-formula-link-p (file)
-  (let ((case-fold-search nil))
-    (cond
-     ((string-match "\\.\\(mathml\\|mml\\)\\'" file)
-      'mathml)
-     ((string-match "\\.odf\\'" file)
-      'odf))))
-
-(defun org-odt-format-org-link (opt-plist type-1 path fragment desc attr
-                                         descp)
-  "Make a OpenDocument link.
-OPT-PLIST is an options list.
-TYPE-1 is the device-type of the link (THIS://foo.html).
-PATH is the path of the link (http://THIS#location).
-FRAGMENT is the fragment part of the link, if any (foo.html#THIS).
-DESC is the link description, if any.
-ATTR is a string of other attributes of the a element."
-  (declare (special org-lparse-par-open))
-  (save-match-data
-    (let* ((may-inline-p
-           (and (member type-1 '("http" "https" "file"))
-                (org-lparse-should-inline-p path descp)
-                (not fragment)))
-          (type (if (equal type-1 "id") "file" type-1))
-          (filename path)
-          (thefile path)
-          sec-frag sec-nos)
-      (cond
-       ;; check for inlined images
-       ((and (member type '("file"))
-            (not fragment)
-            (org-file-image-p
-             filename org-export-odt-inline-image-extensions)
-            (or (eq t org-export-odt-inline-images)
-                (and org-export-odt-inline-images (not descp))))
-       (org-odt-format-inline-image thefile))
-       ;; check for embedded formulas
-       ((and (member type '("file"))
-            (not fragment)
-            (org-odt-is-formula-link-p filename)
-            (or (not descp)))
-       (org-odt-format-inline-formula thefile))
-       ;; code references
-       ((string= type "coderef")
-       (let* ((ref fragment)
-              (lineno-or-ref (cdr (assoc ref org-export-code-refs)))
-              (desc (and descp desc))
-              (org-odt-suppress-xref nil)
-              (href (org-xml-format-href (concat "#coderef-" ref))))
-         (cond
-          ((and (numberp lineno-or-ref) (not desc))
-           (org-odt-format-link lineno-or-ref href))
-          ((and (numberp lineno-or-ref) desc
-                (string-match (regexp-quote (concat "(" ref ")")) desc))
-           (format (replace-match "%s" t t desc)
-                   (org-odt-format-link lineno-or-ref href)))
-          (t
-           (setq desc (format
-                       (if (and desc (string-match
-                                      (regexp-quote (concat "(" ref ")"))
-                                      desc))
-                           (replace-match "%s" t t desc)
-                         (or desc "%s"))
-                       lineno-or-ref))
-           (org-odt-format-link (org-xml-format-desc desc) href)))))
-       ;; links to headlines
-       ((and (string= type "")
-            (or (not thefile) (string= thefile ""))
-            (plist-get org-lparse-opt-plist :section-numbers)
-            (get-text-property 0 'org-no-description fragment)
-            (setq sec-frag fragment)
-            (or (string-match  "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)
-                (and (setq sec-frag
-                           (loop for alias in org-export-target-aliases do
-                                 (when (member fragment (cdr alias))
-                                   (return (car alias)))))
-                     (string-match  "\\`sec\\(\\(-[0-9]+\\)+\\)" sec-frag)))
-            (setq sec-nos (org-split-string (match-string 1 sec-frag) "-"))
-            (<= (length sec-nos) (plist-get org-lparse-opt-plist
-                                            :headline-levels)))
-       (let ((org-odt-suppress-xref nil))
-         (org-odt-format-link sec-nos (concat "#" sec-frag) attr)))
-       (t
-       (when (string= type "file")
-         (setq thefile
-               (cond
-                ((file-name-absolute-p path)
-                 (concat "file://" (expand-file-name path)))
-                (t (org-odt-relocate-relative-path
-                    thefile org-current-export-file)))))
-
-       (when (and (member type '("" "http" "https" "file")) fragment)
-         (setq thefile (concat thefile "#" fragment)))
-
-       (setq thefile (org-xml-format-href thefile))
-
-       (when (not (member type '("" "file")))
-         (setq thefile (concat type ":" thefile)))
-
-       (let ((org-odt-suppress-xref
-              ;; Typeset link to headlines with description, as a
-              ;; regular hyperlink.
-              (and (string= type "")
-                   (not (get-text-property 0 'org-no-description fragment)))))
-         (org-odt-format-link
-          (org-xml-format-desc desc) thefile attr)))))))
-
-(defun org-odt-format-heading (text level &optional id)
-  (let* ((text (if id (org-odt-format-target text id) text)))
-    (org-odt-format-tags
-     '("<text:h text:style-name=\"Heading_20_%s\" text:outline-level=\"%s\">" .
-       "</text:h>") text level level)))
-
-(defun org-odt-format-headline (title extra-targets tags
-                                     &optional snumber level)
-  (concat
-   (org-lparse-format 'EXTRA-TARGETS extra-targets)
-
-   ;; No need to generate section numbers.  They are auto-generated by
-   ;; the application
-
-   ;; (concat (org-lparse-format 'SECTION-NUMBER snumber level) " ")
-   title
-   (and tags (concat (org-lparse-format 'SPACES 3)
-                    (org-lparse-format 'ORG-TAGS tags)))))
-
-(defun org-odt-format-anchor (text name &optional class)
-  (org-odt-format-target text name))
-
-(defun org-odt-format-bookmark (text id)
-  (if id
-      (org-odt-format-tags "<text:bookmark text:name=\"%s\"/>" text id)
-    text))
-
-(defun org-odt-format-target (text id)
-  (let ((name (concat org-export-odt-bookmark-prefix id)))
-    (concat
-     (and id (org-odt-format-tags
-             "<text:bookmark-start text:name=\"%s\"/>" "" name))
-     (org-odt-format-bookmark text id)
-     (and id (org-odt-format-tags
-             "<text:bookmark-end text:name=\"%s\"/>" "" name)))))
-
-(defun org-odt-format-footnote (n def)
-  (let ((id (concat  "fn" n))
-       (note-class "footnote")
-       (par-style "Footnote"))
-    (org-odt-format-tags
-     '("<text:note text:id=\"%s\" text:note-class=\"%s\">" .
-       "</text:note>")
-     (concat
-      (org-odt-format-tags
-       '("<text:note-citation>" . "</text:note-citation>")
-       n)
-      (org-odt-format-tags
-       '("<text:note-body>" . "</text:note-body>")
-       def))
-     id note-class)))
-
-(defun org-odt-format-footnote-reference (n def refcnt)
-  (if (= refcnt 1)
-      (org-odt-format-footnote n def)
-    (org-odt-format-footnote-ref n)))
-
-(defun org-odt-format-footnote-ref (n)
-  (let ((note-class "footnote")
-       (ref-format "text")
-       (ref-name (concat "fn" n)))
-    (org-odt-format-tags
-     '("<text:span text:style-name=\"%s\">" . "</text:span>")
-     (org-odt-format-tags
-      '("<text:note-ref text:note-class=\"%s\" text:reference-format=\"%s\" text:ref-name=\"%s\">" . "</text:note-ref>")
-      n note-class ref-format ref-name)
-     "OrgSuperscript")))
-
-(defun org-odt-get-image-name (file-name)
-  (require 'sha1)
-  (file-relative-name
-   (expand-file-name
-    (concat (sha1 file-name) "." (file-name-extension file-name)) "Pictures")))
-
-(defun org-export-odt-format-image (src href)
-  "Create image tag with source and attributes."
-  (save-match-data
-    (let* ((caption (org-find-text-property-in-string 'org-caption src))
-          (short-caption
-           (or (org-find-text-property-in-string 'org-caption-shortn src)
-               caption))
-          (caption (and caption (org-xml-format-desc caption)))
-          (short-caption (and short-caption
-                              (org-xml-encode-plain-text short-caption)))
-          (attr (org-find-text-property-in-string 'org-attributes src))
-          (label (org-find-text-property-in-string 'org-label src))
-          (latex-frag (org-find-text-property-in-string
-                       'org-latex-src src))
-          (category (and latex-frag "__DvipngImage__"))
-          (attr-plist (org-lparse-get-block-params attr))
-          (user-frame-anchor
-           (car (assoc-string (plist-get attr-plist :anchor)
-                              '(("as-char") ("paragraph") ("page")) t)))
-          (user-frame-style
-           (and user-frame-anchor (plist-get attr-plist :style)))
-          (user-frame-attrs
-           (and user-frame-anchor (plist-get attr-plist :attributes)))
-          (user-frame-params
-           (list user-frame-style user-frame-attrs user-frame-anchor))
-          (embed-as (cond
-                     (latex-frag
-                      (symbol-name
-                       (case (org-find-text-property-in-string
-                              'org-latex-src-embed-type src)
-                         (paragraph 'paragraph)
-                         (t 'as-char))))
-                     (user-frame-anchor)
-                     (t "paragraph")))
-          (size (org-odt-image-size-from-file
-                 src (plist-get attr-plist :width)
-                 (plist-get attr-plist :height)
-                 (plist-get attr-plist :scale) nil embed-as))
-          (width (car size)) (height (cdr size)))
-      (when latex-frag
-       (setq href (org-propertize href :title "LaTeX Fragment"
-                                  :description latex-frag)))
-      (let ((frame-style-handle (concat (and (or caption label) "Captioned")
-                                       embed-as "Image")))
-       (org-odt-format-entity
-        frame-style-handle href width height
-        :caption caption :label label :category category
-        :short-caption short-caption
-        :user-frame-params user-frame-params)))))
-
-(defun org-odt-format-object-description (title description)
-  (concat (and title (org-odt-format-tags
-                     '("<svg:title>" . "</svg:title>")
-                     (org-odt-encode-plain-text title t)))
-         (and description (org-odt-format-tags
-                           '("<svg:desc>" . "</svg:desc>")
-                           (org-odt-encode-plain-text description t)))))
-
-(defun org-odt-format-frame (text width height style &optional
-                                 extra anchor-type)
-  (let ((frame-attrs
-        (concat
-         (if width (format " svg:width=\"%0.2fcm\"" width) "")
-         (if height (format " svg:height=\"%0.2fcm\"" height) "")
-         extra
-         (format " text:anchor-type=\"%s\"" (or anchor-type "paragraph")))))
-    (org-odt-format-tags
-     '("<draw:frame draw:style-name=\"%s\"%s>" . "</draw:frame>")
-     (concat text (org-odt-format-object-description
-                  (get-text-property 0 :title text)
-                  (get-text-property 0 :description text)))
-     style frame-attrs)))
-
-(defun org-odt-format-textbox (text width height style &optional
-                                   extra anchor-type)
-  (org-odt-format-frame
-   (org-odt-format-tags
-    '("<draw:text-box %s>" . "</draw:text-box>")
-    text (concat (format " fo:min-height=\"%0.2fcm\"" (or height .2))
-                (unless width
-                  (format " fo:min-width=\"%0.2fcm\"" (or width .2)))))
-   width nil style extra anchor-type))
-
-(defun org-odt-format-inlinetask (heading content
-                                         &optional todo priority tags)
-  (org-odt-format-stylized-paragraph
-   nil (org-odt-format-textbox
-       (concat (org-odt-format-stylized-paragraph
-                "OrgInlineTaskHeading"
-                (org-lparse-format
-                 'HEADLINE (concat (org-lparse-format-todo todo) " " heading)
-                 nil tags))
-               content) nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))
-
-(defvar org-odt-entity-frame-styles
-  '(("As-CharImage" "__Figure__" ("OrgInlineImage" nil "as-char"))
-    ("ParagraphImage" "__Figure__" ("OrgDisplayImage" nil "paragraph"))
-    ("PageImage" "__Figure__" ("OrgPageImage" nil "page"))
-    ("CaptionedAs-CharImage" "__Figure__"
-     ("OrgCaptionedImage"
-      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
-     ("OrgInlineImage" nil "as-char"))
-    ("CaptionedParagraphImage" "__Figure__"
-     ("OrgCaptionedImage"
-      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
-     ("OrgImageCaptionFrame" nil "paragraph"))
-    ("CaptionedPageImage" "__Figure__"
-     ("OrgCaptionedImage"
-      " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
-     ("OrgPageImageCaptionFrame" nil "page"))
-    ("InlineFormula" "__MathFormula__" ("OrgInlineFormula" nil "as-char"))
-    ("DisplayFormula" "__MathFormula__" ("OrgDisplayFormula" nil "as-char"))
-    ("CaptionedDisplayFormula" "__MathFormula__"
-     ("OrgCaptionedFormula" nil "paragraph")
-     ("OrgFormulaCaptionFrame" nil "as-char"))))
-
-(defun org-odt-merge-frame-params(default-frame-params user-frame-params)
-  (if (not user-frame-params) default-frame-params
-    (assert (= (length default-frame-params) 3))
-    (assert (= (length user-frame-params) 3))
-    (loop for user-frame-param in user-frame-params
-         for default-frame-param in default-frame-params
-         collect (or user-frame-param default-frame-param))))
-
-(defun* org-odt-format-entity (entity href width height
-                                     &key caption label category
-                                     user-frame-params short-caption)
-  (let* ((entity-style (assoc-string entity org-odt-entity-frame-styles t))
-        default-frame-params frame-params)
-    (cond
-     ((not (or caption label))
-      (setq default-frame-params (nth 2 entity-style))
-      (setq frame-params (org-odt-merge-frame-params
-                         default-frame-params user-frame-params))
-      (apply 'org-odt-format-frame href width height frame-params))
-     (t
-      (setq default-frame-params (nth 3 entity-style))
-      (setq frame-params (org-odt-merge-frame-params
-                         default-frame-params user-frame-params))
-      (apply 'org-odt-format-textbox
-            (org-odt-format-stylized-paragraph
-             'illustration
-             (concat
-              (apply 'org-odt-format-frame href width height
-                     (let ((entity-style-1 (copy-sequence
-                                            (nth 2 entity-style))))
-                       (setcar (cdr entity-style-1)
-                               (concat
-                                (cadr entity-style-1)
-                                (and short-caption
-                                     (format " draw:name=\"%s\" "
-                                             short-caption))))
-
-                       entity-style-1))
-              (org-odt-format-entity-caption
-               label caption (or category (nth 1 entity-style)))))
-            width height frame-params)))))
-
-(defvar org-odt-embedded-images-count 0)
-(defun org-odt-copy-image-file (path)
-  "Returns the internal name of the file"
-  (let* ((image-type (file-name-extension path))
-        (media-type (format "image/%s" image-type))
-        (src-file (expand-file-name
-                   path (file-name-directory org-current-export-file)))
-        (target-dir "Images/")
-        (target-file
-         (format "%s%04d.%s" target-dir
-                 (incf org-odt-embedded-images-count) image-type)))
-    (when (not org-lparse-to-buffer)
-      (message "Embedding %s as %s ..."
-              (substring-no-properties path) target-file)
-
-      (when (= 1 org-odt-embedded-images-count)
-       (make-directory target-dir)
-       (org-odt-create-manifest-file-entry "" target-dir))
-
-      (copy-file src-file target-file 'overwrite)
-      (org-odt-create-manifest-file-entry media-type target-file))
-    target-file))
-
-(defvar org-export-odt-image-size-probe-method
-  (append (and (executable-find "identify") '(imagemagick)) ; See Bug#10675
-         '(emacs fixed))
-  "Ordered list of methods for determining image sizes.")
-
-(defvar org-export-odt-default-image-sizes-alist
-  '(("as-char" . (5 . 0.4))
-    ("paragraph" . (5 . 5)))
-  "Hardcoded image dimensions one for each of the anchor
-  methods.")
-
-;; A4 page size is 21.0 by 29.7 cms
-;; The default page settings has 2cm margin on each of the sides.  So
-;; the effective text area is 17.0 by 25.7 cm
-(defvar org-export-odt-max-image-size '(17.0 . 20.0)
-  "Limiting dimensions for an embedded image.")
-
-(defun org-odt-do-image-size (probe-method file &optional dpi anchor-type)
-  (let* ((dpi (or dpi org-export-odt-pixels-per-inch))
-        (anchor-type (or anchor-type "paragraph"))
-        (--pixels-to-cms
-         (function
-          (lambda (pixels dpi)
-            (let* ((cms-per-inch 2.54)
-                   (inches (/ pixels dpi)))
-              (* cms-per-inch inches)))))
-        (--size-in-cms
-         (function
-          (lambda (size-in-pixels dpi)
-            (and size-in-pixels
-                 (cons (funcall --pixels-to-cms (car size-in-pixels) dpi)
-                       (funcall --pixels-to-cms (cdr size-in-pixels) dpi)))))))
-    (case probe-method
-      (emacs
-       (let ((size-in-pixels
-             (ignore-errors            ; Emacs could be in batch mode
-               (clear-image-cache)
-               (image-size (create-image file) 'pixels))))
-        (funcall --size-in-cms size-in-pixels dpi)))
-      (imagemagick
-       (let ((size-in-pixels
-             (let ((dim (shell-command-to-string
-                         (format "identify -format \"%%w:%%h\" \"%s\"" file))))
-               (when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
-                 (cons (string-to-number (match-string 1 dim))
-                       (string-to-number (match-string 2 dim)))))))
-        (funcall --size-in-cms size-in-pixels dpi)))
-      (t (cdr (assoc-string anchor-type
-                           org-export-odt-default-image-sizes-alist))))))
-
-(defun org-odt-image-size-from-file (file &optional user-width
-                                         user-height scale dpi embed-as)
-  (unless (file-name-absolute-p file)
-    (setq file (expand-file-name
-               file (file-name-directory org-current-export-file))))
-  (let* (size width height)
-    (unless (and user-height user-width)
-      (loop for probe-method in org-export-odt-image-size-probe-method
-           until size
-           do (setq size (org-odt-do-image-size
-                          probe-method file dpi embed-as)))
-      (or size (error "Cannot determine image size, aborting"))
-      (setq width (car size) height (cdr size)))
-    (cond
-     (scale
-      (setq width (* width scale) height (* height scale)))
-     ((and user-height user-width)
-      (setq width user-width height user-height))
-     (user-height
-      (setq width (* user-height (/ width height)) height user-height))
-     (user-width
-      (setq height (* user-width (/ height width)) width user-width))
-     (t (ignore)))
-    ;; ensure that an embedded image fits comfortably within a page
-    (let ((max-width (car org-export-odt-max-image-size))
-         (max-height (cdr org-export-odt-max-image-size)))
-      (when (or (> width max-width) (> height max-height))
-       (let* ((scale1 (/ max-width width))
-              (scale2 (/ max-height height))
-              (scale (min scale1 scale2)))
-         (setq width (* scale width) height (* scale height)))))
-    (cons width height)))
-
-(defvar org-odt-entity-counts-plist nil
-  "Plist of running counters of SEQNOs for each of the CATEGORY-NAMEs.
-See `org-odt-entity-labels-alist' for known CATEGORY-NAMEs.")
-
-(defvar org-odt-label-styles
-  '(("math-formula" "%c" "text" "(%n)")
-    ("math-label" "(%n)" "text" "(%n)")
-    ("category-and-value" "%e %n: %c" "category-and-value" "%e %n")
-    ("value" "%e %n: %c" "value" "%n"))
-  "Specify how labels are applied and referenced.
-This is an alist where each element is of the
-form (LABEL-STYLE-NAME LABEL-ATTACH-FMT LABEL-REF-MODE
-LABEL-REF-FMT).
-
-LABEL-ATTACH-FMT controls how labels and captions are attached to
-an entity.  It may contain following specifiers - %e, %n and %c.
-%e is replaced with the CATEGORY-NAME.  %n is replaced with
-\"<text:sequence ...> SEQNO </text:sequence>\".  %c is replaced
-with CAPTION. See `org-odt-format-label-definition'.
-
-LABEL-REF-MODE and LABEL-REF-FMT controls how label references
-are generated.  The following XML is generated for a label
-reference - \"<text:sequence-ref
-text:reference-format=\"LABEL-REF-MODE\" ...> LABEL-REF-FMT
-</text:sequence-ref>\".  LABEL-REF-FMT may contain following
-specifiers - %e and %n.  %e is replaced with the CATEGORY-NAME.
-%n is replaced with SEQNO. See
-`org-odt-format-label-reference'.")
-
-(defcustom org-export-odt-category-strings
-  '(("en" "Table" "Figure" "Equation" "Equation"))
-  "Specify category strings for various captionable entities.
-Captionable entity can be one of a Table, an Embedded Image, a
-LaTeX fragment (generated with dvipng) or a Math Formula.
-
-For example, when `org-export-default-language' is \"en\", an
-embedded image will be captioned as \"Figure 1: Orgmode Logo\".
-If you want the images to be captioned instead as \"Illustration
-1: Orgmode Logo\", then modify the entry for \"en\" as shown
-below.
-
-  \(setq org-export-odt-category-strings
-       '\(\(\"en\" \"Table\" \"Illustration\"
-          \"Equation\" \"Equation\"\)\)\)"
-  :group 'org-export-odt
-  :version "24.1"
-  :type '(repeat (list (string :tag "Language tag")
-                      (choice :tag "Table"
-                              (const :tag "Use Default" nil)
-                              (string :tag "Category string"))
-                      (choice :tag "Figure"
-                              (const :tag "Use Default" nil)
-                              (string :tag "Category string"))
-                      (choice :tag "Math Formula"
-                              (const :tag "Use Default" nil)
-                              (string :tag "Category string"))
-                      (choice :tag "Dvipng Image"
-                              (const :tag "Use Default" nil)
-                              (string :tag "Category string")))))
-
-(defvar org-odt-category-map-alist
-  '(("__Table__" "Table" "value")
-    ("__Figure__" "Illustration" "value")
-    ("__MathFormula__" "Text" "math-formula")
-    ("__DvipngImage__" "Equation" "value")
-    ;; ("__Table__" "Table" "category-and-value")
-    ;; ("__Figure__" "Figure" "category-and-value")
-    ;; ("__DvipngImage__" "Equation" "category-and-value")
-    )
-  "Map a CATEGORY-HANDLE to OD-VARIABLE and LABEL-STYLE.
-This is a list where each entry is of the form \\(CATEGORY-HANDLE
-OD-VARIABLE LABEL-STYLE\\).  CATEGORY_HANDLE identifies the
-captionable entity in question.  OD-VARIABLE is the OpenDocument
-sequence counter associated with the entity.  These counters are
-declared within
-\"<text:sequence-decls>...</text:sequence-decls>\" block of
-`org-export-odt-content-template-file'.  LABEL-STYLE is a key
-into `org-odt-label-styles' and specifies how a given entity
-should be captioned and referenced.
-
-The position of a CATEGORY-HANDLE in this list is used as an
-index in to per-language entry for
-`org-export-odt-category-strings' to retrieve a CATEGORY-NAME.
-This CATEGORY-NAME is then used for qualifying the user-specified
-captions on export.")
-
-(defun org-odt-add-label-definition (label default-category)
-  "Create an entry in `org-odt-entity-labels-alist' and return it."
-  (let* ((label-props (assoc default-category org-odt-category-map-alist))
-        ;; identify the sequence number
-        (counter (nth 1 label-props))
-        (sequence-var (intern counter))
-        (seqno (1+ (or (plist-get org-odt-entity-counts-plist sequence-var)
-                       0)))
-        ;; assign an internal label, if user has not provided one
-        (label (if label (substring-no-properties label)
-                 (format  "%s-%s" default-category seqno)))
-        ;; identify label style
-        (label-style (nth 2 label-props))
-        ;; grok language setting
-        (en-strings (assoc-default "en" org-export-odt-category-strings))
-        (lang (plist-get org-lparse-opt-plist :language))
-        (lang-strings (assoc-default lang org-export-odt-category-strings))
-        ;; retrieve localized category sting
-        (pos (- (length org-odt-category-map-alist)
-                (length (memq label-props org-odt-category-map-alist))))
-        (category (or (nth pos lang-strings) (nth pos en-strings)))
-        (label-props (list label category counter seqno label-style)))
-    ;; synchronize internal counters
-    (setq org-odt-entity-counts-plist
-         (plist-put org-odt-entity-counts-plist sequence-var seqno))
-    ;; stash label properties for later retrieval
-    (push label-props org-odt-entity-labels-alist)
-    label-props))
-
-(defun org-odt-format-label-definition (caption label category counter
-                                               seqno label-style)
-  (assert label)
-  (format-spec
-   (cadr (assoc-string label-style org-odt-label-styles t))
-   `((?e . ,category)
-     (?n . ,(org-odt-format-tags
-            '("<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">" . "</text:sequence>")
-            (format "%d" seqno) label counter counter))
-     (?c . ,(or caption "")))))
-
-(defun org-odt-format-label-reference (label category counter
-                                            seqno label-style)
-  (assert label)
-  (save-match-data
-    (let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
-          (fmt1 (car fmt))
-          (fmt2 (cadr fmt)))
-      (org-odt-format-tags
-       '("<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">"
-        . "</text:sequence-ref>")
-       (format-spec fmt2 `((?e . ,category)
-                          (?n . ,(format "%d" seqno)))) fmt1 label))))
-
-(defun org-odt-fixup-label-references ()
-  (goto-char (point-min))
-  (while (re-search-forward
-         "<text:sequence-ref text:ref-name=\"\\([^\"]+\\)\">[ \t\n]*</text:sequence-ref>"
-         nil t)
-    (let* ((label (match-string 1))
-          (label-def (assoc label org-odt-entity-labels-alist))
-          (rpl (and label-def
-                    (apply 'org-odt-format-label-reference label-def))))
-      (if rpl (replace-match rpl t t)
-       (org-lparse-warn
-        (format "Unable to resolve reference to label \"%s\"" label))))))
-
-(defun org-odt-format-entity-caption (label caption category)
-  (if (not (or label caption)) ""
-    (apply 'org-odt-format-label-definition caption
-          (org-odt-add-label-definition label category))))
-
-(defun org-odt-format-tags (tag text &rest args)
-  (let ((prefix (when org-lparse-encode-pending "@"))
-       (suffix (when org-lparse-encode-pending "@")))
-    (apply 'org-lparse-format-tags tag text prefix suffix args)))
-
-(defvar org-odt-manifest-file-entries nil)
-(defun org-odt-init-outfile (filename)
-  (unless (executable-find "zip")
-    ;; Not at all OSes ship with zip by default
-    (error "Executable \"zip\" needed for creating OpenDocument files"))
-
-  (let* ((content-file (expand-file-name "content.xml" org-odt-zip-dir)))
-    ;; init conten.xml
-    (require 'nxml-mode)
-    (let ((nxml-auto-insert-xml-declaration-flag nil))
-      (find-file-noselect content-file t))
-
-    ;; reset variables
-    (setq org-odt-manifest-file-entries nil
-         org-odt-embedded-images-count 0
-         org-odt-embedded-formulas-count 0
-         org-odt-entity-labels-alist nil
-         org-odt-list-stack-stashed nil
-         org-odt-automatic-styles nil
-         org-odt-object-counters nil
-         org-odt-entity-counts-plist nil)
-    content-file))
-
-(defcustom org-export-odt-prettify-xml nil
-  "Specify whether or not the xml output should be prettified.
-When this option is turned on, `indent-region' is run on all
-component xml buffers before they are saved.  Turn this off for
-regular use.  Turn this on if you need to examine the xml
-visually."
-  :group 'org-export-odt
-  :version "24.1"
-  :type 'boolean)
-
-(defvar hfy-user-sheet-assoc)          ; bound during org-do-lparse
-(defun org-odt-save-as-outfile (target opt-plist)
-  ;; write automatic styles
-  (org-odt-write-automatic-styles)
-
-  ;; write meta file
-  (org-odt-update-meta-file opt-plist)
-
-  ;; write styles file
-  (when (equal org-lparse-backend 'odt)
-    (org-odt-update-styles-file opt-plist))
-
-  ;; create mimetype file
-  (let ((mimetype (org-odt-write-mimetype-file org-lparse-backend)))
-    (org-odt-create-manifest-file-entry mimetype "/" "1.2"))
-
-  ;; create a manifest entry for content.xml
-  (org-odt-create-manifest-file-entry "text/xml" "content.xml")
-
-  ;; write out the manifest entries before zipping
-  (org-odt-write-manifest-file)
-
-  (let ((xml-files '("mimetype" "META-INF/manifest.xml" "content.xml"
-                    "meta.xml")))
-    (when (equal org-lparse-backend 'odt)
-      (push "styles.xml" xml-files))
-
-    ;; save all xml files
-    (mapc (lambda (file)
-           (with-current-buffer
-               (find-file-noselect (expand-file-name file) t)
-             ;; prettify output if needed
-             (when org-export-odt-prettify-xml
-               (indent-region (point-min) (point-max)))
-             (save-buffer 0)))
-         xml-files)
-
-    (let* ((target-name (file-name-nondirectory target))
-          (target-dir (file-name-directory target))
-          (cmds `(("zip" "-mX0" ,target-name "mimetype")
-                  ("zip" "-rmTq" ,target-name "."))))
-      (when (file-exists-p target)
-       ;; FIXME: If the file is locked this throws a cryptic error
-       (delete-file target))
-
-      (let ((coding-system-for-write 'no-conversion) exitcode err-string)
-       (message "Creating odt file...")
-       (mapc
-        (lambda (cmd)
-          (message "Running %s" (mapconcat 'identity cmd " "))
-          (setq err-string
-                (with-output-to-string
-                  (setq exitcode
-                        (apply 'call-process (car cmd)
-                               nil standard-output nil (cdr cmd)))))
-          (or (zerop exitcode)
-              (ignore (message "%s" err-string))
-              (error "Unable to create odt file (%S)" exitcode)))
-        cmds))
-
-      ;; move the file from outdir to target-dir
-      (rename-file target-name target-dir)))
-
-  (message "Created %s" target)
-  (set-buffer (find-file-noselect target t)))
-
-(defconst org-odt-manifest-file-entry-tag
-  "
-<manifest:file-entry manifest:media-type=\"%s\" manifest:full-path=\"%s\"%s/>")
-
-(defun org-odt-create-manifest-file-entry (&rest args)
-  (push args org-odt-manifest-file-entries))
-
-(defun org-odt-write-manifest-file ()
-  (make-directory "META-INF")
-  (let ((manifest-file (expand-file-name "META-INF/manifest.xml")))
-    (with-current-buffer
-       (let ((nxml-auto-insert-xml-declaration-flag nil))
-         (find-file-noselect manifest-file t))
-      (insert
-       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-     <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n")
-      (mapc
-       (lambda (file-entry)
-        (let* ((version (nth 2 file-entry))
-               (extra (if version
-                          (format  " manifest:version=\"%s\"" version)
-                        "")))
-          (insert
-           (format org-odt-manifest-file-entry-tag
-                   (nth 0 file-entry) (nth 1 file-entry) extra))))
-       org-odt-manifest-file-entries)
-      (insert "\n</manifest:manifest>"))))
-
-(defun org-odt-update-meta-file (opt-plist)
-  (let ((date (org-odt-format-date (plist-get opt-plist :date)))
-       (author (or (plist-get opt-plist :author) ""))
-       (email (plist-get opt-plist :email))
-       (keywords (plist-get opt-plist :keywords))
-       (description (plist-get opt-plist :description))
-       (title (plist-get opt-plist :title)))
-    (write-region
-     (concat
-      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-     <office:document-meta
-         xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"
-         xmlns:xlink=\"http://www.w3.org/1999/xlink\"
-         xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
-         xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"
-         xmlns:ooo=\"http://openoffice.org/2004/office\"
-         office:version=\"1.2\">
-       <office:meta>" "\n"
-       (org-odt-format-author)
-       (org-odt-format-tags
-       '("\n<meta:initial-creator>" . "</meta:initial-creator>") author)
-       (org-odt-format-tags '("\n<dc:date>" . "</dc:date>") date)
-       (org-odt-format-tags
-       '("\n<meta:creation-date>" . "</meta:creation-date>") date)
-       (org-odt-format-tags '("\n<meta:generator>" . "</meta:generator>")
-                           (when org-export-creator-info
-                             (format "Org-%s/Emacs-%s"
-                                     (org-version)
-                                     emacs-version)))
-       (org-odt-format-tags '("\n<meta:keyword>" . "</meta:keyword>") keywords)
-       (org-odt-format-tags '("\n<dc:subject>" . "</dc:subject>") description)
-       (org-odt-format-tags '("\n<dc:title>" . "</dc:title>") title)
-       "\n"
-       "  </office:meta>" "</office:document-meta>")
-     nil (expand-file-name "meta.xml")))
-
-  ;; create a manifest entry for meta.xml
-  (org-odt-create-manifest-file-entry "text/xml" "meta.xml"))
-
-(defun org-odt-update-styles-file (opt-plist)
-  ;; write styles file
-  (let ((styles-file (plist-get opt-plist :odt-styles-file)))
-    (org-odt-copy-styles-file (and styles-file
-                                  (read (org-trim styles-file)))))
-
-  ;; Update styles.xml - take care of outline numbering
-  (with-current-buffer
-      (find-file-noselect (expand-file-name "styles.xml") t)
-    ;; Don't make automatic backup of styles.xml file.  This setting
-    ;; prevents the backed-up styles.xml file from being zipped in to
-    ;; odt file.  This is more of a hackish fix.  Better alternative
-    ;; would be to fix the zip command so that the output odt file
-    ;; includes only the needed files and excludes any auto-generated
-    ;; extra files like backups and auto-saves etc etc.  Note that
-    ;; currently the zip command zips up the entire temp directory so
-    ;; that any auto-generated files created under the hood ends up in
-    ;; the resulting odt file.
-    (set (make-local-variable 'backup-inhibited) t)
-
-    ;; Import local setting of `org-export-with-section-numbers'
-    (org-lparse-bind-local-variables opt-plist)
-    (org-odt-configure-outline-numbering
-     (if org-export-with-section-numbers org-export-headline-levels 0)))
-
-  ;; Write custom styles for source blocks
-  (org-odt-insert-custom-styles-for-srcblocks
-   (mapconcat
-    (lambda (style)
-      (format " %s\n" (cddr style)))
-    hfy-user-sheet-assoc "")))
-
-(defun org-odt-write-mimetype-file (format)
-  ;; create mimetype file
-  (let ((mimetype
-        (case format
-          (odt "application/vnd.oasis.opendocument.text")
-          (odf "application/vnd.oasis.opendocument.formula")
-          (t (error "Unknown OpenDocument backend %S" org-lparse-backend)))))
-    (write-region mimetype nil (expand-file-name "mimetype"))
-    mimetype))
-
-(defun org-odt-finalize-outfile ()
-  (org-odt-delete-empty-paragraphs))
-
-(defun org-odt-delete-empty-paragraphs ()
-  (goto-char (point-min))
-  (let ((open "<text:p[^>]*>")
-       (close "</text:p>"))
-    (while (re-search-forward (format "%s[ \r\n\t]*%s" open close) nil t)
-      (replace-match ""))))
-
-(defcustom org-export-odt-convert-processes
-  '(("LibreOffice"
-     "soffice --headless --convert-to %f%x --outdir %d %i")
-    ("unoconv"
-     "unoconv -f %f -o %d %i"))
-  "Specify a list of document converters and their usage.
-The converters in this list are offered as choices while
-customizing `org-export-odt-convert-process'.
-
-This variable is a list where each element is of the
-form (CONVERTER-NAME CONVERTER-CMD).  CONVERTER-NAME is the name
-of the converter.  CONVERTER-CMD is the shell command for the
-converter and can contain format specifiers.  These format
-specifiers are interpreted as below:
-
-%i input file name in full
-%I input file name as a URL
-%f format of the output file
-%o output file name in full
-%O output file name as a URL
-%d output dir in full
-%D output dir as a URL.
-%x extra options as set in `org-export-odt-convert-capabilities'."
-  :group 'org-export-odt
-  :version "24.1"
-  :type
-  '(choice
-    (const :tag "None" nil)
-    (alist :tag "Converters"
-          :key-type (string :tag "Converter Name")
-          :value-type (group (string :tag "Command line")))))
-
-(defcustom org-export-odt-convert-process "LibreOffice"
-  "Use this converter to convert from \"odt\" format to other formats.
-During customization, the list of converter names are populated
-from `org-export-odt-convert-processes'."
-  :group 'org-export-odt
-  :version "24.1"
-  :type '(choice :convert-widget
-                (lambda (w)
-                  (apply 'widget-convert (widget-type w)
-                         (eval (car (widget-get w :args)))))
-                `((const :tag "None" nil)
-                  ,@(mapcar (lambda (c)
-                              `(const :tag ,(car c) ,(car c)))
-                            org-export-odt-convert-processes))))
-
-(defcustom org-export-odt-convert-capabilities
-  '(("Text"
-     ("odt" "ott" "doc" "rtf" "docx")
-     (("pdf" "pdf") ("odt" "odt") ("rtf" "rtf") ("ott" "ott")
-      ("doc" "doc" ":\"MS Word 97\"") ("docx" "docx") ("html" "html")))
-    ("Web"
-     ("html")
-     (("pdf" "pdf") ("odt" "odt") ("html" "html")))
-    ("Spreadsheet"
-     ("ods" "ots" "xls" "csv" "xlsx")
-     (("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv") ("ods" "ods")
-      ("xls" "xls") ("xlsx" "xlsx")))
-    ("Presentation"
-     ("odp" "otp" "ppt" "pptx")
-     (("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("otp" "otp") ("ppt" "ppt")
-      ("pptx" "pptx") ("odg" "odg"))))
-  "Specify input and output formats of `org-export-odt-convert-process'.
-More correctly, specify the set of input and output formats that
-the user is actually interested in.
-
-This variable is an alist where each element is of the
-form (DOCUMENT-CLASS INPUT-FMT-LIST OUTPUT-FMT-ALIST).
-INPUT-FMT-LIST is a list of INPUT-FMTs.  OUTPUT-FMT-ALIST is an
-alist where each element is of the form (OUTPUT-FMT
-OUTPUT-FILE-EXTENSION EXTRA-OPTIONS).
-
-The variable is interpreted as follows:
-`org-export-odt-convert-process' can take any document that is in
-INPUT-FMT-LIST and produce any document that is in the
-OUTPUT-FMT-LIST.  A document converted to OUTPUT-FMT will have
-OUTPUT-FILE-EXTENSION as the file name extension.  OUTPUT-FMT
-serves dual purposes:
-- It is used for populating completion candidates during
-  `org-export-odt-convert' commands.
-- It is used as the value of \"%f\" specifier in
-  `org-export-odt-convert-process'.
-
-EXTRA-OPTIONS is used as the value of \"%x\" specifier in
-`org-export-odt-convert-process'.
-
-DOCUMENT-CLASS is used to group a set of file formats in
-INPUT-FMT-LIST in to a single class.
-
-Note that this variable inherently captures how LibreOffice based
-converters work.  LibreOffice maps documents of various formats
-to classes like Text, Web, Spreadsheet, Presentation etc and
-allow document of a given class (irrespective of it's source
-format) to be converted to any of the export formats associated
-with that class.
-
-See default setting of this variable for an typical
-configuration."
-  :group 'org-export-odt
-  :version "24.1"
-  :type
-  '(choice
-    (const :tag "None" nil)
-    (alist :tag "Capabilities"
-          :key-type (string :tag "Document Class")
-          :value-type
-          (group (repeat :tag "Input formats" (string :tag "Input format"))
-                 (alist :tag "Output formats"
-                        :key-type (string :tag "Output format")
-                        :value-type
-                        (group (string :tag "Output file extension")
-                               (choice
-                                (const :tag "None" nil)
-                                (string :tag "Extra options"))))))))
-
-(declare-function org-create-math-formula "org"
-                 (latex-frag &optional mathml-file))
-
-;;;###autoload
-(defun org-export-odt-convert (&optional in-file out-fmt prefix-arg)
-  "Convert IN-FILE to format OUT-FMT using a command line converter.
-IN-FILE is the file to be converted.  If unspecified, it defaults
-to variable `buffer-file-name'.  OUT-FMT is the desired output
-format.  Use `org-export-odt-convert-process' as the converter.
-If PREFIX-ARG is non-nil then the newly converted file is opened
-using `org-open-file'."
-  (interactive
-   (append (org-lparse-convert-read-params) current-prefix-arg))
-  (org-lparse-do-convert in-file out-fmt prefix-arg))
-
-(defun org-odt-get (what &optional opt-plist)
-  (case what
-    (BACKEND 'odt)
-    (EXPORT-DIR (org-export-directory :html opt-plist))
-    (FILE-NAME-EXTENSION "odt")
-    (EXPORT-BUFFER-NAME "*Org ODT Export*")
-    (ENTITY-CONTROL org-odt-entity-control-callbacks-alist)
-    (ENTITY-FORMAT org-odt-entity-format-callbacks-alist)
-    (INIT-METHOD 'org-odt-init-outfile)
-    (FINAL-METHOD 'org-odt-finalize-outfile)
-    (SAVE-METHOD 'org-odt-save-as-outfile)
-    (CONVERT-METHOD
-     (and org-export-odt-convert-process
-         (cadr (assoc-string org-export-odt-convert-process
-                             org-export-odt-convert-processes t))))
-    (CONVERT-CAPABILITIES
-     (and org-export-odt-convert-process
-         (cadr (assoc-string org-export-odt-convert-process
-                             org-export-odt-convert-processes t))
-         org-export-odt-convert-capabilities))
-    (TOPLEVEL-HLEVEL 1)
-    (SPECIAL-STRING-REGEXPS org-export-odt-special-string-regexps)
-    (INLINE-IMAGES 'maybe)
-    (INLINE-IMAGE-EXTENSIONS '("png" "jpeg" "jpg" "gif" "svg"))
-    (PLAIN-TEXT-MAP '(("&" . "&amp;") ("<" . "&lt;") (">" . "&gt;")))
-    (TABLE-FIRST-COLUMN-AS-LABELS nil)
-    (FOOTNOTE-SEPARATOR (org-lparse-format 'FONTIFY "," 'superscript))
-    (CODING-SYSTEM-FOR-WRITE 'utf-8)
-    (CODING-SYSTEM-FOR-SAVE 'utf-8)
-    (t (error "Unknown property: %s"  what))))
-
-(defvar org-lparse-latex-fragment-fallback) ; set by org-do-lparse
-(defun org-export-odt-do-preprocess-latex-fragments ()
-  "Convert LaTeX fragments to images."
-  (let* ((latex-frag-opt (plist-get org-lparse-opt-plist :LaTeX-fragments))
-        (latex-frag-opt                ;  massage the options
-         (or (and (member latex-frag-opt '(mathjax t))
-                  (not (and (fboundp 'org-format-latex-mathml-available-p)
-                            (org-format-latex-mathml-available-p)))
-                  (prog1 org-lparse-latex-fragment-fallback
-                    (org-lparse-warn
-                     (concat
-                      "LaTeX to MathML converter not available. "
-                      (format "Using %S instead."
-                              org-lparse-latex-fragment-fallback)))))
-             latex-frag-opt))
-        cache-dir display-msg)
-    (cond
-     ((eq latex-frag-opt 'dvipng)
-      (setq cache-dir org-latex-preview-ltxpng-directory)
-      (setq display-msg "Creating LaTeX image %s"))
-     ((member latex-frag-opt '(mathjax t))
-      (setq latex-frag-opt 'mathml)
-      (setq cache-dir "ltxmathml/")
-      (setq display-msg "Creating MathML formula %s")))
-    (when (and org-current-export-file)
-      (org-format-latex
-       (concat cache-dir (file-name-sans-extension
-                         (file-name-nondirectory org-current-export-file)))
-       org-current-export-dir nil display-msg
-       nil nil latex-frag-opt))))
-
-(defadvice org-format-latex-as-mathml
-  (after org-odt-protect-latex-fragment activate)
-  "Encode LaTeX fragment as XML.
-Do this when translation to MathML fails."
-  (when (or (not (> (length ad-return-value) 0))
-           (get-text-property 0 'org-protected ad-return-value))
-    (setq ad-return-value
-         (org-propertize (org-odt-encode-plain-text (ad-get-arg 0))
-                         'org-protected t))))
-
-(defun org-export-odt-preprocess-latex-fragments ()
-  (when (equal org-export-current-backend 'odt)
-    (org-export-odt-do-preprocess-latex-fragments)))
-
-(defun org-export-odt-preprocess-label-references ()
-  (goto-char (point-min))
-  (let (label label-components category value pretty-label)
-    (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t)
-      (org-if-unprotected-at (match-beginning 1)
-       (replace-match
-        (let ((org-lparse-encode-pending t)
-              (label (match-string 1)))
-          ;; markup generated below is mostly an eye-candy.  At
-          ;; pre-processing stage, there is no information on which
-          ;; entity a label reference points to.  The actual markup
-          ;; is generated as part of `org-odt-fixup-label-references'
-          ;; which gets called at the fag end of export.  By this
-          ;; time we would have seen and collected all the label
-          ;; definitions in `org-odt-entity-labels-alist'.
-          (org-odt-format-tags
-           '("<text:sequence-ref text:ref-name=\"%s\">" .
-             "</text:sequence-ref>")
-           "" (org-add-props label '(org-protected t)))) t t)))))
-
-;; process latex fragments as part of
-;; `org-export-preprocess-after-blockquote-hook'.  Note that this hook
-;; is the one that is closest and well before the call to
-;; `org-export-attach-captions-and-attributes' in
-;; `org-export-preprocess-string'.  The above arrangement permits
-;; captions, labels and attributes to be attached to png images
-;; generated out of latex equations.
-(add-hook 'org-export-preprocess-after-blockquote-hook
-         'org-export-odt-preprocess-latex-fragments)
-
-(defun org-export-odt-preprocess (parameters)
-  (org-export-odt-preprocess-label-references))
-
-(declare-function archive-zip-extract "arc-mode" (archive name))
-(defun org-odt-zip-extract-one (archive member &optional target)
-  (require 'arc-mode)
-  (let* ((target (or target default-directory))
-        (archive (expand-file-name archive))
-        (archive-zip-extract
-         (list "unzip" "-qq" "-o" "-d" target))
-        exit-code command-output)
-    (setq command-output
-         (with-temp-buffer
-           (setq exit-code (archive-zip-extract archive member))
-           (buffer-string)))
-    (unless (zerop exit-code)
-      (message command-output)
-      (error "Extraction failed"))))
-
-(defun org-odt-zip-extract (archive members &optional target)
-  (when (atom members) (setq members (list members)))
-  (mapc (lambda (member)
-         (org-odt-zip-extract-one archive member target))
-       members))
-
-(defun org-odt-copy-styles-file (&optional styles-file)
-  ;; Non-availability of styles.xml is not a critical error.  For now
-  ;; throw an error purely for aesthetic reasons.
-  (setq styles-file (or styles-file
-                       org-export-odt-styles-file
-                       (expand-file-name "OrgOdtStyles.xml"
-                                         org-odt-styles-dir)
-                       (error "org-odt: Missing styles file?")))
-  (cond
-   ((listp styles-file)
-    (let ((archive (nth 0 styles-file))
-         (members (nth 1 styles-file)))
-      (org-odt-zip-extract archive members)
-      (mapc
-       (lambda (member)
-        (when (org-file-image-p member)
-          (let* ((image-type (file-name-extension member))
-                 (media-type (format "image/%s" image-type)))
-            (org-odt-create-manifest-file-entry media-type member))))
-       members)))
-   ((and (stringp styles-file) (file-exists-p styles-file))
-    (let ((styles-file-type (file-name-extension styles-file)))
-      (cond
-       ((string= styles-file-type "xml")
-       (copy-file styles-file "styles.xml" t))
-       ((member styles-file-type '("odt" "ott"))
-       (org-odt-zip-extract styles-file "styles.xml")))))
-   (t
-    (error (format "Invalid specification of styles.xml file: %S"
-                  org-export-odt-styles-file))))
-
-  ;; create a manifest entry for styles.xml
-  (org-odt-create-manifest-file-entry "text/xml" "styles.xml"))
-
-(defun org-odt-configure-outline-numbering (level)
-  "Outline numbering is retained only upto LEVEL.
-To disable outline numbering pass a LEVEL of 0."
-  (goto-char (point-min))
-  (let ((regex
-        "<text:outline-level-style\\([^>]*\\)text:level=\"\\([^\"]*\\)\"\\([^>]*\\)>")
-       (replacement
-        "<text:outline-level-style\\1text:level=\"\\2\" style:num-format=\"\">"))
-    (while (re-search-forward regex nil t)
-      (when (> (string-to-number (match-string 2)) level)
-       (replace-match replacement t nil))))
-  (save-buffer 0))
-
-;;;###autoload
-(defun org-export-as-odf (latex-frag &optional odf-file)
-  "Export LATEX-FRAG as OpenDocument formula file ODF-FILE.
-Use `org-create-math-formula' to convert LATEX-FRAG first to
-MathML.  When invoked as an interactive command, use
-`org-latex-regexps' to infer LATEX-FRAG from currently active
-region.  If no LaTeX fragments are found, prompt for it.  Push
-MathML source to kill ring, if `org-export-copy-to-kill-ring' is
-non-nil."
-  (interactive
-   `(,(let (frag)
-       (setq frag (and (setq frag (and (org-region-active-p)
-                                       (buffer-substring (region-beginning)
-                                                         (region-end))))
-                       (loop for e in org-latex-regexps
-                             thereis (when (string-match (nth 1 e) frag)
-                                       (match-string (nth 2 e) frag)))))
-       (read-string "LaTeX Fragment: " frag nil frag))
-     ,(let ((odf-filename (expand-file-name
-                          (concat
-                           (file-name-sans-extension
-                            (or (file-name-nondirectory buffer-file-name)))
-                           "." "odf")
-                          (file-name-directory buffer-file-name))))
-       (read-file-name "ODF filename: " nil odf-filename nil
-                       (file-name-nondirectory odf-filename)))))
-  (org-odt-cleanup-xml-buffers
-   (let* ((org-lparse-backend 'odf)
-         org-lparse-opt-plist
-         (filename (or odf-file
-                       (expand-file-name
-                        (concat
-                         (file-name-sans-extension
-                          (or (file-name-nondirectory buffer-file-name)))
-                         "." "odf")
-                        (file-name-directory buffer-file-name))))
-         (buffer (find-file-noselect (org-odt-init-outfile filename)))
-         (coding-system-for-write 'utf-8)
-         (save-buffer-coding-system 'utf-8))
-     (set-buffer buffer)
-     (set-buffer-file-coding-system coding-system-for-write)
-     (let ((mathml (org-create-math-formula latex-frag)))
-       (unless mathml (error "No Math formula created"))
-       (insert mathml)
-       (or (org-export-push-to-kill-ring
-           (upcase (symbol-name org-lparse-backend)))
-          (message "Exporting... done")))
-     (org-odt-save-as-outfile filename nil))))
-
-;;;###autoload
-(defun org-export-as-odf-and-open ()
-  "Export LaTeX fragment as OpenDocument formula and immediately open it.
-Use `org-export-as-odf' to read LaTeX fragment and OpenDocument
-formula file."
-  (interactive)
-  (org-lparse-and-open
-   nil nil nil (call-interactively 'org-export-as-odf)))
-
-(provide 'org-odt)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-odt.el ends here
index 7ae80b02e2f3668058d76f4f003d36996357f4ff..77f68f4d85b3065db55324732fe77c728db7e94e 100644 (file)
@@ -35,9 +35,8 @@
 (require 'pcomplete)
 
 (declare-function org-split-string "org" (string &optional separators))
-(declare-function org-get-current-options "org-exp" ())
 (declare-function org-make-org-heading-search-string "org"
-                 (&optional string heading))
+                 (&optional string))
 (declare-function org-get-buffer-tags "org" ())
 (declare-function org-get-tags "org" ())
 (declare-function org-buffer-property-keys "org"
@@ -46,7 +45,6 @@
 
 ;;;; Customization variables
 
-;; Unused.  Cf org-completion.
 (defgroup org-complete nil
   "Outline-based notes management and organizer."
   :tag "Org"
@@ -110,11 +108,11 @@ When completing for #+STARTUP, for example, this function returns
   (let ((thing (org-thing-at-point)))
     (cond
      ((string= "file-option" (car thing))
-      (concat (car thing) "/" (downcase (cdr thing))))
+      (concat (car thing)
+             (and (cdr thing) (concat "/" (downcase (cdr thing))))))
      ((string= "block-option" (car thing))
       (concat (car thing) "/" (downcase (cdr thing))))
-     (t
-      (car thing)))))
+     (t (car thing)))))
 
 (defun org-parse-arguments ()
   "Parse whitespace separated arguments in the current region."
@@ -141,21 +139,86 @@ When completing for #+STARTUP, for example, this function returns
                 (car (org-thing-at-point)))
                pcomplete-default-completion-function))))
 
-(defvar org-options-keywords)                ; From org.el
-(defvar org-additional-option-like-keywords) ; From org.el
+(defvar org-options-keywords)           ; From org.el
+(defvar org-element-block-name-alist)   ; From org-element.el
+(defvar org-element-affiliated-keywords) ; From org-element.el
+(declare-function org-get-export-keywords "org" ())
 (defun pcomplete/org-mode/file-option ()
   "Complete against all valid file options."
-  (require 'org-exp)
+  (require 'org-element)
   (pcomplete-here
    (org-pcomplete-case-double
-    (mapcar (lambda (x)
-             (if (= ?: (aref x (1- (length x))))
-                 (concat x " ")
-               x))
-           (append org-options-keywords
-                   org-additional-option-like-keywords)))
+    (append (mapcar (lambda (keyword) (concat keyword " "))
+                   org-options-keywords)
+           (mapcar (lambda (keyword) (concat keyword ": "))
+                   org-element-affiliated-keywords)
+           (let (block-names)
+             (dolist (block-info org-element-block-name-alist block-names)
+               (let ((name (car block-info)))
+                 (push (format "END_%s" name) block-names)
+                 (push (concat "BEGIN_"
+                               name
+                               ;; Since language is compulsory in
+                               ;; source blocks, add a space.
+                               (and (equal name "SRC") " "))
+                       block-names)
+                 (push (format "ATTR_%s: " name) block-names))))
+           (mapcar (lambda (keyword) (concat keyword ": "))
+                   (org-get-export-keywords))))
    (substring pcomplete-stub 2)))
 
+(defun pcomplete/org-mode/file-option/author ()
+  "Complete arguments for the #+AUTHOR file option."
+  (pcomplete-here (list user-full-name)))
+
+(defvar org-time-stamp-formats)
+(defun pcomplete/org-mode/file-option/date ()
+  "Complete arguments for the #+DATE file option."
+  (pcomplete-here (list (format-time-string (car org-time-stamp-formats)))))
+
+(defun pcomplete/org-mode/file-option/email ()
+  "Complete arguments for the #+EMAIL file option."
+  (pcomplete-here (list user-mail-address)))
+
+(defvar org-export-exclude-tags)
+(defun pcomplete/org-mode/file-option/exclude_tags ()
+  "Complete arguments for the #+EXCLUDE_TAGS file option."
+  (require 'ox)
+  (pcomplete-here
+   (and org-export-exclude-tags
+       (list (mapconcat 'identity org-export-exclude-tags " ")))))
+
+(defvar org-file-tags)
+(defun pcomplete/org-mode/file-option/filetags ()
+  "Complete arguments for the #+FILETAGS file option."
+  (pcomplete-here (and org-file-tags (mapconcat 'identity org-file-tags " "))))
+
+(defvar org-export-default-language)
+(defun pcomplete/org-mode/file-option/language ()
+  "Complete arguments for the #+LANGUAGE file option."
+  (require 'ox)
+  (pcomplete-here
+   (pcomplete-uniqify-list
+    (list org-export-default-language "en"))))
+
+(defvar org-default-priority)
+(defvar org-highest-priority)
+(defvar org-lowest-priority)
+(defun pcomplete/org-mode/file-option/priorities ()
+  "Complete arguments for the #+PRIORITIES file option."
+  (pcomplete-here (list (format "%c %c %c"
+                               org-highest-priority
+                               org-lowest-priority
+                               org-default-priority))))
+
+(defvar org-export-select-tags)
+(defun pcomplete/org-mode/file-option/select_tags ()
+  "Complete arguments for the #+SELECT_TAGS file option."
+  (require 'ox)
+  (pcomplete-here
+   (and org-export-select-tags
+       (list (mapconcat 'identity org-export-select-tags " ")))))
+
 (defvar org-startup-options)
 (defun pcomplete/org-mode/file-option/startup ()
   "Complete arguments for the #+STARTUP file option."
@@ -170,37 +233,57 @@ When completing for #+STARTUP, for example, this function returns
                (setq opts (delete "showstars" opts)))))
            opts))))
 
-(defmacro pcomplete/org-mode/file-option/x (option)
-  "Complete arguments for OPTION."
-  `(while
-       (pcomplete-here
-       (pcomplete-uniqify-list
-        (delq nil
-              (mapcar (lambda(o)
-                        (when (string-match (concat "^[ \t]*#\\+"
-                                                    ,option ":[ \t]+\\(.*\\)[ \t]*$") o)
-                          (match-string 1 o)))
-                      (split-string (org-get-current-options) "\n")))))))
-
-(defun pcomplete/org-mode/file-option/options ()
-  "Complete arguments for the #+OPTIONS file option."
-  (pcomplete/org-mode/file-option/x "OPTIONS"))
+(defvar org-tag-alist)
+(defun pcomplete/org-mode/file-option/tags ()
+  "Complete arguments for the #+TAGS file option."
+  (pcomplete-here
+   (list
+    (mapconcat (lambda (x)
+                (cond
+                 ((eq :startgroup (car x)) "{")
+                 ((eq :endgroup (car x)) "}")
+                 ((eq :grouptags (car x)) ":")
+                 ((eq :newline (car x)) "\\n")
+                 ((cdr x) (format "%s(%c)" (car x) (cdr x)))
+                 (t (car x))))
+              org-tag-alist " "))))
 
 (defun pcomplete/org-mode/file-option/title ()
   "Complete arguments for the #+TITLE file option."
-  (pcomplete/org-mode/file-option/x "TITLE"))
-
-(defun pcomplete/org-mode/file-option/author ()
-  "Complete arguments for the #+AUTHOR file option."
-  (pcomplete/org-mode/file-option/x "AUTHOR"))
+  (pcomplete-here
+   (let ((visited-file (buffer-file-name (buffer-base-buffer))))
+     (list (or (and visited-file
+                   (file-name-sans-extension
+                    (file-name-nondirectory visited-file)))
+              (buffer-name (buffer-base-buffer)))))))
 
-(defun pcomplete/org-mode/file-option/email ()
-  "Complete arguments for the #+EMAIL file option."
-  (pcomplete/org-mode/file-option/x "EMAIL"))
 
-(defun pcomplete/org-mode/file-option/date ()
-  "Complete arguments for the #+DATE file option."
-  (pcomplete/org-mode/file-option/x "DATE"))
+(declare-function org-export-backend-options "org-export" (cl-x))
+(defun pcomplete/org-mode/file-option/options ()
+  "Complete arguments for the #+OPTIONS file option."
+  (while (pcomplete-here
+         (pcomplete-uniqify-list
+          (append
+           ;; Hard-coded OPTION items always available.
+           '("H:" "\\n:" "num:" "timestamp:" "arch:" "author:" "c:"
+             "creator:" "date:" "d:" "email:" "*:" "e:" "::" "f:"
+             "inline:" "tex:" "p:" "pri:" "':" "-:" "stat:" "^:" "toc:"
+             "|:" "tags:" "tasks:" "<:" "todo:")
+           ;; OPTION items from registered back-ends.
+           (let (items)
+             (dolist (backend (org-bound-and-true-p
+                               org-export--registered-backends))
+               (dolist (option (org-export-backend-options backend))
+                 (let ((item (nth 2 option)))
+                   (when item (push (concat item ":") items)))))
+             items))))))
+
+(defun pcomplete/org-mode/file-option/infojs_opt ()
+  "Complete arguments for the #+INFOJS_OPT file option."
+  (while (pcomplete-here
+         (pcomplete-uniqify-list
+          (mapcar (lambda (item) (format "%s:" (car item)))
+                  (org-bound-and-true-p org-html-infojs-opts-table))))))
 
 (defun pcomplete/org-mode/file-option/bind ()
   "Complete arguments for the #+BIND file option, which are variable names."
@@ -243,7 +326,7 @@ This needs more work, to handle headings with lots of spaces in them."
         (let (tbl)
           (while (re-search-forward org-todo-line-regexp nil t)
             (push (org-make-org-heading-search-string
-                   (match-string-no-properties 3) t)
+                   (match-string-no-properties 3))
                   tbl))
           (pcomplete-uniqify-list tbl)))
        (substring pcomplete-stub 1))))
@@ -291,7 +374,7 @@ This needs more work, to handle headings with lots of spaces in them."
        (cpllist (mapcar (lambda (x) (concat x ": ")) org-drawers)))
     (pcomplete-here cpllist
                    (substring pcomplete-stub 1)
-                   (unless (or (not (delete
+                   (unless (or (not (delq
                                      nil
                                      (mapcar (lambda(x)
                                                (string-match (substring pcomplete-stub 1) x))
@@ -313,16 +396,16 @@ Complete a language in the first field, the header arguments and switches."
          '("-n" "-r" "-l"
            ":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
            ":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
-           ":session" ":shebang" ":tangle" ":var"))))
+           ":session" ":shebang" ":tangle" ":tangle-mode" ":var"))))
 
 (defun pcomplete/org-mode/block-option/clocktable ()
   "Complete keywords in a clocktable line."
-  (while (pcomplete-here '(":maxlevel" ":scope"
+  (while (pcomplete-here '(":maxlevel" ":scope" ":lang"
                           ":tstart" ":tend" ":block" ":step"
                           ":stepskip0" ":fileskip0"
                           ":emphasize" ":link" ":narrow" ":indent"
                           ":tcolumns" ":level" ":compact" ":timestamp"
-                          ":formula" ":formatter"))))
+                          ":formula" ":formatter" ":wstart" ":mstart"))))
 
 (defun org-pcomplete-case-double (list)
   "Return list with both upcase and downcase version of all strings in LIST."
index 02d747d54415092a3e05fb36126d5f98ec3a40a6..384a6f6847b34feb20912690bbd8e8e4de1c92e2 100644 (file)
@@ -30,7 +30,6 @@
 
 ;;; Code:
 (require 'org)
-(require 'org-exp)
 (require 'org-table)
 (eval-when-compile
   (require 'cl))
index 18c6d6d70a44cbd5197a6e3cc7fc87b48be285d0..84b1176a7026622956930d1cefee35dfb15ee1ca 100644 (file)
@@ -2,7 +2,7 @@
 ;;
 ;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
 ;;
-;; Authors: Bastien Guerry <bzg AT gnu DOT org>
+;; Authors: Bastien Guerry <bzg@gnu.org>
 ;;       Daniel M German <dmg AT uvic DOT org>
 ;;       Sebastian Rose <sebastian_rose AT gmx DOT de>
 ;;       Ross Patterson <me AT rpatterson DOT net>
 ;;     Org-link of which the page title will be the description part.  If text
 ;;     was select in the browser, that text will be the body of the entry.
 ;;
-;;   * Call `org-protocol-remember' by using the sub-protocol \"remember\".
-;;     This is provided for backward compatibility.
-;;     You may read `org-capture' as `org-remember' throughout this file if
-;;     you still use `org-remember'.
-;;
 ;; You may use the same bookmark URL for all those standard handlers and just
 ;; adjust the sub-protocol used:
 ;;
@@ -155,8 +150,7 @@ for `org-protocol-the-protocol' and sub-protocols defined in
 ;;; Variables:
 
 (defconst org-protocol-protocol-alist-default
-  '(("org-remember"    :protocol "remember"    :function org-protocol-remember :kill-client t)
-    ("org-capture"     :protocol "capture"     :function org-protocol-capture  :kill-client t)
+  '(("org-capture"     :protocol "capture"     :function org-protocol-capture  :kill-client t)
     ("org-store-link"  :protocol "store-link"  :function org-protocol-store-link)
     ("org-open-source" :protocol "open-source" :function org-protocol-open-source))
   "Default protocols to use.
@@ -271,12 +265,14 @@ Here is an example:
 This is usually a single character string but can also be a
 string with two characters."
   :group 'org-protocol
-  :type 'string)
+  :type '(choice (const nil) (string)))
 
-(defcustom org-protocol-data-separator "/+"
+(defcustom org-protocol-data-separator "/+\\|\\?"
   "The default data separator to use.
    This should be a single regexp string."
   :group 'org-protocol
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type 'string)
 
 ;;; Helper functions:
@@ -297,7 +293,7 @@ nil, assume \"/+\".  The results of that splitting are returned
 as a list.  If UNHEXIFY is non-nil, hex-decode each split part.
 If UNHEXIFY is a function, use that function to decode each split
 part."
-  (let* ((sep (or separator "/+"))
+  (let* ((sep (or separator "/+\\|\\?"))
          (split-parts (split-string data sep)))
     (if unhexify
        (if (fboundp unhexify)
@@ -391,32 +387,14 @@ The sub-protocol used to reach this function is set in
              uri))
   nil)
 
-(defun org-protocol-remember (info)
-  "Process an org-protocol://remember:// style url.
-
-The location for a browser's bookmark has to look like this:
-
-  javascript:location.href='org-protocol://remember://'+ \\
-        encodeURIComponent(location.href)+'/' \\
-        encodeURIComponent(document.title)+'/'+ \\
-        encodeURIComponent(window.getSelection())
-
-See the docs for `org-protocol-capture' for more information."
-
-  (if (and (boundp 'org-stored-links)
-           (fboundp 'org-capture)
-          (org-protocol-do-capture info 'org-remember))
-      (message "Item remembered."))
-  nil)
-
 (defun org-protocol-capture (info)
   "Process an org-protocol://capture:// style url.
 
 The sub-protocol used to reach this function is set in
 `org-protocol-protocol-alist'.
 
-This function detects an URL, title and optional text, separated by '/'
-The location for a browser's bookmark has to look like this:
+This function detects an URL, title and optional text, separated
+by '/'.  The location for a browser's bookmark looks like this:
 
   javascript:location.href='org-protocol://capture://'+ \\
         encodeURIComponent(location.href)+'/' \\
@@ -431,14 +409,20 @@ But you may prepend the encoded URL with a character and a slash like so:
 
 Now template ?b will be used."
   (if (and (boundp 'org-stored-links)
-           (fboundp 'org-capture)
-          (org-protocol-do-capture info 'org-capture))
+          (org-protocol-do-capture info))
       (message "Item captured."))
   nil)
 
-(defun org-protocol-do-capture (info capture-func)
-  "Support `org-capture' and `org-remember' alike.
-CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
+(defun org-protocol-convert-query-to-plist (query)
+  "Convert query string that is part of url to property list."
+  (if query
+      (apply 'append (mapcar (lambda (x)
+                              (let ((c (split-string x "=")))
+                                (list (intern (concat ":" (car c))) (cadr c))))
+                            (split-string query "&")))))
+
+(defun org-protocol-do-capture (info)
+  "Support `org-capture'."
   (let* ((parts (org-protocol-split-data info t org-protocol-data-separator))
         (template (or (and (>= 2 (length (car parts))) (pop parts))
                       org-protocol-default-template-key))
@@ -449,8 +433,8 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
         (region (or (caddr parts) ""))
         (orglink (org-make-link-string
                   url (if (string-match "[^[:space:]]" title) title url)))
-        (org-capture-link-is-already-stored t) ;; avoid call to org-store-link
-        remember-annotation-functions)
+        (query (or (org-protocol-convert-query-to-plist (cadddr parts)) ""))
+        (org-capture-link-is-already-stored t)) ;; avoid call to org-store-link
     (setq org-stored-links
          (cons (list url title) org-stored-links))
     (kill-new orglink)
@@ -458,9 +442,10 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
                          :link url
                          :description title
                          :annotation orglink
-                         :initial region)
+                         :initial region
+                         :query query)
     (raise-frame)
-    (funcall capture-func nil template)))
+    (funcall 'org-capture nil template)))
 
 (defun org-protocol-open-source (fname)
   "Process an org-protocol://open-source:// style url.
@@ -588,9 +573,9 @@ as filename."
 
 (defun org-protocol-create-for-org ()
   "Create a org-protocol project for the current file's Org-mode project.
-This works, if the file visited is part of a publishing project in
-`org-publish-project-alist'.  This function calls `org-protocol-create' to do
-most of the work."
+The visited file needs to be part of a publishing project in
+`org-publish-project-alist' for this to work.  The function
+delegates most of the work to `org-protocol-create'."
   (interactive)
   (require 'org-publish)
   (let ((all (or (org-publish-get-project-from-filename buffer-file-name))))
@@ -600,10 +585,11 @@ most of the work."
 
 (defun org-protocol-create (&optional project-plist)
   "Create a new org-protocol project interactively.
-An org-protocol project is an entry in `org-protocol-project-alist'
-which is used by `org-protocol-open-source'.
-Optionally use project-plist to initialize the defaults for this project.  If
-project-plist is the CDR of an element in `org-publish-project-alist', reuse
+An org-protocol project is an entry in
+`org-protocol-project-alist' which is used by
+`org-protocol-open-source'.  Optionally use PROJECT-PLIST to
+initialize the defaults for this project.  If PROJECT-PLIST is
+the cdr of an element in `org-publish-project-alist', reuse
 :base-directory, :html-extension and :base-extension."
   (interactive)
   (let ((working-dir (expand-file-name
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el
deleted file mode 100644 (file)
index 20c6a68..0000000
+++ /dev/null
@@ -1,1198 +0,0 @@
-;;; org-publish.el --- publish related org-mode files as a website
-;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
-
-;; Author: David O'Toole <dto@gnu.org>
-;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
-;; Keywords: hypermedia, outlines, wp
-
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This program allow configurable publishing of related sets of
-;; Org-mode files as a complete website.
-;;
-;; org-publish.el can do the following:
-;;
-;; + Publish all one's org-files to HTML or PDF
-;; + Upload HTML, images, attachments and other files to a web server
-;; + Exclude selected private pages from publishing
-;; + Publish a clickable sitemap of pages
-;; + Manage local timestamps for publishing only changed files
-;; + Accept plugin functions to extend range of publishable content
-;;
-;; Documentation for publishing is in the manual.
-
-;;; Code:
-
-
-(eval-when-compile
-  (require 'cl))
-(require 'org)
-(require 'org-exp)
-(require 'format-spec)
-
-(eval-and-compile
-  (unless (fboundp 'declare-function)
-    (defmacro declare-function (fn file &optional arglist fileonly))))
-
-(defvar org-publish-initial-buffer nil
-  "The buffer `org-publish' has been called from.")
-
-(defvar org-publish-temp-files nil
-  "Temporary list of files to be published.")
-
-;; Here, so you find the variable right before it's used the first time:
-(defvar org-publish-cache nil
-  "This will cache timestamps and titles for files in publishing projects.
-Blocks could hash sha1 values here.")
-
-(defgroup org-publish nil
-  "Options for publishing a set of Org-mode and related files."
-  :tag "Org Publishing"
-  :group 'org)
-
-(defcustom org-publish-project-alist nil
-  "Association list to control publishing behavior.
-Each element of the alist is a publishing 'project.'  The CAR of
-each element is a string, uniquely identifying the project.  The
-CDR of each element is in one of the following forms:
-
-1. A well-formed property list with an even number of elements, alternating
-   keys and values, specifying parameters for the publishing process.
-
-     (:property value :property value ... )
-
-2. A meta-project definition, specifying of a list of sub-projects:
-
-     (:components (\"project-1\" \"project-2\" ...))
-
-When the CDR of an element of org-publish-project-alist is in
-this second form, the elements of the list after :components are
-taken to be components of the project, which group together files
-requiring different publishing options.  When you publish such a
-project with \\[org-publish], the components all publish.
-
-When a property is given a value in org-publish-project-alist, its
-setting overrides the value of the corresponding user variable
-\(if any) during publishing.  However, options set within a file
-override everything.
-
-Most properties are optional, but some should always be set:
-
-  :base-directory        Directory containing publishing source files
-  :base-extension        Extension (without the dot!) of source files.
-                         This can be a regular expression.  If not given,
-                         \"org\" will be used as default extension.
-  :publishing-directory  Directory (possibly remote) where output
-                         files will be published
-
-The :exclude property may be used to prevent certain files from
-being published.  Its value may be a string or regexp matching
-file names you don't want to be published.
-
-The :include property may be used to include extra files.  Its
-value may be a list of filenames to include.  The filenames are
-considered relative to the base directory.
-
-When both :include and :exclude properties are given values, the
-exclusion step happens first.
-
-One special property controls which back-end function to use for
-publishing files in the project.  This can be used to extend the
-set of file types publishable by org-publish, as well as the set
-of output formats.
-
-  :publishing-function     Function to publish file.  The default is
-                           `org-publish-org-to-html', but other
-                           values are possible.  May also be a
-                           list of functions, in which case
-                           each function in the list is invoked
-                           in turn.
-
-Another property allows you to insert code that prepares a
-project for publishing.  For example, you could call GNU Make on a
-certain makefile, to ensure published files are built up to date.
-
-  :preparation-function   Function to be called before publishing
-                          this project.  This may also be a list
-                          of functions.
-  :completion-function    Function to be called after publishing
-                          this project.  This may also be a list
-                          of functions.
-
-Some properties control details of the Org publishing process,
-and are equivalent to the corresponding user variables listed in
-the right column.  See the documentation for those variables to
-learn more about their use and default values.
-
-  :language              `org-export-default-language'
-  :headline-levels       `org-export-headline-levels'
-  :section-numbers       `org-export-with-section-numbers'
-  :table-of-contents     `org-export-with-toc'
-  :emphasize             `org-export-with-emphasize'
-  :sub-superscript       `org-export-with-sub-superscripts'
-  :TeX-macros            `org-export-with-TeX-macros'
-  :fixed-width           `org-export-with-fixed-width'
-  :tables                `org-export-with-tables'
-  :table-auto-headline   `org-export-highlight-first-table-line'
-  :style                 `org-export-html-style'
-  :convert-org-links     `org-export-html-link-org-files-as-html'
-  :inline-images         `org-export-html-inline-images'
-  :expand-quoted-html    `org-export-html-expand'
-  :timestamp             `org-export-html-with-timestamp'
-  :publishing-directory  `org-export-publishing-directory'
-  :html-preamble         `org-export-html-preamble'
-  :html-postamble        `org-export-html-postamble'
-  :author                `user-full-name'
-  :email                 `user-mail-address'
-
-The following properties may be used to control publishing of a
-sitemap of files or summary page for a given project.
-
-  :auto-sitemap           Whether to publish a sitemap during
-                         `org-publish-current-project' or `org-publish-all'.
-  :sitemap-filename      Filename for output of sitemap.  Defaults
-                         to 'sitemap.org' (which becomes 'sitemap.html').
-  :sitemap-title         Title of sitemap page.  Defaults to name of file.
-  :sitemap-function      Plugin function to use for generation of sitemap.
-                         Defaults to `org-publish-org-sitemap', which
-                         generates a plain list of links to all files
-                         in the project.
-  :sitemap-style         Can be `list' (sitemap is just an itemized list
-                         of the titles of the files involved) or
-                         `tree' (the directory structure of the source
-                         files is reflected in the sitemap).  Defaults to
-                         `tree'.
-  :sitemap-sans-extension Remove extension from sitemap's
-                           filenames.  Useful to have cool
-                           URIs (see
-                           http://www.w3.org/Provider/Style/URI).
-                           Defaults to nil.
-
-  If you create a sitemap file, adjust the sorting like this:
-
-  :sitemap-sort-folders    Where folders should appear in the sitemap.
-                           Set this to `first' (default) or `last' to
-                           display folders first or last, respectively.
-                           Any other value will mix files and folders.
-  :sitemap-sort-files      The site map is normally sorted alphabetically.
-                           You can change this behaviour setting this to
-                           `chronologically', `anti-chronologically' or nil.
-  :sitemap-ignore-case     Should sorting be case-sensitive?  Default nil.
-
-The following properties control the creation of a concept index.
-
-  :makeindex             Create a concept index.
-
-Other properties affecting publication.
-
-  :body-only              Set this to 't' to publish only the body of the
-                         documents, excluding everything outside and
-                         including the <body> tags in HTML, or
-                         \begin{document}..\end{document} in LaTeX."
-  :group 'org-publish
-  :type 'alist)
-
-(defcustom org-publish-use-timestamps-flag t
-  "Non-nil means use timestamp checking to publish only changed files.
-When nil, do no timestamp checking and always publish all files."
-  :group 'org-publish
-  :type 'boolean)
-
-(defcustom org-publish-timestamp-directory (convert-standard-filename
-                                           "~/.org-timestamps/")
-  "Name of directory in which to store publishing timestamps."
-  :group 'org-publish
-  :type 'directory)
-
-(defcustom org-publish-list-skipped-files t
-  "Non-nil means show message about files *not* published."
-  :group 'org-publish
-  :type 'boolean)
-
-(defcustom org-publish-before-export-hook nil
-  "Hook run before export on the Org file.
-The hook may modify the file in arbitrary ways before publishing happens.
-The original version of the buffer will be restored after publishing."
-  :group 'org-publish
-  :type 'hook)
-
-(defcustom org-publish-after-export-hook nil
-  "Hook run after export on the exported buffer.
-Any changes made by this hook will be saved."
-  :group 'org-publish
-  :type 'hook)
-
-(defcustom org-publish-sitemap-sort-files 'alphabetically
-  "How sitemaps files should be sorted by default?
-Possible values are `alphabetically', `chronologically', `anti-chronologically' and nil.
-If `alphabetically', files will be sorted alphabetically.
-If `chronologically', files will be sorted with older modification time first.
-If `anti-chronologically', files will be sorted with newer modification time first.
-nil won't sort files.
-
-You can overwrite this default per project in your
-`org-publish-project-alist', using `:sitemap-sort-files'."
-  :group 'org-publish
-  :version "24.1"
-  :type 'symbol)
-
-(defcustom org-publish-sitemap-sort-folders 'first
-  "A symbol, denoting if folders are sorted first in sitemaps.
-Possible values are `first', `last', and nil.
-If `first', folders will be sorted before files.
-If `last', folders are sorted to the end after the files.
-Any other value will not mix files and folders.
-
-You can overwrite this default per project in your
-`org-publish-project-alist', using `:sitemap-sort-folders'."
-  :group 'org-publish
-  :version "24.1"
-  :type 'symbol)
-
-(defcustom org-publish-sitemap-sort-ignore-case nil
-  "Sort sitemaps case insensitively by default?
-
-You can overwrite this default per project in your
-`org-publish-project-alist', using `:sitemap-ignore-case'."
-  :group 'org-publish
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-publish-sitemap-date-format "%Y-%m-%d"
-  "Format for `format-time-string' which is used to print a date
-in the sitemap."
-  :group 'org-publish
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-publish-sitemap-file-entry-format "%t"
-  "How a sitemap file entry is formatted.
-You could use brackets to delimit on what part the link will be.
-
-%t is the title.
-%a is the author.
-%d is the date formatted using `org-publish-sitemap-date-format'."
-  :group 'org-publish
-  :version "24.1"
-  :type 'string)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Sanitize-plist (FIXME why?)
-
-(defun org-publish-sanitize-plist (plist)
-  ;; FIXME document
-  (mapcar (lambda (x)
-           (or (cdr (assq x '((:index-filename . :sitemap-filename)
-                              (:index-title . :sitemap-title)
-                              (:index-function . :sitemap-function)
-                              (:index-style . :sitemap-style)
-                              (:auto-index . :auto-sitemap))))
-               x))
-         plist))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Timestamp-related functions
-
-(defun org-publish-timestamp-filename (filename &optional pub-dir pub-func)
-  "Return path to timestamp file for filename FILENAME."
-  (setq filename (concat filename "::" (or pub-dir "") "::"
-                        (format "%s" (or pub-func ""))))
-  (concat "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
-
-(defun org-publish-needed-p (filename &optional pub-dir pub-func true-pub-dir base-dir)
-  "Return t if FILENAME should be published in PUB-DIR using PUB-FUNC.
-TRUE-PUB-DIR is where the file will truly end up.  Currently we are not using
-this - maybe it can eventually be used to check if the file is present at
-the target location, and how old it is.  Right now we cannot do this, because
-we do not know under what file name the file will be stored - the publishing
-function can still decide about that independently."
-  (let ((rtn
-        (if org-publish-use-timestamps-flag
-            (org-publish-cache-file-needs-publishing
-             filename pub-dir pub-func base-dir)
-          ;; don't use timestamps, always return t
-          t)))
-    (if rtn
-       (message "Publishing file %s using `%s'" filename pub-func)
-      (when org-publish-list-skipped-files
-       (message   "Skipping unmodified file %s" filename)))
-    rtn))
-
-(defun org-publish-update-timestamp (filename &optional pub-dir pub-func base-dir)
-  "Update publishing timestamp for file FILENAME.
-If there is no timestamp, create one."
-  (let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
-       (stamp (org-publish-cache-ctime-of-src filename)))
-    (org-publish-cache-set key stamp)))
-
-(defun org-publish-remove-all-timestamps ()
-  "Remove all files in the timestamp directory."
-  (let ((dir org-publish-timestamp-directory)
-       files)
-    (when (and (file-exists-p dir)
-              (file-directory-p dir))
-      (mapc 'delete-file (directory-files dir 'full "[^.]\\'"))
-      (org-publish-reset-cache))))
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Compatibility aliases
-
-;; Delete-dups is not in Emacs <22
-(if (fboundp 'delete-dups)
-    (defalias 'org-publish-delete-dups 'delete-dups)
-  (defun org-publish-delete-dups (list)
-    "Destructively remove `equal' duplicates from LIST.
-Store the result in LIST and return it.  LIST must be a proper list.
-Of several `equal' occurrences of an element in LIST, the first
-one is kept.
-
-This is a compatibility function for Emacsen without `delete-dups'."
-    ;; Code from `subr.el' in Emacs 22:
-    (let ((tail list))
-      (while tail
-       (setcdr tail (delete (car tail) (cdr tail)))
-       (setq tail (cdr tail))))
-    list))
-
-(declare-function org-publish-delete-dups "org-publish" (list))
-(declare-function find-lisp-find-files "find-lisp" (directory regexp))
-(declare-function org-pop-to-buffer-same-window
-                 "org-compat" (&optional buffer-or-name norecord label))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Getting project information out of org-publish-project-alist
-
-(defun org-publish-expand-projects (projects-alist)
-  "Expand projects in PROJECTS-ALIST.
-This splices all the components into the list."
-  (let ((rest projects-alist) rtn p components)
-    (while (setq p (pop rest))
-      (if (setq components (plist-get (cdr p) :components))
-         (setq rest (append
-                     (mapcar (lambda (x) (assoc x org-publish-project-alist))
-                             components)
-                     rest))
-       (push p rtn)))
-    (nreverse (org-publish-delete-dups (delq nil rtn)))))
-
-(defvar org-sitemap-sort-files)
-(defvar org-sitemap-sort-folders)
-(defvar org-sitemap-ignore-case)
-(defvar org-sitemap-requested)
-(defvar org-sitemap-date-format)
-(defvar org-sitemap-file-entry-format)
-(defun org-publish-compare-directory-files (a b)
-  "Predicate for `sort', that sorts folders and files for sitemap."
-  (let ((retval t))
-    (when (or org-sitemap-sort-files org-sitemap-sort-folders)
-      ;; First we sort files:
-      (when org-sitemap-sort-files
-       (cond ((equal org-sitemap-sort-files 'alphabetically)
-              (let* ((adir (file-directory-p a))
-                     (aorg (and (string-match "\\.org$" a) (not adir)))
-                     (bdir (file-directory-p b))
-                     (borg (and (string-match "\\.org$" b) (not bdir)))
-                     (A (if aorg
-                            (concat (file-name-directory a)
-                                    (org-publish-find-title a)) a))
-                     (B (if borg
-                            (concat (file-name-directory b)
-                                    (org-publish-find-title b)) b)))
-                (setq retval (if org-sitemap-ignore-case
-                                 (not (string-lessp (upcase B) (upcase A)))
-                               (not (string-lessp B A))))))
-             ((or (equal org-sitemap-sort-files 'chronologically)
-                  (equal org-sitemap-sort-files 'anti-chronologically))
-              (let* ((adate (org-publish-find-date a))
-                     (bdate (org-publish-find-date b))
-                     (A (+ (lsh (car adate) 16) (cadr adate)))
-                     (B (+ (lsh (car bdate) 16) (cadr bdate))))
-                (setq retval (if (equal org-sitemap-sort-files 'chronologically)
-                                 (<= A B)
-                               (>= A B)))))))
-      ;; Directory-wise wins:
-      (when org-sitemap-sort-folders
-        ;; a is directory, b not:
-        (cond
-         ((and (file-directory-p a) (not (file-directory-p b)))
-          (setq retval (equal org-sitemap-sort-folders 'first)))
-        ;; a is not a directory, but b is:
-         ((and (not (file-directory-p a)) (file-directory-p b))
-          (setq retval (equal org-sitemap-sort-folders 'last))))))
-    retval))
-
-(defun org-publish-get-base-files-1 (base-dir &optional recurse match skip-file skip-dir)
-  "Set `org-publish-temp-files' with files from BASE-DIR directory.
-If RECURSE is non-nil, check BASE-DIR recursively.  If MATCH is
-non-nil, restrict this list to the files matching the regexp
-MATCH.  If SKIP-FILE is non-nil, skip file matching the regexp
-SKIP-FILE.  If SKIP-DIR is non-nil, don't check directories
-matching the regexp SKIP-DIR when recursing through BASE-DIR."
-  (mapc (lambda (f)
-         (let ((fd-p (file-directory-p f))
-               (fnd (file-name-nondirectory f)))
-           (if (and fd-p recurse
-                    (not (string-match "^\\.+$" fnd))
-                    (if skip-dir (not (string-match skip-dir fnd)) t))
-               (org-publish-get-base-files-1 f recurse match skip-file skip-dir)
-             (unless (or fd-p ;; this is a directory
-                         (and skip-file (string-match skip-file fnd))
-                         (not (file-exists-p (file-truename f)))
-                         (not (string-match match fnd)))
-
-               (pushnew f org-publish-temp-files)))))
-       (if org-sitemap-requested
-           (sort (directory-files base-dir t (unless recurse match))
-                 'org-publish-compare-directory-files)
-         (directory-files base-dir t (unless recurse match)))))
-
-(defun org-publish-get-base-files (project &optional exclude-regexp)
-  "Return a list of all files in PROJECT.
-If EXCLUDE-REGEXP is set, this will be used to filter out
-matching filenames."
-  (let* ((project-plist (cdr project))
-        (base-dir (file-name-as-directory
-                   (plist-get project-plist :base-directory)))
-        (include-list (plist-get project-plist :include))
-        (recurse (plist-get project-plist :recursive))
-        (extension (or (plist-get project-plist :base-extension) "org"))
-        ;; sitemap-... variables are dynamically scoped for
-        ;; org-publish-compare-directory-files:
-        (org-sitemap-requested
-         (plist-get project-plist :auto-sitemap))
-        (sitemap-filename
-         (or (plist-get project-plist :sitemap-filename)
-             "sitemap.org"))
-        (org-sitemap-sort-folders
-         (if (plist-member project-plist :sitemap-sort-folders)
-             (plist-get project-plist :sitemap-sort-folders)
-           org-publish-sitemap-sort-folders))
-        (org-sitemap-sort-files
-         (cond ((plist-member project-plist :sitemap-sort-files)
-                (plist-get project-plist :sitemap-sort-files))
-               ;; For backward compatibility:
-               ((plist-member project-plist :sitemap-alphabetically)
-                (if (plist-get project-plist :sitemap-alphabetically)
-                    'alphabetically nil))
-               (t org-publish-sitemap-sort-files)))
-        (org-sitemap-ignore-case
-         (if (plist-member project-plist :sitemap-ignore-case)
-             (plist-get project-plist :sitemap-ignore-case)
-           org-publish-sitemap-sort-ignore-case))
-        (match (if (eq extension 'any)
-                    "^[^\\.]"
-                 (concat "^[^\\.].*\\.\\(" extension "\\)$"))))
-    ;; Make sure `org-sitemap-sort-folders' has an accepted value
-    (unless (memq org-sitemap-sort-folders '(first last))
-      (setq org-sitemap-sort-folders nil))
-
-    (setq org-publish-temp-files nil)
-    (if org-sitemap-requested
-       (pushnew (expand-file-name (concat base-dir sitemap-filename))
-                org-publish-temp-files))
-    (org-publish-get-base-files-1 base-dir recurse match
-                                 ;; FIXME distinguish exclude regexp
-                                 ;; for skip-file and skip-dir?
-                                 exclude-regexp exclude-regexp)
-    (mapc (lambda (f)
-           (pushnew
-            (expand-file-name (concat base-dir f))
-            org-publish-temp-files))
-         include-list)
-    org-publish-temp-files))
-
-(defun org-publish-get-project-from-filename (filename &optional up)
-  "Return the project that FILENAME belongs to."
-  (let* ((filename (expand-file-name filename))
-        project-name)
-
-    (catch 'p-found
-      (dolist (prj org-publish-project-alist)
-       (unless (plist-get (cdr prj) :components)
-         ;; [[info:org:Selecting%20files]] shows how this is supposed to work:
-         (let* ((r (plist-get (cdr prj) :recursive))
-                (b (expand-file-name (file-name-as-directory
-                                      (plist-get (cdr prj) :base-directory))))
-                (x (or (plist-get (cdr prj) :base-extension) "org"))
-                (e (plist-get (cdr prj) :exclude))
-                (i (plist-get (cdr prj) :include))
-                (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$")))
-           (when
-               (or
-                (and
-                 i (member filename
-                           (mapcar
-                            (lambda (file) (expand-file-name file b))
-                            i)))
-                (and
-                 (not (and e (string-match e filename)))
-                 (string-match xm filename)))
-             (setq project-name (car prj))
-             (throw 'p-found project-name))))))
-    (when up
-      (dolist (prj org-publish-project-alist)
-       (if (member project-name (plist-get (cdr prj) :components))
-           (setq project-name (car prj)))))
-    (assoc project-name org-publish-project-alist)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Pluggable publishing back-end functions
-
-(defun org-publish-org-to (format plist filename pub-dir)
-  "Publish an org file to FORMAT.
-PLIST is the property list for the given project.
-FILENAME is the filename of the org file to be published.
-PUB-DIR is the publishing directory."
-  (require 'org)
-  (unless (file-exists-p pub-dir)
-    (make-directory pub-dir t))
-  (let ((visiting (find-buffer-visiting filename)))
-    (save-excursion
-      (org-pop-to-buffer-same-window (or visiting (find-file filename)))
-      (let* ((plist (cons :buffer-will-be-killed (cons t plist)))
-            (init-buf (current-buffer))
-            (init-point (point))
-            (init-buf-string (buffer-string))
-            export-buf-or-file)
-       ;; run hooks before exporting
-       (run-hooks 'org-publish-before-export-hook)
-       ;; export the possibly modified buffer
-       (setq export-buf-or-file
-             (funcall (intern (concat "org-export-as-" format))
-                      (plist-get plist :headline-levels)
-                      plist nil
-                      (plist-get plist :body-only)
-                      pub-dir))
-       (when (and (bufferp export-buf-or-file)
-                  (buffer-live-p export-buf-or-file))
-         (set-buffer export-buf-or-file)
-         ;; run hooks after export and save export
-         (progn (run-hooks 'org-publish-after-export-hook)
-                (if (buffer-modified-p) (save-buffer)))
-         (kill-buffer export-buf-or-file))
-       ;; maybe restore buffer's content
-       (set-buffer init-buf)
-       (when (buffer-modified-p init-buf)
-         (erase-buffer)
-         (insert init-buf-string)
-         (save-buffer)
-         (goto-char init-point))
-       (unless visiting
-         (kill-buffer init-buf))))))
-
-(defmacro org-publish-with-aux-preprocess-maybe (&rest body)
-  "Execute BODY with a modified hook to preprocess for index."
-  `(let ((org-export-preprocess-after-headline-targets-hook
-         (if (plist-get project-plist :makeindex)
-             (cons 'org-publish-aux-preprocess
-                   org-export-preprocess-after-headline-targets-hook)
-           org-export-preprocess-after-headline-targets-hook)))
-     ,@body))
-(def-edebug-spec org-publish-with-aux-preprocess-maybe (body))
-
-(defvar project-plist)
-(defun org-publish-org-to-latex (plist filename pub-dir)
-  "Publish an org file to LaTeX.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "latex" plist filename pub-dir)))
-
-(defun org-publish-org-to-pdf (plist filename pub-dir)
-  "Publish an org file to PDF (via LaTeX).
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "pdf" plist filename pub-dir)))
-
-(defun org-publish-org-to-html (plist filename pub-dir)
-  "Publish an org file to HTML.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "html" plist filename pub-dir)))
-
-(defun org-publish-org-to-org (plist filename pub-dir)
-  "Publish an org file to HTML.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-org-to "org" plist filename pub-dir))
-
-(defun org-publish-org-to-ascii (plist filename pub-dir)
-  "Publish an org file to ASCII.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "ascii" plist filename pub-dir)))
-
-(defun org-publish-org-to-latin1 (plist filename pub-dir)
-  "Publish an org file to Latin-1.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "latin1" plist filename pub-dir)))
-
-(defun org-publish-org-to-utf8 (plist filename pub-dir)
-  "Publish an org file to UTF-8.
-See `org-publish-org-to' to the list of arguments."
-  (org-publish-with-aux-preprocess-maybe
-   (org-publish-org-to "utf8" plist filename pub-dir)))
-
-(defun org-publish-attachment (plist filename pub-dir)
-  "Publish a file with no transformation of any kind.
-See `org-publish-org-to' to the list of arguments."
-  ;; make sure eshell/cp code is loaded
-  (unless (file-directory-p pub-dir)
-    (make-directory pub-dir t))
-  (or (equal (expand-file-name (file-name-directory filename))
-            (file-name-as-directory (expand-file-name pub-dir)))
-      (copy-file filename
-                (expand-file-name (file-name-nondirectory filename) pub-dir)
-                t)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Publishing files, sets of files, and indices
-
-(defun org-publish-file (filename &optional project no-cache)
-  "Publish file FILENAME from PROJECT.
-If NO-CACHE is not nil, do not initialize org-publish-cache and
-write it to disk.  This is needed, since this function is used to
-publish single files, when entire projects are published.
-See `org-publish-projects'."
-  (let* ((project
-         (or project
-             (or (org-publish-get-project-from-filename filename)
-                 (error "File %s not part of any known project"
-                        (abbreviate-file-name filename)))))
-        (project-plist (cdr project))
-        (ftname (expand-file-name filename))
-        (publishing-function
-         (or (plist-get project-plist :publishing-function)
-             'org-publish-org-to-html))
-        (base-dir
-         (file-name-as-directory
-          (expand-file-name
-           (or (plist-get project-plist :base-directory)
-               (error "Project %s does not have :base-directory defined"
-                      (car project))))))
-        (pub-dir
-         (file-name-as-directory
-          (file-truename
-           (or (eval (plist-get project-plist :publishing-directory))
-               (error "Project %s does not have :publishing-directory defined"
-                      (car project))))))
-        tmp-pub-dir)
-
-    (unless no-cache
-      (org-publish-initialize-cache (car project)))
-
-    (setq tmp-pub-dir
-         (file-name-directory
-          (concat pub-dir
-                  (and (string-match (regexp-quote base-dir) ftname)
-                       (substring ftname (match-end 0))))))
-    (if (listp publishing-function)
-       ;; allow chain of publishing functions
-       (mapc (lambda (f)
-               (when (org-publish-needed-p filename pub-dir f tmp-pub-dir base-dir)
-                 (funcall f project-plist filename tmp-pub-dir)
-                 (org-publish-update-timestamp filename pub-dir f base-dir)))
-             publishing-function)
-      (when (org-publish-needed-p filename pub-dir publishing-function tmp-pub-dir base-dir)
-       (funcall publishing-function project-plist filename tmp-pub-dir)
-       (org-publish-update-timestamp
-        filename pub-dir publishing-function base-dir)))
-    (unless no-cache (org-publish-write-cache-file))))
-
-(defun org-publish-projects (projects)
-  "Publish all files belonging to the PROJECTS alist.
-If :auto-sitemap is set, publish the sitemap too.
-If :makeindex is set, also produce a file theindex.org."
-  (mapc
-   (lambda (project)
-     ;; Each project uses its own cache file:
-     (org-publish-initialize-cache (car project))
-     (let*
-        ((project-plist (cdr project))
-         (exclude-regexp (plist-get project-plist :exclude))
-         (sitemap-p (plist-get project-plist :auto-sitemap))
-         (sitemap-filename (or (plist-get project-plist :sitemap-filename)
-                               "sitemap.org"))
-         (sitemap-function (or (plist-get project-plist :sitemap-function)
-                               'org-publish-org-sitemap))
-         (org-sitemap-date-format (or (plist-get project-plist :sitemap-date-format)
-                                      org-publish-sitemap-date-format))
-         (org-sitemap-file-entry-format (or (plist-get project-plist :sitemap-file-entry-format)
-                                            org-publish-sitemap-file-entry-format))
-         (preparation-function (plist-get project-plist :preparation-function))
-         (completion-function (plist-get project-plist :completion-function))
-         (files (org-publish-get-base-files project exclude-regexp)) file)
-       (when preparation-function (run-hooks 'preparation-function))
-       (if sitemap-p (funcall sitemap-function project sitemap-filename))
-       (while (setq file (pop files))
-        (org-publish-file file project t))
-       (when (plist-get project-plist :makeindex)
-        (org-publish-index-generate-theindex
-         (plist-get project-plist :base-directory))
-        (org-publish-file (expand-file-name
-                           "theindex.org"
-                           (plist-get project-plist :base-directory))
-                          project t))
-       (when completion-function (run-hooks 'completion-function))
-       (org-publish-write-cache-file)))
-   (org-publish-expand-projects projects)))
-
-(defun org-publish-org-sitemap (project &optional sitemap-filename)
-  "Create a sitemap of pages in set defined by PROJECT.
-Optionally set the filename of the sitemap with SITEMAP-FILENAME.
-Default for SITEMAP-FILENAME is 'sitemap.org'."
-  (let* ((project-plist (cdr project))
-        (dir (file-name-as-directory
-              (plist-get project-plist :base-directory)))
-        (localdir (file-name-directory dir))
-        (indent-str (make-string 2 ?\ ))
-        (exclude-regexp (plist-get project-plist :exclude))
-        (files (nreverse (org-publish-get-base-files project exclude-regexp)))
-        (sitemap-filename (concat dir (or sitemap-filename "sitemap.org")))
-        (sitemap-title (or (plist-get project-plist :sitemap-title)
-                           (concat "Sitemap for project " (car project))))
-        (sitemap-style (or (plist-get project-plist :sitemap-style)
-                           'tree))
-        (sitemap-sans-extension (plist-get project-plist :sitemap-sans-extension))
-        (visiting (find-buffer-visiting sitemap-filename))
-        (ifn (file-name-nondirectory sitemap-filename))
-        file sitemap-buffer)
-    (with-current-buffer (setq sitemap-buffer
-                              (or visiting (find-file sitemap-filename)))
-      (erase-buffer)
-      (insert (concat "#+TITLE: " sitemap-title "\n\n"))
-      (while (setq file (pop files))
-       (let ((fn (file-name-nondirectory file))
-             (link (file-relative-name file dir))
-             (oldlocal localdir))
-         (when sitemap-sans-extension
-           (setq link (file-name-sans-extension link)))
-         ;; sitemap shouldn't list itself
-         (unless (equal (file-truename sitemap-filename)
-                        (file-truename file))
-           (if (eq sitemap-style 'list)
-               (message "Generating list-style sitemap for %s" sitemap-title)
-             (message "Generating tree-style sitemap for %s" sitemap-title)
-             (setq localdir (concat (file-name-as-directory dir)
-                                    (file-name-directory link)))
-             (unless (string= localdir oldlocal)
-               (if (string= localdir dir)
-                   (setq indent-str (make-string 2 ?\ ))
-                 (let ((subdirs
-                        (split-string
-                         (directory-file-name
-                          (file-name-directory
-                           (file-relative-name localdir dir))) "/"))
-                       (subdir "")
-                       (old-subdirs (split-string
-                                     (file-relative-name oldlocal dir) "/")))
-                   (setq indent-str (make-string 2 ?\ ))
-                   (while (string= (car old-subdirs) (car subdirs))
-                     (setq indent-str (concat indent-str (make-string 2 ?\ )))
-                     (pop old-subdirs)
-                     (pop subdirs))
-                   (dolist (d subdirs)
-                     (setq subdir (concat subdir d "/"))
-                     (insert (concat indent-str " + " d "\n"))
-                     (setq indent-str (make-string
-                                       (+ (length indent-str) 2) ?\ )))))))
-           ;; This is common to 'flat and 'tree
-           (let ((entry
-                  (org-publish-format-file-entry org-sitemap-file-entry-format
-                                                 file project-plist))
-                 (regexp "\\(.*\\)\\[\\([^][]+\\)\\]\\(.*\\)"))
-             (cond ((string-match-p regexp entry)
-                    (string-match regexp entry)
-                    (insert (concat indent-str " + " (match-string 1 entry)
-                                    "[[file:" link "]["
-                                    (match-string 2 entry)
-                                    "]]" (match-string 3 entry) "\n")))
-                   (t
-                    (insert (concat indent-str " + [[file:" link "]["
-                                    entry
-                                    "]]\n"))))))))
-      (save-buffer))
-    (or visiting (kill-buffer sitemap-buffer))))
-
-(defun org-publish-format-file-entry (fmt file project-plist)
-  (format-spec fmt
-              `((?t . ,(org-publish-find-title file t))
-                (?d . ,(format-time-string org-sitemap-date-format
-                                           (org-publish-find-date file)))
-                (?a . ,(or (plist-get project-plist :author) user-full-name)))))
-
-(defun org-publish-find-title (file &optional reset)
-  "Find the title of FILE in project."
-  (or
-   (and (not reset) (org-publish-cache-get-file-property file :title nil t))
-   (let* ((visiting (find-buffer-visiting file))
-         (buffer (or visiting (find-file-noselect file)))
-         title)
-     (with-current-buffer buffer
-       (let* ((opt-plist (org-combine-plists (org-default-export-plist)
-                                            (org-infile-export-plist))))
-        (setq title
-              (or (plist-get opt-plist :title)
-                  (and (not
-                        (plist-get opt-plist :skip-before-1st-heading))
-                       (org-export-grab-title-from-buffer))
-                  (file-name-nondirectory (file-name-sans-extension file))))))
-     (unless visiting
-       (kill-buffer buffer))
-     (org-publish-cache-set-file-property file :title title)
-     title)))
-
-(defun org-publish-find-date (file)
-  "Find the date of FILE in project.
-If FILE provides a #+date keyword use it else use the file
-system's modification time.
-
-It returns time in `current-time' format."
-  (let ((visiting (find-buffer-visiting file)))
-    (save-excursion
-      (org-pop-to-buffer-same-window (or visiting (find-file-noselect file nil t)))
-      (let* ((plist (org-infile-export-plist))
-            (date (plist-get plist :date)))
-       (unless visiting
-         (kill-buffer (current-buffer)))
-       (if date
-           (org-time-string-to-time date)
-         (when (file-exists-p file)
-           (nth 5 (file-attributes file))))))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Interactive publishing functions
-
-;;;###autoload
-(defalias 'org-publish-project 'org-publish)
-
-;;;###autoload
-(defun org-publish (project &optional force)
-  "Publish PROJECT."
-  (interactive
-   (list
-    (assoc (org-icompleting-read
-           "Publish project: "
-           org-publish-project-alist nil t)
-          org-publish-project-alist)
-    current-prefix-arg))
-  (setq org-publish-initial-buffer (current-buffer))
-  (save-window-excursion
-    (let* ((org-publish-use-timestamps-flag
-           (if force nil org-publish-use-timestamps-flag)))
-      (org-publish-projects
-       (if (stringp project)
-          ;; If this function is called in batch mode,
-          ;; project is still a string here.
-          (list (assoc project org-publish-project-alist))
-        (list project))))))
-
-;;;###autoload
-(defun org-publish-all (&optional force)
-  "Publish all projects.
-With prefix argument, remove all files in the timestamp
-directory and force publishing all files."
-  (interactive "P")
-  (when force
-    (org-publish-remove-all-timestamps))
-  (save-window-excursion
-    (let ((org-publish-use-timestamps-flag
-          (if force nil org-publish-use-timestamps-flag)))
-      (org-publish-projects org-publish-project-alist))))
-
-;;;###autoload
-(defun org-publish-current-file (&optional force)
-  "Publish the current file.
-With prefix argument, force publish the file."
-  (interactive "P")
-  (save-window-excursion
-    (let ((org-publish-use-timestamps-flag
-          (if force nil org-publish-use-timestamps-flag)))
-      (org-publish-file (buffer-file-name)))))
-
-;;;###autoload
-(defun org-publish-current-project (&optional force)
-  "Publish the project associated with the current file.
-With a prefix argument, force publishing of all files in
-the project."
-  (interactive "P")
-  (save-window-excursion
-    (let ((project (org-publish-get-project-from-filename (buffer-file-name) 'up))
-         (org-publish-use-timestamps-flag
-          (if force nil org-publish-use-timestamps-flag)))
-      (if (not project)
-         (error "File %s is not part of any known project" (buffer-file-name)))
-      ;; FIXME: force is not used here?
-      (org-publish project))))
-
-
-;;; Index generation
-
-(defun org-publish-aux-preprocess ()
-  "Find index entries and write them to an .orgx file."
-  (let ((case-fold-search t)
-       entry index target)
-    (goto-char (point-min))
-    (while
-       (and
-        (re-search-forward "^[ \t]*#\\+index:[ \t]*\\(.*?\\)[ \t]*$" nil t)
-        (> (match-end 1) (match-beginning 1)))
-      (setq entry (match-string 1))
-      (when (eq org-export-current-backend 'latex)
-       (replace-match (format "\\index{%s}" entry) t t))
-      (save-excursion
-       (ignore-errors (org-back-to-heading t))
-       (setq target (get-text-property (point) 'target))
-       (setq target (or (cdr (assoc target org-export-preferred-target-alist))
-                        (cdr (assoc target org-export-id-target-alist))
-                        target ""))
-       (push (cons entry target) index)))
-    (with-temp-file
-       (concat
-        (file-name-directory org-current-export-file) "."
-        (file-name-sans-extension
-         (file-name-nondirectory org-current-export-file)) ".orgx")
-      (dolist (entry (nreverse index))
-       (insert (format "INDEX: (%s) %s\n" (cdr entry) (car entry)))))))
-
-(defun org-publish-index-generate-theindex (directory)
-  "Generate the index from all .orgx files in DIRECTORY."
-  (require 'find-lisp)
-  (let* ((fulldir (file-name-as-directory
-                  (expand-file-name directory)))
-        (full-files (find-lisp-find-files directory "\\.orgx\\'"))
-        (re (concat "\\`" fulldir))
-        (files (mapcar (lambda (f) (if (string-match re f)
-                                       (substring f (match-end 0))
-                                     f))
-                       full-files))
-        (default-directory directory)
-        index origfile buf target entry ibuffer
-        main last-main letter last-letter file sub link tgext)
-    ;; `files' contains the list of relative file names
-    (dolist (file files)
-      (setq origfile
-           (concat (file-name-directory file)
-                   (substring (file-name-nondirectory file) 1 -1)))
-      (setq buf (find-file-noselect file))
-      (with-current-buffer buf
-       (goto-char (point-min))
-       (while (re-search-forward "^INDEX: (\\(.*?\\)) \\(.*\\)" nil t)
-         (setq target (match-string 1)
-               entry (match-string 2))
-         (push (list entry origfile target) index)))
-      (kill-buffer buf))
-    (setq index (sort index (lambda (a b) (string< (downcase (car a))
-                                                  (downcase (car b))))))
-    (setq ibuffer (find-file-noselect (expand-file-name "theindex.inc" directory)))
-    (with-current-buffer ibuffer
-      (erase-buffer)
-      (insert "* Index\n")
-      (setq last-letter nil)
-      (dolist (idx index)
-       (setq entry (car idx) file (nth 1 idx) target (nth 2 idx))
-       (if (and (stringp target) (string-match "\\S-" target))
-           (setq tgext (concat "::#" target))
-         (setq tgext ""))
-       (setq letter (upcase (substring entry 0 1)))
-       (when (not (equal letter last-letter))
-         (insert "** " letter "\n")
-         (setq last-letter letter))
-       (if (string-match "!" entry)
-           (setq main (substring entry 0 (match-beginning 0))
-                 sub (substring entry (match-end 0)))
-         (setq main nil sub nil last-main nil))
-       (when (and main (not (equal main last-main)))
-         (insert "   - " main "\n")
-         (setq last-main main))
-       (setq link (concat "[[file:" file tgext "]"
-                          "[" (or sub entry) "]]"))
-       (if (and main sub)
-           (insert "     - " link "\n")
-         (insert "   - " link "\n")))
-      (save-buffer))
-    (kill-buffer ibuffer)
-    ;; Create theindex.org if it doesn't exist already
-    (let ((index-file (expand-file-name "theindex.org" directory)))
-      (unless (file-exists-p index-file)
-       (setq ibuffer (find-file-noselect index-file))
-       (with-current-buffer ibuffer
-         (erase-buffer)
-         (insert "\n\n#+INCLUDE: \"theindex.inc\"\n\n")
-         (save-buffer))
-       (kill-buffer ibuffer)))))
-
-;; Caching functions:
-
-(defun org-publish-write-cache-file (&optional free-cache)
-  "Write `org-publish-cache' to file.
-If FREE-CACHE, empty the cache."
-  (or org-publish-cache
-      (error "`org-publish-write-cache-file' called, but no cache present"))
-
-  (let ((cache-file (org-publish-cache-get ":cache-file:")))
-    (or cache-file
-       (error "Cannot find cache-file name in `org-publish-write-cache-file'"))
-    (with-temp-file cache-file
-      (let ((print-level nil)
-           (print-length nil))
-       (insert "(setq org-publish-cache (make-hash-table :test 'equal :weakness nil :size 100))\n")
-       (maphash (lambda (k v)
-                  (insert
-                   (format (concat "(puthash %S "
-                                   (if (or (listp v) (symbolp v))
-                                       "'" "")
-                                   "%S org-publish-cache)\n") k v)))
-                org-publish-cache)))
-    (when free-cache (org-publish-reset-cache))))
-
-(defun org-publish-initialize-cache (project-name)
-  "Initialize the projects cache if not initialized yet and return it."
-
-  (or project-name
-      (error "Cannot initialize `org-publish-cache' without projects name in `org-publish-initialize-cache'"))
-
-  (unless (file-exists-p org-publish-timestamp-directory)
-    (make-directory org-publish-timestamp-directory t))
-  (if (not (file-directory-p org-publish-timestamp-directory))
-      (error "Org publish timestamp: %s is not a directory"
-            org-publish-timestamp-directory))
-
-  (unless (and org-publish-cache
-              (string= (org-publish-cache-get ":project:") project-name))
-    (let* ((cache-file (concat
-                       (expand-file-name org-publish-timestamp-directory)
-                       project-name
-                       ".cache"))
-          (cexists (file-exists-p cache-file)))
-
-      (when org-publish-cache
-       (org-publish-reset-cache))
-
-      (if cexists
-         (load-file cache-file)
-       (setq org-publish-cache
-             (make-hash-table :test 'equal :weakness nil :size 100))
-       (org-publish-cache-set ":project:" project-name)
-       (org-publish-cache-set ":cache-file:" cache-file))
-      (unless cexists (org-publish-write-cache-file nil))))
-  org-publish-cache)
-
-(defun org-publish-reset-cache ()
-  "Empty org-publish-cache and reset it nil."
-  (message "%s" "Resetting org-publish-cache")
-  (if (hash-table-p org-publish-cache)
-      (clrhash org-publish-cache))
-  (setq org-publish-cache nil))
-
-(defun org-publish-cache-file-needs-publishing (filename &optional pub-dir pub-func base-dir)
-  "Check the timestamp of the last publishing of FILENAME.
-Return `t', if the file needs publishing.  The function also
-checks if any included files have been more recently published,
-so that the file including them will be republished as well."
-  (or org-publish-cache
-      (error "`org-publish-cache-file-needs-publishing' called, but no cache present"))
-  (let* ((key (org-publish-timestamp-filename filename pub-dir pub-func))
-        (pstamp (org-publish-cache-get key))
-        (visiting (find-buffer-visiting filename))
-        (case-fold-search t)
-        included-files-ctime buf)
-
-    (when (equal (file-name-extension filename) "org")
-      (setq buf (find-file (expand-file-name filename)))
-      (with-current-buffer buf
-       (goto-char (point-min))
-       (while (re-search-forward "^#\\+include:[ \t]+\"\\([^\t\n\r\"]*\\)\"[ \t]*.*$" nil t)
-         (let* ((included-file (expand-file-name (match-string 1))))
-           (add-to-list 'included-files-ctime
-                        (org-publish-cache-ctime-of-src included-file) t))))
-      ;; FIXME don't kill current buffer
-      (unless visiting (kill-buffer buf)))
-    (if (null pstamp)
-       t
-      (let ((ctime (org-publish-cache-ctime-of-src filename)))
-       (or (< pstamp ctime)
-           (when included-files-ctime
-             (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
-                                          included-files-ctime))))))))))
-
-(defun org-publish-cache-set-file-property (filename property value &optional project-name)
-  "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
-Use cache file of PROJECT-NAME.  If the entry does not exist, it will be
-created.  Return VALUE."
-  ;; Evtl. load the requested cache file:
-  (if project-name (org-publish-initialize-cache project-name))
-  (let ((pl (org-publish-cache-get filename)))
-    (if pl
-       (progn
-         (plist-put pl property value)
-         value)
-      (org-publish-cache-get-file-property
-       filename property value nil project-name))))
-
-(defun org-publish-cache-get-file-property
-  (filename property &optional default no-create project-name)
-  "Return the value for a PROPERTY of file FILENAME in publishing cache.
-Use cache file of PROJECT-NAME. Return the value of that PROPERTY or
-DEFAULT, if the value does not yet exist.
-If the entry will be created, unless NO-CREATE is not nil."
-  ;; Evtl. load the requested cache file:
-  (if project-name (org-publish-initialize-cache project-name))
-  (let ((pl (org-publish-cache-get filename))
-       (retval nil))
-    (if pl
-       (if (plist-member pl property)
-           (setq retval (plist-get pl property))
-         (setq retval default))
-      ;; no pl yet:
-      (unless no-create
-       (org-publish-cache-set filename (list property default)))
-      (setq retval default))
-    retval))
-
-(defun org-publish-cache-get (key)
-  "Return the value stored in `org-publish-cache' for key KEY.
-Returns nil, if no value or nil is found, or the cache does not
-exist."
-  (or org-publish-cache
-      (error "`org-publish-cache-get' called, but no cache present"))
-  (gethash key org-publish-cache))
-
-(defun org-publish-cache-set (key value)
-  "Store KEY VALUE pair in `org-publish-cache'.
-Returns value on success, else nil."
-  (or org-publish-cache
-      (error "`org-publish-cache-set' called, but no cache present"))
-  (puthash key value org-publish-cache))
-
-(defun org-publish-cache-ctime-of-src (file)
-  "Get the ctime of filename F as an integer."
-  (let ((attr (file-attributes
-              (expand-file-name (or (file-symlink-p file) file)
-                                (file-name-directory file)))))
-    (+ (lsh (car (nth 5 attr)) 16)
-       (cadr (nth 5 attr)))))
-
-(provide 'org-publish)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-publish.el ends here
diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el
deleted file mode 100644 (file)
index cb1fdbb..0000000
+++ /dev/null
@@ -1,1156 +0,0 @@
-;;; org-remember.el --- Fast note taking in Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file contains the system to take fast notes with Org-mode.
-;; This system is used together with John Wiegley's `remember.el'.
-
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-(require 'org)
-(require 'org-compat)
-(require 'org-datetree)
-
-(declare-function remember-mode "remember" ())
-(declare-function remember "remember" (&optional initial))
-(declare-function remember-buffer-desc "remember" ())
-(declare-function remember-finalize "remember" ())
-(declare-function org-pop-to-buffer-same-window
-                 "org-compat" (&optional buffer-or-name norecord label))
-
-(defvar remember-save-after-remembering)
-(defvar remember-register)
-(defvar remember-buffer)
-(defvar remember-handler-functions)
-(defvar remember-annotation-functions)
-(defvar org-clock-heading)
-(defvar org-clock-heading-for-remember)
-
-(defgroup org-remember nil
-  "Options concerning interaction with remember.el."
-  :tag "Org Remember"
-  :group 'org)
-
-(defcustom org-remember-store-without-prompt t
-  "Non-nil means \\<org-remember-mode-map>\\[org-remember-finalize] \
-stores the remember note without further prompts.
-It then uses the file and headline specified by the template or (if the
-template does not specify them) by the variables `org-default-notes-file'
-and `org-remember-default-headline'.  To force prompting anyway, use
-\\[universal-argument] \\[org-remember-finalize] to file the note.
-
-When this variable is nil, \\[org-remember-finalize] gives you the prompts, and
-\\[universal-argument] \\[org-remember-finalize] triggers the fast track."
-  :group 'org-remember
-  :type 'boolean)
-
-(defcustom org-remember-interactive-interface 'refile
-  "The interface to be used for interactive filing of remember notes.
-This is only used when the interactive mode for selecting a filing
-location is used (see the variable `org-remember-store-without-prompt').
-Allowed values are:
-outline                  The interface shows an outline of the relevant file
-                         and the correct heading is found by moving through
-                         the outline or by searching with incremental search.
-outline-path-completion  Headlines in the current buffer are offered via
-                         completion.
-refile                   Use the refile interface, and offer headlines,
-                         possibly from different buffers."
-  :group 'org-remember
-  :type '(choice
-         (const :tag "Refile" refile)
-         (const :tag "Outline" outline)
-         (const :tag "Outline-path-completion" outline-path-completion)))
-
-(defcustom org-remember-default-headline ""
-  "The headline that should be the default location in the notes file.
-When filing remember notes, the cursor will start at that position.
-You can set this on a per-template basis with the variable
-`org-remember-templates'."
-  :group 'org-remember
-  :type 'string)
-
-(defcustom org-remember-templates nil
-  "Templates for the creation of remember buffers.
-When nil, just let remember make the buffer.
-When non-nil, this is a list of (up to) 6-element lists.  In each entry,
-the first element is the name of the template, which should be a single
-short word.  The second element is a character, a unique key to select
-this template.  The third element is the template.
-
-The fourth element is optional and can specify a destination file for
-remember items created with this template.  The default file is given
-by `org-default-notes-file'.  If the file name is not an absolute path,
-it will be interpreted relative to `org-directory'.
-
-An optional fifth element can specify the headline in that file that should
-be offered first when the user is asked to file the entry.  The default
-headline is given in the variable `org-remember-default-headline'.  When
-this element is `top' or `bottom', the note will be placed as a level-1
-entry at the beginning or end of the file, respectively.
-
-An optional sixth element specifies the contexts in which the template
-will be offered to the user.  This element can be a list of major modes
-or a function, and the template will only be offered if `org-remember'
-is called from a mode in the list, or if the function returns t.
-Templates that specify t or nil for the context will always be added
-to the list of selectable templates.
-
-The template specifies the structure of the remember buffer.  It should have
-a first line starting with a star, to act as the org-mode headline.
-Furthermore, the following %-escapes will be replaced with content:
-
-  %^{PROMPT}  prompt the user for a string and replace this sequence with it.
-              A default value and a completion table can be specified like this:
-              %^{prompt|default|completion2|completion3|...}
-              The arrow keys access a prompt-specific history.
-  %a          annotation, normally the link created with `org-store-link'
-  %A          like %a, but prompt for the description part
-  %i          initial content, copied from the active region.  If %i is
-              indented, the entire inserted text will be indented as well.
-  %t          time stamp, date only
-  %T          time stamp with date and time
-  %u, %U      like the above, but inactive time stamps
-  %^t         like %t, but prompt for date.  Similarly %^T, %^u, %^U.
-              You may define a prompt like %^{Please specify birthday}t
-  %n          user name (taken from `user-full-name')
-  %c          current kill ring head
-  %x          content of the X clipboard
-  %:keyword   specific information for certain link types, see below
-  %^C         interactive selection of which kill or clip to use
-  %^L         like %^C, but insert as link
-  %k          title of the currently clocked task
-  %K          link to the currently clocked task
-  %^g         prompt for tags, completing tags in the target file
-  %^G         prompt for tags, completing all tags in all agenda files
-  %^{PROP}p   Prompt the user for a value for property PROP
-  %[PATHNAME] insert the contents of the file given by PATHNAME
-  %(SEXP)     evaluate elisp `(SEXP)' and replace with the result
-  %!          store this note immediately after completing the template\
-              \\<org-remember-mode-map>
-              (skipping the \\[org-remember-finalize] that normally triggers storing)
-  %&          jump to target location immediately after storing note
-  %?          after completing the template, position cursor here.
-
-Apart from these general escapes, you can access information specific to the
-link type that is created.  For example, calling `remember' in emails or gnus
-will record the author and the subject of the message, which you can access
-with %:fromname and %:subject, respectively.  Here is a complete list of what
-is recorded for each link type.
-
-Link type          |  Available information
--------------------+------------------------------------------------------
-bbdb               |  %:type %:name %:company
-vm, wl, mh, rmail  |  %:type %:subject %:message-id
-                   |  %:from %:fromname %:fromaddress
-                   |  %:to   %:toname   %:toaddress
-                   |  %:fromto (either \"to NAME\" or \"from NAME\")
-gnus               |  %:group, for messages also all email fields and
-                   |  %:org-date (the Date: header in Org format)
-w3, w3m            |  %:type %:url
-info               |  %:type %:file %:node
-calendar           |  %:type %:date"
-  :group 'org-remember
-  :get (lambda (var) ; Make sure all entries have at least 5 elements
-        (mapcar (lambda (x)
-                  (if (not (stringp (car x))) (setq x (cons "" x)))
-                  (cond ((= (length x) 4) (append x '(nil)))
-                        ((= (length x) 3) (append x '(nil nil)))
-                        (t x)))
-                (default-value var)))
-  :type '(repeat
-         :tag "enabled"
-         (list :value ("" ?a "\n" nil nil nil)
-               (string :tag "Name")
-               (character :tag "Selection Key")
-               (string :tag "Template")
-               (choice :tag "Destination file"
-                       (file :tag "Specify")
-                       (function :tag "Function")
-                       (const :tag "Use `org-default-notes-file'" nil))
-               (choice :tag "Destin. headline"
-                       (string :tag "Specify")
-                       (function :tag "Function")
-                       (const :tag "Use `org-remember-default-headline'" nil)
-                       (const :tag "At beginning of file" top)
-                       (const :tag "At end of file" bottom)
-                       (const :tag "In a date tree" date-tree))
-               (choice :tag "Context"
-                       (const :tag "Use in all contexts" nil)
-                       (const :tag "Use in all contexts" t)
-                       (repeat :tag "Use only if in major mode"
-                               (symbol :tag "Major mode"))
-                       (function :tag "Perform a check against function")))))
-
-(defcustom org-remember-delete-empty-lines-at-end t
-  "Non-nil means clean up final empty lines in remember buffer."
-  :group 'org-remember
-  :type 'boolean)
-
-(defcustom org-remember-before-finalize-hook nil
-  "Hook that is run right before a remember process is finalized.
-The remember buffer is still current when this hook runs."
-  :group 'org-remember
-  :type 'hook)
-
-(defvar org-remember-mode-map (make-sparse-keymap)
-  "Keymap for `org-remember-mode', a minor mode.
-Use this map to set additional keybindings for when Org-mode is used
-for a Remember buffer.")
-(defvar org-remember-mode-hook nil
-  "Hook for the minor `org-remember-mode'.")
-
-(define-minor-mode org-remember-mode
-  "Minor mode for special key bindings in a remember buffer."
-  nil " Rem" org-remember-mode-map
-  (run-hooks 'org-remember-mode-hook))
-(define-key org-remember-mode-map "\C-c\C-c" 'org-remember-finalize)
-(define-key org-remember-mode-map "\C-c\C-k" 'org-remember-kill)
-
-(defcustom org-remember-clock-out-on-exit 'query
-  "Non-nil means stop the clock when exiting a clocking remember buffer.
-This only applies if the clock is running in the remember buffer.  If the
-clock is not stopped, it continues to run in the storage location.
-Instead of nil or t, this may also be the symbol `query' to prompt the
-user each time a remember buffer with a running clock is filed away."
-  :group 'org-remember
-  :type '(choice
-         (const :tag "Never" nil)
-         (const :tag "Always" t)
-         (const :tag "Query user" query)))
-
-(defcustom org-remember-backup-directory nil
-  "Directory where to store all remember buffers, for backup purposes.
-After a remember buffer has been stored successfully, the backup file
-will be removed.  However, if you forget to finish the remember process,
-the file will remain there.
-See also `org-remember-auto-remove-backup-files'."
-  :group 'org-remember
-  :type '(choice
-         (const :tag "No backups" nil)
-         (directory :tag "Directory")))
-
-(defcustom org-remember-auto-remove-backup-files t
-  "Non-nil means remove remember backup files after successfully storage.
-When remember is finished successfully, with storing the note at the
-desired target, remove the backup files related to this remember process
-and show a message about remaining backup files, from previous, unfinished
-remember sessions.
-Backup files will only be made at all, when `org-remember-backup-directory'
-is set."
-  :group 'org-remember
-  :type 'boolean)
-
-(defcustom org-remember-warn-about-backups t
-  "Non-nil means warn about backup files in `org-remember-backup-directory'.
-
-Set this to nil if you find that you don't need the warning.
-
-If you cancel remember calls frequently and know when they
-contain useful information (because you know that you made an
-error or Emacs crashed, for example) nil is more useful.  In the
-opposite case, the default, t, is more useful."
-  :group 'org-remember
-  :type 'boolean)
-
-;;;###autoload
-(defun org-remember-insinuate ()
-  "Setup remember.el for use with Org-mode."
-  (org-require-remember)
-  (setq remember-annotation-functions '(org-remember-annotation))
-  (setq remember-handler-functions '(org-remember-handler))
-  (add-hook 'remember-mode-hook 'org-remember-apply-template))
-
-;;;###autoload
-(defun org-remember-annotation ()
-  "Return a link to the current location as an annotation for remember.el.
-If you are using Org-mode files as target for data storage with
-remember.el, then the annotations should include a link compatible with the
-conventions in Org-mode.  This function returns such a link."
-  (org-store-link nil))
-
-(defconst org-remember-help
-  "Select a destination location for the note.
-UP/DOWN=headline   TAB=cycle visibility  [Q]uit   RET/<left>/<right>=Store
-RET on headline   -> Store as sublevel entry to current headline
-RET at beg-of-buf -> Append to file as level 2 headline
-<left>/<right>    -> before/after current headline, same headings level")
-
-(defvar org-jump-to-target-location nil)
-(defvar org-remember-previous-location nil)
-(defvar org-remember-reference-date nil)
-(defvar org-force-remember-template-char) ;; dynamically scoped
-
-;; Save the major mode of the buffer we called remember from
-(defvar org-select-template-temp-major-mode nil)
-
-;; Temporary store the buffer where remember was called from
-(defvar org-select-template-original-buffer nil)
-
-(defun org-select-remember-template (&optional use-char)
-  (when org-remember-templates
-    (let* ((pre-selected-templates
-           (mapcar
-            (lambda (tpl)
-              (let ((ctxt (nth 5 tpl))
-                    (mode org-select-template-temp-major-mode)
-                    (buf org-select-template-original-buffer))
-                (and (or (not ctxt) (eq ctxt t)
-                         (and (listp ctxt) (memq mode ctxt))
-                         (and (functionp ctxt)
-                              (with-current-buffer buf
-                                ;; Protect the user-defined function from error
-                                (condition-case nil (funcall ctxt) (error nil)))))
-                     tpl)))
-            org-remember-templates))
-          ;; If no template at this point, add the default templates:
-          (pre-selected-templates1
-           (if (not (delq nil pre-selected-templates))
-               (mapcar (lambda(x) (if (not (nth 5 x)) x))
-                       org-remember-templates)
-             pre-selected-templates))
-          ;; Then unconditionally add template for any contexts
-          (pre-selected-templates2
-           (append (mapcar (lambda(x) (if (eq (nth 5 x) t) x))
-                           org-remember-templates)
-                   (delq nil pre-selected-templates1)))
-          (templates (mapcar (lambda (x)
-                               (if (stringp (car x))
-                                   (append (list (nth 1 x) (car x)) (cddr x))
-                                 (append (list (car x) "") (cdr x))))
-                             (delq nil pre-selected-templates2)))
-          msg
-          (char (or use-char
-                    (cond
-                     ((= (length templates) 1)
-                      (caar templates))
-                     ((and (boundp 'org-force-remember-template-char)
-                           org-force-remember-template-char)
-                      (if (stringp org-force-remember-template-char)
-                          (string-to-char org-force-remember-template-char)
-                        org-force-remember-template-char))
-                     (t
-                      (setq msg (format
-                                 "Select template: %s%s"
-                                 (mapconcat
-                                  (lambda (x)
-                                    (cond
-                                     ((not (string-match "\\S-" (nth 1 x)))
-                                      (format "[%c]" (car x)))
-                                     ((equal (downcase (car x))
-                                             (downcase (aref (nth 1 x) 0)))
-                                      (format "[%c]%s" (car x)
-                                              (substring (nth 1 x) 1)))
-                                     (t (format "[%c]%s" (car x) (nth 1 x)))))
-                                  templates " ")
-                                 (if (assoc ?C templates)
-                                     ""
-                                   " [C]customize templates")))
-                      (let ((inhibit-quit t) char0)
-                        (while (not char0)
-                          (message msg)
-                          (setq char0 (read-char-exclusive))
-                          (when (and (not (assoc char0 templates))
-                                     (not (equal char0 ?\C-g))
-                                     (not (equal char0 ?C)))
-                            (message "No such template \"%c\"" char0)
-                            (ding) (sit-for 1)
-                            (setq char0 nil)))
-                        (when (equal char0 ?\C-g)
-                          (jump-to-register remember-register)
-                          (kill-buffer remember-buffer)
-                          (error "Abort"))
-                        (when (not (assoc char0 templates))
-                          (jump-to-register remember-register)
-                          (kill-buffer remember-buffer)
-                          (customize-variable 'org-remember-templates)
-                          (error "Customize templates"))
-                        char0))))))
-      (cddr (assoc char templates)))))
-
-;;;###autoload
-(defun org-remember-apply-template (&optional use-char skip-interactive)
-  "Initialize *remember* buffer with template, invoke `org-mode'.
-This function should be placed into `remember-mode-hook' and in fact requires
-to be run from that hook to function properly."
-  (when (and (boundp 'initial) (stringp initial))
-    (setq initial (org-no-properties initial)))
-  (if org-remember-templates
-      (let* ((entry (org-select-remember-template use-char))
-            (ct (or org-overriding-default-time (org-current-time)))
-            (dct (decode-time ct))
-            (ct1
-             (if (< (nth 2 dct) org-extend-today-until)
-                 (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
-               ct))
-            (tpl (car entry))
-            (plist-p (if org-store-link-plist t nil))
-            (file (if (and (nth 1 entry)
-                           (or (and (stringp (nth 1 entry))
-                                    (string-match "\\S-" (nth 1 entry)))
-                               (functionp (nth 1 entry))))
-                      (nth 1 entry)
-                    org-default-notes-file))
-            (headline (nth 2 entry))
-            (v-c (and (> (length kill-ring) 0) (current-kill 0)))
-            (v-x (or (org-get-x-clipboard 'PRIMARY)
-                     (org-get-x-clipboard 'CLIPBOARD)
-                     (org-get-x-clipboard 'SECONDARY)))
-            (v-t (format-time-string (car org-time-stamp-formats) ct))
-            (v-T (format-time-string (cdr org-time-stamp-formats) ct))
-            (v-u (concat "[" (substring v-t 1 -1) "]"))
-            (v-U (concat "[" (substring v-T 1 -1) "]"))
-            ;; `initial' and `annotation' are bound in `remember'.
-            ;; But if the property list has them, we prefer those values
-            (v-i (or (plist-get org-store-link-plist :initial)
-                     (and (boundp 'initial) (symbol-value 'initial))
-                     ""))
-            (v-a (or (plist-get org-store-link-plist :annotation)
-                     (and (boundp 'annotation) (symbol-value 'annotation))
-                     ""))
-            ;; Is the link empty?  Then we do not want it...
-            (v-a (if (equal v-a "[[]]") "" v-a))
-            (clipboards (remove nil (list v-i
-                                          (org-get-x-clipboard 'PRIMARY)
-                                          (org-get-x-clipboard 'CLIPBOARD)
-                                          (org-get-x-clipboard 'SECONDARY)
-                                          v-c)))
-            (v-A (if (and v-a
-                          (string-match "\\[\\(\\[.*?\\]\\)\\(\\[.*?\\]\\)?\\]" v-a))
-                     (replace-match "[\\1[%^{Link description}]]" nil nil v-a)
-                   v-a))
-            (v-n user-full-name)
-            (v-k (if (marker-buffer org-clock-marker)
-                     (org-no-properties org-clock-heading)))
-            (v-K (if (marker-buffer org-clock-marker)
-                     (org-make-link-string
-                      (buffer-file-name (marker-buffer org-clock-marker))
-                      org-clock-heading)))
-            v-I
-            (org-startup-folded nil)
-            (org-inhibit-startup t)
-            org-time-was-given org-end-time-was-given x
-            prompt completions char time pos default histvar)
-
-       (when (functionp file)
-         (setq file (funcall file)))
-       (when (functionp headline)
-         (setq headline (funcall headline)))
-       (when (and file (not (file-name-absolute-p file)))
-         (setq file (expand-file-name file org-directory)))
-
-       (setq org-store-link-plist
-             (plist-put org-store-link-plist :annotation v-a)
-             org-store-link-plist
-             (plist-put org-store-link-plist :initial v-i))
-
-       (unless tpl (setq tpl "") (message "No template") (ding) (sit-for 1))
-       (erase-buffer)
-       (insert (substitute-command-keys
-                (format
-                 "# %s  \"%s\" -> \"* %s\"
-# C-u C-c C-c  like C-c C-c, and immediately visit note at target location
-# C-0 C-c C-c  \"%s\" -> \"* %s\"
-# %s  to select file and header location interactively.
-# C-2 C-c C-c  as child (C-3: as sibling) of the currently clocked item
-# To switch templates, use `\\[org-remember]'.  To abort use `C-c C-k'.\n\n"
-                 (if org-remember-store-without-prompt "    C-c C-c" "    C-1 C-c C-c")
-                 (abbreviate-file-name (or file org-default-notes-file))
-                 (or headline "")
-                 (or (car org-remember-previous-location) "???")
-                 (or (cdr org-remember-previous-location) "???")
-                 (if org-remember-store-without-prompt "C-1 C-c C-c" "        C-c C-c"))))
-       (insert tpl)
-
-       ;; %[] Insert contents of a file.
-       (goto-char (point-min))
-       (while (re-search-forward "%\\[\\(.+\\)\\]" nil t)
-         (unless (org-remember-escaped-%)
-           (let ((start (match-beginning 0))
-                 (end (match-end 0))
-                 (filename (expand-file-name (match-string 1))))
-             (goto-char start)
-             (delete-region start end)
-             (condition-case error
-                 (insert-file-contents filename)
-               (error (insert (format "%%![Couldn't insert %s: %s]"
-                                      filename error)))))))
-       ;; Simple %-escapes
-       (goto-char (point-min))
-       (let ((init (and (boundp 'initial)
-                        (symbol-value 'initial))))
-         (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t)
-           (unless (org-remember-escaped-%)
-             (when (and init (equal (match-string 0) "%i"))
-               (save-match-data
-                 (let* ((lead (buffer-substring
-                               (point-at-bol) (match-beginning 0))))
-                   (setq v-i (mapconcat 'identity
-                                        (org-split-string init "\n")
-                                        (concat "\n" lead))))))
-             (replace-match
-              (or (eval (intern (concat "v-" (match-string 1)))) "")
-              t t))))
-
-       ;; %() embedded elisp
-       (goto-char (point-min))
-       (while (re-search-forward "%\\((.+)\\)" nil t)
-         (unless (org-remember-escaped-%)
-           (goto-char (match-beginning 0))
-           (let ((template-start (point)))
-             (forward-char 1)
-             (let ((result
-                    (condition-case error
-                        (eval (read (current-buffer)))
-                      (error (format "%%![Error: %s]" error)))))
-               (delete-region template-start (point))
-               (insert result)))))
-
-       ;; From the property list
-       (when plist-p
-         (goto-char (point-min))
-         (while (re-search-forward "%\\(:[-a-zA-Z]+\\)" nil t)
-           (unless (org-remember-escaped-%)
-             (and (setq x (or (plist-get org-store-link-plist
-                                         (intern (match-string 1))) ""))
-                  (replace-match x t t)))))
-
-       ;; Turn on org-mode in the remember buffer, set local variables
-       (let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1))
-       (if (and file (string-match "\\S-" file) (not (file-directory-p file)))
-           (org-set-local 'org-default-notes-file file))
-       (if headline
-           (org-set-local 'org-remember-default-headline headline))
-       (org-set-local 'org-remember-reference-date
-                      (list (nth 4 dct) (nth 3 dct) (nth 5 dct)))
-       ;; Interactive template entries
-       (goto-char (point-min))
-       (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCLp]\\)?" nil t)
-         (unless (org-remember-escaped-%)
-           (setq char (if (match-end 3) (match-string 3))
-                 prompt (if (match-end 2) (match-string 2)))
-           (goto-char (match-beginning 0))
-           (replace-match "")
-           (setq completions nil default nil)
-           (when prompt
-             (setq completions (org-split-string prompt "|")
-                   prompt (pop completions)
-                   default (car completions)
-                   histvar (intern (concat
-                                    "org-remember-template-prompt-history::"
-                                    (or prompt "")))
-                   completions (mapcar 'list completions)))
-           (cond
-            ((member char '("G" "g"))
-             (let* ((org-last-tags-completion-table
-                     (org-global-tags-completion-table
-                      (if (equal char "G") (org-agenda-files) (and file (list file)))))
-                    (org-add-colon-after-tag-completion t)
-                    (ins (org-icompleting-read
-                          (if prompt (concat prompt ": ") "Tags: ")
-                          'org-tags-completion-function nil nil nil
-                          'org-tags-history)))
-               (setq ins (mapconcat 'identity
-                                    (org-split-string ins (org-re "[^[:alnum:]_@#%]+"))
-                                    ":"))
-               (when (string-match "\\S-" ins)
-                 (or (equal (char-before) ?:) (insert ":"))
-                 (insert ins)
-                 (or (equal (char-after) ?:) (insert ":")))))
-            ((equal char "C")
-             (cond ((= (length clipboards) 1) (insert (car clipboards)))
-                   ((> (length clipboards) 1)
-                    (insert (read-string "Clipboard/kill value: "
-                                         (car clipboards) '(clipboards . 1)
-                                         (car clipboards))))))
-            ((equal char "L")
-             (cond ((= (length clipboards) 1)
-                    (org-insert-link 0 (car clipboards)))
-                   ((> (length clipboards) 1)
-                    (org-insert-link 0 (read-string "Clipboard/kill value: "
-                                                    (car clipboards)
-                                                    '(clipboards . 1)
-                                                    (car clipboards))))))
-            ((equal char "p")
-             (let*
-                 ((prop (org-no-properties prompt))
-                  (pall (concat prop "_ALL"))
-                  (allowed
-                   (with-current-buffer
-                       (or (find-buffer-visiting file)
-                           (find-file-noselect file))
-                     (or (cdr (assoc pall org-file-properties))
-                         (cdr (assoc pall org-global-properties))
-                         (cdr (assoc pall org-global-properties-fixed)))))
-                  (existing (with-current-buffer
-                                (or (find-buffer-visiting file)
-                                    (find-file-noselect file))
-                              (mapcar 'list (org-property-values prop))))
-                  (propprompt (concat "Value for " prop ": "))
-                  (val (if allowed
-                           (org-completing-read
-                            propprompt
-                            (mapcar 'list (org-split-string allowed "[ \t]+"))
-                            nil 'req-match)
-                         (org-completing-read-no-i propprompt existing nil nil
-                                                   "" nil ""))))
-               (org-set-property prop val)))
-            (char
-             ;; These are the date/time related ones
-             (setq org-time-was-given (equal (upcase char) char))
-             (setq time (org-read-date (equal (upcase char) "U") t nil
-                                       prompt))
-             (org-insert-time-stamp time org-time-was-given
-                                    (member char '("u" "U"))
-                                    nil nil (list org-end-time-was-given)))
-            (t
-             (let (org-completion-use-ido)
-               (insert (org-without-partial-completion
-                        (org-completing-read-no-i
-                         (concat (if prompt prompt "Enter string")
-                                 (if default (concat " [" default "]"))
-                                 ": ")
-                         completions nil nil nil histvar default))))))))
-
-       (goto-char (point-min))
-       (if (re-search-forward "%\\?" nil t)
-           (replace-match "")
-         (and (re-search-forward "^[^#\n]" nil t) (backward-char 1))))
-    (let ((org-inhibit-startup t)) (org-mode) (org-remember-mode 1)))
-  (when (save-excursion
-         (goto-char (point-min))
-         (re-search-forward "%&" nil t))
-    (replace-match "")
-    (org-set-local 'org-jump-to-target-location t))
-  (when org-remember-backup-directory
-    (unless (file-directory-p org-remember-backup-directory)
-      (make-directory org-remember-backup-directory))
-    (org-set-local 'auto-save-file-name-transforms nil)
-    (setq buffer-file-name
-         (expand-file-name
-          (format-time-string "remember-%Y-%m-%d-%H-%M-%S")
-          org-remember-backup-directory))
-    (save-buffer)
-    (org-set-local 'auto-save-visited-file-name t)
-    (auto-save-mode 1))
-  (when (save-excursion
-         (goto-char (point-min))
-         (re-search-forward "%!" nil t))
-    (replace-match "")
-    (add-hook 'post-command-hook 'org-remember-finish-immediately 'append)))
-
-(defun org-remember-escaped-% ()
-  (if (equal (char-before (match-beginning 0)) ?\\)
-      (progn
-       (delete-region (1- (match-beginning 0)) (match-beginning 0))
-       t)
-    nil))
-
-
-(defun org-remember-finish-immediately ()
-  "File remember note immediately.
-This should be run in `post-command-hook' and will remove itself
-from that hook."
-  (remove-hook 'post-command-hook 'org-remember-finish-immediately)
-  (org-remember-finalize))
-
-(defun org-remember-visit-immediately ()
-  "File remember note immediately.
-This should be run in `post-command-hook' and will remove itself
-from that hook."
-  (org-remember '(16))
-  (goto-char (or (text-property-any
-                 (point) (save-excursion (org-end-of-subtree t t))
-                 'org-position-cursor t)
-                (point)))
-  (message "%s"
-          (format
-           (substitute-command-keys
-            "Restore window configuration with \\[jump-to-register] %c")
-           remember-register)))
-
-(defvar org-clock-marker) ; Defined in org.el
-(defun org-remember-finalize ()
-  "Finalize the remember process."
-  (interactive)
-  (unless org-remember-mode
-    (error "This does not seem to be a remember buffer for Org-mode"))
-  (run-hooks 'org-remember-before-finalize-hook)
-  (unless (fboundp 'remember-finalize)
-    (defalias 'remember-finalize 'remember-buffer))
-  (when (and org-clock-marker
-            (equal (marker-buffer org-clock-marker) (current-buffer)))
-    ;; the clock is running in this buffer.
-    (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
-              (or (eq org-remember-clock-out-on-exit t)
-                  (and org-remember-clock-out-on-exit
-                       (y-or-n-p "The clock is running in this buffer.  Clock out now? "))))
-      (let (org-log-note-clock-out) (org-clock-out))))
-  (when buffer-file-name
-    (do-auto-save))
-  (remember-finalize))
-
-(defun org-remember-kill ()
-  "Abort the current remember process."
-  (interactive)
-  (let ((org-note-abort t))
-    (org-remember-finalize)))
-
-;;;###autoload
-(defun org-remember (&optional goto org-force-remember-template-char)
-  "Call `remember'.  If this is already a remember buffer, re-apply template.
-If there is an active region, make sure remember uses it as initial content
-of the remember buffer.
-
-When called interactively with a \\[universal-argument] \
-prefix argument GOTO, don't remember
-anything, just go to the file/headline where the selected template usually
-stores its notes.  With a double prefix argument \
-\\[universal-argument] \\[universal-argument], go to the last
-note stored by remember.
-
-Lisp programs can set ORG-FORCE-REMEMBER-TEMPLATE-CHAR to a character
-associated with a template in `org-remember-templates'."
-  (interactive "P")
-  (org-require-remember)
-  (cond
-   ((equal goto '(4)) (org-go-to-remember-target))
-   ((equal goto '(16)) (org-remember-goto-last-stored))
-   (t
-    ;; set temporary variables that will be needed in
-    ;; `org-select-remember-template'
-    (setq org-select-template-temp-major-mode major-mode)
-    (setq org-select-template-original-buffer (current-buffer))
-    (if org-remember-mode
-       (progn
-         (when (< (length org-remember-templates) 2)
-           (error "No other template available"))
-         (erase-buffer)
-         (let ((annotation (plist-get org-store-link-plist :annotation))
-               (initial (plist-get org-store-link-plist :initial)))
-           (org-remember-apply-template))
-         (message "Press C-c C-c to remember data"))
-      (if (org-region-active-p)
-         (org-do-remember (buffer-substring (point) (mark)))
-       (org-do-remember))))))
-
-(defvar org-remember-last-stored-marker (make-marker)
-  "Marker pointing to the entry most recently stored with `org-remember'.")
-
-(defun org-remember-goto-last-stored ()
-  "Go to the location where the last remember note was stored."
-  (interactive)
-  (org-goto-marker-or-bmk org-remember-last-stored-marker
-                         "org-remember-last-stored")
-  (message "This is the last note stored by remember"))
-
-(defun org-go-to-remember-target (&optional template-key)
-  "Go to the target location of a remember template.
-The user is queried for the template."
-  (interactive)
-  (let* (org-select-template-temp-major-mode
-        (entry (org-select-remember-template template-key))
-        (file (nth 1 entry))
-        (heading (nth 2 entry))
-        visiting)
-    (unless (and file (stringp file) (string-match "\\S-" file))
-      (setq file org-default-notes-file))
-    (when (and file (not (file-name-absolute-p file)))
-      (setq file (expand-file-name file org-directory)))
-    (unless (and heading (stringp heading) (string-match "\\S-" heading))
-      (setq heading org-remember-default-headline))
-    (setq visiting (org-find-base-buffer-visiting file))
-    (if (not visiting) (find-file-noselect file))
-    (org-pop-to-buffer-same-window (or visiting (get-file-buffer file)))
-    (widen)
-    (goto-char (point-min))
-    (if (re-search-forward
-        (format org-complex-heading-regexp-format (regexp-quote heading))
-        nil t)
-       (goto-char (match-beginning 0))
-      (error "Target headline not found: %s" heading))))
-
-;; FIXME (bzg): let's clean up of final empty lines happen only once
-;; (see the org-remember-delete-empty-lines-at-end option below)
-;;;###autoload
-(defun org-remember-handler ()
-  "Store stuff from remember.el into an org file.
-When the template has specified a file and a headline, the entry is filed
-there, or in the location defined by `org-default-notes-file' and
-`org-remember-default-headline'.
-\\<org-remember-mode-map>
-If no defaults have been defined, or if the current prefix argument
-is 1 (using C-1 \\[org-remember-finalize] to exit remember), an interactive
-process is used to select the target location.
-
-When the prefix is 0 (i.e. when remember is exited with \
-C-0 \\[org-remember-finalize]),
-the entry is filed to the same location as the previous note.
-
-When the prefix is 2 (i.e. when remember is exited with \
-C-2 \\[org-remember-finalize]),
-the entry is filed as a subentry of the entry where the clock is
-currently running.
-
-When \\[universal-argument] has been used as prefix argument, the
-note is stored and Emacs moves point to the new location of the
-note, so that editing can be continued there (similar to
-inserting \"%&\" into the template).
-
-Before storing the note, the function ensures that the text has an
-org-mode-style headline, i.e. a first line that starts with
-a \"*\".  If not, a headline is constructed from the current date and
-some additional data.
-
-If the variable `org-adapt-indentation' is non-nil, the entire text is
-also indented so that it starts in the same column as the headline
-\(i.e. after the stars).
-
-See also the variable `org-reverse-note-order'."
-  (when (and (equal current-prefix-arg 2)
-            (not (marker-buffer org-clock-marker)))
-    (error "No running clock"))
-  (when (org-bound-and-true-p org-jump-to-target-location)
-    (let* ((end (min (point-max) (1+ (point))))
-          (beg (point)))
-      (if (= end beg) (setq beg (1- beg)))
-      (put-text-property beg end 'org-position-cursor t)))
-  (goto-char (point-min))
-  (while (looking-at "^[ \t]*\n\\|^# .*\n")
-    (replace-match ""))
-  (when org-remember-delete-empty-lines-at-end
-    (goto-char (point-max))
-    (beginning-of-line 1)
-    (while (and (looking-at "[ \t]*$\\|[ \t]*# .*") (> (point) 1))
-      (delete-region (1- (point)) (point-max))
-      (beginning-of-line 1)))
-  (catch 'quit
-    (if org-note-abort (throw 'quit t))
-    (let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
-          (backup-file
-           (and buffer-file-name
-                (equal (file-name-directory buffer-file-name)
-                       (file-name-as-directory
-                        (expand-file-name org-remember-backup-directory)))
-                (string-match "^remember-[0-9]\\{4\\}"
-                              (file-name-nondirectory buffer-file-name))
-                buffer-file-name))
-
-          (dummy
-           (unless (string-match "\\S-" (buffer-string))
-             (message "Nothing to remember")
-             (and backup-file
-                  (ignore-errors
-                    (delete-file backup-file)
-                    (delete-file (concat backup-file "~"))))
-             (set-buffer-modified-p nil)
-             (throw 'quit t)))
-          (reference-date org-remember-reference-date)
-          (previousp (and (member current-prefix-arg '((16) 0))
-                          org-remember-previous-location))
-          (clockp (equal current-prefix-arg 2))
-          (clocksp (equal current-prefix-arg 3))
-          (fastp (org-xor (equal current-prefix-arg 1)
-                          org-remember-store-without-prompt))
-          (file (cond
-                 (fastp org-default-notes-file)
-                 ((and (eq org-remember-interactive-interface 'refile)
-                       org-refile-targets)
-                  org-default-notes-file)
-                 ((not previousp)
-                  (org-get-org-file))))
-          (heading org-remember-default-headline)
-          (visiting (and file (org-find-base-buffer-visiting file)))
-          (org-startup-folded nil)
-          (org-startup-align-all-tables nil)
-          (org-goto-start-pos 1)
-          spos exitcmd level reversed txt text-before-node-creation)
-      (when (equal current-prefix-arg '(4))
-       (setq visitp t))
-      (when previousp
-       (setq file (car org-remember-previous-location)
-             visiting (and file (org-find-base-buffer-visiting file))
-             heading (cdr org-remember-previous-location)
-             fastp t))
-      (when (or clockp clocksp)
-       (setq file (buffer-file-name (marker-buffer org-clock-marker))
-             visiting (and file (org-find-base-buffer-visiting file))
-             heading org-clock-heading-for-remember
-             fastp t))
-      (setq current-prefix-arg nil)
-      ;; Modify text so that it becomes a nice subtree which can be inserted
-      ;; into an org tree.
-      (when org-remember-delete-empty-lines-at-end
-       (goto-char (point-min))
-       (if (re-search-forward "[ \t\n]+\\'" nil t)
-           ;; remove empty lines at end
-           (replace-match "")))
-      (goto-char (point-min))
-      (setq text-before-node-creation (buffer-string))
-      (unless (looking-at org-outline-regexp)
-       ;; add a headline
-       (insert (concat "* " (current-time-string)
-                       " (" (remember-buffer-desc) ")\n"))
-       (backward-char 1)
-       (when org-adapt-indentation
-         (while (re-search-forward "^" nil t)
-           (insert "  "))))
-      ;; Delete final empty lines
-      (when org-remember-delete-empty-lines-at-end
-       (goto-char (point-min))
-       (if (re-search-forward "\n[ \t]*\n[ \t\n]*\\'" nil t)
-           (replace-match "\n\n")
-         (if (re-search-forward "[ \t\n]*\\'")
-             (replace-match "\n"))))
-      (goto-char (point-min))
-      (setq txt (buffer-string))
-      (org-save-markers-in-region (point-min) (point-max))
-      (set-buffer-modified-p nil)
-      (when (and (eq org-remember-interactive-interface 'refile)
-                (not fastp))
-       (org-refile nil (or visiting (find-file-noselect file)))
-       (and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
-       (save-excursion
-         (bookmark-jump "org-refile-last-stored")
-         (bookmark-set "org-remember-last-stored")
-         (move-marker org-remember-last-stored-marker (point)))
-       (throw 'quit t))
-      ;; Find the file
-      (with-current-buffer (or visiting (find-file-noselect file))
-       (unless (or (derived-mode-p 'org-mode) (member heading '(top bottom)))
-         (error "Target files for notes must be in Org-mode if not filing to top/bottom"))
-       (save-excursion
-         (save-restriction
-           (widen)
-           (setq reversed (org-notes-order-reversed-p))
-
-           ;; Find the default location
-           (when heading
-             (cond
-              ((not (derived-mode-p 'org-mode))
-               (if (eq heading 'top)
-                   (goto-char (point-min))
-                 (goto-char (point-max))
-                 (or (bolp) (newline)))
-               (insert text-before-node-creation)
-               (when remember-save-after-remembering
-                 (save-buffer)
-                 (if (not visiting) (kill-buffer (current-buffer))))
-               (throw 'quit t))
-              ((eq heading 'top)
-               (goto-char (point-min))
-               (or (looking-at org-outline-regexp)
-                   (re-search-forward org-outline-regexp nil t))
-               (setq org-goto-start-pos (or (match-beginning 0) (point-min))))
-              ((eq heading 'bottom)
-               (goto-char (point-max))
-               (or (bolp) (newline))
-               (setq org-goto-start-pos (point)))
-              ((eq heading 'date-tree)
-               (org-datetree-find-date-create reference-date)
-               (setq reversed nil)
-               (setq org-goto-start-pos (point)))
-              ((and (stringp heading) (string-match "\\S-" heading))
-               (goto-char (point-min))
-               (if (re-search-forward
-                    (format org-complex-heading-regexp-format
-                            (regexp-quote heading))
-                    nil t)
-                   (setq org-goto-start-pos (match-beginning 0))
-                 (when fastp
-                   (goto-char (point-max))
-                   (unless (bolp) (newline))
-                   (insert "* " heading "\n")
-                   (setq org-goto-start-pos (point-at-bol 0)))))
-              (t (goto-char (point-min)) (setq org-goto-start-pos (point)
-                                               heading 'top))))
-
-           ;; Ask the User for a location, using the appropriate interface
-           (cond
-            ((and fastp (memq heading '(top bottom)))
-             (setq spos org-goto-start-pos
-                   exitcmd (if (eq heading 'top) 'left nil)))
-            (fastp (setq spos org-goto-start-pos
-                         exitcmd 'return))
-            ((eq org-remember-interactive-interface 'outline)
-             (setq spos (org-get-location (current-buffer)
-                                          org-remember-help)
-                   exitcmd (cdr spos)
-                   spos (car spos)))
-            ((eq org-remember-interactive-interface 'outline-path-completion)
-             (let ((org-refile-targets '((nil . (:maxlevel . 10))))
-                   (org-refile-use-outline-path t))
-               (setq spos (org-refile-get-location "Heading")
-                     exitcmd 'return
-                     spos (nth 3 spos))))
-            (t (error "This should not happen")))
-           (if (not spos) (throw 'quit nil)) ; return nil to show we did
-                                       ; not handle this note
-           (and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
-           (goto-char spos)
-           (cond ((org-at-heading-p t)
-                  (org-back-to-heading t)
-                  (setq level (funcall outline-level))
-                  (cond
-                   ((eq exitcmd 'return)
-                    ;; sublevel of current
-                    (setq org-remember-previous-location
-                          (cons (abbreviate-file-name file)
-                                (org-get-heading 'notags)))
-                    (if reversed
-                        (outline-next-heading)
-                      (org-end-of-subtree t)
-                      (if (not (bolp))
-                          (if (looking-at "[ \t]*\n")
-                              (beginning-of-line 2)
-                            (end-of-line 1)
-                            (insert "\n"))))
-                    (org-paste-subtree (if clocksp
-                                           level
-                                         (org-get-valid-level level 1)) txt)
-                    (and org-auto-align-tags (org-set-tags nil t))
-                    (bookmark-set "org-remember-last-stored")
-                    (move-marker org-remember-last-stored-marker (point)))
-                   ((eq exitcmd 'left)
-                    ;; before current
-                    (org-paste-subtree level txt)
-                    (and org-auto-align-tags (org-set-tags nil t))
-                    (bookmark-set "org-remember-last-stored")
-                    (move-marker org-remember-last-stored-marker (point)))
-                   ((eq exitcmd 'right)
-                    ;; after current
-                    (org-end-of-subtree t)
-                    (org-paste-subtree level txt)
-                    (and org-auto-align-tags (org-set-tags nil t))
-                    (bookmark-set "org-remember-last-stored")
-                    (move-marker org-remember-last-stored-marker (point)))
-                   (t (error "This should not happen"))))
-
-                 ((eq heading 'bottom)
-                  (org-paste-subtree 1 txt)
-                  (and org-auto-align-tags (org-set-tags nil t))
-                  (bookmark-set "org-remember-last-stored")
-                  (move-marker org-remember-last-stored-marker (point)))
-
-                 ((and (bobp) (not reversed))
-                  ;; Put it at the end, one level below level 1
-                  (save-restriction
-                    (widen)
-                    (goto-char (point-max))
-                    (if (not (bolp)) (newline))
-                    (org-paste-subtree (org-get-valid-level 1 1) txt)
-                    (and org-auto-align-tags (org-set-tags nil t))
-                    (bookmark-set "org-remember-last-stored")
-                    (move-marker org-remember-last-stored-marker (point))))
-
-                 ((and (bobp) reversed)
-                  ;; Put it at the start, as level 1
-                  (save-restriction
-                    (widen)
-                    (goto-char (point-min))
-                    (re-search-forward org-outline-regexp-bol nil t)
-                    (beginning-of-line 1)
-                    (org-paste-subtree 1 txt)
-                    (and org-auto-align-tags (org-set-tags nil t))
-                    (bookmark-set "org-remember-last-stored")
-                    (move-marker org-remember-last-stored-marker (point))))
-                 (t
-                  ;; Put it right there, with automatic level determined by
-                  ;; org-paste-subtree or from prefix arg
-                  (org-paste-subtree
-                   (if (numberp current-prefix-arg) current-prefix-arg)
-                   txt)
-                  (and org-auto-align-tags (org-set-tags nil t))
-                  (bookmark-set "org-remember-last-stored")
-                  (move-marker org-remember-last-stored-marker (point))))
-
-           (when remember-save-after-remembering
-             (save-buffer)
-             (if (and (not visiting)
-                      (not (equal (marker-buffer org-clock-marker)
-                                  (current-buffer))))
-                 (kill-buffer (current-buffer))))
-           (when org-remember-auto-remove-backup-files
-             (when backup-file
-               (ignore-errors
-                 (delete-file backup-file)
-                 (delete-file (concat backup-file "~"))))
-             (when org-remember-backup-directory
-               (let ((n (length
-                         (directory-files
-                          org-remember-backup-directory nil
-                          "^remember-.*[0-9]$"))))
-                 (when (and org-remember-warn-about-backups
-                             (> n 0))
-                   (message
-                    "%d backup files (unfinished remember calls) in %s"
-                    n org-remember-backup-directory))))))))))
-
-  t)    ;; return t to indicate that we took care of this note.
-
-(defun org-do-remember (&optional initial)
-  "Call remember."
-  (remember initial))
-
-(defun org-require-remember ()
-  "Make sure remember is loaded, or install our own emergency version of it."
-  (condition-case nil
-      (require 'remember)
-    (error
-     ;; Lets install our own micro version of remember
-     (defvar remember-register ?R)
-     (defvar remember-mode-hook nil)
-     (defvar remember-handler-functions nil)
-     (defvar remember-buffer "*Remember*")
-     (defvar remember-save-after-remembering t)
-     (defvar remember-annotation-functions '(buffer-file-name))
-     (defun remember-finalize ()
-       (run-hook-with-args-until-success 'remember-handler-functions)
-       (when (equal remember-buffer (buffer-name))
-        (kill-buffer (current-buffer))
-        (jump-to-register remember-register)))
-     (defun remember-mode ()
-       (fundamental-mode)
-       (setq mode-name "Remember")
-       (run-hooks 'remember-mode-hook))
-     (defun remember (&optional initial)
-       (window-configuration-to-register remember-register)
-       (let* ((annotation (run-hook-with-args-until-success
-                          'remember-annotation-functions)))
-        (switch-to-buffer-other-window (get-buffer-create remember-buffer))
-        (remember-mode)))
-     (defun remember-buffer-desc ()
-       (buffer-substring (point-min) (save-excursion (goto-char (point-min))
-                                                    (point-at-eol)))))))
-
-(provide 'org-remember)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-remember.el ends here
diff --git a/lisp/org/org-special-blocks.el b/lisp/org/org-special-blocks.el
deleted file mode 100644 (file)
index bbf5fef..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-;;; org-special-blocks.el --- handle Org special blocks
-;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
-
-;; Author: Chris Gray <chrismgray@gmail.com>
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-
-;; This package generalizes the #+begin_foo and #+end_foo tokens.
-
-;; To use, put the following in your init file:
-;;
-;; (require 'org-special-blocks)
-
-;; The tokens #+begin_center, #+begin_verse, etc. existed previously.
-;; This package generalizes them (at least for the LaTeX and html
-;; exporters).  When a #+begin_foo token is encountered by the LaTeX
-;; exporter, it is expanded into \begin{foo}.  The text inside the
-;; environment is not protected, as text inside environments generally
-;; is.  When #+begin_foo is encountered by the html exporter, a div
-;; with class foo is inserted into the HTML file.  It is up to the
-;; user to add this class to his or her stylesheet if this div is to
-;; mean anything.
-
-(require 'org-html)
-(require 'org-compat)
-
-(declare-function org-open-par "org-html" ())
-(declare-function org-close-par-maybe "org-html" ())
-
-(defvar org-special-blocks-ignore-regexp "^\\(LaTeX\\|HTML\\)$"
-  "A regexp indicating the names of blocks that should be ignored
-by org-special-blocks.  These blocks will presumably be
-interpreted by other mechanisms.")
-
-(defvar org-export-current-backend) ; dynamically bound in org-exp.el
-(defun org-special-blocks-make-special-cookies ()
-  "Adds special cookies when #+begin_foo and #+end_foo tokens are
-seen.  This is run after a few special cases are taken care of."
-  (when (or (eq org-export-current-backend 'html)
-           (eq org-export-current-backend 'latex))
-    (goto-char (point-min))
-    (while (re-search-forward "^[ \t]*#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t)
-      (unless (org-string-match-p org-special-blocks-ignore-regexp (match-string 2))
-       (replace-match
-        (if (equal (downcase (match-string 1)) "begin")
-            (concat "ORG-" (match-string 2) "-START")
-          (concat "ORG-" (match-string 2) "-END"))
-        t t)))))
-
-(add-hook 'org-export-preprocess-after-blockquote-hook
-         'org-special-blocks-make-special-cookies)
-
-(defun org-special-blocks-convert-latex-special-cookies ()
-  "Converts the special cookies into LaTeX blocks."
-  (goto-char (point-min))
-  (while (re-search-forward "^ORG-\\([^ \t\n]*\\)[ \t]*\\(.*\\)-\\(START\\|END\\)$" nil t)
-    (replace-match
-     (if (equal (match-string 3) "START")
-        (concat "\\begin{" (match-string 1) "}" (match-string 2))
-       (concat "\\end{" (match-string 1) "}"))
-     t t)))
-
-
-(add-hook 'org-export-latex-after-blockquotes-hook
-         'org-special-blocks-convert-latex-special-cookies)
-
-(defvar org-line)
-(defun org-special-blocks-convert-html-special-cookies ()
-  "Converts the special cookies into div blocks."
-  ;; Uses the dynamically-bound variable `org-line'.
-  (when (and org-line (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" org-line))
-    (message "%s" (match-string 1))
-    (when (equal (match-string 2 org-line) "START")
-      (org-close-par-maybe)
-      (insert "\n<div class=\"" (match-string 1 org-line) "\">")
-      (org-open-par))
-    (when (equal (match-string 2 org-line) "END")
-      (org-close-par-maybe)
-      (insert "\n</div>")
-      (org-open-par))
-    (throw 'nextline nil)))
-
-(add-hook 'org-export-html-after-blockquotes-hook
-         'org-special-blocks-convert-html-special-cookies)
-
-(provide 'org-special-blocks)
-
-;;; org-special-blocks.el ends here
index 501d30ab1d710b4855854a64a1fff9bd59e874f4..259186c0ce36eb66fec4457c17da3d76ae985ca1 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
-;;        Bastien Guerry <bzg AT gnu DOT org>
+;;        Bastien Guerry <bzg@gnu.org>
 ;;         Dan Davison <davison at stats dot ox dot ac dot uk>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
@@ -64,6 +64,30 @@ there are kept outside the narrowed region."
                   (const :tag "from `lang' element")
                   (const :tag "from `style' element")))))
 
+(defcustom org-edit-src-turn-on-auto-save nil
+  "Non-nil means turn `auto-save-mode' on when editing a source block.
+This will save the content of the source code editing buffer into
+a newly created file, not the base buffer for this source block.
+
+If you want to regularly save the base buffer instead of the source
+code editing buffer, see `org-edit-src-auto-save-idle-delay' instead."
+  :group 'org-edit-structure
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-edit-src-auto-save-idle-delay 0
+  "Delay before saving a source code buffer back into its base buffer.
+When a positive integer N, save after N seconds of idle time.
+When 0 (the default), don't auto-save.
+
+If you want to save the source code buffer itself, don't use this.
+Check `org-edit-src-turn-on-auto-save' instead."
+  :group 'org-edit-structure
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
 (defcustom org-coderef-label-format "(ref:%s)"
   "The default coderef format.
 This format string will be used to search for coderef labels in literal
@@ -155,7 +179,7 @@ but which mess up the display of a snippet in Org exported files.")
 (defcustom org-src-lang-modes
   '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist)
     ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)
-    ("calc" . fundamental) ("C" . c) ("cpp" . c++)
+    ("calc" . fundamental) ("C" . c) ("cpp" . c++) ("C++" . c++)
     ("screen" . shell-script))
   "Alist mapping languages to their major mode.
 The key is the language name, the value is the string that should
@@ -174,6 +198,7 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
 
 (defvar org-src-mode-map (make-sparse-keymap))
 (define-key org-src-mode-map "\C-c'" 'org-edit-src-exit)
+(define-key org-src-mode-map "\C-c\C-k" 'org-edit-src-abort)
 (define-key org-src-mode-map "\C-x\C-s" 'org-edit-src-save)
 
 (defvar org-edit-src-force-single-line nil)
@@ -186,11 +211,15 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
 (defvar org-edit-src-block-indentation nil)
 (defvar org-edit-src-saved-temp-window-config nil)
 
-(defvar org-src-ask-before-returning-to-edit-buffer t
+(defcustom org-src-ask-before-returning-to-edit-buffer t
   "If nil, when org-edit-src code is used on a block that already
 has an active edit buffer, it will switch to that edit buffer
 immediately; otherwise it will ask whether you want to return to
-the existing edit buffer.")
+the existing edit buffer."
+  :group 'org-edit-structure
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
 
 (defvar org-src-babel-info nil)
 
@@ -202,6 +231,7 @@ This minor mode is turned on in two situations:
 There is a mode hook, and keybindings for `org-edit-src-exit' and
 `org-edit-src-save'")
 
+(defvar org-edit-src-code-timer nil)
 (defun org-edit-src-code (&optional context code edit-buffer-name)
   "Edit the source CODE block at point.
 The code is copied to a separate buffer and the appropriate mode
@@ -241,8 +271,8 @@ the display of windows containing the Org buffer and the code buffer."
            end (move-marker end (nth 1 info))
            msg (if allow-write-back-p
                    (substitute-command-keys
-                    "Edit, then exit with C-c ' (C-c and single quote)")
-                 "Exit with C-c ' (C-c and single quote)")
+                    "Edit, then exit with C-c ' (C-c and single quote) -- C-c C-k to abort")
+                 "Exit with C-c ' (C-c and single quote) -- C-c C-k to abort")
            code (or code (buffer-substring-no-properties beg end))
            lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
                     (nth 2 info))
@@ -336,12 +366,33 @@ the display of windows containing the Org buffer and the code buffer."
        (org-src-mode)
        (set-buffer-modified-p nil)
        (setq buffer-file-name nil)
+       (when org-edit-src-turn-on-auto-save
+         (setq buffer-auto-save-file-name
+               (concat (make-temp-name "org-src-")
+                       (format-time-string "-%Y-%d-%m") ".txt")))
        (and org-edit-src-persistent-message
             (org-set-local 'header-line-format msg))
        (let ((edit-prep-func (intern (concat "org-babel-edit-prep:" lang))))
          (when (fboundp edit-prep-func)
-           (funcall edit-prep-func full-info))))
-      t)))
+           (funcall edit-prep-func full-info)))
+       (or org-edit-src-code-timer
+           (setq org-edit-src-code-timer
+                 (unless (zerop org-edit-src-auto-save-idle-delay)
+                   (run-with-idle-timer
+                    org-edit-src-auto-save-idle-delay t
+                    (lambda ()
+                      (cond
+                       ((and (string-match "\*Org Src" (buffer-name))
+                             (buffer-modified-p))
+                        (org-edit-src-save))
+                       ((not
+                         (delq nil (mapcar
+                                    (lambda (b)
+                                      (string-match "\*Org Src" (buffer-name b)))
+                                    (buffer-list))))
+                        (cancel-timer org-edit-src-code-timer)
+                        (setq org-edit-src-code-timer)))))))))
+       t)))
 
 (defun org-edit-src-continue (e)
   "Continue editing source blocks." ;; Fixme: be more accurate
@@ -420,7 +471,7 @@ the fragment in the Org-mode buffer."
        (col (current-column))
        (case-fold-search t)
        (msg (substitute-command-keys
-             "Edit, then exit with C-c ' (C-c and single quote)"))
+             "Edit, then exit with C-c ' (C-c and single quote) -- C-c C-k to abort"))
        (org-mode-p (derived-mode-p 'org-mode))
        (beg (make-marker))
        (end (make-marker))
@@ -520,10 +571,8 @@ the language, a switch telling if the content should be in a single line."
            ("^[ \t]*#\\+begin_latex.*\n" "\n[ \t]*#\\+end_latex" "latex")
            ("^[ \t]*#\\+ascii:" "\n" "fundamental" single-line)
            ("^[ \t]*#\\+begin_ascii.*\n" "\n[ \t]*#\\+end_ascii" "fundamental")
-           ("^[ \t]*#\\+docbook:" "\n" "xml" single-line)
            ("^[ \t]*#\\+macro:[ \t]+\\S-+\\( \\|$\\)"
             "\n" "fundamental" macro-definition)
-           ("^[ \t]*#\\+begin_docbook.*\n" "\n[ \t]*#\\+end_docbook" "xml")
            )))
        (pos (point))
        re1 re2 single beg end lang lfmt match-re1 ind entry)
@@ -699,14 +748,19 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
       (set-buffer-modified-p nil))
     (org-src-switch-to-buffer (marker-buffer beg) (or context 'exit))
     (if (eq context 'save) (save-buffer)
+      (with-current-buffer buffer
+       (set-buffer-modified-p nil))
       (kill-buffer buffer))
     (goto-char beg)
     (when allow-write-back-p
-      (delete-region beg (max beg end))
-      (unless (string-match "\\`[ \t]*\\'" code)
-       (insert code))
-      (goto-char beg)
-      (if single (just-one-space)))
+      (let ((buffer-undo-list t))
+       (delete-region beg (max beg end))
+       (unless (string-match "\\`[ \t]*\\'" code)
+         (insert code))
+       ;; Make sure the overlay stays in place
+       (when (eq context 'save) (move-overlay ovl beg (point)))
+       (goto-char beg)
+       (if single (just-one-space))))
     (if (memq t (mapcar (lambda (overlay)
                          (eq (overlay-get overlay 'invisible)
                              'org-hide-block))
@@ -714,16 +768,26 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
        ;; Block is hidden; put point at start of block
        (beginning-of-line 0)
       ;; Block is visible, put point where it was in the code buffer
-      (org-goto-line (1- (+ (org-current-line) line)))
-      (org-move-to-column (if preserve-indentation col (+ col total-nindent delta))))
+      (when allow-write-back-p
+       (org-goto-line (1- (+ (org-current-line) line)))
+       (org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))))
     (unless (eq context 'save)
       (move-marker beg nil)
       (move-marker end nil)))
+  (when org-edit-src-code-timer
+    (cancel-timer org-edit-src-code-timer)
+    (setq org-edit-src-code-timer nil))
   (unless (eq context 'save)
     (when org-edit-src-saved-temp-window-config
       (set-window-configuration org-edit-src-saved-temp-window-config)
       (setq org-edit-src-saved-temp-window-config nil))))
 
+(defun org-edit-src-abort ()
+  "Abort editing of the src code and return to the Org buffer."
+  (interactive)
+  (let (org-edit-src-allow-write-back-p)
+    (org-edit-src-exit 'exit)))
+
 (defmacro org-src-in-org-buffer (&rest body)
   `(let ((p (point)) (m (mark)) (ul buffer-undo-list) msg)
      (save-window-excursion
@@ -743,9 +807,11 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
 (defun org-edit-src-save ()
   "Save parent buffer with current state source-code buffer."
   (interactive)
-  (org-src-in-org-buffer (save-buffer)))
+  (if (string-match "Fixed Width" (buffer-name))
+      (user-error "Use C-c ' to save and exit, C-c C-k to abort editing")
+    (org-src-in-org-buffer (save-buffer))))
 
-(declare-function org-babel-tangle "ob-tangle" (&optional only-this-block target-file lang))
+(declare-function org-babel-tangle "ob-tangle" (&optional arg target-file lang))
 
 (defun org-src-tangle (arg)
   "Tangle the parent buffer."
@@ -778,8 +844,9 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
   (let ((session (cdr (assoc :session (nth 2 info)))))
     (and session (not (string= session "none"))
         (org-babel-comint-buffer-livep session)
-        ((lambda (f) (and (fboundp f) (funcall f session)))
-         (intern (format "org-babel-%s-associate-session" (nth 0 info)))))))
+        (let ((f (intern (format "org-babel-%s-associate-session"
+                                  (nth 0 info)))))
+           (and (fboundp f) (funcall f session))))))
 
 (defun org-src-babel-configure-edit-buffer ()
   (when org-src-babel-info
@@ -829,9 +896,9 @@ issued in the language major mode buffer."
 
 (defun org-src-native-tab-command-maybe ()
   "Perform language-specific TAB action.
-Alter code block according to effect of TAB in the language major
-mode."
+Alter code block according to what TAB does in the language major mode."
   (and org-src-tab-acts-natively
+       (org-in-src-block-p)
        (not (equal this-command 'org-shifttab))
        (let ((org-src-strip-leading-and-trailing-blank-lines nil))
         (org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))))
@@ -887,8 +954,9 @@ fontification of code blocks see `org-src-fontify-block' and
 LANG is a string, and the returned major mode is a symbol."
   (intern
    (concat
-    ((lambda (l) (if (symbolp l) (symbol-name l) l))
-     (or (cdr (assoc lang org-src-lang-modes)) lang)) "-mode")))
+    (let ((l (or (cdr (assoc lang org-src-lang-modes)) lang)))
+      (if (symbolp l) (symbol-name l) l))
+    "-mode")))
 
 (provide 'org-src)
 
index 00b2eb4d028bfe1b52ffc1dbc3898cb3b48d5b79..1ef90443935649cd8937cd6906ab426d3788c426 100644 (file)
   (require 'cl))
 (require 'org)
 
-(declare-function org-table-clean-before-export "org-exp"
-                 (lines &optional maybe-quoted))
-(declare-function org-format-org-table-html "org-html" (lines &optional splice))
+(declare-function org-export-string-as "ox"
+                 (string backend &optional body-only ext-plist))
 (declare-function aa2u "ext:ascii-art-to-unicode" ())
 (defvar orgtbl-mode) ; defined below
 (defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized
-(defvar org-export-html-table-tag) ; defined in org-exp.el
 (defvar constants-unit-system)
 (defvar org-table-follow-field-mode)
 
@@ -54,6 +52,8 @@ This can be used to add additional functionality after the table is sent
 to the receiver position, otherwise, if table is not sent, the functions
 are not run.")
 
+(defvar org-table-TBLFM-begin-regexp "|\n[ \t]*#\\+TBLFM: ")
+
 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
   "Non-nil means use the optimized table editor version for `orgtbl-mode'.
 In the optimized version, the table editor takes over all simple keys that
@@ -94,6 +94,22 @@ this variable requires a restart of Emacs to become effective."
 | | |
 "))
   "Templates for radio tables in different major modes.
+Each template must define lines that will be treated as a comment and that
+must contain the \"BEGIN RECEIVE ORGTBL %n\" and \"END RECEIVE ORGTBL\"
+lines where \"%n\" will be replaced with the name of the table during
+insertion of the template.  The transformed table will later be inserted
+between these lines.
+
+The template should also contain a minimal table in a multiline comment.
+If multiline comments are not possible in the buffer language,
+you can pack it into a string that will not be used when the code
+is compiled or executed.  Above the table will you need a line with
+the fixed string \"#+ORGTBL: SEND\", followed by instruction on how to
+convert the table into a data structure useful in the
+language of the buffer.  Check the manual for the section on
+\"Translator functions\", and more generally check out
+http://orgmode.org/manual/Tables-in-arbitrary-syntax.html#Tables-in-arbitrary-syntax
+
 All occurrences of %n in a template will be replaced with the name of the
 table, obtained by prompting the user."
   :group 'org-table
@@ -112,7 +128,7 @@ table, obtained by prompting the user."
   :type 'string)
 
 (defcustom org-table-number-regexp
-  "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%:]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$"
+  "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%:]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$"
   "Regular expression for recognizing numbers in table columns.
 If a table column contains mostly numbers, it will be aligned to the
 right.  If not, it will be aligned to the left.
@@ -136,10 +152,10 @@ Other options offered by the customize interface are more restrictive."
                 "^[-+]?\\([0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\\)$")
          (const :tag "Exponential, Floating point, Integer"
                 "^[-+]?[0-9.]+\\([eEdD][-+0-9]+\\)?$")
-         (const :tag "Very General Number-Like, including hex"
-                "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$")
-         (const :tag "Very General Number-Like, including hex, allows comma as decimal mark"
-                "^\\([<>]?[-+^.,0-9]*[0-9][-+^.0-9eEdDx()%]*\\|\\(0[xX]\\)[0-9a-fA-F]+\\|nan\\)$")
+         (const :tag "Very General Number-Like, including hex and Calc radix"
+                "^\\([<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$")
+         (const :tag "Very General Number-Like, including hex and Calc radix, allows comma as decimal mark"
+                "^\\([<>]?[-+^.,0-9]*[0-9][-+^.0-9eEdDx()%]*\\|[<>]?[-+]?0[xX][0-9a-fA-F.]+\\|[<>]?[-+]?[0-9]+#[0-9a-zA-Z.]+\\|nan\\|[-+u]?inf\\)$")
          (string :tag "Regexp:")))
 
 (defcustom org-table-number-fraction 0.5
@@ -419,6 +435,40 @@ available parameters."
                         (org-split-string (match-string 1 line)
                                           "[ \t]*|[ \t]*")))))))
 
+(defvar org-table-clean-did-remove-column nil) ; dynamically scoped
+(defun org-table-clean-before-export (lines &optional maybe-quoted)
+  "Check if the table has a marking column.
+If yes remove the column and the special lines."
+  (let ((special (if maybe-quoted
+                    "^[ \t]*| *\\\\?[\#!$*_^/ ] *|"
+                  "^[ \t]*| *[\#!$*_^/ ] *|"))
+       (ignore  (if maybe-quoted
+                    "^[ \t]*| *\\\\?[!$_^/] *|"
+                  "^[ \t]*| *[!$_^/] *|")))
+    (setq org-table-clean-did-remove-column
+         (not (memq nil
+                    (mapcar
+                     (lambda (line)
+                       (or (string-match org-table-hline-regexp line)
+                           (string-match special                line)))
+                     lines))))
+    (delq nil
+         (mapcar
+          (lambda (line)
+            (cond
+             ((or (org-table-colgroup-line-p line)  ;; colgroup info
+                  (org-table-cookie-line-p line)    ;; formatting cookies
+                  (and org-table-clean-did-remove-column
+                       (string-match ignore line))) ;; non-exportable data
+              nil)
+             ((and org-table-clean-did-remove-column
+                   (or (string-match "^\\([ \t]*\\)|-+\\+" line)
+                       (string-match "^\\([ \t]*\\)|[^|]*|" line)))
+              ;; remove the first column
+              (replace-match "\\1|" t nil line))
+             (t line)))
+          lines))))
+
 (defconst org-table-translate-regexp
   (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)")
   "Match a reference that needs translation, for reference display.")
@@ -503,7 +553,7 @@ nil      When nil, the command tries to be smart and figure out the
          - when each line contains a TAB, assume TAB-separated material
          - when each line contains a comma, assume CSV material
          - else, assume one or more SPACE characters as separator."
-  (interactive "rP")
+  (interactive "r\nP")
   (let* ((beg (min beg0 end0))
         (end (max beg0 end0))
         re)
@@ -539,7 +589,7 @@ nil      When nil, the command tries to be smart and figure out the
                ((equal separator '(16)) "^\\|\t")
                ((integerp separator)
                 (if (< separator 1)
-                    (error "Number of spaces in separator must be >= 1")
+                    (user-error "Number of spaces in separator must be >= 1")
                   (format "^ *\\| *\t *\\| \\{%d,\\}" separator)))
                (t (error "This should not happen"))))
       (while (re-search-forward re end t)
@@ -579,9 +629,7 @@ whether it is set locally or up in the hierarchy, then on the
 extension of the given file name, and finally on the variable
 `org-table-export-default-format'."
   (interactive)
-  (unless (org-at-table-p)
-    (error "No table at point"))
-  (require 'org-exp)
+  (unless (org-at-table-p) (user-error "No table at point"))
   (org-table-align) ;; make sure we have everything we need
   (let* ((beg (org-table-begin))
         (end (org-table-end))
@@ -598,13 +646,13 @@ extension of the given file name, and finally on the variable
       (setq file (read-file-name "Export table to: "))
       (unless (or (not (file-exists-p file))
                  (y-or-n-p (format "Overwrite file %s? " file)))
-       (error "Abort")))
+       (user-error "File not written")))
     (if (file-directory-p file)
-       (error "This is a directory path, not a file"))
+       (user-error "This is a directory path, not a file"))
     (if (and (buffer-file-name)
             (equal (file-truename file)
                    (file-truename (buffer-file-name))))
-       (error "Please specify a file name that is different from current"))
+       (user-error "Please specify a file name that is different from current"))
     (setq fileext (concat (file-name-extension file) "$"))
     (unless format
       (setq deffmt-readable
@@ -641,7 +689,7 @@ extension of the given file name, and finally on the variable
                                     skipcols i0)))
 
          (unless (fboundp transform)
-           (error "No such transformation function %s" transform))
+           (user-error "No such transformation function %s" transform))
          (setq txt (funcall transform table params))
 
          (with-current-buffer (find-file-noselect file)
@@ -652,7 +700,7 @@ extension of the given file name, and finally on the variable
            (save-buffer))
          (kill-buffer buf)
          (message "Export done."))
-      (error "TABLE_EXPORT_FORMAT invalid"))))
+      (user-error "TABLE_EXPORT_FORMAT invalid"))))
 
 (defvar org-table-aligned-begin-marker (make-marker)
   "Marker at the beginning of the table last aligned.
@@ -760,7 +808,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
       (error
        (kill-region beg end)
        (org-table-create org-table-default-size)
-       (error "Empty table - created default table")))
+       (user-error "Empty table - created default table")))
     ;; A list of empty strings to fill any short rows on output
     (setq emptystrings (make-list maxfields ""))
     ;; Check for special formatting.
@@ -787,7 +835,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
                    (concat "Clipped table field, use C-c ` to edit.  Full value is:\n" (org-no-properties (copy-sequence xx))))
                  (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax)))
                  (unless (> f1 1)
-                   (error "Cannot narrow field starting with wide link \"%s\""
+                   (user-error "Cannot narrow field starting with wide link \"%s\""
                           (match-string 0 xx)))
                  (add-text-properties f1 (length xx) (list 'org-cwidth t) xx)
                  (add-text-properties (- f1 2) f1
@@ -860,7 +908,8 @@ When nil, simply write \"#ERROR\" in corrupted fields.")
     (org-goto-line winstartline)
     (setq winstart (point-at-bol))
     (org-goto-line linepos)
-    (set-window-start (selected-window) winstart 'noforce)
+    (when (eq (window-buffer (selected-window)) (current-buffer))
+      (set-window-start (selected-window) winstart 'noforce))
     (org-table-goto-column colpos)
     (and org-table-overlay-coordinates (org-table-overlay-coordinates))
     (setq org-table-may-need-update nil)
@@ -978,7 +1027,7 @@ Before doing so, re-align the table if necessary."
       (progn
        (re-search-backward "|" (org-table-begin))
        (re-search-backward "|" (org-table-begin)))
-    (error (error "Cannot move to previous table field")))
+    (error (user-error "Cannot move to previous table field")))
   (while (looking-at "|\\(-\\|[ \t]*$\\)")
     (re-search-backward "|" (org-table-begin)))
   (if (looking-at "| ?")
@@ -994,7 +1043,7 @@ With numeric argument N, move N-1 fields forward first."
       (setq n (1- n))
       (org-table-previous-field))
     (if (not (re-search-backward "|" (point-at-bol 0) t))
-       (error "No more table fields before the current")
+       (user-error "No more table fields before the current")
       (goto-char (match-end 0))
       (and (looking-at " ") (forward-char 1)))
     (if (>= (point) pos) (org-table-beginning-of-field 2))))
@@ -1055,7 +1104,7 @@ copying.  In the case of a timestamp, increment by one day."
   (interactive "p")
   (let* ((colpos (org-table-current-column))
         (col (current-column))
-        (field (org-table-get-field))
+        (field (save-excursion (org-table-get-field)))
         (non-empty (string-match "[^ \t]" field))
         (beg (org-table-begin))
         (orig-n n)
@@ -1091,7 +1140,7 @@ copying.  In the case of a timestamp, increment by one day."
            (org-table-maybe-recalculate-line))
          (org-table-align)
          (org-move-to-column col))
-      (error "No non-empty field found"))))
+      (user-error "No non-empty field found"))))
 
 (defun org-table-check-inside-data-field (&optional noerror)
   "Is point inside a table data field?
@@ -1103,7 +1152,7 @@ This actually throws an error, so it aborts the current command."
          (looking-at "[ \t]*$"))
       (if noerror
          nil
-       (error "Not in table data field"))
+       (user-error "Not in table data field"))
     t))
 
 (defvar org-table-clip nil
@@ -1286,7 +1335,7 @@ However, when FORCE is non-nil, create new columns if necessary."
   "Insert a new column into the table."
   (interactive)
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (org-table-find-dataline)
   (let* ((col (max 1 (org-table-current-column)))
         (beg (org-table-begin))
@@ -1326,7 +1375,7 @@ However, when FORCE is non-nil, create new columns if necessary."
       (if (and (org-at-table-p)
               (not (org-at-table-hline-p)))
          t
-       (error
+       (user-error
         "Please position cursor in a data line for column operations")))))
 
 (defun org-table-line-to-dline (line &optional above)
@@ -1356,7 +1405,7 @@ first dline below it is used.  When ABOVE is non-nil, the one above is used."
   "Delete a column from the table."
   (interactive)
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (org-table-find-dataline)
   (org-table-check-inside-data-field)
   (let* ((col (org-table-current-column))
@@ -1400,7 +1449,7 @@ first dline below it is used.  When ABOVE is non-nil, the one above is used."
   "Move the current column to the right.  With arg LEFT, move to the left."
   (interactive "P")
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (org-table-find-dataline)
   (org-table-check-inside-data-field)
   (let* ((col (org-table-current-column))
@@ -1411,9 +1460,9 @@ first dline below it is used.  When ABOVE is non-nil, the one above is used."
         (linepos (org-current-line))
         (colpos (if left (1- col) (1+ col))))
     (if (and left (= col 1))
-       (error "Cannot move column further left"))
+       (user-error "Cannot move column further left"))
     (if (and (not left) (looking-at "[^|\n]*|[^|\n]*$"))
-       (error "Cannot move column further right"))
+       (user-error "Cannot move column further right"))
     (goto-char beg)
     (while (< (point) end)
       (if (org-at-table-hline-p)
@@ -1461,7 +1510,7 @@ first dline below it is used.  When ABOVE is non-nil, the one above is used."
     (beginning-of-line tonew)
     (unless (org-at-table-p)
       (goto-char pos)
-      (error "Cannot move row further"))
+      (user-error "Cannot move row further"))
     (setq hline2p (looking-at org-table-hline-regexp))
     (goto-char pos)
     (beginning-of-line 1)
@@ -1486,7 +1535,7 @@ first dline below it is used.  When ABOVE is non-nil, the one above is used."
 With prefix ARG, insert below the current line."
   (interactive "P")
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (let* ((line (buffer-substring (point-at-bol) (point-at-eol)))
         (new (org-table-clean-line line)))
     ;; Fix the first field if necessary
@@ -1508,7 +1557,7 @@ With prefix ARG, insert below the current line."
 With prefix ABOVE, insert above the current line."
   (interactive "P")
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (when (eobp) (insert "\n") (backward-char 1))
   (if (not (string-match "|[ \t]*$" (org-current-line-string)))
       (org-table-align))
@@ -1558,7 +1607,7 @@ In particular, this does handle wide and invisible characters."
   "Delete the current row or horizontal line from the table."
   (interactive)
   (if (not (org-at-table-p))
-      (error "Not at a table"))
+      (user-error "Not at a table"))
   (let ((col (current-column))
        (dline (org-table-current-dline)))
     (kill-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
@@ -1710,7 +1759,7 @@ the table is enlarged as needed.  The process ignores horizontal separator
 lines."
   (interactive)
   (unless (and org-table-clip (listp org-table-clip))
-    (error "First cut/copy a region to paste!"))
+    (user-error "First cut/copy a region to paste!"))
   (org-table-check-inside-data-field)
   (let* ((clip org-table-clip)
         (line (org-current-line))
@@ -1796,11 +1845,16 @@ will be transposed as
 
 Note that horizontal lines disappeared."
   (interactive)
-  (let ((contents
-         (apply #'mapcar* #'list
-                ;; remove 'hline from list
-               (delq nil (mapcar (lambda (x) (when (listp x) x))
-                                 (org-table-to-lisp))))))
+  (let* ((table (delete 'hline (org-table-to-lisp)))
+        (contents (mapcar (lambda (p)
+                            (let ((tp table))
+                              (mapcar
+                               (lambda (rown)
+                                 (prog1
+                                     (pop (car tp))
+                                   (setq tp (cdr tp))))
+                               table)))
+                          (car table))))
     (delete-region (org-table-begin) (org-table-end))
     (insert (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) "  |\n" ))
                        contents ""))
@@ -1839,7 +1893,7 @@ blank, and the content is appended to the field above."
             nlines)
        (org-table-cut-region (region-beginning) (region-end))
        (if (> (length (car org-table-clip)) 1)
-           (error "Region must be limited to single column"))
+           (user-error "Region must be limited to single column"))
        (setq nlines (if arg
                         (if (< arg 1)
                             (+ (length org-table-clip) arg)
@@ -2008,12 +2062,12 @@ If NLAST is a number, only the NLAST fields will actually be summed."
        (setq col (org-table-current-column))
        (goto-char (org-table-begin))
        (unless (re-search-forward "^[ \t]*|[^-]" nil t)
-         (error "No table data"))
+         (user-error "No table data"))
        (org-table-goto-column col)
        (setq beg (point))
        (goto-char (org-table-end))
        (unless (re-search-backward "^[ \t]*|[^-]" nil t)
-         (error "No table data"))
+         (user-error "No table data"))
        (org-table-goto-column col)
        (setq end (point))))
       (let* ((items (apply 'append (org-table-copy-region beg end)))
@@ -2031,7 +2085,7 @@ If NLAST is a number, only the NLAST fields will actually be summed."
                           h (floor (/ diff 3600)) diff (mod diff 3600)
                           m (floor (/ diff 60)) diff (mod diff 60)
                           s diff)
-                    (format "%d:%02d:%02d" h m s))))
+                    (format "%.0f:%02.0f:%02.0f" h m s))))
        (kill-new sres)
        (if (org-called-interactively-p 'interactive)
            (message "%s"
@@ -2098,7 +2152,7 @@ When NAMED is non-nil, look for a named equation."
                 (int-to-string (org-table-current-column))))
         (dummy (and (or nameass refass) (not named)
                     (not (y-or-n-p "Replace existing field formula with column formula? " ))
-                    (error "Abort")))
+                    (message "Formula not replaced")))
         (name (or name ref))
         (org-table-may-need-update nil)
         (stored (cdr (assoc scol stored-list)))
@@ -2122,7 +2176,7 @@ When NAMED is non-nil, look for a named equation."
       ;; remove formula
       (setq stored-list (delq (assoc scol stored-list) stored-list))
       (org-table-store-formulas stored-list)
-      (error "Formula removed"))
+      (user-error "Formula removed"))
     (if (string-match "^ *=?" eq) (setq eq (replace-match "" t t eq)))
     (if (string-match " *$" eq) (setq eq (replace-match "" t t eq)))
     (if (and name (not named))
@@ -2207,7 +2261,7 @@ When NAMED is non-nil, look for a named equation."
                      (message "Double definition `$%s=' in TBLFM line, please fix by hand" scol)
                      (ding)
                      (sit-for 2))
-                 (error "Double definition `$%s=' in TBLFM line, please fix by hand" scol))
+                 (user-error "Double definition `$%s=' in TBLFM line, please fix by hand" scol))
              (push scol seen))))))
     (nreverse eq-alist)))
 
@@ -2231,7 +2285,7 @@ For all numbers larger than LIMIT, shift them by DELTA."
          (while (re-search-forward re2 (point-at-eol) t)
            (unless (save-match-data (org-in-regexp "remote([^)]+?)"))
              (if (equal (char-before (match-beginning 0)) ?.)
-                 (error "Change makes TBLFM term %s invalid, use undo to recover"
+                 (user-error "Change makes TBLFM term %s invalid, use undo to recover"
                         (match-string 0))
                (replace-match "")))))
        (while (re-search-forward re (point-at-eol) t)
@@ -2338,7 +2392,7 @@ If yes, store the formula and apply it."
                (equal (substring eq 0 (min 2 (length eq))) "'("))
            (org-table-eval-formula (if named '(4) nil)
                                    (org-table-formula-from-user eq))
-         (error "Calc does not seem to be installed, and is needed to evaluate the formula"))))))
+         (user-error "Calc does not seem to be installed, and is needed to evaluate the formula"))))))
 
 (defvar org-recalc-commands nil
   "List of commands triggering the recalculation of a line.
@@ -2363,7 +2417,7 @@ after prompting for the marking character.
 After each change, a message will be displayed indicating the meaning
 of the new mark."
   (interactive)
-  (unless (org-at-table-p) (error "Not at a table"))
+  (unless (org-at-table-p) (user-error "Not at a table"))
   (let* ((marks (append (mapcar 'car org-recalc-marks) '(" ")))
         (beg (org-table-begin))
         (end (org-table-end))
@@ -2382,13 +2436,13 @@ of the new mark."
       (setq newchar (char-to-string (read-char-exclusive))
            forcenew (car (assoc newchar org-recalc-marks))))
     (if (and newchar (not forcenew))
-       (error "Invalid NEWCHAR `%s' in `org-table-rotate-recalc-marks'"
+       (user-error "Invalid NEWCHAR `%s' in `org-table-rotate-recalc-marks'"
               newchar))
     (if l1 (org-goto-line l1))
     (save-excursion
       (beginning-of-line 1)
       (unless (looking-at org-table-dataline-regexp)
-       (error "Not at a table data line")))
+       (user-error "Not at a table data line")))
     (unless have-col
       (org-table-goto-column 1)
       (org-table-insert-column)
@@ -2483,7 +2537,7 @@ not overwrite the stored one."
   (or suppress-analysis (org-table-get-specials))
   (if (equal arg '(16))
       (let ((eq (org-table-current-field-formula)))
-       (or eq (error "No equation active for current field"))
+       (or eq (user-error "No equation active for current field"))
        (org-table-get-field nil eq)
        (org-table-align)
        (setq org-table-may-need-update t))
@@ -2557,7 +2611,10 @@ not overwrite the stored one."
                          fields)))
        (if (eq numbers t)
            (setq fields (mapcar
-                         (lambda (x) (number-to-string (string-to-number x)))
+                         (lambda (x)
+                           (if (string-match "\\S-" x)
+                               (number-to-string (string-to-number x))
+                             x))
                          fields)))
        (setq ndown (1- ndown))
        (setq form (copy-sequence formula)
@@ -2612,7 +2669,7 @@ not overwrite the stored one."
          (if (not (save-match-data
                     (string-match (regexp-quote form) formrpl)))
              (setq form (replace-match formrpl t t form))
-           (error "Spreadsheet error: invalid reference \"%s\"" form)))
+           (user-error "Spreadsheet error: invalid reference \"%s\"" form)))
        ;; Insert simple ranges
        (while (string-match "\\$\\([0-9]+\\)\\.\\.\\$\\([0-9]+\\)"  form)
          (setq form
@@ -2630,11 +2687,12 @@ not overwrite the stored one."
          (setq n (+ (string-to-number (match-string 1 form))
                     (if (match-end 2) n0 0))
                x (nth (1- (if (= n 0) n0 (max n 1))) fields))
-         (unless x (error "Invalid field specifier \"%s\""
+         (unless x (user-error "Invalid field specifier \"%s\""
                           (match-string 0 form)))
          (setq form (replace-match
                      (save-match-data
-                       (org-table-make-reference x nil numbers lispp))
+                       (org-table-make-reference
+                        x keep-empty numbers lispp))
                      t t form)))
 
        (if lispp
@@ -2646,12 +2704,23 @@ not overwrite the stored one."
                                   (string-to-number ev)
                                   duration-output-format) ev))
          (or (fboundp 'calc-eval)
-             (error "Calc does not seem to be installed, and is needed to evaluate the formula"))
-         ;; "Inactivate" time-stamps so that Calc can handle them
+             (user-error "Calc does not seem to be installed, and is needed to evaluate the formula"))
+         ;; Use <...> time-stamps so that Calc can handle them
          (setq form (replace-regexp-in-string org-ts-regexp3 "<\\1>" form))
+         ;; I18n-ize local time-stamps by setting (system-time-locale "C")
+         (when (string-match org-ts-regexp2 form)
+           (let* ((ts (match-string 0 form))
+                  (tsp (apply 'encode-time (save-match-data (org-parse-time-string ts))))
+                  (system-time-locale "C")
+                  (tf (or (and (save-match-data (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
+                               (cdr org-time-stamp-formats))
+                          (car org-time-stamp-formats))))
+             (setq form (replace-match (format-time-string tf tsp) t t form))))
+
          (setq ev (if (and duration (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form))
                       form
-                    (calc-eval (cons form org-tbl-calc-modes) (if numbers 'num)))
+                    (calc-eval (cons form org-tbl-calc-modes)
+                               (when (and (not keep-empty) numbers) 'num)))
                ev (if duration (org-table-time-seconds-to-string
                                 (if (string-match "^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" ev)
                                     (string-to-number (org-table-time-string-to-seconds ev))
@@ -2667,7 +2736,7 @@ $xyz->  %s
 @r$c->  %s
 $1->    %s\n" orig formula form0 form))
            (if (listp ev)
-               (princ (format "       %s^\nError:  %s"
+               (princ (format "        %s^\nError:  %s"
                               (make-string (car ev) ?\-) (nth 1 ev)))
              (princ (format "Result: %s\nFormat: %s\nFinal:  %s"
                             ev (or fmt "NONE")
@@ -2678,7 +2747,7 @@ $1->    %s\n" orig formula form0 form))
            (unless (let (inhibit-redisplay)
                      (y-or-n-p "Debugging Formula.  Continue to next? "))
              (org-table-align)
-             (error "Abort"))
+             (user-error "Abort"))
            (delete-window bw)
            (message "")))
        (if (listp ev) (setq fmt nil ev "#ERROR"))
@@ -2716,7 +2785,7 @@ in the buffer and column1 and column2 are table column numbers."
     (let ((thisline (org-current-line))
          beg end c1 c2 r1 r2 rangep tmp)
       (unless (string-match org-table-range-regexp desc)
-       (error "Invalid table range specifier `%s'" desc))
+       (user-error "Invalid table range specifier `%s'" desc))
       (setq rangep (match-end 3)
            r1 (and (match-end 1) (match-string 1 desc))
            r2 (and (match-end 4) (match-string 4 desc))
@@ -2784,7 +2853,7 @@ and TABLE is a vector with line types."
         ;;                     1  2          3           4  5          6
         (and (not (match-end 3)) (not (match-end 6)))
         (and (match-end 3) (match-end 6) (not (match-end 5))))
-       (error "Invalid row descriptor `%s'" desc))
+       (user-error "Invalid row descriptor `%s'" desc))
     (let* ((hdir (and (match-end 2) (match-string 2 desc)))
           (hn (if (match-end 3) (- (match-end 3) (match-beginning 3)) nil))
           (odir (and (match-end 5) (match-string 5 desc)))
@@ -2798,7 +2867,7 @@ and TABLE is a vector with line types."
            (setq i 0 hdir "+")
            (if (eq (aref table 0) 'hline) (setq hn (1- hn)))))
       (if (and (not hn) on (not odir))
-         (error "Should never happen");;(aref org-table-dlines on)
+         (user-error "Should never happen");;(aref org-table-dlines on)
        (if (and hn (> hn 0))
            (setq i (org-table-find-row-type table i 'hline (equal hdir "-")
                                             nil hn cline desc)))
@@ -2818,41 +2887,56 @@ and TABLE is a vector with line types."
                      (cond
                       ((eq org-table-relative-ref-may-cross-hline t) t)
                       ((eq org-table-relative-ref-may-cross-hline 'error)
-                       (error "Row descriptor %s used in line %d crosses hline" desc cline))
+                       (user-error "Row descriptor %s used in line %d crosses hline" desc cline))
                       (t (setq i (- i (if backwards -1 1))
                                n 1)
                          nil))
                    t)))
       (setq n (1- n)))
     (if (or (< i 0) (>= i l))
-       (error "Row descriptor %s used in line %d leads outside table"
+       (user-error "Row descriptor %s used in line %d leads outside table"
               desc cline)
       i)))
 
 (defun org-table-rewrite-old-row-references (s)
   (if (string-match "&[-+0-9I]" s)
-      (error "Formula contains old &row reference, please rewrite using @-syntax")
+      (user-error "Formula contains old &row reference, please rewrite using @-syntax")
     s))
 
 (defun org-table-make-reference (elements keep-empty numbers lispp)
   "Convert list ELEMENTS to something appropriate to insert into formula.
 KEEP-EMPTY indicated to keep empty fields, default is to skip them.
 NUMBERS indicates that everything should be converted to numbers.
-LISPP means to return something appropriate for a Lisp list."
-  (if (stringp elements) ; just a single val
+LISPP non-nil means to return something appropriate for a Lisp
+list, 'literal is for the format specifier L."
+  ;; Calc nan (not a number) is used for the conversion of the empty
+  ;; field to a reference for several reasons: (i) It is accepted in a
+  ;; Calc formula (e. g. "" or "()" would result in a Calc error).
+  ;; (ii) In a single field (not in range) it can be distinguished
+  ;; from "(nan)" which is the reference made from a single field
+  ;; containing "nan".
+  (if (stringp elements)
+      ;; field reference
       (if lispp
          (if (eq lispp 'literal)
              elements
-           (prin1-to-string (if numbers (string-to-number elements) elements)))
-       (if (equal elements "") (setq elements "0"))
-       (if numbers (setq elements (number-to-string (string-to-number elements))))
-       (concat "(" elements ")"))
+           (if (and (eq elements "") (not keep-empty))
+               ""
+             (prin1-to-string
+              (if numbers (string-to-number elements) elements))))
+       (if (string-match "\\S-" elements)
+           (progn
+             (when numbers (setq elements (number-to-string
+                                           (string-to-number elements))))
+             (concat "(" elements ")"))
+         (if (or (not keep-empty) numbers) "(0)" "nan")))
+    ;; range reference
     (unless keep-empty
       (setq elements
            (delq nil
                  (mapcar (lambda (x) (if (string-match "\\S-" x) x nil))
                          elements))))
-    (setq elements (or elements '("0")))
+    (setq elements (or elements '()))  ; if delq returns nil then we need '()
     (if lispp
        (mapconcat
         (lambda (x)
@@ -2862,10 +2946,32 @@ LISPP means to return something appropriate for a Lisp list."
         elements " ")
       (concat "[" (mapconcat
                   (lambda (x)
-                    (if numbers (number-to-string (string-to-number x)) x))
+                    (if (string-match "\\S-" x)
+                        (if numbers
+                            (number-to-string (string-to-number x))
+                          x)
+                      (if (or (not keep-empty) numbers) "0" "nan")))
                   elements
                   ",") "]"))))
 
+;;;###autoload
+(defun org-table-set-constants ()
+  "Set `org-table-formula-constants-local' in the current buffer."
+  (let (cst consts const-str)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward "^[ \t]*#\\+CONSTANTS: \\(.*\\)" nil t)
+       (setq const-str (substring-no-properties (match-string 1)))
+       (setq consts (append consts (org-split-string const-str "[ \t]+")))
+       (when consts
+         (let (e)
+           (while (setq e (pop consts))
+             (when (string-match "^\\([a-zA-Z0][_a-zA-Z0-9]*\\)=\\(.*\\)" e)
+               (if (assoc-string (match-string 1 e) cst)
+                   (setq cst (delete (assoc-string (match-string 1 e) cst) cst)))
+               (push (cons (match-string 1 e) (match-string 2 e)) cst)))
+           (setq org-table-formula-constants-local cst)))))))
+
 ;;;###autoload
 (defun org-table-recalculate (&optional all noalign)
   "Recalculate the current table line by applying all stored formulas.
@@ -2879,7 +2985,7 @@ known that the table will be realigned a little later anyway."
   (interactive "P")
   (or (memq this-command org-recalc-commands)
       (setq org-recalc-commands (cons this-command org-recalc-commands)))
-  (unless (org-at-table-p) (error "Not at a table"))
+  (unless (org-at-table-p) (user-error "Not at a table"))
   (if (or (eq all 'iterate) (equal all '(16)))
       (org-table-iterate)
     (org-table-get-specials)
@@ -2902,7 +3008,7 @@ known that the table will be realigned a little later anyway."
                                        (car x)) 1)
                                      (cdr x)))
                        (if (assoc (car x) eqlist1)
-                           (error "\"%s=\" formula tries to overwrite existing formula for column %s"
+                           (user-error "\"%s=\" formula tries to overwrite existing formula for column %s"
                                   lhs1 (car x))))
                      (cons
                       (org-table-formula-handle-first/last-rc (car x))
@@ -2947,7 +3053,7 @@ known that the table will be realigned a little later anyway."
        (if a (setq name1 (format "@%d$%d" (org-table-line-to-dline (nth 1 a))
                                  (nth 2 a))))
        (when (member name1 seen-fields)
-         (error "Several field/range formulas try to set %s" name1))
+         (user-error "Several field/range formulas try to set %s" name1))
        (push name1 seen-fields)
 
        (and (not a)
@@ -2956,7 +3062,7 @@ known that the table will be realigned a little later anyway."
                           (condition-case nil
                               (aref org-table-dlines
                                     (string-to-number (match-string 1 name)))
-                            (error (error "Invalid row number in %s"
+                            (error (user-error "Invalid row number in %s"
                                           name)))
                           (string-to-number (match-string 2 name)))))
        (when (and a (or all (equal (nth 1 a) thisline)))
@@ -3026,7 +3132,7 @@ with the prefix ARG."
              (message "Convergence after %d iterations" i)
            (message "Table was already stable"))
          (throw 'exit t)))
-      (error "No convergence after %d iterations" i))))
+      (user-error "No convergence after %d iterations" i))))
 
 ;;;###autoload
 (defun org-table-recalculate-buffer-tables ()
@@ -3057,7 +3163,40 @@ with the prefix ARG."
                  (message "Convergence after %d iterations" (- imax i))
                  (throw 'exit t))
              (setq checksum c1)))
-         (error "No convergence after %d iterations" imax))))))
+         (user-error "No convergence after %d iterations" imax))))))
+
+(defun org-table-calc-current-TBLFM (&optional arg)
+  "Apply the #+TBLFM in the line at point to the table."
+  (interactive "P")
+  (unless (org-at-TBLFM-p) (user-error "Not at a #+TBLFM line"))
+  (let ((formula (buffer-substring
+                 (point-at-bol)
+                 (point-at-eol)))
+       s e)
+    (save-excursion
+      ;; Insert a temporary formula at right after the table
+      (goto-char (org-table-TBLFM-begin))
+      (setq s (set-marker (make-marker) (point)))
+      (insert (concat formula "\n"))
+      (setq e (set-marker (make-marker) (point)))
+      ;; Recalculate the table
+      (beginning-of-line 0)            ; move to the inserted line
+      (skip-chars-backward " \r\n\t")
+      (if (org-at-table-p)
+         (unwind-protect
+             (org-call-with-arg 'org-table-recalculate (or arg t))
+           ;; delete the formula inserted temporarily
+           (delete-region s e))))))
+
+(defun org-table-TBLFM-begin ()
+  "Find the beginning of the TBLFM lines and return its position.
+Return nil when the beginning of TBLFM line was not found."
+  (save-excursion
+    (when (progn (forward-line 1)
+             (re-search-backward
+              org-table-TBLFM-begin-regexp
+              nil t))
+         (point-at-bol 2))))
 
 (defun org-table-expand-lhs-ranges (equations)
   "Expand list of formulas.
@@ -3115,7 +3254,7 @@ borders of the table using the @< @> $< $> makers."
                    len
                  (- nmax len -1)))
        (if (or (< n 1) (> n nmax))
-           (error "Reference \"%s\" in expression \"%s\" points outside table"
+           (user-error "Reference \"%s\" in expression \"%s\" points outside table"
                   (match-string 0 s) s))
        (setq start (match-beginning 0))
        (setq s (replace-match (format "%s%d" (match-string 1 s) n) t t s)))))
@@ -3214,7 +3353,7 @@ Parameters get priority."
   (interactive)
   (when (save-excursion (beginning-of-line 1) (let ((case-fold-search t)) (looking-at "[ \t]*#\\+TBLFM")))
     (beginning-of-line 0))
-  (unless (org-at-table-p) (error "Not at a table"))
+  (unless (org-at-table-p) (user-error "Not at a table"))
   (org-table-get-specials)
   (let ((key (org-table-current-field-formula 'key 'noerror))
        (eql (sort (org-table-get-stored-formulas 'noerror)
@@ -3436,7 +3575,7 @@ minutes or seconds."
    ((org-at-regexp-p "\\(\\<[a-zA-Z]\\)&")
     (if (memq dir '(left right))
        (org-rematch-and-replace 1 (eq dir 'left))
-      (error "Cannot shift reference in this direction")))
+      (user-error "Cannot shift reference in this direction")))
    ((org-at-regexp-p "\\(\\<[a-zA-Z]\\{1,2\\}\\)\\([0-9]+\\)")
     ;; A B3-like reference
     (if (memq dir '(up down))
@@ -3451,7 +3590,7 @@ minutes or seconds."
 
 (defun org-rematch-and-replace (n &optional decr hline)
   "Re-match the group N, and replace it with the shifted reference."
-  (or (match-end n) (error "Cannot shift reference in this direction"))
+  (or (match-end n) (user-error "Cannot shift reference in this direction"))
   (goto-char (match-beginning n))
   (and (looking-at (regexp-quote (match-string n)))
        (replace-match (org-table-shift-refpart (match-string 0) decr hline)
@@ -3487,7 +3626,7 @@ a translation reference."
        (org-number-to-letters
         (max 1 (+ (org-letters-to-number ref) (if decr -1 1)))))
 
-       (t (error "Cannot shift reference"))))))
+       (t (user-error "Cannot shift reference"))))))
 
 (defun org-table-fedit-toggle-coordinates ()
   "Toggle the display of coordinates in the referenced table."
@@ -3519,14 +3658,14 @@ With prefix ARG, apply the new formulas to the table."
        (while (string-match "[ \t]*\n[ \t]*" form)
          (setq form (replace-match " " t t form)))
        (when (assoc var eql)
-         (error "Double formulas for %s" var))
+         (user-error "Double formulas for %s" var))
        (push (cons var form) eql)))
     (setq org-pos nil)
     (set-window-configuration org-window-configuration)
     (select-window sel-win)
     (goto-char pos)
     (unless (org-at-table-p)
-      (error "Lost table position - cannot install formulas"))
+      (user-error "Lost table position - cannot install formulas"))
     (org-table-store-formulas eql)
     (move-marker pos nil)
     (kill-buffer "*Edit Formulas*")
@@ -3556,14 +3695,14 @@ With prefix ARG, apply the new formulas to the table."
       (call-interactively 'lisp-indent-line))
      ((looking-at "[$&@0-9a-zA-Z]+ *= *[^ \t\n']") (goto-char pos))
      ((not (fboundp 'pp-buffer))
-      (error "Cannot pretty-print.  Command `pp-buffer' is not available"))
+      (user-error "Cannot pretty-print.  Command `pp-buffer' is not available"))
      ((looking-at "[$&@0-9a-zA-Z]+ *= *'(")
       (goto-char (- (match-end 0) 2))
       (setq beg (point))
       (setq ind (make-string (current-column) ?\ ))
       (condition-case nil (forward-sexp 1)
        (error
-        (error "Cannot pretty-print Lisp expression: Unbalanced parenthesis")))
+        (user-error "Cannot pretty-print Lisp expression: Unbalanced parenthesis")))
       (setq end (point))
       (save-restriction
        (narrow-to-region beg end)
@@ -3615,7 +3754,7 @@ With prefix ARG, apply the new formulas to the table."
                  ((org-at-regexp-p "\\$[a-zA-Z][a-zA-Z0-9]*") 'name)
                  ((org-at-regexp-p "\\$[0-9]+") 'column)
                  ((not local) nil)
-                 (t (error "No reference at point")))
+                 (t (user-error "No reference at point")))
            match (and what (or match (match-string 0))))
       (when (and  match (not (equal (match-beginning 0) (point-at-bol))))
        (org-table-add-rectangle-overlay (match-beginning 0) (match-end 0)
@@ -3682,7 +3821,7 @@ With prefix ARG, apply the new formulas to the table."
              (goto-char (match-beginning 1))
              (org-table-highlight-rectangle)
              (message "Named column (column %s)" (cdr e)))
-         (error "Column name not found")))
+         (user-error "Column name not found")))
        ((eq what 'column)
        ;; column number
        (org-table-goto-column (string-to-number (substring match 1)))
@@ -3695,10 +3834,10 @@ With prefix ARG, apply the new formulas to the table."
              (goto-char (match-beginning 1))
              (org-table-highlight-rectangle)
              (message "Local parameter."))
-         (error "Parameter not found")))
+         (user-error "Parameter not found")))
        (t
        (cond
-        ((not var) (error "No reference at point"))
+        ((not var) (user-error "No reference at point"))
         ((setq e (assoc var org-table-formula-constants-local))
          (message "Local Constant: $%s=%s in #+CONSTANTS line."
                   var (cdr e)))
@@ -3708,7 +3847,7 @@ With prefix ARG, apply the new formulas to the table."
         ((setq e (and (fboundp 'constants-get) (constants-get var)))
          (message "Constant: $%s=%s, from `constants.el'%s."
                   var e (format " (%s units)" constants-unit-system)))
-        (t (error "Undefined name $%s" var)))))
+        (t (user-error "Undefined name $%s" var)))))
       (goto-char pos)
       (when (and org-show-positions
                 (not (memq this-command '(org-table-fedit-scroll
@@ -3734,7 +3873,7 @@ With prefix ARG, apply the new formulas to the table."
             (goto-char (if (< (abs (- p1 (point))) (abs (- p2 (point))))
                            p1 p2)))
            ((or p1 p2) (goto-char (or p1 p2)))
-           (t (error "No table dataline around here"))))))
+           (t (user-error "No table dataline around here"))))))
 
 (defun org-table-fedit-line-up ()
   "Move cursor one line up in the window showing the table."
@@ -3999,7 +4138,7 @@ to execute outside of tables."
 (defun orgtbl-error ()
   "Error when there is no default binding for a table key."
   (interactive)
-  (error "This key has no function outside tables"))
+  (user-error "This key has no function outside tables"))
 
 (defun orgtbl-setup ()
   "Setup orgtbl keymaps."
@@ -4151,7 +4290,7 @@ to execute outside of tables."
 If it is a table to be sent away to a receiver, do it.
 With prefix arg, also recompute table."
   (interactive "P")
-  (let ((case-fold-search t) (pos (point)) action consts-str consts cst const-str)
+  (let ((case-fold-search t) (pos (point)) action)
     (save-excursion
       (beginning-of-line 1)
       (setq action (cond
@@ -4169,17 +4308,7 @@ With prefix arg, also recompute table."
       (when (orgtbl-send-table 'maybe)
        (run-hooks 'orgtbl-after-send-table-hook)))
      ((eq action 'recalc)
-      (save-excursion
-       (goto-char (point-min))
-       (while (re-search-forward "^[ \t]*#\\+CONSTANTS: \\(.*\\)" nil t)
-         (setq const-str (substring-no-properties (match-string 1)))
-         (setq consts (append consts (org-split-string const-str "[ \t]+")))
-         (when consts
-           (let (e)
-             (while (setq e (pop consts))
-               (if (string-match "^\\([a-zA-Z0][_a-zA-Z0-9]*\\)=\\(.*\\)" e)
-                   (push (cons (match-string 1 e) (match-string 2 e)) cst)))
-             (setq org-table-formula-constants-local cst)))))
+      (org-table-set-constants)
       (save-excursion
        (beginning-of-line 1)
        (skip-chars-backward " \r\n\t")
@@ -4264,31 +4393,6 @@ overwritten, and the table is not marked as requiring realignment."
 (defvar orgtbl-exp-regexp "^\\([-+]?[0-9][0-9.]*\\)[eE]\\([-+]?[0-9]+\\)$"
   "Regular expression matching exponentials as produced by calc.")
 
-(defun orgtbl-export (table target)
-  (require 'org-exp)
-  (let ((func (intern (concat "orgtbl-to-" (symbol-name target))))
-       (lines (org-split-string table "[ \t]*\n[ \t]*"))
-       org-table-last-alignment org-table-last-column-widths
-       maxcol column)
-    (if (not (fboundp func))
-       (error "Cannot export orgtbl table to %s" target))
-    (setq lines (org-table-clean-before-export lines))
-    (setq table
-         (mapcar
-          (lambda (x)
-            (if (string-match org-table-hline-regexp x)
-                'hline
-              (org-split-string (org-trim x) "\\s-*|\\s-*")))
-          lines))
-    (setq maxcol (apply 'max (mapcar (lambda (x) (if (listp x) (length x) 0))
-                                    table)))
-    (loop for i from (1- maxcol) downto 0 do
-         (setq column (mapcar (lambda (x) (if (listp x) (nth i x) nil)) table))
-         (setq column (delq nil column))
-         (push (apply 'max (mapcar 'string-width column)) org-table-last-column-widths)
-         (push (> (/ (apply '+ (mapcar (lambda (x) (if (string-match org-table-number-regexp x) 1 0)) column)) maxcol) org-table-number-fraction) org-table-last-alignment))
-    (funcall func table nil)))
-
 (defun orgtbl-gather-send-defs ()
   "Gather a plist of :name, :transform, :params for each destination before
 a radio table."
@@ -4311,15 +4415,15 @@ a radio table."
   (save-excursion
     (goto-char (point-min))
     (unless (re-search-forward
-            (concat "BEGIN RECEIVE ORGTBL +" name "\\([ \t]\\|$\\)") nil t)
-      (error "Don't know where to insert translated table"))
+            (concat "BEGIN +RECEIVE +ORGTBL +" name "\\([ \t]\\|$\\)") nil t)
+      (user-error "Don't know where to insert translated table"))
     (goto-char (match-beginning 0))
     (beginning-of-line 2)
     (save-excursion
       (let ((beg (point)))
        (unless (re-search-forward
-                (concat "END RECEIVE ORGTBL +" name) nil t)
-         (error "Cannot find end of insertion region"))
+                (concat "END +RECEIVE +ORGTBL +" name) nil t)
+         (user-error "Cannot find end of insertion region"))
        (beginning-of-line 1)
        (delete-region beg (point))))
     (insert txt "\n")))
@@ -4332,7 +4436,7 @@ for a horizontal separator line, or a list of field values as strings.
 The table is taken from the parameter TXT, or from the buffer at point."
   (unless txt
     (unless (org-at-table-p)
-      (error "No table at point")))
+      (user-error "No table at point")))
   (let* ((txt (or txt
                  (buffer-substring-no-properties (org-table-begin)
                                                  (org-table-end))))
@@ -4351,7 +4455,7 @@ With argument MAYBE, fail quietly if no transformation is defined for
 this table."
   (interactive)
   (catch 'exit
-    (unless (org-at-table-p) (error "Not at a table"))
+    (unless (org-at-table-p) (user-error "Not at a table"))
     ;; when non-interactive, we assume align has just happened.
     (when (org-called-interactively-p 'any) (org-table-align))
     (let ((dests (orgtbl-gather-send-defs))
@@ -4359,7 +4463,7 @@ this table."
                                               (org-table-end)))
          (ntbl 0))
       (unless dests (if maybe (throw 'exit nil)
-                     (error "Don't know how to transform this table")))
+                     (user-error "Don't know how to transform this table")))
       (dolist (dest dests)
        (let* ((name (plist-get dest :name))
               (transform (plist-get dest :transform))
@@ -4392,7 +4496,7 @@ this table."
                                     skipcols i0))
               (txt (if (fboundp transform)
                        (funcall transform table params)
-                     (error "No such transformation function %s" transform))))
+                     (user-error "No such transformation function %s" transform))))
          (orgtbl-send-replace-tbl name txt))
        (setq ntbl (1+ ntbl)))
       (message "Table converted and installed at %d receiver location%s"
@@ -4422,7 +4526,7 @@ First element has index 0, or I0 if given."
         (commented (save-excursion (beginning-of-line 1)
                                    (cond ((looking-at re1) t)
                                          ((looking-at re2) nil)
-                                         (t (error "Not at an org table")))))
+                                         (t (user-error "Not at an org table")))))
         (re (if commented re1 re2))
         beg end)
     (save-excursion
@@ -4440,7 +4544,7 @@ First element has index 0, or I0 if given."
   (let* ((e (assq major-mode orgtbl-radio-table-templates))
         (txt (nth 1 e))
         name pos)
-    (unless e (error "No radio table setup defined for %s" major-mode))
+    (unless e (user-error "No radio table setup defined for %s" major-mode))
     (setq name (read-string "Table name: "))
     (while (string-match "%n" txt)
       (setq txt (replace-match name t t txt)))
@@ -4474,7 +4578,8 @@ First element has index 0, or I0 if given."
     fmt))
 
 (defsubst orgtbl-apply-fmt (fmt &rest args)
-  "Apply format FMT to the arguments.  NIL FMTs return the first argument."
+  "Apply format FMT to arguments ARGS.
+When FMT is nil, return the first argument from ARGS."
   (cond ((functionp fmt) (apply fmt args))
        (fmt (apply 'format fmt args))
        (args (car args))
@@ -4504,7 +4609,7 @@ First element has index 0, or I0 if given."
                                   f)))
             line)))
       (push (if *orgtbl-lfmt*
-               (orgtbl-apply-fmt *orgtbl-lfmt* line)
+               (apply #'orgtbl-apply-fmt *orgtbl-lfmt* line)
              (concat (orgtbl-eval-str *orgtbl-lstart*)
                      (mapconcat 'identity line *orgtbl-sep*)
                      (orgtbl-eval-str *orgtbl-lend*)))
@@ -4523,12 +4628,15 @@ First element has index 0, or I0 if given."
                     (orgtbl-format-line prevline))))))
 
 ;;;###autoload
-(defun orgtbl-to-generic (table params)
+(defun orgtbl-to-generic (table params &optional backend)
   "Convert the orgtbl-mode TABLE to some other format.
 This generic routine can be used for many standard cases.
 TABLE is a list, each entry either the symbol `hline' for a horizontal
 separator line, or a list of fields for that line.
 PARAMS is a property list of parameters that can influence the conversion.
+A third optional argument BACKEND can be used to convert the content of
+the cells using a specific export back-end.
+
 For the generic converter, some parameters are obligatory: you need to
 specify either :lfmt, or all of (:lstart :lend :sep).
 
@@ -4599,22 +4707,31 @@ directly by `orgtbl-send-table'.  See manual."
         (*orgtbl-llfmt* (or (plist-get params :llfmt) *orgtbl-lfmt*))
         (*orgtbl-fmt* (plist-get params :fmt))
         *orgtbl-rtn*)
-
+    ;; Convert cells content to backend BACKEND
+    (when backend
+      (setq *orgtbl-table*
+           (mapcar
+            (lambda(r)
+              (if (listp r)
+                  (mapcar
+                   (lambda (c)
+                     (org-trim (org-export-string-as c backend t '(:with-tables t))))
+                   r)
+                r))
+            *orgtbl-table*)))
     ;; Put header
     (unless splicep
       (when (plist-member params :tstart)
        (let ((tstart (orgtbl-eval-str (plist-get params :tstart))))
          (if tstart (push tstart *orgtbl-rtn*)))))
-
-    ;; Do we have a heading section?  If so, format it and handle the
-    ;; trailing hline.
+    ;; If we have a heading, format it and handle the trailing hline.
     (if (and (not splicep)
             (or (consp (car *orgtbl-table*))
                 (consp (nth 1 *orgtbl-table*)))
             (memq 'hline (cdr *orgtbl-table*)))
        (progn
          (when (eq 'hline (car *orgtbl-table*))
-           ;; there is a hline before the first data line
+           ;; There is a hline before the first data line
            (and hline (push hline *orgtbl-rtn*))
            (pop *orgtbl-table*))
          (let* ((*orgtbl-lstart* (or (plist-get params :hlstart)
@@ -4632,15 +4749,12 @@ directly by `orgtbl-send-table'.  See manual."
            (orgtbl-format-section 'hline))
          (if (and hline (not skipheadrule)) (push hline *orgtbl-rtn*))
          (pop *orgtbl-table*)))
-
     ;; Now format the main section.
     (orgtbl-format-section nil)
-
     (unless splicep
       (when (plist-member params :tend)
        (let ((tend (orgtbl-eval-str (plist-get params :tend))))
          (if tend (push tend *orgtbl-rtn*)))))
-
     (mapconcat (if remove-newlines
                   (lambda (tend)
                     (replace-regexp-in-string "[\n\r\t\f]" "\\\\n" tend))
@@ -4698,7 +4812,8 @@ this function is called."
           :tend "\\end{tabular}"
           :lstart "" :lend " \\\\" :sep " & "
           :efmt "%s\\,(%s)" :hline "\\hline")))
-    (orgtbl-to-generic table (org-combine-plists params2 params))))
+    (require 'ox-latex)
+    (orgtbl-to-generic table (org-combine-plists params2 params) 'latex)))
 
 ;;;###autoload
 (defun orgtbl-to-html (table params)
@@ -4714,22 +4829,14 @@ Currently this function recognizes the following parameters:
 The general parameters :skip and :skipcols have already been applied when
 this function is called.  The function does *not* use `orgtbl-to-generic',
 so you cannot specify parameters for it."
-  (let* ((splicep (plist-get params :splice))
-        (html-table-tag org-export-html-table-tag)
-        html)
-    ;; Just call the formatter we already have
-    ;; We need to make text lines for it, so put the fields back together.
-    (setq html (org-format-org-table-html
-               (mapcar
-                (lambda (x)
-                  (if (eq x 'hline)
-                      "|----+----|"
-                    (concat "| " (mapconcat 'org-html-expand x " | ") " |")))
-                table)
-               splicep))
-    (if (string-match "\n+\\'" html)
-       (setq html (replace-match "" t t html)))
-    html))
+  (require 'ox-html)
+  (let ((output (org-export-string-as
+                (orgtbl-to-orgtbl table nil) 'html t '(:with-tables t))))
+    (if (not (plist-get params :splice)) output
+      (org-trim
+       (replace-regexp-in-string
+       "\\`<table .*>\n" ""
+       (replace-regexp-in-string "</table>\n*\\'" "" output))))))
 
 ;;;###autoload
 (defun orgtbl-to-texinfo (table params)
@@ -4768,7 +4875,8 @@ this function is called."
           :tend "@end multitable"
           :lstart "@item " :lend "" :sep " @tab "
           :hlstart "@headitem ")))
-    (orgtbl-to-generic table (org-combine-plists params2 params))))
+    (require 'ox-texinfo)
+    (orgtbl-to-generic table (org-combine-plists params2 params) 'texinfo)))
 
 ;;;###autoload
 (defun orgtbl-to-orgtbl (table params)
@@ -4815,22 +4923,22 @@ it here: http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el."
       (unless (delq nil (mapcar (lambda (l) (string-match "aa2u" (car l))) org-stored-links))
        (push '("http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el"
                "Link to ascii-art-to-unicode.el") org-stored-links))
-      (error "Please download ascii-art-to-unicode.el (use C-c C-l to insert the link to it)"))
+      (user-error "Please download ascii-art-to-unicode.el (use C-c C-l to insert the link to it)"))
     (buffer-string)))
 
 (defun org-table-get-remote-range (name-or-id form)
   "Get a field value or a list of values in a range from table at ID.
 
-NAME-OR-ID may be the name of a table in the current file as set by
-a \"#+TBLNAME:\" directive.  The first table following this line
+NAME-OR-ID may be the name of a table in the current file as set
+by a \"#+NAME:\" directive.  The first table following this line
 will then be used.  Alternatively, it may be an ID referring to
-any entry, also in a different file.  In this case, the first table
-in that entry will be referenced.
+any entry, also in a different file.  In this case, the first
+table in that entry will be referenced.
 FORM is a field or range descriptor like \"@2$3\" or \"B3\" or
 \"@I$2..@II$2\".  All the references must be absolute, not relative.
 
 The return value is either a single string for a single field, or a
-list of the fields in the rectangle ."
+list of the fields in the rectangle."
   (save-match-data
     (let ((case-fold-search t) (id-loc nil)
          ;; Protect a bunch of variables from being overwritten
@@ -4851,12 +4959,13 @@ list of the fields in the rectangle ."
          (save-excursion
            (goto-char (point-min))
            (if (re-search-forward
-                (concat "^[ \t]*#\\+tblname:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
+                (concat "^[ \t]*#\\+\\(tbl\\)?name:[ \t]*"
+                        (regexp-quote name-or-id) "[ \t]*$")
                 nil t)
                (setq buffer (current-buffer) loc (match-beginning 0))
              (setq id-loc (org-id-find name-or-id 'marker))
              (unless (and id-loc (markerp id-loc))
-               (error "Can't find remote table \"%s\"" name-or-id))
+               (user-error "Can't find remote table \"%s\"" name-or-id))
              (setq buffer (marker-buffer id-loc)
                    loc (marker-position id-loc))
              (move-marker id-loc nil)))
@@ -4868,7 +4977,7 @@ list of the fields in the rectangle ."
                (forward-char 1)
                (unless (and (re-search-forward "^\\(\\*+ \\)\\|[ \t]*|" nil t)
                             (not (match-beginning 1)))
-                 (error "Cannot find a table at NAME or ID %s" name-or-id))
+                 (user-error "Cannot find a table at NAME or ID %s" name-or-id))
                (setq tbeg (point-at-bol))
                (org-table-get-specials)
                (setq form (org-table-formula-substitute-names
@@ -4879,6 +4988,38 @@ list of the fields in the rectangle ."
                      (org-table-get-range (match-string 0 form) tbeg 1))
                  form)))))))))
 
+(defmacro org-define-lookup-function (mode)
+  (let ((mode-str (symbol-name mode))
+       (first-p (equal mode 'first))
+       (all-p (equal mode 'all)))
+    (let ((plural-str (if all-p "s" "")))
+      `(defun ,(intern (format "org-lookup-%s" mode-str)) (val s-list r-list &optional predicate)
+        ,(format "Find %s occurrence%s of VAL in S-LIST; return corresponding element%s of R-LIST.
+If R-LIST is nil, return matching element%s of S-LIST.
+If PREDICATE is not nil, use it instead of `equal' to match VAL.
+Matching is done by (PREDICATE VAL S), where S is an element of S-LIST.
+This function is generated by a call to the macro `org-define-lookup-function'."
+                 mode-str plural-str plural-str plural-str)
+        (let ,(let ((lvars '((p (or predicate 'equal))
+                             (sl s-list)
+                             (rl (or r-list s-list))
+                             (ret nil))))
+                (if first-p (add-to-list 'lvars '(match-p nil)))
+                lvars)
+          (while ,(if first-p '(and (not match-p) sl) 'sl)
+            (progn
+              (if (funcall p val (car sl))
+                  (progn
+                    ,(if first-p '(setq match-p t))
+                    (let ((rval (car rl)))
+                      (setq ret ,(if all-p '(append ret (list rval)) 'rval)))))
+              (setq sl (cdr sl) rl (cdr rl))))
+          ret)))))
+
+(org-define-lookup-function first)
+(org-define-lookup-function last)
+(org-define-lookup-function all)
+
 (provide 'org-table)
 
 ;; Local variables:
diff --git a/lisp/org/org-taskjuggler.el b/lisp/org/org-taskjuggler.el
deleted file mode 100644 (file)
index bd4c10b..0000000
+++ /dev/null
@@ -1,699 +0,0 @@
-;;; org-taskjuggler.el --- TaskJuggler exporter for org-mode
-;;
-;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
-;;
-;; Emacs Lisp Archive Entry
-;; Filename: org-taskjuggler.el
-;; Author: Christian Egli
-;; Maintainer: Christian Egli
-;; Keywords: org, taskjuggler, project planning
-;; Description: Converts an org-mode buffer into a taskjuggler project plan
-;; URL:
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-;; Commentary:
-;;
-;; This library implements a TaskJuggler exporter for org-mode.
-;; TaskJuggler uses a text format to define projects, tasks and
-;; resources, so it is a natural fit for org-mode.  It can produce all
-;; sorts of reports for tasks or resources in either HTML, CSV or PDF.
-;; The current version of TaskJuggler requires KDE but the next
-;; version is implemented in Ruby and should therefore run on any
-;; platform.
-;;
-;; The exporter is a bit different from other exporters, such as the
-;; HTML and LaTeX exporters for example, in that it does not export
-;; all the nodes of a document or strictly follow the order of the
-;; nodes in the document.
-;;
-;; Instead the TaskJuggler exporter looks for a tree that defines the
-;; tasks and a optionally tree that defines the resources for this
-;; project.  It then creates a TaskJuggler file based on these trees
-;; and the attributes defined in all the nodes.
-;;
-;; * Installation
-;;
-;; Put this file into your load-path and the following line into your
-;; ~/.emacs:
-;;
-;;   (require 'org-taskjuggler)
-;;
-;; The interactive functions are similar to those of the HTML and LaTeX
-;; exporters:
-;;
-;; M-x `org-export-as-taskjuggler'
-;; M-x `org-export-as-taskjuggler-and-open'
-;;
-;; * Tasks
-;;
-;; Let's illustrate the usage with a small example.  Create your tasks
-;; as you usually do with org-mode.  Assign efforts to each task using
-;; properties (it's easiest to do this in the column view). You should
-;; end up with something similar to the example by Peter Jones in
-;; http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org.
-;; Now mark the top node of your tasks with a tag named
-;; "taskjuggler_project" (or whatever you customized
-;; `org-export-taskjuggler-project-tag' to). You are now ready to
-;; export the project plan with `org-export-as-taskjuggler-and-open'
-;; which will export the project plan and open a Gantt chart in
-;; TaskJugglerUI.
-;;
-;; * Resources
-;;
-;; Next you can define resources and assign those to work on specific
-;; tasks.  You can group your resources hierarchically.  Tag the top
-;; node of the resources with "taskjuggler_resource" (or whatever you
-;; customized `org-export-taskjuggler-resource-tag' to). You can
-;; optionally assign an identifier (named "resource_id") to the
-;; resources (using the standard org properties commands) or you can
-;; let the exporter generate identifiers automatically (the exporter
-;; picks the first word of the headline as the identifier as long as
-;; it is unique, see the documentation of
-;; `org-taskjuggler-get-unique-id'). Using that identifier you can
-;; then allocate resources to tasks.  This is again done with the
-;; "allocate" property on the tasks.  Do this in column view or when on
-;; the task type
-;;
-;;  C-c C-x p allocate RET <resource_id> RET
-;;
-;; Once the allocations are done you can again export to TaskJuggler
-;; and check in the Resource Allocation Graph which person is working
-;; on what task at what time.
-;;
-;; * Export of properties
-;;
-;; The exporter also takes TODO state information into consideration,
-;; i.e. if a task is marked as done it will have the corresponding
-;; attribute in TaskJuggler ("complete 100"). Also it will export any
-;; property on a task resource or resource node which is known to
-;; TaskJuggler, such as limits, vacation, shift, booking, efficiency,
-;; journalentry, rate for resources or account, start, note, duration,
-;; end, journalentry, milestone, reference, responsible, scheduling,
-;; etc for tasks.
-;;
-;; * Dependencies
-;;
-;; The exporter will handle dependencies that are defined in the tasks
-;; either with the ORDERED attribute (see TODO dependencies in the Org
-;; mode manual) or with the BLOCKER attribute (see org-depend.el) or
-;; alternatively with a depends attribute.  Both the BLOCKER and the
-;; depends attribute can be either "previous-sibling" or a reference
-;; to an identifier (named "task_id") which is defined for another
-;; task in the project.  BLOCKER and the depends attribute can define
-;; multiple dependencies separated by either space or comma.  You can
-;; also specify optional attributes on the dependency by simply
-;; appending it.  The following examples should illustrate this:
-;;
-;; * Training material
-;;   :PROPERTIES:
-;;   :task_id:  training_material
-;;   :ORDERED:  t
-;;   :END:
-;; ** Markup Guidelines
-;;    :PROPERTIES:
-;;    :Effort:   2d
-;;    :END:
-;; ** Workflow Guidelines
-;;    :PROPERTIES:
-;;    :Effort:   2d
-;;    :END:
-;; * Presentation
-;;   :PROPERTIES:
-;;   :Effort:   2d
-;;   :BLOCKER:  training_material { gapduration 1d } some_other_task
-;;   :END:
-;;
-;;;; * TODO
-;;   - Use SCHEDULED and DEADLINE information (not just start and end
-;;     properties).
-;;   - Look at org-file-properties, org-global-properties and
-;;     org-global-properties-fixed
-;;   - What about property inheritance and org-property-inherit-p?
-;;   - Use TYPE_TODO as an way to assign resources
-;;   - Make sure multiple dependency definitions (i.e.  BLOCKER on
-;;     previous-sibling and on a specific task_id) in multiple
-;;     attributes are properly exported.
-;;
-;;; Code:
-
-(eval-when-compile
-  (require 'cl))
-
-(require 'org)
-(require 'org-exp)
-
-;;; User variables:
-
-(defgroup org-export-taskjuggler nil
-  "Options for exporting Org-mode files to TaskJuggler."
-  :tag "Org Export TaskJuggler"
-  :group 'org-export)
-
-(defcustom org-export-taskjuggler-extension ".tjp"
-  "Extension of TaskJuggler files."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-taskjuggler-project-tag "taskjuggler_project"
-  "Tag, property or todo used to find the tree containing all
-the tasks for the project."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-taskjuggler-resource-tag "taskjuggler_resource"
-  "Tag, property or todo used to find the tree containing all the
-resources for the project."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-taskjuggler-target-version 2.4
-  "Which version of TaskJuggler the exporter is targeting."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'number)
-
-(defcustom org-export-taskjuggler-default-project-version "1.0"
-  "Default version string for the project."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'string)
-
-(defcustom org-export-taskjuggler-default-project-duration 280
-  "Default project duration if no start and end date have been defined
-in the root node of the task tree, i.e. the tree that has been marked
-with `org-export-taskjuggler-project-tag'"
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type 'integer)
-
-(defcustom org-export-taskjuggler-default-reports
-  '("taskreport \"Gantt Chart\" {
-  headline \"Project Gantt Chart\"
-  columns hierarchindex, name, start, end, effort, duration, completed, chart
-  timeformat \"%Y-%m-%d\"
-  hideresource 1
-  loadunit shortauto
-}"
-    "resourcereport \"Resource Graph\" {
-  headline \"Resource Allocation Graph\"
-  columns no, name, utilization, freeload, chart
-  loadunit shortauto
-  sorttasks startup
-  hidetask ~isleaf()
-}")
-  "Default reports for the project."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type '(repeat (string :tag "Report")))
-
-(defcustom org-export-taskjuggler-default-global-properties
-  "shift s40 \"Part time shift\" {
-  workinghours wed, thu, fri off
-}
-"
-  "Default global properties for the project.  Here you typically
-define global properties such as shifts, accounts, rates,
-vacation, macros and flags.  Any property that is allowed within
-the TaskJuggler file can be inserted.  You could for example
-include another TaskJuggler file.
-
-The global properties are inserted after the project declaration
-but before any resource and task declarations."
-  :group 'org-export-taskjuggler
-  :version "24.1"
-  :type '(string :tag "Preamble"))
-
-;;; Hooks
-
-(defvar org-export-taskjuggler-final-hook nil
-  "Hook run at the end of TaskJuggler export, in the new buffer.")
-
-;;; Autoload functions:
-
-;; avoid compiler warning about free variable
-(defvar org-export-taskjuggler-old-level)
-
-;;;###autoload
-(defun org-export-as-taskjuggler ()
-  "Export parts of the current buffer as a TaskJuggler file.
-The exporter looks for a tree with tag, property or todo that
-matches `org-export-taskjuggler-project-tag' and takes this as
-the tasks for this project.  The first node of this tree defines
-the project properties such as project name and project period.
-If there is a tree with tag, property or todo that matches
-`org-export-taskjuggler-resource-tag' this three is taken as
-resources for the project.  If no resources are specified, a
-default resource is created and allocated to the project.  Also
-the taskjuggler project will be created with default reports as
-defined in `org-export-taskjuggler-default-reports'."
-  (interactive)
-
-  (message "Exporting...")
-  (setq-default org-done-keywords org-done-keywords)
-  (let* ((tasks
-         (org-taskjuggler-resolve-dependencies
-          (org-taskjuggler-assign-task-ids
-           (org-taskjuggler-compute-task-leafiness
-            (org-map-entries
-             'org-taskjuggler-components
-             org-export-taskjuggler-project-tag nil 'archive 'comment)))))
-        (resources
-         (org-taskjuggler-assign-resource-ids
-          (org-map-entries
-           'org-taskjuggler-components
-           org-export-taskjuggler-resource-tag nil 'archive 'comment)))
-        (filename (expand-file-name
-                   (concat
-                    (file-name-sans-extension
-                     (file-name-nondirectory buffer-file-name))
-                    org-export-taskjuggler-extension)))
-        (buffer (find-file-noselect filename))
-        (old-buffer (current-buffer))
-        (org-export-taskjuggler-old-level 0)
-        task resource)
-    (unless tasks
-      (error "No tasks specified"))
-    ;; add a default resource
-    (unless resources
-      (setq resources
-           `((("resource_id" . ,(user-login-name))
-              ("headline" . ,user-full-name)
-              ("level" . 1)))))
-    ;; add a default allocation to the first task if none was given
-    (unless (assoc "allocate" (car tasks))
-      (let ((task (car tasks))
-           (resource-id (cdr (assoc "resource_id" (car resources)))))
-       (setcar tasks (push (cons "allocate" resource-id) task))))
-    ;; add a default start date to the first task if none was given
-    (unless (assoc "start" (car tasks))
-      (let ((task (car tasks))
-           (time-string (format-time-string "%Y-%m-%d")))
-       (setcar tasks (push (cons "start" time-string) task))))
-    ;; add a default version if none was given
-    (unless (assoc "version" (car tasks))
-      (let ((task (car tasks))
-           (version org-export-taskjuggler-default-project-version))
-       (setcar tasks (push (cons "version" version) task))))
-    (with-current-buffer buffer
-      (erase-buffer)
-      (org-clone-local-variables old-buffer "^org-")
-      (org-taskjuggler-open-project (car tasks))
-      (insert org-export-taskjuggler-default-global-properties)
-      (insert "\n")
-      (dolist (resource resources)
-       (let ((level (cdr (assoc "level" resource))))
-         (org-taskjuggler-close-maybe level)
-         (org-taskjuggler-open-resource resource)
-         (setq org-export-taskjuggler-old-level level)))
-      (org-taskjuggler-close-maybe 1)
-      (setq org-export-taskjuggler-old-level 0)
-      (dolist (task tasks)
-       (let ((level (cdr (assoc "level" task))))
-         (org-taskjuggler-close-maybe level)
-         (org-taskjuggler-open-task task)
-         (setq org-export-taskjuggler-old-level level)))
-      (org-taskjuggler-close-maybe 1)
-      (org-taskjuggler-insert-reports)
-      (save-buffer)
-      (or (org-export-push-to-kill-ring "TaskJuggler")
-         (message "Exporting... done"))
-      (current-buffer))))
-
-;;;###autoload
-(defun org-export-as-taskjuggler-and-open ()
-  "Export the current buffer as a TaskJuggler file and open it
-with the TaskJuggler GUI."
-  (interactive)
-  (let* ((file-name (buffer-file-name (org-export-as-taskjuggler)))
-        (process-name "TaskJugglerUI")
-        (command (concat process-name " " file-name)))
-    (start-process-shell-command process-name nil command)))
-
-(defun org-taskjuggler-targeting-tj3-p ()
-  "Return true if we are targeting TaskJuggler III."
-  (>= org-export-taskjuggler-target-version 3.0))
-
-(defun org-taskjuggler-parent-is-ordered-p ()
-  "Return true if the parent of the current node has a property
-\"ORDERED\".  Return nil otherwise."
-  (save-excursion
-    (and (org-up-heading-safe) (org-entry-get (point) "ORDERED"))))
-
-(defun org-taskjuggler-components ()
-  "Return an alist containing all the pertinent information for
-the current node such as the headline, the level, todo state
-information, all the properties, etc."
-  (let* ((props (org-entry-properties))
-        (components (org-heading-components))
-        (level (nth 1 components))
-        (headline
-         (replace-regexp-in-string
-          "\"" "\\\"" (nth 4 components) t t)) ; quote double quotes in headlines
-        (parent-ordered (org-taskjuggler-parent-is-ordered-p)))
-    (push (cons "level" level) props)
-    (push (cons "headline" headline) props)
-    (push (cons "parent-ordered" parent-ordered) props)))
-
-(defun org-taskjuggler-assign-task-ids (tasks)
-  "Given a list of tasks return the same list assigning a unique id
-and the full path to each task.  Taskjuggler takes hierarchical ids.
-For that reason we have to make ids locally unique and we have to keep
-a path to the current task."
-  (let ((previous-level 0)
-       unique-ids unique-id
-       path
-       task resolved-tasks tmp)
-    (dolist (task tasks resolved-tasks)
-      (let ((level (cdr (assoc "level" task))))
-       (cond
-        ((< previous-level level)
-         (setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
-         (dotimes (tmp (- level previous-level))
-           (push (list unique-id) unique-ids)
-           (push unique-id path)))
-        ((= previous-level level)
-         (setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
-         (push unique-id (car unique-ids))
-         (setcar path unique-id))
-        ((> previous-level level)
-         (dotimes (tmp (- previous-level level))
-           (pop unique-ids)
-           (pop path))
-         (setq unique-id (org-taskjuggler-get-unique-id task (car unique-ids)))
-         (push unique-id (car unique-ids))
-         (setcar path unique-id)))
-       (push (cons "unique-id" unique-id) task)
-       (push (cons "path" (mapconcat 'identity (reverse path) ".")) task)
-       (setq previous-level level)
-       (setq resolved-tasks (append resolved-tasks (list task)))))))
-
-(defun org-taskjuggler-compute-task-leafiness (tasks)
-  "Figure out if each task is a leaf by looking at it's level,
-and the level of its successor.  If the successor is higher (ie
-deeper), then it's not a leaf."
-  (let (new-list)
-    (while (car tasks)
-      (let ((task (car tasks))
-           (successor (car (cdr tasks))))
-       (cond
-        ;; if a task has no successors it is a leaf
-        ((null successor)
-         (push (cons (cons "leaf-node" t) task) new-list))
-        ;; if the successor has a lower level than task it is a leaf
-        ((<= (cdr (assoc "level" successor)) (cdr (assoc "level" task)))
-         (push (cons (cons "leaf-node" t) task) new-list))
-        ;; otherwise examine the rest of the tasks
-        (t (push task new-list))))
-      (setq tasks (cdr tasks)))
-    (nreverse new-list)))
-
-(defun org-taskjuggler-assign-resource-ids (resources)
-  "Given a list of resources return the same list, assigning a
-unique id to each resource."
-  (let (unique-ids new-list)
-    (dolist (resource resources new-list)
-      (let ((unique-id (org-taskjuggler-get-unique-id resource unique-ids)))
-       (push (cons "unique-id" unique-id) resource)
-       (push unique-id unique-ids)
-       (push resource new-list)))
-    (nreverse new-list)))
-
-(defun org-taskjuggler-resolve-dependencies (tasks)
-  (let ((previous-level 0)
-       siblings
-       task resolved-tasks)
-    (dolist (task tasks resolved-tasks)
-      (let* ((level (cdr (assoc "level" task)))
-            (depends (cdr (assoc "depends" task)))
-            (parent-ordered (cdr (assoc "parent-ordered" task)))
-            (blocker (cdr (assoc "BLOCKER" task)))
-            (blocked-on-previous
-             (and blocker (string-match "previous-sibling" blocker)))
-            (dependencies
-             (org-taskjuggler-resolve-explicit-dependencies
-              (append
-               (and depends (org-taskjuggler-tokenize-dependencies depends))
-               (and blocker (org-taskjuggler-tokenize-dependencies blocker)))
-              tasks))
-            previous-sibling)
-                                       ; update previous sibling info
-       (cond
-        ((< previous-level level)
-         (dotimes (tmp (- level previous-level))
-           (push task siblings)))
-        ((= previous-level level)
-         (setq previous-sibling (car siblings))
-         (setcar siblings task))
-        ((> previous-level level)
-         (dotimes (tmp (- previous-level level))
-           (pop siblings))
-         (setq previous-sibling (car siblings))
-         (setcar siblings task)))
-                                       ; insert a dependency on previous sibling if the parent is
-                                       ; ordered or if the tasks has a BLOCKER attribute with value "previous-sibling"
-       (when (or (and previous-sibling parent-ordered) blocked-on-previous)
-         (push (format "!%s" (cdr (assoc "unique-id" previous-sibling))) dependencies))
-                                       ; store dependency information
-       (when dependencies
-         (push (cons "depends" (mapconcat 'identity dependencies ", ")) task))
-       (setq previous-level level)
-       (setq resolved-tasks (append resolved-tasks (list task)))))))
-
-(defun org-taskjuggler-tokenize-dependencies (dependencies)
-  "Split a dependency property value DEPENDENCIES into the
-individual dependencies and return them as a list while keeping
-the optional arguments (such as gapduration) for the
-dependencies.  A dependency will have to match `[-a-zA-Z0-9_]+'."
-  (cond
-   ((string-match "^ *$" dependencies) nil)
-   ((string-match "^[ \t]*\\([-a-zA-Z0-9_]+\\([ \t]*{[^}]+}\\)?\\)[ \t,]*" dependencies)
-    (cons
-     (substring dependencies (match-beginning 1) (match-end 1))
-     (org-taskjuggler-tokenize-dependencies (substring dependencies (match-end 0)))))
-   (t (error (format "invalid dependency id %s" dependencies)))))
-
-(defun org-taskjuggler-resolve-explicit-dependencies (dependencies tasks)
-  "For each dependency in DEPENDENCIES try to find a
-corresponding task with a matching property \"task_id\" in TASKS.
-Return a list containing the resolved links for all DEPENDENCIES
-where a matching tasks was found.  If the dependency is
-\"previous-sibling\" it is ignored (as this is dealt with in
-`org-taskjuggler-resolve-dependencies'). If there is no matching
-task the dependency is ignored and a warning is displayed ."
-  (unless (null dependencies)
-    (let*
-       ;; the dependency might have optional attributes such as "{
-       ;; gapduration 5d }", so only use the first string as id for the
-       ;; dependency
-       ((dependency (car dependencies))
-        (id (car (split-string dependency)))
-        (optional-attributes
-         (mapconcat 'identity (cdr (split-string dependency)) " "))
-        (path (org-taskjuggler-find-task-with-id id tasks)))
-      (cond
-       ;; ignore previous sibling dependencies
-       ((equal (car dependencies) "previous-sibling")
-       (org-taskjuggler-resolve-explicit-dependencies (cdr dependencies) tasks))
-       ;; if the id is found in another task use its path
-       ((not (null path))
-       (cons (mapconcat 'identity (list path optional-attributes) " ")
-             (org-taskjuggler-resolve-explicit-dependencies
-              (cdr dependencies) tasks)))
-       ;; warn about dangling dependency but otherwise ignore it
-       (t (display-warning
-          'org-export-taskjuggler
-          (format "No task with matching property \"task_id\" found for id %s" id))
-         (org-taskjuggler-resolve-explicit-dependencies (cdr dependencies) tasks))))))
-
-(defun org-taskjuggler-find-task-with-id (id tasks)
-  "Find ID in tasks.  If found return the path of task.  Otherwise
-return nil."
-  (let ((task-id (cdr (assoc "task_id" (car tasks))))
-       (path (cdr (assoc "path" (car tasks)))))
-    (cond
-     ((null tasks) nil)
-     ((equal task-id id) path)
-     (t (org-taskjuggler-find-task-with-id id (cdr tasks))))))
-
-(defun org-taskjuggler-get-unique-id (item unique-ids)
-  "Return a unique id for an ITEM which can be a task or a resource.
-The id is derived from the headline and made unique against
-UNIQUE-IDS. If the (downcased) first token of the headline is not
-unique try to add more (downcased) tokens of the headline or
-finally add more underscore characters (\"_\")."
-  (let* ((headline (cdr (assoc "headline" item)))
-        (parts (split-string headline))
-        (id (org-taskjuggler-clean-id (downcase (pop parts)))))
-                                       ; try to add more parts of the headline to make it unique
-    (while (and (member id unique-ids) (car parts))
-      (setq id (concat id "_" (org-taskjuggler-clean-id (downcase (pop parts))))))
-                                       ; if its still not unique add "_"
-    (while (member id unique-ids)
-      (setq id (concat id "_")))
-    id))
-
-(defun org-taskjuggler-clean-id (id)
-  "Clean and return ID to make it acceptable for taskjuggler."
-  (and id
-       ;; replace non-ascii by _
-       (replace-regexp-in-string
-       "[^a-zA-Z0-9_]" "_"
-       ;; make sure id doesn't start with a number
-       (replace-regexp-in-string "^\\([0-9]\\)" "_\\1" id))))
-
-(defun org-taskjuggler-open-project (project)
-  "Insert the beginning of a project declaration.  All valid
-attributes from the PROJECT alist are inserted.  If no end date is
-specified it is calculated
-`org-export-taskjuggler-default-project-duration' days from now."
-  (let* ((unique-id (cdr (assoc "unique-id" project)))
-        (headline (cdr (assoc "headline" project)))
-        (version (cdr (assoc "version" project)))
-        (start (cdr (assoc "start" project)))
-        (end (cdr (assoc "end" project))))
-    (insert
-     (format "project %s \"%s\" \"%s\" %s +%sd {\n }\n"
-            unique-id headline version start
-            org-export-taskjuggler-default-project-duration))))
-
-(defun org-taskjuggler-filter-and-join (items)
-  "Filter all nil elements from ITEMS and join the remaining ones
-with separator \"\n\"."
-  (let ((filtered-items (remq nil items)))
-    (and filtered-items (mapconcat 'identity filtered-items "\n"))))
-
-(defun org-taskjuggler-get-attributes (item attributes)
-  "Return all attribute as a single formatted string.  ITEM is an
-alist representing either a resource or a task.  ATTRIBUTES is a
-list of symbols.  Only entries from ITEM are considered that are
-listed in ATTRIBUTES."
-  (org-taskjuggler-filter-and-join
-   (mapcar
-    (lambda (attribute)
-      (org-taskjuggler-filter-and-join
-       (org-taskjuggler-get-attribute item attribute)))
-    attributes)))
-
-(defun org-taskjuggler-get-attribute (item attribute)
-  "Return a list of strings containing the properly formatted
-taskjuggler declaration for a given ATTRIBUTE in ITEM (an alist).
-If the ATTRIBUTE is not in ITEM return nil."
-  (cond
-   ((null item) nil)
-   ((equal (symbol-name attribute) (car (car item)))
-    (cons (format "%s %s" (symbol-name attribute) (cdr (car item)))
-         (org-taskjuggler-get-attribute (cdr item) attribute)))
-   (t (org-taskjuggler-get-attribute (cdr item) attribute))))
-
-(defun org-taskjuggler-open-resource (resource)
-  "Insert the beginning of a resource declaration.  All valid
-attributes from the RESOURCE alist are inserted.  If the RESOURCE
-defines a property \"resource_id\" it will be used as the id for
-this resource.  Otherwise it will use the ID property.  If neither
-is defined it will calculate a unique id for the resource using
-`org-taskjuggler-get-unique-id'."
-  (let ((id (org-taskjuggler-clean-id
-            (or (cdr (assoc "resource_id" resource))
-                (cdr (assoc "ID" resource))
-                (cdr (assoc "unique-id" resource)))))
-       (headline (cdr (assoc "headline" resource)))
-       (attributes '(limits vacation shift booking efficiency journalentry rate)))
-    (insert
-     (concat
-      "resource " id " \"" headline "\" {\n "
-      (org-taskjuggler-get-attributes resource attributes) "\n"))))
-
-(defun org-taskjuggler-clean-effort (effort)
-  "Translate effort strings into a format acceptable to taskjuggler,
-i.e.  REAL UNIT. A valid effort string can be anything that is
-accepted by `org-duration-string-to-minutes´."
-  (cond
-   ((null effort) effort)
-   (t (let* ((minutes (org-duration-string-to-minutes effort))
-            (hours (/ minutes 60.0)))
-       (format "%.1fh" hours)))))
-
-(defun org-taskjuggler-get-priority (priority)
-  "Return a priority between 1 and 1000 based on PRIORITY, an
-org-mode priority string."
-  (max 1 (/ (* 1000 (- org-lowest-priority (string-to-char priority)))
-           (- org-lowest-priority org-highest-priority))))
-
-(defun org-taskjuggler-open-task (task)
-  (let* ((unique-id (cdr (assoc "unique-id" task)))
-        (headline (cdr (assoc "headline" task)))
-        (effort (org-taskjuggler-clean-effort (cdr (assoc org-effort-property task))))
-        (depends (cdr (assoc "depends" task)))
-        (allocate (cdr (assoc "allocate" task)))
-        (priority-raw (cdr (assoc "PRIORITY" task)))
-        (priority (and priority-raw (org-taskjuggler-get-priority priority-raw)))
-        (state (cdr (assoc "TODO" task)))
-        (complete (or (and (member state org-done-keywords) "100")
-                      (cdr (assoc "complete" task))))
-        (parent-ordered (cdr (assoc "parent-ordered" task)))
-        (previous-sibling (cdr (assoc "previous-sibling" task)))
-        (milestone (or (cdr (assoc "milestone" task))
-                       (and (assoc "leaf-node" task)
-                            (not (or effort
-                                     (cdr (assoc "duration" task))
-                                     (cdr (assoc "end" task))
-                                     (cdr (assoc "period" task)))))))
-        (attributes
-         '(account start note duration endbuffer endcredit end
-                   flags journalentry length maxend maxstart minend
-                   minstart period reference responsible scheduling
-                   startbuffer startcredit statusnote)))
-    (insert
-     (concat
-      "task " unique-id " \"" headline "\" {\n"
-      (if (and parent-ordered previous-sibling)
-         (format " depends %s\n" previous-sibling)
-       (and depends (format " depends %s\n" depends)))
-      (and allocate (format " purge %s\n allocate %s\n"
-                           (or (and (org-taskjuggler-targeting-tj3-p) "allocate")
-                               "allocations")
-                           allocate))
-      (and complete (format " complete %s\n" complete))
-      (and effort (format " effort %s\n" effort))
-      (and priority (format " priority %s\n" priority))
-      (and milestone (format " milestone\n"))
-
-      (org-taskjuggler-get-attributes task attributes)
-      "\n"))))
-
-(defun org-taskjuggler-close-maybe (level)
-  (while (> org-export-taskjuggler-old-level level)
-    (insert "}\n")
-    (setq org-export-taskjuggler-old-level (1- org-export-taskjuggler-old-level)))
-  (when (= org-export-taskjuggler-old-level level)
-    (insert "}\n")))
-
-(defun org-taskjuggler-insert-reports ()
-  (let (report)
-    (dolist (report org-export-taskjuggler-default-reports)
-      (insert report "\n"))))
-
-(provide 'org-taskjuggler)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-taskjuggler.el ends here
index 2351c4c19899275fb01ae5c0e7865c3b68bcea41..db7760dcaae477da611eb39709a4a8f002d19a56 100644 (file)
@@ -370,6 +370,8 @@ VALUE can be `on', `off', or `pause'."
       (message "%d minute(s) %d seconds left before next time out"
               rmins rsecs))))
 
+(defvar org-clock-sound)
+
 ;;;###autoload
 (defun org-timer-set-timer (&optional opt)
   "Prompt for a duration and set a timer.
@@ -429,7 +431,7 @@ replace any running timer."
                    (run-with-timer
                     secs nil `(lambda ()
                                 (setq org-timer-current-timer nil)
-                                (org-notify ,(format "%s: time out" hl) t)
+                                (org-notify ,(format "%s: time out" hl) ,org-clock-sound)
                                 (setq org-timer-timer-is-countdown nil)
                                 (org-timer-set-mode-line 'off)
                                 (run-hooks 'org-timer-done-hook))))
index 4fa865308e98c79f2c5066cef40338a58dc82068..63abb9d0015140a565304dbec5bd4a619a588d3d 100644 (file)
@@ -5,13 +5,13 @@
 (defun org-release ()
   "The release version of org-mode.
   Inserted by installing org-mode or when a release is made."
-   (let ((org-release "7.9.3f"))
+   (let ((org-release "8.2.3a"))
      org-release))
 ;;;###autoload
 (defun org-git-version ()
   "The Git version of org-mode.
   Inserted by installing org-mode or when a release is made."
-   (let ((org-git-version "release_7.9.3f-17-g7524ef"))
+   (let ((org-git-version "release_8.2.3a"))
      org-git-version))
 ;;;###autoload
 (defvar org-odt-data-dir "/usr/share/emacs/etc/org"
diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el
deleted file mode 100644 (file)
index fc2a34b..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-;;; org-vm.el --- Support for links to VM messages from within Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; Support for IMAP folders added
-;; by Konrad Hinsen <konrad dot hinsen at fastmail dot net>
-;; Requires VM 8.2.0a or later.
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-;; This file implements links to VM messages and folders from within Org-mode.
-;; Org-mode loads this module by default - if this is not what you want,
-;; configure the variable `org-modules'.
-
-;;; Code:
-
-(require 'org)
-
-;; Declare external functions and variables
-(declare-function vm-preview-current-message "ext:vm-page" ())
-(declare-function vm-follow-summary-cursor "ext:vm-motion" ())
-(declare-function vm-get-header-contents "ext:vm-summary"
-                 (message header-name-regexp &optional clump-sep))
-(declare-function vm-isearch-narrow "ext:vm-search" ())
-(declare-function vm-isearch-update "ext:vm-search" ())
-(declare-function vm-select-folder-buffer "ext:vm-macro" ())
-(declare-function vm-su-message-id "ext:vm-summary" (m))
-(declare-function vm-su-subject "ext:vm-summary" (m))
-(declare-function vm-summarize "ext:vm-summary" (&optional display raise))
-(declare-function vm-imap-folder-p "ext:vm-save" ())
-(declare-function vm-imap-find-spec-for-buffer "ext:vm-imap" (buffer))
-(declare-function vm-imap-folder-for-spec "ext:vm-imap" (spec))
-(declare-function vm-imap-parse-spec-to-list "ext:vm-imap" (spec))
-(declare-function vm-imap-spec-for-account "ext:vm-imap" (account))
-(defvar vm-message-pointer)
-(defvar vm-folder-directory)
-
-;; Install the link type
-(org-add-link-type "vm" 'org-vm-open)
-(org-add-link-type "vm-imap" 'org-vm-imap-open)
-(add-hook 'org-store-link-functions 'org-vm-store-link)
-
-;; Implementation
-(defun org-vm-store-link ()
-  "Store a link to a VM folder or message."
-  (when (and (or (eq major-mode 'vm-summary-mode)
-                (eq major-mode 'vm-presentation-mode))
-            (save-window-excursion
-              (vm-select-folder-buffer) buffer-file-name))
-    (and (eq major-mode 'vm-presentation-mode) (vm-summarize))
-    (vm-follow-summary-cursor)
-    (save-excursion
-      (vm-select-folder-buffer)
-      (let* ((message (car vm-message-pointer))
-            (subject (vm-su-subject message))
-            (to (vm-get-header-contents message "To"))
-            (from (vm-get-header-contents message "From"))
-             (message-id (vm-su-message-id message))
-             (link-type (if (vm-imap-folder-p) "vm-imap" "vm"))
-            (date (vm-get-header-contents message "Date"))
-            (date-ts (and date (format-time-string
-                                (org-time-stamp-format t)
-                                (date-to-time date))))
-            (date-ts-ia (and date (format-time-string
-                                   (org-time-stamp-format t t)
-                                   (date-to-time date))))
-            folder desc link)
-        (if (vm-imap-folder-p)
-           (let ((spec (vm-imap-find-spec-for-buffer (current-buffer))))
-             (setq folder (vm-imap-folder-for-spec spec)))
-          (progn
-            (setq folder (abbreviate-file-name buffer-file-name))
-            (if (and vm-folder-directory
-                     (string-match (concat "^" (regexp-quote vm-folder-directory))
-                                   folder))
-                (setq folder (replace-match "" t t folder)))))
-        (setq message-id (org-remove-angle-brackets message-id))
-       (org-store-link-props :type link-type :from from :to to :subject subject
-                             :message-id message-id)
-       (when date
-         (org-add-link-props :date date :date-timestamp date-ts
-                             :date-timestamp-inactive date-ts-ia))
-       (setq desc (org-email-link-description))
-       (setq link (concat (concat link-type ":") folder "#" message-id))
-       (org-add-link-props :link link :description desc)
-       link))))
-
-(defun org-vm-open (path)
-  "Follow a VM message link specified by PATH."
-  (let (folder article)
-    (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
-       (error "Error in VM link"))
-    (setq folder (match-string 1 path)
-         article (match-string 3 path))
-    ;; The prefix argument will be interpreted as read-only
-    (org-vm-follow-link folder article current-prefix-arg)))
-
-(defun org-vm-follow-link (&optional folder article readonly)
-  "Follow a VM link to FOLDER and ARTICLE."
-  (require 'vm)
-  (setq article (org-add-angle-brackets article))
-  (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder)
-      ;; ange-ftp or efs or tramp access
-      (let ((user (or (match-string 1 folder) (user-login-name)))
-           (host (match-string 2 folder))
-           (file (match-string 3 folder)))
-       (cond
-        ((featurep 'tramp)
-         ;; use tramp to access the file
-         (if (featurep 'xemacs)
-             (setq folder (format "[%s@%s]%s" user host file))
-           (setq folder (format "/%s@%s:%s" user host file))))
-        (t
-         ;; use ange-ftp or efs
-         (require (if (featurep 'xemacs) 'efs 'ange-ftp))
-         (setq folder (format "/%s@%s:%s" user host file))))))
-  (when folder
-    (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
-    (when article
-      (org-vm-select-message (org-add-angle-brackets article)))))
-
-(defun org-vm-imap-open (path)
-  "Follow a VM link to an IMAP folder."
-  (require 'vm-imap)
-  (when (string-match "\\([^:]+\\):\\([^#]+\\)#?\\(.+\\)?" path)
-    (let* ((account-name (match-string 1 path))
-           (mailbox-name (match-string 2 path))
-           (message-id  (match-string 3 path))
-           (account-spec (vm-imap-parse-spec-to-list
-                          (vm-imap-spec-for-account account-name)))
-           (mailbox-spec (mapconcat 'identity
-                                    (append (butlast account-spec 4)
-                                            (cons mailbox-name
-                                                  (last account-spec 3)))
-                                    ":")))
-      (funcall (cdr (assq 'vm-imap org-link-frame-setup))
-               mailbox-spec)
-      (when message-id
-        (org-vm-select-message (org-add-angle-brackets message-id))))))
-
-(defun org-vm-select-message (message-id)
-  "Go to the message with message-id in the current folder."
-  (require 'vm-search)
-  (sit-for 0.1)
-  (vm-select-folder-buffer)
-  (widen)
-  (let ((case-fold-search t))
-    (goto-char (point-min))
-    (if (not (re-search-forward
-              (concat "^" "message-id: *" (regexp-quote message-id))))
-        (error "Could not find the specified message in this folder"))
-    (vm-isearch-update)
-    (vm-isearch-narrow)
-    (vm-preview-current-message)
-    (vm-summarize)))
-
-(provide 'org-vm)
-
-
-
-;;; org-vm.el ends here
index e1cc99627ea1feee584906ab2b025591fa54b900..a2f29165e8d1f95b8ab8cd2ef2c2aa628c36ccd2 100644 (file)
@@ -8,12 +8,12 @@
 ;;
 ;; This file is part of GNU Emacs.
 ;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
+;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 (require 'org)
 
+(defvar w3m-current-url)
+(defvar w3m-current-title)
+
+(add-hook 'org-store-link-functions 'org-w3m-store-link)
+(defun org-w3m-store-link ()
+  "Store a link to a w3m buffer."
+  (when (eq major-mode 'w3m-mode)
+    (org-store-link-props
+     :type "w3m"
+     :link w3m-current-url
+     :url (url-view-url t)
+     :description (or w3m-current-title w3m-current-url))))
+
 (defun org-w3m-copy-for-org-mode ()
   "Copy current buffer content or active region with `org-mode' style links.
 This will encode `link-title' and `link-location' with
diff --git a/lisp/org/org-wl.el b/lisp/org/org-wl.el
deleted file mode 100644 (file)
index b755c02..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-;;; org-wl.el --- Support for links to Wanderlust messages from within Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
-;;         David Maus <dmaus at ictsoc dot de>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-
-;; This file implements links to Wanderlust messages from within Org-mode.
-;; Org-mode loads this module by default - if this is not what you want,
-;; configure the variable `org-modules'.
-
-;;; Code:
-
-(require 'org)
-
-(defgroup org-wl nil
-  "Options concerning the Wanderlust link."
-  :tag "Org Startup"
-  :group 'org-link)
-
-(defcustom org-wl-link-to-refile-destination t
-  "Create a link to the refile destination if the message is marked as refile."
-  :group 'org-wl
-  :type 'boolean)
-
-(defcustom org-wl-link-remove-filter nil
-  "Remove filter condition if message is filter folder."
-  :group 'org-wl
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-wl-shimbun-prefer-web-links nil
-  "If non-nil create web links for shimbun messages."
-  :group 'org-wl
-  :version "24.1"
-  :type 'boolean)
-
-(defcustom org-wl-nntp-prefer-web-links nil
-  "If non-nil create web links for nntp messages.
-When folder name contains string \"gmane\" link to gmane,
-googlegroups otherwise."
-  :type 'boolean
-  :version "24.1"
-  :group 'org-wl)
-
-(defcustom org-wl-disable-folder-check t
-  "Disable check for new messages when open a link."
-  :type 'boolean
-  :version "24.1"
-  :group 'org-wl)
-
-(defcustom org-wl-namazu-default-index nil
-  "Default namazu search index."
-  :type 'directory
-  :version "24.1"
-  :group 'org-wl)
-
-;; Declare external functions and variables
-(declare-function elmo-folder-exists-p "ext:elmo" (folder) t)
-(declare-function elmo-message-entity-field "ext:elmo-msgdb"
-                 (entity field &optional type))
-(declare-function elmo-message-field "ext:elmo"
-                 (folder number field &optional type) t)
-(declare-function elmo-msgdb-overview-get-entity "ext:elmo" (id msgdb) t)
-;; Backward compatibility to old version of wl
-(declare-function wl "ext:wl" () t)
-(declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t)
-(declare-function wl-summary-jump-to-msg-by-message-id "ext:wl-summary"
-                 (&optional id))
-(declare-function wl-summary-jump-to-msg "ext:wl-summary"
-                 (&optional number beg end))
-(declare-function wl-summary-line-from "ext:wl-summary" ())
-(declare-function wl-summary-line-subject "ext:wl-summary" ())
-(declare-function wl-summary-message-number "ext:wl-summary" ())
-(declare-function wl-summary-redisplay "ext:wl-summary" (&optional arg))
-(declare-function wl-summary-registered-temp-mark "ext:wl-action" (number))
-(declare-function wl-folder-goto-folder-subr "ext:wl-folder"
-                 (&optional folder sticky))
-(declare-function wl-folder-get-petname "ext:wl-folder" (name))
-(declare-function wl-folder-get-entity-from-buffer "ext:wl-folder"
-                 (&optional getid))
-(declare-function wl-folder-buffer-group-p "ext:wl-folder")
-(defvar wl-init)
-(defvar wl-summary-buffer-elmo-folder)
-(defvar wl-summary-buffer-folder-name)
-(defvar wl-folder-group-regexp)
-(defvar wl-auto-check-folder-name)
-(defvar elmo-nntp-default-server)
-
-(defconst org-wl-folder-types
-  '(("%" . imap) ("-" . nntp) ("+" . mh) ("=" . spool)
-    ("$" . archive) ("&" . pop) ("@" . shimbun) ("[" . search)
-    ("*" . multi) ("/" . filter) ("|" . pipe) ("'" . internal))
-  "List of folder indicators.  See Wanderlust manual, section 3.")
-
-;; Install the link type
-(org-add-link-type "wl" 'org-wl-open)
-(add-hook 'org-store-link-functions 'org-wl-store-link)
-
-;; Implementation
-
-(defun org-wl-folder-type (folder)
-  "Return symbol that indicates the type of FOLDER.
-FOLDER is the wanderlust folder name.  The first character of the
-folder name determines the folder type."
-  (let* ((indicator (substring folder 0 1))
-        (type (cdr (assoc indicator org-wl-folder-types))))
-    ;; maybe access or file folder
-    (when (not type)
-      (setq type
-           (cond
-            ((and (>= (length folder) 5)
-                  (string= (substring folder 0 5) "file:"))
-             'file)
-            ((and (>= (length folder) 7)
-                  (string= (substring folder 0 7) "access:"))
-             'access)
-            (t
-             nil))))
-    type))
-
-(defun org-wl-message-field (field entity)
-  "Return content of FIELD in ENTITY.
-FIELD is a symbol of a rfc822 message header field.
-ENTITY is a message entity."
-  (let ((content (elmo-message-entity-field entity field 'string)))
-    (if (listp content) (car content) content)))
-
-(defun org-wl-store-link ()
-  "Store a link to a WL message or folder."
-  (unless (eobp)
-    (cond
-     ((memq major-mode '(wl-summary-mode mime-view-mode))
-      (org-wl-store-link-message))
-     ((eq major-mode 'wl-folder-mode)
-      (org-wl-store-link-folder))
-     (t
-      nil))))
-
-(defun org-wl-store-link-folder ()
-  "Store a link to a WL folder."
-  (let* ((folder (wl-folder-get-entity-from-buffer))
-        (petname (wl-folder-get-petname folder))
-        (link (concat "wl:" folder)))
-    (save-excursion
-      (beginning-of-line)
-      (unless (and (wl-folder-buffer-group-p)
-                  (looking-at wl-folder-group-regexp))
-       (org-store-link-props :type "wl" :description petname
-                             :link link)
-       link))))
-
-(defun org-wl-store-link-message ()
-  "Store a link to a WL message."
-  (save-excursion
-    (let ((buf (if (eq major-mode 'wl-summary-mode)
-                  (current-buffer)
-                (and (boundp 'wl-message-buffer-cur-summary-buffer)
-                     wl-message-buffer-cur-summary-buffer))))
-      (when buf
-       (with-current-buffer buf
-         (let* ((msgnum (wl-summary-message-number))
-                (mark-info (wl-summary-registered-temp-mark msgnum))
-                (folder-name
-                 (if (and org-wl-link-to-refile-destination
-                          mark-info
-                          (equal (nth 1 mark-info) "o")) ; marked as refile
-                     (nth 2 mark-info)
-                   wl-summary-buffer-folder-name))
-                (folder-type (org-wl-folder-type folder-name))
-                (wl-message-entity
-                 (if (fboundp 'elmo-message-entity)
-                     (elmo-message-entity
-                      wl-summary-buffer-elmo-folder msgnum)
-                   (elmo-msgdb-overview-get-entity
-                    msgnum (wl-summary-buffer-msgdb))))
-                (message-id
-                 (org-wl-message-field 'message-id wl-message-entity))
-                (message-id-no-brackets
-                 (org-remove-angle-brackets message-id))
-                (from (org-wl-message-field 'from wl-message-entity))
-                (to (org-wl-message-field 'to wl-message-entity))
-                (xref (org-wl-message-field 'xref wl-message-entity))
-                (subject (org-wl-message-field 'subject wl-message-entity))
-                (date (org-wl-message-field 'date wl-message-entity))
-                (date-ts (and date (format-time-string
-                                    (org-time-stamp-format t)
-                                    (date-to-time date))))
-                (date-ts-ia (and date (format-time-string
-                                       (org-time-stamp-format t t)
-                                       (date-to-time date))))
-                desc link)
-
-           ;; remove text properties of subject string to avoid possible bug
-           ;; when formatting the subject
-           ;; (Emacs bug #5306, fixed)
-           (set-text-properties 0 (length subject) nil subject)
-
-           ;; maybe remove filter condition
-           (when (and (eq folder-type 'filter) org-wl-link-remove-filter)
-             (while (eq (org-wl-folder-type folder-name) 'filter)
-               (setq folder-name
-                     (replace-regexp-in-string "^/[^/]+/" "" folder-name))))
-
-           ;; maybe create http link
-           (cond
-            ((and (eq folder-type 'shimbun)
-                  org-wl-shimbun-prefer-web-links xref)
-             (org-store-link-props :type "http" :link xref :description subject
-                                   :from from :to to :message-id message-id
-                                   :message-id-no-brackets message-id-no-brackets
-                                   :subject subject))
-            ((and (eq folder-type 'nntp) org-wl-nntp-prefer-web-links)
-             (setq link
-                   (format
-                    (if (string-match "gmane\\." folder-name)
-                        "http://mid.gmane.org/%s"
-                      "http://groups.google.com/groups/search?as_umsgid=%s")
-                    (org-fixup-message-id-for-http message-id)))
-             (org-store-link-props :type "http" :link link :description subject
-                                   :from from :to to :message-id message-id
-                                   :message-id-no-brackets message-id-no-brackets
-                                   :subject subject))
-            (t
-             (org-store-link-props :type "wl" :from from :to to
-                                   :subject subject :message-id message-id
-                                   :message-id-no-brackets message-id-no-brackets)
-             (setq desc (org-email-link-description))
-             (setq link (concat "wl:" folder-name "#" message-id-no-brackets))
-             (org-add-link-props :link link :description desc)))
-           (when date
-             (org-add-link-props :date date :date-timestamp date-ts
-                                 :date-timestamp-inactive date-ts-ia))
-           (or link xref)))))))
-
-(defun org-wl-open-nntp (path)
-  "Follow the nntp: link specified by PATH."
-  (let* ((spec (split-string path "/"))
-        (server (split-string (nth 2 spec) "@"))
-        (group (nth 3 spec))
-        (article (nth 4 spec)))
-    (org-wl-open
-     (concat "-" group ":" (if (cdr server)
-                              (car (split-string (car server) ":"))
-                            "")
-            (if (string= elmo-nntp-default-server (nth 2 spec))
-                ""
-              (concat "@" (or (cdr server) (car server))))
-            (if article (concat "#" article) "")))))
-
-(defun org-wl-open (path)
-  "Follow the WL message link specified by PATH.
-When called with one prefix, open message in namazu search folder
-with `org-wl-namazu-default-index' as search index.  When called
-with two prefixes or `org-wl-namazu-default-index' is nil, ask
-for namazu index."
-  (require 'wl)
-  (let ((wl-auto-check-folder-name
-        (if org-wl-disable-folder-check
-            'none
-          wl-auto-check-folder-name)))
-    (unless wl-init (wl))
-    ;; XXX: The imap-uw's MH folder names start with "%#".
-    (if (not (string-match "\\`\\(\\(?:%#\\)?[^#]+\\)\\(#\\(.*\\)\\)?" path))
-       (error "Error in Wanderlust link"))
-    (let ((folder (match-string 1 path))
-         (article (match-string 3 path)))
-      ;; maybe open message in namazu search folder
-      (when current-prefix-arg
-       (setq folder (concat "[" article "]"
-                            (if (and (equal current-prefix-arg '(4))
-                                     org-wl-namazu-default-index)
-                                org-wl-namazu-default-index
-                              (read-directory-name "Namazu index: ")))))
-      (if (not (elmo-folder-exists-p (org-no-warnings
-                                     (wl-folder-get-elmo-folder folder))))
-         (error "No such folder: %s" folder))
-      (let ((old-buf (current-buffer))
-           (old-point (point-marker)))
-       (wl-folder-goto-folder-subr folder)
-       (with-current-buffer old-buf
-         ;; XXX: `wl-folder-goto-folder-subr' moves point to the
-         ;; beginning of the current line.  So, restore the point
-         ;; in the old buffer.
-         (goto-char old-point))
-       (when article
-         (if (org-string-match-p "@" article)
-             (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets
-                                                    article))
-           (or (wl-summary-jump-to-msg (string-to-number article))
-               (error "No such message: %s" article)))
-         (wl-summary-redisplay))))))
-
-(provide 'org-wl)
-
-;;; org-wl.el ends here
diff --git a/lisp/org/org-xoxo.el b/lisp/org/org-xoxo.el
deleted file mode 100644 (file)
index 1083fe1..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-;;; org-xoxo.el --- XOXO export for Org-mode
-
-;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
-
-;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Keywords: outlines, hypermedia, calendar, wp
-;; Homepage: http://orgmode.org
-;;
-;; This file is part of GNU Emacs.
-;;
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;;; Commentary:
-;; XOXO export
-
-;;; Code:
-
-(require 'org-exp)
-
-(defvar org-export-xoxo-final-hook nil
-  "Hook run after XOXO export, in the new buffer.")
-
-(defun org-export-as-xoxo-insert-into (buffer &rest output)
-  (with-current-buffer buffer
-    (apply 'insert output)))
-(put 'org-export-as-xoxo-insert-into 'lisp-indent-function 1)
-
-;;;###autoload
-(defun org-export-as-xoxo (&optional buffer)
-  "Export the org buffer as XOXO.
-The XOXO buffer is named *xoxo-<source buffer name>*"
-  (interactive (list (current-buffer)))
-  (run-hooks 'org-export-first-hook)
-  ;; A quickie abstraction
-
-  ;; Output everything as XOXO
-  (with-current-buffer (get-buffer buffer)
-    (let* ((pos (point))
-          (opt-plist (org-combine-plists (org-default-export-plist)
-                                         (org-infile-export-plist)))
-          (filename (concat (file-name-as-directory
-                             (org-export-directory :xoxo opt-plist))
-                            (file-name-sans-extension
-                             (file-name-nondirectory buffer-file-name))
-                            ".html"))
-          (out (find-file-noselect filename))
-          (last-level 1)
-          (hanging-li nil))
-      (goto-char (point-min))  ;; CD:  beginning-of-buffer is not allowed.
-      ;; Check the output buffer is empty.
-      (with-current-buffer out (erase-buffer))
-      ;; Kick off the output
-      (org-export-as-xoxo-insert-into out "<ol class='xoxo'>\n")
-      (while (re-search-forward "^\\(\\*+\\)[ \t]+\\(.+\\)" (point-max) 't)
-       (let* ((hd (match-string-no-properties 1))
-              (level (length hd))
-              (text (concat
-                     (match-string-no-properties 2)
-                     (save-excursion
-                       (goto-char (match-end 0))
-                       (let ((str ""))
-                         (catch 'loop
-                           (while 't
-                             (forward-line)
-                             (if (looking-at "^[ \t]\\(.*\\)")
-                                 (setq str (concat str (match-string-no-properties 1)))
-                               (throw 'loop str)))))))))
-
-         ;; Handle level rendering
-         (cond
-          ((> level last-level)
-           (org-export-as-xoxo-insert-into out "\n<ol>\n"))
-
-          ((< level last-level)
-           (dotimes (- (- last-level level) 1)
-             (if hanging-li
-                 (org-export-as-xoxo-insert-into out "</li>\n"))
-             (org-export-as-xoxo-insert-into out "</ol>\n"))
-           (when hanging-li
-             (org-export-as-xoxo-insert-into out "</li>\n")
-             (setq hanging-li nil)))
-
-          ((equal level last-level)
-           (if hanging-li
-               (org-export-as-xoxo-insert-into out "</li>\n")))
-          )
-
-         (setq last-level level)
-
-         ;; And output the new li
-         (setq hanging-li 't)
-         (if (equal ?+ (elt text 0))
-             (org-export-as-xoxo-insert-into out "<li class='" (substring text 1) "'>")
-           (org-export-as-xoxo-insert-into out "<li>" text))))
-
-      ;; Finally finish off the ol
-      (dotimes (- last-level 1)
-       (if hanging-li
-           (org-export-as-xoxo-insert-into out "</li>\n"))
-       (org-export-as-xoxo-insert-into out "</ol>\n"))
-
-      (goto-char pos)
-      ;; Finish the buffer off and clean it up.
-      (switch-to-buffer-other-window out)
-      (indent-region (point-min) (point-max) nil)
-      (run-hooks 'org-export-xoxo-final-hook)
-      (save-buffer)
-      (goto-char (point-min))
-      )))
-
-(provide 'org-xoxo)
-
-;; Local variables:
-;; generated-autoload-file: "org-loaddefs.el"
-;; End:
-
-;;; org-xoxo.el ends here
index cc4c93f22ebca7853c9022ff548b3acc26d78677..50d3842e03dd4a82f0e5c5e574a24e629ac42f3c 100644 (file)
@@ -4,7 +4,7 @@
 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
-;; Maintainer: Bastien Guerry <bzg at gnu dot org>
+;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Homepage: http://orgmode.org
 ;;
@@ -22,7 +22,6 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;;; Commentary:
 ;;
 (require 'find-func)
 (require 'format-spec)
 
-(load "org-loaddefs.el" t t)
+(load "org-loaddefs.el" t t t)
 
-;; `org-outline-regexp' ought to be a defconst but is let-binding in
-;; some places -- e.g. see the macro org-with-limited-levels.
+(require 'org-macs)
+(require 'org-compat)
+
+;; `org-outline-regexp' ought to be a defconst but is let-bound in
+;; some places -- e.g. see the macro `org-with-limited-levels'.
 ;;
 ;; In Org buffers, the value of `outline-regexp' is that of
 ;; `org-outline-regexp'.  The only function still directly relying on
@@ -96,42 +98,68 @@ This is similar to `org-outline-regexp' but additionally makes
 sure that we are at the beginning of the line.")
 
 (defvar org-heading-regexp "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
-  "Matches an headline, putting stars and text into groups.
+  "Matches a headline, putting stars and text into groups.
 Stars are put in group 1 and the trimmed body in group 2.")
 
 ;; Emacs 22 calendar compatibility:  Make sure the new variables are available
-(when (fboundp 'defvaralias)
-  (unless (boundp 'calendar-view-holidays-initially-flag)
-    (defvaralias 'calendar-view-holidays-initially-flag
-      'view-calendar-holidays-initially))
-  (unless (boundp 'calendar-view-diary-initially-flag)
-    (defvaralias 'calendar-view-diary-initially-flag
-      'view-diary-entries-initially))
-  (unless (boundp 'diary-fancy-buffer)
-    (defvaralias 'diary-fancy-buffer 'fancy-diary-buffer)))
+(unless (boundp 'calendar-view-holidays-initially-flag)
+  (org-defvaralias 'calendar-view-holidays-initially-flag
+    'view-calendar-holidays-initially))
+(unless (boundp 'calendar-view-diary-initially-flag)
+  (org-defvaralias 'calendar-view-diary-initially-flag
+    'view-diary-entries-initially))
+(unless (boundp 'diary-fancy-buffer)
+  (org-defvaralias 'diary-fancy-buffer 'fancy-diary-buffer))
 
 (declare-function org-inlinetask-at-task-p "org-inlinetask" ())
 (declare-function org-inlinetask-outline-regexp "org-inlinetask" ())
 (declare-function org-inlinetask-toggle-visibility "org-inlinetask" ())
 (declare-function org-pop-to-buffer-same-window "org-compat" (&optional buffer-or-name norecord label))
-(declare-function org-clock-timestamps-up "org-clock" ())
-(declare-function org-clock-timestamps-down "org-clock" ())
+(declare-function org-clock-get-last-clock-out-time "org-clock" ())
+(declare-function org-clock-timestamps-up "org-clock" (&optional n))
+(declare-function org-clock-timestamps-down "org-clock" (&optional n))
 (declare-function org-clock-sum-current-item "org-clock" (&optional tstart))
 
 (declare-function orgtbl-mode "org-table" (&optional arg))
 (declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
-(declare-function org-beamer-mode "org-beamer" ())
+(declare-function org-beamer-mode "ox-beamer" ())
 (declare-function org-table-edit-field "org-table" (arg))
 (declare-function org-table-justify-field-maybe "org-table" (&optional new))
+(declare-function org-table-set-constants "org-table" ())
+(declare-function org-table-calc-current-TBLFM "org-table" (&optional arg))
 (declare-function org-id-get-create "org-id" (&optional force))
 (declare-function org-id-find-id-file "org-id" (id))
 (declare-function org-tags-view "org-agenda" (&optional todo-only match))
 (declare-function org-agenda-list "org-agenda" (&optional arg start-day span))
+(declare-function org-agenda-redo "org-agenda" (&optional all))
 (declare-function org-table-align "org-table" ())
 (declare-function org-table-paste-rectangle "org-table" ())
 (declare-function org-table-maybe-eval-formula "org-table" ())
 (declare-function org-table-maybe-recalculate-line "org-table" ())
 
+(declare-function org-element--parse-objects "org-element"
+                 (beg end acc restriction))
+(declare-function org-element-at-point "org-element" (&optional keep-trail))
+(declare-function org-element-contents "org-element" (element))
+(declare-function org-element-context "org-element" (&optional element))
+(declare-function org-element-interpret-data "org-element"
+                 (data &optional parent))
+(declare-function org-element-map "org-element"
+                 (data types fun &optional info first-match no-recursion))
+(declare-function org-element-nested-p "org-element" (elem-a elem-b))
+(declare-function org-element-parse-buffer "org-element"
+                 (&optional granularity visible-only))
+(declare-function org-element-property "org-element" (property element))
+(declare-function org-element-put-property "org-element"
+                 (element property value))
+(declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
+(declare-function org-element--parse-objects "org-element"
+                 (beg end acc restriction))
+(declare-function org-element-parse-buffer "org-element"
+                 (&optional granularity visible-only))
+(declare-function org-element-restriction "org-element" (element))
+(declare-function org-element-type "org-element" (element))
+
 ;; load languages based on value of `org-babel-load-languages'
 (defvar org-babel-load-languages)
 
@@ -151,6 +179,34 @@ Stars are put in group 1 and the trimmed body in group 2.")
                         (intern (concat "org-babel-expand-body:" lang)))))))
        org-babel-load-languages))
 
+;;;###autoload
+(defun org-babel-load-file (file &optional compile)
+  "Load Emacs Lisp source code blocks in the Org-mode FILE.
+This function exports the source code using `org-babel-tangle'
+and then loads the resulting file using `load-file'.  With prefix
+arg (noninteractively: 2nd arg) COMPILE the tangled Emacs Lisp
+file to byte-code before it is loaded."
+  (interactive "fFile to load: \nP")
+  (require 'ob-core)
+  (let* ((age (lambda (file)
+               (float-time
+                (time-subtract (current-time)
+                               (nth 5 (or (file-attributes (file-truename file))
+                                          (file-attributes file)))))))
+        (base-name (file-name-sans-extension file))
+        (exported-file (concat base-name ".el")))
+    ;; tangle if the org-mode file is newer than the elisp file
+    (unless (and (file-exists-p exported-file)
+                (> (funcall age file) (funcall age exported-file)))
+      (setq exported-file
+           (car (org-babel-tangle-file file exported-file "emacs-lisp"))))
+    (message "%s %s"
+            (if compile
+                (progn (byte-compile-file exported-file 'load)
+                       "Compiled and loaded")
+              (progn (load-file exported-file) "Loaded"))
+            exported-file)))
+
 (defcustom org-babel-load-languages '((emacs-lisp . t))
   "Languages which can be evaluated in Org-mode buffers.
 This list can be used to load support for any of the languages
@@ -188,6 +244,7 @@ requirements) is loaded."
                 (const :tag "Ledger" ledger)
                 (const :tag "Lilypond" lilypond)
                 (const :tag "Lisp" lisp)
+                (const :tag "Makefile" makefile)
                 (const :tag "Maxima" maxima)
                 (const :tag "Matlab" matlab)
                 (const :tag "Mscgen" mscgen)
@@ -220,7 +277,6 @@ identifier."
   :group 'org-id)
 
 ;;; Version
-(require 'org-compat)
 (org-check-version)
 
 ;;;###autoload
@@ -231,11 +287,13 @@ When FULL is non-nil, use a verbose version string.
 When MESSAGE is non-nil, display a message with the version."
   (interactive "P")
   (let* ((org-dir         (ignore-errors (org-find-library-dir "org")))
-        (org-install-dir (ignore-errors (org-find-library-dir "org-loaddefs.el")))
+        (save-load-suffixes (when (boundp 'load-suffixes) load-suffixes))
+        (load-suffixes (list ".el"))
+        (org-install-dir (ignore-errors (org-find-library-dir "org-loaddefs")))
         (org-trash       (or
                           (and (fboundp 'org-release) (fboundp 'org-git-version))
-                          (load (concat org-dir "org-version.el")
-                                'noerror 'nomessage 'nosuffix)))
+                          (org-load-noerror-mustsuffix (concat org-dir "org-version"))))
+        (load-suffixes save-load-suffixes)
         (org-version (org-release))
         (git-version (org-git-version))
         (version (format "Org-mode version %s (%s @ %s)"
@@ -246,13 +304,13 @@ When MESSAGE is non-nil, display a message with the version."
                                  org-install-dir
                                (concat "mixed installation! " org-install-dir " and " org-dir))
                            "org-loaddefs.el can not be found!")))
-        (_version (if full version org-version)))
+        (version1 (if full version org-version)))
     (if (org-called-interactively-p 'interactive)
        (if here
            (insert version)
          (message version))
       (if message (message _version))
-      _version)))
+      version1)))
 
 (defconst org-version (org-version))
 
@@ -301,24 +359,25 @@ When MESSAGE is non-nil, display a message with the version."
   (when (featurep 'org)
     (org-load-modules-maybe 'force)))
 
-(when (org-bound-and-true-p org-modules)
-  (let ((a (member 'org-infojs org-modules)))
-    (and a (setcar a 'org-jsinfo))))
-
-(defcustom org-modules '(org-bbdb org-bibtex org-docview org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-w3m org-wl)
+(defcustom org-modules '(org-w3m org-bbdb org-bibtex org-docview org-gnus org-info org-irc org-mhe org-rmail)
   "Modules that should always be loaded together with org.el.
+
 If a description starts with <C>, the file is not part of Emacs
-and loading it will require that you have downloaded and properly installed
-the org-mode distribution.
+and loading it will require that you have downloaded and properly
+installed the Org mode distribution.
 
 You can also use this system to load external packages (i.e. neither Org
 core modules, nor modules from the CONTRIB directory).  Just add symbols
 to the end of the list.  If the package is called org-xyz.el, then you need
-to add the symbol `xyz', and the package must have a call to
+to add the symbol `xyz', and the package must have a call to:
+
+   \(provide 'org-xyz)
 
-   (provide 'org-xyz)"
+For export specific modules, see also `org-export-backends'."
   :group 'org
   :set 'org-set-modules
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type
   '(set :greedy t
        (const :tag "   bbdb:              Links to BBDB entries" org-bbdb)
@@ -327,26 +386,20 @@ to add the symbol `xyz', and the package must have a call to
        (const :tag "   ctags:             Access to Emacs tags with links" org-ctags)
        (const :tag "   docview:           Links to doc-view buffers" org-docview)
        (const :tag "   gnus:              Links to GNUS folders/messages" org-gnus)
+       (const :tag "   habit:             Track your consistency with habits" org-habit)
        (const :tag "   id:                Global IDs for identifying entries" org-id)
        (const :tag "   info:              Links to Info nodes" org-info)
-       (const :tag "   jsinfo:            Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
-       (const :tag "   habit:             Track your consistency with habits" org-habit)
        (const :tag "   inlinetask:        Tasks independent of outline hierarchy" org-inlinetask)
        (const :tag "   irc:               Links to IRC/ERC chat sessions" org-irc)
-       (const :tag "   mac-message:       Links to messages in Apple Mail" org-mac-message)
-       (const :tag "   mew                Links to Mew folders/messages" org-mew)
        (const :tag "   mhe:               Links to MHE folders/messages" org-mhe)
+       (const :tag "   mouse:             Additional mouse support" org-mouse)
        (const :tag "   protocol:          Intercept calls from emacsclient" org-protocol)
        (const :tag "   rmail:             Links to RMAIL folders/messages" org-rmail)
-       (const :tag "   special-blocks:    Turn blocks into LaTeX envs and HTML divs" org-special-blocks)
-       (const :tag "   vm:                Links to VM folders/messages" org-vm)
-       (const :tag "   wl:                Links to Wanderlust folders/messages" org-wl)
        (const :tag "   w3m:               Special cut/paste from w3m to Org-mode." org-w3m)
-       (const :tag "   mouse:             Additional mouse support" org-mouse)
-       (const :tag "   TaskJuggler:       Export tasks to a TaskJuggler project" org-taskjuggler)
 
        (const :tag "C  annotate-file:     Annotate a file with org syntax" org-annotate-file)
        (const :tag "C  bookmark:          Org-mode links to bookmarks" org-bookmark)
+       (const :tag "C  bullets:           Add overlays to headlines stars" org-bullets)
        (const :tag "C  checklist:         Extra functions for checklists in repeated tasks" org-checklist)
        (const :tag "C  choose:            Use TODO keywords to mark decisions states" org-choose)
        (const :tag "C  collector:         Collect properties into tables" org-collector)
@@ -354,35 +407,137 @@ to add the symbol `xyz', and the package must have a call to
        (const :tag "C  drill:             Flashcards and spaced repetition for Org-mode" org-drill)
        (const :tag "C  elisp-symbol:      Org-mode links to emacs-lisp symbols" org-elisp-symbol)
        (const :tag "C  eshell             Support for links to working directories in eshell" org-eshell)
-       (const :tag "C  eval:              Include command output as text" org-eval)
        (const :tag "C  eval-light:        Evaluate inbuffer-code on demand" org-eval-light)
+       (const :tag "C  eval:              Include command output as text" org-eval)
        (const :tag "C  expiry:            Expiry mechanism for Org-mode entries" org-expiry)
-       (const :tag "C  exp-bibtex:        Export citations using BibTeX" org-exp-bibtex)
+       (const :tag "C  favtable:          Lookup table of favorite references and links" org-favtable)
        (const :tag "C  git-link:          Provide org links to specific file version" org-git-link)
        (const :tag "C  interactive-query: Interactive modification of tags query\n\t\t\t(PARTIALLY OBSOLETE, see secondary filtering)" org-interactive-query)
-
         (const :tag "C  invoice:           Help manage client invoices in Org-mode" org-invoice)
-
        (const :tag "C  jira:              Add a jira:ticket protocol to Org-mode" org-jira)
        (const :tag "C  learn:             SuperMemo's incremental learning algorithm" org-learn)
-       (const :tag "C  mairix:            Hook mairix search into Org-mode for different MUAs" org-mairix)
-       (const :tag "C  notmuch:           Provide org links to notmuch searches or messages" org-notmuch)
        (const :tag "C  mac-iCal           Imports events from iCal.app to the Emacs diary" org-mac-iCal)
-       (const :tag "C  mac-link-grabber   Grab links and URLs from various Mac applications" org-mac-link-grabber)
+       (const :tag "C  mac-link:          Grab links and url from various mac Applications" org-mac-link)
+       (const :tag "C  mairix:            Hook mairix search into Org-mode for different MUAs" org-mairix)
        (const :tag "C  man:               Support for links to manpages in Org-mode" org-man)
+       (const :tag "C  mew:               Links to Mew folders/messages" org-mew)
        (const :tag "C  mtags:             Support for muse-like tags" org-mtags)
+       (const :tag "C  notmuch:           Provide org links to notmuch searches or messages" org-notmuch)
        (const :tag "C  panel:             Simple routines for us with bad memory" org-panel)
        (const :tag "C  registry:          A registry for Org-mode links" org-registry)
-       (const :tag "C  org2rem:           Convert org appointments into reminders" org2rem)
        (const :tag "C  screen:            Visit screen sessions through Org-mode links" org-screen)
        (const :tag "C  secretary:         Team management with org-mode" org-secretary)
        (const :tag "C  sqlinsert:         Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert)
        (const :tag "C  toc:               Table of contents for Org-mode buffer" org-toc)
        (const :tag "C  track:             Keep up with Org-mode development" org-track)
        (const :tag "C  velocity           Something like Notational Velocity for Org" org-velocity)
+       (const :tag "C  vm:                Links to VM folders/messages" org-vm)
        (const :tag "C  wikinodes:         CamelCase wiki-like links" org-wikinodes)
+       (const :tag "C  wl:                Links to Wanderlust folders/messages" org-wl)
        (repeat :tag "External packages" :inline t (symbol :tag "Package"))))
 
+(defvar org-export--registered-backends) ; From ox.el.
+(declare-function org-export-derived-backend-p "ox" (backend &rest backends))
+(declare-function org-export-backend-name "ox" (backend))
+(defcustom org-export-backends '(ascii html icalendar latex)
+  "List of export back-ends that should be always available.
+
+If a description starts with <C>, the file is not part of Emacs
+and loading it will require that you have downloaded and properly
+installed the Org mode distribution.
+
+Unlike to `org-modules', libraries in this list will not be
+loaded along with Org, but only once the export framework is
+needed.
+
+This variable needs to be set before org.el is loaded.  If you
+need to make a change while Emacs is running, use the customize
+interface or run the following code, where VAL stands for the new
+value of the variable, after updating it:
+
+  \(progn
+    \(setq org-export--registered-backends
+          \(org-remove-if-not
+           \(lambda (backend)
+             \(let ((name (org-export-backend-name backend)))
+               \(or (memq name val)
+                   \(catch 'parentp
+                     \(dolist (b val)
+                       \(and (org-export-derived-backend-p b name)
+                            \(throw 'parentp t)))))))
+           org-export--registered-backends))
+    \(let ((new-list (mapcar 'org-export-backend-name
+                            org-export--registered-backends)))
+      \(dolist (backend val)
+        \(cond
+         \((not (load (format \"ox-%s\" backend) t t))
+          \(message \"Problems while trying to load export back-end `%s'\"
+                   backend))
+         \((not (memq backend new-list)) (push backend new-list))))
+      \(set-default 'org-export-backends new-list)))
+
+Adding a back-end to this list will also pull the back-end it
+depends on, if any."
+  :group 'org
+  :group 'org-export
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :initialize 'custom-initialize-set
+  :set (lambda (var val)
+        (if (not (featurep 'ox)) (set-default var val)
+          ;; Any back-end not required anymore (not present in VAL and not
+          ;; a parent of any back-end in the new value) is removed from the
+          ;; list of registered back-ends.
+          (setq org-export--registered-backends
+                (org-remove-if-not
+                 (lambda (backend)
+                   (let ((name (org-export-backend-name backend)))
+                     (or (memq name val)
+                         (catch 'parentp
+                           (dolist (b val)
+                             (and (org-export-derived-backend-p b name)
+                                  (throw 'parentp t)))))))
+                 org-export--registered-backends))
+          ;; Now build NEW-LIST of both new back-ends and required
+          ;; parents.
+          (let ((new-list (mapcar 'org-export-backend-name
+                                  org-export--registered-backends)))
+            (dolist (backend val)
+              (cond
+               ((not (load (format "ox-%s" backend) t t))
+                (message "Problems while trying to load export back-end `%s'"
+                         backend))
+               ((not (memq backend new-list)) (push backend new-list))))
+            ;; Set VAR to that list with fixed dependencies.
+            (set-default var new-list))))
+  :type '(set :greedy t
+             (const :tag "   ascii       Export buffer to ASCII format" ascii)
+             (const :tag "   beamer      Export buffer to Beamer presentation" beamer)
+             (const :tag "   html        Export buffer to HTML format" html)
+             (const :tag "   icalendar   Export buffer to iCalendar format" icalendar)
+             (const :tag "   latex       Export buffer to LaTeX format" latex)
+             (const :tag "   man         Export buffer to MAN format" man)
+             (const :tag "   md          Export buffer to Markdown format" md)
+             (const :tag "   odt         Export buffer to ODT format" odt)
+             (const :tag "   org         Export buffer to Org format" org)
+             (const :tag "   texinfo     Export buffer to Texinfo format" texinfo)
+             (const :tag "C  confluence  Export buffer to Confluence Wiki format" confluence)
+             (const :tag "C  deck        Export buffer to deck.js presentations" deck)
+             (const :tag "C  freemind    Export buffer to Freemind mindmap format" freemind)
+             (const :tag "C  groff       Export buffer to Groff format" groff)
+             (const :tag "C  koma-letter Export buffer to KOMA Scrlttrl2 format" koma-letter)
+             (const :tag "C  RSS 2.0     Export buffer to RSS 2.0 format" rss)
+             (const :tag "C  s5          Export buffer to s5 presentations" s5)
+             (const :tag "C  taskjuggler Export buffer to TaskJuggler format" taskjuggler)))
+
+(eval-after-load 'ox
+  '(mapc
+    (lambda (backend)
+      (condition-case nil (require (intern (format "ox-%s" backend)))
+       (error (message "Problems while trying to load export back-end `%s'"
+                       backend))))
+    org-export-backends))
+
 (defcustom org-support-shift-select nil
   "Non-nil means make shift-cursor commands select text when possible.
 
@@ -498,7 +653,7 @@ the following lines anywhere in the buffer:
          (const :tag "Globally (slow on startup in large files)" t)))
 
 (defcustom org-use-sub-superscripts t
-  "Non-nil means interpret \"_\" and \"^\" for export.
+  "Non-nil means interpret \"_\" and \"^\" for display.
 When this option is turned on, you can use TeX-like syntax for sub- and
 superscripts.  Several characters after \"_\" or \"^\" will be
 considered as a single item - so grouping with {} is normally not
@@ -511,27 +666,18 @@ sub- or superscripts.
                         terminated by almost any nonword/nondigit char.
  x_{i^2} or   x^(2-i)    braces or parenthesis do grouping.
 
-Still, ambiguity is possible - so when in doubt use {} to enclose the
-sub/superscript.  If you set this variable to the symbol `{}',
-the braces are *required* in order to trigger interpretations as
-sub/superscript.  This can be helpful in documents that need \"_\"
-frequently in plain text.
-
-Not all export backends support this, but HTML does.
-
-This option can also be set with the #+OPTIONS line, e.g. \"^:nil\"."
+Still, ambiguity is possible - so when in doubt use {} to enclose
+the sub/superscript.  If you set this variable to the symbol
+`{}', the braces are *required* in order to trigger
+interpretations as sub/superscript.  This can be helpful in
+documents that need \"_\" frequently in plain text."
   :group 'org-startup
-  :group 'org-export-translation
   :version "24.1"
   :type '(choice
          (const :tag "Always interpret" t)
          (const :tag "Only with braces" {})
          (const :tag "Never interpret" nil)))
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-export-with-sub-superscripts 'org-use-sub-superscripts))
-
-
 (defcustom org-startup-with-beamer-mode nil
   "Non-nil means turn on `org-beamer-mode' on startup.
 This can also be configured on a per-file basis by adding one of
@@ -563,6 +709,18 @@ the following lines anywhere in the buffer:
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-startup-with-latex-preview nil
+  "Non-nil means preview LaTeX fragments when loading a new Org file.
+
+This can also be configured on a per-file basis by adding one of
+the following lines anywhere in the buffer:
+   #+STARTUP: latexpreview
+   #+STARTUP: nolatexpreview"
+  :group 'org-startup
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
 (defcustom org-insert-mode-line-in-empty-file nil
   "Non-nil means insert the first line setting Org-mode in empty files.
 When the function `org-mode' is called interactively in an empty file, this
@@ -602,8 +760,7 @@ it work for ESC."
   :group 'org-startup
   :type 'boolean)
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-CUA-compatible 'org-replace-disputed-keys))
+(org-defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)
 
 (defcustom org-disputed-keys
   '(([(shift up)]              . [(meta p)])
@@ -695,6 +852,14 @@ Changes become only effective after restarting Emacs."
   :group 'org-keywords
   :type 'string)
 
+(defcustom org-closed-keep-when-no-todo nil
+  "Remove CLOSED: time-stamp when switching back to a non-todo state?"
+  :group 'org-todo
+  :group 'org-keywords
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
 (defconst org-planning-or-clock-line-re (concat "^[ \t]*\\("
                                                org-scheduled-string "\\|"
                                                org-deadline-string "\\|"
@@ -786,7 +951,7 @@ contexts.  See `org-show-hierarchy-above' for valid contexts."
   :group 'org-reveal-location
   :type org-context-choice)
 
-(defcustom org-show-siblings '((default . nil) (isearch t))
+(defcustom org-show-siblings '((default . nil) (isearch t) (bookmark-jump t))
   "Non-nil means show all sibling heading when revealing a location.
 Org-mode often shows locations in an org-mode file which might have
 been invisible before.  When this is set, the sibling of the current entry
@@ -800,7 +965,9 @@ use the command \\[org-reveal] to show more context.
 Instead of t, this can also be an alist specifying this option for different
 contexts.  See `org-show-hierarchy-above' for valid contexts."
   :group 'org-reveal-location
-  :type org-context-choice)
+  :type org-context-choice
+  :version "24.4"
+  :package-version '(Org . "8.0"))
 
 (defcustom org-show-entry-below '((default . nil))
   "Non-nil means show the entry below a headline when revealing a location.
@@ -865,6 +1032,21 @@ commands in the Help buffer using the `?' speed command."
                                (function)
                                (sexp))))))
 
+(defcustom org-bookmark-names-plist
+   '(:last-capture "org-capture-last-stored"
+     :last-refile "org-refile-last-stored"
+     :last-capture-marker "org-capture-last-stored-marker")
+   "Names for bookmarks automatically set by some Org commands.
+This can provide strings as names for a number of bookmarks Org sets
+automatically.  The following keys are currently implemented:
+  :last-capture
+  :last-capture-marker
+  :last-refile
+When a key does not show up in the property list, the corresponding bookmark
+is not set."
+   :group 'org-structure
+   :type 'plist)
+
 (defgroup org-cycle nil
   "Options concerning visibility cycling in Org-mode."
   :tag "Org Cycle"
@@ -957,8 +1139,7 @@ visibility is cycled."
                 (const :tag "Only in completely white lines" white)
                 (const :tag "Before first char in a line" whitestart)
                 (const :tag "Everywhere except in headlines" t)
-                (const :tag "Everywhere except at bol in headlines" exc-hl-bol)
-                ))
+                (const :tag "Everywhere except at bol in headlines" exc-hl-bol)))
 
 (defcustom org-cycle-separator-lines 2
   "Number of empty lines needed to keep an empty line between collapsed trees.
@@ -990,6 +1171,7 @@ the values `folded', `children', or `subtree'."
 
 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
                            org-cycle-hide-drawers
+                           org-cycle-hide-inline-tasks
                            org-cycle-show-empty-lines
                            org-optimize-window-after-visibility-change)
   "Hook that is run after `org-cycle' has changed the buffer visibility.
@@ -1083,8 +1265,7 @@ This may also be a cons cell where the behavior for `C-a' and
                        (const :tag "off" nil)
                        (const :tag "on: before tags first" t)
                        (const :tag "reversed: after tags first" reversed)))))
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e))
+(org-defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e)
 
 (defcustom org-special-ctrl-k nil
   "Non-nil means `C-k' will behave specially in headlines.
@@ -1111,6 +1292,11 @@ OK to kill that hidden subtree.  When nil, kill without remorse."
          (const :tag "Protect hidden subtrees with a security query" t)
          (const :tag "Never kill a hidden subtree with C-k" error)))
 
+(defcustom org-special-ctrl-o t
+  "Non-nil means, make `C-o' insert a row in tables."
+  :group 'org-edit-structure
+  :type 'boolean)
+
 (defcustom org-catch-invisible-edits nil
   "Check if in invisible region before inserting or deleting a character.
 Valid values are:
@@ -1180,9 +1366,8 @@ default   the value to be used for all contexts not explicitly
 (defcustom org-insert-heading-respect-content nil
   "Non-nil means insert new headings after the current subtree.
 When nil, the new heading is created directly after the current line.
-The commands \\[org-insert-heading-respect-content] and
-\\[org-insert-todo-heading-respect-content] turn this variable on
-for the duration of the command."
+The commands \\[org-insert-heading-respect-content] and \\[org-insert-todo-heading-respect-content] turn
+this variable on for the duration of the command."
   :group 'org-structure
   :type 'boolean)
 
@@ -1194,9 +1379,9 @@ and a boolean flag as CDR.  The cdr may also be the symbol `auto', in
 which case Org will look at the surrounding headings/items and try to
 make an intelligent decision whether to insert a blank line or not.
 
-For plain lists, if the variable `org-empty-line-terminates-plain-lists' is
-set, the setting here is ignored and no empty line is inserted, to avoid
-breaking the list structure."
+For plain lists, if `org-list-empty-line-terminates-plain-lists' is set,
+the setting here is ignored and no empty line is inserted to avoid breaking
+the list structure."
   :group 'org-edit-structure
   :type '(list
          (cons (const heading)
@@ -1430,7 +1615,7 @@ two parameters: the first one is the link, the second one is the
 description generated by `org-insert-link'.  The function should
 return the description to use."
   :group 'org-link
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defgroup org-link-store nil
   "Options concerning storing links in Org-mode."
@@ -1519,7 +1704,7 @@ Org contains a function for this, so if you set this variable to
 `org-translate-link-from-planner', you should be able follow many
 links created by planner."
   :group 'org-link-follow
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defcustom org-follow-link-hook nil
   "Hook that is run after a link has been followed."
@@ -1535,7 +1720,8 @@ implementation is bad."
   :type 'boolean)
 
 (defcustom org-return-follows-link nil
-  "Non-nil means on links RET will follow the link."
+  "Non-nil means on links RET will follow the link.
+In tables, the special behavior of RET has precedence."
   :group 'org-link-follow
   :type 'boolean)
 
@@ -1600,6 +1786,11 @@ another window."
                 (const vm-visit-folder)
                 (const vm-visit-folder-other-window)
                 (const vm-visit-folder-other-frame)))
+         (cons (const vm-imap)
+               (choice
+                (const vm-visit-imap-folder)
+                (const vm-visit-imap-folder-other-window)
+                (const vm-visit-imap-folder-other-frame)))
          (cons (const gnus)
                (choice
                 (const gnus)
@@ -1746,12 +1937,10 @@ The system \"open\" is used for most files.
 See `org-file-apps'.")
 
 (defcustom org-file-apps
-  '(
-    (auto-mode . emacs)
+  '((auto-mode . emacs)
     ("\\.mm\\'" . default)
     ("\\.x?html?\\'" . default)
-    ("\\.pdf\\'" . default)
-    )
+    ("\\.pdf\\'" . default))
   "External applications for opening `file:path' items in a document.
 Org-mode uses system defaults for different file types, but
 you can use this variable to set the application for a given file
@@ -1865,16 +2054,14 @@ following situations:
    note buffer with `C-1 C-c C-c'.  The user is prompted for an org file,
    with `org-directory' as the default path."
   :group 'org-refile
-  :group 'org-remember
   :group 'org-capture
   :type 'directory)
 
 (defcustom org-default-notes-file (convert-standard-filename "~/.notes")
   "Default target for storing notes.
-Used as a fall back file for org-remember.el and org-capture.el, for
-templates that do not specify a target file."
+Used as a fall back file for org-capture.el, for templates that
+do not specify a target file."
   :group 'org-refile
-  :group 'org-remember
   :group 'org-capture
   :type '(choice
          (const :tag "Default from remember-data-file" nil)
@@ -1904,7 +2091,6 @@ outline-path-completion  Headlines in the current buffer are offered via
 When nil, new notes will be filed to the end of a file or entry.
 This can also be a list with cons cells of regular expressions that
 are matched against file names, and values."
-  :group 'org-remember
   :group 'org-capture
   :group 'org-refile
   :type '(choice
@@ -2000,7 +2186,9 @@ should be continued.  For example, the function may decide that the entire
 subtree of the current entry should be excluded and move point to the end
 of the subtree."
   :group 'org-refile
-  :type 'function)
+  :type '(choice
+         (const nil)
+         (function)))
 
 (defcustom org-refile-use-cache nil
   "Non-nil means cache refile targets to speed up the process.
@@ -2157,7 +2345,12 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'."
 (defvar org-done-keywords-for-agenda nil)
 (defvar org-drawers-for-agenda nil)
 (defvar org-todo-keyword-alist-for-agenda nil)
-(defvar org-tag-alist-for-agenda nil)
+(defvar org-tag-alist-for-agenda nil
+  "Alist of all tags from all agenda files.")
+(defvar org-tag-groups-alist-for-agenda nil
+  "Alist of all groups tags from all current agenda files.")
+(defvar org-tag-groups-alist nil)
+(make-variable-buffer-local 'org-tag-groups-alist)
 (defvar org-agenda-contributing-files nil)
 (defvar org-not-done-keywords nil)
 (make-variable-buffer-local 'org-not-done-keywords)
@@ -2491,6 +2684,11 @@ also set this to a string to define the drawer of your choice.
 
 A value of t is also allowed, representing \"LOGBOOK\".
 
+A value of t or nil can also be set with on a per-file-basis with
+
+   #+STARTUP: logdrawer
+   #+STARTUP: nologdrawer
+
 If this variable is set, `org-log-state-notes-insert-after-drawers'
 will be ignored.
 
@@ -2503,8 +2701,7 @@ a subtree."
          (const :tag "LOGBOOK" t)
          (string :tag "Other")))
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-log-state-notes-into-drawer 'org-log-into-drawer))
+(org-defvaralias 'org-log-state-notes-into-drawer 'org-log-into-drawer)
 
 (defun org-log-into-drawer ()
   "Return the value of `org-log-into-drawer', but let properties overrule.
@@ -2532,7 +2729,12 @@ set."
 
 (defcustom org-log-states-order-reversed t
   "Non-nil means the latest state note will be directly after heading.
-When nil, the state change notes will be ordered according to time."
+When nil, the state change notes will be ordered according to time.
+
+This option can also be set with on a per-file-basis with
+
+   #+STARTUP: logstatesreversed
+   #+STARTUP: nologstatesreversed"
   :group 'org-todo
   :group 'org-progress
   :type 'boolean)
@@ -2629,7 +2831,9 @@ The user can set a different function here, which should take a string
 as an argument and return the numeric priority."
   :group 'org-priorities
   :version "24.1"
-  :type 'function)
+  :type '(choice
+         (const nil)
+         (function)))
 
 (defgroup org-time nil
   "Options concerning time stamps and deadlines in Org-mode."
@@ -2705,26 +2909,137 @@ commands, if custom time display is turned on at the time of export."
        (concat "[" (substring f 1 -1) "]")
       f)))
 
-(defcustom org-time-clocksum-format "%d:%02d"
+(defcustom org-time-clocksum-format
+  '(:days "%dd " :hours "%d" :require-hours t :minutes ":%02d" :require-minutes t)
   "The format string used when creating CLOCKSUM lines.
-This is also used when org-mode generates a time duration."
+This is also used when Org mode generates a time duration.
+
+The value can be a single format string containing two
+%-sequences, which will be filled with the number of hours and
+minutes in that order.
+
+Alternatively, the value can be a plist associating any of the
+keys :years, :months, :weeks, :days, :hours or :minutes with
+format strings.  The time duration is formatted using only the
+time components that are needed and concatenating the results.
+If a time unit in absent, it falls back to the next smallest
+unit.
+
+The keys :require-years, :require-months, :require-days,
+:require-weeks, :require-hours, :require-minutes are also
+meaningful.  A non-nil value for these keys indicates that the
+corresponding time component should always be included, even if
+its value is 0.
+
+
+For example,
+
+  \(:days \"%dd\" :hours \"%d\" :require-hours t :minutes \":%02d\"
+    :require-minutes t)
+
+means durations longer than a day will be expressed in days,
+hours and minutes, and durations less than a day will always be
+expressed in hours and minutes (even for durations less than an
+hour).
+
+The value
+
+  \(:days \"%dd\" :minutes \"%dm\")
+
+means durations longer than a day will be expressed in days and
+minutes, and durations less than a day will be expressed entirely
+in minutes (even for durations longer than an hour)."
   :group 'org-time
-  :type 'string)
+  :group 'org-clock
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice (string :tag "Format string")
+                (set :tag "Plist"
+                     (group :inline t (const :tag "Years" :years)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show years" :require-years)
+                            (const t))
+                     (group :inline t (const :tag "Months" :months)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show months" :require-months)
+                            (const t))
+                     (group :inline t (const :tag "Weeks" :weeks)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show weeks" :require-weeks)
+                            (const t))
+                     (group :inline t (const :tag "Days" :days)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show days" :require-days)
+                            (const t))
+                     (group :inline t (const :tag "Hours" :hours)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show hours" :require-hours)
+                            (const t))
+                     (group :inline t (const :tag "Minutes" :minutes)
+                            (string :tag "Format string"))
+                     (group :inline t
+                            (const :tag "Always show minutes" :require-minutes)
+                            (const t)))))
 
 (defcustom org-time-clocksum-use-fractional nil
-  "If non-nil, \\[org-clock-display] uses fractional times.
-org-mode generates a time duration."
+  "When non-nil, \\[org-clock-display] uses fractional times.
+See `org-time-clocksum-format' for more on time clock formats."
+  :group 'org-time
+  :group 'org-clock
+  :version "24.3"
+  :type 'boolean)
+
+(defcustom org-time-clocksum-use-effort-durations nil
+  "When non-nil, \\[org-clock-display] uses effort durations.
+E.g. by default, one day is considered to be a 8 hours effort,
+so a task that has been clocked for 16 hours will be displayed
+as during 2 days in the clock display or in the clocktable.
+
+See `org-effort-durations' on how to set effort durations
+and `org-time-clocksum-format' for more on time clock formats."
   :group 'org-time
+  :group 'org-clock
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type 'boolean)
 
 (defcustom org-time-clocksum-fractional-format "%.2f"
-  "The format string used when creating CLOCKSUM lines, or when
-org-mode generates a time duration."
+  "The format string used when creating CLOCKSUM lines,
+or when Org mode generates a time duration, if
+`org-time-clocksum-use-fractional' is enabled.
+
+The value can be a single format string containing one
+%-sequence, which will be filled with the number of hours as
+a float.
+
+Alternatively, the value can be a plist associating any of the
+keys :years, :months, :weeks, :days, :hours or :minutes with
+a format string.  The time duration is formatted using the
+largest time unit which gives a non-zero integer part.  If all
+specified formats have zero integer part, the smallest time unit
+is used."
   :group 'org-time
-  :type 'string)
+  :type '(choice (string :tag "Format string")
+                (set (group :inline t (const :tag "Years" :years)
+                           (string :tag "Format string"))
+                     (group :inline t (const :tag "Months" :months)
+                           (string :tag "Format string"))
+                     (group :inline t (const :tag "Weeks" :weeks)
+                            (string :tag "Format string"))
+                     (group :inline t (const :tag "Days" :days)
+                            (string :tag "Format string"))
+                     (group :inline t (const :tag "Hours" :hours)
+                            (string :tag "Format string"))
+                     (group :inline t (const :tag "Minutes" :minutes)
+                            (string :tag "Format string")))))
 
 (defcustom org-deadline-warning-days 14
-  "No. of days before expiration during which a deadline becomes active.
+  "Number of days before expiration during which a deadline becomes active.
 This variable governs the display in sparse trees and in the agenda.
 When 0 or negative, it means use this number (the absolute value of it)
 even if a deadline has a different individual lead time specified.
@@ -2734,6 +3049,21 @@ Custom commands can set this variable in the options section."
   :group 'org-agenda-daily/weekly
   :type 'integer)
 
+(defcustom org-scheduled-delay-days 0
+  "Number of days before a scheduled item becomes active.
+This variable governs the display in sparse trees and in the agenda.
+The default value (i.e. 0) means: don't delay scheduled item.
+When negative, it means use this number (the absolute value of it)
+even if a scheduled item has a different individual delay time
+specified.
+
+Custom commands can set this variable in the options section."
+  :group 'org-time
+  :group 'org-agenda-daily/weekly
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
 (defcustom org-read-date-prefer-future t
   "Non-nil means assume future for incomplete date input from user.
 This affects the following situations:
@@ -2821,14 +3151,19 @@ minibuffer will also be active, and you can simply enter the date as well.
 When nil, only the minibuffer will be available."
   :group 'org-time
   :type 'boolean)
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-popup-calendar-for-date-prompt
-      'org-read-date-popup-calendar))
+(org-defvaralias 'org-popup-calendar-for-date-prompt
+  'org-read-date-popup-calendar)
 
+(make-obsolete-variable
+ 'org-read-date-minibuffer-setup-hook
+ "Set `org-read-date-minibuffer-local-map' instead." "24.4")
 (defcustom org-read-date-minibuffer-setup-hook nil
   "Hook to be used to set up keys for the date/time interface.
-Add key definitions to `minibuffer-local-map', which will be a temporary
-copy."
+Add key definitions to `minibuffer-local-map', which will be a
+temporary copy.
+
+WARNING: This option is obsolete, you should use
+`org-read-date-minibuffer-local-map' to set up keys."
   :group 'org-time
   :type 'hook)
 
@@ -2856,6 +3191,15 @@ For example, if `org-extend-today-until' is 8, and it's 4am, then the
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-use-last-clock-out-time-as-effective-time nil
+  "When non-nil, use the last clock out time for `org-todo'.
+Note that this option has precedence over the combined use of
+`org-use-effective-time' and `org-extend-today-until'."
+  :group 'org-time
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
 (defcustom org-edit-timestamp-down-means-later nil
   "Non-nil means S-down will increase the time in a time stamp.
 When nil, S-up will increase."
@@ -2890,6 +3234,8 @@ See the manual for details."
           (list :tag "Start radio group"
                 (const :startgroup)
                 (option (string :tag "Group description")))
+          (list :tag "Group tags delimiter"
+                (const :grouptags))
           (list :tag "End radio group"
                 (const :endgroup)
                 (option (string :tag "Group description")))
@@ -2912,6 +3258,7 @@ To disable these tags on a per-file basis, insert anywhere in the file:
           (cons   (string    :tag "Tag name")
                   (character :tag "Access char"))
           (const :tag "Start radio group" (:startgroup))
+          (const :tag "Group tags delimiter" (:grouptags))
           (const :tag "End radio group" (:endgroup))
           (const :tag "New line" (:newline)))))
 
@@ -2949,7 +3296,7 @@ automatically if necessary."
   :type '(choice
          (const :tag "Always" t)
          (const :tag "Never" nil)
-         (const :tag "When selection characters are configured" 'auto)))
+         (const :tag "When selection characters are configured" auto)))
 
 (defcustom org-fast-tag-selection-single-key nil
   "Non-nil means fast tag selection exits after first change.
@@ -3094,7 +3441,7 @@ and the clock summary:
                    (let ((clocksum (org-clock-sum-current-item))
                          (effort (org-duration-string-to-minutes
                                    (org-entry-get (point) \"Effort\"))))
-                     (org-minutes-to-hh:mm-string (- effort clocksum))))))"
+                     (org-minutes-to-clocksum-string (- effort clocksum))))))"
   :group 'org-properties
   :version "24.1"
   :type '(alist :key-type (string     :tag "Property")
@@ -3170,7 +3517,7 @@ value           The value that should be modified.
 The function should return the value that should be displayed,
 or nil if the normal value should be used."
   :group 'org-properties
-  :type 'function)
+  :type '(choice (const nil) (function)))
 
 (defcustom org-effort-property "Effort"
   "The property that is being used to keep track of effort estimates.
@@ -3263,23 +3610,22 @@ regular expression will be included."
 
 (defcustom org-agenda-text-search-extra-files nil
   "List of extra files to be searched by text search commands.
-These files will be search in addition to the agenda files by the
+These files will be searched in addition to the agenda files by the
 commands `org-search-view' (`C-c a s') and `org-occur-in-agenda-files'.
 Note that these files will only be searched for text search commands,
 not for the other agenda views like todo lists, tag searches or the weekly
 agenda.  This variable is intended to list notes and possibly archive files
 that should also be searched by these two commands.
 In fact, if the first element in the list is the symbol `agenda-archives',
-than all archive files of all agenda files will be added to the search
+then all archive files of all agenda files will be added to the search
 scope."
   :group 'org-agenda
   :type '(set :greedy t
              (const :tag "Agenda Archives" agenda-archives)
              (repeat :inline t (file))))
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-agenda-multi-occur-extra-files
-      'org-agenda-text-search-extra-files))
+(org-defvaralias 'org-agenda-multi-occur-extra-files
+  'org-agenda-text-search-extra-files)
 
 (defcustom org-agenda-skip-unavailable-files nil
   "Non-nil means to just skip non-reachable files in `org-agenda-files'.
@@ -3340,8 +3686,10 @@ points to a file, `org-agenda-diary-entry' will be used instead."
 This is a property list with the following properties:
 :foreground  the foreground color for images embedded in Emacs, e.g. \"Black\".
              `default' means use the foreground of the default face.
+             `auto' means use the foreground from the text face.
 :background  the background color, or \"Transparent\".
              `default' means use the background of the default face.
+             `auto' means use the background from the text face.
 :scale       a scaling factor for the size of the images, to get more pixels
 :html-foreground, :html-background, :html-scale
              the same numbers for HTML export.
@@ -3408,9 +3756,10 @@ imagemagick     Convert the LaTeX fragments to pdf files and use imagemagick
          (const :tag "imagemagick" imagemagick)))
 
 (defcustom org-latex-preview-ltxpng-directory "ltxpng/"
-  "Path to store latex preview images.  A relative path here creates many
-   directories relative to the processed org files paths.  An absolute path
-   puts all preview images at the same place."
+  "Path to store latex preview images.
+A relative path here creates many directories relative to the
+processed org files paths.  An absolute path puts all preview
+images at the same place."
   :group 'org-latex
   :version "24.3"
   :type 'string)
@@ -3430,11 +3779,9 @@ imagemagick     Convert the LaTeX fragments to pdf files and use imagemagick
 
 (defcustom org-format-latex-header "\\documentclass{article}
 \\usepackage[usenames]{color}
-\\usepackage{amsmath}
-\\usepackage[mathscr]{eucal}
-\\pagestyle{empty}             % do not remove
 \[PACKAGES]
 \[DEFAULT-PACKAGES]
+\\pagestyle{empty}             % do not remove
 % The settings below are copied from fullpage.sty
 \\setlength{\\textwidth}{\\paperwidth}
 \\addtolength{\\textwidth}{-3cm}
@@ -3451,14 +3798,12 @@ imagemagick     Convert the LaTeX fragments to pdf files and use imagemagick
   "The document header used for processing LaTeX fragments.
 It is imperative that this header make sure that no page number
 appears on the page.  The package defined in the variables
-`org-export-latex-default-packages-alist' and `org-export-latex-packages-alist'
-will either replace the placeholder \"[PACKAGES]\" in this header, or they
-will be appended."
+`org-latex-default-packages-alist' and `org-latex-packages-alist'
+will either replace the placeholder \"[PACKAGES]\" in this
+header, or they will be appended."
   :group 'org-latex
   :type 'string)
 
-(defvar org-format-latex-header-extra nil)
-
 (defun org-set-packages-alist (var val)
   "Set the packages alist and make sure it has 3 elements per entry."
   (set var (mapcar (lambda (x)
@@ -3468,7 +3813,6 @@ will be appended."
                   val)))
 
 (defun org-get-packages-alist (var)
-
   "Get the packages alist and make sure it has 3 elements per entry."
   (mapcar (lambda (x)
            (if (and (consp x) (= (length x) 2))
@@ -3476,10 +3820,7 @@ will be appended."
              x))
          (default-value var)))
 
-;; The following variables are defined here because is it also used
-;; when formatting latex fragments.  Originally it was part of the
-;; LaTeX exporter, which is why the name includes "export".
-(defcustom org-export-latex-default-packages-alist
+(defcustom org-latex-default-packages-alist
   '(("AUTO" "inputenc"  t)
     ("T1"   "fontenc"   t)
     (""     "fixltx2e"  nil)
@@ -3487,36 +3828,44 @@ will be appended."
     (""     "longtable" nil)
     (""     "float"     nil)
     (""     "wrapfig"   nil)
-    (""     "soul"      t)
+    (""     "rotating"  nil)
+    ("normalem" "ulem"  t)
+    (""     "amsmath"   t)
     (""     "textcomp"  t)
     (""     "marvosym"  t)
     (""     "wasysym"   t)
-    (""     "latexsym"  t)
     (""     "amssymb"   t)
     (""     "hyperref"  nil)
-    "\\tolerance=1000"
-    )
+    "\\tolerance=1000")
   "Alist of default packages to be inserted in the header.
-Change this only if one of the packages here causes an incompatibility
-with another package you are using.
-The packages in this list are needed by one part or another of Org-mode
-to function properly.
+
+Change this only if one of the packages here causes an
+incompatibility with another package you are using.
+
+The packages in this list are needed by one part or another of
+Org mode to function properly:
 
 - inputenc, fontenc:  for basic font and character selection
-- textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used
-  for interpreting the entities in `org-entities'.  You can skip some of these
-  packages if you don't use any of the symbols in it.
+- fixltx2e: Important patches of LaTeX itself
 - graphicx: for including images
+- longtable: For multipage tables
 - float, wrapfig: for figure placement
-- longtable: for long tables
+- rotating: for sideways figures and tables
+- ulem: for underline and strike-through
+- amsmath: for subscript and superscript and math environments
+- textcomp, marvosymb, wasysym, amssymb: for various symbols used
+  for interpreting the entities in `org-entities'.  You can skip
+  some of these packages if you don't use any of their symbols.
 - hyperref: for cross references
 
-Therefore you should not modify this variable unless you know what you
-are doing.  The one reason to change it anyway is that you might be loading
-some other package that conflicts with one of the default packages.
-Each cell is of the format \( \"options\" \"package\" snippet-flag\).
-If SNIPPET-FLAG is t, the package also needs to be included when
-compiling LaTeX snippets into images for inclusion into HTML."
+Therefore you should not modify this variable unless you know
+what you are doing.  The one reason to change it anyway is that
+you might be loading some other package that conflicts with one
+of the default packages.  Each cell is of the format
+\( \"options\" \"package\" snippet-flag).  If SNIPPET-FLAG is t,
+the package also needs to be included when compiling LaTeX
+snippets into images for inclusion into non-LaTeX output."
+  :group 'org-latex
   :group 'org-export-latex
   :set 'org-set-packages-alist
   :get 'org-get-packages-alist
@@ -3529,17 +3878,25 @@ compiling LaTeX snippets into images for inclusion into HTML."
                 (boolean :tag "Snippet"))
           (string :tag "A line of LaTeX"))))
 
-(defcustom org-export-latex-packages-alist nil
+(defcustom org-latex-packages-alist nil
   "Alist of packages to be inserted in every LaTeX header.
-These will be inserted after `org-export-latex-default-packages-alist'.
-Each cell is of the format \( \"options\" \"package\" snippet-flag \).
-SNIPPET-FLAG, when t, indicates that this package is also needed when
-turning LaTeX snippets into images for inclusion into HTML.
+
+These will be inserted after `org-latex-default-packages-alist'.
+Each cell is of the format:
+
+    \(\"options\" \"package\" snippet-flag)
+
+SNIPPET-FLAG, when t, indicates that this package is also needed
+when turning LaTeX snippets into images for inclusion into
+non-LaTeX output.
+
 Make sure that you only list packages here which:
-- you want in every file
-- do not conflict with the default packages in
-  `org-export-latex-default-packages-alist'
-- do not conflict with the setup in `org-format-latex-header'."
+
+  - you want in every file
+  - do not conflict with the setup in `org-format-latex-header'.
+  - do not conflict with the default packages in
+    `org-latex-default-packages-alist'."
+  :group 'org-latex
   :group 'org-export-latex
   :set 'org-set-packages-alist
   :get 'org-get-packages-alist
@@ -3551,7 +3908,6 @@ Make sure that you only list packages here which:
                 (boolean :tag "Snippet"))
           (string :tag "A line of LaTeX"))))
 
-
 (defgroup org-appearance nil
   "Settings for Org-mode appearance."
   :tag "Org Appearance"
@@ -3622,10 +3978,22 @@ org-level-* faces."
   :group 'org-appearance
   :type 'boolean)
 
-(defcustom org-highlight-latex-fragments-and-specials nil
-  "Non-nil means fontify what is treated specially by the exporters."
+(defcustom org-highlight-latex-and-related nil
+  "Non-nil means highlight LaTeX related syntax in the buffer.
+When non nil, the value should be a list containing any of the
+following symbols:
+  `latex'    Highlight LaTeX snippets and environments.
+  `script'   Highlight subscript and superscript.
+  `entities' Highlight entities."
   :group 'org-appearance
-  :type 'boolean)
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "No highlighting" nil)
+         (set :greedy t :tag "Highlight"
+              (const :tag "LaTeX snippets and environments" latex)
+              (const :tag "Subscript and superscript" script)
+              (const :tag "Entities" entities))))
 
 (defcustom org-hide-emphasis-markers nil
   "Non-nil mean font-lock should hide the emphasis marker characters."
@@ -3674,7 +4042,7 @@ After a match, the match groups contain these elements:
           (body1 (concat body "*?"))
           (markers (mapconcat 'car org-emphasis-alist ""))
           (vmarkers (mapconcat
-                     (lambda (x) (if (eq (nth 4 x) 'verbatim) (car x) ""))
+                     (lambda (x) (if (eq (nth 2 x) 'verbatim) (car x) ""))
                      org-emphasis-alist "")))
       ;; make sure special characters appear at the right position in the class
       (if (string-match "\\^" markers)
@@ -3714,7 +4082,10 @@ After a match, the match groups contain these elements:
                    "\\3\\)"
                    "\\([" post  "]\\|$\\)")))))
 
-(defcustom org-emphasis-regexp-components
+;; This used to be a defcustom (Org <8.0) but allowing the users to
+;; set this option proved cumbersome.  See this message/thread:
+;; http://article.gmane.org/gmane.emacs.orgmode/68681
+(defvar org-emphasis-regexp-components
   '(" \t('\"{" "- \t.,:!?;'\")}\\" " \t\r\n,\"'" "." 1)
   "Components used to build the regular expression for emphasis.
 This is a list with five entries.  Terminology:  In an emphasis string
@@ -3730,48 +4101,36 @@ body-regexp  A regexp like \".\" to match a body character.  Don't use
              non-shy groups here, and don't allow newline here.
 newline      The maximum number of newlines allowed in an emphasis exp.
 
-Use customize to modify this, or restart Emacs after changing it."
-  :group 'org-appearance
-  :set 'org-set-emph-re
-  :type '(list
-         (sexp    :tag "Allowed chars in pre      ")
-         (sexp    :tag "Allowed chars in post     ")
-         (sexp    :tag "Forbidden chars in border ")
-         (sexp    :tag "Regexp for body           ")
-         (integer :tag "number of newlines allowed")
-         (option (boolean :tag "Please ignore this button"))))
+You need to reload Org or to restart Emacs after customizing this.")
 
 (defcustom org-emphasis-alist
-  `(("*" bold "<b>" "</b>")
-    ("/" italic "<i>" "</i>")
-    ("_" underline "<span style=\"text-decoration:underline;\">" "</span>")
-    ("=" org-code "<code>" "</code>" verbatim)
-    ("~" org-verbatim "<code>" "</code>" verbatim)
-    ("+" ,(if (featurep 'xemacs) 'org-table '(:strike-through t))
-     "<del>" "</del>")
-    )
-  "Special syntax for emphasized text.
-Text starting and ending with a special character will be emphasized, for
-example *bold*, _underlined_ and /italic/.  This variable sets the marker
-characters, the face to be used by font-lock for highlighting in Org-mode
-Emacs buffers, and the HTML tags to be used for this.
-For LaTeX export, see the variable `org-export-latex-emphasis-alist'.
-For DocBook export, see the variable `org-export-docbook-emphasis-alist'.
-Use customize to modify this, or restart Emacs after changing it."
+  `(("*" bold)
+    ("/" italic)
+    ("_" underline)
+    ("=" org-code verbatim)
+    ("~" org-verbatim verbatim)
+    ("+" ,(if (featurep 'xemacs) 'org-table '(:strike-through t))))
+  "Alist of characters and faces to emphasize text.
+Text starting and ending with a special character will be emphasized,
+for example *bold*, _underlined_ and /italic/.  This variable sets the
+marker characters and the face to be used by font-lock for highlighting
+in Org-mode Emacs buffers.
+
+You need to reload Org or to restart Emacs after customizing this."
   :group 'org-appearance
   :set 'org-set-emph-re
+  :version "24.4"
+  :package-version '(Org . "8.0")
   :type '(repeat
          (list
           (string :tag "Marker character")
           (choice
            (face :tag "Font-lock-face")
            (plist :tag "Face property list"))
-          (string :tag "HTML start tag")
-          (string :tag "HTML end tag")
           (option (const verbatim)))))
 
 (defvar org-protecting-blocks
-  '("src" "example" "latex" "ascii" "html" "docbook" "ditaa" "dot" "r" "R")
+  '("src" "example" "latex" "ascii" "html" "ditaa" "dot" "r" "R")
   "Blocks that contain text that is quoted, i.e. not processed as Org syntax.
 This is needed for font-lock setup.")
 
@@ -3838,7 +4197,7 @@ Normal means, no org-mode-specific context."
 (declare-function org-agenda-skip "org-agenda" ())
 (declare-function
  org-agenda-format-item "org-agenda"
- (extra txt &optional category tags dotime noprefix remove-re habitp))
+ (extra txt &optional level category tags dotime noprefix remove-re habitp))
 (declare-function org-agenda-new-marker "org-agenda" (&optional pos))
 (declare-function org-agenda-change-all-lines "org-agenda"
                  (newhead hdmarker &optional fixface just-this))
@@ -3856,16 +4215,12 @@ Normal means, no org-mode-specific context."
 (declare-function org-indent-mode "org-indent" (&optional arg))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function org-attach-reveal "org-attach" (&optional if-exists))
-(declare-function org-export-latex-fix-inputenc "org-latex" ())
 (declare-function orgtbl-send-table "org-table" (&optional maybe))
 (defvar remember-data-file)
 (defvar texmathp-why)
 (declare-function speedbar-line-directory "speedbar" (&optional depth))
 (declare-function table--at-cell-p "table" (position &optional object at-column))
 
-(defvar w3m-current-url)
-(defvar w3m-current-title)
-
 (defvar org-latex-regexps)
 
 ;;; Autoload and prepare some org modules
@@ -3893,6 +4248,9 @@ This works for both table types.")
   (org-autoload "org-table"
                '(org-table-begin org-table-blank-field org-table-end)))
 
+(defconst org-TBLFM-regexp "^[ \t]*#\\+TBLFM: "
+  "Detect a #+TBLFM line.")
+
 ;;;###autoload
 (defun turn-on-orgtbl ()
   "Unconditionally turn on `orgtbl-mode'."
@@ -3951,7 +4309,6 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
        (looking-at org-table-hline-regexp))
     nil))
 
-(defvar org-table-clean-did-remove-column nil)
 (defun org-table-map-tables (function &optional quietly)
   "Apply FUNCTION to the start of all tables in the buffer."
   (save-excursion
@@ -3971,12 +4328,6 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
        (re-search-forward org-table-any-border-regexp nil 1))))
   (unless quietly (message "Mapping tables: done")))
 
-;; Declare and autoload functions from org-exp.el  & Co
-
-(declare-function org-default-export-plist "org-exp")
-(declare-function org-infile-export-plist "org-exp")
-(declare-function org-get-current-options "org-exp")
-
 ;; Declare and autoload functions from org-agenda.el
 
 (eval-and-compile
@@ -3987,6 +4338,15 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
 (declare-function org-clock-update-mode-line "org-clock" ())
 (declare-function org-resolve-clocks "org-clock"
                  (&optional also-non-dangling-p prompt last-valid))
+
+(defun org-at-TBLFM-p (&optional pos)
+  "Return t when point (or POS) is in #+TBLFM line."
+  (save-excursion
+    (let ((pos pos)))
+    (goto-char (or pos (point)))
+    (beginning-of-line 1)
+    (looking-at org-TBLFM-regexp)))
+
 (defvar org-clock-start-time)
 (defvar org-clock-marker (make-marker)
   "Marker recording the last clock-in.")
@@ -3995,8 +4355,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
 (defvar org-clock-heading ""
   "The heading of the current clock entry.")
 (defun org-clock-is-active ()
-  "Return non-nil if clock is currently running.
-The return value is actually the clock marker."
+  "Return the buffer where the clock is currently running.
+Return nil if no clock is running."
   (marker-buffer org-clock-marker))
 
 (eval-and-compile
@@ -4150,12 +4510,13 @@ Otherwise, these types are allowed:
    inactive: only inactive timestamps (<...)
   scheduled: only scheduled timestamps
    deadline: only deadline timestamps"
-  :type '(choice (const :tag "Scheduled or deadline" 'scheduled-or-deadline)
+  :type '(choice (const :tag "Scheduled or deadline" scheduled-or-deadline)
                 (const :tag "All timestamps" all)
                 (const :tag "Only active timestamps" active)
                 (const :tag "Only inactive timestamps" inactive)
                 (const :tag "Only scheduled timestamps" scheduled)
-                (const :tag "Only deadline timestamps" deadline))
+                (const :tag "Only deadline timestamps" deadline)
+                (const :tag "Only closed timestamps" closed))
   :version "24.3"
   :group 'org-sparse-trees)
 
@@ -4274,6 +4635,9 @@ Also put tags into group 4 if tags are present.")
 (defvar org-deadline-time-regexp nil
   "Matches the DEADLINE keyword together with a time stamp.")
 (make-variable-buffer-local 'org-deadline-time-regexp)
+(defvar org-deadline-time-hour-regexp nil
+  "Matches the DEADLINE keyword together with a time-and-hour stamp.")
+(make-variable-buffer-local 'org-deadline-time-hour-regexp)
 (defvar org-deadline-line-regexp nil
   "Matches the DEADLINE keyword and the rest of the line.")
 (make-variable-buffer-local 'org-deadline-line-regexp)
@@ -4283,6 +4647,9 @@ Also put tags into group 4 if tags are present.")
 (defvar org-scheduled-time-regexp nil
   "Matches the SCHEDULED keyword together with a time stamp.")
 (make-variable-buffer-local 'org-scheduled-time-regexp)
+(defvar org-scheduled-time-hour-regexp nil
+  "Matches the SCHEDULED keyword together with a time-and-hour stamp.")
+(make-variable-buffer-local 'org-scheduled-time-hour-regexp)
 (defvar org-closed-time-regexp nil
   "Matches the CLOSED keyword together with a time stamp.")
 (make-variable-buffer-local 'org-closed-time-regexp)
@@ -4357,6 +4724,8 @@ After a match, the following groups carry important information:
     ("noalign" org-startup-align-all-tables nil)
     ("inlineimages" org-startup-with-inline-images t)
     ("noinlineimages" org-startup-with-inline-images nil)
+    ("latexpreview" org-startup-with-latex-preview t)
+    ("nolatexpreview" org-startup-with-latex-preview nil)
     ("customtime" org-display-custom-times t)
     ("logdone" org-log-done time)
     ("lognotedone" org-log-done note)
@@ -4365,6 +4734,10 @@ After a match, the following groups carry important information:
     ("nolognoteclock-out" org-log-note-clock-out nil)
     ("logrepeat" org-log-repeat state)
     ("lognoterepeat" org-log-repeat note)
+    ("logdrawer" org-log-into-drawer t)
+    ("nologdrawer" org-log-into-drawer nil)
+    ("logstatesreversed" org-log-states-order-reversed t)
+    ("nologstatesreversed" org-log-states-order-reversed nil)
     ("nologrepeat" org-log-repeat nil)
     ("logreschedule" org-log-reschedule time)
     ("lognotereschedule" org-log-reschedule note)
@@ -4413,19 +4786,121 @@ means to push this value onto the list in the variable.")
   "Regular expression for hiding blocks.")
 (defconst org-heading-keyword-regexp-format
   "^\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
-  "Printf format for a regexp matching an headline with some keyword.
+  "Printf format for a regexp matching a headline with some keyword.
 This regexp will match the headline of any node which has the
 exact keyword that is put into the format.  The keyword isn't in
 any group by default, but the stars and the body are.")
 (defconst org-heading-keyword-maybe-regexp-format
   "^\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$"
-  "Printf format for a regexp matching an headline, possibly with some keyword.
+  "Printf format for a regexp matching a headline, possibly with some keyword.
 This regexp can match any headline with the specified keyword, or
 without a keyword.  The keyword isn't in any group by default,
 but the stars and the body are.")
 
+(defcustom org-group-tags t
+  "When non-nil (the default), use group tags.
+This can be turned on/off through `org-toggle-tags-groups'."
+  :group 'org-tags
+  :group 'org-startup
+  :type 'boolean)
+
+(defvar org-inhibit-startup nil)        ; Dynamically-scoped param.
+
+(defun org-toggle-tags-groups ()
+  "Toggle support for group tags.
+Support for group tags is controlled by the option
+`org-group-tags', which is non-nil by default."
+  (interactive)
+  (setq org-group-tags (not org-group-tags))
+  (cond ((and (derived-mode-p 'org-agenda-mode)
+             org-group-tags)
+        (org-agenda-redo))
+       ((derived-mode-p 'org-mode)
+        (let ((org-inhibit-startup t)) (org-mode))))
+  (message "Groups tags support has been turned %s"
+          (if org-group-tags "on" "off")))
+
+(defun org-set-regexps-and-options-for-tags ()
+  "Precompute variables used for tags."
+  (when (derived-mode-p 'org-mode)
+    (org-set-local 'org-file-tags nil)
+    (let ((re (org-make-options-regexp '("FILETAGS" "TAGS")))
+         (splitre "[ \t]+")
+         (start 0)
+         tags ftags key value)
+      (save-excursion
+       (save-restriction
+         (widen)
+         (goto-char (point-min))
+         (while (re-search-forward re nil t)
+           (setq key (upcase (org-match-string-no-properties 1))
+                 value (org-match-string-no-properties 2))
+           (if (stringp value) (setq value (org-trim value)))
+           (cond
+            ((equal key "TAGS")
+             (setq tags (append tags (if tags '("\\n") nil)
+                                (org-split-string value splitre))))
+            ((equal key "FILETAGS")
+             (when (string-match "\\S-" value)
+               (setq ftags
+                     (append
+                      ftags
+                      (apply 'append
+                             (mapcar (lambda (x) (org-split-string x ":"))
+                                     (org-split-string value)))))))))))
+      ;; Process the file tags.
+      (and ftags (org-set-local 'org-file-tags
+                               (mapcar 'org-add-prop-inherited ftags)))
+      (org-set-local 'org-tag-groups-alist nil)
+      ;; Process the tags.
+      (when (and (not tags) org-tag-alist)
+       (setq tags
+             (mapcar
+              (lambda (tg) (cond ((eq (car tg) :startgroup) "{")
+                                 ((eq (car tg) :endgroup) "}")
+                                 ((eq (car tg) :grouptags) ":")
+                                 ((eq (car tg) :newline) "\n")
+                                 (t (concat (car tg)
+                                            (if (characterp (cdr tg))
+                                                (format "(%s)" (char-to-string (cdr tg))) "")))))
+              org-tag-alist)))
+      (let (e tgs g)
+       (while (setq e (pop tags))
+         (cond
+          ((equal e "{")
+           (progn (push '(:startgroup) tgs)
+                  (when (equal (nth 1 tags) ":")
+                    (push (list (replace-regexp-in-string
+                                 "(.+)$" "" (nth 0 tags)))
+                          org-tag-groups-alist)
+                    (setq g 0))))
+          ((equal e ":") (push '(:grouptags) tgs))
+          ((equal e "}") (push '(:endgroup) tgs) (if g (setq g nil)))
+          ((equal e "\\n") (push '(:newline) tgs))
+          ((string-match (org-re "^\\([[:alnum:]_@#%]+\\)(\\(.\\))$") e)
+           (push (cons (match-string 1 e)
+                       (string-to-char (match-string 2 e))) tgs)
+           (if (and g (> g 0))
+               (setcar org-tag-groups-alist
+                       (append (car org-tag-groups-alist)
+                               (list (match-string 1 e)))))
+           (if g (setq g (1+ g))))
+          (t (push (list e) tgs)
+             (if (and g (> g 0))
+                 (setcar org-tag-groups-alist
+                         (append (car org-tag-groups-alist) (list e))))
+             (if g (setq g (1+ g))))))
+       (org-set-local 'org-tag-alist nil)
+       (while (setq e (pop tgs))
+         (or (and (stringp (car e))
+                  (assoc (car e) org-tag-alist))
+             (push e org-tag-alist)))
+       ;; Return a list with tag variables
+       (list org-file-tags org-tag-alist org-tag-groups-alist)))))
+
+(defvar org-ota nil)
 (defun org-set-regexps-and-options ()
-  "Precompute regular expressions for current buffer."
+  "Precompute regular expressions used in the current buffer."
   (when (derived-mode-p 'org-mode)
     (org-set-local 'org-todo-kwd-alist nil)
     (org-set-local 'org-todo-key-alist nil)
@@ -4436,27 +4911,43 @@ but the stars and the body are.")
     (org-set-local 'org-todo-sets nil)
     (org-set-local 'org-todo-log-states nil)
     (org-set-local 'org-file-properties nil)
-    (org-set-local 'org-file-tags nil)
     (let ((re (org-make-options-regexp
-              '("CATEGORY" "TODO" "COLUMNS"
-                "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
-                "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE" "LATEX_CLASS"
-                "OPTIONS")
+              '("CATEGORY" "TODO" "COLUMNS" "STARTUP" "ARCHIVE"
+                "LINK" "PRIORITIES" "CONSTANTS" "PROPERTY" "DRAWERS"
+                "SETUPFILE" "OPTIONS")
               "\\(?:[a-zA-Z][0-9a-zA-Z_]*_TODO\\)"))
          (splitre "[ \t]+")
          (scripts org-use-sub-superscripts)
-         kwds kws0 kwsa key log value cat arch tags const links hw dws
-         tail sep kws1 prio props ftags drawers beamer-p
-         ext-setup-or-nil setup-contents (start 0))
+         kwds kws0 kwsa key log value cat arch const links hw dws
+         tail sep kws1 prio props drawers ext-setup-or-nil setup-contents
+         (start 0))
       (save-excursion
        (save-restriction
          (widen)
          (goto-char (point-min))
-         (while (or (and ext-setup-or-nil
-                         (string-match re ext-setup-or-nil start)
-                         (setq start (match-end 0)))
-                    (and (setq ext-setup-or-nil nil start 0)
-                         (re-search-forward re nil t)))
+         (while
+             (or (and
+                  ext-setup-or-nil
+                  (not org-ota)
+                  (let (ret)
+                    (with-temp-buffer
+                      (insert ext-setup-or-nil)
+                      (let ((major-mode 'org-mode) org-ota)
+                        (setq ret (save-match-data
+                                    (org-set-regexps-and-options-for-tags)))))
+                    ;; Append setupfile tags to existing tags
+                    (setq org-ota t)
+                    (setq org-file-tags
+                          (delq nil (append org-file-tags (nth 0 ret)))
+                          org-tag-alist
+                          (delq nil (append org-tag-alist (nth 1 ret)))
+                          org-tag-groups-alist
+                          (delq nil (append org-tag-groups-alist (nth 2 ret))))))
+                 (and ext-setup-or-nil
+                      (string-match re ext-setup-or-nil start)
+                      (setq start (match-end 0)))
+                 (and (setq ext-setup-or-nil nil start 0)
+                      (re-search-forward re nil t)))
            (setq key (upcase (match-string 1 ext-setup-or-nil))
                  value (org-match-string-no-properties 2 ext-setup-or-nil))
            (if (stringp value) (setq value (org-trim value)))
@@ -4471,9 +4962,6 @@ but the stars and the body are.")
              ;; general TODO-like setup
              (push (cons (intern (downcase (match-string 1 key)))
                          (org-split-string value splitre)) kwds))
-            ((equal key "TAGS")
-             (setq tags (append tags (if tags '("\\n") nil)
-                                (org-split-string value splitre))))
             ((equal key "COLUMNS")
              (org-set-local 'org-columns-default-format value))
             ((equal key "LINK")
@@ -4488,18 +4976,10 @@ but the stars and the body are.")
                (setq props (org-update-property-plist (match-string 1 value)
                                                       (match-string 2 value)
                                                       props))))
-            ((equal key "FILETAGS")
-             (when (string-match "\\S-" value)
-               (setq ftags
-                     (append
-                      ftags
-                      (apply 'append
-                             (mapcar (lambda (x) (org-split-string x ":"))
-                                     (org-split-string value)))))))
             ((equal key "DRAWERS")
              (setq drawers (delete-dups (append org-drawers (org-split-string value splitre)))))
             ((equal key "CONSTANTS")
-             (setq const (append const (org-split-string value splitre))))
+             (org-table-set-constants))
             ((equal key "STARTUP")
              (let ((opts (org-split-string value splitre))
                    l var val)
@@ -4516,12 +4996,12 @@ but the stars and the body are.")
              (setq arch value)
              (remove-text-properties 0 (length arch)
                                      '(face t fontified t) arch))
-            ((equal key "LATEX_CLASS")
-             (setq beamer-p (equal value "beamer")))
             ((equal key "OPTIONS")
              (if (string-match "\\([ \t]\\|\\`\\)\\^:\\(t\\|nil\\|{}\\)" value)
                  (setq scripts (read (match-string 2 value)))))
-            ((equal key "SETUPFILE")
+            ((and (equal key "SETUPFILE")
+                  ;; Prevent checking in Gnus messages
+                  (not buffer-read-only))
              (setq setup-contents (org-file-contents
                                    (expand-file-name
                                     (org-remove-double-quotes value))
@@ -4553,8 +5033,6 @@ but the stars and the body are.")
        (org-set-local 'org-lowest-priority  (nth 1 prio))
        (org-set-local 'org-default-priority (nth 2 prio)))
       (and props (org-set-local 'org-file-properties (nreverse props)))
-      (and ftags (org-set-local 'org-file-tags
-                               (mapcar 'org-add-prop-inherited ftags)))
       (and drawers (org-set-local 'org-drawers drawers))
       (and arch (org-set-local 'org-archive-location arch))
       (and links (setq org-link-abbrev-alist-local (nreverse links)))
@@ -4605,33 +5083,6 @@ but the stars and the body are.")
              org-todo-kwd-alist (nreverse org-todo-kwd-alist)
              org-todo-key-trigger (delq nil (mapcar 'cdr org-todo-key-alist))
              org-todo-key-alist (org-assign-fast-keys org-todo-key-alist)))
-      ;; Process the constants
-      (when const
-       (let (e cst)
-         (while (setq e (pop const))
-           (if (string-match "^\\([a-zA-Z0][_a-zA-Z0-9]*\\)=\\(.*\\)" e)
-               (push (cons (match-string 1 e) (match-string 2 e)) cst)))
-         (setq org-table-formula-constants-local cst)))
-
-      ;; Process the tags.
-      (when tags
-       (let (e tgs)
-         (while (setq e (pop tags))
-           (cond
-            ((equal e "{") (push '(:startgroup) tgs))
-            ((equal e "}") (push '(:endgroup) tgs))
-            ((equal e "\\n") (push '(:newline) tgs))
-            ((string-match (org-re "^\\([[:alnum:]_@#%]+\\)(\\(.\\))$") e)
-             (push (cons (match-string 1 e)
-                         (string-to-char (match-string 2 e)))
-                   tgs))
-            (t (push (list e) tgs))))
-         (org-set-local 'org-tag-alist nil)
-         (while (setq e (pop tgs))
-           (or (and (stringp (car e))
-                    (assoc (car e) org-tag-alist))
-               (push e org-tag-alist)))))
-
       ;; Compute the regular expressions and other local variables.
       ;; Using `org-outline-regexp-bol' would complicate them much,
       ;; because of the fixed white space at the end of that string.
@@ -4688,12 +5139,18 @@ but the stars and the body are.")
            org-deadline-regexp (concat "\\<" org-deadline-string)
            org-deadline-time-regexp
            (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
+           org-deadline-time-hour-regexp
+           (concat "\\<" org-deadline-string
+                   " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
            org-deadline-line-regexp
            (concat "\\<\\(" org-deadline-string "\\).*")
            org-scheduled-regexp
            (concat "\\<" org-scheduled-string)
            org-scheduled-time-regexp
            (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
+           org-scheduled-time-hour-regexp
+           (concat "\\<" org-scheduled-string
+                   " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
            org-closed-time-regexp
            (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
            org-keyword-time-regexp
@@ -4717,20 +5174,16 @@ but the stars and the body are.")
            org-all-time-keywords
            (mapcar (lambda (w) (substring w 0 -1))
                    (list org-scheduled-string org-deadline-string
-                         org-clock-string org-closed-string))
-           )
-      (org-compute-latex-and-specials-regexp)
-      (org-set-font-lock-defaults))))
+                         org-clock-string org-closed-string)))
+      (setq org-ota nil)
+      (org-compute-latex-and-related-regexp))))
 
 (defun org-file-contents (file &optional noerror)
   "Return the contents of FILE, as a string."
   (if (or (not file)
          (not (file-readable-p file)))
       (if noerror
-         (progn
-           (message "Cannot read file \"%s\"" file)
-           (ding) (sit-for 2)
-           "")
+         (message "Cannot read file \"%s\"" file)
        (error "Cannot read file \"%s\"" file))
     (with-temp-buffer
       (insert-file-contents file)
@@ -4763,7 +5216,7 @@ This will extract info from a string like \"WAIT(w@/!)\"."
 Respect keys that are already there."
   (let (new e (alt ?0))
     (while (setq e (pop alist))
-      (if (or (memq (car e) '(:newline :endgroup :startgroup))
+      (if (or (memq (car e) '(:newline :grouptags :endgroup :startgroup))
              (cdr e)) ;; Key already assigned.
          (push e new)
        (let ((clist (string-to-list (downcase (car e))))
@@ -4813,7 +5266,6 @@ This variable is set by `org-before-change-function'.
   "Every change indicates that a table might need an update."
   (setq org-table-may-need-update t))
 (defvar org-mode-map)
-(defvar org-inhibit-startup nil)        ; Dynamically-scoped param.
 (defvar org-inhibit-startup-visibility-stuff nil) ; Dynamically-scoped param.
 (defvar org-agenda-keep-modes nil)      ; Dynamically-scoped param.
 (defvar org-inhibit-logging nil)        ; Dynamically-scoped param.
@@ -4834,7 +5286,7 @@ This variable is set by `org-before-change-function'.
 (require 'easymenu)
 (require 'overlay)
 
-(require 'org-macs)
+;; (require 'org-macs) moved higher up in the file before it is first used
 (require 'org-entities)
 ;; (require 'org-compat) moved higher up in the file before it is first used
 (require 'org-faces)
@@ -4842,15 +5294,10 @@ This variable is set by `org-before-change-function'.
 (require 'org-pcomplete)
 (require 'org-src)
 (require 'org-footnote)
+(require 'org-macro)
 
 ;; babel
 (require 'ob)
-(require 'ob-table)
-(require 'ob-lob)
-(require 'ob-ref)
-(require 'ob-tangle)
-(require 'ob-comint)
-(require 'ob-keys)
 
 ;;;###autoload
 (define-derived-mode org-mode outline-mode "Org"
@@ -4910,13 +5357,17 @@ The following commands are available:
                                              org-ellipsis)))
               (if (stringp org-ellipsis) org-ellipsis "..."))))
     (setq buffer-display-table org-display-table))
+  (org-set-regexps-and-options-for-tags)
   (org-set-regexps-and-options)
+  (org-set-font-lock-defaults)
   (when (and org-tag-faces (not org-tags-special-faces-re))
     ;; tag faces set outside customize.... force initialization.
     (org-set-tag-faces 'org-tag-faces org-tag-faces))
   ;; Calc embedded
   (org-set-local 'calc-embedded-open-mode "# ")
+  ;; Modify a few syntax entries
   (modify-syntax-entry ?@ "w")
+  (modify-syntax-entry ?\" "\"")
   (if org-startup-truncated (setq truncate-lines t))
   (when org-startup-indented (require 'org-indent) (org-indent-mode 1))
   (org-set-local 'font-lock-unfontify-region-function
@@ -4927,18 +5378,20 @@ The following commands are available:
                'local)
   ;; Check for running clock before killing a buffer
   (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
+  ;; Initialize macros templates.
+  (org-macro-initialize-templates)
+  ;; Initialize radio targets.
+  (org-update-radio-target-regexp)
   ;; Indentation.
   (org-set-local 'indent-line-function 'org-indent-line)
   (org-set-local 'indent-region-function 'org-indent-region)
-  ;; Initialize radio targets.
-  (org-update-radio-target-regexp)
   ;; Filling and auto-filling.
   (org-setup-filling)
   ;; Comments.
   (org-setup-comments-handling)
   ;; Beginning/end of defun
-  (org-set-local 'beginning-of-defun-function 'org-back-to-heading)
-  (org-set-local 'end-of-defun-function (lambda () (interactive) (org-end-of-subtree nil t)))
+  (org-set-local 'beginning-of-defun-function 'org-backward-element)
+  (org-set-local 'end-of-defun-function 'org-forward-element)
   ;; Next error for sparse trees
   (org-set-local 'next-error-function 'org-occur-next-match)
   ;; Make sure dependence stuff works reliably, even for users who set it
@@ -4994,18 +5447,32 @@ The following commands are available:
           (= (point-min) (point-max)))
       (insert "#    -*- mode: org -*-\n\n"))
   (unless org-inhibit-startup
-    (and org-startup-with-beamer-mode (org-beamer-mode))
-    (when org-startup-align-all-tables
-      (let ((bmp (buffer-modified-p)))
-       (org-table-map-tables 'org-table-align 'quietly)
-       (set-buffer-modified-p bmp)))
-    (when org-startup-with-inline-images
-      (org-display-inline-images))
-    (unless org-inhibit-startup-visibility-stuff
-      (org-set-startup-visibility)))
+    (org-unmodified
+     (and org-startup-with-beamer-mode (org-beamer-mode))
+     (when org-startup-align-all-tables
+       (org-table-map-tables 'org-table-align 'quietly))
+     (when org-startup-with-inline-images
+       (org-display-inline-images))
+     (when org-startup-with-latex-preview
+       (org-preview-latex-fragment))
+     (unless org-inhibit-startup-visibility-stuff
+       (org-set-startup-visibility))))
   ;; Try to set org-hide correctly
   (set-face-foreground 'org-hide (org-find-invisible-foreground)))
 
+;; Update `customize-package-emacs-version-alist'
+(add-to-list 'customize-package-emacs-version-alist
+            '(Org ("6.21b" . "23.1")  ("6.33x" . "23.2")
+                  ("7.8.11" . "24.1") ("7.9.4" . "24.3")
+                  ("8.0" . "24.4")))
+
+(defvar org-mode-transpose-word-syntax-table
+  (let ((st (make-syntax-table)))
+    (mapc (lambda(c) (modify-syntax-entry
+                     (string-to-char (car c)) "w p" st))
+         org-emphasis-alist)
+    st))
+
 (when (fboundp 'abbrev-table-put)
   (abbrev-table-put org-mode-abbrev-table
                    :parents (list text-mode-abbrev-table)))
@@ -5029,15 +5496,23 @@ The following commands are available:
                      (list (face-foreground 'org-hide))))))
     (car (remove nil candidates))))
 
-(defun org-current-time ()
-  "Current time, possibly rounded to `org-time-stamp-rounding-minutes'."
-  (if (> (car org-time-stamp-rounding-minutes) 1)
-      (let ((r (car org-time-stamp-rounding-minutes))
-           (time (decode-time)))
-       (apply 'encode-time
-              (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
-                      (nthcdr 2 time))))
-    (current-time)))
+(defun org-current-time (&optional rounding-minutes past)
+  "Current time, possibly rounded to ROUNDING-MINUTES.
+When ROUNDING-MINUTES is not an integer, fall back on the car of
+`org-time-stamp-rounding-minutes'.  When PAST is non-nil, ensure
+the rounding returns a past time."
+  (let ((r (or (and (integerp rounding-minutes) rounding-minutes)
+              (car org-time-stamp-rounding-minutes)))
+       (time (decode-time)) res)
+    (if (< r 1)
+       (current-time)
+      (setq res
+           (apply 'encode-time
+                  (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) r)))))
+                          (nthcdr 2 time))))
+      (if (and past (< (org-float-time (time-subtract (current-time) res)) 0))
+         (seconds-to-time (- (org-float-time res) (* r 60)))
+       res))))
 
 (defun org-today ()
   "Return today date, considering `org-extend-today-until'."
@@ -5088,11 +5563,8 @@ Here is what the match groups contain after a match:
 (defvar org-any-link-re nil
   "Regular expression matching any link.")
 
-(defcustom org-match-sexp-depth 3
-  "Number of stacked braces for sub/superscript matching.
-This has to be set before loading org.el to be effective."
-  :group 'org-export-translation ; ??????????????????????????/
-  :type 'integer)
+(defconst org-match-sexp-depth 3
+  "Number of stacked braces for sub/superscript matching.")
 
 (defun org-create-multibrace-regexp (left right n)
   "Create a regular expression which will match a balanced sexp.
@@ -5114,7 +5586,7 @@ stacked delimiters is N.  Escaping delimiters is not possible."
 
 (defvar org-match-substring-regexp
   (concat
-   "\\([^\\]\\|^\\)\\([_^]\\)\\("
+   "\\(\\S-\\)\\([_^]\\)\\("
    "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
    "\\|"
    "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
@@ -5124,7 +5596,7 @@ stacked delimiters is N.  Escaping delimiters is not possible."
 
 (defvar org-match-substring-with-braces-regexp
   (concat
-   "\\([^\\]\\|^\\)\\([_^]\\)\\("
+   "\\(\\S-\\)\\([_^]\\)\\("
    "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
    "\\)")
   "The regular expression matching a sub- or superscript, forcing braces.")
@@ -5231,7 +5703,7 @@ The time stamps may be either active or inactive.")
            (font-lock-prepend-text-property (match-beginning 2) (match-end 2)
                                             'face
                                             (nth 1 a))
-           (and (nth 4 a)
+           (and (nth 2 a)
                 (org-remove-flyspell-overlays-in
                  (match-beginning 0) (match-end 0)))
            (add-text-properties (match-beginning 2) (match-end 2)
@@ -5249,36 +5721,27 @@ The time stamps may be either active or inactive.")
 If there is an active region, change that region to a new emphasis.
 If there is no region, just insert the marker characters and position
 the cursor between them.
-CHAR should be either the marker character, or the first character of the
-HTML tag associated with that emphasis.  If CHAR is a space, the means
-to remove the emphasis of the selected region.
-If char is not given (for example in an interactive call) it
-will be prompted for."
+CHAR should be the marker character.  If it is a space, it means to
+remove the emphasis of the selected region.
+If CHAR is not given (for example in an interactive call) it will be
+prompted for."
   (interactive)
-  (let ((eal org-emphasis-alist) e det
-       (erc org-emphasis-regexp-components)
+  (let ((erc org-emphasis-regexp-components)
        (prompt "")
-       (string "") beg end move tag c s)
+       (string "") beg end move c s)
     (if (org-region-active-p)
        (setq beg (region-beginning) end (region-end)
              string (buffer-substring beg end))
       (setq move t))
 
-    (while (setq e (pop eal))
-      (setq tag (car (org-split-string (nth 2 e) "[ <>/]+"))
-           c (aref tag 0))
-      (push (cons c (string-to-char (car e))) det)
-      (setq prompt (concat prompt (format " [%s%c]%s" (car e) c
-                                         (substring tag 1)))))
-    (setq det (nreverse det))
     (unless char
-      (message "%s" (concat "Emphasis marker or tag:" prompt))
+      (message "Emphasis marker or tag: [%s]"
+              (mapconcat (lambda(e) (car e)) org-emphasis-alist ""))
       (setq char (read-char-exclusive)))
-    (setq char (or (cdr (assoc char det)) char))
     (if (equal char ?\ )
        (setq s "" move nil)
       (unless (assoc (char-to-string char) org-emphasis-alist)
-       (error "No such emphasis marker: \"%c\"" char))
+       (user-error "No such emphasis marker: \"%c\"" char))
       (setq s (char-to-string char)))
     (while (and (> (length string) 1)
                (equal (substring string 0 1) (substring string -1))
@@ -5305,17 +5768,19 @@ will be prompted for."
 
 (defun org-activate-plain-links (limit)
   "Run through the buffer and add overlays to links."
-  (let (f)
+  (let (f hl)
     (when (and (re-search-forward (concat org-plain-link-re) limit t)
               (not (org-in-src-block-p)))
       (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
       (setq f (get-text-property (match-beginning 0) 'face))
-      (unless (or (org-in-src-block-p)
-                 (eq f 'org-tag)
-                 (and (listp f) (memq 'org-tag f)))
+      (setq hl (org-match-string-no-properties 0))
+      (if (or (eq f 'org-tag)
+             (and (listp f) (memq 'org-tag f)))
+         nil
        (add-text-properties (match-beginning 0) (match-end 0)
                             (list 'mouse-face 'highlight
                                   'face 'org-link
+                                  'htmlize-link `(:uri ,hl)
                                   'keymap org-mouse-map))
        (org-rear-nonsticky-at (match-end 0)))
       t)))
@@ -5349,7 +5814,7 @@ by a #."
     (error (message "org-mode fontification error"))))
 
 (defun org-fontify-meta-lines-and-blocks-1 (limit)
-  "Fontify #+ lines and blocks, in the correct ways."
+  "Fontify #+ lines and blocks."
   (let ((case-fold-search t))
     (if (re-search-forward
         "^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)"
@@ -5363,7 +5828,7 @@ by a #."
              (dc3 (downcase (match-string 3)))
              end end1 quoting block-type ovl)
          (cond
-          ((member dc1 '("+html:" "+ascii:" "+latex:" "+docbook:"))
+          ((member dc1 '("+html:" "+ascii:" "+latex:"))
            ;; a single line of backend-specific content
            (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
            (remove-text-properties (match-beginning 0) (match-end 0)
@@ -5482,17 +5947,16 @@ by a #."
   "Run through the buffer and add overlays to bracketed links."
   (if (and (re-search-forward org-bracket-link-regexp limit t)
           (not (org-in-src-block-p)))
-      (let* ((help (concat "LINK: "
-                          (org-match-string-no-properties 1)))
-            ;; FIXME: above we should remove the escapes.
-            ;; but that requires another match, protecting match data,
-            ;; a lot of overhead for font-lock.
+      (let* ((hl (org-match-string-no-properties 1))
+            (help (concat "LINK: " (save-match-data (org-link-unescape hl))))
             (ip (org-maybe-intangible
                  (list 'invisible 'org-link
                        'keymap org-mouse-map 'mouse-face 'highlight
-                       'font-lock-multiline t 'help-echo help)))
+                       'font-lock-multiline t 'help-echo help
+                       'htmlize-link `(:uri ,hl))))
             (vp (list 'keymap org-mouse-map 'mouse-face 'highlight
-                      'font-lock-multiline t 'help-echo help)))
+                      'font-lock-multiline t 'help-echo help
+                      'htmlize-link `(:uri ,hl))))
        ;; We need to remove the invisible property here.  Table narrowing
        ;; may have made some of this invisible.
        (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
@@ -5573,97 +6037,55 @@ by a #."
       (goto-char e)
       t)))
 
-(defvar org-latex-and-specials-regexp nil
-  "Regular expression for highlighting export special stuff.")
+(defvar org-latex-and-related-regexp nil
+  "Regular expression for highlighting LaTeX, entities and sub/superscript.")
 (defvar org-match-substring-regexp)
 (defvar org-match-substring-with-braces-regexp)
 
-;; This should be with the exporter code, but we also use if for font-locking
-(defconst org-export-html-special-string-regexps
-  '(("\\\\-" . "&shy;")
-    ("---\\([^-]\\)" . "&mdash;\\1")
-    ("--\\([^-]\\)" . "&ndash;\\1")
-    ("\\.\\.\\." . "&hellip;"))
-  "Regular expressions for special string conversion.")
-
-
-(defun org-compute-latex-and-specials-regexp ()
-  "Compute regular expression for stuff treated specially by exporters."
-  (if (not org-highlight-latex-fragments-and-specials)
-      (org-set-local 'org-latex-and-specials-regexp nil)
-    (require 'org-exp)
-    (let*
-       ((matchers (plist-get org-format-latex-options :matchers))
-        (latexs (delq nil (mapcar (lambda (x) (if (member (car x) matchers) x))
-                                  org-latex-regexps)))
-        (org-export-allow-BIND nil)
-        (options (org-combine-plists (org-default-export-plist)
-                                     (org-infile-export-plist)))
-        (org-export-with-sub-superscripts (plist-get options :sub-superscript))
-        (org-export-with-LaTeX-fragments (plist-get options :LaTeX-fragments))
-        (org-export-with-TeX-macros (plist-get options :TeX-macros))
-        (org-export-html-expand (plist-get options :expand-quoted-html))
-        (org-export-with-special-strings (plist-get options :special-strings))
-        (re-sub
-         (cond
-          ((equal org-export-with-sub-superscripts '{})
-           (list org-match-substring-with-braces-regexp))
-          (org-export-with-sub-superscripts
-           (list org-match-substring-regexp))))
-        (re-latex
-         (if org-export-with-LaTeX-fragments
-             (mapcar (lambda (x) (nth 1 x)) latexs)))
-        (re-macros
-         (if org-export-with-TeX-macros
-             (list (concat "\\\\"
-                           (regexp-opt
-                            (append
-
-                             (delq nil
-                                   (mapcar 'car-safe
-                                           (append org-entities-user
-                                                   org-entities)))
-                             (if (boundp 'org-latex-entities)
-                                 (mapcar (lambda (x)
-                                           (or (car-safe x) x))
-                                         org-latex-entities)
-                               nil))
-                            'words))) ; FIXME
-           ))
-        ;;                     (list "\\\\\\(?:[a-zA-Z]+\\)")))
-        (re-special (if org-export-with-special-strings
-                        (mapcar (lambda (x) (car x))
-                                org-export-html-special-string-regexps)))
-        (re-rest
-         (delq nil
-               (list
-                (if org-export-html-expand "@<[^>\n]+>")
-                ))))
-      (org-set-local
-       'org-latex-and-specials-regexp
-       (mapconcat 'identity (append re-latex re-sub re-macros re-special
-                                   re-rest) "\\|")))))
-
-(defun org-do-latex-and-special-faces (limit)
-  "Run through the buffer and add overlays to links."
-  (when org-latex-and-specials-regexp
-    (let (rtn d)
-      (while (and (not rtn) (re-search-forward org-latex-and-specials-regexp
-                                              limit t))
-       (if (not (memq (car-safe (get-text-property (1+ (match-beginning 0))
-                                                   'face))
-                      '(org-code org-verbatim underline)))
-           (progn
-             (setq rtn t
-                   d (cond ((member (char-after (1+ (match-beginning 0)))
-                                    '(?_ ?^)) 1)
-                           (t 0)))
-             (font-lock-prepend-text-property
-              (+ d (match-beginning 0)) (match-end 0)
-              'face 'org-latex-and-export-specials)
-             (add-text-properties (+ d (match-beginning 0)) (match-end 0)
-                                  '(font-lock-multiline t)))))
-      rtn)))
+(defun org-compute-latex-and-related-regexp ()
+  "Compute regular expression for LaTeX, entities and sub/superscript.
+Result depends on variable `org-highlight-latex-and-related'."
+  (org-set-local
+   'org-latex-and-related-regexp
+   (let* ((re-sub
+          (cond ((not (memq 'script org-highlight-latex-and-related)) nil)
+                ((eq org-use-sub-superscripts '{})
+                 (list org-match-substring-with-braces-regexp))
+                (org-use-sub-superscripts (list org-match-substring-regexp))))
+         (re-latex
+          (when (memq 'latex org-highlight-latex-and-related)
+            (let ((matchers (plist-get org-format-latex-options :matchers)))
+              (delq nil
+                    (mapcar (lambda (x)
+                              (and (member (car x) matchers) (nth 1 x)))
+                            org-latex-regexps)))))
+         (re-entities
+          (when (memq 'entities org-highlight-latex-and-related)
+            (list "\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]]\\)"))))
+     (mapconcat 'identity (append re-latex re-entities re-sub) "\\|"))))
+
+(defun org-do-latex-and-related (limit)
+  "Highlight LaTeX snippets and environments, entities and sub/superscript.
+LIMIT bounds the search for syntax to highlight.  Stop at first
+highlighted object, if any.  Return t if some highlighting was
+done, nil otherwise."
+  (when (org-string-nw-p org-latex-and-related-regexp)
+    (catch 'found
+      (while (re-search-forward org-latex-and-related-regexp limit t)
+       (unless (memq (car-safe (get-text-property (1+ (match-beginning 0))
+                                                  'face))
+                     '(org-code org-verbatim underline))
+         (let ((offset (if (memq (char-after (1+ (match-beginning 0)))
+                                 '(?_ ?^))
+                           1
+                         0)))
+           (font-lock-prepend-text-property
+            (+ offset (match-beginning 0)) (match-end 0)
+            'face 'org-latex-and-related)
+           (add-text-properties (+ offset (match-beginning 0)) (match-end 0)
+                                '(font-lock-multiline t)))
+         (throw 'found t)))
+      nil)))
 
 (defun org-restart-font-lock ()
   "Restart `font-lock-mode', to force refontification."
@@ -5673,13 +6095,17 @@ by a #."
 
 (defun org-all-targets (&optional radio)
   "Return a list of all targets in this file.
-With optional argument RADIO, only find radio targets."
-  (let ((re (if radio org-radio-target-regexp org-target-regexp))
-       rtn)
+When optional argument RADIO is non-nil, only find radio
+targets."
+  (let ((re (if radio org-radio-target-regexp org-target-regexp)) rtn)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward re nil t)
-       (add-to-list 'rtn (downcase (org-match-string-no-properties 1))))
+       ;; Make sure point is really within the object.
+       (backward-char)
+       (let ((obj (org-element-context)))
+         (when (memq (org-element-type obj) '(radio-target target))
+           (add-to-list 'rtn (downcase (org-element-property :value obj))))))
       rtn)))
 
 (defun org-make-target-link-regexp (targets)
@@ -5711,18 +6137,34 @@ between words."
 
 (defun org-outline-level ()
   "Compute the outline level of the heading at point.
-This function assumes that the cursor is at the beginning of a line matched
-by `outline-regexp'.  Otherwise it returns garbage.
 If this is called at a normal headline, the level is the number of stars.
 Use `org-reduced-level' to remove the effect of `org-odd-levels'."
   (save-excursion
-    (looking-at org-outline-regexp)
-    (1- (- (match-end 0) (match-beginning 0)))))
+    (if (not (condition-case nil
+                (org-back-to-heading t)
+              (error nil)))
+       0
+      (looking-at org-outline-regexp)
+      (1- (- (match-end 0) (match-beginning 0))))))
 
 (defvar org-font-lock-keywords nil)
 
-(defconst org-property-re (org-re "^[ \t]*\\(:\\([-[:alnum:]_]+\\+?\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
-  "Regular expression matching a property line.")
+(defsubst org-re-property (property &optional literal)
+  "Return a regexp matching a PROPERTY line.
+Match group 3 will be set to the value if it exists."
+  (concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
+         (if literal property (regexp-quote property))
+         "\\):\\)[ \t]+\\(?3:[^ \t\r\n].*?\\)\\(?5:[ \t]*\\)$"))
+
+(defconst org-property-re
+  (org-re-property ".*?" 'literal)
+  "Regular expression matching a property line.
+There are four matching groups:
+1: :PROPKEY: including the leading and trailing colon,
+2: PROPKEY without the leading and trailing colon,
+3: PROPVAL without leading or trailing spaces,
+4: the indentation of the current line,
+5: trailing whitespace.")
 
 (defvar org-font-lock-hook nil
   "Functions to be called for special font lock stuff.")
@@ -5770,12 +6212,17 @@ needs to be inserted at a specific position in the font-lock sequence.")
           ;; Links
           (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
           (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t)))
-          (if (memq 'plain lk) '(org-activate-plain-links))
+          (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t)))
           (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
           (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
           (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
           (if (memq 'footnote lk) '(org-activate-footnote-links))
+           ;; Targets.
+           (list org-any-target-regexp '(0 'org-target t))
+          ;; Diary sexps.
           '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
+          ;; Macro
+          '("{{{.+}}}" (0 'org-macro t))
           '(org-hide-wide-columns (0 nil append))
           ;; TODO keyword
           (list (format org-heading-keyword-regexp-format
@@ -5794,6 +6241,12 @@ needs to be inserted at a specific position in the font-lock sequence.")
           '(org-font-lock-add-priority-faces)
           ;; Tags
           '(org-font-lock-add-tag-faces)
+          ;; Tags groups
+          (if (and org-group-tags org-tag-groups-alist)
+              (list (concat org-outline-regexp-bol ".+\\(:"
+                            (regexp-opt (mapcar 'car org-tag-groups-alist))
+                            ":\\).*$")
+                    '(1 'org-tag-group prepend)))
           ;; Special keywords
           (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
           (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
@@ -5819,7 +6272,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
                  "\\(.*:" org-archive-tag ":.*\\)")
                 '(1 'org-archived prepend))
           ;; Specials
-          '(org-do-latex-and-special-faces)
+          '(org-do-latex-and-related)
           '(org-fontify-entities)
           '(org-raise-scripts)
           ;; Code
@@ -5831,8 +6284,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
                                 "\\)"))
                 '(2 'org-special-keyword t))
           ;; Blocks and meta lines
-          '(org-fontify-meta-lines-and-blocks)
-          )))
+          '(org-fontify-meta-lines-and-blocks))))
     (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
     (run-hooks 'org-font-lock-set-keywords-hook)
     ;; Now set the full font-lock-keywords
@@ -5847,11 +6299,11 @@ needs to be inserted at a specific position in the font-lock sequence.")
   (org-set-local 'org-pretty-entities (not org-pretty-entities))
   (org-restart-font-lock)
   (if org-pretty-entities
-      (message "Entities are displayed as UTF8 characters")
+      (message "Entities are now displayed as UTF8 characters")
     (save-restriction
       (widen)
       (org-decompose-region (point-min) (point-max))
-      (message "Entities are displayed plain"))))
+      (message "Entities are now displayed as plain text"))))
 
 (defvar org-custom-properties-overlays nil
   "List of overlays used for custom properties.")
@@ -5960,10 +6412,10 @@ When FACE-OR-COLOR is not a string, just return it."
       (add-text-properties
        (match-beginning 0) (match-end 0)
        (list 'face (or (org-face-from-face-or-color
-                       'priority 'org-special-keyword
+                       'priority 'org-priority
                        (cdr (assoc (char-after (match-beginning 1))
                                    org-priority-faces)))
-                      'org-special-keyword)
+                      'org-priority)
             'font-lock-fontified t)))))
 
 (defun org-get-tag-face (kwd)
@@ -6021,10 +6473,10 @@ and subscripts."
               (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face))))
          (goto-char (point-at-bol))
          (setq table-p (org-looking-at-p org-table-dataline-regexp)
-               comment-p (org-looking-at-p "[ \t]*#"))
+               comment-p (org-looking-at-p "^[ \t]*#[ +]"))
          (goto-char pos)
-         ;; FIXME: Should we go back one character here, for a_b^c
-         ;; (goto-char (1- pos)) ;????????????????????
+         ;; Handle a_b^c
+         (if (member (char-after) '(?_ ?^)) (goto-char (1- pos)))
          (if (or comment-p emph-p link-p keyw-p)
              t
            (put-text-property (match-beginning 3) (match-end 0)
@@ -6052,11 +6504,18 @@ and subscripts."
 
 (defvar org-cycle-global-status nil)
 (make-variable-buffer-local 'org-cycle-global-status)
+(put 'org-cycle-global-status 'org-state t)
 (defvar org-cycle-subtree-status nil)
 (make-variable-buffer-local 'org-cycle-subtree-status)
+(put 'org-cycle-subtree-status 'org-state t)
 
 (defvar org-inlinetask-min-level)
 
+(defun org-unlogged-message (&rest args)
+  "Display a message, but avoid logging it in the *Messages* buffer."
+  (let ((message-log-max nil))
+    (apply 'message args)))
+
 ;;;###autoload
 (defun org-cycle (&optional arg)
   "TAB-action and visibility cycling for Org-mode.
@@ -6142,11 +6601,11 @@ in special contexts.
        ((equal arg '(16))
        (setq last-command 'dummy)
        (org-set-startup-visibility)
-       (message "Startup visibility, plus VISIBILITY properties"))
+       (org-unlogged-message "Startup visibility, plus VISIBILITY properties"))
 
        ((equal arg '(64))
        (show-all)
-       (message "Entire buffer visible, including drawers"))
+       (org-unlogged-message "Entire buffer visible, including drawers"))
 
        ;; Table: enter it or move to the next field.
        ((org-at-table-p 'any)
@@ -6233,9 +6692,9 @@ in special contexts.
       ;; We just created the overview - now do table of contents
       ;; This can be slow in very large buffers, so indicate action
       (run-hook-with-args 'org-pre-cycle-hook 'contents)
-      (unless ga (message "CONTENTS..."))
+      (unless ga (org-unlogged-message "CONTENTS..."))
       (org-content)
-      (unless ga (message "CONTENTS...done"))
+      (unless ga (org-unlogged-message "CONTENTS...done"))
       (setq org-cycle-global-status 'contents)
       (run-hook-with-args 'org-cycle-hook 'contents))
 
@@ -6244,7 +6703,7 @@ in special contexts.
       ;; We just showed the table of contents - now show everything
       (run-hook-with-args 'org-pre-cycle-hook 'all)
       (show-all)
-      (unless ga (message "SHOW ALL"))
+      (unless ga (org-unlogged-message "SHOW ALL"))
       (setq org-cycle-global-status 'all)
       (run-hook-with-args 'org-cycle-hook 'all))
 
@@ -6252,10 +6711,12 @@ in special contexts.
       ;; Default action: go to overview
       (run-hook-with-args 'org-pre-cycle-hook 'overview)
       (org-overview)
-      (unless ga (message "OVERVIEW"))
+      (unless ga (org-unlogged-message "OVERVIEW"))
       (setq org-cycle-global-status 'overview)
       (run-hook-with-args 'org-cycle-hook 'overview)))))
 
+(defvar org-called-with-limited-levels);Dyn-bound in ̀org-with-limited-levels'.
+
 (defun org-cycle-internal-local ()
   "Do the local cycling action."
   (let ((goal-column 0) eoh eol eos has-children children-skipped struct)
@@ -6298,7 +6759,7 @@ in special contexts.
       ;; Nothing is hidden behind this heading
       (unless (org-before-first-heading-p)
        (run-hook-with-args 'org-pre-cycle-hook 'empty))
-      (message "EMPTY ENTRY")
+      (org-unlogged-message "EMPTY ENTRY")
       (setq org-cycle-subtree-status nil)
       (save-excursion
        (goto-char eos)
@@ -6332,8 +6793,8 @@ in special contexts.
                     (end (org-list-get-bottom-point struct)))
                (mapc (lambda (e) (org-list-set-item-visibility e struct 'folded))
                      (org-list-get-all-items (point) struct prevs))
-               (goto-char end))))))
-      (message "CHILDREN")
+               (goto-char (if (< end eos) end eos)))))))
+      (org-unlogged-message "CHILDREN")
       (save-excursion
        (goto-char eos)
        (outline-next-heading)
@@ -6349,7 +6810,8 @@ in special contexts.
       (unless (org-before-first-heading-p)
        (run-hook-with-args 'org-pre-cycle-hook 'subtree))
       (outline-flag-region eoh eos nil)
-      (message (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE"))
+      (org-unlogged-message
+       (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE"))
       (setq org-cycle-subtree-status 'subtree)
       (unless (org-before-first-heading-p)
        (run-hook-with-args 'org-cycle-hook 'subtree)))
@@ -6357,7 +6819,7 @@ in special contexts.
       ;; Default action: hide the subtree.
       (run-hook-with-args 'org-pre-cycle-hook 'folded)
       (outline-flag-region eoh eos t)
-      (message "FOLDED")
+      (org-unlogged-message "FOLDED")
       (setq org-cycle-subtree-status 'folded)
       (unless (org-before-first-heading-p)
        (run-hook-with-args 'org-cycle-hook 'folded))))))
@@ -6377,7 +6839,7 @@ With a numeric prefix, show all headlines up to that level."
       (setq org-cycle-global-status 'contents))
      ((equal arg '(4))
       (org-set-startup-visibility)
-      (message "Startup visibility, plus VISIBILITY properties."))
+      (org-unlogged-message "Startup visibility, plus VISIBILITY properties."))
      (t
       (org-cycle '(4))))))
 
@@ -6438,7 +6900,7 @@ of the first headline in the buffer.  This is important, because if the
 first headline is not level one, then (hide-sublevels 1) gives confusing
 results."
   (interactive)
-  (let ((l (org-current-line))
+  (let ((pos (point))
        (level (save-excursion
                 (goto-char (point-min))
                 (if (re-search-forward (concat "^" outline-regexp) nil t)
@@ -6447,7 +6909,7 @@ results."
                       (funcall outline-level))))))
     (and level (hide-sublevels level))
     (recenter '(4))
-    (org-goto-line l)))
+    (goto-char pos)))
 
 (defun org-content (&optional arg)
   "Show all headlines in the buffer, like a table of contents.
@@ -6611,6 +7073,21 @@ open and agenda-wise Org files."
        (while (re-search-forward org-drawer-regexp end t)
          (org-flag-drawer t))))))
 
+(defun org-cycle-hide-inline-tasks (state)
+  "Re-hide inline tasks when switching to 'contents or 'children
+visibility state."
+  (case state
+    (contents
+     (when (org-bound-and-true-p org-inlinetask-min-level)
+       (hide-sublevels (1- org-inlinetask-min-level))))
+    (children
+     (when (featurep 'org-inlinetask)
+       (save-excursion
+        (while (and (outline-next-heading)
+                    (org-inlinetask-at-task-p))
+          (org-inlinetask-toggle-visibility)
+          (org-inlinetask-goto-end)))))))
+
 (defun org-flag-drawer (flag)
   "When FLAG is non-nil, hide the drawer we are within.
 Otherwise make it visible."
@@ -6622,7 +7099,7 @@ Otherwise make it visible."
             "^[ \t]*:END:"
             (save-excursion (outline-next-heading) (point)) t)
            (outline-flag-region b (point-at-eol) flag)
-         (error ":END: line missing at position %s" b))))))
+         (user-error ":END: line missing at position %s" b))))))
 
 (defun org-subtree-end-visible-p ()
   "Is the end of the current subtree visible?"
@@ -6754,7 +7231,7 @@ Optional arguments START and END can be used to limit the range."
                          'org-hide-block)
                  (delete-overlay ov))))
             (push ov org-hide-block-overlays)))
-      (error "Not looking at a source block"))))
+      (user-error "Not looking at a source block"))))
 
 ;; org-tab-after-check-for-cycling-hook
 (add-hook 'org-tab-first-hook 'org-hide-block-toggle-maybe)
@@ -6812,7 +7289,6 @@ RET=jump to location             C-g=quit and return to previous location
 
 (defvar org-goto-start-pos) ; dynamically scoped parameter
 
-;; FIXME: Docstring does not mention both interfaces
 (defun org-goto (&optional alternative-interface)
   "Look up a different location in the current file, keeping current visibility.
 
@@ -6948,7 +7424,7 @@ or nil."
        (setq org-goto-selected-point (point)
              org-goto-exit-command 'left)
        (throw 'exit nil))
-    (error "Not on a heading")))
+    (user-error "Not on a heading")))
 
 (defun org-goto-right ()
   "Finish `org-goto' by going to the new location."
@@ -6958,7 +7434,7 @@ or nil."
        (setq org-goto-selected-point (point)
              org-goto-exit-command 'right)
        (throw 'exit nil))
-    (error "Not on a heading")))
+    (user-error "Not on a heading")))
 
 (defun org-goto-quit ()
   "Finish `org-goto' without cursor motion."
@@ -7060,132 +7536,171 @@ frame is not changed."
 
 ;;; Inserting headlines
 
-(defun org-previous-line-empty-p ()
+(defun org-previous-line-empty-p (&optional next)
+  "Is the previous line a blank line?
+When NEXT is non-nil, check the next line instead."
   (save-excursion
     (and (not (bobp))
-        (or (beginning-of-line 0) t)
+        (or (beginning-of-line (if next 2 0)) t)
         (save-match-data
           (looking-at "[ \t]*$")))))
 
-(defun org-insert-heading (&optional force-heading invisible-ok)
+(defun org-insert-heading (&optional arg invisible-ok)
   "Insert a new heading or item with same depth at point.
-If point is in a plain list and FORCE-HEADING is nil, create a new list item.
-If point is at the beginning of a headline, insert a sibling before the
-current headline.  If point is not at the beginning, split the line,
-create the new headline with the text in the current line after point
-\(but see also the variable `org-M-RET-may-split-line').
+If point is in a plain list and ARG is nil, create a new list item.
+With one universal prefix argument, insert a heading even in lists.
+With two universal prefix arguments, insert the heading at the end
+of the parent subtree.
+
+If point is at the beginning of a headline, insert a sibling before
+the current headline.  If point is not at the beginning, split the line
+and create a new headline with the text in the current line after point
+\(see `org-M-RET-may-split-line' on how to modify this behavior).
+
+If point is at the beginning of a normal line, turn this line into
+a heading.
 
 When INVISIBLE-OK is set, stop at invisible headlines when going back.
 This is important for non-interactive uses of the command."
   (interactive "P")
-  (if (or (= (buffer-size) 0)
+  (if (org-called-interactively-p 'any) (org-reveal))
+  (let ((itemp (org-in-item-p))
+       (may-split (org-get-alist-option org-M-RET-may-split-line 'headline))
+       (respect-content (or org-insert-heading-respect-content
+                            (equal arg '(16))))
+       (initial-content "")
+       (adjust-empty-lines t))
+
+    (cond
+
+     ((or (= (buffer-size) 0)
          (and (not (save-excursion
                      (and (ignore-errors (org-back-to-heading invisible-ok))
                           (org-at-heading-p))))
-              (or force-heading (not (org-in-item-p)))))
-      (progn
-       (insert "\n* ")
-       (run-hooks 'org-insert-heading-hook))
-    (when (or force-heading (not (org-insert-item)))
-      (let* ((empty-line-p nil)
-            (level nil)
-            (on-heading (org-at-heading-p))
-            (head (save-excursion
-                    (condition-case nil
-                        (progn
-                          (org-back-to-heading invisible-ok)
-                          (when (and (not on-heading)
-                                     (featurep 'org-inlinetask)
-                                     (integerp org-inlinetask-min-level)
-                                     (>= (length (match-string 0))
-                                         org-inlinetask-min-level))
-                            ;; Find a heading level before the inline task
-                            (while (and (setq level (org-up-heading-safe))
-                                        (>= level org-inlinetask-min-level)))
-                            (if (org-at-heading-p)
-                                (org-back-to-heading invisible-ok)
-                              (error "This should not happen")))
-                          (setq empty-line-p (org-previous-line-empty-p))
-                          (match-string 0))
-                      (error "*"))))
-            (blank-a (cdr (assq 'heading org-blank-before-new-entry)))
-            (blank (if (eq blank-a 'auto) empty-line-p blank-a))
-            pos hide-previous previous-pos)
-       (cond
-        ((and (org-at-heading-p) (bolp)
-              (or (bobp)
-                  (save-excursion (backward-char 1) (not (outline-invisible-p)))))
-         ;; insert before the current line
-         (open-line (if blank 2 1)))
-        ((and (bolp)
-              (not org-insert-heading-respect-content)
-              (or (bobp)
-                  (save-excursion
-                    (backward-char 1) (not (outline-invisible-p)))))
-         ;; insert right here
-         nil)
-        (t
-         ;; somewhere in the line
-          (save-excursion
-           (setq previous-pos (point-at-bol))
-            (end-of-line)
-            (setq hide-previous (outline-invisible-p)))
-         (and org-insert-heading-respect-content (org-show-subtree))
-         (let ((split
-                (and (org-get-alist-option org-M-RET-may-split-line 'headline)
-                     (save-excursion
-                       (let ((p (point)))
-                         (goto-char (point-at-bol))
-                         (and (looking-at org-complex-heading-regexp)
-                              (match-beginning 4)
-                              (> p (match-beginning 4)))))))
-               tags pos)
-           (cond
-            (org-insert-heading-respect-content
-             (org-end-of-subtree nil t)
-             (when (featurep 'org-inlinetask)
-               (while (and (not (eobp))
-                           (looking-at "\\(\\*+\\)[ \t]+")
-                           (>= (length (match-string 1))
-                               org-inlinetask-min-level))
-                 (org-end-of-subtree nil t)))
-             (or (bolp) (newline))
-             (or (org-previous-line-empty-p)
-                 (and blank (newline)))
-             (open-line 1))
-            ((org-at-heading-p)
-             (when hide-previous
-               (show-children)
-               (org-show-entry))
-             (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$")
-             (setq tags (and (match-end 2) (match-string 2)))
-             (and (match-end 1)
-                  (delete-region (match-beginning 1) (match-end 1)))
-             (setq pos (point-at-bol))
-             (or split (end-of-line 1))
-             (delete-horizontal-space)
-             (if (string-match "\\`\\*+\\'"
-                               (buffer-substring (point-at-bol) (point)))
-                 (insert " "))
-             (newline (if blank 2 1))
-             (when tags
+              (or arg (not itemp))))
+      ;; At beginning of buffer or so high up that only a heading
+      ;; makes sense.
+      (insert
+       (if (or (bobp) (org-previous-line-empty-p)) "" "\n")
+       (if (org-in-src-block-p) ",* " "* "))
+      (run-hooks 'org-insert-heading-hook))
+
+     ((and itemp (not (equal arg '(4))))
+      ;; Insert an item
+      (org-insert-item))
+
+     (t
+      ;; Insert a heading
+      (save-restriction
+       (widen)
+       (let* ((level nil)
+              (on-heading (org-at-heading-p))
+              (empty-line-p (if on-heading
+                                (org-previous-line-empty-p)
+                              ;; We will decide later
+                              nil))
+              ;; Get a level string to fall back on
+              (fix-level
                (save-excursion
-                 (goto-char pos)
-                 (end-of-line 1)
-                 (insert " " tags)
-                 (org-set-tags nil 'align))))
-            (t
-             (or split (end-of-line 1))
-             (newline (if blank 2 1)))))))
-       (insert head) (just-one-space)
-       (setq pos (point))
-       (end-of-line 1)
-       (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
-        (when (and org-insert-heading-respect-content hide-previous)
-         (save-excursion
-           (goto-char previous-pos)
-           (hide-subtree)))
-       (run-hooks 'org-insert-heading-hook)))))
+                 (org-back-to-heading t)
+                 (if (org-previous-line-empty-p) (setq empty-line-p t))
+                 (looking-at org-outline-regexp)
+                 (make-string (1- (length (match-string 0))) ?*)))
+              (stars
+               (save-excursion
+                 (condition-case nil
+                     (progn
+                       (org-back-to-heading invisible-ok)
+                       (when (and (not on-heading)
+                                  (featurep 'org-inlinetask)
+                                  (integerp org-inlinetask-min-level)
+                                  (>= (length (match-string 0))
+                                      org-inlinetask-min-level))
+                         ;; Find a heading level before the inline task
+                         (while (and (setq level (org-up-heading-safe))
+                                     (>= level org-inlinetask-min-level)))
+                         (if (org-at-heading-p)
+                             (org-back-to-heading invisible-ok)
+                           (error "This should not happen")))
+                       (unless (and (save-excursion
+                                      (save-match-data
+                                        (org-backward-heading-same-level
+                                         1 invisible-ok))
+                                      (= (point) (match-beginning 0)))
+                                    (not (org-previous-line-empty-p t)))
+                         (setq empty-line-p (or empty-line-p
+                                                (org-previous-line-empty-p))))
+                       (match-string 0))
+                   (error (or fix-level "* ")))))
+              (blank-a (cdr (assq 'heading org-blank-before-new-entry)))
+              (blank (if (eq blank-a 'auto) empty-line-p blank-a))
+              pos hide-previous previous-pos)
+
+         ;; If we insert after content, move there and clean up whitespace
+         (when respect-content
+           (org-end-of-subtree nil t)
+           (skip-chars-backward " \r\n")
+           (and (looking-at "[ \t]+") (replace-match ""))
+           (unless (eobp) (forward-char 1))
+           (when (looking-at "^\\*")
+             (unless (bobp) (backward-char 1))
+             (insert "\n")))
+
+         ;; If we are splitting, grab the text that should be moved to the new headline
+         (when may-split
+           (if (org-on-heading-p)
+               ;; This is a heading, we split intelligently (keeping tags)
+               (let ((pos (point)))
+                 (goto-char (point-at-bol))
+                 (unless (looking-at org-complex-heading-regexp)
+                   (error "This should not happen"))
+                 (when (and (match-beginning 4)
+                            (> pos (match-beginning 4))
+                            (< pos (match-end 4)))
+                   (setq initial-content (buffer-substring pos (match-end 4)))
+                   (goto-char pos)
+                   (delete-region (point) (match-end 4))
+                   (if (looking-at "[ \t]*$")
+                       (replace-match "")
+                     (insert (make-string (length initial-content) ?\ )))
+                   (setq initial-content (org-trim initial-content)))
+                 (goto-char pos))
+             ;; a normal line
+             (unless (bolp)
+               (setq initial-content (buffer-substring (point) (point-at-eol)))
+               (delete-region (point) (point-at-eol))
+               (setq initial-content (org-trim initial-content)))))
+
+         ;; If we are at the beginning of the line, insert before it.  Else after
+         (cond
+          ((and (bolp) (looking-at "[ \t]*$")))
+          ((and (bolp) (not (looking-at "[ \t]*$")))
+           (open-line 1))
+          (t
+           (goto-char (point-at-eol))
+           (insert "\n")))
+
+         ;; Insert the new heading
+         (insert stars)
+         (just-one-space)
+         (insert initial-content)
+         (when adjust-empty-lines
+           (if (or (not blank)
+                   (and blank (not (org-previous-line-empty-p))))
+               (org-N-empty-lines-before-current (if blank 1 0))))
+         (run-hooks 'org-insert-heading-hook)))))))
+
+(defun org-N-empty-lines-before-current (N)
+  "Make the number of empty lines before current exactly N.
+So this will delete or add empty lines."
+  (save-excursion
+    (goto-char (point-at-bol))
+    (if (looking-back "\\s-+" nil 'greedy)
+       (replace-match ""))
+    (or (bobp) (insert "\n"))
+    (while (> N 0)
+      (insert "\n")
+      (setq N (1- N)))))
 
 (defun org-get-heading (&optional no-tags no-todo)
   "Return the heading of the current entry, without the stars.
@@ -7208,6 +7723,8 @@ When NO-TODO is non-nil, don't include TODO keywords."
      (t (looking-at org-heading-regexp)
        (match-string 2)))))
 
+(defvar orgstruct-mode)   ; defined below
+
 (defun org-heading-components ()
   "Return the components of the current heading.
 This is a list with the following elements:
@@ -7219,13 +7736,24 @@ This is a list with the following elements:
 - the tags string, or nil."
   (save-excursion
     (org-back-to-heading t)
-    (if (let (case-fold-search) (looking-at org-complex-heading-regexp))
-       (list (length (match-string 1))
-             (org-reduced-level (length (match-string 1)))
-             (org-match-string-no-properties 2)
-             (and (match-end 3) (aref (match-string 3) 2))
-             (org-match-string-no-properties 4)
-             (org-match-string-no-properties 5)))))
+    (if (let (case-fold-search)
+          (looking-at
+           (if orgstruct-mode
+               org-heading-regexp
+             org-complex-heading-regexp)))
+        (if orgstruct-mode
+            (list (length (match-string 1))
+                  (org-reduced-level (length (match-string 1)))
+                  nil
+                  nil
+                  (match-string 2)
+                  nil)
+          (list (length (match-string 1))
+                (org-reduced-level (length (match-string 1)))
+                (org-match-string-no-properties 2)
+                (and (match-end 3) (aref (match-string 3) 2))
+                (org-match-string-no-properties 4)
+                (org-match-string-no-properties 5))))))
 
 (defun org-get-entry ()
   "Get the entry text, after heading, entire subtree."
@@ -7241,25 +7769,27 @@ This is a list with the following elements:
   (org-move-subtree-down)
   (end-of-line 1))
 
-(defun org-insert-heading-respect-content (invisible-ok)
+(defun org-insert-heading-respect-content (&optional arg invisible-ok)
   "Insert heading with `org-insert-heading-respect-content' set to t."
   (interactive "P")
   (let ((org-insert-heading-respect-content t))
-    (org-insert-heading t invisible-ok)))
+    (org-insert-heading '(4) invisible-ok)))
 
 (defun org-insert-todo-heading-respect-content (&optional force-state)
   "Insert TODO heading with `org-insert-heading-respect-content' set to t."
   (interactive "P")
   (let ((org-insert-heading-respect-content t))
-    (org-insert-todo-heading force-state t)))
+    (org-insert-todo-heading force-state '(4))))
 
 (defun org-insert-todo-heading (arg &optional force-heading)
   "Insert a new heading with the same level and TODO state as current heading.
 If the heading has no TODO state, or if the state is DONE, use the first
-state (TODO by default).  Also with prefix arg, force first state."
+state (TODO by default).  Also one prefix arg, force first state.  With two
+prefix args, force inserting at the end of the parent subtree."
   (interactive "P")
   (when (or force-heading (not (org-insert-item 'checkbox)))
-    (org-insert-heading force-heading)
+    (org-insert-heading (or (and (equal arg '(16)) '(16))
+                           force-heading))
     (save-excursion
       (org-back-to-heading)
       (outline-previous-heading)
@@ -7417,8 +7947,6 @@ even level numbers will become the next higher odd number."
       (define-obsolete-function-alias 'org-get-legal-level
        'org-get-valid-level "23.1")))
 
-(defvar org-called-with-limited-levels nil) ;; Dynamically bound in
-;; ̀org-with-limited-levels'
 (defun org-promote ()
   "Promote the current heading higher up the tree.
 If the region is active in `transient-mark-mode', promote all headings
@@ -7433,7 +7961,7 @@ in the region."
                org-allow-promoting-top-level-subtree)
           (replace-match "# " nil t))
          ((= level 1)
-          (error "Cannot promote to level 0.  UNDO to recover if necessary"))
+          (user-error "Cannot promote to level 0.  UNDO to recover if necessary"))
          (t (replace-match up-head nil t)))
     ;; Fixup tag positioning
     (unless (= level 1)
@@ -7627,7 +8155,7 @@ case."
     (while (> cnt 0)
       (or (and (funcall movfunc) (looking-at org-outline-regexp))
          (progn (goto-char beg0)
-                (error "Cannot move past superior level or buffer limit")))
+                (user-error "Cannot move past superior level or buffer limit")))
       (setq cnt (1- cnt)))
     (if (> arg 0)
        ;; Moving forward - still need to move over subtree
@@ -7687,9 +8215,9 @@ This is a short-hand for marking the subtree and then cutting it."
   (interactive "p")
   (org-copy-subtree n 'cut))
 
-(defun org-copy-subtree (&optional n cut force-store-markers)
-  "Cut the current subtree into the clipboard.
-With prefix arg N, cut this many sequential subtrees.
+(defun org-copy-subtree (&optional n cut force-store-markers nosubtrees)
+  "Copy the current subtree it in the clipboard.
+With prefix arg N, copy this many sequential subtrees.
 This is a short-hand for marking the subtree and then copying it.
 If CUT is non-nil, actually cut the subtree.
 If FORCE-STORE-MARKERS is non-nil, store the relative locations
@@ -7703,12 +8231,14 @@ useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
     (setq beg (point))
     (skip-chars-forward " \t\r\n")
     (save-match-data
-      (save-excursion (outline-end-of-heading)
-                     (setq folded (outline-invisible-p)))
-      (condition-case nil
-         (org-forward-heading-same-level (1- n) t)
-       (error nil))
-      (org-end-of-subtree t t))
+      (if nosubtrees
+         (outline-next-heading)
+       (save-excursion (outline-end-of-heading)
+                       (setq folded (outline-invisible-p)))
+       (condition-case nil
+           (org-forward-heading-same-level (1- n) t)
+         (error nil))
+       (org-end-of-subtree t t)))
     (setq end (point))
     (goto-char beg0)
     (when (> end beg)
@@ -7727,7 +8257,7 @@ The entire subtree is promoted or demoted in order to match a new headline
 level.
 
 If the cursor is at the beginning of a headline, the same level as
-that headline is used to paste the tree
+that headline is used to paste the tree.
 
 If not, the new level is derived from the *visible* headings
 before and after the insertion point, and taken to be the inferior headline
@@ -7748,7 +8278,7 @@ the inserted text when done."
   (interactive "P")
   (setq tree (or tree (and kill-ring (current-kill 0))))
   (unless (org-kill-is-subtree-p tree)
-    (error "%s"
+    (user-error "%s"
           (substitute-command-keys
            "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
   (org-with-limited-levels
@@ -7909,7 +8439,7 @@ If yes, remember the marker and the distance to BEG."
                                        "^[ \t]*#\\+end_.*")))
     (if blockp
        (narrow-to-region (car blockp) (cdr blockp))
-      (error "Not in a block"))))
+      (user-error "Not in a block"))))
 
 (eval-when-compile
   (defvar org-property-drawer-re))
@@ -7920,8 +8450,10 @@ If yes, remember the marker and the distance to BEG."
 The clones will be inserted as siblings.
 
 In interactive use, the user will be prompted for the number of
-clones to be produced, and for a time SHIFT, which may be a
-repeater as used in time stamps, for example `+3d'.
+clones to be produced.  If the entry has a timestamp, the user
+will also be prompted for a time shift, which may be a repeater
+as used in time stamps, for example `+3d'.  To disable this,
+you can call the function with a universal prefix argument.
 
 When a valid repeater is given and the entry contains any time
 stamps, the clones will become a sequence in time, with time
@@ -7940,10 +8472,22 @@ the following will happen:
   to past the last clone.
 In this way you can spell out a number of instances of a repeating task,
 and still retain the repeater to cover future instances of the task."
-  (interactive "nNumber of clones to produce: \nsDate shift per clone (e.g. +1w, empty to copy unchanged): ")
-  (let (beg end template task idprop
-           shift-n shift-what doshift nmin nmax (n-no-remove -1)
-           (drawer-re org-drawer-regexp))
+  (interactive "nNumber of clones to produce: ")
+  (let ((shift
+        (or shift
+            (if (and (not (equal current-prefix-arg '(4)))
+                     (save-excursion
+                       (re-search-forward org-ts-regexp-both
+                                          (save-excursion
+                                            (org-end-of-subtree t)
+                                            (point)) t)))
+                (read-from-minibuffer
+                 "Date shift per clone (e.g. +1w, empty to copy unchanged): ")
+              ""))) ;; No time shift
+       (n-no-remove -1)
+       (drawer-re org-drawer-regexp)
+       beg end template task idprop
+       shift-n shift-what doshift nmin nmax)
     (if (not (and (integerp n) (> n 0)))
        (error "Invalid number of replications %s" n))
     (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift)))
@@ -8015,11 +8559,16 @@ Optional argument WITH-CASE means sort case-sensitively."
     (org-call-with-arg 'org-sort-entries with-case))))
 
 (defun org-sort-remove-invisible (s)
+  "Remove invisible links from string S."
   (remove-text-properties 0 (length s) org-rm-props s)
   (while (string-match org-bracket-link-regexp s)
     (setq s (replace-match (if (match-end 2)
                               (match-string 3 s)
                             (match-string 1 s)) t t s)))
+  (let ((st (format " %s " s)))
+    (while (string-match org-emph-re st)
+      (setq st (replace-match (format " %s " (match-string 4 st)) t t st)))
+    (setq s (substring st 1 -1)))
   s)
 
 (defvar org-priority-regexp) ; defined later in the file
@@ -8038,7 +8587,7 @@ Else, if the cursor is before the first entry, sort the top-level items.
 Else, the children of the entry at point are sorted.
 
 Sorting can be alphabetically, numerically, by date/time as given by
-a time stamp, by a property or by priority.
+a time stamp, by a property, by priority order, or by a custom function.
 
 The command prompts for the sorting type unless it has been given to the
 function through the SORTING-TYPE argument, which needs to be a character,
@@ -8064,7 +8613,10 @@ called with point at the beginning of the record.  It must return either
 a string or a number that should serve as the sorting key for that record.
 
 Comparing entries ignores case by default.  However, with an optional argument
-WITH-CASE, the sorting considers case as well."
+WITH-CASE, the sorting considers case as well.
+
+Sorting is done against the visible part of the headlines, it ignores hidden
+links."
   (interactive "P")
   (let ((case-func (if with-case 'identity 'downcase))
        (cmstr
@@ -8115,7 +8667,7 @@ WITH-CASE, the sorting considers case as well."
       (show-all)))
 
     (setq beg (point))
-    (if (>= beg end) (error "Nothing to sort"))
+    (if (>= beg end) (user-error "Nothing to sort"))
 
     (looking-at "\\(\\*+\\)")
     (setq stars (match-string 1)
@@ -8124,7 +8676,7 @@ WITH-CASE, the sorting considers case as well."
          txt (buffer-substring beg end))
     (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n")))
     (if (and (not (equal stars "*")) (string-match re2 txt))
-       (error "Region to sort contains a level above the first entry"))
+       (user-error "Region to sort contains a level above the first entry"))
 
     (unless sorting-type
       (message
@@ -8134,13 +8686,15 @@ WITH-CASE, the sorting considers case as well."
        what)
       (setq sorting-type (read-char-exclusive))
 
-      (and (= (downcase sorting-type) ?f)
-           (setq getkey-func
-                 (org-icompleting-read "Sort using function: "
-                                      obarray 'fboundp t nil nil))
-           (setq getkey-func (intern getkey-func)))
+      (unless getkey-func
+       (and (= (downcase sorting-type) ?f)
+            (setq getkey-func
+                  (org-icompleting-read "Sort using function: "
+                                        obarray 'fboundp t nil nil))
+            (setq getkey-func (intern getkey-func))))
 
       (and (= (downcase sorting-type) ?r)
+          (not property)
            (setq property
                  (org-icompleting-read "Property: "
                                       (mapcar 'list (org-buffer-property-keys t))
@@ -8174,11 +8728,11 @@ WITH-CASE, the sorting considers case as well."
           (cond
            ((= dcst ?n)
             (if (looking-at org-complex-heading-regexp)
-                (string-to-number (match-string 4))
+                (string-to-number (org-sort-remove-invisible (match-string 4)))
               nil))
            ((= dcst ?a)
             (if (looking-at org-complex-heading-regexp)
-                (funcall case-func (match-string 4))
+                (funcall case-func (org-sort-remove-invisible (match-string 4)))
               nil))
            ((= dcst ?t)
             (let ((end (save-excursion (outline-next-heading) (point))))
@@ -8296,12 +8850,23 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 ;; command.  There might be problems if any of the keys is otherwise
 ;; used as a prefix key.
 
-;; Another challenge is that the key binding for TAB can be tab or \C-i,
-;; likewise the binding for RET can be return or \C-m.  Orgtbl-mode
-;; addresses this by checking explicitly for both bindings.
+(defcustom orgstruct-heading-prefix-regexp nil
+  "Regexp that matches the custom prefix of Org headlines in
+orgstruct(++)-mode."
+  :group 'org
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+;;;###autoload(put 'orgstruct-heading-prefix-regexp 'safe-local-variable 'stringp)
+
+(defcustom orgstruct-setup-hook nil
+  "Hook run after orgstruct-mode-map is filled."
+  :group 'org
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'hook)
 
-(defvar orgstruct-mode-map (make-sparse-keymap)
-  "Keymap for the minor `orgstruct-mode'.")
+(defvar orgstruct-initialized nil)
 
 (defvar org-local-vars nil
   "List of local variables, for use by `orgstruct-mode'.")
@@ -8312,26 +8877,17 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
 This mode is for using Org-mode structure commands in other
 modes.  The following keys behave as if Org-mode were active, if
 the cursor is on a headline, or on a plain list item (both as
-defined by Org-mode).
-
-M-up        Move entry/item up
-M-down     Move entry/item down
-M-left     Promote
-M-right            Demote
-M-S-up     Move entry/item up
-M-S-down    Move entry/item down
-M-S-left    Promote subtree
-M-S-right   Demote subtree
-M-q        Fill paragraph and items like in Org-mode
-C-c ^      Sort entries
-C-c -      Cycle list bullet
-TAB         Cycle item visibility
-M-RET       Insert new heading/item
-S-M-RET     Insert new TODO heading / Checkbox item
-C-c C-c     Set tags / toggle checkbox"
-  nil " OrgStruct" nil
-  (org-load-modules-maybe)
-  (and (orgstruct-setup) (defun orgstruct-setup () nil)))
+defined by Org-mode)."
+  nil " OrgStruct" (make-sparse-keymap)
+  (funcall (if orgstruct-mode
+              'add-to-invisibility-spec
+            'remove-from-invisibility-spec)
+          '(outline . t))
+  (when orgstruct-mode
+    (org-load-modules-maybe)
+    (unless orgstruct-initialized
+      (orgstruct-setup)
+      (setq orgstruct-initialized t))))
 
 ;;;###autoload
 (defun turn-on-orgstruct ()
@@ -8355,6 +8911,8 @@ buffer.  It will also recognize item context in multiline items."
                   org-fb-vars))
     (orgstruct-mode 1)
     (setq org-fb-vars nil)
+    (unless org-local-vars
+      (setq org-local-vars (org-get-local-variables)))
     (let (var val)
       (mapc
        (lambda (x)
@@ -8379,107 +8937,164 @@ buffer.  It will also recognize item context in multiline items."
 (defun orgstruct-error ()
   "Error when there is no default binding for a structure key."
   (interactive)
-  (error "This key has no function outside structure elements"))
+  (funcall (if (fboundp 'user-error)
+              'user-error
+            'error)
+          "This key has no function outside structure elements"))
 
 (defun orgstruct-setup ()
-  "Setup orgstruct keymaps."
-  (let ((nfunc 0)
-       (bindings
-        (list
-         '([(meta up)]           org-metaup)
-         '([(meta down)]         org-metadown)
-         '([(meta left)]         org-metaleft)
-         '([(meta right)]        org-metaright)
-         '([(meta shift up)]     org-shiftmetaup)
-         '([(meta shift down)]   org-shiftmetadown)
-         '([(meta shift left)]   org-shiftmetaleft)
-         '([(meta shift right)]  org-shiftmetaright)
-         '([?\e (up)]            org-metaup)
-         '([?\e (down)]          org-metadown)
-         '([?\e (left)]          org-metaleft)
-         '([?\e (right)]         org-metaright)
-         '([?\e (shift up)]      org-shiftmetaup)
-         '([?\e (shift down)]    org-shiftmetadown)
-         '([?\e (shift left)]    org-shiftmetaleft)
-         '([?\e (shift right)]   org-shiftmetaright)
-         '([(shift up)]          org-shiftup)
-         '([(shift down)]        org-shiftdown)
-         '([(shift left)]        org-shiftleft)
-         '([(shift right)]       org-shiftright)
-         '("\C-c\C-c"            org-ctrl-c-ctrl-c)
-         '("\M-q"                fill-paragraph)
-         '("\C-c^"               org-sort)
-         '("\C-c-"               org-cycle-list-bullet)))
-       elt key fun cmd)
-    (while (setq elt (pop bindings))
-      (setq nfunc (1+ nfunc))
-      (setq key (org-key (car elt))
-           fun (nth 1 elt)
-           cmd (orgstruct-make-binding fun nfunc key))
-      (org-defkey orgstruct-mode-map key cmd))
-
-    ;; Prevent an error for users who forgot to make autoloads
-    (require 'org-element)
-
-    ;; Special treatment needed for TAB and RET
-    (org-defkey orgstruct-mode-map [(tab)]
-               (orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
-    (org-defkey orgstruct-mode-map "\C-i"
-               (orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))
-
-    (org-defkey orgstruct-mode-map "\M-\C-m"
-               (orgstruct-make-binding 'org-insert-heading 105
-                                       "\M-\C-m" [(meta return)]))
-    (org-defkey orgstruct-mode-map [(meta return)]
-               (orgstruct-make-binding 'org-insert-heading 106
-                                       [(meta return)] "\M-\C-m"))
-
-    (org-defkey orgstruct-mode-map [(shift meta return)]
-               (orgstruct-make-binding 'org-insert-todo-heading 107
-                                       [(meta return)] "\M-\C-m"))
-
-    (org-defkey orgstruct-mode-map "\e\C-m"
-               (orgstruct-make-binding 'org-insert-heading 108
-                                       "\e\C-m" [?\e (return)]))
-    (org-defkey orgstruct-mode-map [?\e (return)]
-               (orgstruct-make-binding 'org-insert-heading 109
-                                       [?\e (return)] "\e\C-m"))
-    (org-defkey orgstruct-mode-map [?\e (shift return)]
-               (orgstruct-make-binding 'org-insert-todo-heading 110
-                                       [?\e (return)] "\e\C-m"))
-
-    (unless org-local-vars
-      (setq org-local-vars (org-get-local-variables)))
-
-    t))
-
-(defun orgstruct-make-binding (fun n &rest keys)
+  "Setup orgstruct keymap."
+  (dolist (cell '((org-demote . t)
+                 (org-metaleft . t)
+                 (org-metaright . t)
+                 (org-promote . t)
+                 (org-shiftmetaleft . t)
+                 (org-shiftmetaright . t)
+                 org-backward-element
+                 org-backward-heading-same-level
+                 org-ctrl-c-ret
+                 org-ctrl-c-minus
+                 org-ctrl-c-star
+                 org-cycle
+                 org-forward-heading-same-level
+                 org-insert-heading
+                 org-insert-heading-respect-content
+                 org-kill-note-or-show-branches
+                 org-mark-subtree
+                 org-meta-return
+                 org-metadown
+                 org-metaup
+                 org-narrow-to-subtree
+                 org-promote-subtree
+                 org-reveal
+                 org-shiftdown
+                 org-shiftleft
+                 org-shiftmetadown
+                 org-shiftmetaup
+                 org-shiftright
+                 org-shifttab
+                 org-shifttab
+                 org-shiftup
+                 org-show-subtree
+                 org-sort
+                 org-up-element
+                 outline-demote
+                 outline-next-visible-heading
+                 outline-previous-visible-heading
+                 outline-promote
+                 outline-up-heading
+                 show-children))
+    (let ((f (or (car-safe cell) cell))
+         (disable-when-heading-prefix (cdr-safe cell)))
+      (when (fboundp f)
+       (let ((new-bindings))
+         (dolist (binding (nconc (where-is-internal f org-mode-map)
+                                 (where-is-internal f outline-mode-map)))
+           (push binding new-bindings)
+           ;; TODO use local-function-key-map
+           (dolist (rep '(("<tab>" . "TAB")
+                          ("<return>" . "RET")
+                          ("<escape>" . "ESC")
+                          ("<delete>" . "DEL")))
+             (setq binding (read-kbd-macro
+                            (let ((case-fold-search))
+                              (replace-regexp-in-string
+                               (regexp-quote (cdr rep))
+                               (car rep)
+                               (key-description binding)))))
+             (pushnew binding new-bindings :test 'equal)))
+         (dolist (binding new-bindings)
+           (let ((key (lookup-key orgstruct-mode-map binding)))
+             (when (or (not key) (numberp key))
+               (condition-case nil
+                   (org-defkey orgstruct-mode-map
+                               binding
+                               (orgstruct-make-binding f binding disable-when-heading-prefix))
+                 (error nil)))))))))
+  (run-hooks 'orgstruct-setup-hook))
+
+(defun orgstruct-make-binding (fun key disable-when-heading-prefix)
   "Create a function for binding in the structure minor mode.
-FUN is the command to call inside a table.  N is used to create a unique
-command name.  KEYS are keys that should be checked in for a command
-to execute outside of tables."
-  (eval
-   (list 'defun
-        (intern (concat "orgstruct-hijacker-command-" (int-to-string n)))
-        '(arg)
-        (concat "In Structure, run `" (symbol-name fun) "'.\n"
-                "Outside of structure, run the binding of `"
-                (mapconcat (lambda (x) (format "%s" x)) keys "' or `")
-                "'.")
-        '(interactive "p")
-        (list 'if
-              `(org-context-p 'headline 'item
-                              (and orgstruct-is-++
-                                   ,(and (memq fun '(org-insert-heading org-insert-todo-heading)) t)
-                                   'item-body))
-              (list 'org-run-like-in-org-mode (list 'quote fun))
-              (list 'let '(orgstruct-mode)
-                    (list 'call-interactively
-                          (append '(or)
-                                  (mapcar (lambda (k)
-                                            (list 'key-binding k))
-                                          keys)
-                                  '('orgstruct-error))))))))
+FUN is the command to call inside a table.  KEY is the key that
+should be checked in for a command to execute outside of tables.
+Non-nil DISABLE-WHEN-HEADING-PREFIX means to disable the command
+if `orgstruct-heading-prefix-regexp' is non-nil."
+  (let ((name (concat "orgstruct-hijacker-" (symbol-name fun))))
+    (let ((nname name)
+         (i 0))
+      (while (fboundp (intern nname))
+       (setq nname (format "%s-%d" name (setq i (1+ i)))))
+      (setq name (intern nname)))
+    (eval
+     (let ((bindings '((org-heading-regexp
+                       (concat "^"
+                               orgstruct-heading-prefix-regexp
+                               "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[                ]*$"))
+                      (org-outline-regexp
+                       (concat orgstruct-heading-prefix-regexp "\\*+ "))
+                      (org-outline-regexp-bol
+                       (concat "^" org-outline-regexp))
+                      (outline-regexp org-outline-regexp)
+                      (outline-heading-end-regexp "\n")
+                      (outline-level 'org-outline-level)
+                      (outline-heading-alist))))
+       `(defun ,name (arg)
+         ,(concat "In Structure, run `" (symbol-name fun) "'.\n"
+                  "Outside of structure, run the binding of `"
+                  (key-description key) "'."
+                  (when disable-when-heading-prefix
+                    (concat
+                     "\nIf `orgstruct-heading-prefix-regexp' is non-nil, this command will always fall\n"
+                     "back to the default binding due to limitations of Org's implementation of\n"
+                     "`" (symbol-name fun) "'.")))
+         (interactive "p")
+         (let* ((disable
+                 ,(when disable-when-heading-prefix
+                    '(and orgstruct-heading-prefix-regexp
+                          (not (string= orgstruct-heading-prefix-regexp "")))))
+                (fallback
+                 (or disable
+                     (not
+                      (let* ,bindings
+                        (org-context-p 'headline 'item
+                                       ,(when (memq fun
+                                                    '(org-insert-heading
+                                                      org-insert-heading-respect-content
+                                                      org-meta-return))
+                                          '(when orgstruct-is-++
+                                             'item-body))))))))
+           (if fallback
+               (let* ((orgstruct-mode)
+                      (binding
+                       (loop with key = ,key
+                             for rep in
+                             '(nil
+                               ("<\\([^>]*\\)tab>" . "\\1TAB")
+                               ("<\\([^>]*\\)return>" . "\\1RET")
+                               ("<\\([^>]*\\)escape>" . "\\1ESC")
+                               ("<\\([^>]*\\)delete>" . "\\1DEL"))
+                             do
+                             (when rep
+                               (setq key (read-kbd-macro
+                                          (let ((case-fold-search))
+                                            (replace-regexp-in-string
+                                             (car rep)
+                                             (cdr rep)
+                                             (key-description key))))))
+                             thereis (key-binding key))))
+                 (if (keymapp binding)
+                     (set-temporary-overlay-map binding)
+                   (let ((func (or binding
+                                   (unless disable
+                                     'orgstruct-error))))
+                     (when func
+                       (call-interactively func)))))
+             (org-run-like-in-org-mode
+              (lambda ()
+                (interactive)
+                (let* ,bindings
+                  (call-interactively ',fun)))))))))
+    name))
 
 (defun org-contextualize-keys (alist contexts)
   "Return valid elements in ALIST depending on CONTEXTS.
@@ -8543,11 +9158,15 @@ definitions."
                          (string-match (cdr rr) (buffer-file-name)))
                     (and (eq (car rr) 'in-mode)
                          (string-match (cdr rr) (symbol-name major-mode)))
+                    (and (eq (car rr) 'in-buffer)
+                         (string-match (cdr rr) (buffer-name)))
                     (when (and (eq (car rr) 'not-in-file)
                                (buffer-file-name))
                       (not (string-match (cdr rr) (buffer-file-name))))
                     (when (eq (car rr) 'not-in-mode)
-                      (not (string-match (cdr rr) (symbol-name major-mode)))))))
+                      (not (string-match (cdr rr) (symbol-name major-mode))))
+                    (when (eq (car rr) 'not-in-buffer)
+                      (not (string-match (cdr rr) (buffer-name)))))))
          (push r res)))
        (car (last r))))
     (delete-dups (delq nil res))))
@@ -8576,17 +9195,18 @@ Possible values in the list of contexts are `table', `headline', and `item'."
       (setq varlist (buffer-local-variables)))
     (kill-buffer "*Org tmp*")
     (delq nil
-         (mapcar
-          (lambda (x)
-            (setq x
-                  (if (symbolp x)
-                      (list x)
-                    (list (car x) (list 'quote (cdr x)))))
-            (if (string-match
-                 "^\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
-                 (symbol-name (car x)))
-                x nil))
-          varlist))))
+          (mapcar
+           (lambda (x)
+             (setq x
+                   (if (symbolp x)
+                       (list x)
+                     (list (car x) (cdr x))))
+             (if (and (not (get (car x) 'org-state))
+                      (string-match
+                       "^\\(org-\\|orgtbl-\\|outline-\\|comment-\\|paragraph-\\|auto-fill\\|normal-auto-fill\\|fill-paragraph\\|indent-\\)"
+                       (symbol-name (car x))))
+                 x nil))
+           varlist))))
 
 (defun org-clone-local-variables (from-buffer &optional regexp)
   "Clone local variables from FROM-BUFFER.
@@ -8609,8 +9229,14 @@ call CMD."
   (org-load-modules-maybe)
   (unless org-local-vars
     (setq org-local-vars (org-get-local-variables)))
-  (eval (list 'let org-local-vars
-             (list 'call-interactively (list 'quote cmd)))))
+  (let (binds)
+    (dolist (var org-local-vars)
+      (when (or (not (boundp (car var)))
+               (eq (symbol-value (car var))
+                   (default-value (car var))))
+       (push (list (car var) `(quote ,(cadr var))) binds)))
+    (eval `(let ,binds
+            (call-interactively (quote ,cmd))))))
 
 ;;;; Archiving
 
@@ -8636,7 +9262,7 @@ call CMD."
                  ((symbolp org-category) (symbol-name org-category))
                  (t org-category)))
        beg end cat pos optionp)
-    (org-unmodified
+    (org-with-silent-modifications
      (save-excursion
        (save-restriction
         (widen)
@@ -8661,7 +9287,7 @@ DPROP is the drawer property and TPROP is the corresponding text
 property to set."
   (let ((case-fold-search t)
        (inhibit-read-only t) p)
-    (org-unmodified
+    (org-with-silent-modifications
      (save-excursion
        (save-restriction
         (widen)
@@ -8671,7 +9297,7 @@ property to set."
           (save-excursion
             (org-back-to-heading t)
             (put-text-property
-             (point-at-bol) (point-at-eol) tprop p))))))))
+             (point-at-bol) (org-end-of-subtree t t) tprop p))))))))
 
 
 ;;;; Link Stuff
@@ -8692,7 +9318,9 @@ property to set."
          (cond
           ((symbolp rpl) (funcall rpl tag))
           ((string-match "%(\\([^)]+\\))" rpl)
-           (replace-match (funcall (intern-soft (match-string 1 rpl)) tag) t t rpl))
+           (replace-match
+            (save-match-data
+              (funcall (intern-soft (match-string 1 rpl)) tag)) t t rpl))
           ((string-match "%s" rpl) (replace-match (or tag "") t t rpl))
           ((string-match "%h" rpl)
            (replace-match (url-hexify-string (or tag "")) t t rpl))
@@ -8774,191 +9402,237 @@ type.  For a simple example of an export function, see `org-bbdb.el'."
 This link is added to `org-stored-links' and can later be inserted
 into an org-buffer with \\[org-insert-link].
 
-For some link types, a prefix arg is interpreted:
-For links to usenet articles, arg negates `org-gnus-prefer-web-links'.
-For file links, arg negates `org-context-in-file-links'."
-  (interactive "P")
-  (org-load-modules-maybe)
-  (setq org-store-link-plist nil)  ; reset
-  (org-with-limited-levels
-   (let (link cpltxt desc description search txt custom-id agenda-link)
-     (cond
+For some link types, a prefix arg is interpreted.
+For links to Usenet articles, arg negates `org-gnus-prefer-web-links'.
+For file links, arg negates `org-context-in-file-links'.
 
-      ((run-hook-with-args-until-success 'org-store-link-functions)
-       (setq link (plist-get org-store-link-plist :link)
-            desc (or (plist-get org-store-link-plist :description) link)))
+A double prefix arg force skipping storing functions that are not
+part of Org's core.
 
-      ((org-src-edit-buffer-p)
-       (let (label gc)
-        (while (or (not label)
-                   (save-excursion
-                     (save-restriction
-                       (widen)
-                       (goto-char (point-min))
-                       (re-search-forward
-                        (regexp-quote (format org-coderef-label-format label))
-                        nil t))))
-          (when label (message "Label exists already") (sit-for 2))
-          (setq label (read-string "Code line label: " label)))
-        (end-of-line 1)
-        (setq link (format org-coderef-label-format label))
-        (setq gc (- 79 (length link)))
-        (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
-        (insert link)
-        (setq link (concat "(" label ")") desc nil)))
-
-      ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
-       ;; We are in the agenda, link to referenced location
-       (let ((m (or (get-text-property (point) 'org-hd-marker)
-                   (get-text-property (point) 'org-marker))))
-        (when m
-          (org-with-point-at m
-            (setq agenda-link
-                  (if (org-called-interactively-p 'any)
-                      (call-interactively 'org-store-link)
-                    (org-store-link nil)))))))
-
-      ((eq major-mode 'calendar-mode)
-       (let ((cd (calendar-cursor-to-date)))
-        (setq link
-              (format-time-string
-               (car org-time-stamp-formats)
-               (apply 'encode-time
-                      (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
-                            nil nil nil))))
-        (org-store-link-props :type "calendar" :date cd)))
-
-      ((eq major-mode 'help-mode)
-       (setq link (concat "help:" (save-excursion
-                                   (goto-char (point-min))
-                                   (looking-at "^[^ ]+")
-                                   (match-string 0))))
-       (org-store-link-props :type "help"))
-
-      ((eq major-mode 'w3-mode)
-       (setq cpltxt (if (and (buffer-name)
-                            (not (string-match "Untitled" (buffer-name))))
-                       (buffer-name)
-                     (url-view-url t))
-            link (url-view-url t))
-       (org-store-link-props :type "w3" :url (url-view-url t)))
-
-      ((eq major-mode 'w3m-mode)
-       (setq cpltxt (or w3m-current-title w3m-current-url)
-            link w3m-current-url)
-       (org-store-link-props :type "w3m" :url (url-view-url t)))
-
-      ((setq search (run-hook-with-args-until-success
-                    'org-create-file-search-functions))
-       (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
-                         "::" search))
-       (setq cpltxt (or description link)))
-
-      ((eq major-mode 'image-mode)
-       (setq cpltxt (concat "file:"
-                           (abbreviate-file-name buffer-file-name))
-            link cpltxt)
-       (org-store-link-props :type "image" :file buffer-file-name))
-
-      ((eq major-mode 'dired-mode)
-       ;; link to the file in the current line
-       (let ((file (dired-get-filename nil t)))
-        (setq file (if file
-                       (abbreviate-file-name
-                        (expand-file-name (dired-get-filename nil t)))
-                     ;; otherwise, no file so use current directory.
-                     default-directory))
-        (setq cpltxt (concat "file:" file)
-              link cpltxt)))
-
-      ((and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode))
-       (setq custom-id (org-entry-get nil "CUSTOM_ID"))
+A triple prefix arg force storing a link for each line in the
+active region."
+  (interactive "P")
+  (org-load-modules-maybe)
+  (if (and (equal arg '(64)) (org-region-active-p))
+      (save-excursion
+       (let ((end (region-end)))
+         (goto-char (region-beginning))
+         (set-mark (point))
+         (while (< (point-at-eol) end)
+           (move-end-of-line 1) (activate-mark)
+           (let (current-prefix-arg)
+             (call-interactively 'org-store-link))
+           (move-beginning-of-line 2)
+           (set-mark (point)))))
+    (org-with-limited-levels
+     (setq org-store-link-plist nil)
+     (let (link cpltxt desc description search
+               txt custom-id agenda-link sfuns sfunsn)
        (cond
-       ((org-in-regexp "<<\\(.*?\\)>>")
-        (setq cpltxt
-              (concat "file:"
-                      (abbreviate-file-name
-                       (buffer-file-name (buffer-base-buffer)))
-                      "::" (match-string 1))
-              link cpltxt))
-       ((and (featurep 'org-id)
-             (or (eq org-id-link-to-org-use-id t)
-                 (and (org-called-interactively-p 'any)
-                      (or (eq org-id-link-to-org-use-id 'create-if-interactive)
-                          (and (eq org-id-link-to-org-use-id
-                                   'create-if-interactive-and-no-custom-id)
-                               (not custom-id))))
-                 (and org-id-link-to-org-use-id (org-entry-get nil "ID"))))
-        ;; We can make a link using the ID.
-        (setq link (condition-case nil
-                       (prog1 (org-id-store-link)
-                         (setq desc (plist-get org-store-link-plist :description)))
-                     (error
-                      ;; probably before first headline, link to file only
-                      (concat "file:"
-                              (abbreviate-file-name
-                               (buffer-file-name (buffer-base-buffer))))))))
-       (t
-        ;; Just link to current headline
+
+       ;; Store a link using an external link type
+       ((and (not (equal arg '(16)))
+             (setq sfuns
+                   (delq
+                    nil (mapcar (lambda (f)
+                                  (let (fs) (if (funcall f) (push f fs))))
+                                org-store-link-functions))
+                   sfunsn (mapcar (lambda (fu) (symbol-name (car fu))) sfuns))
+             (or (and (cdr sfuns)
+                      (funcall (intern
+                                (completing-read
+                                 "Which function for creating the link? "
+                                 sfunsn t (car sfunsn)))))
+                 (funcall (caar sfuns)))
+             (setq link (plist-get org-store-link-plist :link)
+                   desc (or (plist-get org-store-link-plist
+                                       :description) link))))
+
+       ;; Store a link from a source code buffer
+       ((org-src-edit-buffer-p)
+        (let (label gc)
+          (while (or (not label)
+                     (save-excursion
+                       (save-restriction
+                         (widen)
+                         (goto-char (point-min))
+                         (re-search-forward
+                          (regexp-quote (format org-coderef-label-format label))
+                          nil t))))
+            (when label (message "Label exists already") (sit-for 2))
+            (setq label (read-string "Code line label: " label)))
+          (end-of-line 1)
+          (setq link (format org-coderef-label-format label))
+          (setq gc (- 79 (length link)))
+          (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
+          (insert link)
+          (setq link (concat "(" label ")") desc nil)))
+
+       ;; We are in the agenda, link to referenced location
+       ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
+        (let ((m (or (get-text-property (point) 'org-hd-marker)
+                     (get-text-property (point) 'org-marker))))
+          (when m
+            (org-with-point-at m
+              (setq agenda-link
+                    (if (org-called-interactively-p 'any)
+                        (call-interactively 'org-store-link)
+                      (org-store-link nil)))))))
+
+       ((eq major-mode 'calendar-mode)
+        (let ((cd (calendar-cursor-to-date)))
+          (setq link
+                (format-time-string
+                 (car org-time-stamp-formats)
+                 (apply 'encode-time
+                        (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
+                              nil nil nil))))
+          (org-store-link-props :type "calendar" :date cd)))
+
+       ((eq major-mode 'help-mode)
+        (setq link (concat "help:" (save-excursion
+                                     (goto-char (point-min))
+                                     (looking-at "^[^ ]+")
+                                     (match-string 0))))
+        (org-store-link-props :type "help"))
+
+       ((eq major-mode 'w3-mode)
+        (setq cpltxt (if (and (buffer-name)
+                              (not (string-match "Untitled" (buffer-name))))
+                         (buffer-name)
+                       (url-view-url t))
+              link (url-view-url t))
+        (org-store-link-props :type "w3" :url (url-view-url t)))
+
+       ((eq major-mode 'image-mode)
+        (setq cpltxt (concat "file:"
+                             (abbreviate-file-name buffer-file-name))
+              link cpltxt)
+        (org-store-link-props :type "image" :file buffer-file-name))
+
+       ;; In dired, store a link to the file of the current line
+       ((eq major-mode 'dired-mode)
+        (let ((file (dired-get-filename nil t)))
+          (setq file (if file
+                         (abbreviate-file-name
+                          (expand-file-name (dired-get-filename nil t)))
+                       ;; otherwise, no file so use current directory.
+                       default-directory))
+          (setq cpltxt (concat "file:" file)
+                link cpltxt)))
+
+       ((setq search (run-hook-with-args-until-success
+                      'org-create-file-search-functions))
+        (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
+                           "::" search))
+        (setq cpltxt (or description link)))
+
+       ((and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode))
+        (setq custom-id (org-entry-get nil "CUSTOM_ID"))
+        (cond
+         ;; Store a link using the target at point
+         ((org-in-regexp "[^<]<<\\([^<>]+\\)>>[^>]" 1)
+          (setq cpltxt
+                (concat "file:"
+                        (abbreviate-file-name
+                         (buffer-file-name (buffer-base-buffer)))
+                        "::" (match-string 1))
+                link cpltxt))
+         ((and (featurep 'org-id)
+               (or (eq org-id-link-to-org-use-id t)
+                   (and (org-called-interactively-p 'any)
+                        (or (eq org-id-link-to-org-use-id 'create-if-interactive)
+                            (and (eq org-id-link-to-org-use-id
+                                     'create-if-interactive-and-no-custom-id)
+                                 (not custom-id))))
+                   (and org-id-link-to-org-use-id (org-entry-get nil "ID"))))
+          ;; Store a link using the ID at point
+          (setq link (condition-case nil
+                         (prog1 (org-id-store-link)
+                           (setq desc (plist-get org-store-link-plist
+                                                 :description)))
+                       (error
+                        ;; Probably before first headline, link only to file
+                        (concat "file:"
+                                (abbreviate-file-name
+                                 (buffer-file-name (buffer-base-buffer))))))))
+         (t
+          ;; Just link to current headline
+          (setq cpltxt (concat "file:"
+                               (abbreviate-file-name
+                                (buffer-file-name (buffer-base-buffer)))))
+          ;; Add a context search string
+          (when (org-xor org-context-in-file-links arg)
+            (let* ((ee (org-element-at-point))
+                   (et (org-element-type ee))
+                   (ev (plist-get (cadr ee) :value))
+                   (ek (plist-get (cadr ee) :key))
+                   (eok (and (stringp ek) (string-match "name" ek))))
+              (setq txt (cond
+                         ((org-at-heading-p) nil)
+                         ((and (eq et 'keyword) eok) ev)
+                         ((org-region-active-p)
+                          (buffer-substring (region-beginning) (region-end)))))
+              (when (or (null txt) (string-match "\\S-" txt))
+                (setq cpltxt
+                      (concat cpltxt "::"
+                              (condition-case nil
+                                  (org-make-org-heading-search-string txt)
+                                (error "")))
+                      desc (or (and (eq et 'keyword) eok ev)
+                               (nth 4 (ignore-errors (org-heading-components)))
+                               "NONE")))))
+          (if (string-match "::\\'" cpltxt)
+              (setq cpltxt (substring cpltxt 0 -2)))
+          (setq link cpltxt))))
+
+       ((buffer-file-name (buffer-base-buffer))
+        ;; Just link to this file here.
         (setq cpltxt (concat "file:"
                              (abbreviate-file-name
                               (buffer-file-name (buffer-base-buffer)))))
-        ;; Add a context search string
+        ;; Add a context string.
         (when (org-xor org-context-in-file-links arg)
-          (setq txt (cond
-                     ((org-at-heading-p) nil)
-                     ((org-region-active-p)
-                      (buffer-substring (region-beginning) (region-end)))))
-          (when (or (null txt) (string-match "\\S-" txt))
+          (setq txt (if (org-region-active-p)
+                        (buffer-substring (region-beginning) (region-end))
+                      (buffer-substring (point-at-bol) (point-at-eol))))
+          ;; Only use search option if there is some text.
+          (when (string-match "\\S-" txt)
             (setq cpltxt
-                  (concat cpltxt "::"
-                          (condition-case nil
-                              (org-make-org-heading-search-string txt)
-                            (error "")))
-                  desc (or (nth 4 (ignore-errors
-                                    (org-heading-components))) "NONE"))))
-        (if (string-match "::\\'" cpltxt)
-            (setq cpltxt (substring cpltxt 0 -2)))
-        (setq link cpltxt))))
-
-      ((buffer-file-name (buffer-base-buffer))
-       ;; Just link to this file here.
-       (setq cpltxt (concat "file:"
-                           (abbreviate-file-name
-                            (buffer-file-name (buffer-base-buffer)))))
-       ;; Add a context string
-       (when (org-xor org-context-in-file-links arg)
-        (setq txt (if (org-region-active-p)
-                      (buffer-substring (region-beginning) (region-end))
-                    (buffer-substring (point-at-bol) (point-at-eol))))
-        ;; Only use search option if there is some text.
-        (when (string-match "\\S-" txt)
-          (setq cpltxt
-                (concat cpltxt "::" (org-make-org-heading-search-string txt))
-                desc "NONE")))
-       (setq link cpltxt))
-
-      ((org-called-interactively-p 'interactive)
-       (error "Cannot link to a buffer which is not visiting a file"))
-
-      (t (setq link nil)))
-
-     (if (consp link) (setq cpltxt (car link) link (cdr link)))
-     (setq link (or link cpltxt)
-          desc (or desc cpltxt))
-     (if (equal desc "NONE") (setq desc nil))
-
-     (if (and (or (org-called-interactively-p 'any) executing-kbd-macro) link)
-        (progn
-          (setq org-stored-links
-                (cons (list link desc) org-stored-links))
-          (message "Stored: %s" (or desc link))
-          (when custom-id
-            (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
-                               "::#" custom-id))
-            (setq org-stored-links
-                  (cons (list link desc) org-stored-links))))
-       (or agenda-link (and link (org-make-link-string link desc)))))))
+                  (concat cpltxt "::" (org-make-org-heading-search-string txt))
+                  desc "NONE")))
+        (setq link cpltxt))
+
+       ((org-called-interactively-p 'interactive)
+        (user-error "No method for storing a link from this buffer"))
+
+       (t (setq link nil)))
+
+       ;; We're done setting link and desc, clean up
+       (if (consp link) (setq cpltxt (car link) link (cdr link)))
+       (setq link (or link cpltxt)
+            desc (or desc cpltxt))
+       (cond ((equal desc "NONE") (setq desc nil))
+            ((string-match org-bracket-link-analytic-regexp desc)
+             (let ((d0 (match-string 3 desc))
+                   (p0 (match-string 5 desc)))
+               (setq desc
+                     (replace-regexp-in-string
+                      org-bracket-link-regexp
+                      (concat (or p0 d0)
+                              (if (equal (length (match-string 0 desc))
+                                         (length desc)) "*" "")) desc)))))
+
+       ;; Return the link
+       (if (not (and (or (org-called-interactively-p 'any)
+                        executing-kbd-macro) link))
+          (or agenda-link (and link (org-make-link-string link desc)))
+        (push (list link desc) org-stored-links)
+        (message "Stored: %s" (or desc link))
+        (when custom-id
+          (setq link (concat "file:" (abbreviate-file-name
+                                      (buffer-file-name)) "::#" custom-id))
+          (push (list link desc) org-stored-links)))))))
 
 (defun org-store-link-props (&rest plist)
   "Store link properties, extract names and addresses."
@@ -9015,24 +9689,16 @@ according to FMT (default from `org-email-link-description-format')."
        (setq fmt (replace-match "from %f" t t fmt))))
     (org-replace-escapes fmt table)))
 
-(defun org-make-org-heading-search-string (&optional string heading)
-  "Make search string for STRING or current headline."
-  (interactive)
-  (let ((s (or string (org-get-heading)))
+(defun org-make-org-heading-search-string (&optional string)
+  "Make search string for the current headline or STRING."
+  (let ((s (or string
+              (and (derived-mode-p 'org-mode)
+                   (save-excursion
+                     (org-back-to-heading t)
+                     (org-element-property :raw-value (org-element-at-point))))))
        (lines org-context-in-file-links))
-    (unless (and string (not heading))
-      ;; We are using a headline, clean up garbage in there.
-      (if (string-match org-todo-regexp s)
-         (setq s (replace-match "" t t s)))
-      (if (string-match (org-re ":[[:alnum:]_@#%:]+:[ \t]*$") s)
-         (setq s (replace-match "" t t s)))
-      (setq s (org-trim s))
-      (if (string-match (concat "^\\(" org-quote-string "\\|"
-                               org-comment-string "\\)") s)
-         (setq s (replace-match "" t t s)))
-      (while (string-match org-ts-regexp s)
-       (setq s (replace-match "" t t s))))
     (or string (setq s (concat "*" s)))  ; Add * for headlines
+    (setq s (replace-regexp-in-string "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" s))
     (when (and string (integerp lines) (> lines 0))
       (let ((slines (org-split-string s "\n")))
        (when (< lines (length slines))
@@ -9079,7 +9745,7 @@ according to FMT (default from `org-email-link-description-format')."
 This is the list that is used for internal purposes.")
 
 (defconst org-link-escape-chars-browser
-  '(?\ )
+  '(?\  ?\")
   "List of escapes for characters that are problematic in links.
 This is the list that is used before handing over to the browser.")
 
@@ -9202,7 +9868,7 @@ This command can be called in any mode to insert a link in Org-mode syntax."
   (let ((links (copy-sequence org-stored-links)) l)
     (while (setq l (if keep (pop links) (pop org-stored-links)))
       (insert "- ")
-      (org-insert-link nil (car l) (cadr l))
+      (org-insert-link nil (car l) (or (cadr l) "<no description>"))
       (insert "\n"))))
 
 (defun org-link-fontify-links-to-this-file ()
@@ -9270,6 +9936,7 @@ If the DEFAULT-DESCRIPTION parameter is non-nil, this value will
 be used as the default description."
   (interactive "P")
   (let* ((wcf (current-window-configuration))
+        (origbuf (current-buffer))
         (region (if (org-region-active-p)
                     (buffer-substring (region-beginning) (region-end))))
         (remove (and region (list (region-beginning) (region-end))))
@@ -9324,20 +9991,17 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
       (unwind-protect
          (progn
            (setq link
-                 (let ((org-completion-use-ido nil)
-                       (org-completion-use-iswitchb nil))
-                   (org-completing-read
-                    "Link: "
-                    (append
-                     (mapcar (lambda (x) (list (concat x ":")))
-                             all-prefixes)
-                     (mapcar 'car org-stored-links)
-                     (mapcar 'cadr org-stored-links))
-                    nil nil nil
-                    'tmphist
-                    (caar org-stored-links))))
+                 (org-completing-read
+                  "Link: "
+                  (append
+                   (mapcar (lambda (x) (concat x ":"))
+                           all-prefixes)
+                   (mapcar 'car org-stored-links))
+                  nil nil nil
+                  'tmphist
+                  (caar org-stored-links)))
            (if (not (string-match "\\S-" link))
-               (error "No link selected"))
+               (user-error "No link selected"))
            (mapc (lambda(l)
                    (when (equal link (cadr l)) (setq link (car l) auto-desc t)))
                  org-stored-links)
@@ -9345,7 +10009,8 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
                    (and (equal ":" (substring link -1))
                         (member (substring link 0 -1) all-prefixes)
                         (setq link (substring link 0 -1))))
-               (setq link (org-link-try-special-completion link))))
+               (setq link (with-current-buffer origbuf
+                            (org-link-try-special-completion link)))))
        (set-window-configuration wcf)
        (kill-buffer "*Org Links*"))
       (setq entry (assoc link org-stored-links))
@@ -9357,7 +10022,8 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
        (setq org-stored-links (delq (assoc link org-stored-links)
                                     org-stored-links)))
 
-    (if (string-match org-plain-link-re link)
+    (if (and (string-match org-plain-link-re link)
+            (not (string-match org-ts-regexp link)))
        ;; URL-like link, normalize the use of angular brackets.
        (setq link (org-remove-angle-brackets link)))
 
@@ -9429,7 +10095,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 (defun org-file-complete-link (&optional arg)
   "Create a file link using completion."
   (let (file link)
-    (setq file (read-file-name "File: "))
+    (setq file (org-iread-file-name "File: "))
     (let ((pwd (file-name-as-directory (expand-file-name ".")))
          (pwd1 (file-name-as-directory (abbreviate-file-name
                                         (expand-file-name ".")))))
@@ -9447,6 +10113,19 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
        (t (setq link (concat "file:" file)))))
     link))
 
+(defun org-iread-file-name (&rest args)
+  "Read-file-name using `ido-mode' speedup if available.
+ARGS are arguments that may be passed to `ido-read-file-name' or `read-file-name'.
+See `read-file-name' for a description of parameters."
+  (org-without-partial-completion
+   (if (and org-completion-use-ido
+            (fboundp 'ido-read-file-name)
+            (boundp 'ido-mode) ido-mode
+            (listp (second args)))
+       (let ((ido-enter-matching-directory nil))
+         (apply 'ido-read-file-name args))
+     (apply 'read-file-name args))))
+
 (defun org-completing-read (&rest args)
   "Completing-read with SPACE being a normal character."
   (let ((enable-recursive-minibuffers t)
@@ -9507,23 +10186,6 @@ from."
       (org-add-props s nil 'org-attr attr))
     s))
 
-(defun org-extract-attributes-from-string (tag)
-  (let (key value attr)
-    (while (string-match "\\([a-zA-Z]+\\)=\"\\([^\"]*\\)\"\\s-?" tag)
-      (setq key (match-string 1 tag) value (match-string 2 tag)
-           tag (replace-match "" t t tag)
-           attr (plist-put attr (intern key) value)))
-    (cons tag attr)))
-
-(defun org-attributes-to-string (plist)
-  "Format a property list into an HTML attribute list."
-  (let ((s "") key value)
-    (while plist
-      (setq key (pop plist) value (pop plist))
-      (and value
-          (setq s (concat s " " (symbol-name key) "=\"" value "\""))))
-    s))
-
 ;;; Opening/following a link
 
 (defvar org-link-search-failed nil)
@@ -9545,45 +10207,35 @@ If it decides that it is not responsible for this link, it must return
 nil to indicate that that Org-mode can continue with other options
 like exact and fuzzy text search.")
 
-(defun org-next-link ()
+(defun org-next-link (&optional search-backward)
   "Move forward to the next link.
 If the link is in hidden text, expose it."
-  (interactive)
+  (interactive "P")
   (when (and org-link-search-failed (eq this-command last-command))
     (goto-char (point-min))
     (message "Link search wrapped back to beginning of buffer"))
   (setq org-link-search-failed nil)
   (let* ((pos (point))
         (ct (org-context))
-        (a (assoc :link ct)))
-    (if a (goto-char (nth 2 a)))
-    (if (re-search-forward org-any-link-re nil t)
+        (a (assoc :link ct))
+        (srch-fun (if search-backward 're-search-backward 're-search-forward)))
+    (cond (a (goto-char (nth (if search-backward 1 2) a)))
+         ((looking-at org-any-link-re)
+          ;; Don't stay stuck at link without an org-link face
+          (forward-char (if search-backward -1 1))))
+    (if (funcall srch-fun org-any-link-re nil t)
        (progn
          (goto-char (match-beginning 0))
          (if (outline-invisible-p) (org-show-context)))
       (goto-char pos)
       (setq org-link-search-failed t)
-      (error "No further link found"))))
+      (message "No further link found"))))
 
 (defun org-previous-link ()
   "Move backward to the previous link.
 If the link is in hidden text, expose it."
   (interactive)
-  (when (and org-link-search-failed (eq this-command last-command))
-    (goto-char (point-max))
-    (message "Link search wrapped back to end of buffer"))
-  (setq org-link-search-failed nil)
-  (let* ((pos (point))
-        (ct (org-context))
-        (a (assoc :link ct)))
-    (if a (goto-char (nth 1 a)))
-    (if (re-search-backward org-any-link-re nil t)
-       (progn
-         (goto-char (match-beginning 0))
-         (if (outline-invisible-p) (org-show-context)))
-      (goto-char pos)
-      (setq org-link-search-failed t)
-      (error "No further link found"))))
+  (funcall 'org-next-link t))
 
 (defun org-translate-link (s)
   "Translate a link string if a translation function has been defined."
@@ -9614,8 +10266,7 @@ This is still an experimental function, your mileage may vary."
     ;; A typical message link.  Planner has the id after the final slash,
     ;; we separate it with a hash mark
     (setq path (concat (match-string 1 path) "#"
-                      (org-remove-angle-brackets (match-string 2 path)))))
-   )
+                      (org-remove-angle-brackets (match-string 2 path))))))
   (cons type path))
 
 (defun org-find-file-at-mouse (ev)
@@ -9671,6 +10322,7 @@ Functions in this hook must return t if they identify and follow
 a link at point.  If they don't find anything interesting at point,
 they must return nil.")
 
+(defvar org-link-search-inhibit-query nil) ;; dynamically scoped
 (defvar clean-buffer-list-kill-buffer-names) ; Defined in midnight.el
 (defun org-open-at-point (&optional arg reference-buffer)
   "Open link at or after point.
@@ -9743,17 +10395,28 @@ application the system uses for this file type."
                        (or (previous-single-property-change pos 'org-linked-text)
                            (point-min))
                        (or (next-single-property-change pos 'org-linked-text)
-                           (point-max))))
+                           (point-max)))
+                 ;; Ensure we will search for a <<<radio>>> link, not
+                 ;; a simple reference like <<ref>>
+                 path (concat "<" path))
            (throw 'match t))
 
          (save-excursion
-           (let ((plinkpos (org-in-regexp org-plain-link-re)))
-             (when (or (org-in-regexp org-angle-link-re)
-                       (and plinkpos (goto-char (car plinkpos))
-                            (save-match-data (not (looking-back "\\[\\[")))))
-               (setq type (match-string 1)
-                     path (org-link-unescape (match-string 2)))
-               (throw 'match t))))
+           (when (or (org-in-regexp org-angle-link-re)
+                     (let ((match (org-in-regexp org-plain-link-re)))
+                       ;; Check a plain link is not within a bracket link
+                       (and match
+                            (save-excursion
+                              (progn
+                                (goto-char (car match))
+                                (not (org-in-regexp org-bracket-link-regexp))))))
+                     (let ((line_ending (save-excursion (end-of-line) (point))))
+                       ;; We are in a line before a plain or bracket link
+                       (or (re-search-forward org-plain-link-re line_ending t)
+                           (re-search-forward org-bracket-link-regexp line_ending t))))
+             (setq type (match-string 1)
+                   path (org-link-unescape (match-string 2)))
+               (throw 'match t)))
          (save-excursion
            (when (org-in-regexp (org-re "\\(:[[:alnum:]_@#%:]+\\):[ \t]*$"))
              (setq type "tags"
@@ -9814,16 +10477,24 @@ application the system uses for this file type."
              (apply cmd (nreverse args1))))
 
           ((member type '("http" "https" "ftp" "news"))
-           (browse-url (concat type ":" (if (org-string-match-p "[[:nonascii:] ]" path)
-                                            (org-link-escape
-                                             path org-link-escape-chars-browser)
-                                          path))))
+           (browse-url
+            (concat type ":"
+                    (if (org-string-match-p
+                         (concat "[[:nonascii:]"
+                                 org-link-escape-chars-browser "]")
+                         path)
+                        (org-link-escape path org-link-escape-chars-browser)
+                      path))))
 
           ((string= type "doi")
-           (browse-url (concat org-doi-server-url (if (org-string-match-p "[[:nonascii:] ]" path)
-                                                      (org-link-escape
-                                                       path org-link-escape-chars-browser)
-                                                    path))))
+           (browse-url
+            (concat org-doi-server-url
+                    (if (org-string-match-p
+                         (concat "[[:nonascii:]"
+                                 org-link-escape-chars-browser "]")
+                         path)
+                        (org-link-escape path org-link-escape-chars-browser)
+                      path))))
 
           ((member type '("message"))
            (browse-url (concat type ":" path)))
@@ -9879,8 +10550,15 @@ application the system uses for this file type."
                (error "Abort"))))
 
           ((and (string= type "thisfile")
-                (run-hook-with-args-until-success
-                 'org-open-link-functions path)))
+                (or (run-hook-with-args-until-success
+                     'org-open-link-functions path)
+                    (and link
+                         (string-match "^id:" link)
+                         (or (featurep 'org-id) (require 'org-id))
+                         (progn
+                           (funcall (nth 1 (assoc "id" org-link-protocols))
+                                    (substring path 3))
+                           t)))))
 
           ((string= type "thisfile")
            (if arg
@@ -9958,7 +10636,7 @@ there is one, return it."
              (setq nth (- c ?0))
              (if have-zero (setq nth (1+ nth)))
              (unless (and (integerp nth) (>= (length links) nth))
-               (error "Invalid link selection"))
+               (user-error "Invalid link selection"))
              (setq link (nth (1- nth) links)))))
          (cons link end))))))
 
@@ -9972,15 +10650,7 @@ there is one, return it."
 (defun org-open-file-with-emacs (path)
   "Open file at PATH in Emacs."
   (org-open-file path 'emacs))
-(defun org-remove-file-link-modifiers ()
-  "Remove the file link modifiers in `file+sys:' and `file+emacs:' links."
-  (goto-char (point-min))
-  (while (re-search-forward "\\<file\\+\\(sys\\|emacs\\):" nil t)
-    (org-if-unprotected
-     (replace-match "file:" t t))))
-(eval-after-load "org-exp"
-  '(add-hook 'org-export-preprocess-before-normalizing-links-hook
-            'org-remove-file-link-modifiers))
+
 
 ;;; File search
 
@@ -10019,16 +10689,15 @@ does handle the search, it must return a non-nil value to keep
 other functions from trying.
 
 Each function can access the current prefix argument through the
-variable `current-prefix-argument'.  Note that a single prefix is
-used to force opening a link in Emacs, so it may be good to only
-use a numeric or double prefix to guide the search function.
+variable `current-prefix-arg'.  Note that a single prefix is used
+to force opening a link in Emacs, so it may be good to only use a
+numeric or double prefix to guide the search function.
 
 In case this is needed, a function in this hook can also restore
 the window configuration before `org-open-at-point' was called using:
 
     (set-window-configuration org-window-config-before-follow-link)")
 
-(defvar org-link-search-inhibit-query nil) ;; dynamically scoped
 (defun org-link-search (s &optional type avoid-pos stealth)
   "Search for a link search option.
 If S is surrounded by forward slashes, it is interpreted as a
@@ -10060,7 +10729,8 @@ visibility around point, thus ignoring
             (goto-char (point-min))
             (and
              (re-search-forward
-              (concat "^[ \t]*:CUSTOM_ID:[ \t]+" (regexp-quote (substring s0 1)) "[ \t]*$") nil t)
+              (concat "^[ \t]*:CUSTOM_ID:[ \t]+"
+                      (regexp-quote (substring s0 1)) "[ \t]*$") nil t)
              (setq type 'dedicated
                    pos (match-beginning 0))))
           ;; There is an exact target for this
@@ -10075,14 +10745,6 @@ visibility around point, thus ignoring
               pos (match-beginning 0))))
       ;; There is an exact target for this
       (goto-char pos))
-     ((save-excursion
-       (goto-char (point-min))
-       (and
-        (re-search-forward
-         (format "^[ \t]*#\\+TARGET: %s" (regexp-quote s0)) nil t)
-        (setq type 'dedicated pos (match-beginning 0))))
-      ;; Found an invisible target.
-      (goto-char pos))
      ((save-excursion
        (goto-char (point-min))
        (and
@@ -10109,8 +10771,6 @@ visibility around point, thus ignoring
       (cond
        ((derived-mode-p 'org-mode)
        (org-occur (match-string 1 s)))
-       ;;((eq major-mode 'dired-mode)
-       ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *")))
        (t (org-do-occur (match-string 1 s)))))
      ((and (derived-mode-p 'org-mode) org-link-search-must-match-exact-headline)
       (and (equal (string-to-char s) ?*) (setq s (substring s 1)))
@@ -10149,9 +10809,11 @@ visibility around point, thus ignoring
            re0 (concat "\\(<<" (regexp-quote s0) ">>\\)")
            re2 (concat markers "\\(" (mapconcat 'downcase words "[ \t]+")
                        "\\)" markers)
-           re2a_ (concat "\\(" (mapconcat 'downcase words "[ \t\r\n]+") "\\)[ \t\r\n]")
+           re2a_ (concat "\\(" (mapconcat 'downcase words
+                                          "[ \t\r\n]+") "\\)[ \t\r\n]")
            re2a (concat "[ \t\r\n]" re2a_)
-           re4_ (concat "\\(" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]")
+           re4_ (concat "\\(" (mapconcat 'downcase words
+                                         "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]")
            re4 (concat "[^a-zA-Z_]" re4_)
 
            re1 (concat pre re2 post)
@@ -10162,21 +10824,20 @@ visibility around point, thus ignoring
            re4 (concat pre (if pre re4_ re4))
            reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2
                          "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\("
-                         re5 "\\)"
-                         ))
+                         re5 "\\)"))
       (cond
        ((eq type 'org-occur) (org-occur reall))
        ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup))
        (t (goto-char (point-min))
          (setq type 'fuzzy)
-         (if (or (and (org-search-not-self 1 re0 nil t) (setq type 'dedicated))
+         (if (or (and (org-search-not-self 1 re0 nil t)
+                      (setq type 'dedicated))
                  (org-search-not-self 1 re1 nil t)
                  (org-search-not-self 1 re2 nil t)
                  (org-search-not-self 1 re2a nil t)
                  (org-search-not-self 1 re3 nil t)
                  (org-search-not-self 1 re4 nil t)
-                 (org-search-not-self 1 re5 nil t)
-                 )
+                 (org-search-not-self 1 re5 nil t))
              (goto-char (match-beginning 1))
            (goto-char pos)
            (error "No match"))))))
@@ -10416,7 +11077,7 @@ If the file does not exist, an error is thrown."
     (if (and (not (eq cmd 'emacs)) ; Emacs has no problems with non-ex files
             (not (file-exists-p file))
             (not org-open-non-existing-files))
-       (error "No such file: %s" file))
+       (user-error "No such file: %s" file))
     (cond
      ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
       ;; Remove quotes around the file name - we'll use shell-quote-argument.
@@ -10442,9 +11103,9 @@ If the file does not exist, an error is thrown."
            (setq match-index (+ match-index 1)))))
 
       (save-window-excursion
+       (message "Running %s...done" cmd)
        (start-process-shell-command cmd nil cmd)
-       (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
-       ))
+       (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
      ((or (stringp cmd)
          (eq cmd 'emacs))
       (funcall (cdr (assq 'file org-link-frame-setup)) file)
@@ -10581,9 +11242,10 @@ on the system \"/user@host:\"."
   (let (marker)
     (catch 'exit
       (while (and set (setq marker (nth 3 (pop set))))
-       ;; if org-refile-use-outline-path is 'file, marker may be nil
+       ;; If `org-refile-use-outline-path' is 'file, marker may be nil
        (when (and marker (null (marker-buffer marker)))
-         (message "not found") (sit-for 3)
+         (message "Please regenerate the refile cache with `C-0 C-c C-w'")
+         (sit-for 3)
          (throw 'exit nil)))
       t)))
 
@@ -10701,8 +11363,7 @@ on the system \"/user@host:\"."
                       (goto-char (point-at-eol))))))))
            (when org-refile-use-cache
              (org-refile-cache-put tgs (buffer-file-name) descre))
-           (setq targets (append tgs targets))
-           ))))
+           (setq targets (append tgs targets))))))
     (message "Getting targets...done")
     (nreverse targets)))
 
@@ -10734,14 +11395,21 @@ avoiding backtracing.  Refile target collection makes use of that."
          (widen)
          (while (org-up-heading-safe)
            (when (looking-at org-complex-heading-regexp)
-             (push (org-match-string-no-properties 4) rtn)))
+             (push (org-trim
+                    (replace-regexp-in-string
+                     ;; Remove statistical/checkboxes cookies
+                     "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
+                     (org-match-string-no-properties 4)))
+                   rtn)))
          rtn)))))
 
-(defun org-format-outline-path (path &optional width prefix)
+(defun org-format-outline-path (path &optional width prefix separator)
   "Format the outline path PATH for display.
-Width is the maximum number of characters that is available.
-Prefix is a prefix to be included in the returned string,
-such as the file name."
+WIDTH is the maximum number of characters that is available.
+PREFIX is a prefix to be included in the returned string,
+such as the file name.
+SEPARATOR is inserted between the different parts of the path,
+the default is \"/\"."
   (setq width (or width 79))
   (if prefix (setq width (- width (length prefix))))
   (if (not path)
@@ -10757,6 +11425,7 @@ such as the file name."
           (total (1+ (length prefix))))
       (setq maxwidth (max maxwidth 10))
       (concat prefix
+             (if prefix (or separator "/"))
              (mapconcat
               (lambda (h)
                 (setq n (1+ n))
@@ -10773,24 +11442,35 @@ such as the file name."
                                (nth (% (1- n) org-n-level-faces)
                                     org-level-faces))
                 h)
-              path "/")))))
+              path (or separator "/"))))))
+
+(defun org-display-outline-path (&optional file current separator just-return-string)
+  "Display the current outline path in the echo area.
 
-(defun org-display-outline-path (&optional file current)
-  "Display the current outline path in the echo area."
+If FILE is non-nil, prepend the output with the file name.
+If CURRENT is non-nil, append the current heading to the output.
+SEPARATOR is passed through to `org-format-outline-path'.  It separates
+the different parts of the path and defaults to \"/\".
+If JUST-RETURN-STRING is non-nil, return a string, don't display a message."
   (interactive "P")
-  (let* ((bfn (buffer-file-name (buffer-base-buffer)))
-        (case-fold-search nil)
-        (path (and (derived-mode-p 'org-mode) (org-get-outline-path))))
+  (let* (case-fold-search
+        (bfn (buffer-file-name (buffer-base-buffer)))
+        (path (and (derived-mode-p 'org-mode) (org-get-outline-path)))
+        res)
     (if current (setq path (append path
                                   (save-excursion
                                     (org-back-to-heading t)
                                     (if (looking-at org-complex-heading-regexp)
                                         (list (match-string 4)))))))
-    (message "%s"
-            (org-format-outline-path
-             path
-             (1- (frame-width))
-             (and file bfn (concat (file-name-nondirectory bfn) "/"))))))
+    (setq res
+         (org-format-outline-path
+          path
+          (1- (frame-width))
+          (and file bfn (concat (file-name-nondirectory bfn) separator))
+          separator))
+    (if just-return-string
+       (org-no-properties res)
+      (org-unlogged-message "%s" res))))
 
 (defvar org-refile-history nil
   "History for refiling operations.")
@@ -10801,7 +11481,16 @@ Note that this is still *before* the stuff will be removed from
 the *old* location.")
 
 (defvar org-capture-last-stored-marker)
-(defun org-refile (&optional goto default-buffer rfloc)
+(defvar org-refile-keep nil
+  "Non-nil means `org-refile' will copy instead of refile.")
+
+(defun org-copy ()
+  "Like `org-refile', but copy."
+  (interactive)
+  (let ((org-refile-keep t))
+    (funcall 'org-refile nil nil nil "Copy")))
+
+(defun org-refile (&optional goto default-buffer rfloc msg)
   "Move the entry or entries at point to another heading.
 The list of target headings is compiled using the information in
 `org-refile-targets', which see.
@@ -10820,10 +11509,19 @@ and not actually move anything.
 
 With a double prefix arg \\[universal-argument] \\[universal-argument], \
 go to the location where the last refiling operation has put the subtree.
-With a prefix argument of `2', refile to the running clock.
+
+With a numeric prefix argument of `2', refile to the running clock.
+
+With a numeric prefix argument of `3', emulate `org-refile-keep'
+being set to `t' and copy to the target location, don't move it.
+Beware that keeping refiled entries may result in duplicated ID
+properties.
 
 RFLOC can be a refile location obtained in a different way.
 
+MSG is a string to replace \"Refile\" in the default prompt with
+another verb.  E.g. `org-copy' sets this parameter to \"Copy\".
+
 See also `org-refile-use-outline-path' and `org-completion-use-ido'.
 
 If you are using target caching (see `org-refile-use-cache'),
@@ -10834,12 +11532,13 @@ prefix argument (`C-u C-u C-u C-c C-w')."
   (interactive "P")
   (if (member goto '(0 (64)))
       (org-refile-cache-clear)
-    (let* ((cbuf (current-buffer))
+    (let* ((actionmsg (or msg "Refile"))
+          (cbuf (current-buffer))
           (regionp (org-region-active-p))
           (region-start (and regionp (region-beginning)))
           (region-end (and regionp (region-end)))
-          (region-length (and regionp (- region-end region-start)))
           (filename (buffer-file-name (buffer-base-buffer cbuf)))
+          (org-refile-keep (if (equal goto 3) t org-refile-keep))
           pos it nbuf file re level reversed)
       (setq last-command nil)
       (when regionp
@@ -10849,8 +11548,10 @@ prefix argument (`C-u C-u C-u C-c C-w')."
        (unless (or (org-kill-is-subtree-p
                     (buffer-substring region-start region-end))
                    (prog1 org-refile-active-region-within-subtree
-                     (org-toggle-heading)))
-         (error "The region is not a (sequence of) subtree(s)")))
+                     (let ((s (point-at-eol)))
+                       (org-toggle-heading)
+                       (setq region-end (+ (- (point-at-eol) s) region-end)))))
+         (user-error "The region is not a (sequence of) subtree(s)")))
       (if (equal goto '(16))
          (org-refile-goto-last-stored)
        (when (or
@@ -10870,10 +11571,11 @@ prefix argument (`C-u C-u C-u C-c C-w')."
                                  (org-back-to-heading t)
                                  (setq heading-text
                                        (nth 4 (org-heading-components))))
+
                                (org-refile-get-location
                                 (cond (goto "Goto")
-                                      (regionp "Refile region to")
-                                      (t (concat "Refile subtree \""
+                                      (regionp (concat actionmsg " region to"))
+                                      (t (concat actionmsg " subtree \""
                                                  heading-text "\" to")))
                                 default-buffer
                                 (and (not (equal '(4) goto))
@@ -10895,7 +11597,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 
          (setq nbuf (or (find-buffer-visiting file)
                         (find-file-noselect file)))
-         (if goto
+         (if (and goto (not (equal goto 3)))
              (progn
                (org-pop-to-buffer-same-window nbuf)
                (goto-char pos)
@@ -10930,30 +11632,38 @@ prefix argument (`C-u C-u C-u C-c C-w')."
                  (if (not (bolp)) (newline))
                  (org-paste-subtree level)
                  (when org-log-refile
-                   (org-add-log-setup 'refile nil nil 'findpos
-                                      org-log-refile)
+                   (org-add-log-setup 'refile nil nil 'findpos org-log-refile)
                    (unless (eq org-log-refile 'note)
                      (save-excursion (org-add-log-note))))
                  (and org-auto-align-tags
                       (let ((org-loop-over-headlines-in-active-region nil))
                         (org-set-tags nil t)))
-                 (with-demoted-errors
-                   (bookmark-set "org-refile-last-stored"))
+                 (let ((bookmark-name (plist-get org-bookmark-names-plist
+                                                 :last-refile)))
+                   (when bookmark-name
+                     (with-demoted-errors
+                       (bookmark-set bookmark-name))))
                  ;; If we are refiling for capture, make sure that the
                  ;; last-capture pointers point here
                  (when (org-bound-and-true-p org-refile-for-capture)
-                   (with-demoted-errors
-                     (bookmark-set "org-capture-last-stored-marker"))
+                   (let ((bookmark-name (plist-get org-bookmark-names-plist
+                                                   :last-capture-marker)))
+                     (when bookmark-name
+                       (with-demoted-errors
+                         (bookmark-set bookmark-name))))
                    (move-marker org-capture-last-stored-marker (point)))
                  (if (fboundp 'deactivate-mark) (deactivate-mark))
                  (run-hooks 'org-after-refile-insert-hook))))
-           (if regionp
-               (delete-region (point) (+ (point) region-length))
-             (org-cut-subtree))
+           (unless org-refile-keep
+             (if regionp
+                 (delete-region (point) (+ (point) (- region-end region-start)))
+               (delete-region
+                (and (org-back-to-heading t) (point))
+                (min (buffer-size) (org-end-of-subtree t t) (point)))))
            (when (featurep 'org-inlinetask)
              (org-inlinetask-remove-END-maybe))
            (setq org-markers-to-move nil)
-           (message "Refiled to \"%s\" in file %s" (car it) file)))))))
+           (message (concat actionmsg " to \"%s\" in file %s: done") (car it) file)))))))
 
 (defun org-refile-goto-last-stored ()
   "Go to the location where the last refile was stored."
@@ -10982,12 +11692,8 @@ this is used for the GOTO interface."
     (setq org-refile-target-table
          (org-refile-get-targets default-buffer excluded-entries)))
   (unless org-refile-target-table
-    (error "No refile targets"))
-  (let* ((prompt (concat prompt
-                        (and (car org-refile-history)
-                             (concat " (default " (car org-refile-history) ")"))
-                        ": "))
-        (cbuf (current-buffer))
+    (user-error "No refile targets"))
+  (let* ((cbuf (current-buffer))
         (partial-completion-mode nil)
         (cfn (buffer-file-name (buffer-base-buffer cbuf)))
         (cfunc (if (and org-refile-use-outline-path
@@ -10995,6 +11701,7 @@ this is used for the GOTO interface."
                    'org-olpath-completing-read
                  'org-icompleting-read))
         (extra (if org-refile-use-outline-path "/" ""))
+        (cbnex (concat (buffer-name) extra))
         (filename (and cfn (expand-file-name cfn)))
         (tbl (mapcar
               (lambda (x)
@@ -11007,10 +11714,16 @@ this is used for the GOTO interface."
                   (cons (concat (car x) extra) (cdr x))))
               org-refile-target-table))
         (completion-ignore-case t)
+        cdef
+        (prompt (concat prompt
+                        (or (and (car org-refile-history)
+                                 (concat " (default " (car org-refile-history) ")"))
+                            (and (assoc cbnex tbl) (setq cdef cbnex)
+                                 (concat " (default " cbnex ")"))) ": "))
         pa answ parent-target child parent old-hist)
     (setq old-hist org-refile-history)
     (setq answ (funcall cfunc prompt tbl nil (not new-nodes)
-                       nil 'org-refile-history (car org-refile-history)))
+                       nil 'org-refile-history (or cdef (car org-refile-history))))
     (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl)))
     (org-refile-check-position pa)
     (if pa
@@ -11037,7 +11750,7 @@ this is used for the GOTO interface."
                                (y-or-n-p (format "Create new node \"%s\"? "
                                                  child)))))
              (org-refile-new-child parent-target child)))
-       (error "Invalid target location")))))
+       (user-error "Invalid target location")))))
 
 (declare-function org-string-nw-p "org-macs" (s))
 (defun org-refile-check-position (refile-pointer)
@@ -11047,7 +11760,7 @@ this is used for the GOTO interface."
         (pos (nth 3 refile-pointer))
         buffer)
     (if (and (not (markerp pos)) (not file))
-       (error "Please save the buffer to a file before refiling")
+       (user-error "Please save the buffer to a file before refiling")
       (when (org-string-nw-p re)
        (setq buffer (if (markerp pos)
                         (marker-buffer pos)
@@ -11060,7 +11773,7 @@ this is used for the GOTO interface."
              (goto-char pos)
              (beginning-of-line 1)
              (unless (org-looking-at-p re)
-               (error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling")))))))))
+               (user-error "Invalid refile position, please clear the cache with `C-0 C-c C-w' before refiling")))))))))
 
 (defun org-refile-new-child (parent-target child)
   "Use refile target PARENT-TARGET to add new CHILD below it."
@@ -11161,7 +11874,7 @@ PLIST must contain a :name entry which is used as name of the block."
 This empties the block, puts the cursor at the insert position and returns
 the property list including an extra property :name with the block name."
   (unless (looking-at org-dblock-start-re)
-    (error "Not at a dynamic block"))
+    (user-error "Not at a dynamic block"))
   (let* ((begdel (1+ (match-end 0)))
         (name (org-no-properties (match-string 1)))
         (params (append (list :name name)
@@ -11260,75 +11973,45 @@ This function can be used in a hook."
 
 ;;;; Completion
 
-(defconst org-additional-option-like-keywords
-  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML:"
-    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook:"
-    "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"
-    "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX:"
-    "BEGIN:" "END:"
-    "ORGTBL" "TBLFM:" "TBLNAME:"
-    "BEGIN_EXAMPLE" "END_EXAMPLE"
-    "BEGIN_VERBATIM" "END_VERBATIM"
-    "BEGIN_QUOTE" "END_QUOTE"
-    "BEGIN_VERSE" "END_VERSE"
-    "BEGIN_CENTER" "END_CENTER"
-    "BEGIN_SRC" "END_SRC"
-    "BEGIN_RESULT" "END_RESULT"
-    "BEGIN_lstlisting" "END_lstlisting"
-    "NAME:" "RESULTS:"
-    "HEADER:" "HEADERS:"
-    "COLUMNS:" "PROPERTY:"
-    "CAPTION:" "LABEL:"
-    "SETUPFILE:"
-    "INCLUDE:" "INDEX:"
-    "BIND:"
-    "MACRO:"))
+(declare-function org-export-backend-name "org-export" (cl-x))
+(declare-function org-export-backend-options "org-export" (cl-x))
+(defun org-get-export-keywords ()
+  "Return a list of all currently understood export keywords.
+Export keywords include options, block names, attributes and
+keywords relative to each registered export back-end."
+  (let (keywords)
+    (dolist (backend
+            (org-bound-and-true-p org-export--registered-backends)
+            (delq nil keywords))
+      ;; Back-end name (for keywords, like #+LATEX:)
+      (push (upcase (symbol-name (org-export-backend-name backend))) keywords)
+      (dolist (option-entry (org-export-backend-options backend))
+       ;; Back-end options.
+       (push (nth 1 option-entry) keywords)))))
 
 (defconst org-options-keywords
-  '("TITLE:" "AUTHOR:" "EMAIL:" "DATE:"
-    "DESCRIPTION:" "KEYWORDS:" "LANGUAGE:" "OPTIONS:"
-    "EXPORT_SELECT_TAGS:" "EXPORT_EXCLUDE_TAGS:"
-    "LINK_UP:" "LINK_HOME:" "LINK:" "TODO:"
-    "XSLT:" "MATHJAX:" "CATEGORY:" "SEQ_TODO:" "TYP_TODO:"
-    "PRIORITIES:" "DRAWERS:" "STARTUP:" "TAGS:" "STYLE:"
-    "FILETAGS:" "ARCHIVE:" "INFOJS_OPT:"))
-
-(defconst org-additional-option-like-keywords-for-flyspell
-  (delete-dups
-   (split-string
-    (mapconcat (lambda(k)
-                (replace-regexp-in-string
-                 "_\\|:" " "
-                 (concat k " " (downcase k) " " (upcase k))))
-              (append org-options-keywords org-additional-option-like-keywords)
-              " ")
-    " +" t)))
+  '("ARCHIVE:" "AUTHOR:" "BIND:" "CATEGORY:" "COLUMNS:" "CREATOR:" "DATE:"
+    "DESCRIPTION:" "DRAWERS:" "EMAIL:" "EXCLUDE_TAGS:" "FILETAGS:" "INCLUDE:"
+    "INDEX:" "KEYWORDS:" "LANGUAGE:" "MACRO:" "OPTIONS:" "PROPERTY:"
+    "PRIORITIES:" "SELECT_TAGS:" "SEQ_TODO:" "SETUPFILE:" "STARTUP:" "TAGS:"
+    "TITLE:" "TODO:" "TYP_TODO:" "SELECT_TAGS:" "EXCLUDE_TAGS:"))
 
 (defcustom org-structure-template-alist
-  '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC"
-     "<src lang=\"?\">\n\n</src>")
-    ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE"
-     "<example>\n?\n</example>")
-    ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE"
-     "<quote>\n?\n</quote>")
-    ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE"
-     "<verse>\n?\n</verse>")
-    ("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM"
-     "<verbatim>\n?\n</verbatim>")
-    ("c" "#+BEGIN_CENTER\n?\n#+END_CENTER"
-     "<center>\n?\n</center>")
+  '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")
+    ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE" "<example>\n?\n</example>")
+    ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE" "<quote>\n?\n</quote>")
+    ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE" "<verse>\n?\n</verse>")
+    ("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM" "<verbatim>\n?\n</verbatim>")
+    ("c" "#+BEGIN_CENTER\n?\n#+END_CENTER" "<center>\n?\n</center>")
     ("l" "#+BEGIN_LaTeX\n?\n#+END_LaTeX"
      "<literal style=\"latex\">\n?\n</literal>")
-    ("L" "#+LaTeX: "
-     "<literal style=\"latex\">?</literal>")
+    ("L" "#+LaTeX: " "<literal style=\"latex\">?</literal>")
     ("h" "#+BEGIN_HTML\n?\n#+END_HTML"
      "<literal style=\"html\">\n?\n</literal>")
-    ("H" "#+HTML: "
-     "<literal style=\"html\">?</literal>")
-    ("a" "#+BEGIN_ASCII\n?\n#+END_ASCII")
-    ("A" "#+ASCII: ")
-    ("i" "#+INDEX: ?"
-     "#+INDEX: ?")
+    ("H" "#+HTML: " "<literal style=\"html\">?</literal>")
+    ("a" "#+BEGIN_ASCII\n?\n#+END_ASCII" "")
+    ("A" "#+ASCII: " "")
+    ("i" "#+INDEX: ?" "#+INDEX: ?")
     ("I" "#+INCLUDE: %file ?"
      "<include file=%file markup=\"?\">"))
   "Structure completion elements.
@@ -11343,9 +12026,10 @@ the default when the /org-mtags.el/ module has been loaded.  See also the
 variable `org-mtags-prefer-muse-templates'."
   :group 'org-completion
   :type '(repeat
-         (string :tag "Key")
-         (string :tag "Template")
-         (string :tag "Muse Template")))
+         (list
+          (string :tag "Key")
+          (string :tag "Template")
+          (string :tag "Muse Template"))))
 
 (defun org-try-structure-completion ()
   "Try to complete a structure template before point.
@@ -11429,10 +12113,12 @@ nil or a string to be used for the todo mark." )
   (let* ((ct (org-current-time))
         (dct (decode-time ct))
         (ct1
-         (if (and org-use-effective-time
-                  (< (nth 2 dct) org-extend-today-until))
-             (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
-           ct)))
+         (cond
+          (org-use-last-clock-out-time-as-effective-time
+           (or (org-clock-get-last-clock-out-time) ct))
+          ((and org-use-effective-time (< (nth 2 dct) org-extend-today-until))
+           (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct)))
+          (t ct))))
     ct1))
 
 (defun org-todo-yesterday (&optional arg)
@@ -11445,6 +12131,9 @@ nil or a string to be used for the todo mark." )
           (org-extend-today-until (1+ hour)))
       (org-todo arg))))
 
+(defvar org-block-entry-blocking ""
+  "First entry preventing the TODO state change.")
+
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
 The state of an item is given by a keyword at the start of the heading,
@@ -11536,8 +12225,7 @@ For calling through lisp, arg is also interpreted in the following way:
                                       (not org-todo-key-trigger)))
                              ;; Read a state with completion
                              (org-icompleting-read
-                              "State: " (mapcar (lambda(x) (list x))
-                                                org-todo-keywords-1)
+                              "State: " (mapcar 'list org-todo-keywords-1)
                               nil t))
                             ((eq arg 'right)
                              (if this
@@ -11568,7 +12256,7 @@ For calling through lisp, arg is also interpreted in the following way:
                                      (car org-todo-heads))))
                               ((car (member arg org-todo-keywords-1)))
                               ((stringp arg)
-                               (error "State `%s' not valid in this file" arg))
+                               (user-error "State `%s' not valid in this file" arg))
                               ((nth (1- (prefix-numeric-value arg))
                                     org-todo-keywords-1))))
                             ((null member) (or head (car org-todo-keywords-1)))
@@ -11599,9 +12287,11 @@ For calling through lisp, arg is also interpreted in the following way:
                           (run-hook-with-args-until-failure
                            'org-blocker-hook change-plist))))
                (if (org-called-interactively-p 'interactive)
-                   (error "TODO state change from %s to %s blocked" this org-state)
+                   (user-error "TODO state change from %s to %s blocked (by \"%s\")"
+                               this org-state org-block-entry-blocking)
                  ;; fail silently
-                 (message "TODO state change from %s to %s blocked" this org-state)
+                 (message "TODO state change from %s to %s blocked (by \"%s\")"
+                          this org-state org-block-entry-blocking)
                  (throw 'exit nil))))
            (store-match-data match-data)
            (replace-match next t t)
@@ -11632,9 +12322,10 @@ For calling through lisp, arg is also interpreted in the following way:
                              (nth 2 (assoc this org-todo-log-states))))
              (if (and (eq dolog 'note) (eq org-inhibit-logging 'note))
                  (setq dolog 'time))
-             (when (and org-state
-                        (member org-state org-not-done-keywords)
-                        (not (member this org-not-done-keywords)))
+             (when (or (and (not org-state) (not org-closed-keep-when-no-todo))
+                       (and org-state
+                            (member org-state org-not-done-keywords)
+                            (not (member this org-not-done-keywords))))
                ;; This is now a todo state and was not one before
                ;; If there was a CLOSED time stamp, get rid of it.
                (org-add-planning-info nil nil 'closed))
@@ -11715,7 +12406,8 @@ changes.  Such blocking occurs when:
              ;; completed
              (if (and (not (org-entry-is-done-p))
                       (org-entry-is-todo-p))
-                 (throw 'dont-block nil))
+                 (progn (setq org-block-entry-blocking (org-get-heading))
+                        (throw 'dont-block nil)))
              (outline-next-heading)
              (setq child-level (funcall outline-level))))))
       ;; Otherwise, if the task's parent has the :ORDERED: property, and
@@ -11728,6 +12420,7 @@ changes.  Such blocking occurs when:
          (when (and (org-not-nil (org-entry-get (point) "ORDERED"))
                     (forward-line 1)
                     (re-search-forward org-not-done-heading-regexp pos t))
+           (setq org-block-entry-blocking (match-string 0))
            (throw 'dont-block nil))  ; block, there is an older sibling not done.
          ;; Search further up the hierarchy, to see if an ancestor is blocked
          (while t
@@ -11739,7 +12432,8 @@ changes.  Such blocking occurs when:
            (if (not parent-pos) (throw 'dont-block t)) ; no parent
            (when (and (org-not-nil (org-entry-get (point) "ORDERED"))
                       (forward-line 1)
-                      (re-search-forward org-not-done-heading-regexp pos t))
+                      (re-search-forward org-not-done-heading-regexp pos t)
+                      (setq org-block-entry-blocking (org-get-heading)))
              (throw 'dont-block nil)))))))) ; block, older sibling not done.
 
 (defcustom org-track-ordered-property-with-tag nil
@@ -11772,7 +12466,7 @@ See variable `org-track-ordered-property-with-tag'."
       (org-back-to-heading)
       (if (org-entry-get nil "ORDERED")
          (progn
-           (org-delete-property "ORDERED")
+           (org-delete-property "ORDERED" "PROPERTIES")
            (and tag (org-toggle-tag tag 'off))
            (message "Subtasks can be completed in arbitrary order"))
        (org-entry-put nil "ORDERED" "t")
@@ -11816,16 +12510,15 @@ changes because there are unchecked boxes in this entry."
 
 (defun org-entry-blocked-p ()
   "Is the current entry blocked?"
-  (org-with-buffer-modified-unmodified
+  (org-with-silent-modifications
    (if (org-entry-get nil "NOBLOCKING")
        nil ;; Never block this entry
-     (not
-      (run-hook-with-args-until-failure
-       'org-blocker-hook
-       (list :type 'todo-state-change
-            :position (point)
-            :from 'todo
-            :to 'done))))))
+     (not (run-hook-with-args-until-failure
+          'org-blocker-hook
+          (list :type 'todo-state-change
+                :position (point)
+                :from 'todo
+                :to 'done))))))
 
 (defun org-update-statistics-cookies (all)
   "Update the statistics cookie, either from TODO or from checkboxes.
@@ -12088,6 +12781,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
   (member (org-get-todo-state) org-done-keywords))
 
 (defun org-get-todo-state ()
+  "Return the TODO keyword of the current subtree."
   (save-excursion
     (org-back-to-heading t)
     (and (looking-at org-todo-line-regexp)
@@ -12180,7 +12874,7 @@ This function is run automatically after each state change to a DONE state."
                what (match-string 3 ts))
          (if (equal what "w") (setq n (* n 7) what "d"))
          (if (and (equal what "h") (not (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)))
-             (error "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
+             (user-error "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
          ;; Preparation, see if we need to modify the start date for the change
          (when (match-end 1)
            (setq time (save-match-data (org-time-string-to-time ts)))
@@ -12207,7 +12901,7 @@ This function is run automatically after each state change to a DONE state."
              (org-at-timestamp-p t)
              (setq ts (match-string 1))
              (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts))))
-         (org-timestamp-change n (cdr (assoc what whata)))
+         (save-excursion (org-timestamp-change n (cdr (assoc what whata)) nil t))
          (setq msg (concat msg type " " org-last-changed-timestamp " "))))
       (setq org-log-post-message msg)
       (message "%s" msg))))
@@ -12232,13 +12926,14 @@ of `org-todo-keywords-1'."
               ((<= (prefix-numeric-value arg) (length org-todo-keywords-1))
                (regexp-quote (nth (1- (prefix-numeric-value arg))
                                   org-todo-keywords-1)))
-              (t (error "Invalid prefix argument: %s" arg)))))
+              (t (user-error "Invalid prefix argument: %s" arg)))))
     (message "%d TODO entries found"
             (org-occur (concat "^" org-outline-regexp " *" kwd-re )))))
 
-(defun org-deadline (&optional remove time)
+(defun org-deadline (arg &optional time)
   "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
-With argument REMOVE, remove any deadline from the item.
+With one universal prefix argument, remove any deadline from the item.
+With two universal prefix arguments, prompt for a warning delay.
 With argument TIME, set the deadline at the corresponding date.  TIME
 can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
   (interactive "P")
@@ -12247,22 +12942,43 @@ can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
                    'region-start-level 'region))
            org-loop-over-headlines-in-active-region)
        (org-map-entries
-        `(org-deadline ',remove ,time)
+        `(org-deadline ',arg ,time)
         org-loop-over-headlines-in-active-region
         cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
     (let* ((old-date (org-entry-get nil "DEADLINE"))
+          (old-date-time (if old-date (org-time-string-to-time old-date)))
           (repeater (and old-date
                          (string-match
                           "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
                           old-date)
                          (match-string 1 old-date))))
-      (if remove
-         (progn
-           (when (and old-date org-log-redeadline)
-             (org-add-log-setup 'deldeadline nil old-date 'findpos
-                                org-log-redeadline))
-           (org-remove-timestamp-with-keyword org-deadline-string)
-           (message "Item no longer has a deadline."))
+      (cond
+       ((equal arg '(4))
+       (when (and old-date org-log-redeadline)
+         (org-add-log-setup 'deldeadline nil old-date 'findpos
+                            org-log-redeadline))
+       (org-remove-timestamp-with-keyword org-deadline-string)
+       (message "Item no longer has a deadline."))
+       ((equal arg '(16))
+       (save-excursion
+         (org-back-to-heading t)
+         (if (re-search-forward
+              org-deadline-time-regexp
+              (save-excursion (outline-next-heading) (point)) t)
+             (let* ((rpl0 (match-string 1))
+                    (rpl (replace-regexp-in-string " -[0-9]+[hdwmy]" "" rpl0)))
+               (replace-match
+                (concat org-deadline-string
+                        " <" rpl
+                        (format " -%dd"
+                                (abs
+                                 (- (time-to-days
+                                     (save-match-data
+                                       (org-read-date nil t nil "Warn starting from" old-date-time)))
+                                    (time-to-days old-date-time))))
+                        ">") t t))
+           (user-error "No deadline information to update"))))
+       (t
        (org-add-planning-info 'deadline time 'closed)
        (when (and old-date org-log-redeadline
                   (not (equal old-date
@@ -12282,11 +12998,12 @@ can either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
                    (concat (substring org-last-inserted-timestamp 0 -1)
                            " " repeater
                            (substring org-last-inserted-timestamp -1))))))
-       (message "Deadline on %s" org-last-inserted-timestamp)))))
+       (message "Deadline on %s" org-last-inserted-timestamp))))))
 
-(defun org-schedule (&optional remove time)
+(defun org-schedule (arg &optional time)
   "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
-With argument REMOVE, remove any scheduling date from the item.
+With one universal prefix argument, remove any scheduling date from the item.
+With two universal prefix arguments, prompt for a delay cookie.
 With argument TIME, scheduled at the corresponding date.  TIME can
 either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
   (interactive "P")
@@ -12295,22 +13012,44 @@ either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
                    'region-start-level 'region))
            org-loop-over-headlines-in-active-region)
        (org-map-entries
-        `(org-schedule ',remove ,time)
+        `(org-schedule ',arg ,time)
         org-loop-over-headlines-in-active-region
         cl (if (outline-invisible-p) (org-end-of-subtree nil t))))
     (let* ((old-date (org-entry-get nil "SCHEDULED"))
+          (old-date-time (if old-date (org-time-string-to-time old-date)))
           (repeater (and old-date
                          (string-match
                           "\\([.+-]+[0-9]+[hdwmy]\\(?:[/ ][-+]?[0-9]+[hdwmy]\\)?\\) ?"
                           old-date)
                          (match-string 1 old-date))))
-      (if remove
-         (progn
-           (when (and old-date org-log-reschedule)
-             (org-add-log-setup 'delschedule nil old-date 'findpos
-                                org-log-reschedule))
-           (org-remove-timestamp-with-keyword org-scheduled-string)
-           (message "Item is no longer scheduled."))
+      (cond
+       ((equal arg '(4))
+       (progn
+         (when (and old-date org-log-reschedule)
+           (org-add-log-setup 'delschedule nil old-date 'findpos
+                              org-log-reschedule))
+         (org-remove-timestamp-with-keyword org-scheduled-string)
+         (message "Item is no longer scheduled.")))
+       ((equal arg '(16))
+       (save-excursion
+         (org-back-to-heading t)
+         (if (re-search-forward
+              org-scheduled-time-regexp
+              (save-excursion (outline-next-heading) (point)) t)
+             (let* ((rpl0 (match-string 1))
+                    (rpl (replace-regexp-in-string " -[0-9]+[hdwmy]" "" rpl0)))
+               (replace-match
+                (concat org-scheduled-string
+                        " <" rpl
+                        (format " -%dd"
+                                (abs
+                                 (- (time-to-days
+                                     (save-match-data
+                                       (org-read-date nil t nil "Delay until" old-date-time)))
+                                    (time-to-days old-date-time))))
+                        ">") t t))
+           (user-error "No scheduled information to update"))))
+       (t
        (org-add-planning-info 'scheduled time 'closed)
        (when (and old-date org-log-reschedule
                   (not (equal old-date
@@ -12330,7 +13069,7 @@ either be an Org date like \"2011-07-24\" or a delta like \"+2d\"."
                    (concat (substring org-last-inserted-timestamp 0 -1)
                            " " repeater
                            (substring org-last-inserted-timestamp -1))))))
-       (message "Scheduled to %s" org-last-inserted-timestamp)))))
+       (message "Scheduled to %s" org-last-inserted-timestamp))))))
 
 (defun org-get-scheduled-time (pom &optional inherit)
   "Get the scheduled time as a time tuple, of a format suitable
@@ -12366,6 +13105,9 @@ nil."
              (delete-region (point-at-bol)
                             (min (point-max) (1+ (point-at-eol))))))))))
 
+(defvar org-time-was-given) ; dynamically scoped parameter
+(defvar org-end-time-was-given) ; dynamically scoped parameter
+
 (defun org-add-planning-info (what &optional time &rest remove)
   "Insert new timestamp with keyword in the line directly after the headline.
 WHAT indicates what kind of time stamp to add.  TIME indicates the time to use.
@@ -12578,7 +13320,7 @@ EXTRA is additional text that will be inserted into the notes buffer."
   (org-switch-to-buffer-other-window "*Org Note*")
   (erase-buffer)
   (if (memq org-log-note-how '(time state))
-      (let (current-prefix-arg)        (org-store-log-note))
+      (let (current-prefix-arg) (org-store-log-note))
     (let ((org-inhibit-startup t)) (org-mode))
     (insert (format "# Insert note for %s.
 # Finish with C-c C-c, or cancel with C-c C-k.\n\n"
@@ -12609,10 +13351,10 @@ EXTRA is additional text that will be inserted into the notes buffer."
 (defvar org-note-abort nil) ; dynamically scoped
 (defun org-store-log-note ()
   "Finish taking a log note, and insert it to where it belongs."
-  (let ((txt (buffer-string))
-       (note (cdr (assq org-log-note-purpose org-log-note-headings)))
-       lines ind bul)
+  (let ((txt (buffer-string)))
     (kill-buffer (current-buffer))
+    (let ((note (cdr (assq org-log-note-purpose org-log-note-headings)))
+         lines ind bul)
     (while (string-match "\\`# .*\n[ \t\n]*" txt)
       (setq txt (replace-match "" t t txt)))
     (if (string-match "\\s-+\\'" txt)
@@ -12679,12 +13421,19 @@ EXTRA is additional text that will be inserted into the notes buffer."
              (insert (pop lines))))
          (message "Note stored")
          (org-back-to-heading t)
-         (org-cycle-hide-drawers 'children)))))
-  (set-window-configuration org-log-note-window-configuration)
-  (with-current-buffer (marker-buffer org-log-note-return-to)
-    (goto-char org-log-note-return-to))
-  (move-marker org-log-note-return-to nil)
-  (and org-log-post-message (message "%s" org-log-post-message)))
+         (org-cycle-hide-drawers 'children))
+       ;; Fix `buffer-undo-list' when `org-store-log-note' is called
+       ;; from within `org-add-log-note' because `buffer-undo-list'
+       ;; is then modified outside of `org-with-remote-undo'.
+       (when (eq this-command 'org-agenda-todo)
+         (setcdr buffer-undo-list (cddr buffer-undo-list)))))))
+  ;; Don't add undo information when called from `org-agenda-todo'
+  (let ((buffer-undo-list (eq this-command 'org-agenda-todo)))
+    (set-window-configuration org-log-note-window-configuration)
+    (with-current-buffer (marker-buffer org-log-note-return-to)
+      (goto-char org-log-note-return-to))
+    (move-marker org-log-note-return-to nil)
+    (and org-log-post-message (message "%s" org-log-post-message))))
 
 (defun org-remove-empty-drawer-at (drawer pos)
   "Remove an empty drawer DRAWER at position POS.
@@ -12725,11 +13474,14 @@ D      Show deadlines and scheduled items between a date range."
                   ((eq type 'active) "only active timestamps")
                   ((eq type 'inactive) "only inactive timestamps")
                   ((eq type 'scheduled-or-deadline) "scheduled/deadline")
+                  ((eq type 'closed) "with a closed time-stamp")
                   (t "scheduled/deadline")))
     (setq ans (read-char-exclusive))
     (cond
      ((equal ans ?c)
-      (org-sparse-tree arg (cadr (member type '(scheduled-or-deadline all scheduled deadline active inactive)))))
+      (org-sparse-tree
+       arg (cadr (member type '(scheduled-or-deadline
+                               all scheduled deadline active inactive closed)))))
      ((equal ans ?d)
       (call-interactively 'org-check-deadlines))
      ((equal ans ?b)
@@ -12754,7 +13506,7 @@ D      Show deadlines and scheduled items between a date range."
       (org-match-sparse-tree arg (concat kwd "=" value)))
      ((member ans '(?r ?R ?/))
       (call-interactively 'org-occur))
-     (t (error "No such sparse tree command \"%c\"" ans)))))
+     (t (user-error "No such sparse tree command \"%c\"" ans)))))
 
 (defvar org-occur-highlights nil
   "List of overlays used for occur matches.")
@@ -12783,7 +13535,7 @@ If CALLBACK is non-nil, it is a function which is called to confirm
 that the match should indeed be shown."
   (interactive "sRegexp: \nP")
   (when (equal regexp "")
-    (error "Regexp cannot be empty"))
+    (user-error "Regexp cannot be empty"))
   (unless keep-previous
     (org-remove-occur-highlights nil nil t))
   (push (cons regexp callback) org-occur-parameters)
@@ -12867,7 +13619,7 @@ How much context is shown depends upon the variables
                    (not (bobp)))
          (org-flag-heading nil)
          (when siblings-p (org-show-siblings)))))
-    (org-fix-ellipsis-at-bol)))
+    (unless (eq key 'agenda) (org-fix-ellipsis-at-bol))))
 
 (defvar org-reveal-start-hook nil
   "Hook run before revealing a location.")
@@ -12940,7 +13692,7 @@ ACTION can be `set', `up', `down', or a character."
   (if (equal action '(4))
       (org-show-priority)
   (unless org-enable-priority-commands
-    (error "Priority commands are disabled"))
+    (user-error "Priority commands are disabled"))
   (setq action (or action 'set))
   (let (current new news have remove)
     (save-excursion
@@ -12964,7 +13716,7 @@ ACTION can be `set', `up', `down', or a character."
            (setq new (upcase new)))
        (cond ((equal new ?\ ) (setq remove t))
              ((or (< (upcase new) org-highest-priority) (> (upcase new) org-lowest-priority))
-              (error "Priority must be between `%c' and `%c'"
+              (user-error "Priority must be between `%c' and `%c'"
                      org-highest-priority org-lowest-priority))))
        ((eq action 'up)
        (setq new (if have
@@ -12986,7 +13738,7 @@ ACTION can be `set', `up', `down', or a character."
                      (if org-priority-start-cycle-with-default
                          org-default-priority
                        (1+ org-default-priority))))))
-       (t (error "Invalid action")))
+       (t (user-error "Invalid action")))
       (if (or (< (upcase new) org-highest-priority)
              (> (upcase new) org-lowest-priority))
          (if (and (memq action '(up down))
@@ -13003,7 +13755,7 @@ ACTION can be `set', `up', `down', or a character."
              (replace-match "" t t nil 1)
            (replace-match news t t nil 2))
        (if remove
-           (error "No priority cookie found in line")
+           (user-error "No priority cookie found in line")
          (let ((case-fold-search nil))
            (looking-at org-todo-line-regexp))
          (if (match-end 2)
@@ -13062,7 +13814,7 @@ a file becomes an N^2 operation - but with this variable set, it scales
 as N.")
 
 (defun org-scan-tags (action matcher todo-only &optional start-level)
-  "Scan headline tags with inheritance and produce output ACTION.
+  "Sca headline tags with inheritance and produce output ACTION.
 
 ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
 or `agenda' to produce an entry list for an agenda view.  It can also be
@@ -13098,7 +13850,6 @@ headlines matching this string."
                              (abbreviate-file-name
                               (or (buffer-file-name (buffer-base-buffer))
                                   (buffer-name (buffer-base-buffer)))))))
-        (case-fold-search nil)
         (org-map-continue-from nil)
          lspos tags tags-list
         (tags-alist (list (cons 0 org-file-tags)))
@@ -13111,13 +13862,14 @@ headlines matching this string."
       (when (eq action 'sparse-tree)
        (org-overview)
        (org-remove-occur-highlights))
-      (while (re-search-forward re nil t)
+      (while (let (case-fold-search)
+              (re-search-forward re nil t))
        (setq org-map-continue-from nil)
        (catch :skip
          (setq todo (if (match-end 1) (org-match-string-no-properties 2))
                tags (if (match-end 4) (org-match-string-no-properties 4)))
          (goto-char (setq lspos (match-beginning 0)))
-         (setq level (org-reduced-level (funcall outline-level))
+         (setq level (org-reduced-level (org-outline-level))
                category (org-get-category))
          (setq i llast llast level)
          ;; remove tag lists from same and sublevels
@@ -13182,7 +13934,7 @@ headlines matching this string."
                          (if (eq org-tags-match-list-sublevels 'indented)
                              (make-string (1- level) ?.) "")
                          (org-get-heading))
-                        category
+                        level category
                         tags-list)
                    priority (org-get-priority txt))
              (goto-char lspos)
@@ -13197,7 +13949,7 @@ headlines matching this string."
              (save-excursion
                (setq rtn1 (funcall action))
                (push rtn1 rtn)))
-            (t (error "Invalid action")))
+            (t (user-error "Invalid action")))
 
            ;; if we are to skip sublevels, jump to end of subtree
            (unless org-tags-match-list-sublevels
@@ -13300,11 +14052,14 @@ See also `org-scan-tags'.
 "
   (declare (special todo-only))
   (unless (boundp 'todo-only)
-    (error "org-make-tags-matcher expects todo-only to be scoped in"))
+    (error "`org-make-tags-matcher' expects todo-only to be scoped in"))
   (unless match
-    ;; Get a new match request, with completion
+    ;; Get a new match request, with completion against the global
+    ;; tags table and the local tags in current buffer
     (let ((org-last-tags-completion-table
-          (org-global-tags-completion-table)))
+          (org-uniquify
+           (delq nil (append (org-get-buffer-tags)
+                             (org-global-tags-completion-table))))))
       (setq match (org-completing-read-no-i
                   "Match: " 'org-tags-completion-function nil nil nil
                   'org-tags-history))))
@@ -13315,8 +14070,19 @@ See also `org-scan-tags'.
        minus tag mm
        tagsmatch todomatch tagsmatcher todomatcher kwd matcher
        orterms term orlist re-p str-p level-p level-op time-p
-       prop-p pn pv po gv rest)
-    (if (string-match "/+" match)
+       prop-p pn pv po gv rest (start 0) (ss 0))
+    ;; Expand group tags
+    (setq match (org-tags-expand match))
+
+    ;; Check if there is a TODO part of this match, which would be the
+    ;; part after a "/".  TO make sure that this slash is not part of
+    ;; a property value to be matched against, we also check that there
+    ;; is no " after that slash.
+    ;; First, find the last slash
+    (while (string-match "/+" match ss)
+      (setq start (match-beginning 0) ss (match-end 0)))
+    (if (and (string-match "/+" match start)
+            (not (save-match-data (string-match "\"" match start))))
        ;; match contains also a todo-matching request
        (progn
          (setq tagsmatch (substring match 0 (match-beginning 0))
@@ -13422,6 +14188,62 @@ See also `org-scan-tags'.
                          matcher)))
     (cons match0 matcher)))
 
+(defun org-tags-expand (match &optional single-as-list downcased)
+  "Expand group tags in MATCH.
+
+This replaces every group tag in MATCH with a regexp tag search.
+For example, a group tag \"Work\" defined as { Work : Lab Conf }
+will be replaced like this:
+
+   Work =>  {\\(?:Work\\|Lab\\|Conf\\)}
+  +Work => +{\\(?:Work\\|Lab\\|Conf\\)}
+  -Work => -{\\(?:Work\\|Lab\\|Conf\\)}
+
+Replacing by a regexp preserves the structure of the match.
+E.g., this expansion
+
+  Work|Home => {\\(?:Work\\|Lab\\|Conf\\}|Home
+
+will match anything tagged with \"Lab\" and \"Home\", or tagged
+with \"Conf\" and \"Home\" or tagged with \"Work\" and \"home\".
+
+When the optional argument SINGLE-AS-LIST is non-nil, MATCH is
+assumed to be a single group tag, and the function will return
+the list of tags in this group.
+
+When DOWNCASE is non-nil, expand downcased TAGS."
+  (if org-group-tags
+      (let* ((case-fold-search t)
+            (stable org-mode-syntax-table)
+            (tal (or org-tag-groups-alist-for-agenda
+                     org-tag-groups-alist))
+            (tal (if downcased
+                     (mapcar (lambda(tg) (mapcar 'downcase tg)) tal) tal))
+            (tml (mapcar 'car tal))
+            (rtnmatch match) rpl)
+       ;; @ and _ are allowed as word-components in tags
+       (modify-syntax-entry ?@ "w" stable)
+       (modify-syntax-entry ?_ "w" stable)
+       (while (and tml
+                   (with-syntax-table stable
+                     (string-match
+                      (concat "\\(?1:[+-]?\\)\\(?2:\\<"
+                              (regexp-opt tml) "\\>\\)") rtnmatch)))
+         (let* ((dir (match-string 1 rtnmatch))
+                (tag (match-string 2 rtnmatch))
+                (tag (if downcased (downcase tag) tag)))
+           (setq tml (delete tag tml))
+           (when (not (get-text-property 0 'grouptag (match-string 2 rtnmatch)))
+             (setq rpl (append (org-uniquify rpl) (assoc tag tal)))
+             (setq rpl (concat dir "{\\<" (regexp-opt rpl) "\\>}"))
+             (if (stringp rpl) (org-add-props rpl '(grouptag t)))
+             (setq rtnmatch (replace-match rpl t t rtnmatch)))))
+       (if single-as-list
+           (or (reverse rpl) (list rtnmatch))
+         rtnmatch))
+    (if single-as-list (list (if downcased (downcase match) match))
+      match)))
+
 (defun org-op-to-function (op &optional stringp)
   "Turn an operator into the appropriate function."
   (setq op
@@ -13600,7 +14422,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
          (insert (make-string (- ncol (current-column)) ?\ ))
          (setq ncol (current-column))
          (when indent-tabs-mode (tabify p (point-at-eol)))
-         (org-move-to-column (min ncol col) t))
+         (org-move-to-column (min ncol col) t nil t))
       (goto-char pos))))
 
 (defun org-set-tags-command (&optional arg just-align)
@@ -13766,7 +14588,9 @@ This works in the agenda, and also in an org-mode buffer."
    (list (region-beginning) (region-end)
         (let ((org-last-tags-completion-table
                (if (derived-mode-p 'org-mode)
-                   (org-get-buffer-tags)
+                   (org-uniquify
+                    (delq nil (append (org-get-buffer-tags)
+                                      (org-global-tags-completion-table))))
                  (org-global-tags-completion-table))))
           (org-icompleting-read
            "Tag: " 'org-tags-completion-function nil nil nil
@@ -13818,15 +14642,14 @@ This works in the agenda, and also in an org-mode buffer."
       rtn)
      ((eq flag t)
       ;; all-completions
-      (all-completions s2 ctable confirm)
-      )
+      (all-completions s2 ctable confirm))
      ((eq flag 'lambda)
       ;; exact match?
-      (assoc s2 ctable)))
-    ))
+      (assoc s2 ctable)))))
 
 (defun org-fast-tag-insert (kwd tags face &optional end)
-  "Insert KDW, and the TAGS, the latter with face FACE.  Also insert END."
+  "Insert KDW, and the TAGS, the latter with face FACE.
+Also insert END."
   (insert (format "%-12s" (concat kwd ":"))
          (org-add-props (mapconcat 'identity tags " ") nil 'face face)
          (or end "")))
@@ -13842,6 +14665,7 @@ This works in the agenda, and also in an org-mode buffer."
       (insert (org-add-props " Next change exits" nil 'face 'org-warning)))))
 
 (defun org-set-current-tags-overlay (current prefix)
+  "Add an overlay to CURRENT tag with PREFIX."
   (let ((s (concat ":" (mapconcat 'identity current ":") ":")))
     (if (featurep 'xemacs)
        (org-overlay-display org-tags-overlay (concat prefix s)
@@ -13924,6 +14748,7 @@ Returns the new tags string, or nil to not change the current settings."
            (while (equal (car tbl) '(:newline))
              (insert "\n")
              (setq tbl (cdr tbl)))))
+        ((equal e '(:grouptags)) nil)
         (t
          (setq tg (copy-sequence (car e)) c2 nil)
          (if (cdr e)
@@ -13939,11 +14764,13 @@ Returns the new tags string, or nil to not change the current settings."
            (setq c (or c2 char)))
          (if ingroup (push tg (car groups)))
          (setq tg (org-add-props tg nil 'face
-                                 (cond
-                                  ((not (assoc tg table))
-                                   (org-get-todo-face tg))
-                                  ((member tg current) c-face)
-                                  ((member tg inherited) i-face))))
+                                 (cond
+                                  ((not (assoc tg table))
+                                   (org-get-todo-face tg))
+                                  ((member tg current) c-face)
+                                  ((member tg inherited) i-face))))
+         (if (equal (caar tbl) :grouptags)
+             (org-add-props tg nil 'face 'org-tag-group))
          (if (and (= cnt 0) (not ingroup)) (insert "  "))
          (insert "[" c "] " tg (make-string
                                 (- fwidth 4 (length tg)) ?\ ))
@@ -14045,7 +14872,7 @@ Returns the new tags string, or nil to not change the current settings."
 (defun org-get-tags-string ()
   "Get the TAGS string in the current headline."
   (unless (org-at-heading-p t)
-    (error "Not on a heading"))
+    (user-error "Not on a heading"))
   (save-excursion
     (beginning-of-line 1)
     (if (looking-at (org-re ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"))
@@ -14153,7 +14980,7 @@ a *different* entry, you cannot use these techniques."
        ((eq match nil) (setq matcher t))
        (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t))))
 
-      (save-excursion
+      (save-window-excursion
        (save-restriction
          (cond ((eq scope 'tree)
                 (org-back-to-heading t)
@@ -14248,16 +15075,6 @@ Being in this list makes sure that they are offered for completion.")
          org-property-end-re "\\)\n?")
   "Matches an entire clock drawer.")
 
-(defsubst org-re-property (property)
-  "Return a regexp matching a PROPERTY line.
-Match group 1 will be set to the value."
-  (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)"))
-
-(defsubst org-re-property-keyword (property)
-  "Return a regexp matching a PROPERTY line, possibly with no
-value for the property."
-  (concat "^[ \t]*:" (regexp-quote property) ":[ \t]*\\(\\S-.*\\)?"))
-
 (defun org-property-action ()
   "Do an action on properties."
   (interactive)
@@ -14274,13 +15091,15 @@ value for the property."
       (call-interactively 'org-delete-property-globally))
      ((equal c ?c)
       (call-interactively 'org-compute-property-at-point))
-     (t (error "No such property action %c" c)))))
+     (t (user-error "No such property action %c" c)))))
 
 (defun org-inc-effort ()
   "Increment the value of the effort property in the current entry."
   (interactive)
   (org-set-effort nil t))
 
+(defvar org-clock-effort)       ;; Defined in org-clock.el
+(defvar org-clock-current-task) ;; Defined in org-clock.el
 (defun org-set-effort (&optional value increment)
   "Set the effort property of the current entry.
 With numerical prefix arg, use the nth allowed value, 0 stands for the
@@ -14294,6 +15113,7 @@ When INCREMENT is non-nil, set the property to the next allowed value."
         (cur (org-entry-get nil prop))
         (allowed (org-property-get-allowed-values nil prop 'table))
         (existing (mapcar 'list (org-property-values prop)))
+        (heading (nth 4 (org-heading-components)))
         rpl
         (val (cond
               ((stringp value) value)
@@ -14302,7 +15122,7 @@ When INCREMENT is non-nil, set the property to the next allowed value."
                    (car (org-last allowed))))
               ((and allowed increment)
                (or (caadr (member (list cur) allowed))
-                   (error "Allowed effort values are not set")))
+                   (user-error "Allowed effort values are not set")))
               (allowed
                (message "Select 1-9,0, [RET%s]: %s"
                         (if cur (concat "=" cur) "")
@@ -14327,18 +15147,17 @@ When INCREMENT is non-nil, set the property to the next allowed value."
     (save-excursion
       (org-back-to-heading t)
       (put-text-property (point-at-bol) (point-at-eol) 'org-effort val))
+    (when (string= heading org-clock-current-task)
+      (setq org-clock-effort (get-text-property (point-at-bol) 'org-effort))
+      (org-clock-update-mode-line))
     (message "%s is now %s" prop val)))
 
 (defun org-at-property-p ()
   "Is cursor inside a property drawer?"
   (save-excursion
-    (beginning-of-line 1)
-    (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
-      (save-match-data ;; Used by calling procedures
-       (let ((p (point))
-             (range (unless (org-before-first-heading-p)
-                      (org-get-property-block))))
-         (and range (<= (car range) p) (< p (cdr range))))))))
+    (when (equal 'node-property (car (org-element-at-point)))
+      (beginning-of-line 1)
+      (looking-at org-property-re))))
 
 (defun org-get-property-block (&optional beg end force)
   "Return the (beg . end) range of the body of the property drawer.
@@ -14463,11 +15282,10 @@ things up because then unnecessary parsing is avoided."
            (setq range (org-get-property-block beg end))
            (when range
              (goto-char (car range))
-             (while (re-search-forward
-                     (org-re "^[ \t]*:\\([[:alpha:]][[:alnum:]_-]*\\):[ \t]*\\(\\S-.*\\)?")
+             (while (re-search-forward org-property-re
                      (cdr range) t)
-               (setq key (org-match-string-no-properties 1)
-                     value (org-trim (or (org-match-string-no-properties 2) "")))
+               (setq key (org-match-string-no-properties 2)
+                     value (org-trim (or (org-match-string-no-properties 3) "")))
                (unless (member key excluded)
                  (push (cons key (or value "")) props)))))
          (if clocksum
@@ -14516,8 +15334,8 @@ when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
                           (setq props
                                 (org-update-property-plist
                                  key
-                                 (if (match-end 1)
-                                     (org-match-string-no-properties 1) "")
+                                 (if (match-end 3)
+                                     (org-match-string-no-properties 3) "")
                                  props)))))
                   val)
              (goto-char (car range))
@@ -14535,8 +15353,10 @@ If yes, return this value.  If not, return the current value of the variable."
        (read prop)
       (symbol-value var))))
 
-(defun org-entry-delete (pom property)
-  "Delete the property PROPERTY from entry at point-or-marker POM."
+(defun org-entry-delete (pom property &optional delete-empty-drawer)
+  "Delete the property PROPERTY from entry at point-or-marker POM.
+When optional argument DELETE-EMPTY-DRAWER is a string, it defines
+an empty drawer to delete."
   (org-with-point-at pom
     (if (member property org-special-properties)
        nil ; cannot delete these properties.
@@ -14548,6 +15368,9 @@ If yes, return this value.  If not, return the current value of the variable."
                  (cdr range) t))
            (progn
              (delete-region (match-beginning 0) (1+ (point-at-eol)))
+             (and delete-empty-drawer
+                  (org-remove-empty-drawer-at
+                   delete-empty-drawer (car range)))
              t)
          nil)))))
 
@@ -14559,7 +15382,7 @@ If yes, return this value.  If not, return the current value of the variable."
         (values (and old (org-split-string old "[ \t]"))))
     (setq value (org-entry-protect-space value))
     (unless (member value values)
-      (setq values (cons value values))
+      (setq values (append values (list value)))
       (org-entry-put pom property
                     (mapconcat 'identity values " ")))))
 
@@ -14660,7 +15483,7 @@ and the new value.")
        ((equal property "TODO")
        (when (and (stringp value) (string-match "\\S-" value)
                   (not (member value org-todo-keywords-1)))
-         (error "\"%s\" is not a valid TODO state" value))
+         (user-error "\"%s\" is not a valid TODO state" value))
        (if (or (not value)
                (not (string-match "\\S-" value)))
            (setq value 'none))
@@ -14670,6 +15493,15 @@ and the new value.")
        (org-priority (if (and value (stringp value) (string-match "\\S-" value))
                          (string-to-char value) ?\ ))
        (org-set-tags nil 'align))
+       ((equal property "CLOCKSUM")
+       (if (not (re-search-forward
+                 (concat org-clock-string ".*\\]--\\(\\[[^]]+\\]\\)") nil t))
+           (error "Cannot find a clock log")
+         (goto-char (- (match-end 1) 2))
+         (cond
+          ((eq value 'earlier) (org-timestamp-down))
+          ((eq value 'later) (org-timestamp-up)))
+         (org-clock-sum-current-item)))
        ((equal property "SCHEDULED")
        (if (re-search-forward org-scheduled-time-regexp end t)
            (cond
@@ -14692,7 +15524,7 @@ and the new value.")
          (setq range (org-get-property-block beg end 'force))
          (goto-char (car range))
          (if (re-search-forward
-              (org-re-property-keyword property) (cdr range) t)
+              (org-re-property property) (cdr range) t)
              (progn
                (delete-region (match-beginning 0) (match-end 0))
                (goto-char (match-beginning 0)))
@@ -14722,10 +15554,9 @@ formats in the current buffer."
        (while (re-search-forward org-property-start-re nil t)
          (setq range (org-get-property-block))
          (goto-char (car range))
-         (while (re-search-forward
-                 (org-re "^[ \t]*:\\([-[:alnum:]_]+\\):")
+         (while (re-search-forward org-property-re
                  (cdr range) t)
-           (add-to-list 'rtn (org-match-string-no-properties 1)))
+           (add-to-list 'rtn (org-match-string-no-properties 2)))
          (outline-next-heading))))
 
     (when include-specials
@@ -14763,7 +15594,7 @@ formats in the current buffer."
       (let ((re (org-re-property key))
            values)
        (while (re-search-forward re nil t)
-         (add-to-list 'values (org-trim (match-string 1))))
+         (add-to-list 'values (org-trim (match-string 3))))
        (delete "" values)))))
 
 (defun org-insert-property-drawer ()
@@ -14792,7 +15623,9 @@ formats in the current buffer."
        (beginning-of-line 1)))
     (org-skip-over-state-notes)
     (skip-chars-backward " \t\n\r")
-    (if (eq (char-before) ?*) (forward-char 1))
+    (if (and (eq (char-before) ?*) (not (eq (char-after) ?\n)))
+       (forward-char 1))
+    (goto-char (point-at-eol))
     (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:"))
     (beginning-of-line 0)
     (org-indent-to-column indent)
@@ -14849,7 +15682,7 @@ Point is left between drawer's boundaries."
              (beginning-of-line)
              (when (save-excursion
                      (re-search-forward org-outline-regexp-bol rend t))
-               (error "Drawers cannot contain headlines"))
+               (user-error "Drawers cannot contain headlines"))
              ;; Position point at the beginning of the first
              ;; non-blank line in region.  Insert drawer's opening
              ;; there, then indent it.
@@ -14907,6 +15740,7 @@ This is computed according to `org-property-set-functions-alist'."
       val)))
 
 (defvar org-last-set-property nil)
+(defvar org-last-set-property-value nil)
 (defun org-read-property-name ()
   "Read a property name."
   (let* ((completion-ignore-case t)
@@ -14924,8 +15758,7 @@ This is computed according to `org-property-set-functions-alist'."
                            ": ")
                    (mapcar 'list keys)
                    nil nil nil nil
-                   default-prop
-                   )))
+                   default-prop)))
     (if (member property keys)
        property
       (or (cdr (assoc (downcase property)
@@ -14933,6 +15766,23 @@ This is computed according to `org-property-set-functions-alist'."
                              keys)))
          property))))
 
+(defun org-set-property-and-value (use-last)
+  "Allow to set [PROPERTY]: [value] direction from prompt.
+When use-default, don't even ask, just use the last
+\"[PROPERTY]: [value]\" string from the history."
+  (interactive "P")
+  (let* ((completion-ignore-case t)
+        (pv (or (and use-last org-last-set-property-value)
+                (org-completing-read
+                 "Enter a \"[Property]: [value]\" pair: "
+                 nil nil nil nil nil
+                 org-last-set-property-value)))
+        prop val)
+    (when (string-match "^[ \t]*\\([^:]+\\):[ \t]*\\(.*\\)[ \t]*$" pv)
+      (setq prop (match-string 1 pv)
+           val (match-string 2 pv))
+      (org-set-property prop val))))
+
 (defun org-set-property (property value)
   "In the current entry, set PROPERTY to VALUE.
 When called interactively, this will prompt for a property name, offering
@@ -14945,20 +15795,23 @@ in the current file."
         (value (or value (org-read-property-value property)))
         (fn (cdr (assoc property org-properties-postprocess-alist))))
     (setq org-last-set-property property)
+    (setq org-last-set-property-value (concat property ": " value))
     ;; Possibly postprocess the inserted value:
     (when fn (setq value (funcall fn value)))
     (unless (equal (org-entry-get nil property) value)
       (org-entry-put nil property value))))
 
-(defun org-delete-property (property)
-  "In the current entry, delete PROPERTY."
+(defun org-delete-property (property &optional delete-empty-drawer)
+  "In the current entry, delete PROPERTY.
+When optional argument DELETE-EMPTY-DRAWER is a string, it defines
+an empty drawer to delete."
   (interactive
    (let* ((completion-ignore-case t)
          (prop (org-icompleting-read "Property: "
                                      (org-entry-properties nil 'standard))))
      (list prop)))
   (message "Property %s %s" property
-          (if (org-entry-delete nil property)
+          (if (org-entry-delete nil property delete-empty-drawer)
               "deleted"
             "was not present in the entry")))
 
@@ -14990,11 +15843,11 @@ This looks for an enclosing column format, extracts the operator and
 then applies it to the property in the column format's scope."
   (interactive)
   (unless (org-at-property-p)
-    (error "Not at a property"))
+    (user-error "Not at a property"))
   (let ((prop (org-match-string-no-properties 2)))
     (org-columns-get-format-and-top-level)
     (unless (nth 3 (assoc prop org-columns-current-fmt-compiled))
-      (error "No operator defined for property %s" prop))
+      (user-error "No operator defined for property %s" prop))
     (org-columns-compute prop)))
 
 (defvar org-property-allowed-value-functions nil
@@ -15047,22 +15900,23 @@ completion."
   "Switch to the next allowed value for this property."
   (interactive)
   (unless (org-at-property-p)
-    (error "Not at a property"))
+    (user-error "Not at a property"))
   (let* ((prop (car (save-match-data (org-split-string (match-string 1) ":"))))
         (key (match-string 2))
         (value (match-string 3))
         (allowed (or (org-property-get-allowed-values (point) key)
                      (and (member value  '("[ ]" "[-]" "[X]"))
                           '("[ ]" "[X]"))))
+        (heading (save-match-data (nth 4 (org-heading-components))))
         nval)
     (unless allowed
-      (error "Allowed values for this property have not been defined"))
+      (user-error "Allowed values for this property have not been defined"))
     (if previous (setq allowed (reverse allowed)))
     (if (member value allowed)
        (setq nval (car (cdr (member value allowed)))))
     (setq nval (or nval (car allowed)))
     (if (equal nval value)
-       (error "Only one allowed value for this property"))
+       (user-error "Only one allowed value for this property"))
     (org-at-property-p)
     (replace-match (concat " :" key ": " nval) t t)
     (org-indent-line)
@@ -15071,7 +15925,10 @@ completion."
     (when (equal prop org-effort-property)
       (save-excursion
        (org-back-to-heading t)
-       (put-text-property (point-at-bol) (point-at-eol) 'org-effort nval)))
+       (put-text-property (point-at-bol) (point-at-eol) 'org-effort nval))
+      (when (string= org-clock-current-task heading)
+       (setq org-clock-effort nval)
+       (org-clock-update-mode-line)))
     (run-hook-with-args 'org-property-changed-functions key nval)))
 
 (defun org-find-olp (path &optional this-buffer)
@@ -15182,8 +16039,6 @@ Return the position where this entry starts, or nil if there is no such entry."
 (defvar org-last-changed-timestamp nil)
 (defvar org-last-inserted-timestamp nil
   "The last time stamp inserted with `org-insert-time-stamp'.")
-(defvar org-time-was-given) ; dynamically scoped parameter
-(defvar org-end-time-was-given) ; dynamically scoped parameter
 (defvar org-ts-what) ; dynamically scoped parameter
 
 (defun org-time-stamp (arg &optional inactive)
@@ -15201,7 +16056,10 @@ If there is already a timestamp at the cursor, it will be
 modified.
 
 With two universal prefix arguments, insert an active timestamp
-with the current time without prompting the user."
+with the current time without prompting the user.
+
+When called from lisp, the timestamp is inactive if INACTIVE is
+non-nil."
   (interactive "P")
   (let* ((ts nil)
         (default-time
@@ -15248,7 +16106,7 @@ with the current time without prompting the user."
                            " " repeater ">"))))
       (message "Timestamp updated"))
      ((equal arg '(16))
-      (org-insert-time-stamp (current-time) t))
+      (org-insert-time-stamp (current-time) t inactive))
      (t
       (setq time (let ((this-command this-command))
                   (org-read-date arg 'totime nil nil default-time default-input inactive)))
@@ -15270,7 +16128,7 @@ with the current time without prompting the user."
        (setq dh (- h2 h1) dm (- m2 m1))
        (if (< dm 0) (setq dm (+ dm 60) dh (1- dh)))
        (concat t1 "+" (number-to-string dh)
-               (if (/= 0 dm) (concat ":" (number-to-string dm))))))))
+               (and (/= 0 dm) (format ":%02d" dm)))))))
 
 (defun org-time-stamp-inactive (&optional arg)
   "Insert an inactive time stamp.
@@ -15299,6 +16157,80 @@ So these are more for recording a certain time/date."
 (defvar org-read-date-analyze-forced-year nil)
 (defvar org-read-date-inactive)
 
+(defvar org-read-date-minibuffer-local-map
+  (let* ((org-replace-disputed-keys nil)
+        (map (make-sparse-keymap)))
+    (set-keymap-parent map minibuffer-local-map)
+    (org-defkey map (kbd ".")
+                (lambda () (interactive)
+                 ;; Are we at the beginning of the prompt?
+                 (if (looking-back "^[^:]+: ")
+                     (org-eval-in-calendar '(calendar-goto-today))
+                   (insert "."))))
+    (org-defkey map (kbd "C-.")
+                (lambda () (interactive)
+                 (org-eval-in-calendar '(calendar-goto-today))))
+    (org-defkey map [(meta shift left)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-month 1))))
+    (org-defkey map [(meta shift right)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-month 1))))
+    (org-defkey map [(meta shift up)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-year 1))))
+    (org-defkey map [(meta shift down)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-year 1))))
+    (org-defkey map [?\e (shift left)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-month 1))))
+    (org-defkey map [?\e (shift right)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-month 1))))
+    (org-defkey map [?\e (shift up)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-year 1))))
+    (org-defkey map [?\e (shift down)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-year 1))))
+    (org-defkey map [(shift up)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-week 1))))
+    (org-defkey map [(shift down)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-week 1))))
+    (org-defkey map [(shift left)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-backward-day 1))))
+    (org-defkey map [(shift right)]
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(calendar-forward-day 1))))
+    (org-defkey map "!"
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(diary-view-entries))
+                  (message "")))
+    (org-defkey map ">"
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(scroll-calendar-left 1))))
+    (org-defkey map "<"
+                (lambda () (interactive)
+                  (org-eval-in-calendar '(scroll-calendar-right 1))))
+    (org-defkey map "\C-v"
+                (lambda () (interactive)
+                  (org-eval-in-calendar
+                   '(calendar-scroll-left-three-months 1))))
+    (org-defkey map "\M-v"
+                (lambda () (interactive)
+                  (org-eval-in-calendar
+                   '(calendar-scroll-right-three-months 1))))
+    map)
+  "Keymap for minibuffer commands when using `org-read-date'.")
+
+(defvar org-def)
+(defvar org-defdecode)
+(defvar org-with-time)
+
 (defun org-read-date (&optional org-with-time to-time from-string prompt
                                default-time default-input inactive)
   "Read a date, possibly a time, and make things smooth for the user.
@@ -15319,7 +16251,8 @@ mean next year.  For details, see the manual.  A few examples:
   12:45         --> today 12:45
   22 sept 0:34  --> currentyear-09-22 0:34
   12            --> currentyear-currentmonth-12
-  Fri           --> nearest Friday (today or later)
+  Fri           --> nearest Friday after today
+  -Tue          --> last Tuesday
   etc.
 
 Furthermore you can specify a relative date by giving, as the *first* thing
@@ -15391,61 +16324,11 @@ user."
                (org-eval-in-calendar nil t)
                (let* ((old-map (current-local-map))
                       (map (copy-keymap calendar-mode-map))
-                      (minibuffer-local-map (copy-keymap minibuffer-local-map)))
+                      (minibuffer-local-map
+                       (copy-keymap org-read-date-minibuffer-local-map)))
                  (org-defkey map (kbd "RET") 'org-calendar-select)
                  (org-defkey map [mouse-1] 'org-calendar-select-mouse)
                  (org-defkey map [mouse-2] 'org-calendar-select-mouse)
-                 (org-defkey minibuffer-local-map [(meta shift left)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-month 1))))
-                 (org-defkey minibuffer-local-map [(meta shift right)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-month 1))))
-                 (org-defkey minibuffer-local-map [(meta shift up)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-year 1))))
-                 (org-defkey minibuffer-local-map [(meta shift down)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-year 1))))
-                 (org-defkey minibuffer-local-map [?\e (shift left)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-month 1))))
-                 (org-defkey minibuffer-local-map [?\e (shift right)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-month 1))))
-                 (org-defkey minibuffer-local-map [?\e (shift up)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-year 1))))
-                 (org-defkey minibuffer-local-map [?\e (shift down)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-year 1))))
-                 (org-defkey minibuffer-local-map [(shift up)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-week 1))))
-                 (org-defkey minibuffer-local-map [(shift down)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-week 1))))
-                 (org-defkey minibuffer-local-map [(shift left)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-backward-day 1))))
-                 (org-defkey minibuffer-local-map [(shift right)]
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(calendar-forward-day 1))))
-                 (org-defkey minibuffer-local-map ">"
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(scroll-calendar-left 1))))
-                 (org-defkey minibuffer-local-map "<"
-                             (lambda () (interactive)
-                               (org-eval-in-calendar '(scroll-calendar-right 1))))
-                 (org-defkey minibuffer-local-map "\C-v"
-                             (lambda () (interactive)
-                               (org-eval-in-calendar
-                                '(calendar-scroll-left-three-months 1))))
-                 (org-defkey minibuffer-local-map "\M-v"
-                             (lambda () (interactive)
-                               (org-eval-in-calendar
-                                '(calendar-scroll-right-three-months 1))))
-                 (run-hooks 'org-read-date-minibuffer-setup-hook)
                  (unwind-protect
                      (progn
                        (use-local-map map)
@@ -15494,9 +16377,6 @@ user."
                  (nth 2 final) (nth 1 final))
        (format "%04d-%02d-%02d" (nth 5 final) (nth 4 final) (nth 3 final))))))
 
-(defvar org-def)
-(defvar org-defdecode)
-(defvar org-with-time)
 (defun org-read-date-display ()
   "Display the current date prompt interpretation in the minibuffer."
   (when org-read-date-display-live
@@ -15757,7 +16637,11 @@ DEF-FLAG   is t when a double ++ or -- indicates shift relative to
       (if wday1
          (progn
            (setq delta (mod (+ 7 (- wday1 wday)) 7))
-           (if (= dir ?-) (setq delta (- delta 7)))
+           (if (= delta 0) (setq delta 7))
+           (if (= dir ?-)
+               (progn
+                 (setq delta (- delta 7))
+                 (if (= delta 0) (setq delta -7))))
            (if (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7)))))
            (list delta "d" rel))
        (list (* n (if (= dir ?-) -1 1)) what rel)))))
@@ -15913,32 +16797,44 @@ Don't touch the rest."
   (let ((n 0))
     (mapcar (lambda (x) (if (< (setq n (1+ n)) 7) (or x 0) x)) time)))
 
-(defun org-days-to-time (timestamp-string)
-  "Difference between TIMESTAMP-STRING and now in days."
-  (- (time-to-days (org-time-string-to-time timestamp-string))
-     (time-to-days (current-time))))
+(define-obsolete-function-alias 'org-days-to-time 'org-time-stamp-to-now "24.4")
+
+(defun org-time-stamp-to-now (timestamp-string &optional seconds)
+  "Difference between TIMESTAMP-STRING and now in days.
+If SECONDS is non-nil, return the difference in seconds."
+  (let ((fdiff (if seconds 'org-float-time 'time-to-days)))
+    (- (funcall fdiff (org-time-string-to-time timestamp-string))
+       (funcall fdiff (current-time)))))
 
 (defun org-deadline-close (timestamp-string &optional ndays)
   "Is the time in TIMESTAMP-STRING close to the current date?"
   (setq ndays (or ndays (org-get-wdays timestamp-string)))
-  (and (< (org-days-to-time timestamp-string) ndays)
+  (and (< (org-time-stamp-to-now timestamp-string) ndays)
        (not (org-entry-is-done-p))))
 
-(defun org-get-wdays (ts)
-  "Get the deadline lead time appropriate for timestring TS."
-  (cond
-   ((<= org-deadline-warning-days 0)
-    ;; 0 or negative, enforce this value no matter what
-    (- org-deadline-warning-days))
-   ((string-match "-\\([0-9]+\\)\\([hdwmy]\\)\\(\\'\\|>\\| \\)" ts)
-    ;; lead time is specified.
-    (floor (* (string-to-number (match-string 1 ts))
-             (cdr (assoc (match-string 2 ts)
-                         '(("d" . 1)    ("w" . 7)
-                           ("m" . 30.4) ("y" . 365.25)
-                           ("h" . 0.041667)))))))
-   ;; go for the default.
-   (t org-deadline-warning-days)))
+(defun org-get-wdays (ts &optional delay zero-delay)
+  "Get the deadline lead time appropriate for timestring TS.
+When DELAY is non-nil, get the delay time for scheduled items
+instead of the deadline lead time.  When ZERO-DELAY is non-nil
+and `org-scheduled-delay-days' is 0, enforce 0 as the delay,
+don't try to find the delay cookie in the scheduled timestamp."
+  (let ((tv (if delay org-scheduled-delay-days
+             org-deadline-warning-days)))
+    (cond
+     ((or (and delay (< tv 0))
+         (and delay zero-delay (<= tv 0))
+         (and (not delay) (<= tv 0)))
+      ;; Enforce this value no matter what
+      (- tv))
+     ((string-match "-\\([0-9]+\\)\\([hdwmy]\\)\\(\\'\\|>\\| \\)" ts)
+      ;; lead time is specified.
+      (floor (* (string-to-number (match-string 1 ts))
+               (cdr (assoc (match-string 2 ts)
+                           '(("d" . 1)    ("w" . 7)
+                             ("m" . 30.4) ("y" . 365.25)
+                             ("h" . 0.041667)))))))
+     ;; go for the default.
+     (t tv))))
 
 (defun org-calendar-select-mouse (ev)
   "Return to `org-read-date' with the date currently selected.
@@ -15981,6 +16877,7 @@ Allowed values for TYPE are:
    inactive: only inactive timestamps ([...])
   scheduled: only scheduled timestamps
    deadline: only deadline timestamps
+     closed: only closed time-stamps
 
 When TYPE is nil, fall back on returning a regexp that matches
 both scheduled and deadline timestamps."
@@ -15989,6 +16886,7 @@ both scheduled and deadline timestamps."
        ((eq type 'inactive) "\\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]")
        ((eq type 'scheduled) (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
        ((eq type 'deadline) (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
+       ((eq type 'closed) (concat org-closed-string " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^\r\n>]*?\\)\\]"))
        ((eq type 'scheduled-or-deadline)
         (concat "\\<\\(?:" org-deadline-string "\\|" org-scheduled-string "\\) *<\\([^>]+\\)>"))))
 
@@ -16052,7 +16950,7 @@ days in order to avoid rounding problems."
        (goto-char (point-at-bol))
        (re-search-forward org-tr-regexp-both (point-at-eol) t))
      (if (not (org-at-date-range-p t))
-        (error "Not at a time-stamp range, and none found in current line")))
+        (user-error "Not at a time-stamp range, and none found in current line")))
    (let* ((ts1 (match-string 1))
          (ts2 (match-string 2))
          (havetime (or (> (length ts1) 15) (> (length ts2) 15)))
@@ -16129,10 +17027,10 @@ days in order to avoid rounding problems."
 
 (defun org-time-string-to-absolute (s &optional daynr prefer show-all buffer pos)
   "Convert a time stamp to an absolute day number.
-If there is a specifier for a cyclic time stamp, get the closest date to
-DAYNR.
+If there is a specifier for a cyclic time stamp, get the closest
+date to DAYNR.
 PREFER and SHOW-ALL are passed through to `org-closest-date'.
-The variable date is bound by the calendar when this is called."
+The variable `date' is bound by the calendar when this is called."
   (cond
    ((and daynr (string-match "\\`%%\\((.*)\\)" s))
     (if (org-diary-sexp-entry (match-string 1 s) "" date)
@@ -16158,7 +17056,7 @@ The variable date is bound by the calendar when this is called."
 
 (defun org-small-year-to-year (year)
   "Convert 2-digit years into 4-digit years.
-38-99 are mapped into 1938-1999.  1-37 are mapped into 2001-2007.
+38-99 are mapped into 1938-1999.  1-37 are mapped into 2001-2037.
 The year 2000 cannot be abbreviated.  Any year larger than 99
 is returned unchanged."
   (if (< year 38)
@@ -16256,7 +17154,7 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
       (if (string-match "\\(\\+[0-9]+\\)\\([hdwmy]\\)" change)
          (setq dn (string-to-number (match-string 1 change))
                dw (cdr (assoc (match-string 2 change) a1)))
-       (error "Invalid change specifier: %s" change))
+       (user-error "Invalid change specifier: %s" change))
       (if (eq dw 'week) (setq dw 'day dn (* 7 dn)))
       (cond
        ((eq dw 'hour)
@@ -16323,17 +17221,19 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
 This should be a lot faster than the normal `parse-time-string'.
 If time is not given, defaults to 0:00.  However, with optional NODEFAULT,
 hour and minute fields will be nil if not given."
-  (if (string-match org-ts-regexp0 s)
-      (list 0
-           (if (or (match-beginning 8) (not nodefault))
-               (string-to-number (or (match-string 8 s) "0")))
-           (if (or (match-beginning 7) (not nodefault))
-               (string-to-number (or (match-string 7 s) "0")))
-           (string-to-number (match-string 4 s))
-           (string-to-number (match-string 3 s))
-           (string-to-number (match-string 2 s))
-           nil nil nil)
-    (error "Not a standard Org-mode time string: %s" s)))
+  (cond ((string-match org-ts-regexp0 s)
+        (list 0
+              (if (or (match-beginning 8) (not nodefault))
+                  (string-to-number (or (match-string 8 s) "0")))
+              (if (or (match-beginning 7) (not nodefault))
+                  (string-to-number (or (match-string 7 s) "0")))
+              (string-to-number (match-string 4 s))
+              (string-to-number (match-string 3 s))
+              (string-to-number (match-string 2 s))
+              nil nil nil))
+       ((string-match "^<[^>]+>$" s)
+        (decode-time (seconds-to-time (org-matcher-time s))))
+       (t (error "Not a standard Org-mode time string: %s" s))))
 
 (defun org-timestamp-up (&optional arg)
   "Increase the date item at the cursor by one.
@@ -16423,11 +17323,12 @@ With prefix ARG, change that many days."
 
 (defvar org-clock-history)                     ; defined in org-clock.el
 (defvar org-clock-adjust-closest nil)          ; defined in org-clock.el
-(defun org-timestamp-change (n &optional what updown)
+(defun org-timestamp-change (n &optional what updown suppress-tmp-delay)
   "Change the date in the time stamp at point.
 The date will be changed by N times WHAT.  WHAT can be `day', `month',
 `year', `minute', `second'.  If WHAT is not given, the cursor position
-in the timestamp determines what will be changed."
+in the timestamp determines what will be changed.
+When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"."
   (let ((origin (point)) origin-cat
        with-hm inactive
        (dm (max (nth 1 org-time-stamp-rounding-minutes) 1))
@@ -16435,7 +17336,7 @@ in the timestamp determines what will be changed."
        extra rem
        ts time time0 fixnext clrgx)
     (if (not (org-at-timestamp-p t))
-       (error "Not at a timestamp"))
+       (user-error "Not at a timestamp"))
     (if (and (not what) (eq org-ts-what 'bracket))
        (org-toggle-timestamp-type)
       ;; Point isn't on brackets.  Remember the part of the time-stamp
@@ -16451,10 +17352,12 @@ in the timestamp determines what will be changed."
            inactive (= (char-after (match-beginning 0)) ?\[)
            ts (match-string 0))
       (replace-match "")
-      (if (string-match
-          "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?[-+][0-9]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)*\\)[]>]"
-          ts)
-         (setq extra (match-string 1 ts)))
+      (when (string-match
+            "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( +[.+]?-?[-+][0-9]+[hdwmy]\\(/[0-9]+[hdwmy]\\)?\\)*\\)[]>]"
+            ts)
+       (setq extra (match-string 1 ts))
+       (if suppress-tmp-delay
+           (setq extra (replace-regexp-in-string " --[0-9]+[hdwmy]" "" extra))))
       (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
          (setq with-hm t))
       (setq time0 (org-parse-time-string ts))
@@ -16518,7 +17421,7 @@ in the timestamp determines what will be changed."
       ;; Maybe adjust the closest clock in `org-clock-history'
       (when org-clock-adjust-closest
        (if (not (and (org-at-clock-log-p)
-                     (< 1 (length (delq nil (mapcar (lambda(m) (marker-position m))
+                     (< 1 (length (delq nil (mapcar 'marker-position
                                                     org-clock-history))))))
            (message "No clock to adjust")
          (cond ((save-excursion ; fix previous clock?
@@ -16637,27 +17540,6 @@ If there is already a time stamp at the cursor position, update it."
       (org-insert-time-stamp
        (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date))))))
 
-(defun org-minutes-to-hh:mm-string (m)
-  "Compute H:MM from a number of minutes."
-  (let ((h (/ m 60)))
-    (setq m (- m (* 60 h)))
-    (format org-time-clocksum-format h m)))
-
-(defun org-hh:mm-string-to-minutes (s)
-  "Convert a string H:MM to a number of minutes.
-If the string is just a number, interpret it as minutes.
-In fact, the first hh:mm or number in the string will be taken,
-there can be extra stuff in the string.
-If no number is found, the return value is 0."
-  (cond
-   ((integerp s) s)
-   ((string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
-    (+ (* (string-to-number (match-string 1 s)) 60)
-       (string-to-number (match-string 2 s))))
-   ((string-match "\\([0-9]+\\)" s)
-    (string-to-number (match-string 1 s)))
-   (t 0)))
-
 (defcustom org-effort-durations
   `(("h" . 60)
     ("d" . ,(* 60 8))
@@ -16679,7 +17561,146 @@ effort string \"2hours\" is equivalent to 120 minutes."
   :type '(alist :key-type (string :tag "Modifier")
                :value-type (number :tag "Minutes")))
 
-(defcustom org-agenda-inhibit-startup t
+(defun org-minutes-to-clocksum-string (m)
+  "Format number of minutes as a clocksum string.
+The format is determined by `org-time-clocksum-format',
+`org-time-clocksum-use-fractional' and
+`org-time-clocksum-fractional-format' and
+`org-time-clocksum-use-effort-durations'."
+  (let ((clocksum "")
+       (m (round m)) ; Don't allow fractions of minutes
+       h d w mo y fmt n)
+    (setq h (if org-time-clocksum-use-effort-durations
+               (cdr (assoc "h" org-effort-durations)) 60)
+         d (if org-time-clocksum-use-effort-durations
+               (/ (cdr (assoc "d" org-effort-durations)) h) 24)
+         w (if org-time-clocksum-use-effort-durations
+               (/ (cdr (assoc "w" org-effort-durations)) (* d h)) 7)
+         mo (if org-time-clocksum-use-effort-durations
+                (/ (cdr (assoc "m" org-effort-durations)) (* d h)) 30)
+         y (if org-time-clocksum-use-effort-durations
+               (/ (cdr (assoc "y" org-effort-durations)) (* d h)) 365))
+    ;; fractional format
+    (if org-time-clocksum-use-fractional
+       (cond
+        ;; single format string
+        ((stringp org-time-clocksum-fractional-format)
+         (format org-time-clocksum-fractional-format (/ m (float h))))
+        ;; choice of fractional formats for different time units
+        ((and (setq fmt (plist-get org-time-clocksum-fractional-format :years))
+              (> (/ (truncate m) (* y d h)) 0))
+         (format fmt (/ m (* y d (float h)))))
+        ((and (setq fmt (plist-get org-time-clocksum-fractional-format :months))
+              (> (/ (truncate m) (* mo d h)) 0))
+         (format fmt (/ m (* mo d (float h)))))
+        ((and (setq fmt (plist-get org-time-clocksum-fractional-format :weeks))
+              (> (/ (truncate m) (* w d h)) 0))
+         (format fmt (/ m (* w d (float h)))))
+        ((and (setq fmt (plist-get org-time-clocksum-fractional-format :days))
+              (> (/ (truncate m) (* d h)) 0))
+         (format fmt (/ m (* d (float h)))))
+        ((and (setq fmt (plist-get org-time-clocksum-fractional-format :hours))
+              (> (/ (truncate m) h) 0))
+         (format fmt (/ m (float h))))
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :minutes))
+         (format fmt m))
+        ;; fall back to smallest time unit with a format
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :hours))
+         (format fmt (/ m (float h))))
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :days))
+         (format fmt (/ m (* d (float h)))))
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :weeks))
+         (format fmt (/ m (* w d (float h)))))
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :months))
+         (format fmt (/ m (* mo d (float h)))))
+        ((setq fmt (plist-get org-time-clocksum-fractional-format :years))
+         (format fmt (/ m (* y d (float h))))))
+      ;; standard (non-fractional) format, with single format string
+      (if (stringp org-time-clocksum-format)
+         (format org-time-clocksum-format (setq n (/ m h)) (- m (* h n)))
+       ;; separate formats components
+       (and (setq fmt (plist-get org-time-clocksum-format :years))
+            (or (> (setq n (/ (truncate m) (* y d h))) 0)
+                (plist-get org-time-clocksum-format :require-years))
+            (setq clocksum (concat clocksum (format fmt n))
+                  m (- m (* n y d h))))
+       (and (setq fmt (plist-get org-time-clocksum-format :months))
+            (or (> (setq n (/ (truncate m) (* mo d h))) 0)
+                (plist-get org-time-clocksum-format :require-months))
+            (setq clocksum (concat clocksum (format fmt n))
+                  m (- m (* n mo d h))))
+       (and (setq fmt (plist-get org-time-clocksum-format :weeks))
+            (or (> (setq n (/ (truncate m) (* w d h))) 0)
+                (plist-get org-time-clocksum-format :require-weeks))
+            (setq clocksum (concat clocksum (format fmt n))
+                  m (- m (* n w d h))))
+       (and (setq fmt (plist-get org-time-clocksum-format :days))
+            (or (> (setq n (/ (truncate m) (* d h))) 0)
+                (plist-get org-time-clocksum-format :require-days))
+            (setq clocksum (concat clocksum (format fmt n))
+                  m (- m (* n d h))))
+       (and (setq fmt (plist-get org-time-clocksum-format :hours))
+            (or (> (setq n (/ (truncate m) h)) 0)
+                (plist-get org-time-clocksum-format :require-hours))
+            (setq clocksum (concat clocksum (format fmt n))
+                  m (- m (* n h))))
+       (and (setq fmt (plist-get org-time-clocksum-format :minutes))
+            (or (> m 0) (plist-get org-time-clocksum-format :require-minutes))
+            (setq clocksum (concat clocksum (format fmt m))))
+       ;; return formatted time duration
+       clocksum))))
+
+(defalias 'org-minutes-to-hh:mm-string 'org-minutes-to-clocksum-string)
+(make-obsolete 'org-minutes-to-hh:mm-string 'org-minutes-to-clocksum-string
+              "Org mode version 8.0")
+
+(defun org-hours-to-clocksum-string (n)
+  (org-minutes-to-clocksum-string (* n 60)))
+
+(defun org-hh:mm-string-to-minutes (s)
+  "Convert a string H:MM to a number of minutes.
+If the string is just a number, interpret it as minutes.
+In fact, the first hh:mm or number in the string will be taken,
+there can be extra stuff in the string.
+If no number is found, the return value is 0."
+  (cond
+   ((integerp s) s)
+   ((string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
+    (+ (* (string-to-number (match-string 1 s)) 60)
+       (string-to-number (match-string 2 s))))
+   ((string-match "\\([0-9]+\\)" s)
+    (string-to-number (match-string 1 s)))
+   (t 0)))
+
+(defcustom org-image-actual-width t
+  "Should we use the actual width of images when inlining them?
+
+When set to `t', always use the image width.
+
+When set to a number, use imagemagick (when available) to set
+the image's width to this value.
+
+When set to a number in a list, try to get the width from any
+#+ATTR.* keyword if it matches a width specification like
+
+  #+ATTR_HTML: :width 300px
+
+and fall back on that number if none is found.
+
+When set to nil, try to get the width from an #+ATTR.* keyword
+and fall back on the original width if none is found.
+
+This requires Emacs >= 24.1, build with imagemagick support."
+  :group 'org-appearance
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Use the image width" t)
+         (integer :tag "Use a number of pixels")
+         (list :tag "Use #+ATTR* or a number of pixels" (integer))
+         (const :tag "Use #+ATTR* or don't resize" nil)))
+
+(defcustom org-agenda-inhibit-startup nil
   "Inhibit startup when preparing agenda buffers.
 When this variable is `t' (the default), the initialization of
 the Org agenda buffers is inhibited: e.g. the visibility state
@@ -16688,6 +17709,21 @@ is not set, the tables are not re-aligned, etc."
   :version "24.3"
   :group 'org-agenda)
 
+(defcustom org-agenda-ignore-drawer-properties nil
+  "Avoid updating text properties when building the agenda.
+Properties are used to prepare buffers for effort estimates, appointments,
+and subtree-local categories.
+If you don't use these in the agenda, you can add them to this list and
+agenda building will be a bit faster.
+The value is a list, with zero or more of the symbols `effort', `appt',
+or `category'."
+  :type '(set :greedy t
+             (const effort)
+             (const appt)
+             (const category))
+  :version "24.3"
+  :group 'org-agenda)
+
 (defun org-duration-string-to-minutes (s &optional output-to-string)
   "Convert a duration string S to minutes.
 
@@ -16733,7 +17769,7 @@ changes from another.  I believe the procedure must be like this:
 3. M-x org-revert-all-org-buffers"
   (interactive)
   (unless (yes-or-no-p "Revert all Org buffers from their files? ")
-    (error "Abort"))
+    (user-error "Abort"))
   (save-excursion
     (save-window-excursion
       (mapc
@@ -16923,7 +17959,7 @@ If the current buffer does not, find the first agenda file."
         (files (append fs (list (car fs))))
         (tcf (if buffer-file-name (file-truename buffer-file-name)))
         file)
-    (unless files (error "No agenda files"))
+    (unless files (user-error "No agenda files"))
     (catch 'exit
       (while (setq file (pop files))
        (if (equal (file-truename file) tcf)
@@ -16945,7 +17981,7 @@ end of the list."
                            (org-agenda-files t)))
        (ctf (file-truename
              (or buffer-file-name
-                 (error "Please save the current buffer to a file"))))
+                 (user-error "Please save the current buffer to a file"))))
        x had)
     (setq x (assoc ctf file-alist) had x)
 
@@ -16965,7 +18001,7 @@ Optional argument FILE means use this file instead of the current."
   (interactive)
   (let* ((org-agenda-skip-unavailable-files nil)
         (file (or file buffer-file-name
-                  (error "Current buffer does not visit a file")))
+                  (user-error "Current buffer does not visit a file")))
         (true-file (file-truename file))
         (afile (abbreviate-file-name file))
         (files (delq nil (mapcar
@@ -17029,8 +18065,10 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
        (inhibit-read-only t)
        (org-inhibit-startup org-agenda-inhibit-startup)
        (rea (concat ":" org-archive-tag ":"))
-       bmp file re)
-    (save-excursion
+       file re pos)
+    (setq org-tag-alist-for-agenda nil
+         org-tag-groups-alist-for-agenda nil)
+    (save-window-excursion
       (save-restriction
        (while (setq file (pop files))
          (catch 'nextfile
@@ -17039,10 +18077,21 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
              (org-check-agenda-file file)
              (set-buffer (org-get-agenda-file-buffer file)))
            (widen)
-           (setq bmp (buffer-modified-p))
-           (org-refresh-category-properties)
-           (org-refresh-properties org-effort-property 'org-effort)
-           (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime)
+           (org-set-regexps-and-options-for-tags)
+           (setq pos (point))
+           (goto-char (point-min))
+           (let ((case-fold-search t))
+             (when (search-forward "#+setupfile" nil t)
+               ;; Don't set all regexps and options systematically as
+               ;; this is only run for setting agenda tags from setup
+               ;; file
+               (org-set-regexps-and-options)))
+           (or (memq 'category org-agenda-ignore-drawer-properties)
+               (org-refresh-category-properties))
+           (or (memq 'effort org-agenda-ignore-drawer-properties)
+               (org-refresh-properties org-effort-property 'org-effort))
+           (or (memq 'appt org-agenda-ignore-drawer-properties)
+               (org-refresh-properties "APPT_WARNTIME" 'org-appt-warntime))
            (setq org-todo-keywords-for-agenda
                  (append org-todo-keywords-for-agenda org-todo-keywords-1))
            (setq org-done-keywords-for-agenda
@@ -17052,29 +18101,36 @@ When a buffer is unmodified, it is just killed.  When modified, it is saved
            (setq org-drawers-for-agenda
                  (append org-drawers-for-agenda org-drawers))
            (setq org-tag-alist-for-agenda
-                 (append org-tag-alist-for-agenda org-tag-alist))
-
-           (save-excursion
-             (remove-text-properties (point-min) (point-max) pall)
-             (when org-agenda-skip-archived-trees
-               (goto-char (point-min))
-               (while (re-search-forward rea nil t)
-                 (if (org-at-heading-p t)
-                     (add-text-properties (point-at-bol) (org-end-of-subtree t) pa))))
-             (goto-char (point-min))
-             (setq re (format org-heading-keyword-regexp-format
-                              org-comment-string))
-             (while (re-search-forward re nil t)
-               (add-text-properties
-                (match-beginning 0) (org-end-of-subtree t) pc)))
-           (set-buffer-modified-p bmp)))))
+                 (org-uniquify
+                  (append org-tag-alist-for-agenda
+                          org-tag-alist
+                          org-tag-persistent-alist)))
+           (if org-group-tags
+               (setq org-tag-groups-alist-for-agenda
+                     (org-uniquify-alist
+                      (append org-tag-groups-alist-for-agenda org-tag-groups-alist))))
+           (org-with-silent-modifications
+            (save-excursion
+              (remove-text-properties (point-min) (point-max) pall)
+              (when org-agenda-skip-archived-trees
+                (goto-char (point-min))
+                (while (re-search-forward rea nil t)
+                  (if (org-at-heading-p t)
+                      (add-text-properties (point-at-bol) (org-end-of-subtree t) pa))))
+              (goto-char (point-min))
+              (setq re (format org-heading-keyword-regexp-format
+                               org-comment-string))
+              (while (re-search-forward re nil t)
+                (add-text-properties
+                 (match-beginning 0) (org-end-of-subtree t) pc))))
+           (goto-char pos)))))
     (setq org-todo-keywords-for-agenda
           (org-uniquify org-todo-keywords-for-agenda))
     (setq org-todo-keyword-alist-for-agenda
-         (org-uniquify org-todo-keyword-alist-for-agenda)
-         org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda))))
+         (org-uniquify org-todo-keyword-alist-for-agenda))))
 
-;;;; Embedded LaTeX
+\f
+;;;; CDLaTeX minor mode
 
 (defvar org-cdlatex-mode-map (make-sparse-keymap)
   "Keymap for the minor `org-cdlatex-mode'.")
@@ -17124,6 +18180,58 @@ an embedded LaTeX fragment, let texmathp do its job.
   "Unconditionally turn on `org-cdlatex-mode'."
   (org-cdlatex-mode 1))
 
+(defun org-try-cdlatex-tab ()
+  "Check if it makes sense to execute `cdlatex-tab', and do it if yes.
+It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
+  - inside a LaTeX fragment, or
+  - after the first word in a line, where an abbreviation expansion could
+    insert a LaTeX environment."
+  (when org-cdlatex-mode
+    (cond
+     ;; Before any word on the line: No expansion possible.
+     ((save-excursion (skip-chars-backward " \t") (bolp)) nil)
+     ;; Just after first word on the line: Expand it.  Make sure it
+     ;; cannot happen on headlines, though.
+     ((save-excursion
+       (skip-chars-backward "a-zA-Z0-9*")
+       (skip-chars-backward " \t")
+       (and (bolp) (not (org-at-heading-p))))
+      (cdlatex-tab) t)
+     ((org-inside-LaTeX-fragment-p) (cdlatex-tab) t))))
+
+(defun org-cdlatex-underscore-caret (&optional arg)
+  "Execute `cdlatex-sub-superscript' in LaTeX fragments.
+Revert to the normal definition outside of these fragments."
+  (interactive "P")
+  (if (org-inside-LaTeX-fragment-p)
+      (call-interactively 'cdlatex-sub-superscript)
+    (let (org-cdlatex-mode)
+      (call-interactively (key-binding (vector last-input-event))))))
+
+(defun org-cdlatex-math-modify (&optional arg)
+  "Execute `cdlatex-math-modify' in LaTeX fragments.
+Revert to the normal definition outside of these fragments."
+  (interactive "P")
+  (if (org-inside-LaTeX-fragment-p)
+      (call-interactively 'cdlatex-math-modify)
+    (let (org-cdlatex-mode)
+      (call-interactively (key-binding (vector last-input-event))))))
+
+
+\f
+;;;; LaTeX fragments
+
+(defvar org-latex-regexps
+  '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
+    ;; ("$" "\\([      (]\\|^\\)\\(\\(\\([$]\\)\\([^   \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^       \r\n,.$]\\)\\4\\)\\)\\([        .,?;:'\")]\\|$\\)" 2 nil)
+    ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
+    ("$1" "\\([^$]\\|^\\)\\(\\$[^      \r\n,;.$]\\$\\)\\([-    .,?;:'\")\000]\\|$\\)" 2 nil)
+    ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^         \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^        \r\n,.$]\\)\\$\\)\\)\\([-       .,?;:'\")\000]\\|$\\)" 2 nil)
+    ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
+    ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
+    ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
+  "Regular expressions for matching embedded LaTeX.")
+
 (defun org-inside-LaTeX-fragment-p ()
   "Test if point is inside a LaTeX fragment.
 I.e. after a \\begin, \\(, \\[, $, or $$, without the corresponding closing
@@ -17174,43 +18282,6 @@ looks only before point, not after."
     (org-in-regexp
      "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")))
 
-(defun org-try-cdlatex-tab ()
-  "Check if it makes sense to execute `cdlatex-tab', and do it if yes.
-It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
-  - inside a LaTeX fragment, or
-  - after the first word in a line, where an abbreviation expansion could
-    insert a LaTeX environment."
-  (when org-cdlatex-mode
-    (cond
-     ;; Before any word on the line: No expansion possible.
-     ((save-excursion (skip-chars-backward " \t") (bolp)) nil)
-     ;; Just after first word on the line: Expand it.  Make sure it
-     ;; cannot happen on headlines, though.
-     ((save-excursion
-       (skip-chars-backward "a-zA-Z0-9*")
-       (skip-chars-backward " \t")
-       (and (bolp) (not (org-at-heading-p))))
-      (cdlatex-tab) t)
-     ((org-inside-LaTeX-fragment-p) (cdlatex-tab) t))))
-
-(defun org-cdlatex-underscore-caret (&optional arg)
-  "Execute `cdlatex-sub-superscript' in LaTeX fragments.
-Revert to the normal definition outside of these fragments."
-  (interactive "P")
-  (if (org-inside-LaTeX-fragment-p)
-      (call-interactively 'cdlatex-sub-superscript)
-    (let (org-cdlatex-mode)
-      (call-interactively (key-binding (vector last-input-event))))))
-
-(defun org-cdlatex-math-modify (&optional arg)
-  "Execute `cdlatex-math-modify' in LaTeX fragments.
-Revert to the normal definition outside of these fragments."
-  (interactive "P")
-  (if (org-inside-LaTeX-fragment-p)
-      (call-interactively 'cdlatex-math-modify)
-    (let (org-cdlatex-mode)
-      (call-interactively (key-binding (vector last-input-event))))))
-
 (defvar org-latex-fragment-image-overlays nil
   "List of overlays carrying the images of latex fragments.")
 (make-variable-buffer-local 'org-latex-fragment-image-overlays)
@@ -17232,51 +18303,40 @@ display all fragments in the buffer.
 The images can be removed again with \\[org-ctrl-c-ctrl-c]."
   (interactive "P")
   (unless buffer-file-name
-    (error "Can't preview LaTeX fragment in a non-file buffer"))
-  (org-remove-latex-fragment-image-overlays)
-  (save-excursion
-    (save-restriction
-      (let (beg end at msg)
-       (cond
-        ((or (equal subtree '(16))
-             (not (save-excursion
-                    (re-search-backward org-outline-regexp-bol nil t))))
-         (setq beg (point-min) end (point-max)
-               msg "Creating images for buffer...%s"))
-        ((equal subtree '(4))
-         (org-back-to-heading)
-         (setq beg (point) end (org-end-of-subtree t)
-               msg "Creating images for subtree...%s"))
-        (t
-         (if (setq at (org-inside-LaTeX-fragment-p))
-             (goto-char (max (point-min) (- (cdr at) 2)))
-           (org-back-to-heading))
-         (setq beg (point) end (progn (outline-next-heading) (point))
-               msg (if at "Creating image...%s"
-                     "Creating images for entry...%s"))))
-       (message msg "")
-       (narrow-to-region beg end)
-       (goto-char beg)
-       (org-format-latex
-        (concat org-latex-preview-ltxpng-directory (file-name-sans-extension
-                                                    (file-name-nondirectory
-                                                     buffer-file-name)))
-        default-directory 'overlays msg at 'forbuffer
-        org-latex-create-formula-image-program)
-       (message msg "done.  Use `C-c C-c' to remove images.")))))
-
-(defvar org-latex-regexps
-  '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
-    ;; ("$" "\\([      (]\\|^\\)\\(\\(\\([$]\\)\\([^   \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^       \r\n,.$]\\)\\4\\)\\)\\([        .,?;:'\")]\\|$\\)" 2 nil)
-    ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
-    ("$1" "\\([^$]\\|^\\)\\(\\$[^      \r\n,;.$]\\$\\)\\([-    .,?;:'\")\000]\\|$\\)" 2 nil)
-    ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^         \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^        \r\n,.$]\\)\\$\\)\\)\\([-       .,?;:'\")\000]\\|$\\)" 2 nil)
-    ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
-    ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
-    ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
-  "Regular expressions for matching embedded LaTeX.")
+    (user-error "Can't preview LaTeX fragment in a non-file buffer"))
+  (when (display-graphic-p)
+    (org-remove-latex-fragment-image-overlays)
+    (save-excursion
+      (save-restriction
+       (let (beg end at msg)
+         (cond
+          ((or (equal subtree '(16))
+               (not (save-excursion
+                      (re-search-backward org-outline-regexp-bol nil t))))
+           (setq beg (point-min) end (point-max)
+                 msg "Creating images for buffer...%s"))
+          ((equal subtree '(4))
+           (org-back-to-heading)
+           (setq beg (point) end (org-end-of-subtree t)
+                 msg "Creating images for subtree...%s"))
+          (t
+           (if (setq at (org-inside-LaTeX-fragment-p))
+               (goto-char (max (point-min) (- (cdr at) 2)))
+             (org-back-to-heading))
+           (setq beg (point) end (progn (outline-next-heading) (point))
+                 msg (if at "Creating image...%s"
+                       "Creating images for entry...%s"))))
+         (message msg "")
+         (narrow-to-region beg end)
+         (goto-char beg)
+         (org-format-latex
+          (concat org-latex-preview-ltxpng-directory (file-name-sans-extension
+                                                      (file-name-nondirectory
+                                                       buffer-file-name)))
+          default-directory 'overlays msg at 'forbuffer
+          org-latex-create-formula-image-program)
+         (message msg "done.  Use `C-c C-c' to remove images."))))))
 
-(defvar org-export-have-math nil) ;; dynamic scoping
 (defun org-format-latex (prefix &optional dir overlays msg at
                                forbuffer processing-type)
   "Replace LaTeX fragments with links to an image, and produce images.
@@ -17287,12 +18347,11 @@ Some of the options can be changed using the variable
         (absprefix (expand-file-name prefix dir))
         (todir (file-name-directory absprefix))
         (opt org-format-latex-options)
+        (optnew org-format-latex-options)
         (matchers (plist-get opt :matchers))
         (re-list org-latex-regexps)
-        (org-format-latex-header-extra
-         (plist-get (org-infile-export-plist) :latex-header-extra))
         (cnt 0) txt hash link beg end re e checkdir
-        executables-checked string
+        string
         m n block-type block linkfile movefile ov)
     ;; Check the different regular expressions
     (while (setq e (pop re-list))
@@ -17302,71 +18361,58 @@ Some of the options can be changed using the variable
        (goto-char (point-min))
        (while (re-search-forward re nil t)
          (when (and (or (not at) (equal (cdr at) (match-beginning n)))
-                    (not (get-text-property (match-beginning n)
-                                            'org-protected))
                     (or (not overlays)
                         (not (eq (get-char-property (match-beginning n)
                                                     'org-overlay-type)
                                  'org-latex-overlay))))
-           (setq org-export-have-math t)
            (cond
-            ((eq processing-type 'verbatim)
-             ;; Leave the text verbatim, just protect it
-             (add-text-properties (match-beginning n) (match-end n)
-                                  '(org-protected t)))
+            ((eq processing-type 'verbatim))
             ((eq processing-type 'mathjax)
-             ;; Prepare for MathJax processing
+             ;; Prepare for MathJax processing.
              (setq string (match-string n))
-             (if (member m '("$" "$1"))
-                 (save-excursion
-                   (delete-region (match-beginning n) (match-end n))
-                   (goto-char (match-beginning n))
-                   (insert (org-add-props (concat "\\(" (substring string 1 -1)
-                                                  "\\)")
-                               '(org-protected t))))
-               (add-text-properties (match-beginning n) (match-end n)
-                                    '(org-protected t))))
+             (when (member m '("$" "$1"))
+               (save-excursion
+                 (delete-region (match-beginning n) (match-end n))
+                 (goto-char (match-beginning n))
+                 (insert (concat "\\(" (substring string 1 -1) "\\)")))))
             ((or (eq processing-type 'dvipng)
                  (eq processing-type 'imagemagick))
-             ;; Process to an image
+             ;; Process to an image.
              (setq txt (match-string n)
                    beg (match-beginning n) end (match-end n)
                    cnt (1+ cnt))
-             (let (print-length print-level) ; make sure full list is printed
+             (let ((face (face-at-point))
+                   (fg (plist-get opt :foreground))
+                   (bg (plist-get opt :background))
+                   ;; Ensure full list is printed.
+                   print-length print-level)
+               (when forbuffer
+                 ;; Get the colors from the face at point.
+                 (goto-char beg)
+                 (when (eq fg 'auto)
+                   (setq fg (face-attribute face :foreground nil 'default)))
+                 (when (eq bg 'auto)
+                   (setq bg (face-attribute face :background nil 'default)))
+                 (setq optnew (copy-sequence opt))
+                 (plist-put optnew :foreground fg)
+                 (plist-put optnew :background bg))
                (setq hash (sha1 (prin1-to-string
                                  (list org-format-latex-header
-                                       org-format-latex-header-extra
-                                       org-export-latex-default-packages-alist
-                                       org-export-latex-packages-alist
+                                       org-latex-default-packages-alist
+                                       org-latex-packages-alist
                                        org-format-latex-options
-                                       forbuffer txt)))
+                                       forbuffer txt fg bg)))
                      linkfile (format "%s_%s.png" prefix hash)
                      movefile (format "%s_%s.png" absprefix hash)))
              (setq link (concat block "[[file:" linkfile "]]" block))
              (if msg (message msg cnt))
              (goto-char beg)
-             (unless checkdir ; make sure the directory exists
+             (unless checkdir        ; Ensure the directory exists.
                (setq checkdir t)
                (or (file-directory-p todir) (make-directory todir t)))
-             (cond
-              ((eq processing-type 'dvipng)
-               (unless executables-checked
-                 (org-check-external-command
-                  "latex" "needed to convert LaTeX fragments to images")
-                 (org-check-external-command
-                  "dvipng" "needed to convert LaTeX fragments to images")
-                 (setq executables-checked t))
-               (unless (file-exists-p movefile)
-                 (org-create-formula-image-with-dvipng
-                  txt movefile opt forbuffer)))
-              ((eq processing-type 'imagemagick)
-               (unless executables-checked
-                 (org-check-external-command
-                  "convert" "you need to install imagemagick")
-                 (setq executables-checked t))
-               (unless (file-exists-p movefile)
-                 (org-create-formula-image-with-imagemagick
-                  txt movefile opt forbuffer))))
+             (unless (file-exists-p movefile)
+               (org-create-formula-image
+                txt movefile optnew forbuffer processing-type))
              (if overlays
                  (progn
                    (mapc (lambda (o)
@@ -17396,10 +18442,8 @@ Some of the options can be changed using the variable
                                  (if block-type 'paragraph 'character))))))
             ((eq processing-type 'mathml)
              ;; Process to MathML
-             (unless executables-checked
-               (unless (save-match-data (org-format-latex-mathml-available-p))
-                 (error "LaTeX to MathML converter not configured"))
-               (setq executables-checked t))
+             (unless (save-match-data (org-format-latex-mathml-available-p))
+               (user-error "LaTeX to MathML converter not configured"))
              (setq txt (match-string n)
                    beg (match-beginning n) end (match-end n)
                    cnt (1+ cnt))
@@ -17409,7 +18453,7 @@ Some of the options can be changed using the variable
              (insert (org-format-latex-as-mathml
                       txt block-type prefix dir)))
             (t
-             (error "Unknown conversion type %s for latex fragments"
+             (error "Unknown conversion type %s for LaTeX fragments"
                     processing-type)))))))))
 
 (defun org-create-math-formula (latex-frag &optional mathml-file)
@@ -17425,7 +18469,7 @@ inspection."
                                   (buffer-substring-no-properties
                                    (region-beginning) (region-end)))))
                       (read-string "LaTeX Fragment: " frag nil frag))))
-  (unless latex-frag (error "Invalid latex-frag"))
+  (unless latex-frag (error "Invalid LaTeX fragment"))
   (let* ((tmp-in-file (file-relative-name
                       (make-temp-name (expand-file-name "ltxmathml-in"))))
         (ignore (write-region latex-frag nil tmp-in-file))
@@ -17440,7 +18484,7 @@ inspection."
         mathml shell-command-output)
     (when (org-called-interactively-p 'any)
       (unless (org-format-latex-mathml-available-p)
-       (error "LaTeX to MathML converter not configured")))
+       (user-error "LaTeX to MathML converter not configured")))
     (message "Running %s" cmd)
     (setq shell-command-output (shell-command-to-string cmd))
     (setq mathml
@@ -17497,14 +18541,57 @@ inspection."
                  'org-latex-src-embed-type (if latex-frag-type
                                                'paragraph 'character)))
       ;; Failed conversion.  Return the LaTeX fragment verbatim
-      (add-text-properties
-       0 (1- (length latex-frag)) '(org-protected t) latex-frag)
       latex-frag)))
 
+(defun org-create-formula-image (string tofile options buffer &optional type)
+  "Create an image from LaTeX source using dvipng or convert.
+This function calls either `org-create-formula-image-with-dvipng'
+or `org-create-formula-image-with-imagemagick' depending on the
+value of `org-latex-create-formula-image-program' or on the value
+of the optional TYPE variable.
+
+Note: ultimately these two function should be combined as they
+share a good deal of logic."
+  (org-check-external-command
+   "latex" "needed to convert LaTeX fragments to images")
+  (funcall
+   (case (or type org-latex-create-formula-image-program)
+     ('dvipng
+      (org-check-external-command
+       "dvipng" "needed to convert LaTeX fragments to images")
+      #'org-create-formula-image-with-dvipng)
+     ('imagemagick
+      (org-check-external-command
+       "convert" "you need to install imagemagick")
+      #'org-create-formula-image-with-imagemagick)
+     (t (error
+         "Invalid value of `org-latex-create-formula-image-program'")))
+   string tofile options buffer))
+
+(declare-function org-export-get-backend "ox" (name))
+(declare-function org-export--get-global-options "ox" (&optional backend))
+(declare-function org-export--get-inbuffer-options "ox" (&optional backend))
+(declare-function org-latex-guess-inputenc "ox-latex" (header))
+(declare-function org-latex-guess-babel-language "ox-latex" (header info))
+(defun org-create-formula--latex-header ()
+  "Return LaTeX header appropriate for previewing a LaTeX snippet."
+  (let ((info (org-combine-plists (org-export--get-global-options
+                                  (org-export-get-backend 'latex))
+                                 (org-export--get-inbuffer-options
+                                  (org-export-get-backend 'latex)))))
+    (org-latex-guess-babel-language
+     (org-latex-guess-inputenc
+      (org-splice-latex-header
+       org-format-latex-header
+       org-latex-default-packages-alist
+       org-latex-packages-alist t
+       (plist-get info :latex-header)))
+     info)))
+
 ;; This function borrows from Ganesh Swami's latex2png.el
 (defun org-create-formula-image-with-dvipng (string tofile options buffer)
   "This calls dvipng."
-  (require 'org-latex)
+  (require 'ox-latex)
   (let* ((tmpdir (if (featurep 'xemacs)
                     (temp-directory)
                   temporary-file-directory))
@@ -17522,17 +18609,14 @@ inspection."
                 "Black"))
         (bg (or (plist-get options (if buffer :background :html-background))
                 "Transparent")))
-    (if (eq fg 'default) (setq fg (org-dvipng-color :foreground)))
-    (if (eq bg 'default) (setq bg (org-dvipng-color :background)))
-    (with-temp-file texfile
-      (insert (org-splice-latex-header
-              org-format-latex-header
-              org-export-latex-default-packages-alist
-              org-export-latex-packages-alist t
-              org-format-latex-header-extra))
-      (insert "\n\\begin{document}\n" string "\n\\end{document}\n")
-      (require 'org-latex)
-      (org-export-latex-fix-inputenc))
+    (if (eq fg 'default) (setq fg (org-dvipng-color :foreground))
+      (unless (string= fg "Transparent") (setq fg (org-dvipng-color-format fg))))
+    (if (eq bg 'default) (setq bg (org-dvipng-color :background))
+      (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format bg))))
+    (let ((latex-header (org-create-formula--latex-header)))
+      (with-temp-file texfile
+       (insert latex-header)
+       (insert "\n\\begin{document}\n" string "\n\\end{document}\n")))
     (let ((dir default-directory))
       (condition-case nil
          (progn
@@ -17569,10 +18653,10 @@ inspection."
                  (delete-file (concat texfilebase e))))
        pngfile))))
 
-(defvar org-latex-to-pdf-process) ;; Defined in org-latex.el
+(declare-function org-latex-compile "ox-latex" (texfile &optional snippet))
 (defun org-create-formula-image-with-imagemagick (string tofile options buffer)
   "This calls convert, which is included into imagemagick."
-  (require 'org-latex)
+  (require 'ox-latex)
   (let* ((tmpdir (if (featurep 'xemacs)
                     (temp-directory)
                   temporary-file-directory))
@@ -17585,7 +18669,7 @@ inspection."
                   (font-height (face-font 'default))
                 (face-attribute 'default :height nil)))
         (scale (or (plist-get options (if buffer :scale :html-scale)) 1.0))
-        (dpi (number-to-string (* scale (floor (* 0.9 (if buffer fnh 140.))))))
+        (dpi (number-to-string (* scale (floor (if buffer fnh 120.)))))
         (fg (or (plist-get options (if buffer :foreground :html-foreground))
                 "black"))
         (bg (or (plist-get options (if buffer :background :html-background))
@@ -17594,54 +18678,19 @@ inspection."
       (setq fg (org-latex-color-format fg)))
     (if (eq bg 'default) (setq bg (org-latex-color :background))
       (setq bg (org-latex-color-format
-               (if (string= bg "Transparent")(setq bg "white")))))
-    (with-temp-file texfile
-      (insert (org-splice-latex-header
-              org-format-latex-header
-              org-export-latex-default-packages-alist
-              org-export-latex-packages-alist t
-              org-format-latex-header-extra))
-      (insert "\n\\begin{document}\n"
-             "\\definecolor{fg}{rgb}{" fg "}\n"
-             "\\definecolor{bg}{rgb}{" bg "}\n"
-             "\n\\pagecolor{bg}\n"
-             "\n{\\color{fg}\n"
-             string
-             "\n}\n"
-             "\n\\end{document}\n" )
-      (require 'org-latex)
-      (org-export-latex-fix-inputenc))
-    (let ((dir default-directory) cmd cmds latex-frags-cmds)
-      (condition-case nil
-         (progn
-           (cd tmpdir)
-           (setq cmds org-latex-to-pdf-process)
-           (while cmds
-             (setq latex-frags-cmds (pop cmds))
-             (if (listp latex-frags-cmds)
-                 (setq cmds nil)
-               (setq latex-frags-cmds (list (car org-latex-to-pdf-process)))))
-           (while latex-frags-cmds
-             (setq cmd (pop latex-frags-cmds))
-             (while (string-match "%b" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument texfile))
-                          t t cmd)))
-             (while (string-match "%f" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument (file-name-nondirectory texfile)))
-                          t t cmd)))
-             (while (string-match "%o" cmd)
-               (setq cmd (replace-match
-                          (save-match-data
-                            (shell-quote-argument (file-name-directory texfile)))
-                          t t cmd)))
-             (setq cmd (split-string cmd))
-             (eval (append (list 'call-process (pop cmd) nil nil nil) cmd))))
-       (error nil))
-      (cd dir))
+               (if (string= bg "Transparent") "white" bg))))
+    (let ((latex-header (org-create-formula--latex-header)))
+      (with-temp-file texfile
+       (insert latex-header)
+       (insert "\n\\begin{document}\n"
+               "\\definecolor{fg}{rgb}{" fg "}\n"
+               "\\definecolor{bg}{rgb}{" bg "}\n"
+               "\n\\pagecolor{bg}\n"
+               "\n{\\color{fg}\n"
+               string
+               "\n}\n"
+               "\n\\end{document}\n")))
+    (org-latex-compile texfile t)
     (if (not (file-exists-p pdffile))
        (progn (message "Failed to create pdf file from %s" texfile) nil)
       (condition-case nil
@@ -17652,7 +18701,7 @@ inspection."
                            "-antialias"
                            pdffile
                            "-quality" "100"
-                           ;;                      "-sharpen" "0x1.0"
+                           ;; "-sharpen" "0x1.0"
                            pngfile)
            (call-process "convert" nil nil nil
                          "-density" dpi
@@ -17660,7 +18709,7 @@ inspection."
                          "-antialias"
                          pdffile
                          "-quality" "100"
-                                       ;                         "-sharpen" "0x1.0"
+                         ;; "-sharpen" "0x1.0"
                          pngfile))
        (error nil))
       (if (not (file-exists-p pngfile))
@@ -17745,6 +18794,12 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
                                           ((eq attr :background) 'background))))
                   (color-values (face-attribute 'default attr nil))))))
 
+(defun org-dvipng-color-format (color-name)
+  "Convert COLOR-NAME to a RGB color value for dvipng."
+  (apply 'format "rgb %s %s %s"
+        (mapcar 'org-normalize-color
+                  (color-values color-name))))
+
 (defun org-latex-color (attr)
   "Return a RGB color for the LaTeX color package."
   (apply 'format "%s,%s,%s"
@@ -17766,8 +18821,9 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
   "Return string to be used as color value for an RGB component."
   (format "%g" (/ value 65535.0)))
 
-;; Image display
 
+\f
+;; Image display
 
 (defvar org-inline-image-overlays nil)
 (make-variable-buffer-local 'org-inline-image-overlays)
@@ -17781,7 +18837,8 @@ INCLUDE-LINKED is passed to `org-display-inline-images'."
        (org-remove-inline-images)
        (message "Inline image display turned off"))
     (org-display-inline-images include-linked)
-    (if org-inline-image-overlays
+    (if (and (org-called-interactively-p)
+            org-inline-image-overlays)
        (message "%d images displayed inline"
                 (length org-inline-image-overlays))
       (message "No images to display inline"))))
@@ -17805,35 +18862,54 @@ When REFRESH is set, refresh existing images between BEG and END.
 This will create new image displays only if necessary.
 BEG and END default to the buffer boundaries."
   (interactive "P")
-  (unless refresh
-    (org-remove-inline-images)
-    (if (fboundp 'clear-image-cache) (clear-image-cache)))
-  (save-excursion
-    (save-restriction
-      (widen)
-      (setq beg (or beg (point-min)) end (or end (point-max)))
-      (goto-char beg)
-      (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?"
-                       (substring (org-image-file-name-regexp) 0 -2)
-                       "\\)\\]" (if include-linked "" "\\]")))
-           old file ov img)
-       (while (re-search-forward re end t)
-         (setq old (get-char-property-and-overlay (match-beginning 1)
-                                                  'org-image-overlay))
-         (setq file (expand-file-name
-                     (concat (or (match-string 3) "") (match-string 4))))
-         (when (file-exists-p file)
-           (if (and (car-safe old) refresh)
-               (image-refresh (overlay-get (cdr old) 'display))
-             (setq img (save-match-data (create-image file)))
-             (when img
-               (setq ov (make-overlay (match-beginning 0) (match-end 0)))
-               (overlay-put ov 'display img)
-               (overlay-put ov 'face 'default)
-               (overlay-put ov 'org-image-overlay t)
-               (overlay-put ov 'modification-hooks
-                            (list 'org-display-inline-remove-overlay))
-               (push ov org-inline-image-overlays)))))))))
+  (when (display-graphic-p)
+    (unless refresh
+      (org-remove-inline-images)
+      (if (fboundp 'clear-image-cache) (clear-image-cache)))
+    (save-excursion
+      (save-restriction
+       (widen)
+       (setq beg (or beg (point-min)) end (or end (point-max)))
+       (goto-char beg)
+       (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?"
+                         (substring (org-image-file-name-regexp) 0 -2)
+                         "\\)\\]" (if include-linked "" "\\]")))
+             (case-fold-search t)
+             old file ov img type attrwidth width)
+         (while (re-search-forward re end t)
+           (setq old (get-char-property-and-overlay (match-beginning 1)
+                                                    'org-image-overlay)
+                 file (expand-file-name
+                       (concat (or (match-string 3) "") (match-string 4))))
+           (when (image-type-available-p 'imagemagick)
+             (setq attrwidth (if (or (listp org-image-actual-width)
+                                     (null org-image-actual-width))
+                                 (save-excursion
+                                   (save-match-data
+                                     (when (re-search-backward
+                                            "#\\+attr.*:width[ \t]+\\([^ ]+\\)"
+                                            (save-excursion
+                                              (re-search-backward "^[ \t]*$\\|\\`" nil t)) t)
+                                       (string-to-number (match-string 1))))))
+                   width (cond ((eq org-image-actual-width t) nil)
+                               ((null org-image-actual-width) attrwidth)
+                               ((numberp org-image-actual-width)
+                                org-image-actual-width)
+                               ((listp org-image-actual-width)
+                                (or attrwidth (car org-image-actual-width))))
+                   type (if width 'imagemagick)))
+           (when (file-exists-p file)
+             (if (and (car-safe old) refresh)
+                 (image-refresh (overlay-get (cdr old) 'display))
+               (setq img (save-match-data (create-image file type nil :width width)))
+               (when img
+                 (setq ov (make-overlay (match-beginning 0) (match-end 0)))
+                 (overlay-put ov 'display img)
+                 (overlay-put ov 'face 'default)
+                 (overlay-put ov 'org-image-overlay t)
+                 (overlay-put ov 'modification-hooks
+                              (list 'org-display-inline-remove-overlay))
+                 (push ov org-inline-image-overlays))))))))))
 
 (define-obsolete-function-alias
   'org-display-inline-modification-hook 'org-display-inline-remove-overlay "24.3")
@@ -17996,6 +19072,8 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-_" 'org-down-element)
 (org-defkey org-mode-map "\C-c\C-f" 'org-forward-heading-same-level)
 (org-defkey org-mode-map "\C-c\C-b" 'org-backward-heading-same-level)
+(org-defkey org-mode-map "\C-c\M-f" 'org-next-block)
+(org-defkey org-mode-map "\C-c\M-b" 'org-previous-block)
 (org-defkey org-mode-map "\C-c$"    'org-archive-subtree)
 (org-defkey org-mode-map "\C-c\C-x\C-s" 'org-advertized-archive-subtree)
 (org-defkey org-mode-map "\C-c\C-x\C-a" 'org-archive-subtree-default)
@@ -18003,6 +19081,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-xa" 'org-toggle-archive-tag)
 (org-defkey org-mode-map "\C-c\C-xA" 'org-archive-to-archive-sibling)
 (org-defkey org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer)
+(org-defkey org-mode-map "\C-c\C-xq" 'org-toggle-tags-groups)
 (org-defkey org-mode-map "\C-c\C-j" 'org-goto)
 (org-defkey org-mode-map "\C-c\C-t" 'org-todo)
 (org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command)
@@ -18010,6 +19089,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline)
 (org-defkey org-mode-map "\C-c;"    'org-toggle-comment)
 (org-defkey org-mode-map "\C-c\C-w" 'org-refile)
+(org-defkey org-mode-map "\C-c\M-w" 'org-copy)
 (org-defkey org-mode-map "\C-c/"    'org-sparse-tree)   ; Minor-mode reserved
 (org-defkey org-mode-map "\C-c\\"   'org-match-sparse-tree) ; Minor-mode res.
 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret)
@@ -18044,6 +19124,9 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
 (org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches)
 (org-defkey org-mode-map "\C-c#"    'org-update-statistics-cookies)
+(org-defkey org-mode-map [remap open-line] 'org-open-line)
+(org-defkey org-mode-map [remap forward-paragraph] 'org-forward-paragraph)
+(org-defkey org-mode-map [remap backward-paragraph] 'org-backward-paragraph)
 (org-defkey org-mode-map "\C-m"     'org-return)
 (org-defkey org-mode-map "\C-j"     'org-return-indent)
 (org-defkey org-mode-map "\C-c?"    'org-table-field-info)
@@ -18058,7 +19141,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-a" 'org-attach)
 (org-defkey org-mode-map "\C-c}"    'org-table-toggle-coordinate-overlays)
 (org-defkey org-mode-map "\C-c{"    'org-table-toggle-formula-debugger)
-(org-defkey org-mode-map "\C-c\C-e" 'org-export)
+(org-defkey org-mode-map "\C-c\C-e" 'org-export-dispatch)
 (org-defkey org-mode-map "\C-c:"    'org-toggle-fixed-width-section)
 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
 (org-defkey org-mode-map "\C-c\C-xf"    'org-footnote-action)
@@ -18089,6 +19172,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-x\\"   'org-toggle-pretty-entities)
 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
 (org-defkey org-mode-map "\C-c\C-xp"    'org-set-property)
+(org-defkey org-mode-map "\C-c\C-xP"    'org-set-property-and-value)
 (org-defkey org-mode-map "\C-c\C-xe"    'org-set-effort)
 (org-defkey org-mode-map "\C-c\C-xE"    'org-inc-effort)
 (org-defkey org-mode-map "\C-c\C-xo"    'org-toggle-ordered-property)
@@ -18123,6 +19207,8 @@ BEG and END default to the buffer boundaries."
     ("p" . (org-speed-move-safe 'outline-previous-visible-heading))
     ("f" . (org-speed-move-safe 'org-forward-heading-same-level))
     ("b" . (org-speed-move-safe 'org-backward-heading-same-level))
+    ("F" . org-next-block)
+    ("B" . org-previous-block)
     ("u" . (org-speed-move-safe 'outline-up-heading))
     ("j" . org-goto)
     ("g" . (org-refile t))
@@ -18130,6 +19216,7 @@ BEG and END default to the buffer boundaries."
     ("c" . org-cycle)
     ("C" . org-shifttab)
     (" " . org-display-outline-path)
+    ("s" . org-narrow-to-subtree)
     ("=" . org-columns)
     ("Outline Structure Editing")
     ("U" . org-shiftmetaup)
@@ -18143,7 +19230,7 @@ BEG and END default to the buffer boundaries."
     ("^" . org-sort)
     ("w" . org-refile)
     ("a" . org-archive-subtree-default-with-confirmation)
-    ("." . org-mark-subtree)
+    ("@" . org-mark-subtree)
     ("#" . org-toggle-comment)
     ("Clock Commands")
     ("I" . org-clock-in)
@@ -18190,7 +19277,7 @@ BEG and END default to the buffer boundaries."
   "Show the available speed commands."
   (interactive)
   (if (not org-use-speed-commands)
-      (error "Speed commands are not activated, customize `org-use-speed-commands'")
+      (user-error "Speed commands are not activated, customize `org-use-speed-commands'")
     (with-output-to-temp-buffer "*Help*"
       (princ "User-defined Speed commands\n===========================\n")
       (mapc 'org-print-speed-command org-speed-commands-user)
@@ -18338,7 +19425,7 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
        (when (or (memq invisible-at-point '(outline org-hide-block t))
                  (memq invisible-before-point '(outline org-hide-block t)))
          (if (eq org-catch-invisible-edits 'error)
-             (error "Editing in invisible areas is prohibited - make visible first"))
+             (user-error "Editing in invisible areas is prohibited, make them visible first"))
          (if (and org-custom-properties-overlays
                   (y-or-n-p "Display invisible properties in this buffer? "))
              (org-toggle-custom-properties-visibility)
@@ -18359,7 +19446,7 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
              (message "Unfolding invisible region around point before editing"))
             (t
              ;; Don't do the edit, make the user repeat it in full visibility
-             (error "Edit in invisible region aborted, repeat to confirm with text visible"))))))))
+             (user-error "Edit in invisible region aborted, repeat to confirm with text visible"))))))))
 
 (defun org-fix-tags-on-the-fly ()
   (when (and (equal (char-after (point-at-bol)) ?*)
@@ -18411,9 +19498,8 @@ because, in this case the deletion might narrow the column."
            (let ((pos (point))
                  (noalign (looking-at "[^|\n\r]*  |"))
                  (c org-table-may-need-update))
-             (replace-match (concat
-                             (substring (match-string 0) 1 -1)
-                             " |"))
+             (replace-match
+              (concat (substring (match-string 0) 1 -1) " |") nil t)
              (goto-char pos)
              ;; noalign: if there were two spaces at the end, this field
              ;; does not determine the width of the column.
@@ -18452,6 +19538,16 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names."
          (org-defkey map (vector 'remap old) new)
        (substitute-key-definition old new map global-map)))))
 
+(defun org-transpose-words ()
+  "Transpose words for Org.
+This uses the `org-mode-transpose-word-syntax-table' syntax
+table, which interprets characters in `org-emphasis-alist' as
+word constituents."
+  (interactive)
+  (with-syntax-table org-mode-transpose-word-syntax-table
+    (call-interactively 'transpose-words)))
+(org-remap org-mode-map 'transpose-words 'org-transpose-words)
+
 (when (eq org-enable-table-editor 'optimized)
   ;; If the user wants maximum table support, we need to hijack
   ;; some standard editing functions
@@ -18577,13 +19673,13 @@ See `org-ctrl-c-ctrl-c-hook' for more information.")
 
 (defun org-modifier-cursor-error ()
   "Throw an error, a modified cursor command was applied in wrong context."
-  (error "This command is active in special context like tables, headlines or items"))
+  (user-error "This command is active in special context like tables, headlines or items"))
 
 (defun org-shiftselect-error ()
   "Throw an error because Shift-Cursor command was applied in wrong context."
   (if (and (boundp 'shift-select-mode) shift-select-mode)
-      (error "To use shift-selection with Org-mode, customize `org-support-shift-select'")
-    (error "This command works only in special context like headlines or timestamps")))
+      (user-error "To use shift-selection with Org-mode, customize `org-support-shift-select'")
+    (user-error "This command works only in special context like headlines or timestamps")))
 
 (defun org-call-for-shift-select (cmd)
   (let ((this-command-keys-shift-translated t))
@@ -18591,9 +19687,9 @@ See `org-ctrl-c-ctrl-c-hook' for more information.")
 
 (defun org-shifttab (&optional arg)
   "Global visibility cycling or move to previous table field.
-Calls `org-cycle' with argument t, or `org-table-previous-field', depending
-on context.
-See the individual commands for more information."
+Call `org-table-previous-field' within a table.
+When ARG is nil, cycle globally through visibility states.
+When ARG is a numeric prefix, show contents of this level."
   (interactive "P")
   (cond
    ((org-at-table-p) (call-interactively 'org-table-previous-field))
@@ -18601,6 +19697,7 @@ See the individual commands for more information."
     (let ((arg2 (if org-odd-levels-only (1- (* 2 arg)) arg)))
       (message "Content view to level: %d" arg)
       (org-content (prefix-numeric-value arg2))
+      (org-cycle-show-empty-lines t)
       (setq org-cycle-global-status 'overview)))
    (t (call-interactively 'org-global-cycle))))
 
@@ -18649,7 +19746,7 @@ See the individual commands for more information."
    ((org-at-item-p) (call-interactively 'org-move-item-up))
    ((org-at-clock-log-p) (let ((org-clock-adjust-closest t))
                           (call-interactively 'org-timestamp-up)))
-   (t (org-modifier-cursor-error))))
+   (t (call-interactively 'org-drag-line-backward))))
 
 (defun org-shiftmetadown (&optional arg)
   "Move subtree down or insert table row.
@@ -18664,10 +19761,10 @@ See the individual commands for more information."
    ((org-at-item-p) (call-interactively 'org-move-item-down))
    ((org-at-clock-log-p) (let ((org-clock-adjust-closest t))
                           (call-interactively 'org-timestamp-down)))
-   (t (org-modifier-cursor-error))))
+   (t (call-interactively 'org-drag-line-forward))))
 
 (defsubst org-hidden-tree-error ()
-  (error
+  (user-error
    "Hidden subtree, open with TAB or use subtree command M-S-<left>/<right>"))
 
 (defun org-metaleft (&optional arg)
@@ -18757,18 +19854,6 @@ this function returns t, nil otherwise."
                (throw 'exit t))))
        nil))))
 
-(org-autoload "org-element" '(org-element-at-point org-element-type))
-
-(declare-function org-element-at-point "org-element" (&optional keep-trail))
-(declare-function org-element-type "org-element" (element))
-(declare-function org-element-contents "org-element" (element))
-(declare-function org-element-property "org-element" (property element))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion))
-(declare-function org-element-nested-p "org-element" (elem-a elem-b))
-(declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
-(declare-function org-element--parse-objects "org-element" (beg end acc restriction))
-(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
-
 (defun org-metaup (&optional arg)
   "Move subtree up or move table row up.
 Calls `org-move-subtree-up' or `org-table-move-row' or
@@ -18959,22 +20044,24 @@ Depending on context, this does one of the following:
     (org-call-for-shift-select 'backward-word))
    (t (org-shiftselect-error))))
 
-(defun org-shiftcontrolup ()
-  "Change timestamps synchronously up in CLOCK log lines."
-  (interactive)
+(defun org-shiftcontrolup (&optional n)
+  "Change timestamps synchronously up in CLOCK log lines.
+Optional argument N tells to change by that many units."
+  (interactive "P")
   (cond ((and (not org-support-shift-select)
              (org-at-clock-log-p)
              (org-at-timestamp-p t))
-        (org-clock-timestamps-up))
+        (org-clock-timestamps-up n))
        (t (org-shiftselect-error))))
 
-(defun org-shiftcontroldown ()
-  "Change timestamps synchronously down in CLOCK log lines."
-  (interactive)
+(defun org-shiftcontroldown (&optional n)
+  "Change timestamps synchronously down in CLOCK log lines.
+Optional argument N tells to change by that many units."
+  (interactive "P")
   (cond ((and (not org-support-shift-select)
              (org-at-clock-log-p)
              (org-at-timestamp-p t))
-        (org-clock-timestamps-down))
+        (org-clock-timestamps-down n))
        (t (org-shiftselect-error))))
 
 (defun org-ctrl-c-ret ()
@@ -19040,38 +20127,51 @@ See the individual commands for more information."
     (eq 'fixed-width (org-element-type (org-element-at-point)))))
 
 (defun org-edit-special (&optional arg)
-  "Call a special editor for the stuff at point.
+  "Call a special editor for the element at point.
 When at a table, call the formula editor with `org-table-edit-formulas'.
 When in a source code block, call `org-edit-src-code'.
 When in a fixed-width region, call `org-edit-fixed-width-region'.
-When in an #+include line, visit the included file.
+When at an #+INCLUDE keyword, visit the included file.
 On a link, call `ffap' to visit the link at point.
 Otherwise, return a user error."
-  (interactive)
-  ;; possibly prep session before editing source
-  (when (and (org-in-src-block-p) arg)
-    (let* ((info (org-babel-get-src-block-info))
-           (lang (nth 0 info))
-           (params (nth 2 info))
-           (session (cdr (assoc :session params))))
-      (when (and info session) ;; we are in a source-code block with a session
-        (funcall
-         (intern (concat "org-babel-prep-session:" lang)) session params))))
-  (cond ;; proceed with `org-edit-special'
-   ((save-excursion
-      (beginning-of-line 1)
-      (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
-    (find-file (org-trim (match-string 1))))
-   ((org-at-table.el-p) (org-edit-src-code))
-   ((or (org-at-table-p)
-       (save-excursion
-         (beginning-of-line 1)
-         (let ((case-fold-search )) (looking-at "[ \t]*#\\+tblfm:"))))
-    (call-interactively 'org-table-edit-formulas))
-   ((org-in-block-p '("src" "example" "latex" "html")) (org-edit-src-code))
-   ((org-in-fixed-width-region-p) (org-edit-fixed-width-region))
-   ((org-at-regexp-p org-any-link-re) (call-interactively 'ffap))
-   (t (user-error "No special environment to edit here"))))
+  (interactive "P")
+  (let ((element (org-element-at-point)))
+    (assert (not buffer-read-only) nil
+           "Buffer is read-only: %s" (buffer-name))
+    (case (org-element-type element)
+      (src-block
+       (if (not arg) (org-edit-src-code)
+         (let* ((info (org-babel-get-src-block-info))
+                (lang (nth 0 info))
+                (params (nth 2 info))
+                (session (cdr (assq :session params))))
+           (if (not session) (org-edit-src-code)
+             ;; At a src-block with a session and function called with
+             ;; an ARG: switch to the buffer related to the inferior
+             ;; process.
+             (switch-to-buffer
+             (funcall (intern (concat "org-babel-prep-session:" lang))
+                      session params))))))
+      (keyword
+       (if (member (org-element-property :key element) '("INCLUDE" "SETUPFILE"))
+           (find-file
+            (org-remove-double-quotes
+             (car (org-split-string (org-element-property :value element)))))
+         (user-error "No special environment to edit here")))
+      (table
+       (if (eq (org-element-property :type element) 'table.el)
+           (org-edit-src-code)
+         (call-interactively 'org-table-edit-formulas)))
+      ;; Only Org tables contain `table-row' type elements.
+      (table-row (call-interactively 'org-table-edit-formulas))
+      ((example-block export-block) (org-edit-src-code))
+      (fixed-width (org-edit-fixed-width-region))
+      (otherwise
+       ;; No notable element at point.  Though, we may be at a link,
+       ;; which is an object.  Thus, scan deeper.
+       (if (eq (org-element-type (org-element-context element)) 'link)
+          (call-interactively 'ffap)
+        (user-error "No special environment to edit here"))))))
 
 (defvar org-table-coordinate-overlays) ; defined in org-table.el
 (defun org-ctrl-c-ctrl-c (&optional arg)
@@ -19119,136 +20219,161 @@ This command does many different things, depending on context:
   evaluation requires confirmation.  Code block evaluation can be
   inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'."
   (interactive "P")
-  (let  ((org-enable-table-editor t))
-    (cond
-     ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
-         org-occur-highlights
-         org-latex-fragment-image-overlays)
-      (and (boundp 'org-clock-overlays) (org-clock-remove-overlays))
-      (org-remove-occur-highlights)
-      (org-remove-latex-fragment-image-overlays)
-      (message "Temporary highlights/overlays removed from current buffer"))
-     ((and (local-variable-p 'org-finish-function (current-buffer))
-          (fboundp org-finish-function))
-      (funcall org-finish-function))
-     ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
-     ((org-in-regexp org-ts-regexp-both)
-      (org-timestamp-change 0 'day))
-     ((or (looking-at org-property-start-re)
-         (org-at-property-p))
-      (call-interactively 'org-property-action))
-     ((org-at-target-p) (call-interactively 'org-update-radio-target-regexp))
-     ((and (org-in-regexp "\\[\\([0-9]*%\\|[0-9]*/[0-9]*\\)\\]")
-          (or (org-at-heading-p) (org-at-item-p)))
-      (call-interactively 'org-update-statistics-cookies))
-     ((org-at-heading-p) (call-interactively 'org-set-tags))
-     ((org-at-table.el-p)
-      (message "Use C-c ' to edit table.el tables"))
-     ((org-at-table-p)
-      (org-table-maybe-eval-formula)
-      (if arg
-         (call-interactively 'org-table-recalculate)
-       (org-table-maybe-recalculate-line))
-      (call-interactively 'org-table-align)
-      (orgtbl-send-table 'maybe))
-     ((or (org-footnote-at-reference-p)
-         (org-footnote-at-definition-p))
-      (call-interactively 'org-footnote-action))
-     ((org-at-item-checkbox-p)
-      ;; Cursor at a checkbox: repair list and update checkboxes.  Send
-      ;; list only if at top item.
-      (let* ((cbox (match-string 1))
-            (struct (org-list-struct))
-            (old-struct (copy-tree struct))
-            (parents (org-list-parents-alist struct))
-            (orderedp (org-entry-get nil "ORDERED"))
-            (firstp (= (org-list-get-top-point struct) (point-at-bol)))
-            block-item)
-       ;; Use a light version of `org-toggle-checkbox' to avoid
-       ;; computing list structure twice.
-       (let ((new-box (cond
-                       ((equal arg '(16)) "[-]")
-                       ((equal arg '(4)) nil)
-                       ((equal "[X]" cbox) "[ ]")
-                       (t "[X]"))))
-         (if (and firstp arg)
-             ;; If at first item of sub-list, remove check-box from
-             ;; every item at the same level.
-             (mapc
-              (lambda (pos) (org-list-set-checkbox pos struct new-box))
-              (org-list-get-all-items
-               (point-at-bol) struct (org-list-prevs-alist struct)))
-           (org-list-set-checkbox (point-at-bol) struct new-box)))
-       ;; Replicate `org-list-write-struct', while grabbing a return
-       ;; value from `org-list-struct-fix-box'.
-       (org-list-struct-fix-ind struct parents 2)
-       (org-list-struct-fix-item-end struct)
-       (let ((prevs (org-list-prevs-alist struct)))
-         (org-list-struct-fix-bul struct prevs)
-         (org-list-struct-fix-ind struct parents)
-         (setq block-item
-               (org-list-struct-fix-box struct parents prevs orderedp)))
-       (if (equal struct old-struct)
-           (user-error "Cannot toggle this checkbox (unchecked subitems?)")
-         (org-list-struct-apply-struct struct old-struct)
-         (org-update-checkbox-count-maybe))
-       (when block-item
-         (message
-          "Checkboxes were removed due to unchecked box at line %d"
-          (org-current-line block-item)))
-       (when firstp (org-list-send-list 'maybe))))
-     ((org-at-item-p)
-      ;; Cursor at an item: repair list.  Do checkbox related actions
-      ;; only if function was called with an argument.  Send list only
-      ;; if at top item.
-      (let* ((struct (org-list-struct))
-            (firstp (= (org-list-get-top-point struct) (point-at-bol)))
-            old-struct)
-       (when arg
-         (setq old-struct (copy-tree struct))
-         (if firstp
-             ;; If at first item of sub-list, add check-box to every
-             ;; item at the same level.
-             (mapc
-              (lambda (pos)
-                (unless (org-list-get-checkbox pos struct)
-                  (org-list-set-checkbox pos struct "[ ]")))
-              (org-list-get-all-items
-               (point-at-bol) struct (org-list-prevs-alist struct)))
-           (org-list-set-checkbox (point-at-bol) struct "[ ]")))
-       (org-list-write-struct
-        struct (org-list-parents-alist struct) old-struct)
-       (when arg (org-update-checkbox-count-maybe))
-       (when firstp (org-list-send-list 'maybe))))
-     ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re))
-      ;; Dynamic block
-      (beginning-of-line 1)
-      (save-excursion (org-update-dblock)))
-     ((save-excursion
-       (let ((case-fold-search t))
-         (beginning-of-line 1)
-         (looking-at "[ \t]*#\\+\\([a-z]+\\)")))
-      (cond
-       ((or (equal (match-string 1) "TBLFM")
-           (equal (match-string 1) "tblfm"))
-       ;; Recalculate the table before this line
-       (save-excursion
-         (beginning-of-line 1)
-         (skip-chars-backward " \r\n\t")
-         (if (org-at-table-p)
-             (org-call-with-arg 'org-table-recalculate (or arg t)))))
-       (t
-       (let ((org-inhibit-startup-visibility-stuff t)
-             (org-startup-align-all-tables nil))
-         (when (boundp 'org-table-coordinate-overlays)
-           (mapc 'delete-overlay org-table-coordinate-overlays)
-           (setq org-table-coordinate-overlays nil))
-         (org-save-outline-visibility 'use-markers (org-mode-restart)))
-       (message "Local setup has been refreshed"))))
-     ((org-clock-update-time-maybe))
-     (t
-      (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
-         (error "C-c C-c can do nothing useful at this location"))))))
+  (cond
+   ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
+       org-occur-highlights
+       org-latex-fragment-image-overlays)
+    (and (boundp 'org-clock-overlays) (org-clock-remove-overlays))
+    (org-remove-occur-highlights)
+    (org-remove-latex-fragment-image-overlays)
+    (message "Temporary highlights/overlays removed from current buffer"))
+   ((and (local-variable-p 'org-finish-function (current-buffer))
+        (fboundp org-finish-function))
+    (funcall org-finish-function))
+   ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
+   (t
+    (let* ((context (org-element-context)) (type (org-element-type context)))
+      ;; Test if point is within a blank line.
+      (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
+         (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
+             (user-error "C-c C-c can do nothing useful at this location"))
+       ;; When at a link, act according to the parent instead.
+       (when (eq type 'link)
+         (setq context (org-element-property :parent context))
+         (setq type (org-element-type context)))
+       ;; For convenience: at the first line of a paragraph on the
+       ;; same line as an item, apply function on that item instead.
+       (when (eq type 'paragraph)
+         (let ((parent (org-element-property :parent context)))
+           (when (and (eq (org-element-type parent) 'item)
+                      (= (point-at-bol) (org-element-property :begin parent)))
+             (setq context parent type 'item))))
+       ;; Act according to type of element or object at point.
+       (case type
+         (clock (org-clock-update-time-maybe))
+         (dynamic-block
+          (save-excursion
+            (goto-char (org-element-property :post-affiliated context))
+            (org-update-dblock)))
+         (footnote-definition
+          (goto-char (org-element-property :post-affiliated context))
+          (call-interactively 'org-footnote-action))
+         (footnote-reference (call-interactively 'org-footnote-action))
+         ((headline inlinetask)
+          (save-excursion (goto-char (org-element-property :begin context))
+                          (call-interactively 'org-set-tags)))
+         (item
+          ;; At an item: a double C-u set checkbox to "[-]"
+          ;; unconditionally, whereas a single one will toggle its
+          ;; presence.  Without an universal argument, if the item
+          ;; has a checkbox, toggle it.  Otherwise repair the list.
+          (let* ((box (org-element-property :checkbox context))
+                 (struct (org-element-property :structure context))
+                 (old-struct (copy-tree struct))
+                 (parents (org-list-parents-alist struct))
+                 (prevs (org-list-prevs-alist struct))
+                 (orderedp (org-not-nil (org-entry-get nil "ORDERED"))))
+            (org-list-set-checkbox
+             (org-element-property :begin context) struct
+             (cond ((equal arg '(16)) "[-]")
+                   ((and (not box) (equal arg '(4))) "[ ]")
+                   ((or (not box) (equal arg '(4))) nil)
+                   ((eq box 'on) "[ ]")
+                   (t "[X]")))
+            ;; Mimic `org-list-write-struct' but with grabbing
+            ;; a return value from `org-list-struct-fix-box'.
+            (org-list-struct-fix-ind struct parents 2)
+            (org-list-struct-fix-item-end struct)
+            (org-list-struct-fix-bul struct prevs)
+            (org-list-struct-fix-ind struct parents)
+            (let ((block-item
+                   (org-list-struct-fix-box struct parents prevs orderedp)))
+              (if (and box (equal struct old-struct))
+                  (if (equal arg '(16))
+                      (message "Checkboxes already reset")
+                    (user-error "Cannot toggle this checkbox: %s"
+                                (if (eq box 'on)
+                                    "all subitems checked"
+                                  "unchecked subitems")))
+                (org-list-struct-apply-struct struct old-struct)
+                (org-update-checkbox-count-maybe))
+              (when block-item
+                (message "Checkboxes were removed due to empty box at line %d"
+                         (org-current-line block-item))))))
+         (keyword
+          (let ((org-inhibit-startup-visibility-stuff t)
+                (org-startup-align-all-tables nil))
+            (when (boundp 'org-table-coordinate-overlays)
+              (mapc 'delete-overlay org-table-coordinate-overlays)
+              (setq org-table-coordinate-overlays nil))
+            (org-save-outline-visibility 'use-markers (org-mode-restart)))
+          (message "Local setup has been refreshed"))
+         (plain-list
+          ;; At a plain list, with a double C-u argument, set
+          ;; checkboxes of each item to "[-]", whereas a single one
+          ;; will toggle their presence according to the state of the
+          ;; first item in the list.  Without an argument, repair the
+          ;; list.
+          (let* ((begin (org-element-property :contents-begin context))
+                 (beginm (move-marker (make-marker) begin))
+                 (struct (org-element-property :structure context))
+                 (old-struct (copy-tree struct))
+                 (first-box (save-excursion
+                              (goto-char begin)
+                              (looking-at org-list-full-item-re)
+                              (match-string-no-properties 3)))
+                 (new-box (cond ((equal arg '(16)) "[-]")
+                                ((equal arg '(4)) (unless first-box "[ ]"))
+                                ((equal first-box "[X]") "[ ]")
+                                (t "[X]"))))
+            (cond
+             (arg
+              (mapc (lambda (pos) (org-list-set-checkbox pos struct new-box))
+                    (org-list-get-all-items
+                     begin struct (org-list-prevs-alist struct))))
+             ((and first-box (eq (point) begin))
+              ;; For convenience, when point is at bol on the first
+              ;; item of the list and no argument is provided, simply
+              ;; toggle checkbox of that item, if any.
+              (org-list-set-checkbox begin struct new-box)))
+            (org-list-write-struct
+             struct (org-list-parents-alist struct) old-struct)
+            (org-update-checkbox-count-maybe)
+            (save-excursion (goto-char beginm) (org-list-send-list 'maybe))))
+         ((property-drawer node-property)
+          (call-interactively 'org-property-action))
+         ((radio-target target)
+          (call-interactively 'org-update-radio-target-regexp))
+         (statistics-cookie
+          (call-interactively 'org-update-statistics-cookies))
+         ((table table-cell table-row)
+          ;; At a table, recalculate every field and align it.  Also
+          ;; send the table if necessary.  If the table has
+          ;; a `table.el' type, just give up.  At a table row or
+          ;; cell, maybe recalculate line but always align table.
+          (if (eq (org-element-property :type context) 'table.el)
+              (message "Use C-c ' to edit table.el tables")
+            (let ((org-enable-table-editor t))
+              (if (or (eq type 'table)
+                      ;; Check if point is at a TBLFM line.
+                      (and (eq type 'table-row)
+                           (= (point) (org-element-property :end context))))
+                  (save-excursion
+                    (if (org-at-TBLFM-p)
+                        (progn (require 'org-table)
+                               (org-table-calc-current-TBLFM))
+                      (goto-char (org-element-property :contents-begin context))
+                      (org-call-with-arg 'org-table-recalculate (or arg t))
+                      (orgtbl-send-table 'maybe)))
+                (org-table-maybe-eval-formula)
+                (cond (arg (call-interactively 'org-table-recalculate))
+                      ((org-table-maybe-recalculate-line))
+                      (t (org-table-align)))))))
+         (timestamp (org-timestamp-change 0 'day))
+         (otherwise
+          (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
+              (user-error
+               "C-c C-c can do nothing useful at this location")))))))))
 
 (defun org-mode-restart ()
   "Restart Org-mode, to scan again for special lines.
@@ -19267,6 +20392,18 @@ Also updates the keyword regular expressions."
     (let ((org-note-abort t))
       (funcall org-finish-function))))
 
+(defun org-open-line (n)
+  "Insert a new row in tables, call `open-line' elsewhere.
+If `org-special-ctrl-o' is nil, just call `open-line' everywhere."
+  (interactive "*p")
+  (cond
+   ((not org-special-ctrl-o)
+    (open-line n))
+   ((org-at-table-p)
+    (org-table-insert-row))
+   (t
+    (open-line n))))
+
 (defun org-return (&optional indent)
   "Goto next table row or insert a newline.
 Calls `org-table-next-row' or `newline', depending on context.
@@ -19347,13 +20484,13 @@ Calls `org-table-insert-hline', `org-toggle-item', or
   "Convert headings or normal lines to items, items to normal lines.
 If there is no active region, only the current line is considered.
 
-If the first non blank line in the region is an headline, convert
+If the first non blank line in the region is a headline, convert
 all headlines to items, shifting text accordingly.
 
 If it is an item, convert all items to normal lines.
 
-If it is normal text, change region into an item.  With a prefix
-argument ARG, change each line in region into an item."
+If it is normal text, change region into a list of items.
+With a prefix argument ARG, change the region in a single item."
   (interactive "P")
   (let ((shift-text
         (function
@@ -19446,19 +20583,10 @@ argument ARG, change each line in region into an item."
                 (funcall shift-text
                          (+ start-ind (* (1+ delta) bul-len))
                          (min end section-end)))))))
-       ;; Case 3. Normal line with ARG: turn each non-item line into
-       ;;         an item.
-       (arg
-        (while (< (point) end)
-          (unless (or (org-at-heading-p) (org-at-item-p))
-            (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
-                (replace-match
-                 (concat "\\1" (org-list-bullet-string "-") "\\2"))))
-          (forward-line)))
-       ;; Case 4. Normal line without ARG: make the first line of
-       ;;         region an item, and shift indentation of others
-       ;;         lines to set them as item's body.
-       (t (let* ((bul (org-list-bullet-string "-"))
+       ;; Case 3. Normal line with ARG: make the first line of region
+       ;;         an item, and shift indentation of others lines to
+       ;;         set them as item's body.
+       (arg (let* ((bul (org-list-bullet-string "-"))
                  (bul-len (length bul))
                  (ref-ind (org-get-indentation)))
             (skip-chars-forward " \t")
@@ -19471,29 +20599,40 @@ argument ARG, change each line in region into an item."
                        (+ ref-ind bul-len)
                        (min end (save-excursion (or (outline-next-heading)
                                                     (point)))))
-              (forward-line)))))))))
+              (forward-line))))
+       ;; Case 4. Normal line without ARG: turn each non-item line
+       ;;         into an item.
+       (t
+        (while (< (point) end)
+          (unless (or (org-at-heading-p) (org-at-item-p))
+            (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
+                (replace-match
+                 (concat "\\1" (org-list-bullet-string "-") "\\2"))))
+          (forward-line))))))))
 
 (defun org-toggle-heading (&optional nstars)
   "Convert headings to normal text, or items or text to headings.
-If there is no active region, only the current line is considered.
+If there is no active region, only convert the current line.
 
 With a \\[universal-argument] prefix, convert the whole list at
 point into heading.
 
 In a region:
 
-- If the first non blank line is an headline, remove the stars
+- If the first non blank line is a headline, remove the stars
   from all headlines in the region.
 
-- If it is a normal line turn each and every normal line (i.e. not an
-  heading or an item) in the region into a heading.
+- If it is a normal line, turn each and every normal line (i.e.,
+  not an heading or an item) in the region into headings.  If you
+  want to convert only the first line of this region, use one
+  universal prefix argument.
 
 - If it is a plain list item, turn all plain list items into headings.
 
 When converting a line into a heading, the number of stars is chosen
 such that the lines become children of the current entry.  However,
-when a prefix argument is given, its value determines the number of
-stars to add."
+when a numeric prefix argument is given, its value determines the
+number of stars to add."
   (interactive "P")
   (let ((skip-blanks
         (function
@@ -19511,7 +20650,7 @@ stars to add."
     ;; do not consider the last line to be in the region.
 
     (when (and current-prefix-arg (org-at-item-p))
-      (if (equal current-prefix-arg '(4)) (setq current-prefix-arg 1))
+      (if (listp current-prefix-arg) (setq current-prefix-arg 1))
       (org-mark-element))
 
     (if (org-region-active-p)
@@ -19537,10 +20676,9 @@ stars to add."
        ;;         One star will be added by `org-list-to-subtree'.
        ((org-at-item-p)
         (let* ((stars (make-string
-                       (if nstars
-                           ;; subtract the star that will be added again by
-                           ;; `org-list-to-subtree'
-                           (1- (prefix-numeric-value current-prefix-arg))
+                       ;; subtract the star that will be added again by
+                       ;; `org-list-to-subtree'
+                       (if (numberp nstars) (1- nstars)
                          (or (org-current-level) 0))
                        ?*))
                (add-stars
@@ -19564,18 +20702,17 @@ stars to add."
             (forward-line))))
        ;; Case 3. Started at normal text: make every line an heading,
        ;;         skipping headlines and items.
-       (t (let* ((stars (make-string
-                         (if nstars
-                             (prefix-numeric-value current-prefix-arg)
-                           (or (org-current-level) 0))
-                         ?*))
+       (t (let* ((stars
+                  (make-string
+                   (if (numberp nstars) nstars (or (org-current-level) 0)) ?*))
                  (add-stars
                   (cond (nstars "")                ; stars from prefix only
                         ((equal stars "") "*")     ; before first heading
                         (org-odd-levels-only "**") ; inside heading, odd
                         (t "*")))                  ; inside heading, oddeven
-                 (rpl (concat stars add-stars " ")))
-            (while (< (point) end)
+                 (rpl (concat stars add-stars " "))
+                 (lend (if (listp nstars) (save-excursion (end-of-line) (point)))))
+            (while (< (point) (if (equal nstars '(4)) lend end))
               (when (and (not (or (org-at-heading-p) (org-at-item-p) (org-at-comment-p)))
                          (looking-at "\\([ \t]*\\)\\(\\S-\\)"))
                 (replace-match (concat rpl (match-string 2))) (setq toggled t))
@@ -19584,16 +20721,22 @@ stars to add."
 
 (defun org-meta-return (&optional arg)
   "Insert a new heading or wrap a region in a table.
-Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
-See the individual commands for more information."
+Calls `org-insert-heading' or `org-table-wrap-region', depending
+on context.  See the individual commands for more information."
   (interactive "P")
-  (cond
-   ((run-hook-with-args-until-success 'org-metareturn-hook))
-   ((or (org-at-drawer-p) (org-at-property-p))
-    (newline-and-indent))
-   ((org-at-table-p)
-    (call-interactively 'org-table-wrap-region))
-   (t (call-interactively 'org-insert-heading))))
+  (org-check-before-invisible-edit 'insert)
+  (or (run-hook-with-args-until-success 'org-metareturn-hook)
+      (let* ((element (org-element-at-point))
+             (type (org-element-type element)))
+        (when (eq type 'table-row)
+          (setq element (org-element-property :parent element))
+          (setq type 'table))
+        (if (and (eq type 'table)
+                 (eq (org-element-property :type element) 'org)
+                 (>= (point) (org-element-property :contents-begin element))
+                 (< (point) (org-element-property :contents-end element)))
+            (call-interactively 'org-table-wrap-region)
+          (call-interactively 'org-insert-heading)))))
 
 ;;; Menu entries
 
@@ -19826,7 +20969,7 @@ See the individual commands for more information."
      ["Timeline" org-timeline t]
      ["Tags/Property tree" org-match-sparse-tree t])
     "--"
-    ["Export/Publish..." org-export t]
+    ["Export/Publish..." org-export-dispatch t]
     ("LaTeX"
      ["Org CDLaTeX mode" org-cdlatex-mode :style toggle
       :selected org-cdlatex-mode]
@@ -19836,8 +20979,7 @@ See the individual commands for more information."
       (org-inside-LaTeX-fragment-p)]
      ["Insert citation" org-reftex-citation t]
      "--"
-     ["Template for BEAMER" (progn (require 'org-beamer)
-                                  (org-insert-beamer-options-template)) t])
+     ["Template for BEAMER" (org-beamer-insert-options-template) t])
     "--"
     ("MobileOrg"
      ["Push Files and Views" org-mobile-push t]
@@ -19952,55 +21094,63 @@ Your bug report will be posted to the Org-mode mailing list.
 (defun org-require-autoloaded-modules ()
   (interactive)
   (mapc 'require
-       '(org-agenda org-archive org-ascii org-attach org-clock org-colview
-                    org-docbook org-exp org-html org-icalendar
-                    org-id org-latex
-                    org-publish org-remember org-table
-                    org-timer org-xoxo)))
+       '(org-agenda org-archive org-attach org-clock org-colview org-id
+                    org-table org-timer)))
 
 ;;;###autoload
 (defun org-reload (&optional uncompiled)
   "Reload all org lisp files.
 With prefix arg UNCOMPILED, load the uncompiled versions."
   (interactive "P")
-  (require 'find-func)
-  (let* ((file-re "^org\\(-.*\\)?\\.el")
-        (dir-org (file-name-directory (org-find-library-dir "org")))
-        (dir-org-contrib (ignore-errors
-                           (file-name-directory
-                            (org-find-library-dir "org-contribdir"))))
-        (babel-files
-         (mapcar (lambda (el) (concat "ob" (when el (format "-%s" el)) ".el"))
-                 (append (list nil "comint" "eval" "exp" "keys"
-                               "lob" "ref" "table" "tangle")
-                         (delq nil
-                               (mapcar
-                                (lambda (lang)
-                                  (when (cdr lang) (symbol-name (car lang))))
-                                org-babel-load-languages)))))
-        (files
-         (append  babel-files
-                  (and dir-org-contrib
-                       (directory-files dir-org-contrib t file-re))
-                  (directory-files dir-org t file-re)))
-        (remove-re (concat (if (featurep 'xemacs)
-                               "org-colview" "org-colview-xemacs")
-                           "\\'")))
-    (setq files (mapcar 'file-name-sans-extension files))
-    (setq files (mapcar
-                (lambda (x) (if (string-match remove-re x) nil x))
-                files))
-    (setq files (delq nil files))
-    (mapc
-     (lambda (f)
-       (when (featurep (intern (file-name-nondirectory f)))
-        (if (and (not uncompiled)
-                 (file-exists-p (concat f ".elc")))
-            (load (concat f ".elc") nil nil 'nosuffix)
-          (load (concat f ".el") nil nil 'nosuffix))))
-     files)
-    (load (concat dir-org "org-version.el") 'noerror nil 'nosuffix))
-  (org-version nil 'full 'message))
+  (require 'loadhist)
+  (let* ((org-dir     (org-find-library-dir "org"))
+        (contrib-dir (or (org-find-library-dir "org-contribdir") org-dir))
+        (feature-re "^\\(org\\|ob\\|ox\\)\\(-.*\\)?")
+        (remove-re (mapconcat 'identity
+                              (mapcar (lambda (f) (concat "^" f "$"))
+                                      (list (if (featurep 'xemacs)
+                                                "org-colview"
+                                              "org-colview-xemacs")
+                                            "org" "org-loaddefs" "org-version"))
+                              "\\|"))
+        (feats (delete-dups
+                (mapcar 'file-name-sans-extension
+                        (mapcar 'file-name-nondirectory
+                                (delq nil
+                                      (mapcar 'feature-file
+                                              features))))))
+        (lfeat (append
+                (sort
+                 (setq feats
+                       (delq nil (mapcar
+                                  (lambda (f)
+                                    (if (and (string-match feature-re f)
+                                             (not (string-match remove-re f)))
+                                        f nil))
+                                  feats)))
+                 'string-lessp)
+                (list "org-version" "org")))
+        (load-suffixes (when (boundp 'load-suffixes) load-suffixes))
+        (load-suffixes (if uncompiled (reverse load-suffixes) load-suffixes))
+        load-uncore load-misses)
+    (setq load-misses
+         (delq 't
+               (mapcar (lambda (f)
+                         (or (org-load-noerror-mustsuffix (concat org-dir f))
+                             (and (string= org-dir contrib-dir)
+                                  (org-load-noerror-mustsuffix (concat contrib-dir f)))
+                             (and (org-load-noerror-mustsuffix (concat (org-find-library-dir f) f))
+                                  (add-to-list 'load-uncore f 'append)
+                                  't)
+                             f))
+                       lfeat)))
+    (if load-uncore
+       (message "The following feature%s found in load-path, please check if that's correct:\n%s"
+                (if (> (length load-uncore) 1) "s were" " was") load-uncore))
+    (if load-misses
+       (message "Some error occurred while reloading Org feature%s\n%s\nPlease check *Messages*!\n%s"
+                (if (> (length load-misses) 1) "s" "") load-misses (org-version nil 'full))
+      (message "Successfully reloaded Org\n%s" (org-version nil 'full)))))
 
 ;;;###autoload
 (defun org-customize ()
@@ -20088,7 +21238,10 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
 
 (defun org-in-verbatim-emphasis ()
   (save-match-data
-    (and (org-in-regexp org-emph-re 2) (member (match-string 3) '("=" "~")))))
+    (and (org-in-regexp org-emph-re 2)
+        (>= (point) (match-beginning 3))
+        (<= (point) (match-end 4))
+        (member (match-string 3) '("=" "~")))))
 
 (defun org-goto-marker-or-bmk (marker &optional bookmark)
   "Go to MARKER, widen if necessary.  When marker is not live, try BOOKMARK."
@@ -20543,6 +21696,17 @@ block from point."
              names))
       nil)))
 
+(defun org-in-drawer-p ()
+  "Is point within a drawer?"
+  (save-match-data
+    (let ((case-fold-search t)
+         (lim-up (save-excursion (outline-previous-heading)))
+         (lim-down (save-excursion (outline-next-heading))))
+      (org-between-regexps-p
+       (concat "^[ \t]*:" (regexp-opt org-drawers) ":")
+       "^[ \t]*:end:.*$"
+       lim-up lim-down))))
+
 (defun org-occur-in-agenda-files (regexp &optional nlines)
   "Call `multi-occur' with buffers for all agenda files."
   (interactive "sOrg-files matching: \np")
@@ -20598,11 +21762,36 @@ for the search purpose."
                (error "Unable to create a link to here"))))
     (org-occur-in-agenda-files (regexp-quote link))))
 
-(defun org-uniquify (list)
-  "Remove duplicate elements from LIST."
-  (let (res)
-    (mapc (lambda (x) (add-to-list 'res x 'append)) list)
-    res))
+(defun org-reverse-string (string)
+  "Return the reverse of STRING."
+  (apply 'string (reverse (string-to-list string))))
+
+(defsubst org-uniquify (list)
+  "Non-destructively remove duplicate elements from LIST."
+  (let ((res (copy-sequence list))) (delete-dups res)))
+
+(defun org-uniquify-alist (alist)
+  "Merge elements of ALIST with the same key.
+
+For example, in this alist:
+
+\(org-uniquify-alist '((a 1) (b 2) (a 3)))
+  => '((a 1 3) (b 2))
+
+merge (a 1) and (a 3) into (a 1 3).
+
+The function returns the new ALIST."
+  (let (rtn)
+    (mapc
+     (lambda (e)
+       (let (n)
+        (if (not (assoc (car e) rtn))
+            (push e rtn)
+          (setq n (cons (car e) (append (cdr (assoc (car e) rtn)) (cdr e))))
+          (setq rtn (assq-delete-all (car e) rtn))
+          (push n rtn))))
+         alist)
+    rtn))
 
 (defun org-delete-all (elts list)
   "Remove all elements in ELTS from LIST."
@@ -20649,6 +21838,20 @@ Taken from `reduce' in cl-seq.el with all keyword arguments but
       (setq cl-accum (funcall cl-func cl-accum (pop cl-seq))))
     cl-accum))
 
+(defun org-every (pred seq)
+  "Return true if PREDICATE is true of every element of SEQ.
+Adapted from `every' in cl.el."
+  (catch 'org-every
+    (mapc (lambda (e) (unless (funcall pred e) (throw 'org-every nil))) seq)
+    t))
+
+(defun org-some (pred seq)
+  "Return true if PREDICATE is true of any element of SEQ.
+Adapted from `some' in cl.el."
+  (catch 'org-some
+    (mapc (lambda (e) (when (funcall pred e) (throw 'org-some t))) seq)
+    nil))
+
 (defun org-back-over-empty-lines ()
   "Move backwards over whitespace, to the beginning of the first empty line.
 Returns the number of empty lines passed."
@@ -20764,21 +21967,31 @@ If EXTENSIONS is given, only match these."
   (save-match-data
     (string-match (org-image-file-name-regexp extensions) file)))
 
-(defun org-get-cursor-date ()
+(defun org-get-cursor-date (&optional with-time)
   "Return the date at cursor in as a time.
 This works in the calendar and in the agenda, anywhere else it just
-returns the current time."
-  (let (date day defd)
+returns the current time.
+If WITH-TIME is non-nil, returns the time of the event at point (in
+the agenda) or the current time of the day."
+  (let (date day defd tp tm hod mod)
+    (when with-time
+      (setq tp (get-text-property (point) 'time))
+      (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp))
+       (setq hod (string-to-number (match-string 1 tp))
+             mod (string-to-number (match-string 2 tp))))
+      (or tp (setq hod (nth 2 (decode-time (current-time)))
+                  mod (nth 1 (decode-time (current-time))))))
     (cond
      ((eq major-mode 'calendar-mode)
       (setq date (calendar-cursor-to-date)
-           defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
+           defd (encode-time 0 (or mod 0) (or hod 0)
+                             (nth 1 date) (nth 0 date) (nth 2 date))))
      ((eq major-mode 'org-agenda-mode)
       (setq day (get-text-property (point) 'day))
       (if day
          (setq date (calendar-gregorian-from-absolute day)
-               defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
-                                 (nth 2 date))))))
+               defd (encode-time 0 (or mod 0) (or hod 0)
+                                 (nth 1 date) (nth 0 date) (nth 2 date))))))
     (or defd (current-time))))
 
 (defun org-mark-subtree (&optional up)
@@ -20789,13 +22002,14 @@ hierarchy of headlines by UP levels before marking the subtree."
   (interactive "P")
   (org-with-limited-levels
    (cond ((org-at-heading-p) (beginning-of-line))
-        ((org-before-first-heading-p) (error "Not in a subtree"))
+        ((org-before-first-heading-p) (user-error "Not in a subtree"))
         (t (outline-previous-visible-heading 1))))
   (when up (while (and (> up 0) (org-up-heading-safe)) (decf up)))
   (if (org-called-interactively-p 'any)
       (call-interactively 'org-mark-element)
     (org-mark-element)))
 
+
 ;;; Indentation
 
 (defun org-indent-line ()
@@ -20817,8 +22031,6 @@ hierarchy of headlines by UP levels before marking the subtree."
       (cond
        ;; Headings
        ((looking-at org-outline-regexp) (setq column 0))
-       ;; Included files
-       ((looking-at "#\\+include:") (setq column 0))
        ;; Footnote definition
        ((looking-at org-footnote-definition-re) (setq column 0))
        ;; Literal examples
@@ -20874,15 +22086,16 @@ hierarchy of headlines by UP levels before marking the subtree."
                             (re-search-backward "[ \t]*#\\+begin_"nil t))
                        (looking-at "[ \t]*[\n:#|]")
                        (looking-at org-footnote-definition-re)
-                       (and (ignore-errors (goto-char (org-in-item-p)))
-                            (goto-char
-                             (org-list-get-top-point (org-list-struct))))
                        (and (not inline-task-p)
                             (featurep 'org-inlinetask)
                             (org-inlinetask-in-task-p)
                             (or (org-inlinetask-goto-beginning) t))))
          (beginning-of-line 0))
        (cond
+        ;; There was a list item above.
+        ((ignore-errors (goto-char (org-in-item-p)))
+         (goto-char (org-list-get-top-point (org-list-struct)))
+         (setq column (org-get-indentation)))
         ;; There was an heading above.
         ((looking-at "\\*+[ \t]+")
          (if (not org-adapt-indentation)
@@ -20903,11 +22116,10 @@ hierarchy of headlines by UP levels before marking the subtree."
       ;; Special polishing for properties, see `org-property-format'
       (setq column (current-column))
       (beginning-of-line 1)
-      (if (looking-at
-          "\\([ \t]*\\)\\(:[-_0-9a-zA-Z]+:\\)[ \t]*\\(\\S-.*\\(\\S-\\|$\\)\\)")
-         (replace-match (concat (match-string 1)
+      (if (looking-at org-property-re)
+         (replace-match (concat (match-string 4)
                                 (format org-property-format
-                                        (match-string 2) (match-string 3)))
+                                        (match-string 1) (match-string 3)))
                         t t))
       (org-move-to-column column))))
 
@@ -20959,7 +22171,7 @@ hierarchy of headlines by UP levels before marking the subtree."
     (let ((line-end (org-current-line end)))
       (goto-char start)
       (while (< (org-current-line) line-end)
-       (cond ((org-in-src-block-p) (org-src-native-tab-command-maybe))
+       (cond ((org-in-src-block-p t) (org-src-native-tab-command-maybe))
              (t (call-interactively 'org-indent-line)))
        (move-beginning-of-line 2)))))
 
@@ -20980,102 +22192,115 @@ hierarchy of headlines by UP levels before marking the subtree."
 ;; `org-setup-filling' installs filling and auto-filling related
 ;; variables during `org-mode' initialization.
 
+(defvar org-element-paragraph-separate) ; org-element.el
 (defun org-setup-filling ()
-  (interactive)
+  (require 'org-element)
   ;; Prevent auto-fill from inserting unwanted new items.
   (when (boundp 'fill-nobreak-predicate)
     (org-set-local
      'fill-nobreak-predicate
      (org-uniquify
       (append fill-nobreak-predicate
-             '(org-fill-paragraph-separate-nobreak-p
-               org-fill-line-break-nobreak-p
+             '(org-fill-line-break-nobreak-p
                org-fill-paragraph-with-timestamp-nobreak-p)))))
+  (let ((paragraph-ending (substring org-element-paragraph-separate 1)))
+    (org-set-local 'paragraph-start paragraph-ending)
+    (org-set-local 'paragraph-separate paragraph-ending))
   (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
   (org-set-local 'auto-fill-inhibit-regexp nil)
   (org-set-local 'adaptive-fill-function 'org-adaptive-fill-function)
   (org-set-local 'normal-auto-fill-function 'org-auto-fill-function)
   (org-set-local 'comment-line-break-function 'org-comment-line-break-function))
 
-(defvar org-element-paragraph-separate) ; org-element.el
-(defun org-fill-paragraph-separate-nobreak-p ()
-  "Non-nil when a line break at point would insert a new item."
-  (looking-at (substring org-element-paragraph-separate 1)))
-
 (defun org-fill-line-break-nobreak-p ()
-  "Non-nil when a line break at point would create an Org line break."
+  "Non-nil when a new line at point would create an Org line break."
   (save-excursion
     (skip-chars-backward "[ \t]")
     (skip-chars-backward "\\\\")
     (looking-at "\\\\\\\\\\($\\|[^\\\\]\\)")))
 
 (defun org-fill-paragraph-with-timestamp-nobreak-p ()
-  "Non-nil when a line break at point would insert a new item."
+  "Non-nil when a new line at point would split a timestamp."
   (and (org-at-timestamp-p t)
        (not (looking-at org-ts-regexp-both))))
 
 (declare-function message-in-body-p "message" ())
-(defvar org-element--affiliated-re) ; From org-element.el
 (defvar orgtbl-line-start-regexp) ; From org-table.el
 (defun org-adaptive-fill-function ()
   "Compute a fill prefix for the current line.
 Return fill prefix, as a string, or nil if current line isn't
-meant to be filled."
-  (let (prefix)
-    (catch 'exit
-      (when (derived-mode-p 'message-mode)
-       (save-excursion
-         (beginning-of-line)
-         (cond ((or (not (message-in-body-p))
-                    (looking-at orgtbl-line-start-regexp))
-                (throw 'exit nil))
-               ((looking-at message-cite-prefix-regexp)
-                (throw 'exit (match-string-no-properties 0)))
-               ((looking-at org-outline-regexp)
-                (throw 'exit (make-string (length (match-string 0)) ? ))))))
-      (org-with-wide-buffer
-       (let* ((p (line-beginning-position))
-             (element (save-excursion (beginning-of-line) (org-element-at-point)))
-             (type (org-element-type element))
-             (post-affiliated
-              (save-excursion
-                (goto-char (org-element-property :begin element))
-                (while (looking-at org-element--affiliated-re) (forward-line))
-                (point))))
-        (unless (< p post-affiliated)
-          (case type
-            (comment (looking-at "[ \t]*# ?") (match-string 0))
-            (footnote-definition "")
-            ((item plain-list)
-             (make-string (org-list-item-body-column post-affiliated) ? ))
-            (paragraph
-             ;; Fill prefix is usually the same as the current line,
-             ;; except if the paragraph is at the beginning of an item.
-             (let ((parent (org-element-property :parent element)))
+meant to be filled.  For convenience, if `adaptive-fill-regexp'
+matches in paragraphs or comments, use it."
+  (catch 'exit
+    (when (derived-mode-p 'message-mode)
+      (save-excursion
+       (beginning-of-line)
+       (cond ((or (not (message-in-body-p))
+                  (looking-at orgtbl-line-start-regexp))
+              (throw 'exit nil))
+             ((looking-at message-cite-prefix-regexp)
+              (throw 'exit (match-string-no-properties 0)))
+             ((looking-at org-outline-regexp)
+              (throw 'exit (make-string (length (match-string 0)) ? ))))))
+    (org-with-wide-buffer
+     (let* ((p (line-beginning-position))
+           (element (save-excursion
+                      (beginning-of-line)
+                      (or (ignore-errors (org-element-at-point))
+                          (user-error "An element cannot be parsed line %d"
+                                      (line-number-at-pos (point))))))
+           (type (org-element-type element))
+           (post-affiliated (org-element-property :post-affiliated element)))
+       (unless (and post-affiliated (< p post-affiliated))
+        (case type
+          (comment
+           (save-excursion
+             (beginning-of-line)
+             (looking-at "[ \t]*")
+             (concat (match-string 0) "# ")))
+          (footnote-definition "")
+          ((item plain-list)
+           (make-string (org-list-item-body-column
+                         (or post-affiliated
+                             (org-element-property :begin element)))
+                        ? ))
+          (paragraph
+           ;; Fill prefix is usually the same as the current line,
+           ;; unless the paragraph is at the beginning of an item.
+           (let ((parent (org-element-property :parent element)))
+             (save-excursion
+               (beginning-of-line)
                (cond ((eq (org-element-type parent) 'item)
                       (make-string (org-list-item-body-column
                                     (org-element-property :begin parent))
                                    ? ))
-                     ((save-excursion (beginning-of-line) (looking-at "[ \t]+"))
-                      (match-string 0))
-                     (t  ""))))
-            (comment-block
-             ;; Only fill contents if P is within block boundaries.
-             (let* ((cbeg (save-excursion (goto-char post-affiliated)
-                                          (forward-line)
-                                          (point)))
-                    (cend (save-excursion
-                            (goto-char (org-element-property :end element))
-                            (skip-chars-backward " \r\t\n")
-                            (line-beginning-position))))
-               (when (and (>= p cbeg) (< p cend))
-                 (if (save-excursion (beginning-of-line) (looking-at "[ \t]+"))
-                     (match-string 0)
-                   "")))))))))))
+                     ((and adaptive-fill-regexp
+                           ;; Locally disable
+                           ;; `adaptive-fill-function' to let
+                           ;; `fill-context-prefix' handle
+                           ;; `adaptive-fill-regexp' variable.
+                           (let (adaptive-fill-function)
+                             (fill-context-prefix
+                              post-affiliated
+                              (org-element-property :end element)))))
+                     ((looking-at "[ \t]+") (match-string 0))
+                     (t  "")))))
+          (comment-block
+           ;; Only fill contents if P is within block boundaries.
+           (let* ((cbeg (save-excursion (goto-char post-affiliated)
+                                        (forward-line)
+                                        (point)))
+                  (cend (save-excursion
+                          (goto-char (org-element-property :end element))
+                          (skip-chars-backward " \r\t\n")
+                          (line-beginning-position))))
+             (when (and (>= p cbeg) (< p cend))
+               (if (save-excursion (beginning-of-line) (looking-at "[ \t]+"))
+                   (match-string 0)
+                 ""))))))))))
 
 (declare-function message-goto-body "message" ())
 (defvar message-cite-prefix-regexp)    ; From message.el
-(defvar org-element-all-objects)       ; From org-element.el
 (defun org-fill-paragraph (&optional justify)
   "Fill element at point, when applicable.
 
@@ -21104,94 +22329,120 @@ a footnote definition, try to fill the first paragraph within."
            (paragraph-separate
             (cadadr (assoc 'paragraph-separate org-fb-vars))))
        (fill-paragraph nil))
-    (save-excursion
+    (with-syntax-table org-mode-transpose-word-syntax-table
       ;; Move to end of line in order to get the first paragraph
       ;; within a plain list or a footnote definition.
-      (end-of-line)
-      (let ((element (org-element-at-point)))
+      (let ((element (save-excursion
+                      (end-of-line)
+                      (or (ignore-errors (org-element-at-point))
+                          (user-error "An element cannot be parsed line %d"
+                                      (line-number-at-pos (point)))))))
        ;; First check if point is in a blank line at the beginning of
        ;; the buffer.  In that case, ignore filling.
-       (if (< (point) (org-element-property :begin element)) t
-         (case (org-element-type element)
-           ;; Use major mode filling function is src blocks.
-           (src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
-           ;; Align Org tables, leave table.el tables as-is.
-           (table-row (org-table-align) t)
-           (table
-            (when (eq (org-element-property :type element) 'org)
-              (org-table-align))
-            t)
-           (paragraph
-            ;; Paragraphs may contain `line-break' type objects.
-            (let ((beg (max (point-min)
-                            (org-element-property :contents-begin element)))
-                  (end (min (point-max)
-                            (org-element-property :contents-end element))))
-              ;; Do nothing if point is at an affiliated keyword.
-              (if (< (point) beg) t
-                (when (derived-mode-p 'message-mode)
-                  ;; In `message-mode', do not fill following
-                  ;; citation in current paragraph nor text before
-                  ;; message body.
-                  (let ((body-start (save-excursion (message-goto-body))))
-                    (when body-start (setq beg (max body-start beg))))
-                  (when (save-excursion
-                          (re-search-forward
-                           (concat "^" message-cite-prefix-regexp) end t))
-                    (setq end (match-beginning 0))))
-                ;; Fill paragraph, taking line breaks into
-                ;; consideration.  For that, slice the paragraph
-                ;; using line breaks as separators, and fill the
-                ;; parts in reverse order to avoid messing with
-                ;; markers.
-                (save-excursion
-                  (goto-char end)
-                  (mapc
-                   (lambda (pos)
-                     (fill-region-as-paragraph pos (point) justify)
-                     (goto-char pos))
-                   ;; Find the list of ending positions for line
-                   ;; breaks in the current paragraph.  Add paragraph
-                   ;; beginning to include first slice.
-                   (nreverse
-                    (cons
-                     beg
-                     (org-element-map
-                      (org-element--parse-objects
-                       beg end nil org-element-all-objects)
-                      'line-break
-                      (lambda (lb) (org-element-property :end lb)))))))
-                t)))
-           ;; Contents of `comment-block' type elements should be
-           ;; filled as plain text, but only if point is within block
-           ;; markers.
-           (comment-block
-            (let* ((case-fold-search t)
-                   (beg (save-excursion
-                          (goto-char (org-element-property :begin element))
-                          (re-search-forward "^[ \t]*#\\+begin_comment" nil t)
-                          (forward-line)
-                          (point)))
-                   (end (save-excursion
-                          (goto-char (org-element-property :end element))
-                          (re-search-backward "^[ \t]*#\\+end_comment" nil t)
-                          (line-beginning-position))))
-              (when (and (>= (point) beg) (< (point) end))
-                (fill-region-as-paragraph
-                 (save-excursion
-                   (end-of-line)
-                   (re-search-backward "^[ \t]*$" beg 'move)
-                   (line-beginning-position))
-                 (save-excursion
-                   (beginning-of-line)
-                   (re-search-forward "^[ \t]*$" end 'move)
-                   (line-beginning-position))
-                 justify)))
-            t)
-           ;; Fill comments.
-           (comment (fill-comment-paragraph justify))
-           ;; Ignore every other element.
-           (otherwise t)))))))
+       (case (org-element-type element)
+         ;; Use major mode filling function is src blocks.
+         (src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q")))
+         ;; Align Org tables, leave table.el tables as-is.
+         (table-row (org-table-align) t)
+         (table
+          (when (eq (org-element-property :type element) 'org)
+            (save-excursion
+              (goto-char (org-element-property :post-affiliated element))
+              (org-table-align)))
+          t)
+         (paragraph
+          ;; Paragraphs may contain `line-break' type objects.
+          (let ((beg (max (point-min)
+                          (org-element-property :contents-begin element)))
+                (end (min (point-max)
+                          (org-element-property :contents-end element))))
+            ;; Do nothing if point is at an affiliated keyword.
+            (if (< (line-end-position) beg) t
+              (when (derived-mode-p 'message-mode)
+                ;; In `message-mode', do not fill following citation
+                ;; in current paragraph nor text before message body.
+                (let ((body-start (save-excursion (message-goto-body))))
+                  (when body-start (setq beg (max body-start beg))))
+                (when (save-excursion
+                        (re-search-forward
+                         (concat "^" message-cite-prefix-regexp) end t))
+                  (setq end (match-beginning 0))))
+              ;; Fill paragraph, taking line breaks into account.
+              ;; For that, slice the paragraph using line breaks as
+              ;; separators, and fill the parts in reverse order to
+              ;; avoid messing with markers.
+              (save-excursion
+                (goto-char end)
+                (mapc
+                 (lambda (pos)
+                   (fill-region-as-paragraph pos (point) justify)
+                   (goto-char pos))
+                 ;; Find the list of ending positions for line breaks
+                 ;; in the current paragraph.  Add paragraph
+                 ;; beginning to include first slice.
+                 (nreverse
+                  (cons beg
+                        (org-element-map
+                            (org-element--parse-objects
+                             beg end nil (org-element-restriction 'paragraph))
+                            'line-break
+                          (lambda (lb) (org-element-property :end lb)))))))
+              t)))
+         ;; Contents of `comment-block' type elements should be
+         ;; filled as plain text, but only if point is within block
+         ;; markers.
+         (comment-block
+          (let* ((case-fold-search t)
+                 (beg (save-excursion
+                        (goto-char (org-element-property :begin element))
+                        (re-search-forward "^[ \t]*#\\+begin_comment" nil t)
+                        (forward-line)
+                        (point)))
+                 (end (save-excursion
+                        (goto-char (org-element-property :end element))
+                        (re-search-backward "^[ \t]*#\\+end_comment" nil t)
+                        (line-beginning-position))))
+            (if (or (< (point) beg) (> (point) end)) t
+              (fill-region-as-paragraph
+               (save-excursion (end-of-line)
+                               (re-search-backward "^[ \t]*$" beg 'move)
+                               (line-beginning-position))
+               (save-excursion (beginning-of-line)
+                               (re-search-forward "^[ \t]*$" end 'move)
+                               (line-beginning-position))
+               justify))))
+         ;; Fill comments.
+         (comment
+          (let ((begin (org-element-property :post-affiliated element))
+                (end (org-element-property :end element)))
+            (when (and (>= (point) begin) (<= (point) end))
+              (let ((begin (save-excursion
+                             (end-of-line)
+                             (if (re-search-backward "^[ \t]*#[ \t]*$" begin t)
+                                 (progn (forward-line) (point))
+                               begin)))
+                    (end (save-excursion
+                           (end-of-line)
+                           (if (re-search-forward "^[ \t]*#[ \t]*$" end 'move)
+                               (1- (line-beginning-position))
+                             (skip-chars-backward " \r\t\n")
+                             (line-end-position)))))
+                ;; Do not fill comments when at a blank line.
+                (when (> end begin)
+                  (let ((fill-prefix
+                         (save-excursion
+                           (beginning-of-line)
+                           (looking-at "[ \t]*#")
+                           (let ((comment-prefix (match-string 0)))
+                             (goto-char (match-end 0))
+                             (if (looking-at adaptive-fill-regexp)
+                                 (concat comment-prefix (match-string 0))
+                               (concat comment-prefix " "))))))
+                    (save-excursion
+                      (fill-region-as-paragraph begin end justify))))))
+            t))
+         ;; Ignore every other element.
+         (otherwise t))))))
 
 (defun org-auto-fill-function ()
   "Auto-fill function."
@@ -21298,11 +22549,102 @@ contains commented lines.  Otherwise, comment them."
            (goto-char (point-min))
            (while (not (eobp))
              (unless (and (not comment-empty-lines) (looking-at "[ \t]*$"))
-               (org-move-to-column min-indent t)
+               ;; Don't get fooled by invisible text (e.g. link path)
+               ;; when moving to column MIN-INDENT.
+               (let ((buffer-invisibility-spec nil))
+                 (org-move-to-column min-indent t))
                (insert comment-start))
              (forward-line))))))))
 
 
+;;; Planning
+
+;; This section contains tools to operate on timestamp objects, as
+;; returned by, e.g. `org-element-context'.
+
+(defun org-timestamp-has-time-p (timestamp)
+  "Non-nil when TIMESTAMP has a time specified."
+  (org-element-property :hour-start timestamp))
+
+(defun org-timestamp-format (timestamp format &optional end utc)
+  "Format a TIMESTAMP element into a string.
+
+FORMAT is a format specifier to be passed to
+`format-time-string'.
+
+When optional argument END is non-nil, use end of date-range or
+time-range, if possible.
+
+When optional argument UTC is non-nil, time will be expressed as
+Universal Time."
+  (format-time-string
+   format
+   (apply 'encode-time
+          (cons 0
+                (mapcar
+                 (lambda (prop) (or (org-element-property prop timestamp) 0))
+                 (if end '(:minute-end :hour-end :day-end :month-end :year-end)
+                   '(:minute-start :hour-start :day-start :month-start
+                                   :year-start)))))
+   utc))
+
+(defun org-timestamp-split-range (timestamp &optional end)
+  "Extract a timestamp object from a date or time range.
+
+TIMESTAMP is a timestamp object. END, when non-nil, means extract
+the end of the range.  Otherwise, extract its start.
+
+Return a new timestamp object sharing the same parent as
+TIMESTAMP."
+  (let ((type (org-element-property :type timestamp)))
+    (if (memq type '(active inactive diary)) timestamp
+      (let ((split-ts (list 'timestamp (copy-sequence (nth 1 timestamp)))))
+       ;; Set new type.
+       (org-element-put-property
+        split-ts :type (if (eq type 'active-range) 'active 'inactive))
+       ;; Copy start properties over end properties if END is
+       ;; non-nil.  Otherwise, copy end properties over `start' ones.
+       (let ((p-alist '((:minute-start . :minute-end)
+                        (:hour-start . :hour-end)
+                        (:day-start . :day-end)
+                        (:month-start . :month-end)
+                        (:year-start . :year-end))))
+         (dolist (p-cell p-alist)
+           (org-element-put-property
+            split-ts
+            (funcall (if end 'car 'cdr) p-cell)
+            (org-element-property
+             (funcall (if end 'cdr 'car) p-cell) split-ts)))
+         ;; Eventually refresh `:raw-value'.
+         (org-element-put-property split-ts :raw-value nil)
+         (org-element-put-property
+          split-ts :raw-value (org-element-interpret-data split-ts)))))))
+
+(defun org-timestamp-translate (timestamp &optional boundary)
+  "Apply `org-translate-time' on a TIMESTAMP object.
+When optional argument BOUNDARY is non-nil, it is either the
+symbol `start' or `end'.  In this case, only translate the
+starting or ending part of TIMESTAMP if it is a date or time
+range.  Otherwise, translate both parts."
+  (if (and (not boundary)
+          (memq (org-element-property :type timestamp)
+                '(active-range inactive-range)))
+      (concat
+       (org-translate-time
+       (org-element-property :raw-value
+                             (org-timestamp-split-range timestamp)))
+       "--"
+       (org-translate-time
+       (org-element-property :raw-value
+                             (org-timestamp-split-range timestamp t))))
+    (org-translate-time
+     (org-element-property
+      :raw-value
+      (if (not boundary) timestamp
+       (org-timestamp-split-range timestamp (eq boundary 'end)))))))
+
+
+
 ;;; Other stuff.
 
 (defun org-toggle-fixed-width-section (arg)
@@ -21365,7 +22707,7 @@ to work in this buffer and calls `reftex-citation'  to insert a citation
 into the buffer.
 
 Export of such citations to both LaTeX and HTML is handled by the contributed
-package org-exp-bibtex by Taru Karttunen."
+package ox-bibtex by Taru Karttunen."
   (interactive)
   (let ((reftex-docstruct-symbol 'rds)
        (reftex-cite-format "\\cite{%l}")
@@ -21396,7 +22738,7 @@ beyond the end of the headline."
        (special (if (consp org-special-ctrl-a/e)
                     (car org-special-ctrl-a/e)
                   org-special-ctrl-a/e))
-       refpos)
+       deactivate-mark refpos)
     (if (org-bound-and-true-p visual-line-mode)
        (beginning-of-visual-line 1)
       (beginning-of-line 1))
@@ -21448,7 +22790,10 @@ beyond the end of the headline."
              (when (and (= (point) pos) (eq last-command this-command))
                (goto-char after-bullet))))))))
     (org-no-warnings
-     (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
+     (and (featurep 'xemacs) (setq zmacs-region-stays t))))
+  (setq disable-point-adjustment
+        (or (not (invisible-p (point)))
+            (not (invisible-p (max (point-min) (1- (point))))))))
 
 (defun org-end-of-line (&optional arg)
   "Go to the end of the line.
@@ -21461,7 +22806,8 @@ the cursor is already beyond the end of the headline."
        (move-fun (cond ((org-bound-and-true-p visual-line-mode)
                         'end-of-visual-line)
                        ((fboundp 'move-end-of-line) 'move-end-of-line)
-                       (t 'end-of-line))))
+                       (t 'end-of-line)))
+       deactivate-mark)
     (if (or (not special) arg) (call-interactively move-fun)
       (let* ((element (save-excursion (beginning-of-line)
                                      (org-element-at-point)))
@@ -21485,7 +22831,10 @@ the cursor is already beyond the end of the headline."
          ;; after it.  Use `end-of-line' to stay on current line.
          (call-interactively 'end-of-line))
         (t (call-interactively move-fun)))))
-    (org-no-warnings (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
+    (org-no-warnings (and (featurep 'xemacs) (setq zmacs-region-stays t))))
+  (setq disable-point-adjustment
+        (or (not (invisible-p (point)))
+            (not (invisible-p (max (point-min) (1- (point))))))))
 
 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
 (define-key org-mode-map "\C-e" 'org-end-of-line)
@@ -21522,7 +22871,7 @@ depending on context."
             org-ctrl-k-protect-subtree)
        (if (or (eq org-ctrl-k-protect-subtree 'error)
                (not (y-or-n-p "Kill hidden subtree along with headline? ")))
-           (error "C-k aborted - would kill hidden subtree")))
+           (user-error "C-k aborted as it would kill a hidden subtree")))
     (call-interactively
      (if (org-bound-and-true-p visual-line-mode) 'kill-visual-line 'kill-line)))
    ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$"))
@@ -21741,7 +23090,7 @@ make a significant difference in outlines with very many siblings."
   (let ((re org-outline-regexp-bol)
        level l)
     (unless (org-at-heading-p t)
-      (error "Not at a heading"))
+      (user-error "Not at a heading"))
     (setq level (funcall outline-level))
     (save-excursion
       (if (not (re-search-backward re nil t))
@@ -21899,77 +23248,248 @@ clocking lines, and drawers."
     (point)))
 
 (defun org-forward-heading-same-level (arg &optional invisible-ok)
-  "Move forward to the arg'th subheading at same level as this one.
+  "Move forward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading.
 Normally this only looks at visible headings, but when INVISIBLE-OK is
 non-nil it will also look at invisible ones."
   (interactive "p")
-  (org-back-to-heading invisible-ok)
-  (org-at-heading-p)
-  (let* ((level (- (match-end 0) (match-beginning 0) 1))
-        (re (format "^\\*\\{1,%d\\} " level))
-        l)
-    (forward-char 1)
-    (while (> arg 0)
-      (while (and (re-search-forward re nil 'move)
-                 (setq l (- (match-end 0) (match-beginning 0) 1))
-                 (= l level)
-                 (not invisible-ok)
-                 (progn (backward-char 1) (outline-invisible-p)))
-       (if (< l level) (setq arg 1)))
-      (setq arg (1- arg)))
+  (if (not (ignore-errors (org-back-to-heading invisible-ok)))
+      (if (and arg (< arg 0))
+          (goto-char (point-min))
+        (outline-next-heading))
+    (org-at-heading-p)
+    (let ((level (- (match-end 0) (match-beginning 0) 1))
+          (f (if (and arg (< arg 0))
+                 're-search-backward
+               're-search-forward))
+          (count (if arg (abs arg) 1))
+          (result (point)))
+      (while (and (prog1 (> count 0)
+                   (forward-char (if (and arg (< arg 0)) -1 1)))
+                  (funcall f org-outline-regexp-bol nil 'move))
+        (let ((l (- (match-end 0) (match-beginning 0) 1)))
+          (cond ((< l level) (setq count 0))
+                ((and (= l level)
+                      (or invisible-ok
+                          (progn
+                            (goto-char (line-beginning-position))
+                            (not (outline-invisible-p)))))
+                 (setq count (1- count))
+                 (when (eq l level)
+                   (setq result (point)))))))
+      (goto-char result))
     (beginning-of-line 1)))
 
 (defun org-backward-heading-same-level (arg &optional invisible-ok)
-  "Move backward to the arg'th subheading at same level as this one.
+  "Move backward to the ARG'th subheading at same level as this one.
 Stop at the first and last subheadings of a superior heading."
   (interactive "p")
-  (org-back-to-heading)
-  (org-at-heading-p)
-  (let* ((level (- (match-end 0) (match-beginning 0) 1))
-        (re (format "^\\*\\{1,%d\\} " level))
-        l)
-    (while (> arg 0)
-      (while (and (re-search-backward re nil 'move)
-                 (setq l (- (match-end 0) (match-beginning 0) 1))
-                 (= l level)
-                 (not invisible-ok)
-                 (outline-invisible-p))
-       (if (< l level) (setq arg 1)))
-      (setq arg (1- arg)))))
+  (org-forward-heading-same-level (if arg (- arg) -1) invisible-ok))
+
+(defun org-next-block (arg &optional backward block-regexp)
+  "Jump to the next block.
+With a prefix argument ARG, jump forward ARG many source blocks.
+When BACKWARD is non-nil, jump to the previous block.
+When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
+  (interactive "p")
+  (let ((re (or block-regexp org-block-regexp))
+       (re-search-fn (or (and backward 're-search-backward)
+                          're-search-forward)))
+    (if (looking-at re) (forward-char 1))
+    (condition-case nil
+       (funcall re-search-fn re nil nil arg)
+      (error (error "No %s code blocks" (if backward "previous" "further" ))))
+    (goto-char (match-beginning 0)) (org-show-context)))
+
+(defun org-previous-block (arg &optional block-regexp)
+  "Jump to the previous block.
+With a prefix argument ARG, jump backward ARG many source blocks.
+When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
+  (interactive "p")
+  (org-next-block arg t block-regexp))
+
+(defun org-forward-paragraph ()
+  "Move forward to beginning of next paragraph or equivalent.
+
+The function moves point to the beginning of the next visible
+structural element, which can be a paragraph, a table, a list
+item, etc.  It also provides some special moves for convenience:
+
+  - On an affiliated keyword, jump to the beginning of the
+    relative element.
+  - On an item or a footnote definition, move to the second
+    element inside, if any.
+  - On a table or a property drawer, jump after it.
+  - On a verse or source block, stop after blank lines."
+  (interactive)
+  (when (eobp) (user-error "Cannot move further down"))
+  (let* ((deactivate-mark nil)
+        (element (org-element-at-point))
+         (type (org-element-type element))
+         (post-affiliated (org-element-property :post-affiliated element))
+         (contents-begin (org-element-property :contents-begin element))
+         (contents-end (org-element-property :contents-end element))
+         (end (let ((end (org-element-property :end element)) (parent element))
+                (while (and (setq parent (org-element-property :parent parent))
+                            (= (org-element-property :contents-end parent) end))
+                  (setq end (org-element-property :end parent)))
+                end)))
+    (cond ((not element)
+           (skip-chars-forward " \r\t\n")
+           (or (eobp) (beginning-of-line)))
+          ;; On affiliated keywords, move to element's beginning.
+          ((and post-affiliated (< (point) post-affiliated))
+           (goto-char post-affiliated))
+          ;; At a table row, move to the end of the table.  Similarly,
+          ;; at a node property, move to the end of the property
+          ;; drawer.
+          ((memq type '(node-property table-row))
+           (goto-char (org-element-property
+                       :end (org-element-property :parent element))))
+          ((memq type '(property-drawer table)) (goto-char end))
+          ;; Consider blank lines as separators in verse and source
+          ;; blocks to ease editing.
+          ((memq type '(src-block verse-block))
+           (when (eq type 'src-block)
+             (setq contents-end
+                   (save-excursion (goto-char end)
+                                   (skip-chars-backward " \r\t\n")
+                                   (line-beginning-position))))
+           (beginning-of-line)
+           (when (looking-at "[ \t]*$") (skip-chars-forward " \r\t\n"))
+           (if (not (re-search-forward "^[ \t]*$" contents-end t))
+               (goto-char end)
+             (skip-chars-forward " \r\t\n")
+             (if (= (point) contents-end) (goto-char end)
+               (beginning-of-line))))
+          ;; With no contents, just skip element.
+          ((not contents-begin) (goto-char end))
+          ;; If contents are invisible, skip the element altogether.
+          ((outline-invisible-p (line-end-position))
+           (case type
+             (headline
+              (org-with-limited-levels (outline-next-visible-heading 1)))
+             ;; At a plain list, make sure we move to the next item
+             ;; instead of skipping the whole list.
+             (plain-list (forward-char)
+                         (org-forward-paragraph))
+             (otherwise (goto-char end))))
+          ((>= (point) contents-end) (goto-char end))
+          ((>= (point) contents-begin)
+           ;; This can only happen on paragraphs and plain lists.
+           (case type
+             (paragraph (goto-char end))
+             ;; At a plain list, try to move to second element in
+             ;; first item, if possible.
+             (plain-list (end-of-line)
+                         (org-forward-paragraph))))
+          ;; When contents start on the middle of a line (e.g. in
+          ;; items and footnote definitions), try to reach first
+          ;; element starting after current line.
+          ((> (line-end-position) contents-begin)
+           (end-of-line)
+           (org-forward-paragraph))
+          (t (goto-char contents-begin)))))
+
+(defun org-backward-paragraph ()
+  "Move backward to start of previous paragraph or equivalent.
+
+The function moves point to the beginning of the current
+structural element, which can be a paragraph, a table, a list
+item, etc., or to the beginning of the previous visible one if
+point is already there.  It also provides some special moves for
+convenience:
+
+  - On an affiliated keyword, jump to the first one.
+  - On a table or a property drawer, move to its beginning.
+  - On a verse or source block, stop before blank lines."
+  (interactive)
+  (when (bobp) (user-error "Cannot move further up"))
+  (let* ((deactivate-mark nil)
+        (element (org-element-at-point))
+         (type (org-element-type element))
+         (contents-begin (org-element-property :contents-begin element))
+         (contents-end (org-element-property :contents-end element))
+         (post-affiliated (org-element-property :post-affiliated element))
+         (begin (org-element-property :begin element)))
+    (cond
+     ((not element) (goto-char (point-min)))
+     ((= (point) begin)
+      (backward-char)
+      (org-backward-paragraph))
+     ((and post-affiliated (<= (point) post-affiliated)) (goto-char begin))
+     ((memq type '(node-property table-row))
+      (goto-char (org-element-property
+                  :post-affiliated (org-element-property :parent element))))
+     ((memq type '(property-drawer table)) (goto-char begin))
+     ((memq type '(src-block verse-block))
+      (when (eq type 'src-block)
+        (setq contents-begin
+              (save-excursion (goto-char begin) (forward-line) (point))))
+      (if (= (point) contents-begin) (goto-char post-affiliated)
+        ;; Inside a verse block, see blank lines as paragraph
+        ;; separators.
+        (let ((origin (point)))
+          (skip-chars-backward " \r\t\n" contents-begin)
+          (when (re-search-backward "^[ \t]*$" contents-begin 'move)
+            (skip-chars-forward " \r\t\n" origin)
+            (if (= (point) origin) (goto-char contents-begin)
+              (beginning-of-line))))))
+     ((not contents-begin) (goto-char (or post-affiliated begin)))
+     ((eq type 'paragraph)
+      (goto-char contents-begin)
+      ;; When at first paragraph in an item or a footnote definition,
+      ;; move directly to beginning of line.
+      (let ((parent-contents
+             (org-element-property
+              :contents-begin (org-element-property :parent element))))
+        (when (and parent-contents (= parent-contents contents-begin))
+          (beginning-of-line))))
+     ;; At the end of a greater element, move to the beginning of the
+     ;; last element within.
+     ((>= (point) contents-end)
+      (goto-char (1- contents-end))
+      (org-backward-paragraph))
+     (t (goto-char (or post-affiliated begin))))
+    ;; Ensure we never leave point invisible.
+    (when (outline-invisible-p (point)) (beginning-of-visual-line))))
 
 (defun org-forward-element ()
   "Move forward by one element.
 Move to the next element at the same level, when possible."
   (interactive)
-  (cond ((eobp) (error "Cannot move further down"))
+  (cond ((eobp) (user-error "Cannot move further down"))
        ((org-with-limited-levels (org-at-heading-p))
         (let ((origin (point)))
-          (org-forward-heading-same-level 1)
+          (goto-char (org-end-of-subtree nil t))
           (unless (org-with-limited-levels (org-at-heading-p))
             (goto-char origin)
-            (error "Cannot move further down"))))
+            (user-error "Cannot move further down"))))
        (t
         (let* ((elem (org-element-at-point))
                (end (org-element-property :end elem))
                (parent (org-element-property :parent elem)))
-          (if (and parent (= (org-element-property :contents-end parent) end))
-              (goto-char (org-element-property :end parent))
-            (goto-char end))))))
+          (cond ((and parent (= (org-element-property :contents-end parent) end))
+                 (goto-char (org-element-property :end parent)))
+                ((integer-or-marker-p end) (goto-char end))
+                (t (message "No element at point")))))))
 
 (defun org-backward-element ()
   "Move backward by one element.
 Move to the previous element at the same level, when possible."
   (interactive)
-  (cond ((bobp) (error "Cannot move further up"))
+  (cond ((bobp) (user-error "Cannot move further up"))
        ((org-with-limited-levels (org-at-heading-p))
-        ;; At an headline, move to the previous one, if any, or stay
+        ;; At a headline, move to the previous one, if any, or stay
         ;; here.
         (let ((origin (point)))
-          (org-backward-heading-same-level 1)
-          (unless (org-with-limited-levels (org-at-heading-p))
-            (goto-char origin)
-            (error "Cannot move further up"))))
+          (org-with-limited-levels (org-backward-heading-same-level 1))
+          ;; When current headline has no sibling above, move to its
+          ;; parent.
+          (when (= (point) origin)
+            (or (org-with-limited-levels (org-up-heading-safe))
+                (progn (goto-char origin)
+                       (user-error "Cannot move further up"))))))
        (t
         (let* ((trail (org-element-at-point 'keep-trail))
                (elem (car trail))
@@ -21978,6 +23498,7 @@ Move to the previous element at the same level, when possible."
           (cond
            ;; Move to beginning of current element if point isn't
            ;; there already.
+           ((null beg) (message "No element at point"))
            ((/= (point) beg) (goto-char beg))
            (prev-elem (goto-char (org-element-property :begin prev-elem)))
            ((org-before-first-heading-p) (goto-char (point-min)))
@@ -21987,12 +23508,12 @@ Move to the previous element at the same level, when possible."
   "Move to upper element."
   (interactive)
   (if (org-with-limited-levels (org-at-heading-p))
-      (unless (org-up-heading-safe) (error "No surrounding element"))
+      (unless (org-up-heading-safe) (user-error "No surrounding element"))
     (let* ((elem (org-element-at-point))
           (parent (org-element-property :parent elem)))
       (if parent (goto-char (org-element-property :begin parent))
        (if (org-with-limited-levels (org-before-first-heading-p))
-           (error "No surrounding element")
+           (user-error "No surrounding element")
          (org-with-limited-levels (org-back-to-heading)))))))
 
 (defvar org-element-greater-elements)
@@ -22008,8 +23529,8 @@ Move to the previous element at the same level, when possible."
       ;; If contents are hidden, first disclose them.
       (when (org-element-property :hiddenp element) (org-cycle))
       (goto-char (or (org-element-property :contents-begin element)
-                    (error "No content for this element"))))
-     (t (error "No inner element")))))
+                    (user-error "No content for this element"))))
+     (t (user-error "No inner element")))))
 
 (defun org-drag-element-backward ()
   "Move backward element at point."
@@ -22021,7 +23542,7 @@ Move to the previous element at the same level, when possible."
       ;; Error out if no previous element or previous element is
       ;; a parent of the current one.
       (if (or (not prev-elem) (org-element-nested-p elem prev-elem))
-         (error "Cannot drag element backward")
+         (user-error "Cannot drag element backward")
        (let ((pos (point)))
          (org-element-swap-A-B prev-elem elem)
          (goto-char (+ (org-element-property :begin prev-elem)
@@ -22033,14 +23554,14 @@ Move to the previous element at the same level, when possible."
   (let* ((pos (point))
         (elem (org-element-at-point)))
     (when (= (point-max) (org-element-property :end elem))
-      (error "Cannot drag element forward"))
+      (user-error "Cannot drag element forward"))
     (goto-char (org-element-property :end elem))
     (let ((next-elem (org-element-at-point)))
       (when (or (org-element-nested-p elem next-elem)
                (and (eq (org-element-type next-elem) 'headline)
                     (not (eq (org-element-type elem) 'headline))))
        (goto-char pos)
-       (error "Cannot drag element forward"))
+       (user-error "Cannot drag element forward"))
       ;; Compute new position of point: it's shifted by NEXT-ELEM
       ;; body's length (without final blanks) and by the length of
       ;; blanks between ELEM and NEXT-ELEM.
@@ -22061,6 +23582,25 @@ Move to the previous element at the same level, when possible."
        (org-element-swap-A-B elem next-elem)
        (goto-char (+ pos size-next size-blank))))))
 
+(defun org-drag-line-forward (arg)
+  "Drag the line at point ARG lines forward."
+  (interactive "p")
+  (dotimes (n (abs arg))
+    (let ((c (current-column)))
+      (if (< 0 arg)
+         (progn
+           (beginning-of-line 2)
+           (transpose-lines 1)
+           (beginning-of-line 0))
+       (transpose-lines 1)
+       (beginning-of-line -1))
+      (org-move-to-column c))))
+
+(defun org-drag-line-backward (arg)
+  "Drag the line at point ARG lines backward."
+  (interactive "p")
+  (org-drag-line-forward (- arg)))
+
 (defun org-mark-element ()
   "Put point at beginning of this element, mark at end.
 
@@ -22114,7 +23654,7 @@ Relative indentation (between items, inside blocks, etc.) isn't
 modified."
   (interactive)
   (unless (eq major-mode 'org-mode)
-    (error "Cannot un-indent a buffer not in Org mode"))
+    (user-error "Cannot un-indent a buffer not in Org mode"))
   (let* ((parse-tree (org-element-parse-buffer 'greater-element))
         unindent-tree                  ; For byte-compiler.
         (unindent-tree
@@ -22244,8 +23784,8 @@ Show the heading too, if it is currently invisible."
                     (org-show-context 'org-goto))))))
 
 (defun org-link-display-format (link)
-  "Replace a link with either the description, or the link target
-if no description is present"
+  "Replace a link with its the description.
+If there is no description, use the link target."
   (save-match-data
     (if (string-match org-bracket-link-analytic-regexp link)
        (replace-match (if (match-end 5)
@@ -22302,14 +23842,16 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
                            (let ((default-directory dir))
                              (expand-file-name txt)))
        (unless (derived-mode-p 'org-mode)
-         (error "Cannot restrict to non-Org-mode file"))
+         (user-error "Cannot restrict to non-Org-mode file"))
        (org-agenda-set-restriction-lock 'file)))
-     (t (error "Don't know how to restrict Org-mode's agenda")))
+     (t (user-error "Don't know how to restrict Org-mode's agenda")))
     (move-overlay org-speedbar-restriction-lock-overlay
                  (point-at-bol) (point-at-eol))
     (setq current-prefix-arg nil)
     (org-agenda-maybe-redo)))
 
+(defvar speedbar-file-key-map)
+(declare-function speedbar-add-supported-extension "speedbar" (extension))
 (eval-after-load "speedbar"
   '(progn
      (speedbar-add-supported-extension ".org")
@@ -22323,9 +23865,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 ;;; Fixes and Hacks for problems with other packages
 
 ;; Make flyspell not check words in links, to not mess up our keymap
+(defvar org-element-affiliated-keywords) ; From org-element.el
+(defvar org-element-block-name-alist)   ; From org-element.el
 (defun org-mode-flyspell-verify ()
   "Don't let flyspell put overlays at active buttons, or on
    {todo,all-time,additional-option-like}-keywords."
+  (require 'org-element) ; For `org-element-affiliated-keywords'
   (let ((pos (max (1- (point)) (point-min)))
        (word (thing-at-point 'word)))
     (and (not (get-text-property pos 'keymap))
@@ -22334,7 +23879,12 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
         (not (member word org-all-time-keywords))
         (not (member word org-options-keywords))
         (not (member word (mapcar 'car org-startup-options)))
-        (not (member word org-additional-option-like-keywords-for-flyspell)))))
+        (not (member-ignore-case word org-element-affiliated-keywords))
+        (not (member-ignore-case word (org-get-export-keywords)))
+        (not (member-ignore-case
+              word (mapcar 'car org-element-block-name-alist)))
+        (not (member-ignore-case word '("BEGIN" "END" "ATTR")))
+        (not (org-in-src-block-p)))))
 
 (defun org-remove-flyspell-overlays-in (beg end)
   "Remove flyspell overlays in region."
@@ -22375,32 +23925,10 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
        (org-show-context 'bookmark-jump)))
 
 ;; Make session.el ignore our circular variable
+(defvar session-globals-exclude)
 (eval-after-load "session"
   '(add-to-list 'session-globals-exclude 'org-mark-ring))
 
-;;;; Experimental code
-
-(defun org-closed-in-range ()
-  "Sparse tree of items closed in a certain time range.
-Still experimental, may disappear in the future."
-  (interactive)
-  ;; Get the time interval from the user.
-  (let* ((time1 (org-float-time
-                 (org-read-date nil 'to-time nil "Starting date: ")))
-         (time2 (org-float-time
-                 (org-read-date nil 'to-time nil "End date:")))
-         ;; callback function
-         (callback (lambda ()
-                     (let ((time
-                            (org-float-time
-                             (apply 'encode-time
-                                    (org-parse-time-string
-                                     (match-string 1))))))
-                       ;; check if time in interval
-                       (and (>= time time1) (<= time time2))))))
-    ;; make tree, check each match with the callback
-    (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
-
 ;;;; Finish up
 
 (provide 'org)
diff --git a/lisp/org/ox-ascii.el b/lisp/org/ox-ascii.el
new file mode 100644 (file)
index 0000000..5b41d2d
--- /dev/null
@@ -0,0 +1,1975 @@
+;;; ox-ascii.el --- ASCII Back-End for Org Export Engine
+
+;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements an ASCII back-end for Org generic exporter.
+;; See Org manual for more information.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox)
+(require 'ox-publish)
+
+(declare-function aa2u "ext:ascii-art-to-unicode" ())
+
+;;; Define Back-End
+;;
+;; The following setting won't allow to modify preferred charset
+;; through a buffer keyword or an option item, but, since the property
+;; will appear in communication channel nonetheless, it allows to
+;; override `org-ascii-charset' variable on the fly by the ext-plist
+;; mechanism.
+;;
+;; We also install a filter for headlines and sections, in order to
+;; control blank lines separating them in output string.
+
+(org-export-define-backend 'ascii
+  '((bold . org-ascii-bold)
+    (center-block . org-ascii-center-block)
+    (clock . org-ascii-clock)
+    (code . org-ascii-code)
+    (comment . (lambda (&rest args) ""))
+    (comment-block . (lambda (&rest args) ""))
+    (drawer . org-ascii-drawer)
+    (dynamic-block . org-ascii-dynamic-block)
+    (entity . org-ascii-entity)
+    (example-block . org-ascii-example-block)
+    (export-block . org-ascii-export-block)
+    (export-snippet . org-ascii-export-snippet)
+    (fixed-width . org-ascii-fixed-width)
+    (footnote-reference . org-ascii-footnote-reference)
+    (headline . org-ascii-headline)
+    (horizontal-rule . org-ascii-horizontal-rule)
+    (inline-src-block . org-ascii-inline-src-block)
+    (inlinetask . org-ascii-inlinetask)
+    (inner-template . org-ascii-inner-template)
+    (italic . org-ascii-italic)
+    (item . org-ascii-item)
+    (keyword . org-ascii-keyword)
+    (latex-environment . org-ascii-latex-environment)
+    (latex-fragment . org-ascii-latex-fragment)
+    (line-break . org-ascii-line-break)
+    (link . org-ascii-link)
+    (paragraph . org-ascii-paragraph)
+    (plain-list . org-ascii-plain-list)
+    (plain-text . org-ascii-plain-text)
+    (planning . org-ascii-planning)
+    (quote-block . org-ascii-quote-block)
+    (quote-section . org-ascii-quote-section)
+    (radio-target . org-ascii-radio-target)
+    (section . org-ascii-section)
+    (special-block . org-ascii-special-block)
+    (src-block . org-ascii-src-block)
+    (statistics-cookie . org-ascii-statistics-cookie)
+    (strike-through . org-ascii-strike-through)
+    (subscript . org-ascii-subscript)
+    (superscript . org-ascii-superscript)
+    (table . org-ascii-table)
+    (table-cell . org-ascii-table-cell)
+    (table-row . org-ascii-table-row)
+    (target . org-ascii-target)
+    (template . org-ascii-template)
+    (timestamp . org-ascii-timestamp)
+    (underline . org-ascii-underline)
+    (verbatim . org-ascii-verbatim)
+    (verse-block . org-ascii-verse-block))
+  :export-block "ASCII"
+  :menu-entry
+  '(?t "Export to Plain Text"
+       ((?A "As ASCII buffer"
+           (lambda (a s v b)
+             (org-ascii-export-as-ascii a s v b '(:ascii-charset ascii))))
+       (?a "As ASCII file"
+           (lambda (a s v b)
+             (org-ascii-export-to-ascii a s v b '(:ascii-charset ascii))))
+       (?L "As Latin1 buffer"
+           (lambda (a s v b)
+             (org-ascii-export-as-ascii a s v b '(:ascii-charset latin1))))
+       (?l "As Latin1 file"
+           (lambda (a s v b)
+             (org-ascii-export-to-ascii a s v b '(:ascii-charset latin1))))
+       (?U "As UTF-8 buffer"
+           (lambda (a s v b)
+             (org-ascii-export-as-ascii a s v b '(:ascii-charset utf-8))))
+       (?u "As UTF-8 file"
+           (lambda (a s v b)
+             (org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8))))))
+  :filters-alist '((:filter-headline . org-ascii-filter-headline-blank-lines)
+                  (:filter-parse-tree org-ascii-filter-paragraph-spacing
+                                      org-ascii-filter-comment-spacing)
+                  (:filter-section . org-ascii-filter-headline-blank-lines))
+  :options-alist '((:ascii-charset nil nil org-ascii-charset)))
+
+
+\f
+;;; User Configurable Variables
+
+(defgroup org-export-ascii nil
+  "Options for exporting Org mode files to ASCII."
+  :tag "Org Export ASCII"
+  :group 'org-export)
+
+(defcustom org-ascii-text-width 72
+  "Maximum width of exported text.
+This number includes margin size, as set in
+`org-ascii-global-margin'."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
+(defcustom org-ascii-global-margin 0
+  "Width of the left margin, in number of characters."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
+(defcustom org-ascii-inner-margin 2
+  "Width of the inner margin, in number of characters.
+Inner margin is applied between each headline."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
+(defcustom org-ascii-quote-margin 6
+  "Width of margin used for quoting text, in characters.
+This margin is applied on both sides of the text."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
+(defcustom org-ascii-inlinetask-width 30
+  "Width of inline tasks, in number of characters.
+This number ignores any margin."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'integer)
+
+(defcustom org-ascii-headline-spacing '(1 . 2)
+  "Number of blank lines inserted around headlines.
+
+This variable can be set to a cons cell.  In that case, its car
+represents the number of blank lines present before headline
+contents whereas its cdr reflects the number of blank lines after
+contents.
+
+A nil value replicates the number of blank lines found in the
+original Org buffer at the same place."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Replicate original spacing" nil)
+         (cons :tag "Set an uniform spacing"
+               (integer :tag "Number of blank lines before contents")
+               (integer :tag "Number of blank lines after contents"))))
+
+(defcustom org-ascii-indented-line-width 'auto
+  "Additional indentation width for the first line in a paragraph.
+If the value is an integer, indent the first line of each
+paragraph by this number.  If it is the symbol `auto' preserve
+indentation from original document."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (integer :tag "Number of white spaces characters")
+         (const :tag "Preserve original width" auto)))
+
+(defcustom org-ascii-paragraph-spacing 'auto
+  "Number of white lines between paragraphs.
+If the value is an integer, add this number of blank lines
+between contiguous paragraphs.  If is it the symbol `auto', keep
+the same number of blank lines as in the original document."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (integer :tag "Number of blank lines")
+         (const :tag "Preserve original spacing" auto)))
+
+(defcustom org-ascii-charset 'ascii
+  "The charset allowed to represent various elements and objects.
+Possible values are:
+`ascii'    Only use plain ASCII characters
+`latin1'   Include Latin-1 characters
+`utf-8'    Use all UTF-8 characters"
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "ASCII" ascii)
+         (const :tag "Latin-1" latin1)
+         (const :tag "UTF-8" utf-8)))
+
+(defcustom org-ascii-underline '((ascii ?= ?~ ?-)
+                                (latin1 ?= ?~ ?-)
+                                (utf-8 ?═ ?─ ?╌ ?┄ ?┈))
+  "Characters for underlining headings in ASCII export.
+
+Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
+and whose value is a list of characters.
+
+For each supported charset, this variable associates a sequence
+of underline characters.  In a sequence, the characters will be
+used in order for headlines level 1, 2, ...  If no character is
+available for a given level, the headline won't be underlined."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(list
+         (cons :tag "Underline characters sequence"
+               (const :tag "ASCII charset" ascii)
+               (repeat character))
+         (cons :tag "Underline characters sequence"
+               (const :tag "Latin-1 charset" latin1)
+               (repeat character))
+         (cons :tag "Underline characters sequence"
+               (const :tag "UTF-8 charset" utf-8)
+               (repeat character))))
+
+(defcustom org-ascii-bullets '((ascii ?* ?+ ?-)
+                              (latin1 ?§ ?¶)
+                              (utf-8 ?◊))
+  "Bullet characters for headlines converted to lists in ASCII export.
+
+Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
+and whose value is a list of characters.
+
+The first character is used for the first level considered as low
+level, and so on.  If there are more levels than characters given
+here, the list will be repeated.
+
+Note that this variable doesn't affect plain lists
+representation."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(list
+         (cons :tag "Bullet characters for low level headlines"
+               (const :tag "ASCII charset" ascii)
+               (repeat character))
+         (cons :tag "Bullet characters for low level headlines"
+               (const :tag "Latin-1 charset" latin1)
+               (repeat character))
+         (cons :tag "Bullet characters for low level headlines"
+               (const :tag "UTF-8 charset" utf-8)
+               (repeat character))))
+
+(defcustom org-ascii-links-to-notes t
+  "Non-nil means convert links to notes before the next headline.
+When nil, the link will be exported in place.  If the line
+becomes long in this way, it will be wrapped."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-ascii-table-keep-all-vertical-lines nil
+  "Non-nil means keep all vertical lines in ASCII tables.
+When nil, vertical lines will be removed except for those needed
+for column grouping."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-ascii-table-widen-columns t
+  "Non-nil means widen narrowed columns for export.
+When nil, narrowed columns will look in ASCII export just like in
+Org mode, i.e. with \"=>\" as ellipsis."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-ascii-table-use-ascii-art nil
+  "Non-nil means table.el tables are turned into ascii-art.
+
+It only makes sense when export charset is `utf-8'.  It is nil by
+default since it requires ascii-art-to-unicode.el package.  You
+can download it here:
+
+  http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-ascii-caption-above nil
+  "When non-nil, place caption string before the element.
+Otherwise, place it right after it."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-ascii-verbatim-format "`%s'"
+  "Format string used for verbatim text and inline code."
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-ascii-format-drawer-function nil
+  "Function called to format a drawer in ASCII.
+
+The function must accept three parameters:
+  NAME      the drawer name, like \"LOGBOOK\"
+  CONTENTS  the contents of the drawer.
+  WIDTH     the text width within the drawer.
+
+The function should return either the string to be exported or
+nil to ignore the drawer.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-ascii-format-drawer-default (name contents width)
+  \"Format a drawer element for ASCII export.\"
+  contents)"
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+(defcustom org-ascii-format-inlinetask-function nil
+  "Function called to format an inlinetask in ASCII.
+
+The function must accept six parameters:
+  TODO      the todo keyword, as a string
+  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  PRIORITY  the inlinetask priority, as a string
+  NAME      the inlinetask name, as a string.
+  TAGS      the inlinetask tags, as a list of strings.
+  CONTENTS  the contents of the inlinetask, as a string.
+
+The function should return either the string to be exported or
+nil to ignore the inline task.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-ascii-format-inlinetask-default
+  \(todo type priority name tags contents\)
+  \"Format an inline task element for ASCII export.\"
+  \(let* \(\(utf8p \(eq \(plist-get info :ascii-charset\) 'utf-8\)\)
+           \(width org-ascii-inlinetask-width\)
+    \(org-ascii--indent-string
+     \(concat
+      ;; Top line, with an additional blank line if not in UTF-8.
+      \(make-string width \(if utf8p ?━ ?_\)\)  \"\\n\"
+      \(unless utf8p \(concat \(make-string width ? \) \"\\n\"\)\)
+      ;; Add title.  Fill it if wider than inlinetask.
+      \(let \(\(title \(org-ascii--build-title inlinetask info width\)\)\)
+       \(if \(<= \(length title\) width\) title
+         \(org-ascii--fill-string title width info\)\)\)
+      \"\\n\"
+      ;; If CONTENTS is not empty, insert it along with
+      ;; a separator.
+      \(when \(org-string-nw-p contents\)
+        \(concat \(make-string width \(if utf8p ?─ ?-\)\) \"\\n\" contents\)\)
+      ;; Bottom line.
+      \(make-string width \(if utf8p ?━ ?_\)\)\)
+     ;; Flush the inlinetask to the right.
+     \(- \(plist-get info :ascii-width\)
+        \(plist-get info :ascii-margin\)
+        \(plist-get info :ascii-inner-margin\)
+        \(org-ascii--current-text-width inlinetask info\)\)"
+  :group 'org-export-ascii
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+
+\f
+;;; Internal Functions
+
+;; Internal functions fall into three categories.
+
+;; The first one is about text formatting.  The core function is
+;; `org-ascii--current-text-width', which determines the current
+;; text width allowed to a given element.  In other words, it helps
+;; keeping each line width within maximum text width defined in
+;; `org-ascii-text-width'.  Once this information is known,
+;; `org-ascii--fill-string', `org-ascii--justify-string',
+;; `org-ascii--box-string' and `org-ascii--indent-string' can
+;; operate on a given output string.
+
+;; The second category contains functions handling elements listings,
+;; triggered by "#+TOC:" keyword.  As such, `org-ascii--build-toc'
+;; returns a complete table of contents, `org-ascii--list-listings'
+;; returns a list of referenceable src-block elements, and
+;; `org-ascii--list-tables' does the same for table elements.
+
+;; The third category includes general helper functions.
+;; `org-ascii--build-title' creates the title for a given headline
+;; or inlinetask element.  `org-ascii--build-caption' returns the
+;; caption string associated to a table or a src-block.
+;; `org-ascii--describe-links' creates notes about links for
+;; insertion at the end of a section.  It uses
+;; `org-ascii--unique-links' to get the list of links to describe.
+;; Eventually, `org-ascii--translate' translates a string according
+;; to language and charset specification.
+
+
+(defun org-ascii--fill-string (s text-width info &optional justify)
+  "Fill a string with specified text-width and return it.
+
+S is the string being filled.  TEXT-WIDTH is an integer
+specifying maximum length of a line.  INFO is the plist used as
+a communication channel.
+
+Optional argument JUSTIFY can specify any type of justification
+among `left', `center', `right' or `full'.  A nil value is
+equivalent to `left'.  For a justification that doesn't also fill
+string, see `org-ascii--justify-string'.
+
+Return nil if S isn't a string."
+  ;; Don't fill paragraph when break should be preserved.
+  (cond ((not (stringp s)) nil)
+       ((plist-get info :preserve-breaks) s)
+       (t (let ((double-space-p sentence-end-double-space))
+            (with-temp-buffer
+              (let ((fill-column text-width)
+                    (use-hard-newlines t)
+                    (sentence-end-double-space double-space-p))
+                (insert s)
+                (fill-region (point-min) (point-max) justify))
+              (buffer-string))))))
+
+(defun org-ascii--justify-string (s text-width how)
+  "Justify string S.
+TEXT-WIDTH is an integer specifying maximum length of a line.
+HOW determines the type of justification: it can be `left',
+`right', `full' or `center'."
+  (with-temp-buffer
+    (insert s)
+    (goto-char (point-min))
+    (let ((fill-column text-width)
+         ;; Disable `adaptive-fill-mode' so it doesn't prevent
+         ;; filling lines matching `adaptive-fill-regexp'.
+         (adaptive-fill-mode nil))
+      (while (< (point) (point-max))
+       (justify-current-line how)
+       (forward-line)))
+    (buffer-string)))
+
+(defun org-ascii--indent-string (s width)
+  "Indent string S by WIDTH white spaces.
+Empty lines are not indented."
+  (when (stringp s)
+    (replace-regexp-in-string
+     "\\(^\\)\\(?:.*\\S-\\)" (make-string width ? ) s nil nil 1)))
+
+(defun org-ascii--box-string (s info)
+  "Return string S with a partial box to its left.
+INFO is a plist used as a communication channel."
+  (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
+    (format (if utf8p "╭────\n%s\n╰────" ",----\n%s\n`----")
+           (replace-regexp-in-string
+            "^" (if utf8p "│ " "| ")
+            ;; Remove last newline character.
+            (replace-regexp-in-string "\n[ \t]*\\'" "" s)))))
+
+(defun org-ascii--current-text-width (element info)
+  "Return maximum text width for ELEMENT's contents.
+INFO is a plist used as a communication channel."
+  (case (org-element-type element)
+    ;; Elements with an absolute width: `headline' and `inlinetask'.
+    (inlinetask org-ascii-inlinetask-width)
+    ('headline
+     (- org-ascii-text-width
+       (let ((low-level-rank (org-export-low-level-p element info)))
+         (if low-level-rank (* low-level-rank 2) org-ascii-global-margin))))
+    ;; Elements with a relative width: store maximum text width in
+    ;; TOTAL-WIDTH.
+    (otherwise
+     (let* ((genealogy (cons element (org-export-get-genealogy element)))
+           ;; Total width is determined by the presence, or not, of an
+           ;; inline task among ELEMENT parents.
+           (total-width
+            (if (loop for parent in genealogy
+                      thereis (eq (org-element-type parent) 'inlinetask))
+                org-ascii-inlinetask-width
+              ;; No inlinetask: Remove global margin from text width.
+              (- org-ascii-text-width
+                 org-ascii-global-margin
+                 (let ((parent (org-export-get-parent-headline element)))
+                   ;; Inner margin doesn't apply to text before first
+                   ;; headline.
+                   (if (not parent) 0
+                     (let ((low-level-rank
+                            (org-export-low-level-p parent info)))
+                       ;; Inner margin doesn't apply to contents of
+                       ;; low level headlines, since they've got their
+                       ;; own indentation mechanism.
+                       (if low-level-rank (* low-level-rank 2)
+                         org-ascii-inner-margin))))))))
+       (- total-width
+         ;; Each `quote-block', `quote-section' and `verse-block' above
+         ;; narrows text width by twice the standard margin size.
+         (+ (* (loop for parent in genealogy
+                     when (memq (org-element-type parent)
+                                '(quote-block quote-section verse-block))
+                     count parent)
+               2 org-ascii-quote-margin)
+            ;; Text width within a plain-list is restricted by
+            ;; indentation of current item.  If that's the case,
+            ;; compute it with the help of `:structure' property from
+            ;; parent item, if any.
+            (let ((parent-item
+                   (if (eq (org-element-type element) 'item) element
+                     (loop for parent in genealogy
+                           when (eq (org-element-type parent) 'item)
+                           return parent))))
+              (if (not parent-item) 0
+                ;; Compute indentation offset of the current item,
+                ;; that is the sum of the difference between its
+                ;; indentation and the indentation of the top item in
+                ;; the list and current item bullet's length.  Also
+                ;; remove checkbox length, and tag length (for
+                ;; description lists) or bullet length.
+                (let ((struct (org-element-property :structure parent-item))
+                      (beg-item (org-element-property :begin parent-item)))
+                  (+ (- (org-list-get-ind beg-item struct)
+                        (org-list-get-ind
+                         (org-list-get-top-point struct) struct))
+                     (length (org-ascii--checkbox parent-item info))
+                     (length
+                      (or (org-list-get-tag beg-item struct)
+                          (org-list-get-bullet beg-item struct)))))))))))))
+
+(defun org-ascii--build-title
+  (element info text-width &optional underline notags toc)
+  "Format ELEMENT title and return it.
+
+ELEMENT is either an `headline' or `inlinetask' element.  INFO is
+a plist used as a communication channel.  TEXT-WIDTH is an
+integer representing the maximum length of a line.
+
+When optional argument UNDERLINE is non-nil, underline title,
+without the tags, according to `org-ascii-underline'
+specifications.
+
+If optional argument NOTAGS is non-nil, no tags will be added to
+the title.
+
+When optional argument TOC is non-nil, use optional title if
+possible.  It doesn't apply to `inlinetask' elements."
+  (let* ((headlinep (eq (org-element-type element) 'headline))
+        (numbers
+         ;; Numbering is specific to headlines.
+         (and headlinep (org-export-numbered-headline-p element info)
+              ;; All tests passed: build numbering string.
+              (concat
+               (mapconcat
+                'number-to-string
+                (org-export-get-headline-number element info) ".")
+               " ")))
+        (text
+         (org-trim
+          (org-export-data
+           (if (and toc headlinep) (org-export-get-alt-title element info)
+             (org-element-property :title element))
+           info)))
+        (todo
+         (and (plist-get info :with-todo-keywords)
+              (let ((todo (org-element-property :todo-keyword element)))
+                (and todo (concat (org-export-data todo info) " ")))))
+        (tags (and (not notags)
+                   (plist-get info :with-tags)
+                   (let ((tag-list (org-export-get-tags element info)))
+                     (and tag-list
+                          (format ":%s:"
+                                  (mapconcat 'identity tag-list ":"))))))
+        (priority
+         (and (plist-get info :with-priority)
+              (let ((char (org-element-property :priority element)))
+                (and char (format "(#%c) " char)))))
+        (first-part (concat numbers todo priority text)))
+    (concat
+     first-part
+     ;; Align tags, if any.
+     (when tags
+       (format
+       (format " %%%ds"
+               (max (- text-width  (1+ (length first-part))) (length tags)))
+       tags))
+     ;; Maybe underline text, if ELEMENT type is `headline' and an
+     ;; underline character has been defined.
+     (when (and underline headlinep)
+       (let ((under-char
+             (nth (1- (org-export-get-relative-level element info))
+                  (cdr (assq (plist-get info :ascii-charset)
+                             org-ascii-underline)))))
+        (and under-char
+             (concat "\n"
+                     (make-string (length first-part) under-char))))))))
+
+(defun org-ascii--has-caption-p (element info)
+  "Non-nil when ELEMENT has a caption affiliated keyword.
+INFO is a plist used as a communication channel.  This function
+is meant to be used as a predicate for `org-export-get-ordinal'."
+  (org-element-property :caption element))
+
+(defun org-ascii--build-caption (element info)
+  "Return caption string for ELEMENT, if applicable.
+
+INFO is a plist used as a communication channel.
+
+The caption string contains the sequence number of ELEMENT along
+with its real caption.  Return nil when ELEMENT has no affiliated
+caption keyword."
+  (let ((caption (org-export-get-caption element)))
+    (when caption
+      ;; Get sequence number of current src-block among every
+      ;; src-block with a caption.
+      (let ((reference
+            (org-export-get-ordinal
+             element info nil 'org-ascii--has-caption-p))
+           (title-fmt (org-ascii--translate
+                       (case (org-element-type element)
+                         (table "Table %d:")
+                         (src-block "Listing %d:"))
+                       info)))
+       (org-ascii--fill-string
+        (concat (format title-fmt reference)
+                " "
+                (org-export-data caption info))
+        (org-ascii--current-text-width element info) info)))))
+
+(defun org-ascii--build-toc (info &optional n keyword)
+  "Return a table of contents.
+
+INFO is a plist used as a communication channel.
+
+Optional argument N, when non-nil, is an integer specifying the
+depth of the table.
+
+Optional argument KEYWORD specifies the TOC keyword, if any, from
+which the table of contents generation has been initiated."
+  (let ((title (org-ascii--translate "Table of Contents" info)))
+    (concat
+     title "\n"
+     (make-string (length title)
+                 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
+     "\n\n"
+     (let ((text-width
+           (if keyword (org-ascii--current-text-width keyword info)
+             (- org-ascii-text-width org-ascii-global-margin))))
+       (mapconcat
+       (lambda (headline)
+         (let* ((level (org-export-get-relative-level headline info))
+                (indent (* (1- level) 3)))
+           (concat
+            (unless (zerop indent) (concat (make-string (1- indent) ?.) " "))
+            (org-ascii--build-title
+             headline info (- text-width indent) nil
+             (or (not (plist-get info :with-tags))
+                 (eq (plist-get info :with-tags) 'not-in-toc))
+             'toc))))
+       (org-export-collect-headlines info n) "\n")))))
+
+(defun org-ascii--list-listings (keyword info)
+  "Return a list of listings.
+
+KEYWORD is the keyword that initiated the list of listings
+generation.  INFO is a plist used as a communication channel."
+  (let ((title (org-ascii--translate "List of Listings" info)))
+    (concat
+     title "\n"
+     (make-string (length title)
+                 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
+     "\n\n"
+     (let ((text-width
+           (if keyword (org-ascii--current-text-width keyword info)
+             (- org-ascii-text-width org-ascii-global-margin)))
+          ;; Use a counter instead of retrieving ordinal of each
+          ;; src-block.
+          (count 0))
+       (mapconcat
+       (lambda (src-block)
+         ;; Store initial text so its length can be computed.  This is
+         ;; used to properly align caption right to it in case of
+         ;; filling (like contents of a description list item).
+         (let ((initial-text
+                (format (org-ascii--translate "Listing %d:" info)
+                        (incf count))))
+           (concat
+            initial-text " "
+            (org-trim
+             (org-ascii--indent-string
+              (org-ascii--fill-string
+               ;; Use short name in priority, if available.
+               (let ((caption (or (org-export-get-caption src-block t)
+                                  (org-export-get-caption src-block))))
+                 (org-export-data caption info))
+               (- text-width (length initial-text)) info)
+              (length initial-text))))))
+       (org-export-collect-listings info) "\n")))))
+
+(defun org-ascii--list-tables (keyword info)
+  "Return a list of tables.
+
+KEYWORD is the keyword that initiated the list of tables
+generation.  INFO is a plist used as a communication channel."
+  (let ((title (org-ascii--translate "List of Tables" info)))
+    (concat
+     title "\n"
+     (make-string (length title)
+                 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
+     "\n\n"
+     (let ((text-width
+           (if keyword (org-ascii--current-text-width keyword info)
+             (- org-ascii-text-width org-ascii-global-margin)))
+          ;; Use a counter instead of retrieving ordinal of each
+          ;; src-block.
+          (count 0))
+       (mapconcat
+       (lambda (table)
+         ;; Store initial text so its length can be computed.  This is
+         ;; used to properly align caption right to it in case of
+         ;; filling (like contents of a description list item).
+         (let ((initial-text
+                (format (org-ascii--translate "Table %d:" info)
+                        (incf count))))
+           (concat
+            initial-text " "
+            (org-trim
+             (org-ascii--indent-string
+              (org-ascii--fill-string
+               ;; Use short name in priority, if available.
+               (let ((caption (or (org-export-get-caption table t)
+                                  (org-export-get-caption table))))
+                 (org-export-data caption info))
+               (- text-width (length initial-text)) info)
+              (length initial-text))))))
+       (org-export-collect-tables info) "\n")))))
+
+(defun org-ascii--unique-links (element info)
+  "Return a list of unique link references in ELEMENT.
+
+ELEMENT is either a headline element or a section element.  INFO
+is a plist used as a communication channel."
+  (let* (seen
+        (unique-link-p
+         (function
+          ;; Return LINK if it wasn't referenced so far, or nil.
+          ;; Update SEEN links along the way.
+          (lambda (link)
+            (let ((footprint
+                   (cons (org-element-property :raw-link link)
+                         (org-element-contents link))))
+              ;; Ignore LINK if it hasn't been translated already.
+              ;; It can happen if it is located in an affiliated
+              ;; keyword that was ignored.
+              (when (and (org-string-nw-p
+                          (gethash link (plist-get info :exported-data)))
+                         (not (member footprint seen)))
+                (push footprint seen) link)))))
+        ;; If at a section, find parent headline, if any, in order to
+        ;; count links that might be in the title.
+        (headline
+         (if (eq (org-element-type element) 'headline) element
+           (or (org-export-get-parent-headline element) element))))
+    ;; Get all links in HEADLINE.
+    (org-element-map headline 'link
+      (lambda (l) (funcall unique-link-p l)) info nil nil t)))
+
+(defun org-ascii--describe-links (links width info)
+  "Return a string describing a list of links.
+
+LINKS is a list of link type objects, as returned by
+`org-ascii--unique-links'.  WIDTH is the text width allowed for
+the output string.  INFO is a plist used as a communication
+channel."
+  (mapconcat
+   (lambda (link)
+     (let ((type (org-element-property :type link))
+          (anchor (let ((desc (org-element-contents link)))
+                    (if desc (org-export-data desc info)
+                      (org-element-property :raw-link link)))))
+       (cond
+       ;; Coderefs, radio links and fuzzy links are ignored.
+       ((member type '("coderef" "radio" "fuzzy")) nil)
+       ;; Id and custom-id links: Headlines refer to their numbering.
+       ((member type '("custom-id" "id"))
+        (let ((dest (org-export-resolve-id-link link info)))
+          (concat
+           (org-ascii--fill-string
+            (format
+             "[%s] %s"
+             anchor
+             (if (not dest) (org-ascii--translate "Unknown reference" info)
+               (format
+                (org-ascii--translate "See section %s" info)
+                (mapconcat 'number-to-string
+                           (org-export-get-headline-number dest info) "."))))
+            width info) "\n\n")))
+       ;; Do not add a link that cannot be resolved and doesn't have
+       ;; any description: destination is already visible in the
+       ;; paragraph.
+       ((not (org-element-contents link)) nil)
+       (t
+        (concat
+         (org-ascii--fill-string
+          (format "[%s] %s" anchor (org-element-property :raw-link link))
+          width info)
+         "\n\n")))))
+   links ""))
+
+(defun org-ascii--checkbox (item info)
+  "Return checkbox string for ITEM or nil.
+INFO is a plist used as a communication channel."
+  (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
+    (case (org-element-property :checkbox item)
+      (on (if utf8p "☑ " "[X] "))
+      (off (if utf8p "☐ " "[ ] "))
+      (trans (if utf8p "☒ " "[-] ")))))
+
+
+\f
+;;; Template
+
+(defun org-ascii-template--document-title (info)
+  "Return document title, as a string.
+INFO is a plist used as a communication channel."
+  (let* ((text-width org-ascii-text-width)
+        ;; Links in the title will not be resolved later, so we make
+        ;; sure their path is located right after them.
+        (org-ascii-links-to-notes nil)
+        (title (org-export-data (plist-get info :title) info))
+        (author (and (plist-get info :with-author)
+                     (let ((auth (plist-get info :author)))
+                       (and auth (org-export-data auth info)))))
+        (email (and (plist-get info :with-email)
+                    (org-export-data (plist-get info :email) info)))
+        (date (and (plist-get info :with-date)
+                   (org-export-data (org-export-get-date info) info))))
+    ;; There are two types of title blocks depending on the presence
+    ;; of a title to display.
+    (if (string= title "")
+       ;; Title block without a title.  DATE is positioned at the top
+       ;; right of the document, AUTHOR to the top left and EMAIL
+       ;; just below.
+       (cond
+        ((and (org-string-nw-p date) (org-string-nw-p author))
+         (concat
+          author
+          (make-string (- text-width (length date) (length author)) ? )
+          date
+          (when (org-string-nw-p email) (concat "\n" email))
+          "\n\n\n"))
+        ((and (org-string-nw-p date) (org-string-nw-p email))
+         (concat
+          email
+          (make-string (- text-width (length date) (length email)) ? )
+          date "\n\n\n"))
+        ((org-string-nw-p date)
+         (concat
+          (org-ascii--justify-string date text-width 'right)
+          "\n\n\n"))
+        ((and (org-string-nw-p author) (org-string-nw-p email))
+         (concat author "\n" email "\n\n\n"))
+        ((org-string-nw-p author) (concat author "\n\n\n"))
+        ((org-string-nw-p email) (concat email "\n\n\n")))
+      ;; Title block with a title.  Document's TITLE, along with the
+      ;; AUTHOR and its EMAIL are both overlined and an underlined,
+      ;; centered.  Date is just below, also centered.
+      (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
+            ;; Format TITLE.  It may be filled if it is too wide,
+            ;; that is wider than the two thirds of the total width.
+            (title-len (min (length title) (/ (* 2 text-width) 3)))
+            (formatted-title (org-ascii--fill-string title title-len info))
+            (line
+             (make-string
+              (min (+ (max title-len (length author) (length email)) 2)
+                   text-width) (if utf8p ?━ ?_))))
+       (org-ascii--justify-string
+        (concat line "\n"
+                (unless utf8p "\n")
+                (upcase formatted-title)
+                (cond
+                 ((and (org-string-nw-p author) (org-string-nw-p email))
+                  (concat (if utf8p "\n\n\n" "\n\n") author "\n" email))
+                 ((org-string-nw-p author)
+                  (concat (if utf8p "\n\n\n" "\n\n") author))
+                 ((org-string-nw-p email)
+                  (concat (if utf8p "\n\n\n" "\n\n") email)))
+                "\n" line
+                (when (org-string-nw-p date) (concat "\n\n\n" date))
+                "\n\n\n") text-width 'center)))))
+
+(defun org-ascii-inner-template (contents info)
+  "Return complete document string after ASCII conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (org-element-normalize-string
+   (org-ascii--indent-string
+    (concat
+     ;; 1. Document's body.
+     contents
+     ;; 2. Footnote definitions.
+     (let ((definitions (org-export-collect-footnote-definitions
+                        (plist-get info :parse-tree) info))
+          ;; Insert full links right inside the footnote definition
+          ;; as they have no chance to be inserted later.
+          (org-ascii-links-to-notes nil))
+       (when definitions
+        (concat
+         "\n\n\n"
+         (let ((title (org-ascii--translate "Footnotes" info)))
+           (concat
+            title "\n"
+            (make-string
+             (length title)
+             (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))))
+         "\n\n"
+         (let ((text-width (- org-ascii-text-width org-ascii-global-margin)))
+           (mapconcat
+            (lambda (ref)
+              (let ((id (format "[%s] " (car ref))))
+                ;; Distinguish between inline definitions and
+                ;; full-fledged definitions.
+                (org-trim
+                 (let ((def (nth 2 ref)))
+                   (if (eq (org-element-type def) 'org-data)
+                       ;; Full-fledged definition: footnote ID is
+                       ;; inserted inside the first parsed paragraph
+                       ;; (FIRST), if any, to be sure filling will
+                       ;; take it into consideration.
+                       (let ((first (car (org-element-contents def))))
+                         (if (not (eq (org-element-type first) 'paragraph))
+                             (concat id "\n" (org-export-data def info))
+                           (push id (nthcdr 2 first))
+                           (org-export-data def info)))
+                     ;; Fill paragraph once footnote ID is inserted
+                     ;; in order to have a correct length for first
+                     ;; line.
+                     (org-ascii--fill-string
+                      (concat id (org-export-data def info))
+                      text-width info))))))
+            definitions "\n\n"))))))
+    org-ascii-global-margin)))
+
+(defun org-ascii-template (contents info)
+  "Return complete document string after ASCII conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (concat
+   ;; 1. Build title block.
+   (org-ascii--indent-string
+    (concat (org-ascii-template--document-title info)
+           ;; 2. Table of contents.
+           (let ((depth (plist-get info :with-toc)))
+             (when depth
+               (concat
+                (org-ascii--build-toc info (and (wholenump depth) depth))
+                "\n\n\n"))))
+    org-ascii-global-margin)
+   ;; 3. Document's body.
+   contents
+   ;; 4. Creator.  Ignore `comment' value as there are no comments in
+   ;;    ASCII.  Justify it to the bottom right.
+   (org-ascii--indent-string
+    (let ((creator-info (plist-get info :with-creator))
+         (text-width (- org-ascii-text-width org-ascii-global-margin)))
+      (unless (or (not creator-info) (eq creator-info 'comment))
+       (concat
+        "\n\n\n"
+        (org-ascii--fill-string
+         (plist-get info :creator) text-width info 'right))))
+    org-ascii-global-margin)))
+
+(defun org-ascii--translate (s info)
+  "Translate string S according to specified language and charset.
+INFO is a plist used as a communication channel."
+  (let ((charset (intern (format ":%s" (plist-get info :ascii-charset)))))
+    (org-export-translate s charset info)))
+
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-ascii-bold (bold contents info)
+  "Transcode BOLD from Org to ASCII.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (format "*%s*" contents))
+
+
+;;;; Center Block
+
+(defun org-ascii-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (org-ascii--justify-string
+   contents (org-ascii--current-text-width center-block info) 'center))
+
+
+;;;; Clock
+
+(defun org-ascii-clock (clock contents info)
+  "Transcode a CLOCK object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat org-clock-string " "
+         (org-translate-time
+          (org-element-property :raw-value
+                                (org-element-property :value clock)))
+         (let ((time (org-element-property :duration clock)))
+           (and time
+                (concat " => "
+                        (apply 'format
+                               "%2s:%02s"
+                               (org-split-string time ":")))))))
+
+
+;;;; Code
+
+(defun org-ascii-code (code contents info)
+  "Return a CODE object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format org-ascii-verbatim-format (org-element-property :value code)))
+
+
+;;;; Drawer
+
+(defun org-ascii-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((name (org-element-property :drawer-name drawer))
+       (width (org-ascii--current-text-width drawer info)))
+    (if (functionp org-ascii-format-drawer-function)
+       (funcall org-ascii-format-drawer-function name contents width)
+      ;; If there's no user defined function: simply
+      ;; display contents of the drawer.
+      contents)))
+
+
+;;;; Dynamic Block
+
+(defun org-ascii-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;;; Entity
+
+(defun org-ascii-entity (entity contents info)
+  "Transcode an ENTITY object from Org to ASCII.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (org-element-property
+   (intern (concat ":" (symbol-name (plist-get info :ascii-charset))))
+   entity))
+
+
+;;;; Example Block
+
+(defun org-ascii-example-block (example-block contents info)
+  "Transcode a EXAMPLE-BLOCK element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-ascii--box-string
+   (org-export-format-code-default example-block info) info))
+
+
+;;;; Export Snippet
+
+(defun org-ascii-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (eq (org-export-snippet-backend export-snippet) 'ascii)
+    (org-element-property :value export-snippet)))
+
+
+;;;; Export Block
+
+(defun org-ascii-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (string= (org-element-property :type export-block) "ASCII")
+    (org-remove-indentation (org-element-property :value export-block))))
+
+
+;;;; Fixed Width
+
+(defun org-ascii-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-ascii--box-string
+   (org-remove-indentation
+    (org-element-property :value fixed-width)) info))
+
+
+;;;; Footnote Definition
+
+;; Footnote Definitions are ignored.  They are compiled at the end of
+;; the document, by `org-ascii-inner-template'.
+
+
+;;;; Footnote Reference
+
+(defun org-ascii-footnote-reference (footnote-reference contents info)
+  "Transcode a FOOTNOTE-REFERENCE element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (format "[%s]" (org-export-get-footnote-number footnote-reference info)))
+
+
+;;;; Headline
+
+(defun org-ascii-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to ASCII.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  ;; Don't export footnote section, which will be handled at the end
+  ;; of the template.
+  (unless (org-element-property :footnote-section-p headline)
+    (let* ((low-level-rank (org-export-low-level-p headline info))
+          (width (org-ascii--current-text-width headline info))
+          ;; Blank lines between headline and its contents.
+          ;; `org-ascii-headline-spacing', when set, overwrites
+          ;; original buffer's spacing.
+          (pre-blanks
+           (make-string
+            (if org-ascii-headline-spacing (car org-ascii-headline-spacing)
+              (org-element-property :pre-blank headline)) ?\n))
+          ;; Even if HEADLINE has no section, there might be some
+          ;; links in its title that we shouldn't forget to describe.
+          (links
+           (unless (or (eq (caar (org-element-contents headline)) 'section))
+             (let ((title (org-element-property :title headline)))
+               (when (consp title)
+                 (org-ascii--describe-links
+                  (org-ascii--unique-links title info) width info))))))
+      ;; Deep subtree: export it as a list item.
+      (if low-level-rank
+         (concat
+          ;; Bullet.
+          (let ((bullets (cdr (assq (plist-get info :ascii-charset)
+                                    org-ascii-bullets))))
+            (char-to-string
+             (nth (mod (1- low-level-rank) (length bullets)) bullets)))
+          " "
+          ;; Title.
+          (org-ascii--build-title headline info width) "\n"
+          ;; Contents, indented by length of bullet.
+          pre-blanks
+          (org-ascii--indent-string
+           (concat contents
+                   (when (org-string-nw-p links) (concat "\n\n" links)))
+           2))
+       ;; Else: Standard headline.
+       (concat
+        (org-ascii--build-title headline info width 'underline)
+        "\n" pre-blanks
+        (concat (when (org-string-nw-p links) links) contents))))))
+
+
+;;;; Horizontal Rule
+
+(defun org-ascii-horizontal-rule (horizontal-rule contents info)
+  "Transcode an HORIZONTAL-RULE object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((text-width (org-ascii--current-text-width horizontal-rule info))
+       (spec-width
+        (org-export-read-attribute :attr_ascii horizontal-rule :width)))
+    (org-ascii--justify-string
+     (make-string (if (and spec-width (string-match "^[0-9]+$" spec-width))
+                     (string-to-number spec-width)
+                   text-width)
+                 (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))
+     text-width 'center)))
+
+
+;;;; Inline Src Block
+
+(defun org-ascii-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (format org-ascii-verbatim-format
+         (org-element-property :value inline-src-block)))
+
+
+;;;; Inlinetask
+
+(defun org-ascii-inlinetask (inlinetask contents info)
+  "Transcode an INLINETASK element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((width (org-ascii--current-text-width inlinetask info)))
+    ;; If `org-ascii-format-inlinetask-function' is provided, call it
+    ;; with appropriate arguments.
+    (if (functionp org-ascii-format-inlinetask-function)
+       (funcall org-ascii-format-inlinetask-function
+                ;; todo.
+                (and (plist-get info :with-todo-keywords)
+                     (let ((todo (org-element-property
+                                  :todo-keyword inlinetask)))
+                       (and todo (org-export-data todo info))))
+                ;; todo-type
+                (org-element-property :todo-type inlinetask)
+                ;; priority
+                (and (plist-get info :with-priority)
+                     (org-element-property :priority inlinetask))
+                ;; title
+                (org-export-data (org-element-property :title inlinetask) info)
+                ;; tags
+                (and (plist-get info :with-tags)
+                     (org-element-property :tags inlinetask))
+                ;; contents and width
+                contents width)
+      ;; Otherwise, use a default template.
+      (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
+       (org-ascii--indent-string
+        (concat
+         ;; Top line, with an additional blank line if not in UTF-8.
+         (make-string width (if utf8p ?━ ?_))  "\n"
+         (unless utf8p (concat (make-string width ? ) "\n"))
+         ;; Add title.  Fill it if wider than inlinetask.
+         (let ((title (org-ascii--build-title inlinetask info width)))
+           (if (<= (length title) width) title
+             (org-ascii--fill-string title width info)))
+         "\n"
+         ;; If CONTENTS is not empty, insert it along with
+         ;; a separator.
+         (when (org-string-nw-p contents)
+           (concat (make-string width (if utf8p ?─ ?-)) "\n" contents))
+         ;; Bottom line.
+         (make-string width (if utf8p ?━ ?_)))
+        ;; Flush the inlinetask to the right.
+        (- org-ascii-text-width org-ascii-global-margin
+           (if (not (org-export-get-parent-headline inlinetask)) 0
+             org-ascii-inner-margin)
+           (org-ascii--current-text-width inlinetask info)))))))
+
+
+;;;; Italic
+
+(defun org-ascii-italic (italic contents info)
+  "Transcode italic from Org to ASCII.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (format "/%s/" contents))
+
+
+;;;; Item
+
+(defun org-ascii-item (item contents info)
+  "Transcode an ITEM element from Org to ASCII.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
+        (checkbox (org-ascii--checkbox item info))
+        (list-type (org-element-property :type (org-export-get-parent item)))
+        (bullet
+         ;; First parent of ITEM is always the plain-list.  Get
+         ;; `:type' property from it.
+         (org-list-bullet-string
+          (case list-type
+            (descriptive
+             (concat checkbox
+                     (org-export-data (org-element-property :tag item) info)
+                     ": "))
+            (ordered
+             ;; Return correct number for ITEM, paying attention to
+             ;; counters.
+             (let* ((struct (org-element-property :structure item))
+                    (bul (org-element-property :bullet item))
+                    (num (number-to-string
+                          (car (last (org-list-get-item-number
+                                      (org-element-property :begin item)
+                                      struct
+                                      (org-list-prevs-alist struct)
+                                      (org-list-parents-alist struct)))))))
+               (replace-regexp-in-string "[0-9]+" num bul)))
+            (t (let ((bul (org-element-property :bullet item)))
+                 ;; Change bullets into more visible form if UTF-8 is active.
+                 (if (not utf8p) bul
+                   (replace-regexp-in-string
+                    "-" "•"
+                    (replace-regexp-in-string
+                     "+" "⁃"
+                     (replace-regexp-in-string "*" "‣" bul))))))))))
+    (concat
+     bullet
+     (unless (eq list-type 'descriptive) checkbox)
+     ;; Contents: Pay attention to indentation.  Note: check-boxes are
+     ;; already taken care of at the paragraph level so they don't
+     ;; interfere with indentation.
+     (let ((contents (org-ascii--indent-string contents (length bullet))))
+       (if (eq (org-element-type (car (org-element-contents item))) 'paragraph)
+          (org-trim contents)
+        (concat "\n" contents))))))
+
+
+;;;; Keyword
+
+(defun org-ascii-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "ASCII") value)
+     ((string= key "TOC")
+      (let ((value (downcase value)))
+       (cond
+        ((string-match "\\<headlines\\>" value)
+         (let ((depth (or (and (string-match "[0-9]+" value)
+                               (string-to-number (match-string 0 value)))
+                          (plist-get info :with-toc))))
+           (org-ascii--build-toc
+            info (and (wholenump depth) depth) keyword)))
+        ((string= "tables" value)
+         (org-ascii--list-tables keyword info))
+        ((string= "listings" value)
+         (org-ascii--list-listings keyword info))))))))
+
+
+;;;; Latex Environment
+
+(defun org-ascii-latex-environment (latex-environment contents info)
+  "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (when (plist-get info :with-latex)
+    (org-remove-indentation (org-element-property :value latex-environment))))
+
+
+;;;; Latex Fragment
+
+(defun org-ascii-latex-fragment (latex-fragment contents info)
+  "Transcode a LATEX-FRAGMENT object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (when (plist-get info :with-latex)
+    (org-element-property :value latex-fragment)))
+
+
+;;;; Line Break
+
+(defun org-ascii-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual
+  information."  hard-newline)
+
+
+;;;; Link
+
+(defun org-ascii-link (link desc info)
+  "Transcode a LINK object from Org to ASCII.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information."
+  (let ((raw-link (org-element-property :raw-link link))
+       (type (org-element-property :type link)))
+    (cond
+     ((string= type "coderef")
+      (let ((ref (org-element-property :path link)))
+       (format (org-export-get-coderef-format ref desc)
+               (org-export-resolve-coderef ref info))))
+     ;; Do not apply a special syntax on radio links.  Though, use
+     ;; transcoded target's contents as output.
+     ((string= type "radio")
+      (let ((destination (org-export-resolve-radio-link link info)))
+       (when destination
+         (org-export-data (org-element-contents destination) info))))
+     ;; Do not apply a special syntax on fuzzy links pointing to
+     ;; targets.
+     ((string= type "fuzzy")
+      (let ((destination (org-export-resolve-fuzzy-link link info)))
+       (if (org-string-nw-p desc) desc
+         (when destination
+           (let ((number
+                  (org-export-get-ordinal
+                   destination info nil 'org-ascii--has-caption-p)))
+             (when number
+               (if (atom number) (number-to-string number)
+                 (mapconcat 'number-to-string number "."))))))))
+     (t
+      (if (not (org-string-nw-p desc)) (format "[%s]" raw-link)
+       (concat
+        (format "[%s]" desc)
+        (unless org-ascii-links-to-notes (format " (%s)" raw-link))))))))
+
+
+;;;; Paragraph
+
+(defun org-ascii-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to ASCII.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  (let ((contents (if (not (wholenump org-ascii-indented-line-width)) contents
+                   (concat
+                    (make-string org-ascii-indented-line-width ? )
+                    (replace-regexp-in-string "\\`[ \t]+" "" contents)))))
+    (org-ascii--fill-string
+     contents (org-ascii--current-text-width paragraph info) info)))
+
+
+;;;; Plain List
+
+(defun org-ascii-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to ASCII.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  contents)
+
+
+;;;; Plain Text
+
+(defun org-ascii-plain-text (text info)
+  "Transcode a TEXT string from Org to ASCII.
+INFO is a plist used as a communication channel."
+  (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
+    (when (and utf8p (plist-get info :with-smart-quotes))
+      (setq text (org-export-activate-smart-quotes text :utf-8 info)))
+    (if (not (plist-get info :with-special-strings)) text
+      (setq text (replace-regexp-in-string "\\\\-" "" text))
+      (if (not utf8p) text
+       ;; Usual replacements in utf-8 with proper option set.
+       (replace-regexp-in-string
+        "\\.\\.\\." "…"
+        (replace-regexp-in-string
+         "--" "–"
+         (replace-regexp-in-string "---" "—" text)))))))
+
+
+;;;; Planning
+
+(defun org-ascii-planning (planning contents info)
+  "Transcode a PLANNING element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (mapconcat
+   'identity
+   (delq nil
+        (list (let ((closed (org-element-property :closed planning)))
+                (when closed
+                  (concat org-closed-string " "
+                          (org-translate-time
+                           (org-element-property :raw-value closed)))))
+              (let ((deadline (org-element-property :deadline planning)))
+                (when deadline
+                  (concat org-deadline-string " "
+                          (org-translate-time
+                           (org-element-property :raw-value deadline)))))
+              (let ((scheduled (org-element-property :scheduled planning)))
+                (when scheduled
+                  (concat org-scheduled-string " "
+                          (org-translate-time
+                           (org-element-property :raw-value scheduled)))))))
+   " "))
+
+
+;;;; Quote Block
+
+(defun org-ascii-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (org-ascii--indent-string contents org-ascii-quote-margin))
+
+
+;;;; Quote Section
+
+(defun org-ascii-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((width (org-ascii--current-text-width quote-section info))
+       (value
+        (org-export-data
+         (org-remove-indentation (org-element-property :value quote-section))
+         info)))
+    (org-ascii--indent-string
+     value
+     (+ org-ascii-quote-margin
+       ;; Don't apply inner margin if parent headline is low level.
+       (let ((headline (org-export-get-parent-headline quote-section)))
+         (if (org-export-low-level-p headline info) 0
+           org-ascii-inner-margin))))))
+
+
+;;;; Radio Target
+
+(defun org-ascii-radio-target (radio-target contents info)
+  "Transcode a RADIO-TARGET object from Org to ASCII.
+CONTENTS is the contents of the target.  INFO is a plist holding
+contextual information."
+  contents)
+
+
+;;;; Section
+
+(defun org-ascii-section (section contents info)
+  "Transcode a SECTION element from Org to ASCII.
+CONTENTS is the contents of the section.  INFO is a plist holding
+contextual information."
+  (org-ascii--indent-string
+   (concat
+    contents
+    (when org-ascii-links-to-notes
+      ;; Add list of links at the end of SECTION.
+      (let ((links (org-ascii--describe-links
+                   (org-ascii--unique-links section info)
+                   (org-ascii--current-text-width section info) info)))
+       ;; Separate list of links and section contents.
+       (when (org-string-nw-p links) (concat "\n\n" links)))))
+   ;; Do not apply inner margin if parent headline is low level.
+   (let ((headline (org-export-get-parent-headline section)))
+     (if (or (not headline) (org-export-low-level-p headline info)) 0
+       org-ascii-inner-margin))))
+
+
+;;;; Special Block
+
+(defun org-ascii-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;;; Src Block
+
+(defun org-ascii-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to ASCII.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let ((caption (org-ascii--build-caption src-block info))
+       (code (org-export-format-code-default src-block info)))
+    (if (equal code "") ""
+      (concat
+       (when (and caption org-ascii-caption-above) (concat caption "\n"))
+       (org-ascii--box-string code info)
+       (when (and caption (not org-ascii-caption-above))
+        (concat "\n" caption))))))
+
+
+;;;; Statistics Cookie
+
+(defun org-ascii-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-element-property :value statistics-cookie))
+
+
+;;;; Subscript
+
+(defun org-ascii-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to ASCII.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (if (org-element-property :use-brackets-p subscript)
+      (format "_{%s}" contents)
+    (format "_%s" contents)))
+
+
+;;;; Superscript
+
+(defun org-ascii-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to ASCII.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (if (org-element-property :use-brackets-p superscript)
+      (format "_{%s}" contents)
+    (format "_%s" contents)))
+
+
+;;;; Strike-through
+
+(defun org-ascii-strike-through (strike-through contents info)
+  "Transcode STRIKE-THROUGH from Org to ASCII.
+CONTENTS is text with strike-through markup.  INFO is a plist
+holding contextual information."
+  (format "+%s+" contents))
+
+
+;;;; Table
+
+(defun org-ascii-table (table contents info)
+  "Transcode a TABLE element from Org to ASCII.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (let ((caption (org-ascii--build-caption table info)))
+    (concat
+     ;; Possibly add a caption string above.
+     (when (and caption org-ascii-caption-above) (concat caption "\n"))
+     ;; Insert table.  Note: "table.el" tables are left unmodified.
+     (cond ((eq (org-element-property :type table) 'org) contents)
+          ((and org-ascii-table-use-ascii-art
+                (eq (plist-get info :ascii-charset) 'utf-8)
+                (require 'ascii-art-to-unicode nil t))
+           (with-temp-buffer
+             (insert (org-remove-indentation
+                      (org-element-property :value table)))
+             (goto-char (point-min))
+             (aa2u)
+             (goto-char (point-max))
+             (skip-chars-backward " \r\t\n")
+             (buffer-substring (point-min) (point))))
+          (t (org-remove-indentation (org-element-property :value table))))
+     ;; Possible add a caption string below.
+     (and (not org-ascii-caption-above) caption))))
+
+
+;;;; Table Cell
+
+(defun org-ascii--table-cell-width (table-cell info)
+  "Return width of TABLE-CELL.
+
+INFO is a plist used as a communication channel.
+
+Width of a cell is determined either by a width cookie in the
+same column as the cell, or by the maximum cell's length in that
+column.
+
+When `org-ascii-table-widen-columns' is non-nil, width cookies
+are ignored."
+  (let* ((row (org-export-get-parent table-cell))
+        (table (org-export-get-parent row))
+        (col (let ((cells (org-element-contents row)))
+               (- (length cells) (length (memq table-cell cells)))))
+        (cache
+         (or (plist-get info :ascii-table-cell-width-cache)
+             (plist-get (setq info
+                              (plist-put info :ascii-table-cell-width-cache
+                                         (make-hash-table :test 'equal)))
+                        :ascii-table-cell-width-cache)))
+        (key (cons table col)))
+    (or (gethash key cache)
+       (puthash
+        key
+        (or (and (not org-ascii-table-widen-columns)
+                 (org-export-table-cell-width table-cell info))
+            (let* ((max-width 0))
+              (org-element-map table 'table-row
+                (lambda (row)
+                  (setq max-width
+                        (max (length
+                              (org-export-data
+                               (org-element-contents
+                                (elt (org-element-contents row) col))
+                               info))
+                             max-width)))
+                info)
+              max-width))
+        cache))))
+
+(defun org-ascii-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL object from Org to ASCII.
+CONTENTS is the cell contents.  INFO is a plist used as
+a communication channel."
+  ;; Determine column width.  When `org-ascii-table-widen-columns'
+  ;; is nil and some width cookie has set it, use that value.
+  ;; Otherwise, compute the maximum width among transcoded data of
+  ;; each cell in the column.
+  (let ((width (org-ascii--table-cell-width table-cell info)))
+    ;; When contents are too large, truncate them.
+    (unless (or org-ascii-table-widen-columns (<= (length contents) width))
+      (setq contents (concat (substring contents 0 (- width 2)) "=>")))
+    ;; Align contents correctly within the cell.
+    (let* ((indent-tabs-mode nil)
+          (data
+           (when contents
+             (org-ascii--justify-string
+              contents width
+              (org-export-table-cell-alignment table-cell info)))))
+      (setq contents (concat data (make-string (- width (length data)) ? ))))
+    ;; Return cell.
+    (concat (format " %s " contents)
+           (when (memq 'right (org-export-table-cell-borders table-cell info))
+             (if (eq (plist-get info :ascii-charset) 'utf-8) "│" "|")))))
+
+
+;;;; Table Row
+
+(defun org-ascii-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to ASCII.
+CONTENTS is the row contents.  INFO is a plist used as
+a communication channel."
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let ((build-hline
+          (function
+           (lambda (lcorner horiz vert rcorner)
+             (concat
+              (apply
+               'concat
+               (org-element-map table-row 'table-cell
+                 (lambda (cell)
+                   (let ((width (org-ascii--table-cell-width cell info))
+                         (borders (org-export-table-cell-borders cell info)))
+                     (concat
+                      ;; In order to know if CELL starts the row, do
+                      ;; not compare it with the first cell in the
+                      ;; row as there might be a special column.
+                      ;; Instead, compare it with first exportable
+                      ;; cell, obtained with `org-element-map'.
+                      (when (and (memq 'left borders)
+                                 (eq (org-element-map table-row 'table-cell
+                                       'identity info t)
+                                     cell))
+                        lcorner)
+                      (make-string (+ 2 width) (string-to-char horiz))
+                      (cond
+                       ((not (memq 'right borders)) nil)
+                       ((eq (car (last (org-element-contents table-row))) cell)
+                        rcorner)
+                       (t vert)))))
+                 info)) "\n"))))
+         (utf8p (eq (plist-get info :ascii-charset) 'utf-8))
+         (borders (org-export-table-cell-borders
+                   (org-element-map table-row 'table-cell 'identity info t)
+                   info)))
+      (concat (cond
+              ((and (memq 'top borders) (or utf8p (memq 'above borders)))
+               (if utf8p (funcall build-hline "┍" "━" "┯" "┑")
+                 (funcall build-hline "+" "-" "+" "+")))
+              ((memq 'above borders)
+               (if utf8p (funcall build-hline "├" "─" "┼" "┤")
+                 (funcall build-hline "+" "-" "+" "+"))))
+             (when (memq 'left borders) (if utf8p "│" "|"))
+             contents "\n"
+             (when (and (memq 'bottom borders) (or utf8p (memq 'below borders)))
+               (if utf8p (funcall build-hline "┕" "━" "┷" "┙")
+                 (funcall build-hline "+" "-" "+" "+")))))))
+
+
+;;;; Timestamp
+
+(defun org-ascii-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-ascii-plain-text (org-timestamp-translate timestamp) info))
+
+
+;;;; Underline
+
+(defun org-ascii-underline (underline contents info)
+  "Transcode UNDERLINE from Org to ASCII.
+CONTENTS is the text with underline markup.  INFO is a plist
+holding contextual information."
+  (format "_%s_" contents))
+
+
+;;;; Verbatim
+
+(defun org-ascii-verbatim (verbatim contents info)
+  "Return a VERBATIM object from Org to ASCII.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (format org-ascii-verbatim-format
+         (org-element-property :value verbatim)))
+
+
+;;;; Verse Block
+
+(defun org-ascii-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to ASCII.
+CONTENTS is verse block contents.  INFO is a plist holding
+contextual information."
+  (let ((verse-width (org-ascii--current-text-width verse-block info)))
+    (org-ascii--indent-string
+     (org-ascii--justify-string contents verse-width 'left)
+     org-ascii-quote-margin)))
+
+
+\f
+;;; Filters
+
+(defun org-ascii-filter-headline-blank-lines (headline back-end info)
+  "Filter controlling number of blank lines after a headline.
+
+HEADLINE is a string representing a transcoded headline.
+BACK-END is symbol specifying back-end used for export.  INFO is
+plist containing the communication channel.
+
+This function only applies to `ascii' back-end.  See
+`org-ascii-headline-spacing' for information."
+  (if (not org-ascii-headline-spacing) headline
+    (let ((blanks (make-string (1+ (cdr org-ascii-headline-spacing)) ?\n)))
+      (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline))))
+
+(defun org-ascii-filter-paragraph-spacing (tree back-end info)
+  "Filter controlling number of blank lines between paragraphs.
+
+TREE is the parse tree.  BACK-END is the symbol specifying
+back-end used for export.  INFO is a plist used as
+a communication channel.
+
+See `org-ascii-paragraph-spacing' for information."
+  (when (wholenump org-ascii-paragraph-spacing)
+    (org-element-map tree 'paragraph
+      (lambda (p)
+       (when (eq (org-element-type (org-export-get-next-element p info))
+                 'paragraph)
+         (org-element-put-property
+          p :post-blank org-ascii-paragraph-spacing)))))
+  tree)
+
+(defun org-ascii-filter-comment-spacing (tree backend info)
+  "Filter removing blank lines between comments.
+TREE is the parse tree.  BACK-END is the symbol specifying
+back-end used for export.  INFO is a plist used as
+a communication channel."
+  (org-element-map tree '(comment comment-block)
+    (lambda (c)
+      (when (memq (org-element-type (org-export-get-next-element c info))
+                 '(comment comment-block))
+       (org-element-put-property c :post-blank 0))))
+  tree)
+
+
+\f
+;;; End-user functions
+
+;;;###autoload
+(defun org-ascii-export-as-ascii
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a text buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, strip title and
+table of contents from output.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Export is done in a buffer named \"*Org ASCII Export*\", which
+will be displayed when `org-export-show-temporary-export-buffer'
+is non-nil."
+  (interactive)
+  (org-export-to-buffer 'ascii "*Org ASCII Export*"
+    async subtreep visible-only body-only ext-plist (lambda () (text-mode))))
+
+;;;###autoload
+(defun org-ascii-export-to-ascii
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a text file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, strip title and
+table of contents from output.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let ((file (org-export-output-file-name ".txt" subtreep)))
+    (org-export-to-file 'ascii file
+      async subtreep visible-only body-only ext-plist)))
+
+;;;###autoload
+(defun org-ascii-publish-to-ascii (plist filename pub-dir)
+  "Publish an Org file to ASCII.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to
+   'ascii filename ".txt" `(:ascii-charset ascii ,@plist) pub-dir))
+
+;;;###autoload
+(defun org-ascii-publish-to-latin1 (plist filename pub-dir)
+  "Publish an Org file to Latin-1.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to
+   'ascii filename ".txt" `(:ascii-charset latin1 ,@plist) pub-dir))
+
+;;;###autoload
+(defun org-ascii-publish-to-utf8 (plist filename pub-dir)
+  "Publish an org file to UTF-8.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to
+   'ascii filename ".txt" `(:ascii-charset utf-8 ,@plist) pub-dir))
+
+
+(provide 'ox-ascii)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; coding: utf-8-emacs
+;; End:
+
+;;; ox-ascii.el ends here
diff --git a/lisp/org/ox-beamer.el b/lisp/org/ox-beamer.el
new file mode 100644 (file)
index 0000000..2868944
--- /dev/null
@@ -0,0 +1,1181 @@
+;;; ox-beamer.el --- Beamer Back-End for Org Export Engine
+
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
+
+;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
+;;         Nicolas Goaziou <n.goaziou AT gmail DOT com>
+;; Keywords: org, wp, tex
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements both a Beamer back-end, derived from the
+;; LaTeX one and a minor mode easing structure edition of the
+;; document.  See Org manual for more information.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox-latex)
+
+;; Install a default set-up for Beamer export.
+(unless (assoc "beamer" org-latex-classes)
+  (add-to-list 'org-latex-classes
+              '("beamer"
+                "\\documentclass[presentation]{beamer}
+\[DEFAULT-PACKAGES]
+\[PACKAGES]
+\[EXTRA]"
+                ("\\section{%s}" . "\\section*{%s}")
+                ("\\subsection{%s}" . "\\subsection*{%s}")
+                ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
+
+
+\f
+;;; User-Configurable Variables
+
+(defgroup org-export-beamer nil
+  "Options specific for using the beamer class in LaTeX export."
+  :tag "Org Beamer"
+  :group 'org-export
+  :version "24.2")
+
+(defcustom org-beamer-frame-level 1
+  "The level at which headlines become frames.
+
+Headlines at a lower level will be translated into a sectioning
+structure.  At a higher level, they will be translated into
+blocks.
+
+If a headline with a \"BEAMER_env\" property set to \"frame\" is
+found within a tree, its level locally overrides this number.
+
+This variable has no effect on headlines with the \"BEAMER_env\"
+property set to either \"ignoreheading\", \"appendix\", or
+\"note\", which will respectively, be invisible, become an
+appendix or a note.
+
+This integer is relative to the minimal level of a headline
+within the parse tree, defined as 1."
+  :group 'org-export-beamer
+  :type 'integer)
+
+(defcustom org-beamer-frame-default-options ""
+  "Default options string to use for frames.
+For example, it could be set to \"allowframebreaks\"."
+  :group 'org-export-beamer
+  :type '(string :tag "[options]"))
+
+(defcustom org-beamer-column-view-format
+  "%45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)"
+  "Column view format that should be used to fill the template."
+  :group 'org-export-beamer
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const  :tag "Do not insert Beamer column view format" nil)
+         (string :tag "Beamer column view format")))
+
+(defcustom org-beamer-theme "default"
+  "Default theme used in Beamer presentations."
+  :group 'org-export-beamer
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Do not insert a Beamer theme" nil)
+         (string :tag "Beamer theme")))
+
+(defcustom org-beamer-environments-extra nil
+  "Environments triggered by tags in Beamer export.
+Each entry has 4 elements:
+
+name    Name of the environment
+key     Selection key for `org-beamer-select-environment'
+open    The opening template for the environment, with the following escapes
+        %a   the action/overlay specification
+        %A   the default action/overlay specification
+        %o   the options argument of the template
+        %h   the headline text
+        %r   the raw headline text (i.e. without any processing)
+        %H   if there is headline text, that raw text in {} braces
+        %U   if there is headline text, that raw text in [] brackets
+close   The closing string of the environment."
+  :group 'org-export-beamer
+  :version "24.4"
+  :package-version '(Org . "8.1")
+  :type '(repeat
+         (list
+          (string :tag "Environment")
+          (string :tag "Selection key")
+          (string :tag "Begin")
+          (string :tag "End"))))
+
+(defcustom org-beamer-outline-frame-title "Outline"
+  "Default title of a frame containing an outline."
+  :group 'org-export-beamer
+  :type '(string :tag "Outline frame title"))
+
+(defcustom org-beamer-outline-frame-options ""
+  "Outline frame options appended after \\begin{frame}.
+You might want to put e.g. \"allowframebreaks=0.9\" here."
+  :group 'org-export-beamer
+  :type '(string :tag "Outline frame options"))
+
+
+\f
+;;; Internal Variables
+
+(defconst org-beamer-column-widths
+  "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
+"The column widths that should be installed as allowed property values.")
+
+(defconst org-beamer-environments-special
+  '(("againframe"     "A")
+    ("appendix"       "x")
+    ("column"         "c")
+    ("columns"        "C")
+    ("frame"          "f")
+    ("fullframe"      "F")
+    ("ignoreheading"  "i")
+    ("note"           "n")
+    ("noteNH"         "N"))
+  "Alist of environments treated in a special way by the back-end.
+Keys are environment names, as strings, values are bindings used
+in `org-beamer-select-environment'.  Environments listed here,
+along with their binding, are hard coded and cannot be modified
+through `org-beamer-environments-extra' variable.")
+
+(defconst org-beamer-environments-default
+  '(("block"          "b" "\\begin{block}%a{%h}"          "\\end{block}")
+    ("alertblock"     "a" "\\begin{alertblock}%a{%h}"     "\\end{alertblock}")
+    ("verse"          "v" "\\begin{verse}%a %% %h"        "\\end{verse}")
+    ("quotation"      "q" "\\begin{quotation}%a %% %h"    "\\end{quotation}")
+    ("quote"          "Q" "\\begin{quote}%a %% %h"        "\\end{quote}")
+    ("structureenv"   "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
+    ("theorem"        "t" "\\begin{theorem}%a%U"          "\\end{theorem}")
+    ("definition"     "d" "\\begin{definition}%a%U"       "\\end{definition}")
+    ("example"        "e" "\\begin{example}%a%U"          "\\end{example}")
+    ("exampleblock"   "E" "\\begin{exampleblock}%a{%h}"   "\\end{exampleblock}")
+    ("proof"          "p" "\\begin{proof}%a%U"            "\\end{proof}")
+    ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
+  "Environments triggered by properties in Beamer export.
+These are the defaults - for user definitions, see
+`org-beamer-environments-extra'.")
+
+(defconst org-beamer-verbatim-elements
+  '(code example-block fixed-width inline-src-block src-block verbatim)
+  "List of element or object types producing verbatim text.
+This is used internally to determine when a frame should have the
+\"fragile\" option.")
+
+
+\f
+;;; Internal functions
+
+(defun org-beamer--normalize-argument (argument type)
+  "Return ARGUMENT string with proper boundaries.
+
+TYPE is a symbol among the following:
+`action'    Return ARGUMENT within angular brackets.
+`defaction' Return ARGUMENT within both square and angular brackets.
+`option'    Return ARGUMENT within square brackets."
+  (if (not (string-match "\\S-" argument)) ""
+    (case type
+      (action (if (string-match "\\`<.*>\\'" argument) argument
+               (format "<%s>" argument)))
+      (defaction (cond
+                 ((string-match "\\`\\[<.*>\\]\\'" argument) argument)
+                 ((string-match "\\`<.*>\\'" argument)
+                  (format "[%s]" argument))
+                 ((string-match "\\`\\[\\(.*\\)\\]\\'" argument)
+                  (format "[<%s>]" (match-string 1 argument)))
+                 (t (format "[<%s>]" argument))))
+      (option (if (string-match "\\`\\[.*\\]\\'" argument) argument
+               (format "[%s]" argument)))
+      (otherwise argument))))
+
+(defun org-beamer--element-has-overlay-p (element)
+  "Non-nil when ELEMENT has an overlay specified.
+An element has an overlay specification when it starts with an
+`beamer' export-snippet whose value is between angular brackets.
+Return overlay specification, as a string, or nil."
+  (let ((first-object (car (org-element-contents element))))
+    (when (eq (org-element-type first-object) 'export-snippet)
+      (let ((value (org-element-property :value first-object)))
+       (and (string-match "\\`<.*>\\'" value) value)))))
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-derived-backend 'beamer 'latex
+  :export-block "BEAMER"
+  :menu-entry
+  '(?l 1
+       ((?B "As LaTeX buffer (Beamer)" org-beamer-export-as-latex)
+       (?b "As LaTeX file (Beamer)" org-beamer-export-to-latex)
+       (?P "As PDF file (Beamer)" org-beamer-export-to-pdf)
+       (?O "As PDF file and open (Beamer)"
+           (lambda (a s v b)
+             (if a (org-beamer-export-to-pdf t s v b)
+               (org-open-file (org-beamer-export-to-pdf nil s v b)))))))
+  :options-alist
+  '((:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
+    (:beamer-color-theme "BEAMER_COLOR_THEME" nil nil t)
+    (:beamer-font-theme "BEAMER_FONT_THEME" nil nil t)
+    (:beamer-inner-theme "BEAMER_INNER_THEME" nil nil t)
+    (:beamer-outer-theme "BEAMER_OUTER_THEME" nil nil t)
+    (:beamer-header-extra "BEAMER_HEADER" nil nil newline)
+    ;; Modify existing properties.
+    (:headline-levels nil "H" org-beamer-frame-level)
+    (:latex-class "LATEX_CLASS" nil "beamer" t))
+  :translate-alist '((bold . org-beamer-bold)
+                    (export-block . org-beamer-export-block)
+                    (export-snippet . org-beamer-export-snippet)
+                    (headline . org-beamer-headline)
+                    (item . org-beamer-item)
+                    (keyword . org-beamer-keyword)
+                    (link . org-beamer-link)
+                    (plain-list . org-beamer-plain-list)
+                    (radio-target . org-beamer-radio-target)
+                    (target . org-beamer-target)
+                    (template . org-beamer-template)))
+
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-beamer-bold (bold contents info)
+  "Transcode BLOCK object into Beamer code.
+CONTENTS is the text being bold.  INFO is a plist used as
+a communication channel."
+  (format "\\alert%s{%s}"
+         (or (org-beamer--element-has-overlay-p bold) "")
+         contents))
+
+
+;;;; Export Block
+
+(defun org-beamer-export-block (export-block contents info)
+  "Transcode an EXPORT-BLOCK element into Beamer code.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (when (member (org-element-property :type export-block) '("BEAMER" "LATEX"))
+    (org-remove-indentation (org-element-property :value export-block))))
+
+
+;;;; Export Snippet
+
+(defun org-beamer-export-snippet (export-snippet contents info)
+  "Transcode an EXPORT-SNIPPET object into Beamer code.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((backend (org-export-snippet-backend export-snippet))
+       (value (org-element-property :value export-snippet)))
+    ;; Only "latex" and "beamer" snippets are retained.
+    (cond ((eq backend 'latex) value)
+         ;; Ignore "beamer" snippets specifying overlays.
+         ((and (eq backend 'beamer)
+               (or (org-export-get-previous-element export-snippet info)
+                   (not (string-match "\\`<.*>\\'" value))))
+          value))))
+
+
+;;;; Headline
+;;
+;; The main function to translate a headline is
+;; `org-beamer-headline'.
+;;
+;; Depending on the level at which a headline is considered as
+;; a frame (given by `org-beamer--frame-level'), the headline is
+;; either a section (`org-beamer--format-section'), a frame
+;; (`org-beamer--format-frame') or a block
+;; (`org-beamer--format-block').
+;;
+;; `org-beamer-headline' also takes care of special environments
+;; like "ignoreheading", "note", "noteNH", "appendix" and
+;; "againframe".
+
+(defun org-beamer--get-label (headline info)
+  "Return label for HEADLINE, as a string.
+
+INFO is a plist used as a communication channel.
+
+The value is either the label specified in \"BEAMER_opt\"
+property, or a fallback value built from headline's number.  This
+function assumes HEADLINE will be treated as a frame."
+  (let ((opt (org-element-property :BEAMER_OPT headline)))
+    (if (and (org-string-nw-p opt)
+            (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt))
+       (match-string 1 opt)
+      (format "sec-%s"
+             (mapconcat 'number-to-string
+                        (org-export-get-headline-number headline info)
+                        "-")))))
+
+(defun org-beamer--frame-level (headline info)
+  "Return frame level in subtree containing HEADLINE.
+INFO is a plist used as a communication channel."
+  (or
+   ;; 1. Look for "frame" environment in parents, starting from the
+   ;;    farthest.
+   (catch 'exit
+     (mapc (lambda (parent)
+            (let ((env (org-element-property :BEAMER_ENV parent)))
+              (when (and env (member-ignore-case env '("frame" "fullframe")))
+                (throw 'exit (org-export-get-relative-level parent info)))))
+          (nreverse (org-export-get-genealogy headline)))
+     nil)
+   ;; 2. Look for "frame" environment in HEADLINE.
+   (let ((env (org-element-property :BEAMER_ENV headline)))
+     (and env (member-ignore-case env '("frame" "fullframe"))
+         (org-export-get-relative-level headline info)))
+   ;; 3. Look for "frame" environment in sub-tree.
+   (org-element-map headline 'headline
+     (lambda (hl)
+       (let ((env (org-element-property :BEAMER_ENV hl)))
+        (when (and env (member-ignore-case env '("frame" "fullframe")))
+          (org-export-get-relative-level hl info))))
+     info 'first-match)
+   ;; 4. No "frame" environment in tree: use default value.
+   (plist-get info :headline-levels)))
+
+(defun org-beamer--format-section (headline contents info)
+  "Format HEADLINE as a sectioning part.
+CONTENTS holds the contents of the headline.  INFO is a plist
+used as a communication channel."
+  (let ((latex-headline
+        (org-export-with-backend
+         ;; We create a temporary export back-end which behaves the
+         ;; same as current one, but adds "\protect" in front of the
+         ;; output of some objects.
+         (org-export-create-backend
+          :parent 'latex
+          :transcoders
+          (let ((protected-output
+                 (function
+                  (lambda (object contents info)
+                    (let ((code (org-export-with-backend
+                                 'beamer object contents info)))
+                      (if (org-string-nw-p code) (concat "\\protect" code)
+                        code))))))
+            (mapcar #'(lambda (type) (cons type protected-output))
+                    '(bold footnote-reference italic strike-through timestamp
+                           underline))))
+         headline
+         contents
+         info))
+       (mode-specs (org-element-property :BEAMER_ACT headline)))
+    (if (and mode-specs
+            (string-match "\\`\\\\\\(.*?\\)\\(?:\\*\\|\\[.*\\]\\)?{"
+                          latex-headline))
+       ;; Insert overlay specifications.
+       (replace-match (concat (match-string 1 latex-headline)
+                              (format "<%s>" mode-specs))
+                      nil nil latex-headline 1)
+      latex-headline)))
+
+(defun org-beamer--format-frame (headline contents info)
+  "Format HEADLINE as a frame.
+CONTENTS holds the contents of the headline.  INFO is a plist
+used as a communication channel."
+  (let ((fragilep
+        ;; FRAGILEP is non-nil when HEADLINE contains an element
+        ;; among `org-beamer-verbatim-elements'.
+        (org-element-map headline org-beamer-verbatim-elements 'identity
+                         info 'first-match)))
+    (concat "\\begin{frame}"
+           ;; Overlay specification, if any. When surrounded by
+           ;; square brackets, consider it as a default
+           ;; specification.
+           (let ((action (org-element-property :BEAMER_ACT headline)))
+             (cond
+              ((not action) "")
+              ((string-match "\\`\\[.*\\]\\'" action )
+               (org-beamer--normalize-argument action 'defaction))
+              (t (org-beamer--normalize-argument action 'action))))
+           ;; Options, if any.
+           (let* ((beamer-opt (org-element-property :BEAMER_OPT headline))
+                  (options
+                   ;; Collect options from default value and headline's
+                   ;; properties.  Also add a label for links.
+                   (append
+                    (org-split-string org-beamer-frame-default-options ",")
+                    (and beamer-opt
+                         (org-split-string
+                          ;; Remove square brackets if user provided
+                          ;; them.
+                          (and (string-match "^\\[?\\(.*\\)\\]?$" beamer-opt)
+                               (match-string 1 beamer-opt))
+                          ","))
+                    ;; Provide an automatic label for the frame
+                    ;; unless the user specified one.
+                    (unless (and beamer-opt
+                                 (string-match "\\(^\\|,\\)label=" beamer-opt))
+                      (list
+                       (format "label=%s"
+                               (org-beamer--get-label headline info)))))))
+             ;; Change options list into a string.
+             (org-beamer--normalize-argument
+              (mapconcat
+               'identity
+               (if (or (not fragilep) (member "fragile" options)) options
+                 (cons "fragile" options))
+               ",")
+              'option))
+           ;; Title.
+           (let ((env (org-element-property :BEAMER_ENV headline)))
+             (format "{%s}"
+                     (if (and env (equal (downcase env) "fullframe")) ""
+                       (org-export-data
+                        (org-element-property :title headline) info))))
+           "\n"
+           ;; The following workaround is required in fragile frames
+           ;; as Beamer will append "\par" to the beginning of the
+           ;; contents.  So we need to make sure the command is
+           ;; separated from the contents by at least one space.  If
+           ;; it isn't, it will create "\parfirst-word" command and
+           ;; remove the first word from the contents in the PDF
+           ;; output.
+           (if (not fragilep) contents
+             (replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
+           "\\end{frame}")))
+
+(defun org-beamer--format-block (headline contents info)
+  "Format HEADLINE as a block.
+CONTENTS holds the contents of the headline.  INFO is a plist
+used as a communication channel."
+  (let* ((column-width (org-element-property :BEAMER_COL headline))
+        ;; ENVIRONMENT defaults to "block" if none is specified and
+        ;; there is no column specification.  If there is a column
+        ;; specified but still no explicit environment, ENVIRONMENT
+        ;; is "column".
+        (environment (let ((env (org-element-property :BEAMER_ENV headline)))
+                       (cond
+                        ;; "block" is the fallback environment.
+                        ((and (not env) (not column-width)) "block")
+                        ;; "column" only.
+                        ((not env) "column")
+                        ;; Use specified environment.
+                        (t env))))
+        (raw-title (org-element-property :raw-value headline))
+        (env-format
+         (cond ((member environment '("column" "columns")) nil)
+               ((assoc environment
+                       (append org-beamer-environments-extra
+                               org-beamer-environments-default)))
+               (t (user-error "Wrong block type at a headline named \"%s\""
+                              raw-title))))
+        (title (org-export-data (org-element-property :title headline) info))
+        (options (let ((options (org-element-property :BEAMER_OPT headline)))
+                   (if (not options) ""
+                     (org-beamer--normalize-argument options 'option))))
+        ;; Start a "columns" environment when explicitly requested or
+        ;; when there is no previous headline or the previous
+        ;; headline do not have a BEAMER_column property.
+        (parent-env (org-element-property
+                     :BEAMER_ENV (org-export-get-parent-headline headline)))
+        (start-columns-p
+         (or (equal environment "columns")
+             (and column-width
+                  (not (and parent-env
+                            (equal (downcase parent-env) "columns")))
+                  (or (org-export-first-sibling-p headline info)
+                      (not (org-element-property
+                            :BEAMER_COL
+                            (org-export-get-previous-element
+                             headline info)))))))
+        ;; End the "columns" environment when explicitly requested or
+        ;; when there is no next headline or the next headline do not
+        ;; have a BEAMER_column property.
+        (end-columns-p
+         (or (equal environment "columns")
+             (and column-width
+                  (not (and parent-env
+                            (equal (downcase parent-env) "columns")))
+                  (or (org-export-last-sibling-p headline info)
+                      (not (org-element-property
+                            :BEAMER_COL
+                            (org-export-get-next-element headline info))))))))
+    (concat
+     (when start-columns-p
+       ;; Column can accept options only when the environment is
+       ;; explicitly defined.
+       (if (not (equal environment "columns")) "\\begin{columns}\n"
+        (format "\\begin{columns}%s\n" options)))
+     (when column-width
+       (format "\\begin{column}%s{%s}\n"
+              ;; One can specify placement for column only when
+              ;; HEADLINE stands for a column on its own.
+              (if (equal environment "column") options "")
+              (format "%s\\textwidth" column-width)))
+     ;; Block's opening string.
+     (when (nth 2 env-format)
+       (concat
+       (org-fill-template
+        (nth 2 env-format)
+        (nconc
+         ;; If BEAMER_act property has its value enclosed in square
+         ;; brackets, it is a default overlay specification and
+         ;; overlay specification is empty.  Otherwise, it is an
+         ;; overlay specification and the default one is nil.
+         (let ((action (org-element-property :BEAMER_ACT headline)))
+           (cond
+            ((not action) (list (cons "a" "") (cons "A" "")))
+            ((string-match "\\`\\[.*\\]\\'" action)
+             (list
+              (cons "A" (org-beamer--normalize-argument action 'defaction))
+              (cons "a" "")))
+            (t
+             (list (cons "a" (org-beamer--normalize-argument action 'action))
+                   (cons "A" "")))))
+         (list (cons "o" options)
+               (cons "h" title)
+               (cons "r" raw-title)
+               (cons "H" (if (equal raw-title "") ""
+                           (format "{%s}" raw-title)))
+               (cons "U" (if (equal raw-title "") ""
+                           (format "[%s]" raw-title))))))
+       "\n"))
+     contents
+     ;; Block's closing string, if any.
+     (and (nth 3 env-format) (concat (nth 3 env-format) "\n"))
+     (when column-width "\\end{column}\n")
+     (when end-columns-p "\\end{columns}"))))
+
+(defun org-beamer-headline (headline contents info)
+  "Transcode HEADLINE element into Beamer code.
+CONTENTS is the contents of the headline.  INFO is a plist used
+as a communication channel."
+  (unless (org-element-property :footnote-section-p headline)
+    (let ((level (org-export-get-relative-level headline info))
+         (frame-level (org-beamer--frame-level headline info))
+         (environment (let ((env (org-element-property :BEAMER_ENV headline)))
+                        (or (org-string-nw-p env) "block"))))
+      (cond
+       ;; Case 1: Resume frame specified by "BEAMER_ref" property.
+       ((equal environment "againframe")
+       (let ((ref (org-element-property :BEAMER_REF headline)))
+         ;; Reference to frame being resumed is mandatory.  Ignore
+         ;; the whole headline if it isn't provided.
+         (when (org-string-nw-p ref)
+           (concat "\\againframe"
+                   ;; Overlay specification.
+                   (let ((overlay (org-element-property :BEAMER_ACT headline)))
+                     (when overlay
+                       (org-beamer--normalize-argument
+                        overlay
+                        (if (string-match "^\\[.*\\]$" overlay) 'defaction
+                          'action))))
+                   ;; Options.
+                   (let ((options (org-element-property :BEAMER_OPT headline)))
+                     (when options
+                       (org-beamer--normalize-argument options 'option)))
+                   ;; Resolve reference provided by "BEAMER_ref"
+                   ;; property.  This is done by building a minimal fake
+                   ;; link and calling the appropriate resolve function,
+                   ;; depending on the reference syntax.
+                   (let* ((type
+                           (progn
+                             (string-match "^\\(id:\\|#\\|\\*\\)?\\(.*\\)" ref)
+                             (cond
+                              ((or (not (match-string 1 ref))
+                                   (equal (match-string 1 ref) "*")) 'fuzzy)
+                              ((equal (match-string 1 ref) "id:") 'id)
+                              (t 'custom-id))))
+                          (link (list 'link (list :path (match-string 2 ref))))
+                          (target (if (eq type 'fuzzy)
+                                      (org-export-resolve-fuzzy-link link info)
+                                    (org-export-resolve-id-link link info))))
+                     ;; Now use user-defined label provided in TARGET
+                     ;; headline, or fallback to standard one.
+                     (format "{%s}" (org-beamer--get-label target info)))))))
+       ;; Case 2: Creation of an appendix is requested.
+       ((equal environment "appendix")
+       (concat "\\appendix"
+               (org-element-property :BEAMER_ACT headline)
+               "\n"
+               (make-string (org-element-property :pre-blank headline) ?\n)
+               contents))
+       ;; Case 3: Ignore heading.
+       ((equal environment "ignoreheading")
+       (concat (make-string (org-element-property :pre-blank headline) ?\n)
+               contents))
+       ;; Case 4: HEADLINE is a note.
+       ((member environment '("note" "noteNH"))
+       (format "\\note{%s}"
+               (concat (and (equal environment "note")
+                            (concat
+                             (org-export-data
+                              (org-element-property :title headline) info)
+                             "\n"))
+                       (org-trim contents))))
+       ;; Case 5: HEADLINE is a frame.
+       ((= level frame-level)
+       (org-beamer--format-frame headline contents info))
+       ;; Case 6: Regular section, extracted from
+       ;; `org-latex-classes'.
+       ((< level frame-level)
+       (org-beamer--format-section headline contents info))
+       ;; Case 7: Otherwise, HEADLINE is a block.
+       (t (org-beamer--format-block headline contents info))))))
+
+
+;;;; Item
+
+(defun org-beamer-item (item contents info)
+  "Transcode an ITEM element into Beamer code.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let ((action (let ((first-element (car (org-element-contents item))))
+                 (and (eq (org-element-type first-element) 'paragraph)
+                      (org-beamer--element-has-overlay-p first-element))))
+       (output (org-export-with-backend 'latex item contents info)))
+    (if (not action) output
+      ;; If the item starts with a paragraph and that paragraph starts
+      ;; with an export snippet specifying an overlay, insert it after
+      ;; \item command.
+      (replace-regexp-in-string "\\\\item" (concat "\\\\item" action) output))))
+
+
+;;;; Keyword
+
+(defun org-beamer-keyword (keyword contents info)
+  "Transcode a KEYWORD element into Beamer code.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    ;; Handle specifically BEAMER and TOC (headlines only) keywords.
+    ;; Otherwise, fallback to `latex' back-end.
+    (cond
+     ((equal key "BEAMER") value)
+     ((and (equal key "TOC") (string-match "\\<headlines\\>" value))
+      (let ((depth (or (and (string-match "[0-9]+" value)
+                           (string-to-number (match-string 0 value)))
+                      (plist-get info :with-toc)))
+           (options (and (string-match "\\[.*?\\]" value)
+                         (match-string 0 value))))
+       (concat
+        (when (wholenump depth) (format "\\setcounter{tocdepth}{%s}\n" depth))
+        "\\tableofcontents" options)))
+     (t (org-export-with-backend 'latex keyword contents info)))))
+
+
+;;;; Link
+
+(defun org-beamer-link (link contents info)
+  "Transcode a LINK object into Beamer code.
+CONTENTS is the description part of the link.  INFO is a plist
+used as a communication channel."
+  (let ((type (org-element-property :type link))
+       (path (org-element-property :path link)))
+    ;; Use \hyperlink command for all internal links.
+    (cond
+     ((equal type "radio")
+      (let ((destination (org-export-resolve-radio-link link info)))
+       (when destination
+         (format "\\hyperlink%s{%s}{%s}"
+                 (or (org-beamer--element-has-overlay-p link) "")
+                 (org-export-solidify-link-text path)
+                 (org-export-data (org-element-contents destination) info)))))
+     ((and (member type '("custom-id" "fuzzy" "id"))
+          (let ((destination (if (string= type "fuzzy")
+                                 (org-export-resolve-fuzzy-link link info)
+                               (org-export-resolve-id-link link info))))
+            (case (org-element-type destination)
+              (headline
+               (let ((label
+                      (format "sec-%s"
+                              (mapconcat
+                               'number-to-string
+                               (org-export-get-headline-number
+                                destination info)
+                               "-"))))
+                 (if (and (plist-get info :section-numbers) (not contents))
+                     (format "\\ref{%s}" label)
+                   (format "\\hyperlink%s{%s}{%s}"
+                           (or (org-beamer--element-has-overlay-p link) "")
+                           label
+                           contents))))
+              (target
+               (let ((path (org-export-solidify-link-text path)))
+                 (if (not contents) (format "\\ref{%s}" path)
+                   (format "\\hyperlink%s{%s}{%s}"
+                           (or (org-beamer--element-has-overlay-p link) "")
+                           path
+                           contents))))))))
+     ;; Otherwise, use `latex' back-end.
+     (t (org-export-with-backend 'latex link contents info)))))
+
+
+;;;; Plain List
+;;
+;; Plain lists support `:environment', `:overlay' and `:options'
+;; attributes.
+
+(defun org-beamer-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element into Beamer code.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  (let* ((type (org-element-property :type plain-list))
+        (attributes (org-combine-plists
+                     (org-export-read-attribute :attr_latex plain-list)
+                     (org-export-read-attribute :attr_beamer plain-list)))
+        (latex-type (let ((env (plist-get attributes :environment)))
+                      (cond (env)
+                            ((eq type 'ordered) "enumerate")
+                            ((eq type 'descriptive) "description")
+                            (t "itemize")))))
+    (org-latex--wrap-label
+     plain-list
+     (format "\\begin{%s}%s%s\n%s\\end{%s}"
+            latex-type
+            ;; Default overlay specification, if any.
+            (org-beamer--normalize-argument
+             (or (plist-get attributes :overlay) "")
+             'defaction)
+            ;; Second optional argument depends on the list type.
+            (org-beamer--normalize-argument
+             (or (plist-get attributes :options) "")
+             'option)
+            ;; Eventually insert contents and close environment.
+            contents
+            latex-type))))
+
+
+;;;; Radio Target
+
+(defun org-beamer-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object into Beamer code.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  (format "\\hypertarget%s{%s}{%s}"
+         (or (org-beamer--element-has-overlay-p radio-target) "")
+         (org-export-solidify-link-text
+          (org-element-property :value radio-target))
+         text))
+
+
+;;;; Target
+
+(defun org-beamer-target (target contents info)
+  "Transcode a TARGET object into Beamer code.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format "\\hypertarget{%s}{}"
+         (org-export-solidify-link-text (org-element-property :value target))))
+
+
+;;;; Template
+;;
+;; Template used is similar to the one used in `latex' back-end,
+;; excepted for the table of contents and Beamer themes.
+
+(defun org-beamer-template (contents info)
+  "Return complete document string after Beamer conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (let ((title (org-export-data (plist-get info :title) info)))
+    (concat
+     ;; 1. Time-stamp.
+     (and (plist-get info :time-stamp-file)
+         (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
+     ;; 2. Document class and packages.
+     (let* ((class (plist-get info :latex-class))
+           (class-options (plist-get info :latex-class-options))
+           (header (nth 1 (assoc class org-latex-classes)))
+           (document-class-string
+            (and (stringp header)
+                 (if (not class-options) header
+                   (replace-regexp-in-string
+                    "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
+                    class-options header t nil 1)))))
+       (if (not document-class-string)
+          (user-error "Unknown LaTeX class `%s'" class)
+        (org-latex-guess-babel-language
+         (org-latex-guess-inputenc
+          (org-element-normalize-string
+           (org-splice-latex-header
+            document-class-string
+            org-latex-default-packages-alist
+            org-latex-packages-alist nil
+            (concat (org-element-normalize-string
+                     (plist-get info :latex-header))
+                    (org-element-normalize-string
+                     (plist-get info :latex-header-extra))
+                    (plist-get info :beamer-header-extra)))))
+         info)))
+     ;; 3. Insert themes.
+     (let ((format-theme
+           (function
+            (lambda (prop command)
+              (let ((theme (plist-get info prop)))
+                (when theme
+                  (concat command
+                          (if (not (string-match "\\[.*\\]" theme))
+                              (format "{%s}\n" theme)
+                            (format "%s{%s}\n"
+                                    (match-string 0 theme)
+                                    (org-trim
+                                     (replace-match "" nil nil theme)))))))))))
+       (mapconcat (lambda (args) (apply format-theme args))
+                 '((:beamer-theme "\\usetheme")
+                   (:beamer-color-theme "\\usecolortheme")
+                   (:beamer-font-theme "\\usefonttheme")
+                   (:beamer-inner-theme "\\useinnertheme")
+                   (:beamer-outer-theme "\\useoutertheme"))
+                 ""))
+     ;; 4. Possibly limit depth for headline numbering.
+     (let ((sec-num (plist-get info :section-numbers)))
+       (when (integerp sec-num)
+        (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
+     ;; 5. Author.
+     (let ((author (and (plist-get info :with-author)
+                       (let ((auth (plist-get info :author)))
+                         (and auth (org-export-data auth info)))))
+          (email (and (plist-get info :with-email)
+                      (org-export-data (plist-get info :email) info))))
+       (cond ((and author email (not (string= "" email)))
+             (format "\\author{%s\\thanks{%s}}\n" author email))
+            (author (format "\\author{%s}\n" author))
+            (t "\\author{}\n")))
+     ;; 6. Date.
+     (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
+       (format "\\date{%s}\n" (org-export-data date info)))
+     ;; 7. Title
+     (format "\\title{%s}\n" title)
+     ;; 8. Hyperref options.
+     (when (plist-get info :latex-hyperref-p)
+       (format "\\hypersetup{\n  pdfkeywords={%s},\n  pdfsubject={%s},\n  pdfcreator={%s}}\n"
+              (or (plist-get info :keywords) "")
+              (or (plist-get info :description) "")
+              (if (not (plist-get info :with-creator)) ""
+                (plist-get info :creator))))
+     ;; 9. Document start.
+     "\\begin{document}\n\n"
+     ;; 10. Title command.
+     (org-element-normalize-string
+      (cond ((string= "" title) nil)
+           ((not (stringp org-latex-title-command)) nil)
+           ((string-match "\\(?:[^%]\\|^\\)%s"
+                          org-latex-title-command)
+            (format org-latex-title-command title))
+           (t org-latex-title-command)))
+     ;; 11. Table of contents.
+     (let ((depth (plist-get info :with-toc)))
+       (when depth
+        (concat
+         (format "\\begin{frame}%s{%s}\n"
+                 (org-beamer--normalize-argument
+                  org-beamer-outline-frame-options 'option)
+                 org-beamer-outline-frame-title)
+         (when (wholenump depth)
+           (format "\\setcounter{tocdepth}{%d}\n" depth))
+         "\\tableofcontents\n"
+         "\\end{frame}\n\n")))
+     ;; 12. Document's body.
+     contents
+     ;; 13. Creator.
+     (let ((creator-info (plist-get info :with-creator)))
+       (cond
+       ((not creator-info) "")
+       ((eq creator-info 'comment)
+        (format "%% %s\n" (plist-get info :creator)))
+       (t (concat (plist-get info :creator) "\n"))))
+     ;; 14. Document end.
+     "\\end{document}")))
+
+
+\f
+;;; Minor Mode
+
+
+(defvar org-beamer-mode-map (make-sparse-keymap)
+  "The keymap for `org-beamer-mode'.")
+(define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
+
+;;;###autoload
+(define-minor-mode org-beamer-mode
+  "Support for editing Beamer oriented Org mode files."
+  nil " Bm" 'org-beamer-mode-map)
+
+(when (fboundp 'font-lock-add-keywords)
+  (font-lock-add-keywords
+   'org-mode
+   '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
+   'prepend))
+
+(defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
+  "The special face for beamer tags."
+  :group 'org-export-beamer)
+
+(defun org-beamer-property-changed (property value)
+  "Track the BEAMER_env property with tags.
+PROPERTY is the name of the modified property.  VALUE is its new
+value."
+  (cond
+   ((equal property "BEAMER_env")
+    (save-excursion
+      (org-back-to-heading t)
+      ;; Filter out Beamer-related tags and install environment tag.
+      (let ((tags (org-remove-if (lambda (x) (string-match "^B_" x))
+                                (org-get-tags)))
+           (env-tag (and (org-string-nw-p value) (concat "B_" value))))
+       (org-set-tags-to (if env-tag (cons env-tag tags) tags))
+       (when env-tag (org-toggle-tag env-tag 'on)))))
+   ((equal property "BEAMER_col")
+    (org-toggle-tag "BMCOL" (if (org-string-nw-p value) 'on 'off)))))
+
+(add-hook 'org-property-changed-functions 'org-beamer-property-changed)
+
+(defun org-beamer-allowed-property-values (property)
+  "Supply allowed values for PROPERTY."
+  (cond
+   ((and (equal property "BEAMER_env")
+        (not (org-entry-get nil (concat property "_ALL") 'inherit)))
+    ;; If no allowed values for BEAMER_env have been defined,
+    ;; supply all defined environments
+    (mapcar 'car (append org-beamer-environments-special
+                        org-beamer-environments-extra
+                        org-beamer-environments-default)))
+   ((and (equal property "BEAMER_col")
+        (not (org-entry-get nil (concat property "_ALL") 'inherit)))
+    ;; If no allowed values for BEAMER_col have been defined,
+    ;; supply some
+    (org-split-string org-beamer-column-widths " "))))
+
+(add-hook 'org-property-allowed-value-functions
+         'org-beamer-allowed-property-values)
+
+
+\f
+;;; Commands
+
+;;;###autoload
+(defun org-beamer-export-as-latex
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer as a Beamer buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Export is done in a buffer named \"*Org BEAMER Export*\", which
+will be displayed when `org-export-show-temporary-export-buffer'
+is non-nil."
+  (interactive)
+  (org-export-to-buffer 'beamer "*Org BEAMER Export*"
+    async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
+
+;;;###autoload
+(defun org-beamer-export-to-latex
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer as a Beamer presentation (tex).
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let ((file (org-export-output-file-name ".tex" subtreep)))
+    (org-export-to-file 'beamer file
+      async subtreep visible-only body-only ext-plist)))
+
+;;;###autoload
+(defun org-beamer-export-to-pdf
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer as a Beamer presentation (PDF).
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return PDF file's name."
+  (interactive)
+  (let ((file (org-export-output-file-name ".tex" subtreep)))
+    (org-export-to-file 'beamer file
+      async subtreep visible-only body-only ext-plist
+      (lambda (file) (org-latex-compile file)))))
+
+;;;###autoload
+(defun org-beamer-select-environment ()
+  "Select the environment to be used by beamer for this entry.
+While this uses (for convenience) a tag selection interface, the
+result of this command will be that the BEAMER_env *property* of
+the entry is set.
+
+In addition to this, the command will also set a tag as a visual
+aid, but the tag does not have any semantic meaning."
+  (interactive)
+  ;; Make sure `org-beamer-environments-special' has a higher
+  ;; priority than `org-beamer-environments-extra'.
+  (let* ((envs (append org-beamer-environments-special
+                      org-beamer-environments-extra
+                      org-beamer-environments-default))
+        (org-tag-alist
+         (append '((:startgroup))
+                 (mapcar (lambda (e) (cons (concat "B_" (car e))
+                                      (string-to-char (nth 1 e))))
+                         envs)
+                 '((:endgroup))
+                 '(("BMCOL" . ?|))))
+        (org-fast-tag-selection-single-key t))
+    (org-set-tags)
+    (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
+      (cond
+       ;; For a column, automatically ask for its width.
+       ((eq org-last-tag-selection-key ?|)
+       (if (string-match ":BMCOL:" tags)
+           (org-set-property "BEAMER_col" (read-string "Column width: "))
+         (org-delete-property "BEAMER_col")))
+       ;; For an "againframe" section, automatically ask for reference
+       ;; to resumed frame and overlay specifications.
+       ((eq org-last-tag-selection-key ?A)
+       (if (equal (org-entry-get nil "BEAMER_env") "againframe")
+           (progn (org-entry-delete nil "BEAMER_env")
+                  (org-entry-delete nil "BEAMER_ref")
+                  (org-entry-delete nil "BEAMER_act"))
+         (org-entry-put nil "BEAMER_env" "againframe")
+         (org-set-property
+          "BEAMER_ref"
+          (read-string "Frame reference (*Title, #custom-id, id:...): "))
+         (org-set-property "BEAMER_act"
+                           (read-string "Overlay specification: "))))
+       ((string-match (concat ":B_\\(" (mapconcat 'car envs "\\|") "\\):") tags)
+       (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
+       (t (org-entry-delete nil "BEAMER_env"))))))
+
+;;;###autoload
+(defun org-beamer-insert-options-template (&optional kind)
+  "Insert a settings template, to make sure users do this right."
+  (interactive (progn
+                (message "Current [s]ubtree or [g]lobal?")
+                (if (eq (read-char-exclusive) ?g) (list 'global)
+                  (list 'subtree))))
+  (if (eq kind 'subtree)
+      (progn
+       (org-back-to-heading t)
+       (org-reveal)
+       (org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
+       (org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
+       (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
+       (when org-beamer-column-view-format
+         (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
+       (org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
+    (insert "#+LaTeX_CLASS: beamer\n")
+    (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
+    (when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
+    (when org-beamer-column-view-format
+      (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
+    (insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
+
+;;;###autoload
+(defun org-beamer-publish-to-latex (plist filename pub-dir)
+  "Publish an Org file to a Beamer presentation (LaTeX).
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to 'beamer filename ".tex" plist pub-dir))
+
+;;;###autoload
+(defun org-beamer-publish-to-pdf (plist filename pub-dir)
+  "Publish an Org file to a Beamer presentation (PDF, via LaTeX).
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  ;; Unlike to `org-beamer-publish-to-latex', PDF file is generated in
+  ;; working directory and then moved to publishing directory.
+  (org-publish-attachment
+   plist
+   (org-latex-compile (org-publish-org-to 'beamer filename ".tex" plist))
+   pub-dir))
+
+
+(provide 'ox-beamer)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-beamer.el ends here
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el
new file mode 100644 (file)
index 0000000..b4094d3
--- /dev/null
@@ -0,0 +1,3429 @@
+;;; ox-html.el --- HTML Back-End for Org Export Engine
+
+;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
+
+;; Author: Carsten Dominik <carsten at orgmode dot org>
+;;      Jambunathan K <kjambunathan at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library implements a HTML back-end for Org generic exporter.
+;; See Org manual for more information.
+
+;;; Code:
+
+;;; Dependencies
+
+(require 'ox)
+(require 'ox-publish)
+(require 'format-spec)
+(eval-when-compile (require 'cl) (require 'table nil 'noerror))
+
+\f
+;;; Function Declarations
+
+(declare-function org-id-find-id-file "org-id" (id))
+(declare-function htmlize-region "ext:htmlize" (beg end))
+(declare-function org-pop-to-buffer-same-window
+                 "org-compat" (&optional buffer-or-name norecord label))
+(declare-function mm-url-decode-entities "mm-url" ())
+
+;;; Define Back-End
+
+(org-export-define-backend 'html
+  '((bold . org-html-bold)
+    (center-block . org-html-center-block)
+    (clock . org-html-clock)
+    (code . org-html-code)
+    (drawer . org-html-drawer)
+    (dynamic-block . org-html-dynamic-block)
+    (entity . org-html-entity)
+    (example-block . org-html-example-block)
+    (export-block . org-html-export-block)
+    (export-snippet . org-html-export-snippet)
+    (fixed-width . org-html-fixed-width)
+    (footnote-definition . org-html-footnote-definition)
+    (footnote-reference . org-html-footnote-reference)
+    (headline . org-html-headline)
+    (horizontal-rule . org-html-horizontal-rule)
+    (inline-src-block . org-html-inline-src-block)
+    (inlinetask . org-html-inlinetask)
+    (inner-template . org-html-inner-template)
+    (italic . org-html-italic)
+    (item . org-html-item)
+    (keyword . org-html-keyword)
+    (latex-environment . org-html-latex-environment)
+    (latex-fragment . org-html-latex-fragment)
+    (line-break . org-html-line-break)
+    (link . org-html-link)
+    (paragraph . org-html-paragraph)
+    (plain-list . org-html-plain-list)
+    (plain-text . org-html-plain-text)
+    (planning . org-html-planning)
+    (property-drawer . org-html-property-drawer)
+    (quote-block . org-html-quote-block)
+    (quote-section . org-html-quote-section)
+    (radio-target . org-html-radio-target)
+    (section . org-html-section)
+    (special-block . org-html-special-block)
+    (src-block . org-html-src-block)
+    (statistics-cookie . org-html-statistics-cookie)
+    (strike-through . org-html-strike-through)
+    (subscript . org-html-subscript)
+    (superscript . org-html-superscript)
+    (table . org-html-table)
+    (table-cell . org-html-table-cell)
+    (table-row . org-html-table-row)
+    (target . org-html-target)
+    (template . org-html-template)
+    (timestamp . org-html-timestamp)
+    (underline . org-html-underline)
+    (verbatim . org-html-verbatim)
+    (verse-block . org-html-verse-block))
+  :export-block "HTML"
+  :filters-alist '((:filter-options . org-html-infojs-install-script)
+                  (:filter-final-output . org-html-final-function))
+  :menu-entry
+  '(?h "Export to HTML"
+       ((?H "As HTML buffer" org-html-export-as-html)
+       (?h "As HTML file" org-html-export-to-html)
+       (?o "As HTML file and open"
+           (lambda (a s v b)
+             (if a (org-html-export-to-html t s v b)
+               (org-open-file (org-html-export-to-html nil s v b)))))))
+  :options-alist
+  '((:html-extension nil nil org-html-extension)
+    (:html-link-org-as-html nil nil org-html-link-org-files-as-html)
+    (:html-doctype "HTML_DOCTYPE" nil org-html-doctype)
+    (:html-container "HTML_CONTAINER" nil org-html-container-element)
+    (:html-html5-fancy nil "html5-fancy" org-html-html5-fancy)
+    (:html-link-use-abs-url nil "html-link-use-abs-url" org-html-link-use-abs-url)
+    (:html-link-home "HTML_LINK_HOME" nil org-html-link-home)
+    (:html-link-up "HTML_LINK_UP" nil org-html-link-up)
+    (:html-mathjax "HTML_MATHJAX" nil "" space)
+    (:html-postamble nil "html-postamble" org-html-postamble)
+    (:html-preamble nil "html-preamble" org-html-preamble)
+    (:html-head "HTML_HEAD" nil org-html-head newline)
+    (:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline)
+    (:html-head-include-default-style nil "html-style" org-html-head-include-default-style)
+    (:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts)
+    (:html-table-attributes nil nil org-html-table-default-attributes)
+    (:html-table-row-tags nil nil org-html-table-row-tags)
+    (:html-xml-declaration nil nil org-html-xml-declaration)
+    (:html-inline-images nil nil org-html-inline-images)
+    (:infojs-opt "INFOJS_OPT" nil nil)
+    ;; Redefine regular options.
+    (:creator "CREATOR" nil org-html-creator-string)
+    (:with-latex nil "tex" org-html-with-latex)))
+
+\f
+;;; Internal Variables
+
+(defvar org-html-format-table-no-css)
+(defvar htmlize-buffer-places)  ; from htmlize.el
+
+(defvar org-html--pre/postamble-class "status"
+  "CSS class used for pre/postamble")
+
+(defconst org-html-doctype-alist
+  '(("html4-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
+\"http://www.w3.org/TR/html4/strict.dtd\">")
+    ("html4-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
+\"http://www.w3.org/TR/html4/loose.dtd\">")
+    ("html4-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"
+\"http://www.w3.org/TR/html4/frameset.dtd\">")
+
+    ("xhtml-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
+\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
+    ("xhtml-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
+\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
+    ("xhtml-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
+\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
+    ("xhtml-11" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
+\"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
+
+    ("html5" . "<!DOCTYPE html>")
+    ("xhtml5" . "<!DOCTYPE html>"))
+  "An alist mapping (x)html flavors to specific doctypes.")
+
+(defconst org-html-html5-elements
+  '("article" "aside" "audio" "canvas" "details" "figcaption"
+    "figure" "footer" "header" "menu" "meter" "nav" "output"
+    "progress" "section" "video")
+  "New elements in html5.
+
+<hgroup> is not included because it's currently impossible to
+wrap special blocks around multiple headlines. For other blocks
+that should contain headlines, use the HTML_CONTAINER property on
+the headline itself.")
+
+(defconst org-html-special-string-regexps
+  '(("\\\\-" . "&#x00ad;")             ; shy
+    ("---\\([^-]\\)" . "&#x2014;\\1")  ; mdash
+    ("--\\([^-]\\)" . "&#x2013;\\1")   ; ndash
+    ("\\.\\.\\." . "&#x2026;"))                ; hellip
+  "Regular expressions for special string conversion.")
+
+(defconst org-html-scripts
+  "<script type=\"text/javascript\">
+/*
+@licstart  The following is the entire license notice for the
+JavaScript code in this tag.
+
+Copyright (C) 2012-2013 Free Software Foundation, Inc.
+
+The JavaScript code in this tag is free software: you can
+redistribute it and/or modify it under the terms of the GNU
+General Public License (GNU GPL) as published by the Free Software
+Foundation, either version 3 of the License, or (at your option)
+any later version.  The code is distributed WITHOUT ANY WARRANTY;
+without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
+
+As additional permission under GNU GPL version 3 section 7, you
+may distribute non-source (e.g., minimized or compacted) forms of
+that code without the copy of the GNU GPL normally required by
+section 4, provided you include this license notice and a URL
+through which recipients can access the Corresponding Source.
+
+
+@licend  The above is the entire license notice
+for the JavaScript code in this tag.
+*/
+<!--/*--><![CDATA[/*><!--*/
+ function CodeHighlightOn(elem, id)
+ {
+   var target = document.getElementById(id);
+   if(null != target) {
+     elem.cacheClassElem = elem.className;
+     elem.cacheClassTarget = target.className;
+     target.className = \"code-highlighted\";
+     elem.className   = \"code-highlighted\";
+   }
+ }
+ function CodeHighlightOff(elem, id)
+ {
+   var target = document.getElementById(id);
+   if(elem.cacheClassElem)
+     elem.className = elem.cacheClassElem;
+   if(elem.cacheClassTarget)
+     target.className = elem.cacheClassTarget;
+ }
+/*]]>*///-->
+</script>"
+  "Basic JavaScript that is needed by HTML files produced by Org mode.")
+
+(defconst org-html-style-default
+  "<style type=\"text/css\">
+ <!--/*--><![CDATA[/*><!--*/
+  .title  { text-align: center; }
+  .todo   { font-family: monospace; color: red; }
+  .done   { color: green; }
+  .tag    { background-color: #eee; font-family: monospace;
+            padding: 2px; font-size: 80%; font-weight: normal; }
+  .timestamp { color: #bebebe; }
+  .timestamp-kwd { color: #5f9ea0; }
+  .right  { margin-left: auto; margin-right: 0px;  text-align: right; }
+  .left   { margin-left: 0px;  margin-right: auto; text-align: left; }
+  .center { margin-left: auto; margin-right: auto; text-align: center; }
+  .underline { text-decoration: underline; }
+  #postamble p, #preamble p { font-size: 90%; margin: .2em; }
+  p.verse { margin-left: 3%; }
+  pre {
+    border: 1px solid #ccc;
+    box-shadow: 3px 3px 3px #eee;
+    padding: 8pt;
+    font-family: monospace;
+    overflow: auto;
+    margin: 1.2em;
+  }
+  pre.src {
+    position: relative;
+    overflow: visible;
+    padding-top: 1.2em;
+  }
+  pre.src:before {
+    display: none;
+    position: absolute;
+    background-color: white;
+    top: -10px;
+    right: 10px;
+    padding: 3px;
+    border: 1px solid black;
+  }
+  pre.src:hover:before { display: inline;}
+  pre.src-sh:before    { content: 'sh'; }
+  pre.src-bash:before  { content: 'sh'; }
+  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
+  pre.src-R:before     { content: 'R'; }
+  pre.src-perl:before  { content: 'Perl'; }
+  pre.src-java:before  { content: 'Java'; }
+  pre.src-sql:before   { content: 'SQL'; }
+
+  table { border-collapse:collapse; }
+  td, th { vertical-align:top;  }
+  th.right  { text-align: center;  }
+  th.left   { text-align: center;   }
+  th.center { text-align: center; }
+  td.right  { text-align: right;  }
+  td.left   { text-align: left;   }
+  td.center { text-align: center; }
+  dt { font-weight: bold; }
+  .footpara:nth-child(2) { display: inline; }
+  .footpara { display: block; }
+  .footdef  { margin-bottom: 1em; }
+  .figure { padding: 1em; }
+  .figure p { text-align: center; }
+  .inlinetask {
+    padding: 10px;
+    border: 2px solid gray;
+    margin: 10px;
+    background: #ffffcc;
+  }
+  #org-div-home-and-up
+   { text-align: right; font-size: 70%; white-space: nowrap; }
+  textarea { overflow-x: auto; }
+  .linenr { font-size: smaller }
+  .code-highlighted { background-color: #ffff00; }
+  .org-info-js_info-navigation { border-style: none; }
+  #org-info-js_console-label
+    { font-size: 10px; font-weight: bold; white-space: nowrap; }
+  .org-info-js_search-highlight
+    { background-color: #ffff00; color: #000000; font-weight: bold; }
+  /*]]>*/-->
+</style>"
+  "The default style specification for exported HTML files.
+You can use `org-html-head' and `org-html-head-extra' to add to
+this style.  If you don't want to include this default style,
+customize `org-html-head-include-default-style'.")
+
+\f
+;;; User Configuration Variables
+
+(defgroup org-export-html nil
+  "Options for exporting Org mode files to HTML."
+  :tag "Org Export HTML"
+  :group 'org-export)
+
+;;;; Handle infojs
+
+(defvar org-html-infojs-opts-table
+  '((path PATH "http://orgmode.org/org-info.js")
+    (view VIEW "info")
+    (toc TOC :with-toc)
+    (ftoc FIXED_TOC "0")
+    (tdepth TOC_DEPTH "max")
+    (sdepth SECTION_DEPTH "max")
+    (mouse MOUSE_HINT "underline")
+    (buttons VIEW_BUTTONS "0")
+    (ltoc LOCAL_TOC "1")
+    (up LINK_UP :html-link-up)
+    (home LINK_HOME :html-link-home))
+  "JavaScript options, long form for script, default values.")
+
+(defcustom org-html-use-infojs 'when-configured
+  "Non-nil when Sebastian Rose's Java Script org-info.js should be active.
+This option can be nil or t to never or always use the script.
+It can also be the symbol `when-configured', meaning that the
+script will be linked into the export file if and only if there
+is a \"#+INFOJS_OPT:\" line in the buffer.  See also the variable
+`org-html-infojs-options'."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Never" nil)
+         (const :tag "When configured in buffer" when-configured)
+         (const :tag "Always" t)))
+
+(defcustom org-html-infojs-options
+  (mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table)
+  "Options settings for the INFOJS JavaScript.
+Each of the options must have an entry in `org-html-infojs-opts-table'.
+The value can either be a string that will be passed to the script, or
+a property.  This property is then assumed to be a property that is defined
+by the Export/Publishing setup of Org.
+The `sdepth' and `tdepth' parameters can also be set to \"max\", which
+means to use the maximum value consistent with other options."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type
+  `(set :greedy t :inline t
+       ,@(mapcar
+          (lambda (x)
+            (list 'cons (list 'const (car x))
+                  '(choice
+                    (symbol :tag "Publishing/Export property")
+                    (string :tag "Value"))))
+          org-html-infojs-opts-table)))
+
+(defcustom org-html-infojs-template
+  "<script type=\"text/javascript\" src=\"%SCRIPT_PATH\">
+/**
+ *
+ * @source: %SCRIPT_PATH
+ *
+ * @licstart  The following is the entire license notice for the
+ *  JavaScript code in %SCRIPT_PATH.
+ *
+ * Copyright (C) 2012-2013 Free Software Foundation, Inc.
+ *
+ *
+ * The JavaScript code in this tag is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GNU GPL) as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option)
+ * any later version.  The code is distributed WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
+ *
+ * As additional permission under GNU GPL version 3 section 7, you
+ * may distribute non-source (e.g., minimized or compacted) forms of
+ * that code without the copy of the GNU GPL normally required by
+ * section 4, provided you include this license notice and a URL
+ * through which recipients can access the Corresponding Source.
+ *
+ * @licend  The above is the entire license notice
+ * for the JavaScript code in %SCRIPT_PATH.
+ *
+ */
+</script>
+
+<script type=\"text/javascript\">
+
+/*
+@licstart  The following is the entire license notice for the
+JavaScript code in this tag.
+
+Copyright (C) 2012-2013 Free Software Foundation, Inc.
+
+The JavaScript code in this tag is free software: you can
+redistribute it and/or modify it under the terms of the GNU
+General Public License (GNU GPL) as published by the Free Software
+Foundation, either version 3 of the License, or (at your option)
+any later version.  The code is distributed WITHOUT ANY WARRANTY;
+without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
+
+As additional permission under GNU GPL version 3 section 7, you
+may distribute non-source (e.g., minimized or compacted) forms of
+that code without the copy of the GNU GPL normally required by
+section 4, provided you include this license notice and a URL
+through which recipients can access the Corresponding Source.
+
+
+@licend  The above is the entire license notice
+for the JavaScript code in this tag.
+*/
+
+<!--/*--><![CDATA[/*><!--*/
+%MANAGER_OPTIONS
+org_html_manager.setup();  // activate after the parameters are set
+/*]]>*///-->
+</script>"
+  "The template for the export style additions when org-info.js is used.
+Option settings will replace the %MANAGER-OPTIONS cookie."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defun org-html-infojs-install-script (exp-plist backend)
+  "Install script in export options when appropriate.
+EXP-PLIST is a plist containing export options.  BACKEND is the
+export back-end currently used."
+  (unless (or (memq 'body-only (plist-get exp-plist :export-options))
+             (not org-html-use-infojs)
+             (and (eq org-html-use-infojs 'when-configured)
+                  (or (not (plist-get exp-plist :infojs-opt))
+                      (string-match "\\<view:nil\\>"
+                                    (plist-get exp-plist :infojs-opt)))))
+    (let* ((template org-html-infojs-template)
+          (ptoc (plist-get exp-plist :with-toc))
+          (hlevels (plist-get exp-plist :headline-levels))
+          (sdepth hlevels)
+          (tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
+          (options (plist-get exp-plist :infojs-opt))
+          (table org-html-infojs-opts-table)
+          style)
+      (dolist (entry table)
+       (let* ((opt (car entry))
+              (var (nth 1 entry))
+              ;; Compute default values for script option OPT from
+              ;; `org-html-infojs-options' variable.
+              (default
+                (let ((default (cdr (assq opt org-html-infojs-options))))
+                  (if (and (symbolp default) (not (memq default '(t nil))))
+                      (plist-get exp-plist default)
+                    default)))
+              ;; Value set through INFOJS_OPT keyword has precedence
+              ;; over the default one.
+              (val (if (and options
+                            (string-match (format "\\<%s:\\(\\S-+\\)" opt)
+                                          options))
+                       (match-string 1 options)
+                     default)))
+         (case opt
+           (path (setq template
+                       (replace-regexp-in-string
+                        "%SCRIPT_PATH" val template t t)))
+           (sdepth (when (integerp (read val))
+                     (setq sdepth (min (read val) sdepth))))
+           (tdepth (when (integerp (read val))
+                     (setq tdepth (min (read val) tdepth))))
+           (otherwise (setq val
+                            (cond
+                             ((or (eq val t) (equal val "t")) "1")
+                             ((or (eq val nil) (equal val "nil")) "0")
+                             ((stringp val) val)
+                             (t (format "%s" val))))
+                      (push (cons var val) style)))))
+      ;; Now we set the depth of the *generated* TOC to SDEPTH,
+      ;; because the toc will actually determine the splitting.  How
+      ;; much of the toc will actually be displayed is governed by the
+      ;; TDEPTH option.
+      (setq exp-plist (plist-put exp-plist :with-toc sdepth))
+      ;; The table of contents should not show more sections than we
+      ;; generate.
+      (setq tdepth (min tdepth sdepth))
+      (push (cons "TOC_DEPTH" tdepth) style)
+      ;; Build style string.
+      (setq style (mapconcat
+                  (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
+                                 (car x)
+                                 (cdr x)))
+                  style "\n"))
+      (when (and style (> (length style) 0))
+       (and (string-match "%MANAGER_OPTIONS" template)
+            (setq style (replace-match style t t template))
+            (setq exp-plist
+                  (plist-put
+                   exp-plist :html-head-extra
+                   (concat (or (plist-get exp-plist :html-head-extra) "")
+                           "\n"
+                           style)))))
+      ;; This script absolutely needs the table of contents, so we
+      ;; change that setting.
+      (unless (plist-get exp-plist :with-toc)
+       (setq exp-plist (plist-put exp-plist :with-toc t)))
+      ;; Return the modified property list.
+      exp-plist)))
+
+;;;; Bold, etc.
+
+(defcustom org-html-text-markup-alist
+  '((bold . "<b>%s</b>")
+    (code . "<code>%s</code>")
+    (italic . "<i>%s</i>")
+    (strike-through . "<del>%s</del>")
+    (underline . "<span class=\"underline\">%s</span>")
+    (verbatim . "<code>%s</code>"))
+  "Alist of HTML expressions to convert text markup.
+
+The key must be a symbol among `bold', `code', `italic',
+`strike-through', `underline' and `verbatim'.  The value is
+a formatting string to wrap fontified text with.
+
+If no association can be found for a given markup, text will be
+returned as-is."
+  :group 'org-export-html
+  :type '(alist :key-type (symbol :tag "Markup type")
+               :value-type (string :tag "Format string"))
+  :options '(bold code italic strike-through underline verbatim))
+
+(defcustom org-html-indent nil
+  "Non-nil means to indent the generated HTML.
+Warning: non-nil may break indentation of source code blocks."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-html-use-unicode-chars nil
+  "Non-nil means to use unicode characters instead of HTML entities."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+;;;; Drawers
+
+(defcustom org-html-format-drawer-function nil
+  "Function called to format a drawer in HTML code.
+
+The function must accept two parameters:
+  NAME      the drawer name, like \"LOGBOOK\"
+  CONTENTS  the contents of the drawer.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-html-format-drawer-default \(name contents\)
+  \"Format a drawer element for HTML export.\"
+  contents\)"
+  :group 'org-export-html
+  :type 'function)
+
+;;;; Footnotes
+
+(defcustom org-html-footnotes-section "<div id=\"footnotes\">
+<h2 class=\"footnotes\">%s: </h2>
+<div id=\"text-footnotes\">
+%s
+</div>
+</div>"
+  "Format for the footnotes section.
+Should contain a two instances of %s.  The first will be replaced with the
+language-specific word for \"Footnotes\", the second one will be replaced
+by the footnotes themselves."
+  :group 'org-export-html
+  :type 'string)
+
+(defcustom org-html-footnote-format "<sup>%s</sup>"
+  "The format for the footnote reference.
+%s will be replaced by the footnote reference itself."
+  :group 'org-export-html
+  :type 'string)
+
+(defcustom org-html-footnote-separator "<sup>, </sup>"
+  "Text used to separate footnotes."
+  :group 'org-export-html
+  :type 'string)
+
+;;;; Headline
+
+(defcustom org-html-toplevel-hlevel 2
+  "The <H> level for level 1 headings in HTML export.
+This is also important for the classes that will be wrapped around headlines
+and outline structure.  If this variable is 1, the top-level headlines will
+be <h1>, and the corresponding classes will be outline-1, section-number-1,
+and outline-text-1.  If this is 2, all of these will get a 2 instead.
+The default for this variable is 2, because we use <h1> for formatting the
+document title."
+  :group 'org-export-html
+  :type 'integer)
+
+(defcustom org-html-format-headline-function nil
+  "Function to format headline text.
+
+This function will be called with 5 arguments:
+TODO      the todo keyword (string or nil).
+TODO-TYPE the type of todo (symbol: `todo', `done', nil)
+PRIORITY  the priority of the headline (integer or nil)
+TEXT      the main headline text (string).
+TAGS      the tags (string or nil).
+
+The function result will be used in the section format string."
+  :group 'org-export-html
+  :type 'function)
+
+;;;; HTML-specific
+
+(defcustom org-html-allow-name-attribute-in-anchors t
+  "When nil, do not set \"name\" attribute in anchors.
+By default, anchors are formatted with both \"id\" and \"name\"
+attributes, when appropriate."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+;;;; Inlinetasks
+
+(defcustom org-html-format-inlinetask-function nil
+  "Function called to format an inlinetask in HTML code.
+
+The function must accept six parameters:
+  TODO      the todo keyword, as a string
+  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  PRIORITY  the inlinetask priority, as a string
+  NAME      the inlinetask name, as a string.
+  TAGS      the inlinetask tags, as a list of strings.
+  CONTENTS  the contents of the inlinetask, as a string.
+
+The function should return the string to be exported."
+  :group 'org-export-html
+  :type 'function)
+
+;;;; LaTeX
+
+(defcustom org-html-with-latex org-export-with-latex
+  "Non-nil means process LaTeX math snippets.
+
+When set, the exporter will process LaTeX environments and
+fragments.
+
+This option can also be set with the +OPTIONS line,
+e.g. \"tex:mathjax\".  Allowed values are:
+
+nil            Ignore math snippets.
+`verbatim'     Keep everything in verbatim
+`dvipng'       Process the LaTeX fragments to images.  This will also
+               include processing of non-math environments.
+`imagemagick'  Convert the LaTeX fragments to pdf files and use
+               imagemagick to convert pdf files to png files.
+`mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
+               be loaded.
+t              Synonym for `mathjax'."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Do not process math in any way" nil)
+         (const :tag "Use dvipng to make images" dvipng)
+         (const :tag "Use imagemagick to make images" imagemagick)
+         (const :tag "Use MathJax to display math" mathjax)
+         (const :tag "Leave math verbatim" verbatim)))
+
+;;;; Links :: Generic
+
+(defcustom org-html-link-org-files-as-html t
+  "Non-nil means make file links to `file.org' point to `file.html'.
+When `org-mode' is exporting an `org-mode' file to HTML, links to
+non-html files are directly put into a href tag in HTML.
+However, links to other Org-mode files (recognized by the
+extension `.org.) should become links to the corresponding html
+file, assuming that the linked `org-mode' file will also be
+converted to HTML.
+When nil, the links still point to the plain `.org' file."
+  :group 'org-export-html
+  :type 'boolean)
+
+;;;; Links :: Inline images
+
+(defcustom org-html-inline-images t
+  "Non-nil means inline images into exported HTML pages.
+This is done using an <img> tag.  When nil, an anchor with href is used to
+link to the image."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.1")
+  :type 'boolean)
+
+(defcustom org-html-inline-image-rules
+  '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
+    ("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")
+    ("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'"))
+  "Rules characterizing image files that can be inlined into HTML.
+A rule consists in an association whose key is the type of link
+to consider, and value is a regexp that will be matched against
+link's path."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(alist :key-type (string :tag "Type")
+               :value-type (regexp :tag "Path")))
+
+;;;; Plain Text
+
+(defcustom org-html-protect-char-alist
+  '(("&" . "&amp;")
+    ("<" . "&lt;")
+    (">" . "&gt;"))
+  "Alist of characters to be converted by `org-html-protect'."
+  :group 'org-export-html
+  :type '(repeat (cons (string :tag "Character")
+                      (string :tag "HTML equivalent"))))
+
+;;;; Src Block
+
+(defcustom org-html-htmlize-output-type 'inline-css
+  "Output type to be used by htmlize when formatting code snippets.
+Choices are `css', to export the CSS selectors only, or `inline-css', to
+export the CSS attribute values inline in the HTML.  We use as default
+`inline-css', in order to make the resulting HTML self-containing.
+
+However, this will fail when using Emacs in batch mode for export, because
+then no rich font definitions are in place.  It will also not be good if
+people with different Emacs setup contribute HTML files to a website,
+because the fonts will represent the individual setups.  In these cases,
+it is much better to let Org/Htmlize assign classes only, and to use
+a style file to define the look of these classes.
+To get a start for your css file, start Emacs session and make sure that
+all the faces you are interested in are defined, for example by loading files
+in all modes you want.  Then, use the command
+\\[org-html-htmlize-generate-css] to extract class definitions."
+  :group 'org-export-html
+  :type '(choice (const css) (const inline-css)))
+
+(defcustom org-html-htmlize-font-prefix "org-"
+  "The prefix for CSS class names for htmlize font specifications."
+  :group 'org-export-html
+  :type 'string)
+
+;;;; Table
+
+(defcustom org-html-table-default-attributes
+  '(:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides")
+  "Default attributes and values which will be used in table tags.
+This is a plist where attributes are symbols, starting with
+colons, and values are strings.
+
+When exporting to HTML5, these values will be disregarded."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(plist :key-type (symbol :tag "Property")
+               :value-type (string :tag "Value")))
+
+(defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>")
+  "The opening tag for table header fields.
+This is customizable so that alignment options can be specified.
+The first %s will be filled with the scope of the field, either row or col.
+The second %s will be replaced by a style entry to align the field.
+See also the variable `org-html-table-use-header-tags-for-first-column'.
+See also the variable `org-html-table-align-individual-fields'."
+  :group 'org-export-html
+  :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
+
+(defcustom org-html-table-data-tags '("<td%s>" . "</td>")
+  "The opening tag for table data fields.
+This is customizable so that alignment options can be specified.
+The first %s will be filled with the scope of the field, either row or col.
+The second %s will be replaced by a style entry to align the field.
+See also the variable `org-html-table-align-individual-fields'."
+  :group 'org-export-html
+  :type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
+
+(defcustom org-html-table-row-tags '("<tr>" . "</tr>")
+  "The opening and ending tags for table rows.
+This is customizable so that alignment options can be specified.
+Instead of strings, these can be Lisp forms that will be
+evaluated for each row in order to construct the table row tags.
+
+During evaluation, these variables will be dynamically bound so that
+you can reuse them:
+
+       `row-number': row number (0 is the first row)
+  `rowgroup-number': group number of current row
+ `start-rowgroup-p': non-nil means the row starts a group
+   `end-rowgroup-p': non-nil means the row ends a group
+        `top-row-p': non-nil means this is the top row
+     `bottom-row-p': non-nil means this is the bottom row
+
+For example:
+
+\(setq org-html-table-row-tags
+      (cons '(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
+                   (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
+                   (t (if (= (mod row-number 2) 1)
+                         \"<tr class=\\\"tr-odd\\\">\"
+                       \"<tr class=\\\"tr-even\\\">\")))
+           \"</tr>\"))
+
+will use the \"tr-top\" and \"tr-bottom\" classes for the top row
+and the bottom row, and otherwise alternate between \"tr-odd\" and
+\"tr-even\" for odd and even rows."
+  :group 'org-export-html
+  :type '(cons
+         (choice :tag "Opening tag"
+                 (string :tag "Specify")
+                 (sexp))
+         (choice :tag "Closing tag"
+                 (string :tag "Specify")
+                 (sexp))))
+
+(defcustom org-html-table-align-individual-fields t
+  "Non-nil means attach style attributes for alignment to each table field.
+When nil, alignment will only be specified in the column tags, but this
+is ignored by some browsers (like Firefox, Safari).  Opera does it right
+though."
+  :group 'org-export-html
+  :type 'boolean)
+
+(defcustom org-html-table-use-header-tags-for-first-column nil
+  "Non-nil means format column one in tables with header tags.
+When nil, also column one will use data tags."
+  :group 'org-export-html
+  :type 'boolean)
+
+(defcustom org-html-table-caption-above t
+  "When non-nil, place caption string at the beginning of the table.
+Otherwise, place it near the end."
+  :group 'org-export-html
+  :type 'boolean)
+
+;;;; Tags
+
+(defcustom org-html-tag-class-prefix ""
+  "Prefix to class names for TODO keywords.
+Each tag gets a class given by the tag itself, with this prefix.
+The default prefix is empty because it is nice to just use the keyword
+as a class name.  But if you get into conflicts with other, existing
+CSS classes, then this prefix can be very useful."
+  :group 'org-export-html
+  :type 'string)
+
+;;;; Template :: Generic
+
+(defcustom org-html-extension "html"
+  "The extension for exported HTML files."
+  :group 'org-export-html
+  :type 'string)
+
+(defcustom org-html-xml-declaration
+  '(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
+    ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))
+  "The extension for exported HTML files.
+%s will be replaced with the charset of the exported file.
+This may be a string, or an alist with export extensions
+and corresponding declarations.
+
+This declaration only applies when exporting to XHTML."
+  :group 'org-export-html
+  :type '(choice
+         (string :tag "Single declaration")
+         (repeat :tag "Dependent on extension"
+                 (cons (string :tag "Extension")
+                       (string :tag "Declaration")))))
+
+(defcustom org-html-coding-system 'utf-8
+  "Coding system for HTML export.
+Use utf-8 as the default value."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'coding-system)
+
+(defcustom org-html-doctype "xhtml-strict"
+  "Document type definition to use for exported HTML files.
+Can be set with the in-buffer HTML_DOCTYPE property or for
+publishing, with :html-doctype."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-html-html5-fancy nil
+  "Non-nil means using new HTML5 elements.
+This variable is ignored for anything other than HTML5 export.
+
+For compatibility with Internet Explorer, it's probably a good
+idea to download some form of the html5shiv (for instance
+https://code.google.com/p/html5shiv/) and add it to your
+HTML_HEAD_EXTRA, so that your pages don't break for users of IE
+versions 8 and below."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-html-container-element "div"
+  "HTML element to use for wrapping top level sections.
+Can be set with the in-buffer HTML_CONTAINER property or for
+publishing, with :html-container.
+
+Note that changing the default will prevent you from using
+org-info.js for your website."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-html-divs
+  '((preamble  "div" "preamble")
+    (content   "div" "content")
+    (postamble "div" "postamble"))
+  "Alist of the three section elements for HTML export.
+The car of each entry is one of 'preamble, 'content or 'postamble.
+The cdrs of each entry are the ELEMENT_TYPE and ID for each
+section of the exported document.
+
+Note that changing the default will prevent you from using
+org-info.js for your website."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(list :greedy t
+              (list :tag "Preamble"
+                    (const :format "" preamble)
+                    (string :tag "element") (string :tag "     id"))
+              (list :tag "Content"
+                    (const :format "" content)
+                    (string :tag "element") (string :tag "     id"))
+              (list :tag "Postamble" (const :format "" postamble)
+                    (string :tag "     id") (string :tag "element"))))
+
+(defcustom org-html-metadata-timestamp-format "%Y-%m-%d %a %H:%M"
+  "Format used for timestamps in preamble, postamble and metadata.
+See `format-time-string' for more information on its components."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+;;;; Template :: Mathjax
+
+(defcustom org-html-mathjax-options
+  '((path  "http://orgmode.org/mathjax/MathJax.js")
+    (scale "100")
+    (align "center")
+    (indent "2em")
+    (mathml nil))
+  "Options for MathJax setup.
+
+path        The path where to find MathJax
+scale       Scaling for the HTML-CSS backend, usually between 100 and 133
+align       How to align display math: left, center, or right
+indent      If align is not center, how far from the left/right side?
+mathml      Should a MathML player be used if available?
+            This is faster and reduces bandwidth use, but currently
+            sometimes has lower spacing quality.  Therefore, the default is
+            nil.  When browsers get better, this switch can be flipped.
+
+You can also customize this for each buffer, using something like
+
+#+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\""
+  :group 'org-export-html
+  :type '(list :greedy t
+             (list :tag "path   (the path from where to load MathJax.js)"
+                   (const :format "       " path) (string))
+             (list :tag "scale  (scaling for the displayed math)"
+                   (const :format "       " scale) (string))
+             (list :tag "align  (alignment of displayed equations)"
+                   (const :format "       " align) (string))
+             (list :tag "indent (indentation with left or right alignment)"
+                   (const :format "       " indent) (string))
+             (list :tag "mathml (should MathML display be used is possible)"
+                   (const :format "       " mathml) (boolean))))
+
+(defcustom org-html-mathjax-template
+  "<script type=\"text/javascript\" src=\"%PATH\"></script>
+<script type=\"text/javascript\">
+<!--/*--><![CDATA[/*><!--*/
+    MathJax.Hub.Config({
+        // Only one of the two following lines, depending on user settings
+        // First allows browser-native MathML display, second forces HTML/CSS
+        :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"],
+        :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"],
+        extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\",
+                     \"TeX/noUndefined.js\"],
+        tex2jax: {
+            inlineMath: [ [\"\\\\(\",\"\\\\)\"] ],
+            displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"], [\"\\\\begin{displaymath}\",\"\\\\end{displaymath}\"] ],
+            skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"],
+            ignoreClass: \"tex2jax_ignore\",
+            processEscapes: false,
+            processEnvironments: true,
+            preview: \"TeX\"
+        },
+        showProcessingMessages: true,
+        displayAlign: \"%ALIGN\",
+        displayIndent: \"%INDENT\",
+
+        \"HTML-CSS\": {
+             scale: %SCALE,
+             availableFonts: [\"STIX\",\"TeX\"],
+             preferredFont: \"TeX\",
+             webFont: \"TeX\",
+             imageFont: \"TeX\",
+             showMathMenu: true,
+        },
+        MMLorHTML: {
+             prefer: {
+                 MSIE:    \"MML\",
+                 Firefox: \"MML\",
+                 Opera:   \"HTML\",
+                 other:   \"HTML\"
+             }
+        }
+    });
+/*]]>*///-->
+</script>"
+  "The MathJax setup for XHTML files."
+  :group 'org-export-html
+  :type 'string)
+
+;;;; Template :: Postamble
+
+(defcustom org-html-postamble 'auto
+  "Non-nil means insert a postamble in HTML export.
+
+When set to 'auto, check against the
+`org-export-with-author/email/creator/date' variables to set the
+content of the postamble.  When set to a string, use this string
+as the postamble.  When t, insert a string as defined by the
+formatting string in `org-html-postamble-format'.
+
+When set to a function, apply this function and insert the
+returned string.  The function takes the property list of export
+options as its only argument.
+
+Setting :html-postamble in publishing projects will take
+precedence over this variable."
+  :group 'org-export-html
+  :type '(choice (const :tag "No postamble" nil)
+                (const :tag "Auto postamble" auto)
+                (const :tag "Default formatting string" t)
+                (string :tag "Custom formatting string")
+                (function :tag "Function (must return a string)")))
+
+(defcustom org-html-postamble-format
+  '(("en" "<p class=\"author\">Author: %a (%e)</p>
+<p class=\"date\">Date: %d</p>
+<p class=\"creator\">%c</p>
+<p class=\"validation\">%v</p>"))
+  "Alist of languages and format strings for the HTML postamble.
+
+The first element of each list is the language code, as used for
+the LANGUAGE keyword.  See `org-export-default-language'.
+
+The second element of each list is a format string to format the
+postamble itself.  This format string can contain these elements:
+
+  %t stands for the title.
+  %a stands for the author's name.
+  %e stands for the author's email.
+  %d stands for the date.
+  %c will be replaced by `org-html-creator-string'.
+  %v will be replaced by `org-html-validation-link'.
+  %T will be replaced by the export time.
+  %C will be replaced by the last modification time.
+
+If you need to use a \"%\" character, you need to escape it
+like that: \"%%\"."
+  :group 'org-export-html
+  :type '(repeat
+         (list (string :tag "Language")
+               (string :tag "Format string"))))
+
+(defcustom org-html-validation-link
+  "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>"
+  "Link to HTML validation service."
+  :group 'org-export-html
+  :type 'string)
+
+(defcustom org-html-creator-string
+  (format "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"http://orgmode.org\">Org</a> mode %s)"
+         emacs-version
+         (if (fboundp 'org-version) (org-version) "unknown version"))
+  "Information about the creator of the HTML document.
+This option can also be set on with the CREATOR keyword."
+  :group 'org-export-html
+  :type '(string :tag "Creator string"))
+
+;;;; Template :: Preamble
+
+(defcustom org-html-preamble t
+  "Non-nil means insert a preamble in HTML export.
+
+When t, insert a string as defined by the formatting string in
+`org-html-preamble-format'.  When set to a string, use this
+formatting string instead (see `org-html-postamble-format' for an
+example of such a formatting string).
+
+When set to a function, apply this function and insert the
+returned string.  The function takes the property list of export
+options as its only argument.
+
+Setting :html-preamble in publishing projects will take
+precedence over this variable."
+  :group 'org-export-html
+  :type '(choice (const :tag "No preamble" nil)
+                (const :tag "Default preamble" t)
+                (string :tag "Custom formatting string")
+                (function :tag "Function (must return a string)")))
+
+(defcustom org-html-preamble-format '(("en" ""))
+  "Alist of languages and format strings for the HTML preamble.
+
+The first element of each list is the language code, as used for
+the LANGUAGE keyword.  See `org-export-default-language'.
+
+The second element of each list is a format string to format the
+preamble itself.  This format string can contain these elements:
+
+  %t stands for the title.
+  %a stands for the author's name.
+  %e stands for the author's email.
+  %d stands for the date.
+  %c will be replaced by `org-html-creator-string'.
+  %v will be replaced by `org-html-validation-link'.
+  %T will be replaced by the export time.
+  %C will be replaced by the last modification time.
+
+If you need to use a \"%\" character, you need to escape it
+like that: \"%%\".
+
+See the default value of `org-html-postamble-format' for an
+example."
+  :group 'org-export-html
+  :type '(repeat
+         (list (string :tag "Language")
+               (string :tag "Format string"))))
+
+(defcustom org-html-link-up ""
+  "Where should the \"UP\" link of exported HTML pages lead?"
+  :group 'org-export-html
+  :type '(string :tag "File or URL"))
+
+(defcustom org-html-link-home ""
+  "Where should the \"HOME\" link of exported HTML pages lead?"
+  :group 'org-export-html
+  :type '(string :tag "File or URL"))
+
+(defcustom org-html-link-use-abs-url nil
+  "Should we prepend relative links with HTML_LINK_HOME?"
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.1")
+  :type 'boolean)
+
+(defcustom org-html-home/up-format
+  "<div id=\"org-div-home-and-up\">
+ <a accesskey=\"h\" href=\"%s\"> UP </a>
+ |
+ <a accesskey=\"H\" href=\"%s\"> HOME </a>
+</div>"
+  "Snippet used to insert the HOME and UP links.
+This is a format string, the first %s will receive the UP link,
+the second the HOME link.  If both `org-html-link-up' and
+`org-html-link-home' are empty, the entire snippet will be
+ignored."
+  :group 'org-export-html
+  :type 'string)
+
+;;;; Template :: Scripts
+
+(define-obsolete-variable-alias
+  'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
+(defcustom org-html-head-include-scripts t
+  "Non-nil means include the JavaScript snippets in exported HTML files.
+The actual script is defined in `org-html-scripts' and should
+not be modified."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+;;;; Template :: Styles
+
+(define-obsolete-variable-alias
+  'org-html-style-include-default 'org-html-head-include-default-style "24.4")
+(defcustom org-html-head-include-default-style t
+  "Non-nil means include the default style in exported HTML files.
+The actual style is defined in `org-html-style-default' and
+should not be modified.  Use `org-html-head' to use your own
+style information."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+;;;###autoload
+(put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
+
+(define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
+(defcustom org-html-head ""
+  "Org-wide head definitions for exported HTML files.
+
+This variable can contain the full HTML structure to provide a
+style, including the surrounding HTML tags.  You can consider
+including definitions for the following classes: title, todo,
+done, timestamp, timestamp-kwd, tag, target.
+
+For example, a valid value would be:
+
+   <style type=\"text/css\">
+    <![CDATA[
+       p { font-weight: normal; color: gray; }
+       h1 { color: black; }
+      .title { text-align: center; }
+      .todo, .timestamp-kwd { color: red; }
+      .done { color: green; }
+    ]]>
+   </style>
+
+If you want to refer to an external style, use something like
+
+   <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" />
+
+As the value of this option simply gets inserted into the HTML
+<head> header, you can use it to add any arbitrary text to the
+header.
+
+You can set this on a per-file basis using #+HTML_HEAD:,
+or for publication projects using the :html-head property."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+;;;###autoload
+(put 'org-html-head 'safe-local-variable 'stringp)
+
+(defcustom org-html-head-extra ""
+  "More head information to add in the HTML output.
+
+You can set this on a per-file basis using #+HTML_HEAD_EXTRA:,
+or for publication projects using the :html-head-extra property."
+  :group 'org-export-html
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+;;;###autoload
+(put 'org-html-head-extra 'safe-local-variable 'stringp)
+
+;;;; Todos
+
+(defcustom org-html-todo-kwd-class-prefix ""
+  "Prefix to class names for TODO keywords.
+Each TODO keyword gets a class given by the keyword itself, with this prefix.
+The default prefix is empty because it is nice to just use the keyword
+as a class name.  But if you get into conflicts with other, existing
+CSS classes, then this prefix can be very useful."
+  :group 'org-export-html
+  :type 'string)
+
+\f
+;;; Internal Functions
+
+(defun org-html-xhtml-p (info)
+  (let ((dt (downcase (plist-get info :html-doctype))))
+    (string-match-p "xhtml" dt)))
+
+(defun org-html-html5-p (info)
+  (let ((dt (downcase (plist-get info :html-doctype))))
+       (member dt '("html5" "xhtml5" "<!doctype html>"))))
+
+(defun org-html-close-tag (tag attr info)
+  (concat "<" tag " " attr
+         (if (org-html-xhtml-p info) " />" ">")))
+
+(defun org-html-doctype (info)
+  "Return correct html doctype tag from `org-html-doctype-alist',
+or the literal value of :html-doctype from INFO if :html-doctype
+is not found in the alist.
+INFO is a plist used as a communication channel."
+  (let ((dt (plist-get info :html-doctype)))
+    (or (cdr (assoc dt org-html-doctype-alist)) dt)))
+
+(defun org-html--make-attribute-string (attributes)
+  "Return a list of attributes, as a string.
+ATTRIBUTES is a plist where values are either strings or nil. An
+attributes with a nil value will be omitted from the result."
+  (let (output)
+    (dolist (item attributes (mapconcat 'identity (nreverse output) " "))
+      (cond ((null item) (pop output))
+            ((symbolp item) (push (substring (symbol-name item) 1) output))
+            (t (let ((key (car output))
+                     (value (replace-regexp-in-string
+                             "\"" "&quot;" (org-html-encode-plain-text item))))
+                 (setcar output (format "%s=\"%s\"" key value))))))))
+
+(defun org-html--wrap-image (contents info &optional caption label)
+  "Wrap CONTENTS string within an appropriate environment for images.
+INFO is a plist used as a communication channel.  When optional
+arguments CAPTION and LABEL are given, use them for caption and
+\"id\" attribute."
+  (let ((html5-fancy (and (org-html-html5-p info)
+                         (plist-get info :html-html5-fancy))))
+    (format (if html5-fancy "\n<figure%s>%s%s\n</figure>"
+             "\n<div%s class=\"figure\">%s%s\n</div>")
+           ;; ID.
+           (if (not (org-string-nw-p label)) ""
+             (format " id=\"%s\"" (org-export-solidify-link-text label)))
+           ;; Contents.
+           (format "\n<p>%s</p>" contents)
+           ;; Caption.
+           (if (not (org-string-nw-p caption)) ""
+             (format (if html5-fancy "\n<figcaption>%s</figcaption>"
+                       "\n<p>%s</p>")
+                     caption)))))
+
+(defun org-html--format-image (source attributes info)
+  "Return \"img\" tag with given SOURCE and ATTRIBUTES.
+SOURCE is a string specifying the location of the image.
+ATTRIBUTES is a plist, as returned by
+`org-export-read-attribute'.  INFO is a plist used as
+a communication channel."
+  (org-html-close-tag
+   "img"
+   (org-html--make-attribute-string
+    (org-combine-plists
+     (list :src source
+          :alt (if (string-match-p "^ltxpng/" source)
+                   (org-html-encode-plain-text
+                    (org-find-text-property-in-string 'org-latex-src source))
+                 (file-name-nondirectory source)))
+     attributes))
+   info))
+
+(defun org-html--textarea-block (element)
+  "Transcode ELEMENT into a textarea block.
+ELEMENT is either a src block or an example block."
+  (let* ((code (car (org-export-unravel-code element)))
+        (attr (org-export-read-attribute :attr_html element)))
+    (format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>"
+           (or (plist-get attr :width) 80)
+           (or (plist-get attr :height) (org-count-lines code))
+           code)))
+
+(defun org-html--has-caption-p (element &optional info)
+  "Non-nil when ELEMENT has a caption affiliated keyword.
+INFO is a plist used as a communication channel.  This function
+is meant to be used as a predicate for `org-export-get-ordinal' or
+a value to `org-html-standalone-image-predicate'."
+  (org-element-property :caption element))
+
+;;;; Table
+
+(defun org-html-htmlize-region-for-paste (beg end)
+  "Convert the region between BEG and END to HTML, using htmlize.el.
+This is much like `htmlize-region-for-paste', only that it uses
+the settings define in the org-... variables."
+  (let* ((htmlize-output-type org-html-htmlize-output-type)
+        (htmlize-css-name-prefix org-html-htmlize-font-prefix)
+        (htmlbuf (htmlize-region beg end)))
+    (unwind-protect
+       (with-current-buffer htmlbuf
+         (buffer-substring (plist-get htmlize-buffer-places 'content-start)
+                           (plist-get htmlize-buffer-places 'content-end)))
+      (kill-buffer htmlbuf))))
+
+;;;###autoload
+(defun org-html-htmlize-generate-css ()
+  "Create the CSS for all font definitions in the current Emacs session.
+Use this to create face definitions in your CSS style file that can then
+be used by code snippets transformed by htmlize.
+This command just produces a buffer that contains class definitions for all
+faces used in the current Emacs session.  You can copy and paste the ones you
+need into your CSS file.
+
+If you then set `org-html-htmlize-output-type' to `css', calls
+to the function `org-html-htmlize-region-for-paste' will
+produce code that uses these same face definitions."
+  (interactive)
+  (require 'htmlize)
+  (and (get-buffer "*html*") (kill-buffer "*html*"))
+  (with-temp-buffer
+    (let ((fl (face-list))
+         (htmlize-css-name-prefix "org-")
+         (htmlize-output-type 'css)
+         f i)
+      (while (setq f (pop fl)
+                  i (and f (face-attribute f :inherit)))
+       (when (and (symbolp f) (or (not i) (not (listp i))))
+         (insert (org-add-props (copy-sequence "1") nil 'face f))))
+      (htmlize-region (point-min) (point-max))))
+  (org-pop-to-buffer-same-window "*html*")
+  (goto-char (point-min))
+  (if (re-search-forward "<style" nil t)
+      (delete-region (point-min) (match-beginning 0)))
+  (if (re-search-forward "</style>" nil t)
+      (delete-region (1+ (match-end 0)) (point-max)))
+  (beginning-of-line 1)
+  (if (looking-at " +") (replace-match ""))
+  (goto-char (point-min)))
+
+(defun org-html--make-string (n string)
+  "Build a string by concatenating N times STRING."
+  (let (out) (dotimes (i n out) (setq out (concat string out)))))
+
+(defun org-html-fix-class-name (kwd)   ; audit callers of this function
+  "Turn todo keyword KWD into a valid class name.
+Replaces invalid characters with \"_\"."
+  (save-match-data
+    (while (string-match "[^a-zA-Z0-9_]" kwd)
+      (setq kwd (replace-match "_" t t kwd))))
+  kwd)
+
+(defun org-html-format-footnote-reference (n def refcnt)
+  "Format footnote reference N with definition DEF into HTML."
+  (let ((extra (if (= refcnt 1) "" (format ".%d"  refcnt))))
+    (format org-html-footnote-format
+           (let* ((id (format "fnr.%s%s" n extra))
+                  (href (format " href=\"#fn.%s\"" n))
+                  (attributes (concat " class=\"footref\"" href)))
+             (org-html--anchor id n attributes)))))
+
+(defun org-html-format-footnotes-section (section-name definitions)
+  "Format footnotes section SECTION-NAME."
+  (if (not definitions) ""
+    (format org-html-footnotes-section section-name definitions)))
+
+(defun org-html-format-footnote-definition (fn)
+  "Format the footnote definition FN."
+  (let ((n (car fn)) (def (cdr fn)))
+    (format
+     "<div class=\"footdef\">%s %s</div>\n"
+     (format org-html-footnote-format
+            (let* ((id (format "fn.%s" n))
+                   (href (format " href=\"#fnr.%s\"" n))
+                   (attributes (concat " class=\"footnum\"" href)))
+              (org-html--anchor id n attributes)))
+     def)))
+
+(defun org-html-footnote-section (info)
+  "Format the footnote section.
+INFO is a plist used as a communication channel."
+  (let* ((fn-alist (org-export-collect-footnote-definitions
+                   (plist-get info :parse-tree) info))
+        (fn-alist
+         (loop for (n type raw) in fn-alist collect
+               (cons n (if (eq (org-element-type raw) 'org-data)
+                           (org-trim (org-export-data raw info))
+                         (format "<p>%s</p>"
+                                 (org-trim (org-export-data raw info))))))))
+    (when fn-alist
+      (org-html-format-footnotes-section
+       (org-html--translate "Footnotes" info)
+       (format
+       "\n%s\n"
+       (mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
+
+\f
+;;; Template
+
+(defun org-html--build-meta-info (info)
+  "Return meta tags for exported document.
+INFO is a plist used as a communication channel."
+  (let ((protect-string
+        (lambda (str)
+          (replace-regexp-in-string
+           "\"" "&quot;" (org-html-encode-plain-text str))))
+       (title (org-export-data (plist-get info :title) info))
+       (author (and (plist-get info :with-author)
+                    (let ((auth (plist-get info :author)))
+                      (and auth
+                           ;; Return raw Org syntax, skipping non
+                           ;; exportable objects.
+                           (org-element-interpret-data
+                            (org-element-map auth
+                                (cons 'plain-text org-element-all-objects)
+                              'identity info))))))
+       (description (plist-get info :description))
+       (keywords (plist-get info :keywords))
+       (charset (or (and org-html-coding-system
+                         (fboundp 'coding-system-get)
+                         (coding-system-get org-html-coding-system
+                                            'mime-charset))
+                    "iso-8859-1")))
+    (concat
+     (format "<title>%s</title>\n" title)
+     (when (plist-get info :time-stamp-file)
+       (format-time-string
+        (concat "<!-- " org-html-metadata-timestamp-format " -->\n")))
+     (format
+      (if (org-html-html5-p info)
+         (org-html-close-tag "meta" " charset=\"%s\"" info)
+       (org-html-close-tag
+        "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
+        info))
+      charset) "\n"
+     (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info)
+     "\n"
+     (and (org-string-nw-p author)
+         (concat
+          (org-html-close-tag "meta"
+                              (format " name=\"author\" content=\"%s\""
+                                      (funcall protect-string author))
+                              info)
+          "\n"))
+     (and (org-string-nw-p description)
+         (concat
+          (org-html-close-tag "meta"
+                              (format " name=\"description\" content=\"%s\"\n"
+                                      (funcall protect-string description))
+                              info)
+          "\n"))
+     (and (org-string-nw-p keywords)
+         (concat
+          (org-html-close-tag "meta"
+                              (format " name=\"keywords\" content=\"%s\""
+                                      (funcall protect-string keywords))
+                              info)
+          "\n")))))
+
+(defun org-html--build-head (info)
+  "Return information for the <head>..</head> of the HTML output.
+INFO is a plist used as a communication channel."
+  (org-element-normalize-string
+   (concat
+    (when (plist-get info :html-head-include-default-style)
+      (org-element-normalize-string org-html-style-default))
+    (org-element-normalize-string (plist-get info :html-head))
+    (org-element-normalize-string (plist-get info :html-head-extra))
+    (when (and (plist-get info :html-htmlized-css-url)
+              (eq org-html-htmlize-output-type 'css))
+      (org-html-close-tag "link"
+                         (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
+                                 (plist-get info :html-htmlized-css-url))
+                         info))
+    (when (plist-get info :html-head-include-scripts) org-html-scripts))))
+
+(defun org-html--build-mathjax-config (info)
+  "Insert the user setup into the mathjax template.
+INFO is a plist used as a communication channel."
+  (when (and (memq (plist-get info :with-latex) '(mathjax t))
+            (org-element-map (plist-get info :parse-tree)
+                '(latex-fragment latex-environment) 'identity info t))
+    (let ((template org-html-mathjax-template)
+         (options org-html-mathjax-options)
+         (in-buffer (or (plist-get info :html-mathjax) ""))
+         name val (yes "   ") (no "// ") x)
+      (mapc
+       (lambda (e)
+        (setq name (car e) val (nth 1 e))
+        (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
+            (setq val (car (read-from-string
+                            (substring in-buffer (match-end 0))))))
+        (if (not (stringp val)) (setq val (format "%s" val)))
+        (if (string-match (concat "%" (upcase (symbol-name name))) template)
+            (setq template (replace-match val t t template))))
+       options)
+      (setq val (nth 1 (assq 'mathml options)))
+      (if (string-match (concat "\\<mathml:") in-buffer)
+         (setq val (car (read-from-string
+                         (substring in-buffer (match-end 0))))))
+      ;; Exchange prefixes depending on mathml setting.
+      (if (not val) (setq x yes yes no no x))
+      ;; Replace cookies to turn on or off the config/jax lines.
+      (if (string-match ":MMLYES:" template)
+         (setq template (replace-match yes t t template)))
+      (if (string-match ":MMLNO:" template)
+         (setq template (replace-match no t t template)))
+      ;; Return the modified template.
+      (org-element-normalize-string template))))
+
+(defun org-html-format-spec (info)
+  "Return format specification for elements that can be
+used in the preamble or postamble."
+  `((?t . ,(org-export-data (plist-get info :title) info))
+    (?d . ,(org-export-data (org-export-get-date info) info))
+    (?T . ,(format-time-string org-html-metadata-timestamp-format))
+    (?a . ,(org-export-data (plist-get info :author) info))
+    (?e . ,(mapconcat
+           (lambda (e)
+             (format "<a href=\"mailto:%s\">%s</a>" e e))
+           (split-string (plist-get info :email)  ",+ *")
+           ", "))
+    (?c . ,(plist-get info :creator))
+    (?C . ,(let ((file (plist-get info :input-file)))
+            (format-time-string org-html-metadata-timestamp-format
+                                (if file (nth 5 (file-attributes file))
+                                  (current-time)))))
+    (?v . ,(or org-html-validation-link ""))))
+
+(defun org-html--build-pre/postamble (type info)
+  "Return document preamble or postamble as a string, or nil.
+TYPE is either 'preamble or 'postamble, INFO is a plist used as a
+communication channel."
+  (let ((section (plist-get info (intern (format ":html-%s" type))))
+       (spec (org-html-format-spec info)))
+    (when section
+      (let ((section-contents
+            (if (functionp section) (funcall section info)
+              (cond
+               ((stringp section) (format-spec section spec))
+               ((eq section 'auto)
+                (let ((date (cdr (assq ?d spec)))
+                      (author (cdr (assq ?a spec)))
+                      (email (cdr (assq ?e spec)))
+                      (creator (cdr (assq ?c spec)))
+                      (timestamp (cdr (assq ?T spec)))
+                      (validation-link (cdr (assq ?v spec))))
+                  (concat
+                   (when (and (plist-get info :with-date)
+                              (org-string-nw-p date))
+                     (format "<p class=\"date\">%s: %s</p>\n"
+                             (org-html--translate "Date" info)
+                             date))
+                   (when (and (plist-get info :with-author)
+                              (org-string-nw-p author))
+                     (format "<p class=\"author\">%s: %s</p>\n"
+                             (org-html--translate "Author" info)
+                             author))
+                   (when (and (plist-get info :with-email)
+                              (org-string-nw-p email))
+                     (format "<p class=\"email\">%s: %s</p>\n"
+                             (org-html--translate "Email" info)
+                             email))
+                   (when (plist-get info :time-stamp-file)
+                     (format
+                      "<p class=\"date\">%s: %s</p>\n"
+                      (org-html--translate "Created" info)
+                      (format-time-string org-html-metadata-timestamp-format)))
+                   (when (plist-get info :with-creator)
+                     (format "<p class=\"creator\">%s</p>\n" creator))
+                   (format "<p class=\"validation\">%s</p>\n"
+                           validation-link))))
+               (t (format-spec
+                   (or (cadr (assoc
+                              (plist-get info :language)
+                              (eval (intern
+                                     (format "org-html-%s-format" type)))))
+                       (cadr
+                        (assoc
+                         "en"
+                         (eval
+                          (intern (format "org-html-%s-format" type))))))
+                   spec))))))
+       (when (org-string-nw-p section-contents)
+         (concat
+          (format "<%s id=\"%s\" class=\"%s\">\n"
+                  (nth 1 (assq type org-html-divs))
+                  (nth 2 (assq type org-html-divs))
+                  org-html--pre/postamble-class)
+          (org-element-normalize-string section-contents)
+          (format "</%s>\n" (nth 1 (assq type org-html-divs)))))))))
+
+(defun org-html-inner-template (contents info)
+  "Return body of document string after HTML conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (concat
+   ;; Table of contents.
+   (let ((depth (plist-get info :with-toc)))
+     (when depth (org-html-toc depth info)))
+   ;; Document contents.
+   contents
+   ;; Footnotes section.
+   (org-html-footnote-section info)))
+
+(defun org-html-template (contents info)
+  "Return complete document string after HTML conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (concat
+   (when (and (not (org-html-html5-p info)) (org-html-xhtml-p info))
+     (let ((decl (or (and (stringp org-html-xml-declaration)
+                             org-html-xml-declaration)
+                        (cdr (assoc (plist-get info :html-extension)
+                                    org-html-xml-declaration))
+                        (cdr (assoc "html" org-html-xml-declaration))
+
+                        "")))
+       (when (not (or (eq nil decl) (string= "" decl)))
+        (format "%s\n"
+                (format decl
+                 (or (and org-html-coding-system
+                          (fboundp 'coding-system-get)
+                          (coding-system-get org-html-coding-system 'mime-charset))
+                     "iso-8859-1"))))))
+   (org-html-doctype info)
+   "\n"
+   (concat "<html"
+          (when (org-html-xhtml-p info)
+            (format
+             " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
+             (plist-get info :language) (plist-get info :language)))
+          ">\n")
+   "<head>\n"
+   (org-html--build-meta-info info)
+   (org-html--build-head info)
+   (org-html--build-mathjax-config info)
+   "</head>\n"
+   "<body>\n"
+   (let ((link-up (org-trim (plist-get info :html-link-up)))
+        (link-home (org-trim (plist-get info :html-link-home))))
+     (unless (and (string= link-up "") (string= link-home ""))
+       (format org-html-home/up-format
+              (or link-up link-home)
+              (or link-home link-up))))
+   ;; Preamble.
+   (org-html--build-pre/postamble 'preamble info)
+   ;; Document contents.
+   (format "<%s id=\"%s\">\n"
+          (nth 1 (assq 'content org-html-divs))
+          (nth 2 (assq 'content org-html-divs)))
+   ;; Document title.
+   (let ((title (plist-get info :title)))
+     (format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title "") info)))
+   contents
+   (format "</%s>\n"
+          (nth 1 (assq 'content org-html-divs)))
+   ;; Postamble.
+   (org-html--build-pre/postamble 'postamble info)
+   ;; Closing document.
+   "</body>\n</html>"))
+
+(defun org-html--translate (s info)
+  "Translate string S according to specified language.
+INFO is a plist used as a communication channel."
+  (org-export-translate s :html info))
+
+;;;; Anchor
+
+(defun org-html--anchor (&optional id desc attributes)
+  "Format a HTML anchor."
+  (let* ((name (and org-html-allow-name-attribute-in-anchors id))
+        (attributes (concat (and id (format " id=\"%s\"" id))
+                            (and name (format " name=\"%s\"" name))
+                            attributes)))
+    (format "<a%s>%s</a>" attributes (or desc ""))))
+
+;;;; Todo
+
+(defun org-html--todo (todo)
+  "Format TODO keywords into HTML."
+  (when todo
+    (format "<span class=\"%s %s%s\">%s</span>"
+           (if (member todo org-done-keywords) "done" "todo")
+           org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
+           todo)))
+
+;;;; Tags
+
+(defun org-html--tags (tags)
+  "Format TAGS into HTML."
+  (when tags
+    (format "<span class=\"tag\">%s</span>"
+           (mapconcat
+            (lambda (tag)
+              (format "<span class=\"%s\">%s</span>"
+                      (concat org-html-tag-class-prefix
+                              (org-html-fix-class-name tag))
+                      tag))
+            tags "&#xa0;"))))
+
+;;;; Headline
+
+(defun* org-html-format-headline
+  (todo todo-type priority text tags
+       &key level section-number headline-label &allow-other-keys)
+  "Format a headline in HTML."
+  (let ((section-number
+        (when section-number
+          (format "<span class=\"section-number-%d\">%s</span> "
+                  level section-number)))
+       (todo (org-html--todo todo))
+       (tags (org-html--tags tags)))
+    (concat section-number todo (and todo " ") text
+           (and tags "&#xa0;&#xa0;&#xa0;") tags)))
+
+;;;; Src Code
+
+(defun org-html-fontify-code (code lang)
+  "Color CODE with htmlize library.
+CODE is a string representing the source code to colorize.  LANG
+is the language used for CODE, as a string, or nil."
+  (when code
+    (cond
+     ;; Case 1: No lang.  Possibly an example block.
+     ((not lang)
+      ;; Simple transcoding.
+      (org-html-encode-plain-text code))
+     ;; Case 2: No htmlize or an inferior version of htmlize
+     ((not (and (require 'htmlize nil t) (fboundp 'htmlize-region-for-paste)))
+      ;; Emit a warning.
+      (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
+      ;; Simple transcoding.
+      (org-html-encode-plain-text code))
+     (t
+      ;; Map language
+      (setq lang (or (assoc-default lang org-src-lang-modes) lang))
+      (let* ((lang-mode (and lang (intern (format "%s-mode" lang)))))
+       (cond
+        ;; Case 1: Language is not associated with any Emacs mode
+        ((not (functionp lang-mode))
+         ;; Simple transcoding.
+         (org-html-encode-plain-text code))
+        ;; Case 2: Default.  Fontify code.
+        (t
+         ;; htmlize
+         (setq code (with-temp-buffer
+                      ;; Switch to language-specific mode.
+                      (funcall lang-mode)
+                      (insert code)
+                      ;; Fontify buffer.
+                      (font-lock-fontify-buffer)
+                      ;; Remove formatting on newline characters.
+                      (save-excursion
+                        (let ((beg (point-min))
+                              (end (point-max)))
+                          (goto-char beg)
+                          (while (progn (end-of-line) (< (point) end))
+                            (put-text-property (point) (1+ (point)) 'face nil)
+                            (forward-char 1))))
+                      (org-src-mode)
+                      (set-buffer-modified-p nil)
+                      ;; Htmlize region.
+                      (org-html-htmlize-region-for-paste
+                       (point-min) (point-max))))
+         ;; Strip any enclosing <pre></pre> tags.
+         (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
+                (end (and beg (string-match "</pre>\\'" code))))
+           (if (and beg end) (substring code beg end) code)))))))))
+
+(defun org-html-do-format-code
+  (code &optional lang refs retain-labels num-start)
+  "Format CODE string as source code.
+Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are,
+respectively, the language of the source code, as a string, an
+alist between line numbers and references (as returned by
+`org-export-unravel-code'), a boolean specifying if labels should
+appear in the source code, and the number associated to the first
+line of code."
+  (let* ((code-lines (org-split-string code "\n"))
+        (code-length (length code-lines))
+        (num-fmt
+         (and num-start
+              (format "%%%ds: "
+                      (length (number-to-string (+ code-length num-start))))))
+        (code (org-html-fontify-code code lang)))
+    (org-export-format-code
+     code
+     (lambda (loc line-num ref)
+       (setq loc
+            (concat
+             ;; Add line number, if needed.
+             (when num-start
+               (format "<span class=\"linenr\">%s</span>"
+                       (format num-fmt line-num)))
+             ;; Transcoded src line.
+             loc
+             ;; Add label, if needed.
+             (when (and ref retain-labels) (format " (%s)" ref))))
+       ;; Mark transcoded line as an anchor, if needed.
+       (if (not ref) loc
+        (format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>"
+                ref loc)))
+     num-start refs)))
+
+(defun org-html-format-code (element info)
+  "Format contents of ELEMENT as source code.
+ELEMENT is either an example block or a src block.  INFO is
+a plist used as a communication channel."
+  (let* ((lang (org-element-property :language element))
+        ;; Extract code and references.
+        (code-info (org-export-unravel-code element))
+        (code (car code-info))
+        (refs (cdr code-info))
+        ;; Does the src block contain labels?
+        (retain-labels (org-element-property :retain-labels element))
+        ;; Does it have line numbers?
+        (num-start (case (org-element-property :number-lines element)
+                     (continued (org-export-get-loc element info))
+                     (new 0))))
+    (org-html-do-format-code code lang refs retain-labels num-start)))
+
+\f
+;;; Tables of Contents
+
+(defun org-html-toc (depth info)
+  "Build a table of contents.
+DEPTH is an integer specifying the depth of the table.  INFO is a
+plist used as a communication channel.  Return the table of
+contents as a string, or nil if it is empty."
+  (let ((toc-entries
+        (mapcar (lambda (headline)
+                  (cons (org-html--format-toc-headline headline info)
+                        (org-export-get-relative-level headline info)))
+                (org-export-collect-headlines info depth)))
+       (outer-tag (if (and (org-html-html5-p info)
+                           (plist-get info :html-html5-fancy))
+                      "nav"
+                    "div")))
+    (when toc-entries
+      (concat (format "<%s id=\"table-of-contents\">\n" outer-tag)
+             (format "<h%d>%s</h%d>\n"
+                     org-html-toplevel-hlevel
+                     (org-html--translate "Table of Contents" info)
+                     org-html-toplevel-hlevel)
+             "<div id=\"text-table-of-contents\">"
+             (org-html--toc-text toc-entries)
+             "</div>\n"
+             (format "</%s>\n" outer-tag)))))
+
+(defun org-html--toc-text (toc-entries)
+  "Return innards of a table of contents, as a string.
+TOC-ENTRIES is an alist where key is an entry title, as a string,
+and value is its relative level, as an integer."
+  (let* ((prev-level (1- (cdar toc-entries)))
+        (start-level prev-level))
+    (concat
+     (mapconcat
+      (lambda (entry)
+       (let ((headline (car entry))
+             (level (cdr entry)))
+         (concat
+          (let* ((cnt (- level prev-level))
+                 (times (if (> cnt 0) (1- cnt) (- cnt)))
+                 rtn)
+            (setq prev-level level)
+            (concat
+             (org-html--make-string
+              times (cond ((> cnt 0) "\n<ul>\n<li>")
+                          ((< cnt 0) "</li>\n</ul>\n")))
+             (if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>")))
+          headline)))
+      toc-entries "")
+     (org-html--make-string (- prev-level start-level) "</li>\n</ul>\n"))))
+
+(defun org-html--format-toc-headline (headline info)
+  "Return an appropriate table of contents entry for HEADLINE.
+INFO is a plist used as a communication channel."
+  (let* ((todo (and (plist-get info :with-todo-keywords)
+                   (let ((todo (org-element-property :todo-keyword headline)))
+                     (and todo (org-export-data todo info)))))
+        (todo-type (and todo (org-element-property :todo-type headline)))
+        (priority (and (plist-get info :with-priority)
+                       (org-element-property :priority headline)))
+        (text (org-export-data-with-backend
+               (org-export-get-alt-title headline info)
+               ;; Create an anonymous back-end that will ignore any
+               ;; footnote-reference, link, radio-target and target
+               ;; in table of contents.
+               (org-export-create-backend
+                :parent 'html
+                :transcoders '((footnote-reference . ignore)
+                               (link . (lambda (object c i) c))
+                               (radio-target . (lambda (object c i) c))
+                               (target . ignore)))
+               info))
+        (tags (and (eq (plist-get info :with-tags) t)
+                   (org-export-get-tags headline info))))
+    (format "<a href=\"#%s\">%s</a>"
+           (org-export-solidify-link-text
+            (or (org-element-property :CUSTOM_ID headline)
+                (concat "sec-"
+                        (mapconcat
+                         #'number-to-string
+                         (org-export-get-headline-number headline info)
+                         "-"))))
+           (apply (if (functionp org-html-format-headline-function)
+                      (lambda (todo todo-type priority text tags &rest ignore)
+                        (funcall org-html-format-headline-function
+                                 todo todo-type priority text tags))
+                    #'org-html-format-headline)
+                  todo todo-type priority text tags :section-number nil))))
+
+(defun org-html-list-of-listings (info)
+  "Build a list of listings.
+INFO is a plist used as a communication channel.  Return the list
+of listings as a string, or nil if it is empty."
+  (let ((lol-entries (org-export-collect-listings info)))
+    (when lol-entries
+      (concat "<div id=\"list-of-listings\">\n"
+             (format "<h%d>%s</h%d>\n"
+                     org-html-toplevel-hlevel
+                     (org-html--translate "List of Listings" info)
+                     org-html-toplevel-hlevel)
+             "<div id=\"text-list-of-listings\">\n<ul>\n"
+             (let ((count 0)
+                   (initial-fmt (format "<span class=\"listing-number\">%s</span>"
+                                        (org-html--translate "Listing %d:" info))))
+               (mapconcat
+                (lambda (entry)
+                  (let ((label (org-element-property :name entry))
+                        (title (org-trim
+                                (org-export-data
+                                 (or (org-export-get-caption entry t)
+                                     (org-export-get-caption entry))
+                                 info))))
+                    (concat
+                     "<li>"
+                     (if (not label)
+                         (concat (format initial-fmt (incf count)) " " title)
+                       (format "<a href=\"#%s\">%s %s</a>"
+                               (org-export-solidify-link-text label)
+                               (format initial-fmt (incf count))
+                               title))
+                     "</li>")))
+                lol-entries "\n"))
+             "\n</ul>\n</div>\n</div>"))))
+
+(defun org-html-list-of-tables (info)
+  "Build a list of tables.
+INFO is a plist used as a communication channel.  Return the list
+of tables as a string, or nil if it is empty."
+  (let ((lol-entries (org-export-collect-tables info)))
+    (when lol-entries
+      (concat "<div id=\"list-of-tables\">\n"
+             (format "<h%d>%s</h%d>\n"
+                     org-html-toplevel-hlevel
+                     (org-html--translate "List of Tables" info)
+                     org-html-toplevel-hlevel)
+             "<div id=\"text-list-of-tables\">\n<ul>\n"
+             (let ((count 0)
+                   (initial-fmt (format "<span class=\"table-number\">%s</span>"
+                                        (org-html--translate "Table %d:" info))))
+               (mapconcat
+                (lambda (entry)
+                  (let ((label (org-element-property :name entry))
+                        (title (org-trim
+                                (org-export-data
+                                 (or (org-export-get-caption entry t)
+                                     (org-export-get-caption entry))
+                                 info))))
+                    (concat
+                     "<li>"
+                     (if (not label)
+                         (concat (format initial-fmt (incf count)) " " title)
+                       (format "<a href=\"#%s\">%s %s</a>"
+                               (org-export-solidify-link-text label)
+                               (format initial-fmt (incf count))
+                               title))
+                     "</li>")))
+                lol-entries "\n"))
+             "\n</ul>\n</div>\n</div>"))))
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-html-bold (bold contents info)
+  "Transcode BOLD from Org to HTML.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
+         contents))
+
+;;;; Center Block
+
+(defun org-html-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (format "<div class=\"center\">\n%s</div>" contents))
+
+;;;; Clock
+
+(defun org-html-clock (clock contents info)
+  "Transcode a CLOCK element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "<p>
+<span class=\"timestamp-wrapper\">
+<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s
+</span>
+</p>"
+         org-clock-string
+         (org-translate-time
+          (org-element-property :raw-value
+                                (org-element-property :value clock)))
+         (let ((time (org-element-property :duration clock)))
+           (and time (format " <span class=\"timestamp\">(%s)</span>" time)))))
+
+;;;; Code
+
+(defun org-html-code (code contents info)
+  "Transcode CODE from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
+         (org-html-encode-plain-text (org-element-property :value code))))
+
+;;;; Drawer
+
+(defun org-html-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (if (functionp org-html-format-drawer-function)
+      (funcall org-html-format-drawer-function
+              (org-element-property :drawer-name drawer)
+              contents)
+    ;; If there's no user defined function: simply
+    ;; display contents of the drawer.
+    contents))
+
+;;;; Dynamic Block
+
+(defun org-html-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information.  See `org-export-data'."
+  contents)
+
+;;;; Entity
+
+(defun org-html-entity (entity contents info)
+  "Transcode an ENTITY object from Org to HTML.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (org-element-property :html entity))
+
+;;;; Example Block
+
+(defun org-html-example-block (example-block contents info)
+  "Transcode a EXAMPLE-BLOCK element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (if (org-export-read-attribute :attr_html example-block :textarea)
+      (org-html--textarea-block example-block)
+    (format "<pre class=\"example\">\n%s</pre>"
+           (org-html-format-code example-block info))))
+
+;;;; Export Snippet
+
+(defun org-html-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (when (eq (org-export-snippet-backend export-snippet) 'html)
+    (org-element-property :value export-snippet)))
+
+;;;; Export Block
+
+(defun org-html-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (string= (org-element-property :type export-block) "HTML")
+    (org-remove-indentation (org-element-property :value export-block))))
+
+;;;; Fixed Width
+
+(defun org-html-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (format "<pre class=\"example\">\n%s</pre>"
+         (org-html-do-format-code
+          (org-remove-indentation
+           (org-element-property :value fixed-width)))))
+
+;;;; Footnote Reference
+
+(defun org-html-footnote-reference (footnote-reference contents info)
+  "Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (concat
+   ;; Insert separator between two footnotes in a row.
+   (let ((prev (org-export-get-previous-element footnote-reference info)))
+     (when (eq (org-element-type prev) 'footnote-reference)
+       org-html-footnote-separator))
+   (cond
+    ((not (org-export-footnote-first-reference-p footnote-reference info))
+     (org-html-format-footnote-reference
+      (org-export-get-footnote-number footnote-reference info)
+      "IGNORED" 100))
+    ;; Inline definitions are secondary strings.
+    ((eq (org-element-property :type footnote-reference) 'inline)
+     (org-html-format-footnote-reference
+      (org-export-get-footnote-number footnote-reference info)
+      "IGNORED" 1))
+    ;; Non-inline footnotes definitions are full Org data.
+    (t (org-html-format-footnote-reference
+       (org-export-get-footnote-number footnote-reference info)
+       "IGNORED" 1)))))
+
+;;;; Headline
+
+(defun org-html-format-headline--wrap
+  (headline info &optional format-function &rest extra-keys)
+  "Transcode a HEADLINE element from Org to HTML.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  (let* ((level (+ (org-export-get-relative-level headline info)
+                  (1- org-html-toplevel-hlevel)))
+        (headline-number (org-export-get-headline-number headline info))
+        (section-number (and (not (org-export-low-level-p headline info))
+                             (org-export-numbered-headline-p headline info)
+                             (mapconcat 'number-to-string
+                                        headline-number ".")))
+        (todo (and (plist-get info :with-todo-keywords)
+                   (let ((todo (org-element-property :todo-keyword headline)))
+                     (and todo (org-export-data todo info)))))
+        (todo-type (and todo (org-element-property :todo-type headline)))
+        (priority (and (plist-get info :with-priority)
+                       (org-element-property :priority headline)))
+        (text (org-export-data (org-element-property :title headline) info))
+        (tags (and (plist-get info :with-tags)
+                   (org-export-get-tags headline info)))
+        (headline-label (or (org-element-property :CUSTOM_ID headline)
+                            (concat "sec-" (mapconcat 'number-to-string
+                                                      headline-number "-"))))
+        (format-function
+         (cond ((functionp format-function) format-function)
+               ((functionp org-html-format-headline-function)
+                (lambda (todo todo-type priority text tags &rest ignore)
+                  (funcall org-html-format-headline-function
+                           todo todo-type priority text tags)))
+               (t 'org-html-format-headline))))
+    (apply format-function
+          todo todo-type  priority text tags
+          :headline-label headline-label :level level
+          :section-number section-number extra-keys)))
+
+(defun org-html-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to HTML.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  ;; Empty contents?
+  (setq contents (or contents ""))
+  (let* ((numberedp (org-export-numbered-headline-p headline info))
+        (level (org-export-get-relative-level headline info))
+        (text (org-export-data (org-element-property :title headline) info))
+        (todo (and (plist-get info :with-todo-keywords)
+                   (let ((todo (org-element-property :todo-keyword headline)))
+                     (and todo (org-export-data todo info)))))
+        (todo-type (and todo (org-element-property :todo-type headline)))
+        (tags (and (plist-get info :with-tags)
+                   (org-export-get-tags headline info)))
+        (priority (and (plist-get info :with-priority)
+                       (org-element-property :priority headline)))
+        (section-number (and (org-export-numbered-headline-p headline info)
+                             (mapconcat 'number-to-string
+                                        (org-export-get-headline-number
+                                         headline info) ".")))
+        ;; Create the headline text.
+        (full-text (org-html-format-headline--wrap headline info)))
+    (cond
+     ;; Case 1: This is a footnote section: ignore it.
+     ((org-element-property :footnote-section-p headline) nil)
+     ;; Case 2. This is a deep sub-tree: export it as a list item.
+     ;;         Also export as items headlines for which no section
+     ;;         format has been found.
+     ((org-export-low-level-p headline info)
+      ;; Build the real contents of the sub-tree.
+      (let* ((type (if numberedp 'ordered 'unordered))
+            (itemized-body (org-html-format-list-item
+                            contents type nil info nil full-text)))
+       (concat
+        (and (org-export-first-sibling-p headline info)
+             (org-html-begin-plain-list type))
+        itemized-body
+        (and (org-export-last-sibling-p headline info)
+             (org-html-end-plain-list type)))))
+     ;; Case 3. Standard headline.  Export it as a section.
+     (t
+      (let* ((section-number (mapconcat 'number-to-string
+                                       (org-export-get-headline-number
+                                        headline info) "-"))
+            (ids (remove 'nil
+                         (list (org-element-property :CUSTOM_ID headline)
+                               (concat "sec-" section-number)
+                               (org-element-property :ID headline))))
+            (preferred-id (car ids))
+            (extra-ids (cdr ids))
+            (extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
+            (level1 (+ level (1- org-html-toplevel-hlevel)))
+            (first-content (car (org-element-contents headline))))
+       (format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
+               (org-html--container headline info)
+               (format "outline-container-%s"
+                       (or (org-element-property :CUSTOM_ID headline)
+                           (concat "sec-" section-number)))
+               (concat (format "outline-%d" level1) (and extra-class " ")
+                       extra-class)
+               (format "\n<h%d id=\"%s\">%s%s</h%d>\n"
+                       level1
+                       preferred-id
+                       (mapconcat
+                        (lambda (x)
+                          (let ((id (org-export-solidify-link-text
+                                     (if (org-uuidgen-p x) (concat "ID-" x)
+                                       x))))
+                            (org-html--anchor id)))
+                        extra-ids "")
+                       full-text
+                       level1)
+               ;; When there is no section, pretend there is an empty
+               ;; one to get the correct <div class="outline- ...>
+               ;; which is needed by `org-info.js'.
+               (if (not (eq (org-element-type first-content) 'section))
+                   (concat (org-html-section first-content "" info)
+                           contents)
+                 contents)
+               (org-html--container headline info)))))))
+
+(defun org-html--container (headline info)
+  (or (org-element-property :HTML_CONTAINER headline)
+      (if (= 1 (org-export-get-relative-level headline info))
+         (plist-get info :html-container)
+       "div")))
+
+;;;; Horizontal Rule
+
+(defun org-html-horizontal-rule (horizontal-rule contents info)
+  "Transcode an HORIZONTAL-RULE  object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-html-close-tag "hr" nil info))
+
+;;;; Inline Src Block
+
+(defun org-html-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((org-lang (org-element-property :language inline-src-block))
+        (code (org-element-property :value inline-src-block)))
+    (error "Cannot export inline src block")))
+
+;;;; Inlinetask
+
+(defun org-html-format-section (text class &optional id)
+  "Format a section with TEXT into a HTML div with CLASS and ID."
+  (let ((extra (concat (when id (format " id=\"%s\"" id)))))
+    (concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
+
+(defun org-html-inlinetask (inlinetask contents info)
+  "Transcode an INLINETASK element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (cond
+   ;; If `org-html-format-inlinetask-function' is provided, call it
+   ;; with appropriate arguments.
+   ((functionp org-html-format-inlinetask-function)
+    (let ((format-function
+          (function*
+           (lambda (todo todo-type priority text tags
+                    &key contents &allow-other-keys)
+             (funcall org-html-format-inlinetask-function
+                      todo todo-type priority text tags contents)))))
+      (org-html-format-headline--wrap
+       inlinetask info format-function :contents contents)))
+   ;; Otherwise, use a default template.
+   (t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
+             (org-html-format-headline--wrap inlinetask info)
+             (org-html-close-tag "br" nil info)
+             contents))))
+
+;;;; Italic
+
+(defun org-html-italic (italic contents info)
+  "Transcode ITALIC from Org to HTML.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
+
+;;;; Item
+
+(defun org-html-checkbox (checkbox)
+  "Format CHECKBOX into HTML."
+  (case checkbox (on "<code>[X]</code>")
+       (off "<code>[&#xa0;]</code>")
+       (trans "<code>[-]</code>")
+       (t "")))
+
+(defun org-html-format-list-item (contents type checkbox info
+                                            &optional term-counter-id
+                                            headline)
+  "Format a list item into HTML."
+  (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " ")))
+       (br (org-html-close-tag "br" nil info)))
+    (concat
+     (case type
+       (ordered
+       (let* ((counter term-counter-id)
+              (extra (if counter (format " value=\"%s\"" counter) "")))
+         (concat
+          (format "<li%s>" extra)
+          (when headline (concat headline br)))))
+       (unordered
+       (let* ((id term-counter-id)
+              (extra (if id (format " id=\"%s\"" id) "")))
+         (concat
+          (format "<li%s>" extra)
+          (when headline (concat headline br)))))
+       (descriptive
+       (let* ((term term-counter-id))
+         (setq term (or term "(no term)"))
+         ;; Check-boxes in descriptive lists are associated to tag.
+         (concat (format "<dt> %s </dt>"
+                         (concat checkbox term))
+                 "<dd>"))))
+     (unless (eq type 'descriptive) checkbox)
+     contents
+     (case type
+       (ordered "</li>")
+       (unordered "</li>")
+       (descriptive "</dd>")))))
+
+(defun org-html-item (item contents info)
+  "Transcode an ITEM element from Org to HTML.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((plain-list (org-export-get-parent item))
+        (type (org-element-property :type plain-list))
+        (counter (org-element-property :counter item))
+        (checkbox (org-element-property :checkbox item))
+        (tag (let ((tag (org-element-property :tag item)))
+               (and tag (org-export-data tag info)))))
+    (org-html-format-list-item
+     contents type checkbox info (or tag counter))))
+
+;;;; Keyword
+
+(defun org-html-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "HTML") value)
+     ((string= key "TOC")
+      (let ((value (downcase value)))
+       (cond
+        ((string-match "\\<headlines\\>" value)
+         (let ((depth (or (and (string-match "[0-9]+" value)
+                               (string-to-number (match-string 0 value)))
+                          (plist-get info :with-toc))))
+           (org-html-toc depth info)))
+        ((string= "listings" value) (org-html-list-of-listings info))
+        ((string= "tables" value) (org-html-list-of-tables info))))))))
+
+;;;; Latex Environment
+
+(defun org-html-format-latex (latex-frag processing-type)
+  "Format a LaTeX fragment LATEX-FRAG into HTML."
+  (let ((cache-relpath "") (cache-dir ""))
+    (unless (eq processing-type 'mathjax)
+      (let ((bfn (or (buffer-file-name)
+                    (make-temp-name
+                     (expand-file-name "latex" temporary-file-directory)))))
+       (setq cache-relpath
+             (concat "ltxpng/"
+                     (file-name-sans-extension
+                      (file-name-nondirectory bfn)))
+             cache-dir (file-name-directory bfn))))
+    (with-temp-buffer
+      (insert latex-frag)
+      (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
+                       nil nil processing-type)
+      (buffer-string))))
+
+(defun org-html-latex-environment (latex-environment contents info)
+  "Transcode a LATEX-ENVIRONMENT element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((processing-type (plist-get info :with-latex))
+       (latex-frag (org-remove-indentation
+                    (org-element-property :value latex-environment)))
+       (attributes (org-export-read-attribute :attr_html latex-environment)))
+    (case processing-type
+      ((t mathjax)
+       (org-html-format-latex latex-frag 'mathjax))
+      ((dvipng imagemagick)
+       (let ((formula-link (org-html-format-latex latex-frag processing-type)))
+        (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
+          ;; Do not provide a caption or a name to be consistent with
+          ;; `mathjax' handling.
+          (org-html--wrap-image
+           (org-html--format-image
+            (match-string 1 formula-link) attributes info) info))))
+      (t latex-frag))))
+
+;;;; Latex Fragment
+
+(defun org-html-latex-fragment (latex-fragment contents info)
+  "Transcode a LATEX-FRAGMENT object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((latex-frag (org-element-property :value latex-fragment))
+       (processing-type (plist-get info :with-latex)))
+    (case processing-type
+      ((t mathjax)
+       (org-html-format-latex latex-frag 'mathjax))
+      ((dvipng imagemagick)
+       (let ((formula-link (org-html-format-latex latex-frag processing-type)))
+        (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
+          (org-html--format-image (match-string 1 formula-link) nil info))))
+      (t latex-frag))))
+
+;;;; Line Break
+
+(defun org-html-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (concat (org-html-close-tag "br" nil info) "\n"))
+
+;;;; Link
+
+(defun org-html-inline-image-p (link info)
+  "Non-nil when LINK is meant to appear as an image.
+INFO is a plist used as a communication channel.  LINK is an
+inline image when it has no description and targets an image
+file (see `org-html-inline-image-rules' for more information), or
+if its description is a single link targeting an image file."
+  (if (not (org-element-contents link))
+      (org-export-inline-image-p link org-html-inline-image-rules)
+    (not
+     (let ((link-count 0))
+       (org-element-map (org-element-contents link)
+          (cons 'plain-text org-element-all-objects)
+        (lambda (obj)
+          (case (org-element-type obj)
+            (plain-text (org-string-nw-p obj))
+            (link (if (= link-count 1) t
+                    (incf link-count)
+                    (not (org-export-inline-image-p
+                          obj org-html-inline-image-rules))))
+            (otherwise t)))
+         info t)))))
+
+(defvar org-html-standalone-image-predicate)
+(defun org-html-standalone-image-p (element info)
+  "Test if ELEMENT is a standalone image.
+
+INFO is a plist holding contextual information.
+
+Return non-nil, if ELEMENT is of type paragraph and its sole
+content, save for white spaces, is a link that qualifies as an
+inline image.
+
+Return non-nil, if ELEMENT is of type link and its containing
+paragraph has no other content save white spaces.
+
+Return nil, otherwise.
+
+Bind `org-html-standalone-image-predicate' to constrain paragraph
+further.  For example, to check for only captioned standalone
+images, set it to:
+
+  \(lambda (paragraph) (org-element-property :caption paragraph))"
+  (let ((paragraph (case (org-element-type element)
+                    (paragraph element)
+                    (link (org-export-get-parent element)))))
+    (and (eq (org-element-type paragraph) 'paragraph)
+        (or (not (and (boundp 'org-html-standalone-image-predicate)
+                      (functionp org-html-standalone-image-predicate)))
+            (funcall org-html-standalone-image-predicate paragraph))
+        (not (let ((link-count 0))
+               (org-element-map (org-element-contents paragraph)
+                   (cons 'plain-text org-element-all-objects)
+                 (lambda (obj) (case (org-element-type obj)
+                            (plain-text (org-string-nw-p obj))
+                            (link
+                             (or (> (incf link-count) 1)
+                                 (not (org-html-inline-image-p obj info))))
+                            (otherwise t)))
+                 info 'first-match 'link))))))
+
+(defun org-html-link (link desc info)
+  "Transcode a LINK object from Org to HTML.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information.  See
+`org-export-data'."
+  (let* ((home (when (plist-get info :html-link-home)
+                (org-trim (plist-get info :html-link-home))))
+        (use-abs-url (plist-get info :html-link-use-abs-url))
+        (link-org-files-as-html-maybe
+         (function
+          (lambda (raw-path info)
+            "Treat links to `file.org' as links to `file.html', if needed.
+           See `org-html-link-org-files-as-html'."
+            (cond
+             ((and org-html-link-org-files-as-html
+                   (string= ".org"
+                            (downcase (file-name-extension raw-path "."))))
+              (concat (file-name-sans-extension raw-path) "."
+                      (plist-get info :html-extension)))
+             (t raw-path)))))
+        (type (org-element-property :type link))
+        (raw-path (org-element-property :path link))
+        ;; Ensure DESC really exists, or set it to nil.
+        (desc (org-string-nw-p desc))
+        (path
+         (cond
+          ((member type '("http" "https" "ftp" "mailto"))
+           (concat type ":" raw-path))
+          ((string= type "file")
+           ;; Treat links to ".org" files as ".html", if needed.
+           (setq raw-path
+                 (funcall link-org-files-as-html-maybe raw-path info))
+           ;; If file path is absolute, prepend it with protocol
+           ;; component - "file://".
+           (cond ((file-name-absolute-p raw-path)
+                  (setq raw-path
+                        (concat "file://" (expand-file-name
+                                           raw-path))))
+                 ((and home use-abs-url)
+                  (setq raw-path (concat (file-name-as-directory home) raw-path))))
+           ;; Add search option, if any.  A search option can be
+           ;; relative to a custom-id or a headline title.  Any other
+           ;; option is ignored.
+           (let ((option (org-element-property :search-option link)))
+             (cond ((not option) raw-path)
+                   ((eq (aref option 0) ?#) (concat raw-path option))
+                   ;; External fuzzy link: try to resolve it if path
+                   ;; belongs to current project, if any.
+                   ((eq (aref option 0) ?*)
+                    (concat
+                     raw-path
+                     (let ((numbers
+                            (org-publish-resolve-external-fuzzy-link
+                             (org-element-property :path link) option)))
+                       (and numbers (concat "#sec-"
+                                            (mapconcat 'number-to-string
+                                                       numbers "-"))))))
+                   (t raw-path))))
+          (t raw-path)))
+        ;; Extract attributes from parent's paragraph.  HACK: Only do
+        ;; this for the first link in parent (inner image link for
+        ;; inline images).  This is needed as long as attributes
+        ;; cannot be set on a per link basis.
+        (attributes-plist
+         (let* ((parent (org-export-get-parent-element link))
+                (link (let ((container (org-export-get-parent link)))
+                        (if (and (eq (org-element-type container) 'link)
+                                 (org-html-inline-image-p link info))
+                            container
+                          link))))
+           (and (eq (org-element-map parent 'link 'identity info t) link)
+                (org-export-read-attribute :attr_html parent))))
+        (attributes
+         (let ((attr (org-html--make-attribute-string attributes-plist)))
+           (if (org-string-nw-p attr) (concat " " attr) "")))
+        protocol)
+    (cond
+     ;; Image file.
+     ((and org-html-inline-images
+          (org-export-inline-image-p link org-html-inline-image-rules))
+      (org-html--format-image path attributes-plist info))
+     ;; Radio target: Transcode target's contents and use them as
+     ;; link's description.
+     ((string= type "radio")
+      (let ((destination (org-export-resolve-radio-link link info)))
+       (when destination
+         (format "<a href=\"#%s\"%s>%s</a>"
+                 (org-export-solidify-link-text path)
+                 attributes
+                 (org-export-data (org-element-contents destination) info)))))
+     ;; Links pointing to a headline: Find destination and build
+     ;; appropriate referencing command.
+     ((member type '("custom-id" "fuzzy" "id"))
+      (let ((destination (if (string= type "fuzzy")
+                            (org-export-resolve-fuzzy-link link info)
+                          (org-export-resolve-id-link link info))))
+       (case (org-element-type destination)
+         ;; ID link points to an external file.
+         (plain-text
+          (let ((fragment (concat "ID-" path))
+                ;; Treat links to ".org" files as ".html", if needed.
+                (path (funcall link-org-files-as-html-maybe
+                               destination info)))
+            (format "<a href=\"%s#%s\"%s>%s</a>"
+                    path fragment attributes (or desc destination))))
+         ;; Fuzzy link points nowhere.
+         ((nil)
+          (format "<i>%s</i>"
+                  (or desc
+                      (org-export-data
+                       (org-element-property :raw-link link) info))))
+         ;; Link points to a headline.
+         (headline
+          (let ((href
+                 ;; What href to use?
+                 (cond
+                  ;; Case 1: Headline is linked via it's CUSTOM_ID
+                  ;; property.  Use CUSTOM_ID.
+                  ((string= type "custom-id")
+                   (org-element-property :CUSTOM_ID destination))
+                  ;; Case 2: Headline is linked via it's ID property
+                  ;; or through other means.  Use the default href.
+                  ((member type '("id" "fuzzy"))
+                   (format "sec-%s"
+                           (mapconcat 'number-to-string
+                                      (org-export-get-headline-number
+                                       destination info) "-")))
+                  (t (error "Shouldn't reach here"))))
+                ;; What description to use?
+                (desc
+                 ;; Case 1: Headline is numbered and LINK has no
+                 ;; description.  Display section number.
+                 (if (and (org-export-numbered-headline-p destination info)
+                          (not desc))
+                     (mapconcat 'number-to-string
+                                (org-export-get-headline-number
+                                 destination info) ".")
+                   ;; Case 2: Either the headline is un-numbered or
+                   ;; LINK has a custom description.  Display LINK's
+                   ;; description or headline's title.
+                   (or desc (org-export-data (org-element-property
+                                              :title destination) info)))))
+            (format "<a href=\"#%s\"%s>%s</a>"
+                    (org-export-solidify-link-text href) attributes desc)))
+         ;; Fuzzy link points to a target or an element.
+         (t
+          (let* ((path (org-export-solidify-link-text path))
+                 (org-html-standalone-image-predicate 'org-html--has-caption-p)
+                 (number (cond
+                          (desc nil)
+                          ((org-html-standalone-image-p destination info)
+                           (org-export-get-ordinal
+                            (org-element-map destination 'link
+                              'identity info t)
+                            info 'link 'org-html-standalone-image-p))
+                          (t (org-export-get-ordinal
+                              destination info nil 'org-html--has-caption-p))))
+                 (desc (cond (desc)
+                             ((not number) "No description for this link")
+                             ((numberp number) (number-to-string number))
+                             (t (mapconcat 'number-to-string number ".")))))
+            (format "<a href=\"#%s\"%s>%s</a>" path attributes desc))))))
+     ;; Coderef: replace link with the reference name or the
+     ;; equivalent line number.
+     ((string= type "coderef")
+      (let ((fragment (concat "coderef-" path)))
+       (format "<a href=\"#%s\"%s%s>%s</a>"
+               fragment
+               (org-trim
+                (format (concat "class=\"coderef\""
+                                " onmouseover=\"CodeHighlightOn(this, '%s');\""
+                                " onmouseout=\"CodeHighlightOff(this, '%s');\"")
+                        fragment fragment))
+               attributes
+               (format (org-export-get-coderef-format path desc)
+                       (org-export-resolve-coderef path info)))))
+     ;; Link type is handled by a special function.
+     ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
+      (funcall protocol (org-link-unescape path) desc 'html))
+     ;; External link with a description part.
+     ((and path desc) (format "<a href=\"%s\"%s>%s</a>" path attributes desc))
+     ;; External link without a description part.
+     (path (format "<a href=\"%s\"%s>%s</a>" path attributes path))
+     ;; No path, only description.  Try to do something useful.
+     (t (format "<i>%s</i>" desc)))))
+
+;;;; Paragraph
+
+(defun org-html-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to HTML.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  (let* ((parent (org-export-get-parent paragraph))
+        (parent-type (org-element-type parent))
+        (style '((footnote-definition " class=\"footpara\"")))
+        (extra (or (cadr (assoc parent-type style)) "")))
+    (cond
+     ((and (eq (org-element-type parent) 'item)
+          (= (org-element-property :begin paragraph)
+             (org-element-property :contents-begin parent)))
+      ;; Leading paragraph in a list item have no tags.
+      contents)
+     ((org-html-standalone-image-p paragraph info)
+      ;; Standalone image.
+      (let ((caption
+            (let ((raw (org-export-data
+                        (org-export-get-caption paragraph) info))
+                  (org-html-standalone-image-predicate
+                   'org-html--has-caption-p))
+              (if (not (org-string-nw-p raw)) raw
+                (concat
+                  "<span class=\"figure-number\">"
+                 (format (org-html--translate "Figure %d:" info)
+                         (org-export-get-ordinal
+                          (org-element-map paragraph 'link
+                            'identity info t)
+                          info nil 'org-html-standalone-image-p))
+                 "</span> " raw))))
+           (label (org-element-property :name paragraph)))
+       (org-html--wrap-image contents info caption label)))
+     ;; Regular paragraph.
+     (t (format "<p%s>\n%s</p>" extra contents)))))
+
+;;;; Plain List
+
+;; FIXME Maybe arg1 is not needed because <li value="20"> already sets
+;; the correct value for the item counter
+(defun org-html-begin-plain-list (type &optional arg1)
+  "Insert the beginning of the HTML list depending on TYPE.
+When ARG1 is a string, use it as the start parameter for ordered
+lists."
+  (case type
+    (ordered
+     (format "<ol class=\"org-ol\"%s>"
+            (if arg1 (format " start=\"%d\"" arg1) "")))
+    (unordered "<ul class=\"org-ul\">")
+    (descriptive "<dl class=\"org-dl\">")))
+
+(defun org-html-end-plain-list (type)
+  "Insert the end of the HTML list depending on TYPE."
+  (case type
+    (ordered "</ol>")
+    (unordered "</ul>")
+    (descriptive "</dl>")))
+
+(defun org-html-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to HTML.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
+        (type (org-element-property :type plain-list)))
+    (format "%s\n%s%s"
+           (org-html-begin-plain-list type)
+           contents (org-html-end-plain-list type))))
+
+;;;; Plain Text
+
+(defun org-html-convert-special-strings (string)
+  "Convert special characters in STRING to HTML."
+  (let ((all org-html-special-string-regexps)
+       e a re rpl start)
+    (while (setq a (pop all))
+      (setq re (car a) rpl (cdr a) start 0)
+      (while (string-match re string start)
+       (setq string (replace-match rpl t nil string))))
+    string))
+
+(defun org-html-encode-plain-text (text)
+  "Convert plain text characters from TEXT to HTML equivalent.
+Possible conversions are set in `org-html-protect-char-alist'."
+  (mapc
+   (lambda (pair)
+     (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
+   org-html-protect-char-alist)
+  text)
+
+(defun org-html-plain-text (text info)
+  "Transcode a TEXT string from Org to HTML.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  (let ((output text))
+    ;; Protect following characters: <, >, &.
+    (setq output (org-html-encode-plain-text output))
+    ;; Handle smart quotes.  Be sure to provide original string since
+    ;; OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output (org-export-activate-smart-quotes output :html info text)))
+    ;; Handle special strings.
+    (when (plist-get info :with-special-strings)
+      (setq output (org-html-convert-special-strings output)))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output
+           (replace-regexp-in-string
+            "\\(\\\\\\\\\\)?[ \t]*\n"
+            (concat (org-html-close-tag "br" nil info) "\n") output)))
+    ;; Return value.
+    output))
+
+
+;; Planning
+
+(defun org-html-planning (planning contents info)
+  "Transcode a PLANNING element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
+    (format
+     "<p><span class=\"timestamp-wrapper\">%s</span></p>"
+     (mapconcat
+      'identity
+      (delq nil
+           (list
+            (let ((closed (org-element-property :closed planning)))
+              (when closed
+                (format span-fmt org-closed-string
+                        (org-translate-time
+                         (org-element-property :raw-value closed)))))
+            (let ((deadline (org-element-property :deadline planning)))
+              (when deadline
+                (format span-fmt org-deadline-string
+                        (org-translate-time
+                         (org-element-property :raw-value deadline)))))
+            (let ((scheduled (org-element-property :scheduled planning)))
+              (when scheduled
+                (format span-fmt org-scheduled-string
+                        (org-translate-time
+                         (org-element-property :raw-value scheduled)))))))
+      " "))))
+
+;;;; Property Drawer
+
+(defun org-html-property-drawer (property-drawer contents info)
+  "Transcode a PROPERTY-DRAWER element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  ;; The property drawer isn't exported but we want separating blank
+  ;; lines nonetheless.
+  "")
+
+;;;; Quote Block
+
+(defun org-html-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (format "<blockquote>\n%s</blockquote>" contents))
+
+;;;; Quote Section
+
+(defun org-html-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((value (org-remove-indentation
+               (org-element-property :value quote-section))))
+    (when value (format "<pre>\n%s</pre>" value))))
+
+;;;; Section
+
+(defun org-html-section (section contents info)
+  "Transcode a SECTION element from Org to HTML.
+CONTENTS holds the contents of the section.  INFO is a plist
+holding contextual information."
+  (let ((parent (org-export-get-parent-headline section)))
+    ;; Before first headline: no container, just return CONTENTS.
+    (if (not parent) contents
+      ;; Get div's class and id references.
+      (let* ((class-num (+ (org-export-get-relative-level parent info)
+                          (1- org-html-toplevel-hlevel)))
+            (section-number
+             (mapconcat
+              'number-to-string
+              (org-export-get-headline-number parent info) "-")))
+        ;; Build return value.
+       (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
+               class-num
+               (or (org-element-property :CUSTOM_ID parent) section-number)
+               contents)))))
+
+;;;; Radio Target
+
+(defun org-html-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object from Org to HTML.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  (let ((id (org-export-solidify-link-text
+            (org-element-property :value radio-target))))
+    (org-html--anchor id text)))
+
+;;;; Special Block
+
+(defun org-html-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let* ((block-type (downcase
+                     (org-element-property :type special-block)))
+        (contents (or contents ""))
+        (html5-fancy (and (org-html-html5-p info)
+                          (plist-get info :html-html5-fancy)
+                          (member block-type org-html-html5-elements)))
+        (attributes (org-export-read-attribute :attr_html special-block)))
+    (unless html5-fancy
+      (let ((class (plist-get attributes :class)))
+       (setq attributes (plist-put attributes :class
+                                   (if class (concat class " " block-type)
+                                     block-type)))))
+    (setq attributes (org-html--make-attribute-string attributes))
+    (when (not (equal attributes ""))
+      (setq attributes (concat " " attributes)))
+    (if html5-fancy
+       (format "<%s%s>\n%s</%s>" block-type attributes
+               contents block-type)
+      (format "<div%s>\n%s\n</div>" attributes contents))))
+
+;;;; Src Block
+
+(defun org-html-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (if (org-export-read-attribute :attr_html src-block :textarea)
+      (org-html--textarea-block src-block)
+    (let ((lang (org-element-property :language src-block))
+         (caption (org-export-get-caption src-block))
+         (code (org-html-format-code src-block info))
+         (label (let ((lbl (org-element-property :name src-block)))
+                  (if (not lbl) ""
+                    (format " id=\"%s\""
+                            (org-export-solidify-link-text lbl))))))
+      (if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
+       (format
+        "<div class=\"org-src-container\">\n%s%s\n</div>"
+        (if (not caption) ""
+          (format "<label class=\"org-src-name\">%s</label>"
+                  (org-export-data caption info)))
+        (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
+
+;;;; Statistics Cookie
+
+(defun org-html-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((cookie-value (org-element-property :value statistics-cookie)))
+    (format "<code>%s</code>" cookie-value)))
+
+;;;; Strike-Through
+
+(defun org-html-strike-through (strike-through contents info)
+  "Transcode STRIKE-THROUGH from Org to HTML.
+CONTENTS is the text with strike-through markup.  INFO is a plist
+holding contextual information."
+  (format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
+         contents))
+
+;;;; Subscript
+
+(defun org-html-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to HTML.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "<sub>%s</sub>" contents))
+
+;;;; Superscript
+
+(defun org-html-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to HTML.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "<sup>%s</sup>" contents))
+
+;;;; Table Cell
+
+(defun org-html-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL element from Org to HTML.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let* ((table-row (org-export-get-parent table-cell))
+        (table (org-export-get-parent-table table-cell))
+        (cell-attrs
+         (if (not org-html-table-align-individual-fields) ""
+           (format (if (and (boundp 'org-html-format-table-no-css)
+                            org-html-format-table-no-css)
+                       " align=\"%s\"" " class=\"%s\"")
+                   (org-export-table-cell-alignment table-cell info)))))
+    (when (or (not contents) (string= "" (org-trim contents)))
+      (setq contents "&#xa0;"))
+    (cond
+     ((and (org-export-table-has-header-p table info)
+          (= 1 (org-export-table-row-group table-row info)))
+      (concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
+             contents (cdr org-html-table-header-tags)))
+     ((and org-html-table-use-header-tags-for-first-column
+          (zerop (cdr (org-export-table-cell-address table-cell info))))
+      (concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
+             contents (cdr org-html-table-header-tags)))
+     (t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
+               contents (cdr org-html-table-data-tags))))))
+
+;;;; Table Row
+
+(defun org-html-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to HTML.
+CONTENTS is the contents of the row.  INFO is a plist used as a
+communication channel."
+  ;; Rules are ignored since table separators are deduced from
+  ;; borders of the current row.
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let* ((rowgroup-number (org-export-table-row-group table-row info))
+          (row-number (org-export-table-row-number table-row info))
+          (start-rowgroup-p
+           (org-export-table-row-starts-rowgroup-p table-row info))
+          (end-rowgroup-p
+           (org-export-table-row-ends-rowgroup-p table-row info))
+          ;; `top-row-p' and `end-rowgroup-p' are not used directly
+          ;; but should be set so that `org-html-table-row-tags' can
+          ;; use them (see the docstring of this variable.)
+          (top-row-p (and (equal start-rowgroup-p '(top))
+                          (equal end-rowgroup-p '(below top))))
+          (bottom-row-p (and (equal start-rowgroup-p '(above))
+                             (equal end-rowgroup-p '(bottom above))))
+          (rowgroup-tags
+           (cond
+            ;; Case 1: Row belongs to second or subsequent rowgroups.
+            ((not (= 1 rowgroup-number))
+             '("<tbody>" . "\n</tbody>"))
+            ;; Case 2: Row is from first rowgroup.  Table has >=1 rowgroups.
+            ((org-export-table-has-header-p
+              (org-export-get-parent-table table-row) info)
+             '("<thead>" . "\n</thead>"))
+            ;; Case 2: Row is from first and only row group.
+            (t '("<tbody>" . "\n</tbody>")))))
+      (concat
+       ;; Begin a rowgroup?
+       (when start-rowgroup-p (car rowgroup-tags))
+       ;; Actual table row
+       (concat "\n" (eval (car org-html-table-row-tags))
+              contents
+              "\n"
+              (eval (cdr org-html-table-row-tags)))
+       ;; End a rowgroup?
+       (when end-rowgroup-p (cdr rowgroup-tags))))))
+
+;;;; Table
+
+(defun org-html-table-first-row-data-cells (table info)
+  "Transcode the first row of TABLE.
+INFO is a plist used as a communication channel."
+  (let ((table-row
+        (org-element-map table 'table-row
+          (lambda (row)
+            (unless (eq (org-element-property :type row) 'rule) row))
+          info 'first-match))
+       (special-column-p (org-export-table-has-special-column-p table)))
+    (if (not special-column-p) (org-element-contents table-row)
+      (cdr (org-element-contents table-row)))))
+
+(defun org-html-table--table.el-table (table info)
+  "Format table.el tables into HTML.
+INFO is a plist used as a communication channel."
+  (when (eq (org-element-property :type table) 'table.el)
+    (require 'table)
+    (let ((outbuf (with-current-buffer
+                     (get-buffer-create "*org-export-table*")
+                   (erase-buffer) (current-buffer))))
+      (with-temp-buffer
+       (insert (org-element-property :value table))
+       (goto-char 1)
+       (re-search-forward "^[ \t]*|[^|]" nil t)
+       (table-generate-source 'html outbuf))
+      (with-current-buffer outbuf
+       (prog1 (org-trim (buffer-string))
+         (kill-buffer) )))))
+
+(defun org-html-table (table contents info)
+  "Transcode a TABLE element from Org to HTML.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (case (org-element-property :type table)
+    ;; Case 1: table.el table.  Convert it using appropriate tools.
+    (table.el (org-html-table--table.el-table table info))
+    ;; Case 2: Standard table.
+    (t
+     (let* ((label (org-element-property :name table))
+           (caption (org-export-get-caption table))
+           (number (org-export-get-ordinal
+                    table info nil 'org-html--has-caption-p))
+           (attributes
+            (org-html--make-attribute-string
+             (org-combine-plists
+              (and label (list :id (org-export-solidify-link-text label)))
+              (and (not (org-html-html5-p info))
+                   (plist-get info :html-table-attributes))
+              (org-export-read-attribute :attr_html table))))
+           (alignspec
+            (if (and (boundp 'org-html-format-table-no-css)
+                     org-html-format-table-no-css)
+                "align=\"%s\"" "class=\"%s\""))
+           (table-column-specs
+            (function
+             (lambda (table info)
+               (mapconcat
+                (lambda (table-cell)
+                  (let ((alignment (org-export-table-cell-alignment
+                                    table-cell info)))
+                    (concat
+                     ;; Begin a colgroup?
+                     (when (org-export-table-cell-starts-colgroup-p
+                            table-cell info)
+                       "\n<colgroup>")
+                     ;; Add a column.  Also specify it's alignment.
+                     (format "\n%s"
+                             (org-html-close-tag
+                              "col" (concat " " (format alignspec alignment)) info))
+                     ;; End a colgroup?
+                     (when (org-export-table-cell-ends-colgroup-p
+                            table-cell info)
+                       "\n</colgroup>"))))
+                (org-html-table-first-row-data-cells table info) "\n")))))
+       (format "<table%s>\n%s\n%s\n%s</table>"
+              (if (equal attributes "") "" (concat " " attributes))
+              (if (not caption) ""
+                (format (if org-html-table-caption-above
+                            "<caption align=\"above\">%s</caption>"
+                          "<caption align=\"bottom\">%s</caption>")
+                        (concat
+                         "<span class=\"table-number\">"
+                          (format (org-html--translate "Table %d:" info) number)
+                         "</span> " (org-export-data caption info))))
+              (funcall table-column-specs table info)
+              contents)))))
+
+;;;; Target
+
+(defun org-html-target (target contents info)
+  "Transcode a TARGET object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((id (org-export-solidify-link-text
+            (org-element-property :value target))))
+    (org-html--anchor id)))
+
+;;;; Timestamp
+
+(defun org-html-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((value (org-html-plain-text
+               (org-timestamp-translate timestamp) info)))
+    (format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>"
+           (replace-regexp-in-string "--" "&#x2013;" value))))
+
+;;;; Underline
+
+(defun org-html-underline (underline contents info)
+  "Transcode UNDERLINE from Org to HTML.
+CONTENTS is the text with underline markup.  INFO is a plist
+holding contextual information."
+  (format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
+         contents))
+
+;;;; Verbatim
+
+(defun org-html-verbatim (verbatim contents info)
+  "Transcode VERBATIM from Org to HTML.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
+         (org-html-encode-plain-text (org-element-property :value verbatim))))
+
+;;;; Verse Block
+
+(defun org-html-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to HTML.
+CONTENTS is verse block contents.  INFO is a plist holding
+contextual information."
+  ;; Replace each newline character with line break.  Also replace
+  ;; each blank line with a line break.
+  (setq contents (replace-regexp-in-string
+                 "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info))
+                 (replace-regexp-in-string
+                  "\\(\\\\\\\\\\)?[ \t]*\n"
+                  (format "%s\n" (org-html-close-tag "br" nil info)) contents)))
+  ;; Replace each white space at beginning of a line with a
+  ;; non-breaking space.
+  (while (string-match "^[ \t]+" contents)
+    (let* ((num-ws (length (match-string 0 contents)))
+          (ws (let (out) (dotimes (i num-ws out)
+                           (setq out (concat out "&#xa0;"))))))
+      (setq contents (replace-match ws nil t contents))))
+  (format "<p class=\"verse\">\n%s</p>" contents))
+
+\f
+;;; Filter Functions
+
+(defun org-html-final-function (contents backend info)
+  "Filter to indent the HTML and convert HTML entities."
+  (with-temp-buffer
+    (insert contents)
+    (set-auto-mode t)
+    (if org-html-indent
+       (indent-region (point-min) (point-max)))
+    (when org-html-use-unicode-chars
+      (require 'mm-url)
+      (mm-url-decode-entities))
+    (buffer-substring-no-properties (point-min) (point-max))))
+
+\f
+;;; End-user functions
+
+;;;###autoload
+(defun org-html-export-as-html
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to an HTML buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"<body>\" and \"</body>\" tags.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Export is done in a buffer named \"*Org HTML Export*\", which
+will be displayed when `org-export-show-temporary-export-buffer'
+is non-nil."
+  (interactive)
+  (org-export-to-buffer 'html "*Org HTML Export*"
+    async subtreep visible-only body-only ext-plist
+    (lambda () (set-auto-mode t))))
+
+;;;###autoload
+(defun org-html-convert-region-to-html ()
+  "Assume the current region has org-mode syntax, and convert it to HTML.
+This can be used in any buffer.  For example, you can write an
+itemized list in org-mode syntax in an HTML buffer and use this
+command to convert it."
+  (interactive)
+  (org-export-replace-region-by 'html))
+
+;;;###autoload
+(defun org-html-export-to-html
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a HTML file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"<body>\" and \"</body>\" tags.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let* ((extension (concat "." org-html-extension))
+        (file (org-export-output-file-name extension subtreep))
+        (org-export-coding-system org-html-coding-system))
+    (org-export-to-file 'html file
+      async subtreep visible-only body-only ext-plist)))
+
+;;;###autoload
+(defun org-html-publish-to-html (plist filename pub-dir)
+  "Publish an org file to HTML.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to 'html filename
+                     (concat "." (or (plist-get plist :html-extension)
+                                     org-html-extension "html"))
+                     plist pub-dir))
+
+\f
+;;; FIXME
+
+;;;; org-format-table-html
+;;;; org-format-org-table-html
+;;;; org-format-table-table-html
+;;;; org-table-number-fraction
+;;;; org-table-number-regexp
+;;;; org-html-inline-image-extensions
+;;;; org-export-preferred-target-alist
+;;;; class for anchors
+;;;; org-export-mark-todo-in-toc
+;;;; org-html-format-org-link
+;;;; (caption (and caption (org-xml-encode-org-text caption)))
+;;;; alt = (file-name-nondirectory path)
+
+(provide 'ox-html)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-html.el ends here
diff --git a/lisp/org/ox-icalendar.el b/lisp/org/ox-icalendar.el
new file mode 100644 (file)
index 0000000..7c4b4bf
--- /dev/null
@@ -0,0 +1,981 @@
+;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine
+
+;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
+
+;; Author: Carsten Dominik <carsten at orgmode dot org>
+;;      Nicolas Goaziou <n dot goaziou at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements an iCalendar back-end for Org generic
+;; exporter.  See Org manual for more information.
+;;
+;; It is expected to conform to RFC 5545.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox-ascii)
+(declare-function org-bbdb-anniv-export-ical "org-bbdb" nil)
+
+
+\f
+;;; User-Configurable Variables
+
+(defgroup org-export-icalendar nil
+  "Options specific for iCalendar export back-end."
+  :tag "Org Export iCalendar"
+  :group 'org-export)
+
+(defcustom org-icalendar-combined-agenda-file "~/org.ics"
+  "The file name for the iCalendar file covering all agenda files.
+This file is created with the command \\[org-icalendar-combine-agenda-files].
+The file name should be absolute.  It will be overwritten without warning."
+  :group 'org-export-icalendar
+  :type 'file)
+
+(defcustom org-icalendar-alarm-time 0
+  "Number of minutes for triggering an alarm for exported timed events.
+
+A zero value (the default) turns off the definition of an alarm trigger
+for timed events.  If non-zero, alarms are created.
+
+- a single alarm per entry is defined
+- The alarm will go off N minutes before the event
+- only a DISPLAY action is defined."
+  :group 'org-export-icalendar
+  :version "24.1"
+  :type 'integer)
+
+(defcustom org-icalendar-combined-name "OrgMode"
+  "Calendar name for the combined iCalendar representing all agenda files."
+  :group 'org-export-icalendar
+  :type 'string)
+
+(defcustom org-icalendar-combined-description ""
+  "Calendar description for the combined iCalendar (all agenda files)."
+  :group 'org-export-icalendar
+  :type 'string)
+
+(defcustom org-icalendar-exclude-tags nil
+  "Tags that exclude a tree from export.
+This variable allows to specify different exclude tags from other
+back-ends.  It can also be set with the ICAL_EXCLUDE_TAGS
+keyword."
+  :group 'org-export-icalendar
+  :type '(repeat (string :tag "Tag")))
+
+(defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
+  "Contexts where iCalendar export should use a deadline time stamp.
+
+This is a list with several symbols in it.  Valid symbol are:
+`event-if-todo'       Deadlines in TODO entries become calendar events.
+`event-if-not-todo'   Deadlines in non-TODO entries become calendar events.
+`todo-due'            Use deadlines in TODO entries as due-dates"
+  :group 'org-export-icalendar
+  :type '(set :greedy t
+             (const :tag "Deadlines in non-TODO entries become events"
+                    event-if-not-todo)
+             (const :tag "Deadline in TODO entries become events"
+                    event-if-todo)
+             (const :tag "Deadlines in TODO entries become due-dates"
+                    todo-due)))
+
+(defcustom org-icalendar-use-scheduled '(todo-start)
+  "Contexts where iCalendar export should use a scheduling time stamp.
+
+This is a list with several symbols in it.  Valid symbol are:
+`event-if-todo'       Scheduling time stamps in TODO entries become an event.
+`event-if-not-todo'   Scheduling time stamps in non-TODO entries become an event.
+`todo-start'          Scheduling time stamps in TODO entries become start date.
+                      Some calendar applications show TODO entries only after
+                      that date."
+  :group 'org-export-icalendar
+  :type '(set :greedy t
+             (const :tag
+                    "SCHEDULED timestamps in non-TODO entries become events"
+                    event-if-not-todo)
+             (const :tag "SCHEDULED timestamps in TODO entries become events"
+                    event-if-todo)
+             (const :tag "SCHEDULED in TODO entries become start date"
+                    todo-start)))
+
+(defcustom org-icalendar-categories '(local-tags category)
+  "Items that should be entered into the \"categories\" field.
+
+This is a list of symbols, the following are valid:
+`category'    The Org mode category of the current file or tree
+`todo-state'  The todo state, if any
+`local-tags'  The tags, defined in the current line
+`all-tags'    All tags, including inherited ones."
+  :group 'org-export-icalendar
+  :type '(repeat
+         (choice
+          (const :tag "The file or tree category" category)
+          (const :tag "The TODO state" todo-state)
+          (const :tag "Tags defined in current line" local-tags)
+          (const :tag "All tags, including inherited ones" all-tags))))
+
+(defcustom org-icalendar-with-timestamps 'active
+  "Non-nil means make an event from plain time stamps.
+
+It can be set to `active', `inactive', t or nil, in order to make
+an event from, respectively, only active timestamps, only
+inactive ones, all of them or none.
+
+This variable has precedence over `org-export-with-timestamps'.
+It can also be set with the #+OPTIONS line, e.g. \"<:t\"."
+  :group 'org-export-icalendar
+  :type '(choice
+         (const :tag "All timestamps" t)
+         (const :tag "Only active timestamps" active)
+         (const :tag "Only inactive timestamps" inactive)
+         (const :tag "No timestamp" nil)))
+
+(defcustom org-icalendar-include-todo nil
+  "Non-nil means create VTODO components from TODO items.
+
+Valid values are:
+nil                  don't include any task.
+t                    include tasks that are not in DONE state.
+`unblocked'          include all TODO items that are not blocked.
+`all'                include both done and not done items."
+  :group 'org-export-icalendar
+  :type '(choice
+         (const :tag "None" nil)
+         (const :tag "Unfinished" t)
+         (const :tag "Unblocked" unblocked)
+         (const :tag "All" all)
+         (repeat :tag "Specific TODO keywords"
+                 (string :tag "Keyword"))))
+
+(defcustom org-icalendar-include-bbdb-anniversaries nil
+  "Non-nil means a combined iCalendar file should include anniversaries.
+The anniversaries are defined in the BBDB database."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
+(defcustom org-icalendar-include-sexps t
+  "Non-nil means export to iCalendar files should also cover sexp entries.
+These are entries like in the diary, but directly in an Org mode
+file."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
+(defcustom org-icalendar-include-body t
+  "Amount of text below headline to be included in iCalendar export.
+This is a number of characters that should maximally be included.
+Properties, scheduling and clocking lines will always be removed.
+The text will be inserted into the DESCRIPTION field."
+  :group 'org-export-icalendar
+  :type '(choice
+         (const :tag "Nothing" nil)
+         (const :tag "Everything" t)
+         (integer :tag "Max characters")))
+
+(defcustom org-icalendar-store-UID nil
+  "Non-nil means store any created UIDs in properties.
+
+The iCalendar standard requires that all entries have a unique identifier.
+Org will create these identifiers as needed.  When this variable is non-nil,
+the created UIDs will be stored in the ID property of the entry.  Then the
+next time this entry is exported, it will be exported with the same UID,
+superseding the previous form of it.  This is essential for
+synchronization services.
+
+This variable is not turned on by default because we want to avoid creating
+a property drawer in every entry if people are only playing with this feature,
+or if they are only using it locally."
+  :group 'org-export-icalendar
+  :type 'boolean)
+
+(defcustom org-icalendar-timezone (getenv "TZ")
+  "The time zone string for iCalendar export.
+When nil or the empty string, use output
+from (current-time-zone)."
+  :group 'org-export-icalendar
+  :type '(choice
+         (const :tag "Unspecified" nil)
+         (string :tag "Time zone")))
+
+(defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S"
+  "Format-string for exporting icalendar DATE-TIME.
+
+See `format-time-string' for a full documentation.  The only
+difference is that `org-icalendar-timezone' is used for %Z.
+
+Interesting value are:
+ - \":%Y%m%dT%H%M%S\" for local time
+ - \";TZID=%Z:%Y%m%dT%H%M%S\" for local time with explicit timezone
+ - \":%Y%m%dT%H%M%SZ\" for time expressed in Universal Time"
+  :group 'org-export-icalendar
+  :version "24.1"
+  :type '(choice
+         (const :tag "Local time" ":%Y%m%dT%H%M%S")
+         (const :tag "Explicit local time" ";TZID=%Z:%Y%m%dT%H%M%S")
+         (const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
+         (string :tag "Explicit format")))
+
+(defvar org-icalendar-after-save-hook nil
+  "Hook run after an iCalendar file has been saved.
+This hook is run with the name of the file as argument.  A good
+way to use this is to tell a desktop calendar application to
+re-read the iCalendar file.")
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-derived-backend 'icalendar 'ascii
+  :translate-alist '((clock . ignore)
+                    (footnote-definition . ignore)
+                    (footnote-reference . ignore)
+                    (headline . org-icalendar-entry)
+                    (inlinetask . ignore)
+                    (planning . ignore)
+                    (section . ignore)
+                    (inner-template . (lambda (c i) c))
+                    (template . org-icalendar-template))
+  :options-alist
+  '((:exclude-tags
+     "ICALENDAR_EXCLUDE_TAGS" nil org-icalendar-exclude-tags split)
+    (:with-timestamps nil "<" org-icalendar-with-timestamps)
+    (:with-vtodo nil nil org-icalendar-include-todo)
+    ;; The following property will be non-nil when export has been
+    ;; started from org-agenda-mode.  In this case, any entry without
+    ;; a non-nil "ICALENDAR_MARK" property will be ignored.
+    (:icalendar-agenda-view nil nil nil))
+  :filters-alist
+  '((:filter-headline . org-icalendar-clear-blank-lines))
+  :menu-entry
+  '(?c "Export to iCalendar"
+       ((?f "Current file" org-icalendar-export-to-ics)
+       (?a "All agenda files"
+           (lambda (a s v b) (org-icalendar-export-agenda-files a)))
+       (?c "Combine all agenda files"
+           (lambda (a s v b) (org-icalendar-combine-agenda-files a))))))
+
+
+\f
+;;; Internal Functions
+
+(defun org-icalendar-create-uid (file &optional bell h-markers)
+  "Set ID property on headlines missing it in FILE.
+When optional argument BELL is non-nil, inform the user with
+a message if the file was modified.  With optional argument
+H-MARKERS non-nil, it is a list of markers for the headlines
+which will be updated."
+  (let ((pt (if h-markers (goto-char (car h-markers)) (point-min)))
+       modified-flag)
+    (org-map-entries
+     (lambda ()
+       (let ((entry (org-element-at-point)))
+        (unless (or (< (point) pt) (org-element-property :ID entry))
+          (org-id-get-create)
+          (setq modified-flag t)
+          (forward-line))
+        (when h-markers (setq org-map-continue-from (pop h-markers)))))
+     nil nil 'comment)
+    (when (and bell modified-flag)
+      (message "ID properties created in file \"%s\"" file)
+      (sit-for 2))))
+
+(defun org-icalendar-blocked-headline-p (headline info)
+  "Non-nil when HEADLINE is considered to be blocked.
+
+INFO is a plist used as a communication channel.
+
+a headline is blocked when either:
+
+  - It has children which are not all in a completed state.
+
+  - It has a parent with the property :ORDERED:, and there are
+    siblings prior to it with incomplete status.
+
+  - Its parent is blocked because it has siblings that should be
+    done first or is a child of a blocked grandparent entry."
+  (or
+   ;; Check if any child is not done.
+   (org-element-map headline 'headline
+     (lambda (hl) (eq (org-element-property :todo-type hl) 'todo))
+     info 'first-match)
+   ;; Check :ORDERED: node property.
+   (catch 'blockedp
+     (let ((current headline))
+       (mapc (lambda (parent)
+              (cond
+               ((not (org-element-property :todo-keyword parent))
+                (throw 'blockedp nil))
+               ((org-not-nil (org-element-property :ORDERED parent))
+                (let ((sibling current))
+                  (while (setq sibling (org-export-get-previous-element
+                                        sibling info))
+                    (when (eq (org-element-property :todo-type sibling) 'todo)
+                      (throw 'blockedp t)))))
+               (t (setq current parent))))
+            (org-export-get-genealogy headline))
+       nil))))
+
+(defun org-icalendar-use-UTC-date-time-p ()
+  "Non-nil when `org-icalendar-date-time-format' requires UTC time."
+  (char-equal (elt org-icalendar-date-time-format
+                  (1- (length org-icalendar-date-time-format))) ?Z))
+
+(defvar org-agenda-default-appointment-duration) ; From org-agenda.el.
+(defun org-icalendar-convert-timestamp (timestamp keyword &optional end utc)
+  "Convert TIMESTAMP to iCalendar format.
+
+TIMESTAMP is a timestamp object.  KEYWORD is added in front of
+it, in order to make a complete line (e.g. \"DTSTART\").
+
+When optional argument END is non-nil, use end of time range.
+Also increase the hour by two (if time string contains a time),
+or the day by one (if it does not contain a time) when no
+explicit ending time is specified.
+
+When optional argument UTC is non-nil, time will be expressed in
+Universal Time, ignoring `org-icalendar-date-time-format'."
+  (let* ((year-start (org-element-property :year-start timestamp))
+        (year-end (org-element-property :year-end timestamp))
+        (month-start (org-element-property :month-start timestamp))
+        (month-end (org-element-property :month-end timestamp))
+        (day-start (org-element-property :day-start timestamp))
+        (day-end (org-element-property :day-end timestamp))
+        (hour-start (org-element-property :hour-start timestamp))
+        (hour-end (org-element-property :hour-end timestamp))
+        (minute-start (org-element-property :minute-start timestamp))
+        (minute-end (org-element-property :minute-end timestamp))
+        (with-time-p minute-start)
+        (equal-bounds-p
+         (equal (list year-start month-start day-start hour-start minute-start)
+                (list year-end month-end day-end hour-end minute-end)))
+        (mi (cond ((not with-time-p) 0)
+                  ((not end) minute-start)
+                  ((and org-agenda-default-appointment-duration equal-bounds-p)
+                   (+ minute-end org-agenda-default-appointment-duration))
+                  (t minute-end)))
+        (h (cond ((not with-time-p) 0)
+                 ((not end) hour-start)
+                 ((or (not equal-bounds-p)
+                      org-agenda-default-appointment-duration)
+                  hour-end)
+                 (t (+ hour-end 2))))
+        (d (cond ((not end) day-start)
+                 ((not with-time-p) (1+ day-end))
+                 (t day-end)))
+        (m (if end month-end month-start))
+        (y (if end year-end year-start)))
+    (concat
+     keyword
+     (format-time-string
+      (cond (utc ":%Y%m%dT%H%M%SZ")
+           ((not with-time-p) ";VALUE=DATE:%Y%m%d")
+           (t (replace-regexp-in-string "%Z"
+                                        org-icalendar-timezone
+                                        org-icalendar-date-time-format
+                                        t)))
+      ;; Convert timestamp into internal time in order to use
+      ;; `format-time-string' and fix any mistake (i.e. MI >= 60).
+      (encode-time 0 mi h d m y)
+      (or utc (and with-time-p (org-icalendar-use-UTC-date-time-p)))))))
+
+(defun org-icalendar-dtstamp ()
+  "Return DTSTAMP property, as a string."
+  (format-time-string "DTSTAMP:%Y%m%dT%H%M%SZ" nil t))
+
+(defun org-icalendar-get-categories (entry info)
+  "Return categories according to `org-icalendar-categories'.
+ENTRY is a headline or an inlinetask element.  INFO is a plist
+used as a communication channel."
+  (mapconcat
+   'identity
+   (org-uniquify
+    (let (categories)
+      (mapc (lambda (type)
+             (case type
+               (category
+                (push (org-export-get-category entry info) categories))
+               (todo-state
+                (let ((todo (org-element-property :todo-keyword entry)))
+                  (and todo (push todo categories))))
+               (local-tags
+                (setq categories
+                      (append (nreverse (org-export-get-tags entry info))
+                              categories)))
+               (all-tags
+                (setq categories
+                      (append (nreverse (org-export-get-tags entry info nil t))
+                              categories)))))
+           org-icalendar-categories)
+      ;; Return list of categories, following specified order.
+      (nreverse categories))) ","))
+
+(defun org-icalendar-transcode-diary-sexp (sexp uid summary)
+  "Transcode a diary sexp into iCalendar format.
+SEXP is the diary sexp being transcoded, as a string.  UID is the
+unique identifier for the entry.  SUMMARY defines a short summary
+or subject for the event."
+  (when (require 'icalendar nil t)
+    (org-element-normalize-string
+     (with-temp-buffer
+       (let ((sexp (if (not (string-match "\\`<%%" sexp)) sexp
+                    (concat (substring sexp 1 -1) " " summary))))
+        (put-text-property 0 1 'uid uid sexp)
+        (insert sexp "\n"))
+       (org-diary-to-ical-string (current-buffer))))))
+
+(defun org-icalendar-cleanup-string (s)
+  "Cleanup string S according to RFC 5545."
+  (when s
+    ;; Protect "\", "," and ";" characters. and replace newline
+    ;; characters with literal \n.
+    (replace-regexp-in-string
+     "[ \t]*\n" "\\n"
+     (replace-regexp-in-string "[\\,;]" "\\\&" s)
+     nil t)))
+
+(defun org-icalendar-fold-string (s)
+  "Fold string S according to RFC 5545."
+  (org-element-normalize-string
+   (mapconcat
+    (lambda (line)
+      ;; Limit each line to a maximum of 75 characters.  If it is
+      ;; longer, fold it by using "\n " as a continuation marker.
+      (let ((len (length line)))
+       (if (<= len 75) line
+         (let ((folded-line (substring line 0 75))
+               (chunk-start 75)
+               chunk-end)
+           ;; Since continuation marker takes up one character on the
+           ;; line, real contents must be split at 74 chars.
+           (while (< (setq chunk-end (+ chunk-start 74)) len)
+             (setq folded-line
+                   (concat folded-line "\n "
+                           (substring line chunk-start chunk-end))
+                   chunk-start chunk-end))
+           (concat folded-line "\n " (substring line chunk-start))))))
+    (org-split-string s "\n") "\n")))
+
+
+\f
+;;; Filters
+
+(defun org-icalendar-clear-blank-lines (headline back-end info)
+  "Remove trailing blank lines in HEADLINE export.
+HEADLINE is a string representing a transcoded headline.
+BACK-END and INFO are ignored."
+  (replace-regexp-in-string "^\\(?:[ \t]*\n\\)*" "" headline))
+
+
+\f
+;;; Transcode Functions
+
+;;;; Headline and Inlinetasks
+
+;; The main function is `org-icalendar-entry', which extracts
+;; information from a headline or an inlinetask (summary,
+;; description...) and then delegates code generation to
+;; `org-icalendar--vtodo' and `org-icalendar--vevent', depending
+;; on the component needed.
+
+;; Obviously, `org-icalendar--valarm' handles alarms, which can
+;; happen within a VTODO component.
+
+(defun org-icalendar-entry (entry contents info)
+  "Transcode ENTRY element into iCalendar format.
+
+ENTRY is either a headline or an inlinetask.  CONTENTS is
+ignored.  INFO is a plist used as a communication channel.
+
+This function is called on every headline, the section below
+it (minus inlinetasks) being its contents.  It tries to create
+VEVENT and VTODO components out of scheduled date, deadline date,
+plain timestamps, diary sexps.  It also calls itself on every
+inlinetask within the section."
+  (unless (org-element-property :footnote-section-p entry)
+    (let* ((type (org-element-type entry))
+          ;; Determine contents really associated to the entry.  For
+          ;; a headline, limit them to section, if any.  For an
+          ;; inlinetask, this is every element within the task.
+          (inside
+           (if (eq type 'inlinetask)
+               (cons 'org-data (cons nil (org-element-contents entry)))
+             (let ((first (car (org-element-contents entry))))
+               (and (eq (org-element-type first) 'section)
+                    (cons 'org-data
+                          (cons nil (org-element-contents first))))))))
+      (concat
+       (unless (and (plist-get info :icalendar-agenda-view)
+                   (not (org-element-property :ICALENDAR-MARK entry)))
+        (let ((todo-type (org-element-property :todo-type entry))
+              (uid (or (org-element-property :ID entry) (org-id-new)))
+              (summary (org-icalendar-cleanup-string
+                        (or (org-element-property :SUMMARY entry)
+                            (org-export-data
+                             (org-element-property :title entry) info))))
+              (loc (org-icalendar-cleanup-string
+                    (org-element-property :LOCATION entry)))
+              ;; Build description of the entry from associated
+              ;; section (headline) or contents (inlinetask).
+              (desc
+               (org-icalendar-cleanup-string
+                (or (org-element-property :DESCRIPTION entry)
+                    (let ((contents (org-export-data inside info)))
+                      (cond
+                       ((not (org-string-nw-p contents)) nil)
+                       ((wholenump org-icalendar-include-body)
+                        (let ((contents (org-trim contents)))
+                          (substring
+                           contents 0 (min (length contents)
+                                           org-icalendar-include-body))))
+                       (org-icalendar-include-body (org-trim contents)))))))
+              (cat (org-icalendar-get-categories entry info)))
+          (concat
+           ;; Events: Delegate to `org-icalendar--vevent' to
+           ;; generate "VEVENT" component from scheduled, deadline,
+           ;; or any timestamp in the entry.
+           (let ((deadline (org-element-property :deadline entry)))
+             (and deadline
+                  (memq (if todo-type 'event-if-todo 'event-if-not-todo)
+                        org-icalendar-use-deadline)
+                  (org-icalendar--vevent
+                   entry deadline (concat "DL-" uid)
+                   (concat "DL: " summary) loc desc cat)))
+           (let ((scheduled (org-element-property :scheduled entry)))
+             (and scheduled
+                  (memq (if todo-type 'event-if-todo 'event-if-not-todo)
+                        org-icalendar-use-scheduled)
+                  (org-icalendar--vevent
+                   entry scheduled (concat "SC-" uid)
+                   (concat "S: " summary) loc desc cat)))
+           ;; When collecting plain timestamps from a headline and
+           ;; its title, skip inlinetasks since collection will
+           ;; happen once ENTRY is one of them.
+           (let ((counter 0))
+             (mapconcat
+              'identity
+              (org-element-map (cons (org-element-property :title entry)
+                                     (org-element-contents inside))
+                  'timestamp
+                (lambda (ts)
+                  (let ((uid (format "TS%d-%s" (incf counter) uid)))
+                    (org-icalendar--vevent entry ts uid summary loc desc cat)))
+                info nil (and (eq type 'headline) 'inlinetask))
+              ""))
+           ;; Task: First check if it is appropriate to export it.
+           ;; If so, call `org-icalendar--vtodo' to transcode it
+           ;; into a "VTODO" component.
+           (when (and todo-type
+                      (case (plist-get info :with-vtodo)
+                        (all t)
+                        (unblocked
+                         (and (eq type 'headline)
+                              (not (org-icalendar-blocked-headline-p
+                                    entry info))))
+                        ('t (eq todo-type 'todo))))
+             (org-icalendar--vtodo entry uid summary loc desc cat))
+           ;; Diary-sexp: Collect every diary-sexp element within
+           ;; ENTRY and its title, and transcode them.  If ENTRY is
+           ;; a headline, skip inlinetasks: they will be handled
+           ;; separately.
+           (when org-icalendar-include-sexps
+             (let ((counter 0))
+               (mapconcat 'identity
+                          (org-element-map
+                              (cons (org-element-property :title entry)
+                                    (org-element-contents inside))
+                              'diary-sexp
+                            (lambda (sexp)
+                              (org-icalendar-transcode-diary-sexp
+                               (org-element-property :value sexp)
+                               (format "DS%d-%s" (incf counter) uid)
+                               summary))
+                            info nil (and (eq type 'headline) 'inlinetask))
+                          ""))))))
+       ;; If ENTRY is a headline, call current function on every
+       ;; inlinetask within it.  In agenda export, this is independent
+       ;; from the mark (or lack thereof) on the entry.
+       (when (eq type 'headline)
+        (mapconcat 'identity
+                   (org-element-map inside 'inlinetask
+                     (lambda (task) (org-icalendar-entry task nil info))
+                     info) ""))
+       ;; Don't forget components from inner entries.
+       contents))))
+
+(defun org-icalendar--vevent
+  (entry timestamp uid summary location description categories)
+  "Create a VEVENT component.
+
+ENTRY is either a headline or an inlinetask element.  TIMESTAMP
+is a timestamp object defining the date-time of the event.  UID
+is the unique identifier for the event.  SUMMARY defines a short
+summary or subject for the event.  LOCATION defines the intended
+venue for the event.  DESCRIPTION provides the complete
+description of the event.  CATEGORIES defines the categories the
+event belongs to.
+
+Return VEVENT component as a string."
+  (org-icalendar-fold-string
+   (if (eq (org-element-property :type timestamp) 'diary)
+       (org-icalendar-transcode-diary-sexp
+       (org-element-property :raw-value timestamp) uid summary)
+     (concat "BEGIN:VEVENT\n"
+            (org-icalendar-dtstamp) "\n"
+            "UID:" uid "\n"
+            (org-icalendar-convert-timestamp timestamp "DTSTART") "\n"
+            (org-icalendar-convert-timestamp timestamp "DTEND" t) "\n"
+            ;; RRULE.
+            (when (org-element-property :repeater-type timestamp)
+              (format "RRULE:FREQ=%s;INTERVAL=%d\n"
+                      (case (org-element-property :repeater-unit timestamp)
+                        (hour "HOURLY") (day "DAILY") (week "WEEKLY")
+                        (month "MONTHLY") (year "YEARLY"))
+                      (org-element-property :repeater-value timestamp)))
+            "SUMMARY:" summary "\n"
+            (and (org-string-nw-p location) (format "LOCATION:%s\n" location))
+            (and (org-string-nw-p description)
+                 (format "DESCRIPTION:%s\n" description))
+            "CATEGORIES:" categories "\n"
+            ;; VALARM.
+            (org-icalendar--valarm entry timestamp summary)
+            "END:VEVENT"))))
+
+(defun org-icalendar--vtodo
+  (entry uid summary location description categories)
+  "Create a VTODO component.
+
+ENTRY is either a headline or an inlinetask element.  UID is the
+unique identifier for the task.  SUMMARY defines a short summary
+or subject for the task.  LOCATION defines the intended venue for
+the task.  DESCRIPTION provides the complete description of the
+task.  CATEGORIES defines the categories the task belongs to.
+
+Return VTODO component as a string."
+  (let ((start (or (and (memq 'todo-start org-icalendar-use-scheduled)
+                       (org-element-property :scheduled entry))
+                  ;; If we can't use a scheduled time for some
+                  ;; reason, start task now.
+                  (let ((now (decode-time (current-time))))
+                    (list 'timestamp
+                          (list :type 'active
+                                :minute-start (nth 1 now)
+                                :hour-start (nth 2 now)
+                                :day-start (nth 3 now)
+                                :month-start (nth 4 now)
+                                :year-start (nth 5 now)))))))
+    (org-icalendar-fold-string
+     (concat "BEGIN:VTODO\n"
+            "UID:TODO-" uid "\n"
+            (org-icalendar-dtstamp) "\n"
+            (org-icalendar-convert-timestamp start "DTSTART") "\n"
+            (and (memq 'todo-due org-icalendar-use-deadline)
+                 (org-element-property :deadline entry)
+                 (concat (org-icalendar-convert-timestamp
+                          (org-element-property :deadline entry) "DUE")
+                         "\n"))
+            "SUMMARY:" summary "\n"
+            (and (org-string-nw-p location) (format "LOCATION:%s\n" location))
+            (and (org-string-nw-p description)
+                 (format "DESCRIPTION:%s\n" description))
+            "CATEGORIES:" categories "\n"
+            "SEQUENCE:1\n"
+            (format "PRIORITY:%d\n"
+                    (let ((pri (or (org-element-property :priority entry)
+                                   org-default-priority)))
+                      (floor (- 9 (* 8. (/ (float (- org-lowest-priority pri))
+                                           (- org-lowest-priority
+                                              org-highest-priority)))))))
+            (format "STATUS:%s\n"
+                    (if (eq (org-element-property :todo-type entry) 'todo)
+                        "NEEDS-ACTION"
+                      "COMPLETED"))
+            "END:VTODO"))))
+
+(defun org-icalendar--valarm (entry timestamp summary)
+  "Create a VALARM component.
+
+ENTRY is the calendar entry triggering the alarm.  TIMESTAMP is
+the start date-time of the entry.  SUMMARY defines a short
+summary or subject for the task.
+
+Return VALARM component as a string, or nil if it isn't allowed."
+  ;; Create a VALARM entry if the entry is timed.  This is not very
+  ;; general in that:
+  ;; (a) only one alarm per entry is defined,
+  ;; (b) only minutes are allowed for the trigger period ahead of the
+  ;;     start time,
+  ;; (c) only a DISPLAY action is defined.                       [ESF]
+  (let ((alarm-time
+        (let ((warntime
+               (org-element-property :APPT_WARNTIME entry)))
+          (if warntime (string-to-number warntime) 0))))
+    (and (or (> alarm-time 0) (> org-icalendar-alarm-time 0))
+        (org-element-property :hour-start timestamp)
+        (format "BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:%s
+TRIGGER:-P0DT0H%dM0S
+END:VALARM\n"
+                summary
+                (if (zerop alarm-time) org-icalendar-alarm-time alarm-time)))))
+
+
+;;;; Template
+
+(defun org-icalendar-template (contents info)
+  "Return complete document string after iCalendar conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist used
+as a communication channel."
+  (org-icalendar--vcalendar
+   ;; Name.
+   (if (not (plist-get info :input-file)) (buffer-name (buffer-base-buffer))
+     (file-name-nondirectory
+      (file-name-sans-extension (plist-get info :input-file))))
+   ;; Owner.
+   (if (not (plist-get info :with-author)) ""
+     (org-export-data (plist-get info :author) info))
+   ;; Timezone.
+   (if (org-string-nw-p org-icalendar-timezone) org-icalendar-timezone
+     (cadr (current-time-zone)))
+   ;; Description.
+   (org-export-data (plist-get info :title) info)
+   contents))
+
+(defun org-icalendar--vcalendar (name owner tz description contents)
+  "Create a VCALENDAR component.
+NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
+respectively, the name of the calendar, its owner, the timezone
+used, a short description and the other components included."
+  (concat (format "BEGIN:VCALENDAR
+VERSION:2.0
+X-WR-CALNAME:%s
+PRODID:-//%s//Emacs with Org mode//EN
+X-WR-TIMEZONE:%s
+X-WR-CALDESC:%s
+CALSCALE:GREGORIAN\n"
+                 (org-icalendar-cleanup-string name)
+                 (org-icalendar-cleanup-string owner)
+                 (org-icalendar-cleanup-string tz)
+                 (org-icalendar-cleanup-string description))
+         contents
+         "END:VCALENDAR\n"))
+
+
+\f
+;;; Interactive Functions
+
+;;;###autoload
+(defun org-icalendar-export-to-ics
+  (&optional async subtreep visible-only body-only)
+  "Export current buffer to an iCalendar file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"BEGIN:VCALENDAR\" and \"END:VCALENDAR\".
+
+Return ICS file name."
+  (interactive)
+  (let ((file (buffer-file-name (buffer-base-buffer))))
+    (when (and file org-icalendar-store-UID)
+      (org-icalendar-create-uid file 'warn-user)))
+  ;; Export part.  Since this back-end is backed up by `ascii', ensure
+  ;; links will not be collected at the end of sections.
+  (let ((outfile (org-export-output-file-name ".ics" subtreep)))
+    (org-export-to-file 'icalendar outfile
+      async subtreep visible-only body-only '(:ascii-charset utf-8)
+      (lambda (file)
+       (run-hook-with-args 'org-icalendar-after-save-hook file) nil))))
+
+;;;###autoload
+(defun org-icalendar-export-agenda-files (&optional async)
+  "Export all agenda files to iCalendar files.
+When optional argument ASYNC is non-nil, export happens in an
+external process."
+  (interactive)
+  (if async
+      ;; Asynchronous export is not interactive, so we will not call
+      ;; `org-check-agenda-file'.  Instead we remove any non-existent
+      ;; agenda file from the list.
+      (let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
+       (org-export-async-start
+           (lambda (results)
+             (mapc (lambda (f) (org-export-add-to-stack f 'icalendar))
+                   results))
+         `(let (output-files)
+            (mapc (lambda (file)
+                    (with-current-buffer (org-get-agenda-file-buffer file)
+                      (push (expand-file-name (org-icalendar-export-to-ics))
+                            output-files)))
+                  ',files)
+            output-files)))
+    (let ((files (org-agenda-files t)))
+      (org-agenda-prepare-buffers files)
+      (unwind-protect
+         (mapc (lambda (file)
+                 (catch 'nextfile
+                   (org-check-agenda-file file)
+                   (with-current-buffer (org-get-agenda-file-buffer file)
+                     (org-icalendar-export-to-ics))))
+               files)
+       (org-release-buffers org-agenda-new-buffers)))))
+
+;;;###autoload
+(defun org-icalendar-combine-agenda-files (&optional async)
+  "Combine all agenda files into a single iCalendar file.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+The file is stored under the name chosen in
+`org-icalendar-combined-agenda-file'."
+  (interactive)
+  (if async
+      (let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
+       (org-export-async-start
+           (lambda (dummy)
+             (org-export-add-to-stack
+              (expand-file-name org-icalendar-combined-agenda-file)
+              'icalendar))
+         `(apply 'org-icalendar--combine-files nil ',files)))
+    (apply 'org-icalendar--combine-files nil (org-agenda-files t))))
+
+(defun org-icalendar-export-current-agenda (file)
+  "Export current agenda view to an iCalendar FILE.
+This function assumes major mode for current buffer is
+`org-agenda-mode'."
+  (let (org-export-babel-evaluate ; Don't evaluate Babel block
+       (org-icalendar-combined-agenda-file file)
+       (marker-list
+        ;; Collect the markers pointing to entries in the current
+        ;; agenda buffer.
+        (let (markers)
+          (save-excursion
+            (goto-char (point-min))
+            (while (not (eobp))
+              (let ((m (or (org-get-at-bol 'org-hd-marker)
+                           (org-get-at-bol 'org-marker))))
+                (and m (push m markers)))
+              (beginning-of-line 2)))
+          (nreverse markers))))
+    (apply 'org-icalendar--combine-files
+          ;; Build restriction alist.
+          (let (restriction)
+            ;; Sort markers in each association within RESTRICTION.
+            (mapcar (lambda (x) (setcdr x (sort (copy-sequence (cdr x)) '<)) x)
+                    (dolist (m marker-list restriction)
+                      (let* ((pos (marker-position m))
+                             (file (buffer-file-name
+                                    (org-base-buffer (marker-buffer m))))
+                             (file-markers (assoc file restriction)))
+                        ;; Add POS in FILE association if one exists
+                        ;; or create a new association for FILE.
+                        (if file-markers (push pos (cdr file-markers))
+                          (push (list file pos) restriction))))))
+          (org-agenda-files nil 'ifmode))))
+
+(defun org-icalendar--combine-files (restriction &rest files)
+  "Combine entries from multiple files into an iCalendar file.
+RESTRICTION, when non-nil, is an alist where key is a file name
+and value a list of buffer positions pointing to entries that
+should appear in the calendar.  It only makes sense if the
+function was called from an agenda buffer.  FILES is a list of
+files to build the calendar from."
+  (org-agenda-prepare-buffers files)
+  (unwind-protect
+      (progn
+       (with-temp-file org-icalendar-combined-agenda-file
+         (insert
+          (org-icalendar--vcalendar
+           ;; Name.
+           org-icalendar-combined-name
+           ;; Owner.
+           user-full-name
+           ;; Timezone.
+           (or (org-string-nw-p org-icalendar-timezone)
+               (cadr (current-time-zone)))
+           ;; Description.
+           org-icalendar-combined-description
+           ;; Contents.
+           (concat
+            ;; Agenda contents.
+            (mapconcat
+             (lambda (file)
+               (catch 'nextfile
+                 (org-check-agenda-file file)
+                 (with-current-buffer (org-get-agenda-file-buffer file)
+                   (let ((marks (cdr (assoc (expand-file-name file)
+                                            restriction))))
+                     ;; Create ID if necessary.
+                     (when org-icalendar-store-UID
+                       (org-icalendar-create-uid file t marks))
+                     (unless (and restriction (not marks))
+                       ;; Add a hook adding :ICALENDAR_MARK: property
+                       ;; to each entry appearing in agenda view.
+                       ;; Use `apply-partially' because the function
+                       ;; still has to accept one argument.
+                       (let ((org-export-before-processing-hook
+                              (cons (apply-partially
+                                     (lambda (m-list dummy)
+                                       (mapc (lambda (m)
+                                               (org-entry-put
+                                                m "ICALENDAR-MARK" "t"))
+                                             m-list))
+                                     (sort marks '>))
+                                    org-export-before-processing-hook)))
+                         (org-export-as
+                          'icalendar nil nil t
+                          (list :ascii-charset 'utf-8
+                                :icalendar-agenda-view restriction))))))))
+             files "")
+            ;; BBDB anniversaries.
+            (when (and org-icalendar-include-bbdb-anniversaries
+                       (require 'org-bbdb nil t))
+              (with-temp-buffer
+                (org-bbdb-anniv-export-ical)
+                (buffer-string)))))))
+       (run-hook-with-args 'org-icalendar-after-save-hook
+                           org-icalendar-combined-agenda-file))
+    (org-release-buffers org-agenda-new-buffers)))
+
+
+(provide 'ox-icalendar)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-icalendar.el ends here
diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el
new file mode 100644 (file)
index 0000000..6766b85
--- /dev/null
@@ -0,0 +1,2922 @@
+;;; ox-latex.el --- LaTeX Back-End for Org Export Engine
+
+;; Copyright (C) 2011-2013  Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; See Org manual for details.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox)
+(require 'ox-publish)
+
+(defvar org-latex-default-packages-alist)
+(defvar org-latex-packages-alist)
+(defvar orgtbl-exp-regexp)
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-backend 'latex
+  '((bold . org-latex-bold)
+    (center-block . org-latex-center-block)
+    (clock . org-latex-clock)
+    (code . org-latex-code)
+    (comment . (lambda (&rest args) ""))
+    (comment-block . (lambda (&rest args) ""))
+    (drawer . org-latex-drawer)
+    (dynamic-block . org-latex-dynamic-block)
+    (entity . org-latex-entity)
+    (example-block . org-latex-example-block)
+    (export-block . org-latex-export-block)
+    (export-snippet . org-latex-export-snippet)
+    (fixed-width . org-latex-fixed-width)
+    (footnote-definition . org-latex-footnote-definition)
+    (footnote-reference . org-latex-footnote-reference)
+    (headline . org-latex-headline)
+    (horizontal-rule . org-latex-horizontal-rule)
+    (inline-src-block . org-latex-inline-src-block)
+    (inlinetask . org-latex-inlinetask)
+    (italic . org-latex-italic)
+    (item . org-latex-item)
+    (keyword . org-latex-keyword)
+    (latex-environment . org-latex-latex-environment)
+    (latex-fragment . org-latex-latex-fragment)
+    (line-break . org-latex-line-break)
+    (link . org-latex-link)
+    (paragraph . org-latex-paragraph)
+    (plain-list . org-latex-plain-list)
+    (plain-text . org-latex-plain-text)
+    (planning . org-latex-planning)
+    (property-drawer . (lambda (&rest args) ""))
+    (quote-block . org-latex-quote-block)
+    (quote-section . org-latex-quote-section)
+    (radio-target . org-latex-radio-target)
+    (section . org-latex-section)
+    (special-block . org-latex-special-block)
+    (src-block . org-latex-src-block)
+    (statistics-cookie . org-latex-statistics-cookie)
+    (strike-through . org-latex-strike-through)
+    (subscript . org-latex-subscript)
+    (superscript . org-latex-superscript)
+    (table . org-latex-table)
+    (table-cell . org-latex-table-cell)
+    (table-row . org-latex-table-row)
+    (target . org-latex-target)
+    (template . org-latex-template)
+    (timestamp . org-latex-timestamp)
+    (underline . org-latex-underline)
+    (verbatim . org-latex-verbatim)
+    (verse-block . org-latex-verse-block))
+  :export-block '("LATEX" "TEX")
+  :menu-entry
+  '(?l "Export to LaTeX"
+       ((?L "As LaTeX buffer" org-latex-export-as-latex)
+       (?l "As LaTeX file" org-latex-export-to-latex)
+       (?p "As PDF file" org-latex-export-to-pdf)
+       (?o "As PDF file and open"
+           (lambda (a s v b)
+             (if a (org-latex-export-to-pdf t s v b)
+               (org-open-file (org-latex-export-to-pdf nil s v b)))))))
+  :options-alist '((:latex-class "LATEX_CLASS" nil org-latex-default-class t)
+                  (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t)
+                  (:latex-header "LATEX_HEADER" nil nil newline)
+                  (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline)
+                  (:latex-hyperref-p nil "texht" org-latex-with-hyperref t)
+                  ;; Redefine regular options.
+                  (:date "DATE" nil "\\today" t)))
+
+
+\f
+;;; Internal Variables
+
+(defconst org-latex-babel-language-alist
+  '(("af" . "afrikaans")
+    ("bg" . "bulgarian")
+    ("bt-br" . "brazilian")
+    ("ca" . "catalan")
+    ("cs" . "czech")
+    ("cy" . "welsh")
+    ("da" . "danish")
+    ("de" . "germanb")
+    ("de-at" . "naustrian")
+    ("de-de" . "ngerman")
+    ("el" . "greek")
+    ("en" . "english")
+    ("en-au" . "australian")
+    ("en-ca" . "canadian")
+    ("en-gb" . "british")
+    ("en-ie" . "irish")
+    ("en-nz" . "newzealand")
+    ("en-us" . "american")
+    ("es" . "spanish")
+    ("et" . "estonian")
+    ("eu" . "basque")
+    ("fi" . "finnish")
+    ("fr" . "frenchb")
+    ("fr-ca" . "canadien")
+    ("gl" . "galician")
+    ("hr" . "croatian")
+    ("hu" . "hungarian")
+    ("id" . "indonesian")
+    ("is" . "icelandic")
+    ("it" . "italian")
+    ("la" . "latin")
+    ("ms" . "malay")
+    ("nl" . "dutch")
+    ("nb" . "norsk")
+    ("nn" . "nynorsk")
+    ("no" . "norsk")
+    ("pl" . "polish")
+    ("pt" . "portuguese")
+    ("ro" . "romanian")
+    ("ru" . "russian")
+    ("sa" . "sanskrit")
+    ("sb" . "uppersorbian")
+    ("sk" . "slovak")
+    ("sl" . "slovene")
+    ("sq" . "albanian")
+    ("sr" . "serbian")
+    ("sv" . "swedish")
+    ("ta" . "tamil")
+    ("tr" . "turkish")
+    ("uk" . "ukrainian"))
+  "Alist between language code and corresponding Babel option.")
+
+(defconst org-latex-table-matrix-macros '(("bordermatrix" . "\\cr")
+                                           ("qbordermatrix" . "\\cr")
+                                           ("kbordermatrix" . "\\\\"))
+  "Alist between matrix macros and their row ending.")
+
+
+\f
+;;; User Configurable Variables
+
+(defgroup org-export-latex nil
+  "Options for exporting Org mode files to LaTeX."
+  :tag "Org Export LaTeX"
+  :group 'org-export)
+
+
+;;;; Preamble
+
+(defcustom org-latex-default-class "article"
+  "The default LaTeX class."
+  :group 'org-export-latex
+  :type '(string :tag "LaTeX class"))
+
+(defcustom org-latex-classes
+  '(("article"
+     "\\documentclass[11pt]{article}"
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
+     ("\\paragraph{%s}" . "\\paragraph*{%s}")
+     ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
+    ("report"
+     "\\documentclass[11pt]{report}"
+     ("\\part{%s}" . "\\part*{%s}")
+     ("\\chapter{%s}" . "\\chapter*{%s}")
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
+    ("book"
+     "\\documentclass[11pt]{book}"
+     ("\\part{%s}" . "\\part*{%s}")
+     ("\\chapter{%s}" . "\\chapter*{%s}")
+     ("\\section{%s}" . "\\section*{%s}")
+     ("\\subsection{%s}" . "\\subsection*{%s}")
+     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
+  "Alist of LaTeX classes and associated header and structure.
+If #+LATEX_CLASS is set in the buffer, use its value and the
+associated information.  Here is the structure of each cell:
+
+  \(class-name
+    header-string
+    \(numbered-section . unnumbered-section)
+    ...)
+
+The header string
+-----------------
+
+The HEADER-STRING is the header that will be inserted into the
+LaTeX file.  It should contain the \\documentclass macro, and
+anything else that is needed for this setup.  To this header, the
+following commands will be added:
+
+- Calls to \\usepackage for all packages mentioned in the
+  variables `org-latex-default-packages-alist' and
+  `org-latex-packages-alist'.  Thus, your header definitions
+  should avoid to also request these packages.
+
+- Lines specified via \"#+LATEX_HEADER:\" and
+  \"#+LATEX_HEADER_EXTRA:\" keywords.
+
+If you need more control about the sequence in which the header
+is built up, or if you want to exclude one of these building
+blocks for a particular class, you can use the following
+macro-like placeholders.
+
+ [DEFAULT-PACKAGES]      \\usepackage statements for default packages
+ [NO-DEFAULT-PACKAGES]   do not include any of the default packages
+ [PACKAGES]              \\usepackage statements for packages
+ [NO-PACKAGES]           do not include the packages
+ [EXTRA]                 the stuff from #+LATEX_HEADER(_EXTRA)
+ [NO-EXTRA]              do not include #+LATEX_HEADER(_EXTRA) stuff
+
+So a header like
+
+  \\documentclass{article}
+  [NO-DEFAULT-PACKAGES]
+  [EXTRA]
+  \\providecommand{\\alert}[1]{\\textbf{#1}}
+  [PACKAGES]
+
+will omit the default packages, and will include the
+#+LATEX_HEADER and #+LATEX_HEADER_EXTRA lines, then have a call
+to \\providecommand, and then place \\usepackage commands based
+on the content of `org-latex-packages-alist'.
+
+If your header, `org-latex-default-packages-alist' or
+`org-latex-packages-alist' inserts \"\\usepackage[AUTO]{inputenc}\",
+AUTO will automatically be replaced with a coding system derived
+from `buffer-file-coding-system'.  See also the variable
+`org-latex-inputenc-alist' for a way to influence this mechanism.
+
+Likewise, if your header contains \"\\usepackage[AUTO]{babel}\",
+AUTO will be replaced with the language related to the language
+code specified by `org-export-default-language', which see.  Note
+that constructions such as \"\\usepackage[french,AUTO,english]{babel}\"
+are permitted.
+
+The sectioning structure
+------------------------
+
+The sectioning structure of the class is given by the elements
+following the header string.  For each sectioning level, a number
+of strings is specified.  A %s formatter is mandatory in each
+section string and will be replaced by the title of the section.
+
+Instead of a cons cell (numbered . unnumbered), you can also
+provide a list of 2 or 4 elements,
+
+  \(numbered-open numbered-close)
+
+or
+
+  \(numbered-open numbered-close unnumbered-open unnumbered-close)
+
+providing opening and closing strings for a LaTeX environment
+that should represent the document section.  The opening clause
+should have a %s to represent the section title.
+
+Instead of a list of sectioning commands, you can also specify
+a function name.  That function will be called with two
+parameters, the (reduced) level of the headline, and a predicate
+non-nil when the headline should be numbered.  It must return
+a format string in which the section title will be added."
+  :group 'org-export-latex
+  :type '(repeat
+         (list (string :tag "LaTeX class")
+               (string :tag "LaTeX header")
+               (repeat :tag "Levels" :inline t
+                       (choice
+                        (cons :tag "Heading"
+                              (string :tag "  numbered")
+                              (string :tag "unnumbered"))
+                        (list :tag "Environment"
+                              (string :tag "Opening   (numbered)")
+                              (string :tag "Closing   (numbered)")
+                              (string :tag "Opening (unnumbered)")
+                              (string :tag "Closing (unnumbered)"))
+                        (function :tag "Hook computing sectioning"))))))
+
+(defcustom org-latex-inputenc-alist nil
+  "Alist of inputenc coding system names, and what should really be used.
+For example, adding an entry
+
+      (\"utf8\" . \"utf8x\")
+
+will cause \\usepackage[utf8x]{inputenc} to be used for buffers that
+are written as utf8 files."
+  :group 'org-export-latex
+  :type '(repeat
+         (cons
+          (string :tag "Derived from buffer")
+          (string :tag "Use this instead"))))
+
+(defcustom org-latex-title-command "\\maketitle"
+  "The command used to insert the title just after \\begin{document}.
+If this string contains the formatting specification \"%s\" then
+it will be used as a formatting string, passing the title as an
+argument."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-latex-toc-command "\\tableofcontents\n\n"
+  "LaTeX command to set the table of contents, list of figures, etc.
+This command only applies to the table of contents generated with
+the toc:nil option, not to those generated with #+TOC keyword."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-latex-with-hyperref t
+  "Toggle insertion of \\hypersetup{...} in the preamble."
+  :group 'org-export-latex
+  :type 'boolean)
+
+;;;; Headline
+
+(defcustom org-latex-format-headline-function
+  'org-latex-format-headline-default-function
+  "Function for formatting the headline's text.
+
+This function will be called with 5 arguments:
+TODO      the todo keyword (string or nil).
+TODO-TYPE the type of todo (symbol: `todo', `done', nil)
+PRIORITY  the priority of the headline (integer or nil)
+TEXT      the main headline text (string).
+TAGS      the tags as a list of strings (list of strings or nil).
+
+The function result will be used in the section format string.
+
+Use `org-latex-format-headline-default-function' by default,
+which format headlines like for Org version prior to 8.0."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+
+;;;; Footnotes
+
+(defcustom org-latex-footnote-separator "\\textsuperscript{,}\\,"
+  "Text used to separate footnotes."
+  :group 'org-export-latex
+  :type 'string)
+
+
+;;;; Timestamps
+
+(defcustom org-latex-active-timestamp-format "\\textit{%s}"
+  "A printf format string to be applied to active timestamps."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-latex-inactive-timestamp-format "\\textit{%s}"
+  "A printf format string to be applied to inactive timestamps."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-latex-diary-timestamp-format "\\textit{%s}"
+  "A printf format string to be applied to diary timestamps."
+  :group 'org-export-latex
+  :type 'string)
+
+
+;;;; Links
+
+(defcustom org-latex-image-default-option ""
+  "Default option for images."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-image-default-width ".9\\linewidth"
+  "Default width for images.
+This value will not be used if a height is provided."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-image-default-height ""
+  "Default height for images.
+This value will not be used if a width is provided, or if the
+image is wrapped within a \"figure\" or \"wrapfigure\"
+environment."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-default-figure-position "htb"
+  "Default position for latex figures."
+  :group 'org-export-latex
+  :type 'string)
+
+(defcustom org-latex-inline-image-rules
+  '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\|tikz\\|pgf\\|svg\\)\\'"))
+  "Rules characterizing image files that can be inlined into LaTeX.
+
+A rule consists in an association whose key is the type of link
+to consider, and value is a regexp that will be matched against
+link's path.
+
+Note that, by default, the image extension *actually* allowed
+depend on the way the LaTeX file is processed.  When used with
+pdflatex, pdf, jpg and png images are OK.  When processing
+through dvi to Postscript, only ps and eps are allowed.  The
+default we use here encompasses both."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(alist :key-type (string :tag "Type")
+               :value-type (regexp :tag "Path")))
+
+(defcustom org-latex-link-with-unknown-path-format "\\texttt{%s}"
+  "Format string for links with unknown path type."
+  :group 'org-export-latex
+  :type 'string)
+
+
+;;;; Tables
+
+(defcustom org-latex-default-table-environment "tabular"
+  "Default environment used to build tables."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
+
+(defcustom org-latex-default-table-mode 'table
+  "Default mode for tables.
+
+Value can be a symbol among:
+
+  `table' Regular LaTeX table.
+
+  `math' In this mode, every cell is considered as being in math
+     mode and the complete table will be wrapped within a math
+     environment.  It is particularly useful to write matrices.
+
+  `inline-math' This mode is almost the same as `math', but the
+     math environment will be inlined.
+
+  `verbatim' The table is exported as it appears in the Org
+     buffer, within a verbatim environment.
+
+This value can be overridden locally with, i.e. \":mode math\" in
+LaTeX attributes.
+
+When modifying this variable, it may be useful to change
+`org-latex-default-table-environment' accordingly."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice (const :tag "Table" table)
+                (const :tag "Matrix" math)
+                (const :tag "Inline matrix" inline-math)
+                (const :tag "Verbatim" verbatim)))
+
+(defcustom org-latex-tables-centered t
+  "When non-nil, tables are exported in a center environment."
+  :group 'org-export-latex
+  :type 'boolean)
+
+(defcustom org-latex-tables-booktabs nil
+  "When non-nil, display tables in a formal \"booktabs\" style.
+This option assumes that the \"booktabs\" package is properly
+loaded in the header of the document.  This value can be ignored
+locally with \":booktabs t\" and \":booktabs nil\" LaTeX
+attributes."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-latex-table-caption-above t
+  "When non-nil, place caption string at the beginning of the table.
+Otherwise, place it near the end."
+  :group 'org-export-latex
+  :type 'boolean)
+
+(defcustom org-latex-table-scientific-notation "%s\\,(%s)"
+  "Format string to display numbers in scientific notation.
+The format should have \"%s\" twice, for mantissa and exponent
+\(i.e., \"%s\\\\times10^{%s}\").
+
+When nil, no transformation is made."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (string :tag "Format string")
+         (const :tag "No formatting")))
+
+
+;;;; Text markup
+
+(defcustom org-latex-text-markup-alist '((bold . "\\textbf{%s}")
+                                        (code . verb)
+                                        (italic . "\\emph{%s}")
+                                        (strike-through . "\\sout{%s}")
+                                        (underline . "\\uline{%s}")
+                                        (verbatim . protectedtexttt))
+  "Alist of LaTeX expressions to convert text markup.
+
+The key must be a symbol among `bold', `code', `italic',
+`strike-through', `underline' and `verbatim'.  The value is
+a formatting string to wrap fontified text with.
+
+Value can also be set to the following symbols: `verb' and
+`protectedtexttt'.  For the former, Org will use \"\\verb\" to
+create a format string and select a delimiter character that
+isn't in the string.  For the latter, Org will use \"\\texttt\"
+to typeset and try to protect special characters.
+
+If no association can be found for a given markup, text will be
+returned as-is."
+  :group 'org-export-latex
+  :type 'alist
+  :options '(bold code italic strike-through underline verbatim))
+
+
+;;;; Drawers
+
+(defcustom org-latex-format-drawer-function nil
+  "Function called to format a drawer in LaTeX code.
+
+The function must accept two parameters:
+  NAME      the drawer name, like \"LOGBOOK\"
+  CONTENTS  the contents of the drawer.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-latex-format-drawer-default \(name contents\)
+  \"Format a drawer element for LaTeX export.\"
+  contents\)"
+  :group 'org-export-latex
+  :type 'function)
+
+
+;;;; Inlinetasks
+
+(defcustom org-latex-format-inlinetask-function nil
+  "Function called to format an inlinetask in LaTeX code.
+
+The function must accept six parameters:
+  TODO      the todo keyword, as a string
+  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  PRIORITY  the inlinetask priority, as a string
+  NAME      the inlinetask name, as a string.
+  TAGS      the inlinetask tags, as a list of strings.
+  CONTENTS  the contents of the inlinetask, as a string.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-latex-format-inlinetask \(todo type priority name tags contents\)
+\"Format an inline task element for LaTeX export.\"
+  \(let ((full-title
+        \(concat
+         \(when todo
+            \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo))
+         \(when priority (format \"\\\\framebox{\\\\#%c} \" priority))
+         title
+         \(when tags
+            \(format \"\\\\hfill{}\\\\textsc{:%s:}\"
+                    \(mapconcat 'identity tags \":\")))))
+    \(format (concat \"\\\\begin{center}\\n\"
+                   \"\\\\fbox{\\n\"
+                   \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
+                   \"%s\\n\\n\"
+                   \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
+                   \"%s\"
+                   \"\\\\end{minipage}}\"
+                   \"\\\\end{center}\")
+           full-title contents))"
+  :group 'org-export-latex
+  :type 'function)
+
+
+;; Src blocks
+
+(defcustom org-latex-listings nil
+  "Non-nil means export source code using the listings package.
+
+This package will fontify source code, possibly even with color.
+If you want to use this, you also need to make LaTeX use the
+listings package, and if you want to have color, the color
+package.  Just add these to `org-latex-packages-alist', for
+example using customize, or with something like:
+
+  \(require 'ox-latex)
+  \(add-to-list 'org-latex-packages-alist '(\"\" \"listings\"))
+  \(add-to-list 'org-latex-packages-alist '(\"\" \"color\"))
+
+Alternatively,
+
+  \(setq org-latex-listings 'minted)
+
+causes source code to be exported using the minted package as
+opposed to listings.  If you want to use minted, you need to add
+the minted package to `org-latex-packages-alist', for example
+using customize, or with
+
+  \(require 'ox-latex)
+  \(add-to-list 'org-latex-packages-alist '(\"\" \"minted\"))
+
+In addition, it is necessary to install pygments
+\(http://pygments.org), and to configure the variable
+`org-latex-pdf-process' so that the -shell-escape option is
+passed to pdflatex.
+
+The minted choice has possible repercussions on the preview of
+latex fragments (see `org-preview-latex-fragment').  If you run
+into previewing problems, please consult
+
+  http://orgmode.org/worg/org-tutorials/org-latex-preview.html"
+  :group 'org-export-latex
+  :type '(choice
+         (const :tag "Use listings" t)
+         (const :tag "Use minted" minted)
+         (const :tag "Export verbatim" nil)))
+
+(defcustom org-latex-listings-langs
+  '((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp")
+    (c "C") (cc "C++")
+    (fortran "fortran")
+    (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby")
+    (html "HTML") (xml "XML")
+    (tex "TeX") (latex "[LaTeX]TeX")
+    (shell-script "bash")
+    (gnuplot "Gnuplot")
+    (ocaml "Caml") (caml "Caml")
+    (sql "SQL") (sqlite "sql"))
+  "Alist mapping languages to their listing language counterpart.
+The key is a symbol, the major mode symbol without the \"-mode\".
+The value is the string that should be inserted as the language
+parameter for the listings package.  If the mode name and the
+listings name are the same, the language does not need an entry
+in this list - but it does not hurt if it is present."
+  :group 'org-export-latex
+  :type '(repeat
+         (list
+          (symbol :tag "Major mode       ")
+          (string :tag "Listings language"))))
+
+(defcustom org-latex-listings-options nil
+  "Association list of options for the latex listings package.
+
+These options are supplied as a comma-separated list to the
+\\lstset command.  Each element of the association list should be
+a list containing two strings: the name of the option, and the
+value.  For example,
+
+  (setq org-latex-listings-options
+    '((\"basicstyle\" \"\\\\small\")
+      (\"keywordstyle\" \"\\\\color{black}\\\\bfseries\\\\underbar\")))
+
+will typeset the code in a small size font with underlined, bold
+black keywords.
+
+Note that the same options will be applied to blocks of all
+languages."
+  :group 'org-export-latex
+  :type '(repeat
+         (list
+          (string :tag "Listings option name ")
+          (string :tag "Listings option value"))))
+
+(defcustom org-latex-minted-langs
+  '((emacs-lisp "common-lisp")
+    (cc "c++")
+    (cperl "perl")
+    (shell-script "bash")
+    (caml "ocaml"))
+  "Alist mapping languages to their minted language counterpart.
+The key is a symbol, the major mode symbol without the \"-mode\".
+The value is the string that should be inserted as the language
+parameter for the minted package.  If the mode name and the
+listings name are the same, the language does not need an entry
+in this list - but it does not hurt if it is present.
+
+Note that minted uses all lower case for language identifiers,
+and that the full list of language identifiers can be obtained
+with:
+
+  pygmentize -L lexers"
+  :group 'org-export-latex
+  :type '(repeat
+         (list
+          (symbol :tag "Major mode     ")
+          (string :tag "Minted language"))))
+
+(defcustom org-latex-minted-options nil
+  "Association list of options for the latex minted package.
+
+These options are supplied within square brackets in
+\\begin{minted} environments.  Each element of the alist should
+be a list containing two strings: the name of the option, and the
+value.  For example,
+
+  \(setq org-latex-minted-options
+    '\((\"bgcolor\" \"bg\") \(\"frame\" \"lines\")))
+
+will result in src blocks being exported with
+
+\\begin{minted}[bgcolor=bg,frame=lines]{<LANG>}
+
+as the start of the minted environment. Note that the same
+options will be applied to blocks of all languages."
+  :group 'org-export-latex
+  :type '(repeat
+         (list
+          (string :tag "Minted option name ")
+          (string :tag "Minted option value"))))
+
+(defvar org-latex-custom-lang-environments nil
+  "Alist mapping languages to language-specific LaTeX environments.
+
+It is used during export of src blocks by the listings and minted
+latex packages.  For example,
+
+  \(setq org-latex-custom-lang-environments
+     '\(\(python \"pythoncode\"\)\)\)
+
+would have the effect that if org encounters begin_src python
+during latex export it will output
+
+  \\begin{pythoncode}
+  <src block body>
+  \\end{pythoncode}")
+
+
+;;;; Compilation
+
+(defcustom org-latex-pdf-process
+  '("pdflatex -interaction nonstopmode -output-directory %o %f"
+    "pdflatex -interaction nonstopmode -output-directory %o %f"
+    "pdflatex -interaction nonstopmode -output-directory %o %f")
+  "Commands to process a LaTeX file to a PDF file.
+This is a list of strings, each of them will be given to the
+shell as a command.  %f in the command will be replaced by the
+full file name, %b by the file base name (i.e. without directory
+and extension parts) and %o by the base directory of the file.
+
+The reason why this is a list is that it usually takes several
+runs of `pdflatex', maybe mixed with a call to `bibtex'.  Org
+does not have a clever mechanism to detect which of these
+commands have to be run to get to a stable result, and it also
+does not do any error checking.
+
+By default, Org uses 3 runs of `pdflatex' to do the processing.
+If you have texi2dvi on your system and if that does not cause
+the infamous egrep/locale bug:
+
+     http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html
+
+then `texi2dvi' is the superior choice as it automates the LaTeX
+build process by calling the \"correct\" combinations of
+auxiliary programs.  Org does offer `texi2dvi' as one of the
+customize options.  Alternatively, `rubber' and `latexmk' also
+provide similar functionality.  The latter supports `biber' out
+of the box.
+
+Alternatively, this may be a Lisp function that does the
+processing, so you could use this to apply the machinery of
+AUCTeX or the Emacs LaTeX mode.  This function should accept the
+file name as its single argument."
+  :group 'org-export-pdf
+  :type '(choice
+         (repeat :tag "Shell command sequence"
+                 (string :tag "Shell command"))
+         (const :tag "2 runs of pdflatex"
+                ("pdflatex -interaction nonstopmode -output-directory %o %f"
+                  "pdflatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "3 runs of pdflatex"
+                ("pdflatex -interaction nonstopmode -output-directory %o %f"
+                  "pdflatex -interaction nonstopmode -output-directory %o %f"
+                  "pdflatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "pdflatex,bibtex,pdflatex,pdflatex"
+                ("pdflatex -interaction nonstopmode -output-directory %o %f"
+                  "bibtex %b"
+                  "pdflatex -interaction nonstopmode -output-directory %o %f"
+                  "pdflatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "2 runs of xelatex"
+                ("xelatex -interaction nonstopmode -output-directory %o %f"
+                 "xelatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "3 runs of xelatex"
+                ("xelatex -interaction nonstopmode -output-directory %o %f"
+                 "xelatex -interaction nonstopmode -output-directory %o %f"
+                 "xelatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "xelatex,bibtex,xelatex,xelatex"
+                ("xelatex -interaction nonstopmode -output-directory %o %f"
+                 "bibtex %b"
+                 "xelatex -interaction nonstopmode -output-directory %o %f"
+                 "xelatex -interaction nonstopmode -output-directory %o %f"))
+         (const :tag "texi2dvi"
+                ("texi2dvi -p -b -V %f"))
+         (const :tag "rubber"
+                ("rubber -d --into %o %f"))
+         (const :tag "latexmk"
+                ("latexmk -g -pdf %f"))
+         (function)))
+
+(defcustom org-latex-logfiles-extensions
+  '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb")
+  "The list of file extensions to consider as LaTeX logfiles.
+The logfiles will be remove if `org-latex-remove-logfiles' is
+non-nil."
+  :group 'org-export-latex
+  :type '(repeat (string :tag "Extension")))
+
+(defcustom org-latex-remove-logfiles t
+  "Non-nil means remove the logfiles produced by PDF production.
+By default, logfiles are files with these extensions: .aux, .idx,
+.log, .out, .toc, .nav, .snm and .vrb.  To define the set of
+logfiles to remove, set `org-latex-logfiles-extensions'."
+  :group 'org-export-latex
+  :type 'boolean)
+
+(defcustom org-latex-known-errors
+  '(("Reference.*?undefined" .  "[undefined reference]")
+    ("Citation.*?undefined" .  "[undefined citation]")
+    ("Undefined control sequence" .  "[undefined control sequence]")
+    ("^! LaTeX.*?Error" .  "[LaTeX error]")
+    ("^! Package.*?Error" .  "[package error]")
+    ("Runaway argument" .  "Runaway argument"))
+  "Alist of regular expressions and associated messages for the user.
+The regular expressions are used to find possible errors in the
+log of a latex-run."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(repeat
+         (cons
+          (string :tag "Regexp")
+          (string :tag "Message"))))
+
+
+\f
+;;; Internal Functions
+
+(defun org-latex--caption/label-string (element info)
+  "Return caption and label LaTeX string for ELEMENT.
+
+INFO is a plist holding contextual information.  If there's no
+caption nor label, return the empty string.
+
+For non-floats, see `org-latex--wrap-label'."
+  (let* ((label (org-element-property :name element))
+        (label-str (if (not (org-string-nw-p label)) ""
+                     (format "\\label{%s}"
+                             (org-export-solidify-link-text label))))
+        (main (org-export-get-caption element))
+        (short (org-export-get-caption element t))
+        (caption-from-attr-latex (org-export-read-attribute :attr_latex element :caption)))
+    (cond
+     ((org-string-nw-p caption-from-attr-latex)
+      (concat caption-from-attr-latex "\n"))
+     ((and (not main) (equal label-str "")) "")
+     ((not main) (concat label-str "\n"))
+     ;; Option caption format with short name.
+     (short (format "\\caption[%s]{%s%s}\n"
+                   (org-export-data short info)
+                   label-str
+                   (org-export-data main info)))
+     ;; Standard caption format.
+     (t (format "\\caption{%s%s}\n" label-str (org-export-data main info))))))
+
+(defun org-latex-guess-inputenc (header)
+  "Set the coding system in inputenc to what the buffer is.
+
+HEADER is the LaTeX header string.  This function only applies
+when specified inputenc option is \"AUTO\".
+
+Return the new header, as a string."
+  (let* ((cs (or (ignore-errors
+                  (latexenc-coding-system-to-inputenc
+                   (or org-export-coding-system buffer-file-coding-system)))
+                "utf8")))
+    (if (not cs) header
+      ;; First translate if that is requested.
+      (setq cs (or (cdr (assoc cs org-latex-inputenc-alist)) cs))
+      ;; Then find the \usepackage statement and replace the option.
+      (replace-regexp-in-string "\\\\usepackage\\[\\(AUTO\\)\\]{inputenc}"
+                               cs header t nil 1))))
+
+(defun org-latex-guess-babel-language (header info)
+  "Set Babel's language according to LANGUAGE keyword.
+
+HEADER is the LaTeX header string.  INFO is the plist used as
+a communication channel.
+
+Insertion of guessed language only happens when Babel package has
+explicitly been loaded.  Then it is added to the rest of
+package's options.
+
+The argument to Babel may be \"AUTO\" which is then replaced with
+the language of the document or `org-export-default-language'
+unless language in question is already loaded.
+
+Return the new header."
+  (let ((language-code (plist-get info :language)))
+    ;; If no language is set or Babel package is not loaded, return
+    ;; HEADER as-is.
+    (if (or (not (stringp language-code))
+           (not (string-match "\\\\usepackage\\[\\(.*\\)\\]{babel}" header)))
+       header
+      (let ((options (save-match-data
+                      (org-split-string (match-string 1 header) ",[ \t]*")))
+           (language (cdr (assoc language-code
+                                 org-latex-babel-language-alist))))
+       ;; If LANGUAGE is already loaded, return header without AUTO.
+       ;; Otherwise, replace AUTO with language or append language if
+       ;; AUTO is not present.
+       (replace-match
+        (mapconcat (lambda (option) (if (equal "AUTO" option) language option))
+                   (cond ((member language options) (delete "AUTO" options))
+                         ((member "AUTO" options) options)
+                         (t (append options (list language))))
+                   ", ")
+        t nil header 1)))))
+
+(defun org-latex--find-verb-separator (s)
+  "Return a character not used in string S.
+This is used to choose a separator for constructs like \\verb."
+  (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
+    (loop for c across ll
+         when (not (string-match (regexp-quote (char-to-string c)) s))
+         return (char-to-string c))))
+
+(defun org-latex--make-option-string (options)
+  "Return a comma separated string of keywords and values.
+OPTIONS is an alist where the key is the options keyword as
+a string, and the value a list containing the keyword value, or
+nil."
+  (mapconcat (lambda (pair)
+              (concat (first pair)
+                      (when (> (length (second pair)) 0)
+                        (concat "=" (second pair)))))
+            options
+            ","))
+
+(defun org-latex--wrap-label (element output)
+  "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
+This function shouldn't be used for floats.  See
+`org-latex--caption/label-string'."
+  (let ((label (org-element-property :name element)))
+    (if (not (and (org-string-nw-p output) (org-string-nw-p label))) output
+      (concat (format "\\label{%s}\n" (org-export-solidify-link-text label))
+             output))))
+
+(defun org-latex--text-markup (text markup)
+  "Format TEXT depending on MARKUP text markup.
+See `org-latex-text-markup-alist' for details."
+  (let ((fmt (cdr (assq markup org-latex-text-markup-alist))))
+    (cond
+     ;; No format string: Return raw text.
+     ((not fmt) text)
+     ;; Handle the `verb' special case: Find and appropriate separator
+     ;; and use "\\verb" command.
+     ((eq 'verb fmt)
+      (let ((separator (org-latex--find-verb-separator text)))
+       (concat "\\verb" separator text separator)))
+     ;; Handle the `protectedtexttt' special case: Protect some
+     ;; special chars and use "\texttt{%s}" format string.
+     ((eq 'protectedtexttt fmt)
+      (let ((start 0)
+           (trans '(("\\" . "\\textbackslash{}")
+                    ("~" . "\\textasciitilde{}")
+                    ("^" . "\\textasciicircum{}")))
+           (rtn "")
+           char)
+       (while (string-match "[\\{}$%&_#~^]" text)
+         (setq char (match-string 0 text))
+         (if (> (match-beginning 0) 0)
+             (setq rtn (concat rtn (substring text 0 (match-beginning 0)))))
+         (setq text (substring text (1+ (match-beginning 0))))
+         (setq char (or (cdr (assoc char trans)) (concat "\\" char))
+               rtn (concat rtn char)))
+       (setq text (concat rtn text)
+             fmt "\\texttt{%s}")
+       (while (string-match "--" text)
+         (setq text (replace-match "-{}-" t t text)))
+       (format fmt text)))
+     ;; Else use format string.
+     (t (format fmt text)))))
+
+(defun org-latex--delayed-footnotes-definitions (element info)
+  "Return footnotes definitions in ELEMENT as a string.
+
+INFO is a plist used as a communication channel.
+
+Footnotes definitions are returned within \"\\footnotetxt{}\"
+commands.
+
+This function is used within constructs that don't support
+\"\\footnote{}\" command (i.e. an item's tag).  In that case,
+\"\\footnotemark\" is used within the construct and the function
+just outside of it."
+  (mapconcat
+   (lambda (ref)
+     (format
+      "\\footnotetext[%s]{%s}"
+      (org-export-get-footnote-number ref info)
+      (org-trim
+       (org-export-data
+       (org-export-get-footnote-definition ref info) info))))
+   ;; Find every footnote reference in ELEMENT.
+   (let* (all-refs
+         search-refs                   ; For byte-compiler.
+         (search-refs
+          (function
+           (lambda (data)
+             ;; Return a list of all footnote references never seen
+             ;; before in DATA.
+             (org-element-map data 'footnote-reference
+               (lambda (ref)
+                 (when (org-export-footnote-first-reference-p ref info)
+                   (push ref all-refs)
+                   (when (eq (org-element-property :type ref) 'standard)
+                     (funcall search-refs
+                              (org-export-get-footnote-definition ref info)))))
+               info)
+             (reverse all-refs)))))
+     (funcall search-refs element))
+   ""))
+
+
+\f
+;;; Template
+
+(defun org-latex-template (contents info)
+  "Return complete document string after LaTeX conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (let ((title (org-export-data (plist-get info :title) info)))
+    (concat
+     ;; Time-stamp.
+     (and (plist-get info :time-stamp-file)
+         (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
+     ;; Document class and packages.
+     (let* ((class (plist-get info :latex-class))
+           (class-options (plist-get info :latex-class-options))
+           (header (nth 1 (assoc class org-latex-classes)))
+           (document-class-string
+            (and (stringp header)
+                 (if (not class-options) header
+                   (replace-regexp-in-string
+                    "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
+                    class-options header t nil 1)))))
+       (if (not document-class-string)
+          (user-error "Unknown LaTeX class `%s'" class)
+        (org-latex-guess-babel-language
+         (org-latex-guess-inputenc
+          (org-element-normalize-string
+           (org-splice-latex-header
+            document-class-string
+            org-latex-default-packages-alist
+            org-latex-packages-alist nil
+            (concat (org-element-normalize-string
+                     (plist-get info :latex-header))
+                    (plist-get info :latex-header-extra)))))
+         info)))
+     ;; Possibly limit depth for headline numbering.
+     (let ((sec-num (plist-get info :section-numbers)))
+       (when (integerp sec-num)
+        (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
+     ;; Author.
+     (let ((author (and (plist-get info :with-author)
+                       (let ((auth (plist-get info :author)))
+                         (and auth (org-export-data auth info)))))
+          (email (and (plist-get info :with-email)
+                      (org-export-data (plist-get info :email) info))))
+       (cond ((and author email (not (string= "" email)))
+             (format "\\author{%s\\thanks{%s}}\n" author email))
+            ((or author email) (format "\\author{%s}\n" (or author email)))))
+     ;; Date.
+     (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
+       (format "\\date{%s}\n" (org-export-data date info)))
+     ;; Title
+     (format "\\title{%s}\n" title)
+     ;; Hyperref options.
+     (when (plist-get info :latex-hyperref-p)
+       (format "\\hypersetup{\n  pdfkeywords={%s},\n  pdfsubject={%s},\n  pdfcreator={%s}}\n"
+              (or (plist-get info :keywords) "")
+              (or (plist-get info :description) "")
+              (if (not (plist-get info :with-creator)) ""
+                (plist-get info :creator))))
+     ;; Document start.
+     "\\begin{document}\n\n"
+     ;; Title command.
+     (org-element-normalize-string
+      (cond ((string= "" title) nil)
+           ((not (stringp org-latex-title-command)) nil)
+           ((string-match "\\(?:[^%]\\|^\\)%s"
+                          org-latex-title-command)
+            (format org-latex-title-command title))
+           (t org-latex-title-command)))
+     ;; Table of contents.
+     (let ((depth (plist-get info :with-toc)))
+       (when depth
+        (concat (when (wholenump depth)
+                  (format "\\setcounter{tocdepth}{%d}\n" depth))
+                org-latex-toc-command)))
+     ;; Document's body.
+     contents
+     ;; Creator.
+     (let ((creator-info (plist-get info :with-creator)))
+       (cond
+       ((not creator-info) "")
+       ((eq creator-info 'comment)
+        (format "%% %s\n" (plist-get info :creator)))
+       (t (concat (plist-get info :creator) "\n"))))
+     ;; Document end.
+     "\\end{document}")))
+
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-latex-bold (bold contents info)
+  "Transcode BOLD from Org to LaTeX.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (org-latex--text-markup contents 'bold))
+
+
+;;;; Center Block
+
+(defun org-latex-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the center block.  INFO is a plist
+holding contextual information."
+  (org-latex--wrap-label
+   center-block
+   (format "\\begin{center}\n%s\\end{center}" contents)))
+
+
+;;;; Clock
+
+(defun org-latex-clock (clock contents info)
+  "Transcode a CLOCK element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "\\noindent"
+   (format "\\textbf{%s} " org-clock-string)
+   (format org-latex-inactive-timestamp-format
+          (concat (org-translate-time
+                   (org-element-property :raw-value
+                                         (org-element-property :value clock)))
+                  (let ((time (org-element-property :duration clock)))
+                    (and time (format " (%s)" time)))))
+   "\\\\"))
+
+
+;;;; Code
+
+(defun org-latex-code (code contents info)
+  "Transcode a CODE object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-latex--text-markup (org-element-property :value code) 'code))
+
+
+;;;; Drawer
+
+(defun org-latex-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to LaTeX.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let* ((name (org-element-property :drawer-name drawer))
+        (output (if (functionp org-latex-format-drawer-function)
+                    (funcall org-latex-format-drawer-function
+                             name contents)
+                  ;; If there's no user defined function: simply
+                  ;; display contents of the drawer.
+                  contents)))
+    (org-latex--wrap-label drawer output)))
+
+
+;;;; Dynamic Block
+
+(defun org-latex-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information.  See `org-export-data'."
+  (org-latex--wrap-label dynamic-block contents))
+
+
+;;;; Entity
+
+(defun org-latex-entity (entity contents info)
+  "Transcode an ENTITY object from Org to LaTeX.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (let ((ent (org-element-property :latex entity)))
+    (if (org-element-property :latex-math-p entity) (format "$%s$" ent) ent)))
+
+
+;;;; Example Block
+
+(defun org-latex-example-block (example-block contents info)
+  "Transcode an EXAMPLE-BLOCK element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (when (org-string-nw-p (org-element-property :value example-block))
+    (org-latex--wrap-label
+     example-block
+     (format "\\begin{verbatim}\n%s\\end{verbatim}"
+            (org-export-format-code-default example-block info)))))
+
+
+;;;; Export Block
+
+(defun org-latex-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (member (org-element-property :type export-block) '("LATEX" "TEX"))
+    (org-remove-indentation (org-element-property :value export-block))))
+
+
+;;;; Export Snippet
+
+(defun org-latex-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (eq (org-export-snippet-backend export-snippet) 'latex)
+    (org-element-property :value export-snippet)))
+
+
+;;;; Fixed Width
+
+(defun org-latex-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-latex--wrap-label
+   fixed-width
+   (format "\\begin{verbatim}\n%s\\end{verbatim}"
+          (org-remove-indentation
+           (org-element-property :value fixed-width)))))
+
+
+;;;; Footnote Reference
+
+(defun org-latex-footnote-reference (footnote-reference contents info)
+  "Transcode a FOOTNOTE-REFERENCE element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (concat
+   ;; Insert separator between two footnotes in a row.
+   (let ((prev (org-export-get-previous-element footnote-reference info)))
+     (when (eq (org-element-type prev) 'footnote-reference)
+       org-latex-footnote-separator))
+   (cond
+    ;; Use \footnotemark if the footnote has already been defined.
+    ((not (org-export-footnote-first-reference-p footnote-reference info))
+     (format "\\footnotemark[%s]{}"
+            (org-export-get-footnote-number footnote-reference info)))
+    ;; Use \footnotemark if reference is within another footnote
+    ;; reference, footnote definition or table cell.
+    ((loop for parent in (org-export-get-genealogy footnote-reference)
+          thereis (memq (org-element-type parent)
+                        '(footnote-reference footnote-definition table-cell)))
+     "\\footnotemark")
+    ;; Otherwise, define it with \footnote command.
+    (t
+     (let ((def (org-export-get-footnote-definition footnote-reference info)))
+       (concat
+       (format "\\footnote{%s}" (org-trim (org-export-data def info)))
+       ;; Retrieve all footnote references within the footnote and
+       ;; add their definition after it, since LaTeX doesn't support
+       ;; them inside.
+       (org-latex--delayed-footnotes-definitions def info)))))))
+
+
+;;;; Headline
+
+(defun org-latex-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to LaTeX.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  (unless (org-element-property :footnote-section-p headline)
+    (let* ((class (plist-get info :latex-class))
+          (level (org-export-get-relative-level headline info))
+          (numberedp (org-export-numbered-headline-p headline info))
+          (class-sectioning (assoc class org-latex-classes))
+          ;; Section formatting will set two placeholders: one for
+          ;; the title and the other for the contents.
+          (section-fmt
+           (let ((sec (if (functionp (nth 2 class-sectioning))
+                          (funcall (nth 2 class-sectioning) level numberedp)
+                        (nth (1+ level) class-sectioning))))
+             (cond
+              ;; No section available for that LEVEL.
+              ((not sec) nil)
+              ;; Section format directly returned by a function.  Add
+              ;; placeholder for contents.
+              ((stringp sec) (concat sec "\n%s"))
+              ;; (numbered-section . unnumbered-section)
+              ((not (consp (cdr sec)))
+               (concat (funcall (if numberedp #'car #'cdr) sec) "\n%s"))
+              ;; (numbered-open numbered-close)
+              ((= (length sec) 2)
+               (when numberedp (concat (car sec) "\n%s" (nth 1 sec))))
+              ;; (num-in num-out no-num-in no-num-out)
+              ((= (length sec) 4)
+               (if numberedp (concat (car sec) "\n%s" (nth 1 sec))
+                 (concat (nth 2 sec) "\n%s" (nth 3 sec)))))))
+          (text (org-export-data (org-element-property :title headline) info))
+          (todo
+           (and (plist-get info :with-todo-keywords)
+                (let ((todo (org-element-property :todo-keyword headline)))
+                  (and todo (org-export-data todo info)))))
+          (todo-type (and todo (org-element-property :todo-type headline)))
+          (tags (and (plist-get info :with-tags)
+                     (org-export-get-tags headline info)))
+          (priority (and (plist-get info :with-priority)
+                         (org-element-property :priority headline)))
+          ;; Create the headline text along with a no-tag version.
+          ;; The latter is required to remove tags from toc.
+          (full-text (funcall org-latex-format-headline-function
+                              todo todo-type priority text tags))
+          ;; Associate \label to the headline for internal links.
+          (headline-label
+           (format "\\label{sec-%s}\n"
+                   (mapconcat 'number-to-string
+                              (org-export-get-headline-number headline info)
+                              "-")))
+          (pre-blanks
+           (make-string (org-element-property :pre-blank headline) 10)))
+      (if (or (not section-fmt) (org-export-low-level-p headline info))
+         ;; This is a deep sub-tree: export it as a list item.  Also
+         ;; export as items headlines for which no section format has
+         ;; been found.
+         (let ((low-level-body
+                (concat
+                 ;; If headline is the first sibling, start a list.
+                 (when (org-export-first-sibling-p headline info)
+                   (format "\\begin{%s}\n" (if numberedp 'enumerate 'itemize)))
+                 ;; Itemize headline
+                 "\\item " full-text "\n" headline-label pre-blanks contents)))
+           ;; If headline is not the last sibling simply return
+           ;; LOW-LEVEL-BODY.  Otherwise, also close the list, before
+           ;; any blank line.
+           (if (not (org-export-last-sibling-p headline info)) low-level-body
+             (replace-regexp-in-string
+              "[ \t\n]*\\'"
+              (format "\n\\\\end{%s}" (if numberedp 'enumerate 'itemize))
+              low-level-body)))
+       ;; This is a standard headline.  Export it as a section.  Add
+       ;; an alternative heading when possible, and when this is not
+       ;; identical to the usual heading.
+       (let ((opt-title
+              (funcall org-latex-format-headline-function
+                       todo todo-type priority
+                       (org-export-data
+                        (org-export-get-alt-title headline info) info)
+                       (and (eq (plist-get info :with-tags) t) tags))))
+         (if (and numberedp opt-title
+                  (not (equal opt-title full-text))
+                  (string-match "\\`\\\\\\(.*?[^*]\\){" section-fmt))
+             (format (replace-match "\\1[%s]" nil nil section-fmt 1)
+                     ;; Replace square brackets with parenthesis
+                     ;; since square brackets are not supported in
+                     ;; optional arguments.
+                     (replace-regexp-in-string
+                      "\\[" "(" (replace-regexp-in-string "\\]" ")" opt-title))
+                     full-text
+                     (concat headline-label pre-blanks contents))
+           ;; Impossible to add an alternative heading.  Fallback to
+           ;; regular sectioning format string.
+           (format section-fmt full-text
+                   (concat headline-label pre-blanks contents))))))))
+
+(defun org-latex-format-headline-default-function
+  (todo todo-type priority text tags)
+  "Default format function for a headline.
+See `org-latex-format-headline-function' for details."
+  (concat
+   (and todo (format "{\\bfseries\\sffamily %s} " todo))
+   (and priority (format "\\framebox{\\#%c} " priority))
+   text
+   (and tags
+       (format "\\hfill{}\\textsc{%s}" (mapconcat 'identity tags ":")))))
+
+
+;;;; Horizontal Rule
+
+(defun org-latex-horizontal-rule (horizontal-rule contents info)
+  "Transcode an HORIZONTAL-RULE object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((attr (org-export-read-attribute :attr_latex horizontal-rule))
+       (prev (org-export-get-previous-element horizontal-rule info)))
+    (concat
+     ;; Make sure the rule doesn't start at the end of the current
+     ;; line by separating it with a blank line from previous element.
+     (when (and prev
+               (let ((prev-blank (org-element-property :post-blank prev)))
+                 (or (not prev-blank) (zerop prev-blank))))
+       "\n")
+     (org-latex--wrap-label
+      horizontal-rule
+      (format "\\rule{%s}{%s}"
+             (or (plist-get attr :width) "\\linewidth")
+             (or (plist-get attr :thickness) "0.5pt"))))))
+
+
+;;;; Inline Src Block
+
+(defun org-latex-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((code (org-element-property :value inline-src-block))
+        (separator (org-latex--find-verb-separator code)))
+    (cond
+     ;; Do not use a special package: transcode it verbatim.
+     ((not org-latex-listings)
+      (concat "\\verb" separator code separator))
+     ;; Use minted package.
+     ((eq org-latex-listings 'minted)
+      (let* ((org-lang (org-element-property :language inline-src-block))
+            (mint-lang (or (cadr (assq (intern org-lang)
+                                       org-latex-minted-langs))
+                           org-lang))
+            (options (org-latex--make-option-string
+                      org-latex-minted-options)))
+       (concat (format "\\mint%s{%s}"
+                       (if (string= options "") "" (format "[%s]" options))
+                       mint-lang)
+               separator code separator)))
+     ;; Use listings package.
+     (t
+      ;; Maybe translate language's name.
+      (let* ((org-lang (org-element-property :language inline-src-block))
+            (lst-lang (or (cadr (assq (intern org-lang)
+                                      org-latex-listings-langs))
+                          org-lang))
+            (options (org-latex--make-option-string
+                      (append org-latex-listings-options
+                              `(("language" ,lst-lang))))))
+       (concat (format "\\lstinline[%s]" options)
+               separator code separator))))))
+
+
+;;;; Inlinetask
+
+(defun org-latex-inlinetask (inlinetask contents info)
+  "Transcode an INLINETASK element from Org to LaTeX.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((title (org-export-data (org-element-property :title inlinetask) info))
+       (todo (and (plist-get info :with-todo-keywords)
+                  (let ((todo (org-element-property :todo-keyword inlinetask)))
+                    (and todo (org-export-data todo info)))))
+       (todo-type (org-element-property :todo-type inlinetask))
+       (tags (and (plist-get info :with-tags)
+                  (org-export-get-tags inlinetask info)))
+       (priority (and (plist-get info :with-priority)
+                      (org-element-property :priority inlinetask))))
+    ;; If `org-latex-format-inlinetask-function' is provided, call it
+    ;; with appropriate arguments.
+    (if (functionp org-latex-format-inlinetask-function)
+       (funcall org-latex-format-inlinetask-function
+                todo todo-type priority title tags contents)
+      ;; Otherwise, use a default template.
+      (org-latex--wrap-label
+       inlinetask
+       (let ((full-title
+             (concat
+              (when todo (format "\\textbf{\\textsf{\\textsc{%s}}} " todo))
+              (when priority (format "\\framebox{\\#%c} " priority))
+              title
+              (when tags (format "\\hfill{}\\textsc{:%s:}"
+                                 (mapconcat 'identity tags ":"))))))
+        (format (concat "\\begin{center}\n"
+                        "\\fbox{\n"
+                        "\\begin{minipage}[c]{.6\\textwidth}\n"
+                        "%s\n\n"
+                        "\\rule[.8em]{\\textwidth}{2pt}\n\n"
+                        "%s"
+                        "\\end{minipage}\n"
+                        "}\n"
+                        "\\end{center}")
+                full-title contents))))))
+
+
+;;;; Italic
+
+(defun org-latex-italic (italic contents info)
+  "Transcode ITALIC from Org to LaTeX.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (org-latex--text-markup contents 'italic))
+
+
+;;;; Item
+
+(defun org-latex-item (item contents info)
+  "Transcode an ITEM element from Org to LaTeX.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((counter
+         (let ((count (org-element-property :counter item))
+               (level
+                ;; Determine level of current item to determine the
+                ;; correct LaTeX counter to use (enumi, enumii...).
+                (let ((parent item) (level 0))
+                  (while (memq (org-element-type
+                                (setq parent (org-export-get-parent parent)))
+                               '(plain-list item))
+                    (when (and (eq (org-element-type parent) 'plain-list)
+                               (eq (org-element-property :type parent)
+                                   'ordered))
+                      (incf level)))
+                  level)))
+           (and count
+                (< level 5)
+                (format "\\setcounter{enum%s}{%s}\n"
+                        (nth (1- level) '("i" "ii" "iii" "iv"))
+                        (1- count)))))
+        (checkbox (case (org-element-property :checkbox item)
+                    (on "$\\boxtimes$ ")
+                    (off "$\\square$ ")
+                    (trans "$\\boxminus$ ")))
+        (tag (let ((tag (org-element-property :tag item)))
+               ;; Check-boxes must belong to the tag.
+               (and tag (format "[{%s}] "
+                                (concat checkbox
+                                        (org-export-data tag info)))))))
+    (concat counter "\\item" (or tag (concat " " checkbox))
+           (and contents (org-trim contents))
+           ;; If there are footnotes references in tag, be sure to
+           ;; add their definition at the end of the item.  This
+           ;; workaround is necessary since "\footnote{}" command is
+           ;; not supported in tags.
+           (and tag
+                (org-latex--delayed-footnotes-definitions
+                 (org-element-property :tag item) info)))))
+
+
+;;;; Keyword
+
+(defun org-latex-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "LATEX") value)
+     ((string= key "INDEX") (format "\\index{%s}" value))
+     ((string= key "TOC")
+      (let ((value (downcase value)))
+       (cond
+        ((string-match "\\<headlines\\>" value)
+         (let ((depth (or (and (string-match "[0-9]+" value)
+                               (string-to-number (match-string 0 value)))
+                          (plist-get info :with-toc))))
+           (concat
+            (when (wholenump depth)
+              (format "\\setcounter{tocdepth}{%s}\n" depth))
+            "\\tableofcontents")))
+        ((string= "tables" value) "\\listoftables")
+        ((string= "listings" value)
+         (cond
+          ((eq org-latex-listings 'minted) "\\listoflistings")
+          (org-latex-listings "\\lstlistoflistings")
+          ;; At the moment, src blocks with a caption are wrapped
+          ;; into a figure environment.
+          (t "\\listoffigures")))))))))
+
+
+;;;; Latex Environment
+
+(defun org-latex-latex-environment (latex-environment contents info)
+  "Transcode a LATEX-ENVIRONMENT element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (plist-get info :with-latex)
+    (let ((label (org-element-property :name latex-environment))
+         (value (org-remove-indentation
+                 (org-element-property :value latex-environment))))
+      (if (not (org-string-nw-p label)) value
+       ;; Environment is labeled: label must be within the environment
+       ;; (otherwise, a reference pointing to that element will count
+       ;; the section instead).
+       (with-temp-buffer
+         (insert value)
+         (goto-char (point-min))
+         (forward-line)
+         (insert
+          (format "\\label{%s}\n" (org-export-solidify-link-text label)))
+         (buffer-string))))))
+
+
+;;;; Latex Fragment
+
+(defun org-latex-latex-fragment (latex-fragment contents info)
+  "Transcode a LATEX-FRAGMENT object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (plist-get info :with-latex)
+    (org-element-property :value latex-fragment)))
+
+
+;;;; Line Break
+
+(defun org-latex-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  "\\\\\n")
+
+
+;;;; Link
+
+(defun org-latex--inline-image (link info)
+  "Return LaTeX code for an inline image.
+LINK is the link pointing to the inline image.  INFO is a plist
+used as a communication channel."
+  (let* ((parent (org-export-get-parent-element link))
+        (path (let ((raw-path (org-element-property :path link)))
+                (if (not (file-name-absolute-p raw-path)) raw-path
+                  (expand-file-name raw-path))))
+        (filetype (file-name-extension path))
+        (caption (org-latex--caption/label-string parent info))
+        ;; Retrieve latex attributes from the element around.
+        (attr (org-export-read-attribute :attr_latex parent))
+        (float (let ((float (plist-get attr :float)))
+                 (cond ((and (not float) (plist-member attr :float)) nil)
+                       ((string= float "wrap") 'wrap)
+                       ((string= float "multicolumn") 'multicolumn)
+                       ((or float
+                            (org-element-property :caption parent)
+                            (org-string-nw-p (plist-get attr :caption)))
+                        'figure))))
+        (placement
+         (let ((place (plist-get attr :placement)))
+           (cond (place (format "%s" place))
+                 ((eq float 'wrap) "{l}{0.5\\textwidth}")
+                 ((eq float 'figure)
+                  (format "[%s]" org-latex-default-figure-position))
+                 (t ""))))
+        (comment-include (if (plist-get attr :comment-include) "%" ""))
+        ;; It is possible to specify width and height in the
+        ;; ATTR_LATEX line, and also via default variables.
+        (width (cond ((plist-get attr :width))
+                     ((plist-get attr :height) "")
+                     ((eq float 'wrap) "0.48\\textwidth")
+                     (t org-latex-image-default-width)))
+        (height (cond ((plist-get attr :height))
+                      ((or (plist-get attr :width)
+                           (memq float '(figure wrap))) "")
+                      (t org-latex-image-default-height)))
+        (options (let ((opt (or (plist-get attr :options)
+                                org-latex-image-default-option)))
+                   (if (not (string-match "\\`\\[\\(.*\\)\\]\\'" opt)) opt
+                     (match-string 1 opt))))
+        image-code)
+    (if (member filetype '("tikz" "pgf"))
+       ;; For tikz images:
+       ;; - use \input to read in image file.
+       ;; - if options are present, wrap in a tikzpicture environment.
+       ;; - if width or height are present, use \resizebox to change
+       ;;   the image size.
+       (progn
+         (setq image-code (format "\\input{%s}" path))
+         (when (org-string-nw-p options)
+           (setq image-code
+                 (format "\\begin{tikzpicture}[%s]\n%s\n\\end{tikzpicture}"
+                         options
+                         image-code)))
+         (when (or (org-string-nw-p width) (org-string-nw-p height))
+           (setq image-code (format "\\resizebox{%s}{%s}{%s}"
+                                    (if (org-string-nw-p width) width "!")
+                                    (if (org-string-nw-p height) height "!")
+                                    image-code))))
+      ;; For other images:
+      ;; - add width and height to options.
+      ;; - include the image with \includegraphics.
+      (when (org-string-nw-p width)
+       (setq options (concat options ",width=" width)))
+      (when (org-string-nw-p height)
+       (setq options (concat options ",height=" height)))
+      (setq image-code
+           (format "\\includegraphics%s{%s}"
+                   (cond ((not (org-string-nw-p options)) "")
+                         ((= (aref options 0) ?,)
+                          (format "[%s]"(substring options 1)))
+                         (t (format "[%s]" options)))
+                   path))
+      (when (equal filetype "svg")
+       (setq image-code (replace-regexp-in-string "^\\\\includegraphics"
+                                                  "\\includesvg"
+                                                  image-code
+                                                  nil t))
+       (setq image-code (replace-regexp-in-string "\\.svg}"
+                                                  "}"
+                                                  image-code
+                                                  nil t))))
+    ;; Return proper string, depending on FLOAT.
+    (case float
+      (wrap (format "\\begin{wrapfigure}%s
+\\centering
+%s%s
+%s\\end{wrapfigure}" placement comment-include image-code caption))
+      (multicolumn (format "\\begin{figure*}%s
+\\centering
+%s%s
+%s\\end{figure*}" placement comment-include image-code caption))
+      (figure (format "\\begin{figure}%s
+\\centering
+%s%s
+%s\\end{figure}" placement comment-include image-code caption))
+      (otherwise image-code))))
+
+(defun org-latex-link (link desc info)
+  "Transcode a LINK object from Org to LaTeX.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information.  See
+`org-export-data'."
+  (let* ((type (org-element-property :type link))
+        (raw-path (org-element-property :path link))
+        ;; Ensure DESC really exists, or set it to nil.
+        (desc (and (not (string= desc "")) desc))
+        (imagep (org-export-inline-image-p
+                 link org-latex-inline-image-rules))
+        (path (cond
+               ((member type '("http" "https" "ftp" "mailto"))
+                (concat type ":" raw-path))
+               ((string= type "file")
+                (if (not (file-name-absolute-p raw-path)) raw-path
+                  (concat "file://" (expand-file-name raw-path))))
+               (t raw-path)))
+        protocol)
+    (cond
+     ;; Image file.
+     (imagep (org-latex--inline-image link info))
+     ;; Radio link: Transcode target's contents and use them as link's
+     ;; description.
+     ((string= type "radio")
+      (let ((destination (org-export-resolve-radio-link link info)))
+       (when destination
+         (format "\\hyperref[%s]{%s}"
+                 (org-export-solidify-link-text path)
+                 (org-export-data (org-element-contents destination) info)))))
+     ;; Links pointing to a headline: Find destination and build
+     ;; appropriate referencing command.
+     ((member type '("custom-id" "fuzzy" "id"))
+      (let ((destination (if (string= type "fuzzy")
+                            (org-export-resolve-fuzzy-link link info)
+                          (org-export-resolve-id-link link info))))
+       (case (org-element-type destination)
+         ;; Id link points to an external file.
+         (plain-text
+          (if desc (format "\\href{%s}{%s}" destination desc)
+            (format "\\url{%s}" destination)))
+         ;; Fuzzy link points nowhere.
+         ('nil
+          (format org-latex-link-with-unknown-path-format
+                  (or desc
+                      (org-export-data
+                       (org-element-property :raw-link link) info))))
+         ;; LINK points to a headline.  If headlines are numbered
+         ;; and the link has no description, display headline's
+         ;; number.  Otherwise, display description or headline's
+         ;; title.
+         (headline
+          (let ((label
+                 (format "sec-%s"
+                         (mapconcat
+                          'number-to-string
+                          (org-export-get-headline-number destination info)
+                          "-"))))
+            (if (and (plist-get info :section-numbers) (not desc))
+                (format "\\ref{%s}" label)
+              (format "\\hyperref[%s]{%s}" label
+                      (or desc
+                          (org-export-data
+                           (org-element-property :title destination) info))))))
+          ;; Fuzzy link points to a target.  Do as above.
+         (otherwise
+          (let ((path (org-export-solidify-link-text path)))
+            (if (not desc) (format "\\ref{%s}" path)
+              (format "\\hyperref[%s]{%s}" path desc)))))))
+     ;; Coderef: replace link with the reference name or the
+     ;; equivalent line number.
+     ((string= type "coderef")
+      (format (org-export-get-coderef-format path desc)
+             (org-export-resolve-coderef path info)))
+     ;; Link type is handled by a special function.
+     ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
+      (funcall protocol (org-link-unescape path) desc 'latex))
+     ;; External link with a description part.
+     ((and path desc) (format "\\href{%s}{%s}" path desc))
+     ;; External link without a description part.
+     (path (format "\\url{%s}" path))
+     ;; No path, only description.  Try to do something useful.
+     (t (format org-latex-link-with-unknown-path-format desc)))))
+
+
+;;;; Paragraph
+
+(defun org-latex-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to LaTeX.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  contents)
+
+
+;;;; Plain List
+
+(defun org-latex-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to LaTeX.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  (let* ((type (org-element-property :type plain-list))
+        (attr (org-export-read-attribute :attr_latex plain-list))
+        (latex-type (let ((env (plist-get attr :environment)))
+                      (cond (env (format "%s" env))
+                            ((eq type 'ordered) "enumerate")
+                            ((eq type 'unordered) "itemize")
+                            ((eq type 'descriptive) "description")))))
+    (org-latex--wrap-label
+     plain-list
+     (format "\\begin{%s}%s\n%s\\end{%s}"
+            latex-type
+            ;; Put optional arguments, if any inside square brackets
+            ;; when necessary.
+            (let ((options (format "%s" (or (plist-get attr :options) ""))))
+              (cond ((equal options "") "")
+                    ((string-match "\\`\\[.*\\]\\'" options) options)
+                    (t (format "[%s]" options))))
+            contents
+            latex-type))))
+
+
+;;;; Plain Text
+
+(defun org-latex-plain-text (text info)
+  "Transcode a TEXT string from Org to LaTeX.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  (let ((specialp (plist-get info :with-special-strings))
+       (output text))
+    ;; Protect %, #, &, $, _, { and }.
+    (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}_]\\)" output)
+      (setq output
+           (replace-match
+            (format "\\%s" (match-string 2 output)) nil t output 2)))
+    ;; Protect ^.
+    (setq output
+         (replace-regexp-in-string
+          "\\([^\\]\\|^\\)\\(\\^\\)" "\\\\^{}" output nil nil 2))
+    ;; Protect \.  If special strings are used, be careful not to
+    ;; protect "\" in "\-" constructs.
+    (let ((symbols (if specialp "-%$#&{}^_\\" "%$#&{}^_\\")))
+      (setq output
+           (replace-regexp-in-string
+            (format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols)
+            "$\\backslash$" output nil t 1)))
+    ;; Protect ~.
+    (setq output
+         (replace-regexp-in-string
+          "\\([^\\]\\|^\\)\\(~\\)" "\\textasciitilde{}" output nil t 2))
+    ;; Activate smart quotes.  Be sure to provide original TEXT string
+    ;; since OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output (org-export-activate-smart-quotes output :latex info text)))
+    ;; LaTeX into \LaTeX{} and TeX into \TeX{}.
+    (let ((case-fold-search nil)
+         (start 0))
+      (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" output start)
+       (setq output (replace-match
+                     (format "\\%s{}" (match-string 1 output)) nil t output)
+             start (match-end 0))))
+    ;; Convert special strings.
+    (when specialp
+      (setq output
+           (replace-regexp-in-string "\\.\\.\\." "\\ldots{}" output nil t)))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string
+                   "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" output)))
+    ;; Return value.
+    output))
+
+
+;;;; Planning
+
+(defun org-latex-planning (planning contents info)
+  "Transcode a PLANNING element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "\\noindent"
+   (mapconcat
+    'identity
+    (delq nil
+         (list
+          (let ((closed (org-element-property :closed planning)))
+            (when closed
+              (concat
+               (format "\\textbf{%s} " org-closed-string)
+               (format org-latex-inactive-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value closed))))))
+          (let ((deadline (org-element-property :deadline planning)))
+            (when deadline
+              (concat
+               (format "\\textbf{%s} " org-deadline-string)
+               (format org-latex-active-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value deadline))))))
+          (let ((scheduled (org-element-property :scheduled planning)))
+            (when scheduled
+              (concat
+               (format "\\textbf{%s} " org-scheduled-string)
+               (format org-latex-active-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value scheduled))))))))
+    " ")
+   "\\\\"))
+
+
+;;;; Quote Block
+
+(defun org-latex-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (org-latex--wrap-label
+   quote-block
+   (format "\\begin{quote}\n%s\\end{quote}" contents)))
+
+
+;;;; Quote Section
+
+(defun org-latex-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((value (org-remove-indentation
+               (org-element-property :value quote-section))))
+    (when value (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
+
+
+;;;; Radio Target
+
+(defun org-latex-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object from Org to LaTeX.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  (format "\\label{%s}%s"
+         (org-export-solidify-link-text
+          (org-element-property :value radio-target))
+         text))
+
+
+;;;; Section
+
+(defun org-latex-section (section contents info)
+  "Transcode a SECTION element from Org to LaTeX.
+CONTENTS holds the contents of the section.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;;; Special Block
+
+(defun org-latex-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((type (downcase (org-element-property :type special-block)))
+       (opt (org-export-read-attribute :attr_latex special-block :options)))
+    (concat (format "\\begin{%s}%s\n" type (or opt ""))
+           ;; Insert any label or caption within the block
+           ;; (otherwise, a reference pointing to that element will
+           ;; count the section instead).
+           (org-latex--caption/label-string special-block info)
+           contents
+           (format "\\end{%s}" type))))
+
+
+;;;; Src Block
+
+(defun org-latex-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to LaTeX.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (when (org-string-nw-p (org-element-property :value src-block))
+    (let* ((lang (org-element-property :language src-block))
+          (caption (org-element-property :caption src-block))
+          (label (org-element-property :name src-block))
+          (custom-env (and lang
+                           (cadr (assq (intern lang)
+                                       org-latex-custom-lang-environments))))
+          (num-start (case (org-element-property :number-lines src-block)
+                       (continued (org-export-get-loc src-block info))
+                       (new 0)))
+          (retain-labels (org-element-property :retain-labels src-block))
+          (attributes (org-export-read-attribute :attr_latex src-block))
+          (float (plist-get attributes :float)))
+      (cond
+       ;; Case 1.  No source fontification.
+       ((not org-latex-listings)
+       (let* ((caption-str (org-latex--caption/label-string src-block info))
+              (float-env
+               (cond ((and (not float) (plist-member attributes :float)) "%s")
+                     ((string= "multicolumn" float)
+                      (format "\\begin{figure*}[%s]\n%%s%s\n\\end{figure*}"
+                              org-latex-default-figure-position
+                              caption-str))
+                     ((or caption float)
+                      (format "\\begin{figure}[H]\n%%s%s\n\\end{figure}"
+                              caption-str))
+                     (t "%s"))))
+         (format
+          float-env
+          (concat (format "\\begin{verbatim}\n%s\\end{verbatim}"
+                          (org-export-format-code-default src-block info))))))
+       ;; Case 2.  Custom environment.
+       (custom-env (format "\\begin{%s}\n%s\\end{%s}\n"
+                          custom-env
+                          (org-export-format-code-default src-block info)
+                          custom-env))
+       ;; Case 3.  Use minted package.
+       ((eq org-latex-listings 'minted)
+       (let* ((caption-str (org-latex--caption/label-string src-block info))
+              (float-env
+               (cond ((and (not float) (plist-member attributes :float)) "%s")
+                     ((string= "multicolumn" float)
+                      (format "\\begin{listing*}\n%%s\n%s\\end{listing*}"
+                              caption-str))
+                     ((or caption float)
+                      (format "\\begin{listing}[H]\n%%s\n%s\\end{listing}"
+                              caption-str))
+                     (t "%s")))
+              (body
+               (format
+                "\\begin{minted}[%s]{%s}\n%s\\end{minted}"
+                ;; Options.
+                (org-latex--make-option-string
+                 (if (or (not num-start)
+                         (assoc "linenos" org-latex-minted-options))
+                     org-latex-minted-options
+                   (append
+                    `(("linenos")
+                      ("firstnumber" ,(number-to-string (1+ num-start))))
+                    org-latex-minted-options)))
+                ;; Language.
+                (or (cadr (assq (intern lang) org-latex-minted-langs)) lang)
+                ;; Source code.
+                (let* ((code-info (org-export-unravel-code src-block))
+                       (max-width
+                        (apply 'max
+                               (mapcar 'length
+                                       (org-split-string (car code-info)
+                                                         "\n")))))
+                  (org-export-format-code
+                   (car code-info)
+                   (lambda (loc num ref)
+                     (concat
+                      loc
+                      (when ref
+                        ;; Ensure references are flushed to the right,
+                        ;; separated with 6 spaces from the widest line
+                        ;; of code.
+                        (concat (make-string (+ (- max-width (length loc)) 6)
+                                             ?\s)
+                                (format "(%s)" ref)))))
+                   nil (and retain-labels (cdr code-info)))))))
+         ;; Return value.
+         (format float-env body)))
+       ;; Case 4.  Use listings package.
+       (t
+       (let ((lst-lang
+              (or (cadr (assq (intern lang) org-latex-listings-langs)) lang))
+             (caption-str
+              (when caption
+                (let ((main (org-export-get-caption src-block))
+                      (secondary (org-export-get-caption src-block t)))
+                  (if (not secondary)
+                      (format "{%s}" (org-export-data main info))
+                    (format "{[%s]%s}"
+                            (org-export-data secondary info)
+                            (org-export-data main info)))))))
+         (concat
+          ;; Options.
+          (format
+           "\\lstset{%s}\n"
+           (org-latex--make-option-string
+            (append
+             org-latex-listings-options
+             (cond
+              ((and (not float) (plist-member attributes :float)) nil)
+              ((string= "multicolumn" float) '(("float" "*")))
+              ((and float (not (assoc "float" org-latex-listings-options)))
+               `(("float" ,org-latex-default-figure-position))))
+             `(("language" ,lst-lang))
+             (when label `(("label" ,label)))
+             (when caption-str `(("caption" ,caption-str)))
+             (cond ((assoc "numbers" org-latex-listings-options) nil)
+                   ((not num-start) '(("numbers" "none")))
+                   ((zerop num-start) '(("numbers" "left")))
+                   (t `(("numbers" "left")
+                        ("firstnumber"
+                         ,(number-to-string (1+ num-start)))))))))
+          ;; Source code.
+          (format
+           "\\begin{lstlisting}\n%s\\end{lstlisting}"
+           (let* ((code-info (org-export-unravel-code src-block))
+                  (max-width
+                   (apply 'max
+                          (mapcar 'length
+                                  (org-split-string (car code-info) "\n")))))
+             (org-export-format-code
+              (car code-info)
+              (lambda (loc num ref)
+                (concat
+                 loc
+                 (when ref
+                   ;; Ensure references are flushed to the right,
+                   ;; separated with 6 spaces from the widest line of
+                   ;; code
+                   (concat (make-string (+ (- max-width (length loc)) 6) ? )
+                           (format "(%s)" ref)))))
+              nil (and retain-labels (cdr code-info))))))))))))
+
+
+;;;; Statistics Cookie
+
+(defun org-latex-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (replace-regexp-in-string
+   "%" "\\%" (org-element-property :value statistics-cookie) nil t))
+
+
+;;;; Strike-Through
+
+(defun org-latex-strike-through (strike-through contents info)
+  "Transcode STRIKE-THROUGH from Org to LaTeX.
+CONTENTS is the text with strike-through markup.  INFO is a plist
+holding contextual information."
+  (org-latex--text-markup contents 'strike-through))
+
+
+;;;; Subscript
+
+(defun org-latex--script-size (object info)
+  "Transcode a subscript or superscript object.
+OBJECT is an Org object.  INFO is a plist used as a communication
+channel."
+  (let ((in-script-p
+        ;; Non-nil if object is already in a sub/superscript.
+        (let ((parent object))
+          (catch 'exit
+            (while (setq parent (org-export-get-parent parent))
+              (let ((type (org-element-type parent)))
+                (cond ((memq type '(subscript superscript))
+                       (throw 'exit t))
+                      ((memq type org-element-all-elements)
+                       (throw 'exit nil))))))))
+       (type (org-element-type object))
+       (output ""))
+    (org-element-map (org-element-contents object)
+       (cons 'plain-text org-element-all-objects)
+      (lambda (obj)
+       (case (org-element-type obj)
+         ((entity latex-fragment)
+          (let ((data (org-trim (org-export-data obj info))))
+            (string-match
+             "\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'"
+             data)
+            (setq output
+                  (concat output
+                          (match-string 1 data)
+                          (let ((blank (org-element-property :post-blank obj)))
+                            (and blank (> blank 0) "\\ "))))))
+         (plain-text
+          (setq output
+                (format "%s\\text{%s}" output (org-export-data obj info))))
+         (otherwise
+          (setq output
+                (concat output
+                        (org-export-data obj info)
+                        (let ((blank (org-element-property :post-blank obj)))
+                          (and blank (> blank 0) "\\ ")))))))
+      info nil org-element-recursive-objects)
+    ;; Result.  Do not wrap into math mode if already in a subscript
+    ;; or superscript.  Do not wrap into curly brackets if OUTPUT is
+    ;; a single character.  Also merge consecutive subscript and
+    ;; superscript into the same math snippet.
+    (concat (and (not in-script-p)
+                (let ((prev (org-export-get-previous-element object info)))
+                  (or (not prev)
+                      (not (eq (org-element-type prev)
+                               (if (eq type 'subscript) 'superscript
+                                 'subscript)))
+                      (let ((blank (org-element-property :post-blank prev)))
+                        (and blank (> blank 0)))))
+                "$")
+           (if (eq (org-element-type object) 'subscript) "_" "^")
+           (and (> (length output) 1) "{")
+           output
+           (and (> (length output) 1) "}")
+           (and (not in-script-p)
+                (or (let ((blank (org-element-property :post-blank object)))
+                      (and blank (> blank 0)))
+                    (not (eq (org-element-type
+                              (org-export-get-next-element object info))
+                             (if (eq type 'subscript) 'superscript
+                               'subscript))))
+                "$"))))
+
+(defun org-latex-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to LaTeX.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (org-latex--script-size subscript info))
+
+
+;;;; Superscript
+
+(defun org-latex-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to LaTeX.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (org-latex--script-size superscript info))
+
+
+;;;; Table
+;;
+;; `org-latex-table' is the entry point for table transcoding.  It
+;; takes care of tables with a "verbatim" mode.  Otherwise, it
+;; delegates the job to either `org-latex--table.el-table',
+;; `org-latex--org-table' or `org-latex--math-table' functions,
+;; depending of the type of the table and the mode requested.
+;;
+;; `org-latex--align-string' is a subroutine used to build alignment
+;; string for Org tables.
+
+(defun org-latex-table (table contents info)
+  "Transcode a TABLE element from Org to LaTeX.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (if (eq (org-element-property :type table) 'table.el)
+      ;; "table.el" table.  Convert it using appropriate tools.
+      (org-latex--table.el-table table info)
+    (let ((type (or (org-export-read-attribute :attr_latex table :mode)
+                   org-latex-default-table-mode)))
+      (cond
+       ;; Case 1: Verbatim table.
+       ((string= type "verbatim")
+       (format "\\begin{verbatim}\n%s\n\\end{verbatim}"
+               ;; Re-create table, without affiliated keywords.
+               (org-trim (org-element-interpret-data
+                          `(table nil ,@(org-element-contents table))))))
+       ;; Case 2: Matrix.
+       ((or (string= type "math") (string= type "inline-math"))
+       (org-latex--math-table table info))
+       ;; Case 3: Standard table.
+       (t (concat (org-latex--org-table table contents info)
+                 ;; When there are footnote references within the
+                 ;; table, insert their definition just after it.
+                 (org-latex--delayed-footnotes-definitions table info)))))))
+
+(defun org-latex--align-string (table info)
+  "Return an appropriate LaTeX alignment string.
+TABLE is the considered table.  INFO is a plist used as
+a communication channel."
+  (or (org-export-read-attribute :attr_latex table :align)
+      (let (align)
+       ;; Extract column groups and alignment from first (non-rule)
+       ;; row.
+       (org-element-map
+           (org-element-map table 'table-row
+             (lambda (row)
+               (and (eq (org-element-property :type row) 'standard) row))
+             info 'first-match)
+           'table-cell
+         (lambda (cell)
+           (let ((borders (org-export-table-cell-borders cell info)))
+             ;; Check left border for the first cell only.
+             (when (and (memq 'left borders) (not align))
+               (push "|" align))
+             (push (case (org-export-table-cell-alignment cell info)
+                     (left "l")
+                     (right "r")
+                     (center "c"))
+                   align)
+             (when (memq 'right borders) (push "|" align))))
+         info)
+       (apply 'concat (nreverse align)))))
+
+(defun org-latex--org-table (table contents info)
+  "Return appropriate LaTeX code for an Org table.
+
+TABLE is the table type element to transcode.  CONTENTS is its
+contents, as a string.  INFO is a plist used as a communication
+channel.
+
+This function assumes TABLE has `org' as its `:type' property and
+`table' as its `:mode' attribute."
+  (let* ((caption (org-latex--caption/label-string table info))
+        (attr (org-export-read-attribute :attr_latex table))
+        ;; Determine alignment string.
+        (alignment (org-latex--align-string table info))
+        ;; Determine environment for the table: longtable, tabular...
+        (table-env (or (plist-get attr :environment)
+                       org-latex-default-table-environment))
+        ;; If table is a float, determine environment: table, table*
+        ;; or sidewaystable.
+        (float-env (unless (member table-env '("longtable" "longtabu"))
+                     (let ((float (plist-get attr :float)))
+                       (cond
+                        ((and (not float) (plist-member attr :float)) nil)
+                        ((string= float "sidewaystable") "sidewaystable")
+                        ((string= float "multicolumn") "table*")
+                        ((or float
+                             (org-element-property :caption table)
+                             (org-string-nw-p (plist-get attr :caption)))
+                         "table")))))
+        ;; Extract others display options.
+        (fontsize (let ((font (plist-get attr :font)))
+                    (and font (concat font "\n"))))
+        (width (plist-get attr :width))
+        (spreadp (plist-get attr :spread))
+        (placement (or (plist-get attr :placement)
+                       (format "[%s]" org-latex-default-figure-position)))
+        (centerp (if (plist-member attr :center) (plist-get attr :center)
+                   org-latex-tables-centered)))
+    ;; Prepare the final format string for the table.
+    (cond
+     ;; Longtable.
+     ((equal "longtable" table-env)
+      (concat (and fontsize (concat "{" fontsize))
+             (format "\\begin{longtable}{%s}\n" alignment)
+             (and org-latex-table-caption-above
+                  (org-string-nw-p caption)
+                  (concat caption "\\\\\n"))
+             contents
+             (and (not org-latex-table-caption-above)
+                  (org-string-nw-p caption)
+                  (concat caption "\\\\\n"))
+             "\\end{longtable}\n"
+             (and fontsize "}")))
+     ;; Longtabu
+     ((equal "longtabu" table-env)
+      (concat (and fontsize (concat "{" fontsize))
+             (format "\\begin{longtabu}%s{%s}\n"
+                     (if width
+                         (format " %s %s "
+                                 (if spreadp "spread" "to") width) "")
+                     alignment)
+             (and org-latex-table-caption-above
+                  (org-string-nw-p caption)
+                  (concat caption "\\\\\n"))
+             contents
+             (and (not org-latex-table-caption-above)
+                  (org-string-nw-p caption)
+                  (concat caption "\\\\\n"))
+             "\\end{longtabu}\n"
+             (and fontsize "}")))
+     ;; Others.
+     (t (concat (cond
+                (float-env
+                 (concat (format "\\begin{%s}%s\n" float-env placement)
+                         (if org-latex-table-caption-above caption "")
+                         (when centerp "\\centering\n")
+                         fontsize))
+                (centerp (concat "\\begin{center}\n" fontsize))
+                (fontsize (concat "{" fontsize)))
+               (cond ((equal "tabu" table-env)
+                      (format "\\begin{tabu}%s{%s}\n%s\\end{tabu}"
+                              (if width (format
+                                         (if spreadp " spread %s " " to %s ")
+                                         width) "")
+                              alignment
+                              contents))
+                     (t (format "\\begin{%s}%s{%s}\n%s\\end{%s}"
+                                table-env
+                                (if width (format "{%s}" width) "")
+                                alignment
+                                contents
+                                table-env)))
+               (cond
+                (float-env
+                 (concat (if org-latex-table-caption-above "" caption)
+                         (format "\n\\end{%s}" float-env)))
+                (centerp "\n\\end{center}")
+                (fontsize "}")))))))
+
+(defun org-latex--table.el-table (table info)
+  "Return appropriate LaTeX code for a table.el table.
+
+TABLE is the table type element to transcode.  INFO is a plist
+used as a communication channel.
+
+This function assumes TABLE has `table.el' as its `:type'
+property."
+  (require 'table)
+  ;; Ensure "*org-export-table*" buffer is empty.
+  (with-current-buffer (get-buffer-create "*org-export-table*")
+    (erase-buffer))
+  (let ((output (with-temp-buffer
+                 (insert (org-element-property :value table))
+                 (goto-char 1)
+                 (re-search-forward "^[ \t]*|[^|]" nil t)
+                 (table-generate-source 'latex "*org-export-table*")
+                 (with-current-buffer "*org-export-table*"
+                   (org-trim (buffer-string))))))
+    (kill-buffer (get-buffer "*org-export-table*"))
+    ;; Remove left out comments.
+    (while (string-match "^%.*\n" output)
+      (setq output (replace-match "" t t output)))
+    (let ((attr (org-export-read-attribute :attr_latex table)))
+      (when (plist-get attr :rmlines)
+       ;; When the "rmlines" attribute is provided, remove all hlines
+       ;; but the the one separating heading from the table body.
+       (let ((n 0) (pos 0))
+         (while (and (< (length output) pos)
+                     (setq pos (string-match "^\\\\hline\n?" output pos)))
+           (incf n)
+           (unless (= n 2) (setq output (replace-match "" nil nil output))))))
+      (let ((centerp (if (plist-member attr :center) (plist-get attr :center)
+                      org-latex-tables-centered)))
+       (if (not centerp) output
+         (format "\\begin{center}\n%s\n\\end{center}" output))))))
+
+(defun org-latex--math-table (table info)
+  "Return appropriate LaTeX code for a matrix.
+
+TABLE is the table type element to transcode.  INFO is a plist
+used as a communication channel.
+
+This function assumes TABLE has `org' as its `:type' property and
+`inline-math' or `math' as its `:mode' attribute.."
+  (let* ((caption (org-latex--caption/label-string table info))
+        (attr (org-export-read-attribute :attr_latex table))
+        (inlinep (equal (plist-get attr :mode) "inline-math"))
+        (env (or (plist-get attr :environment)
+                 org-latex-default-table-environment))
+        (contents
+         (mapconcat
+          (lambda (row)
+            ;; Ignore horizontal rules.
+            (when (eq (org-element-property :type row) 'standard)
+              ;; Return each cell unmodified.
+              (concat
+               (mapconcat
+                (lambda (cell)
+                  (substring (org-element-interpret-data cell) 0 -1))
+                (org-element-map row 'table-cell 'identity info) "&")
+               (or (cdr (assoc env org-latex-table-matrix-macros)) "\\\\")
+               "\n")))
+          (org-element-map table 'table-row 'identity info) ""))
+        ;; Variables related to math clusters (contiguous math tables
+        ;; of the same type).
+        (mode (org-export-read-attribute :attr_latex table :mode))
+        (prev (org-export-get-previous-element table info))
+        (next (org-export-get-next-element table info))
+        (same-mode-p
+         (lambda (table)
+           ;; Non-nil when TABLE has the same mode as current table.
+           (string= (or (org-export-read-attribute :attr_latex table :mode)
+                        org-latex-default-table-mode)
+                    mode))))
+    (concat
+     ;; Opening string.  If TABLE is in the middle of a table cluster,
+     ;; do not insert any.
+     (cond ((and prev
+                (eq (org-element-type prev) 'table)
+                (memq (org-element-property :post-blank prev) '(0 nil))
+                (funcall same-mode-p prev))
+           nil)
+          (inlinep "\\(")
+          ((org-string-nw-p caption) (concat "\\begin{equation}\n" caption))
+          (t "\\["))
+     ;; Prefix.
+     (or (plist-get attr :math-prefix) "")
+     ;; Environment.  Also treat special cases.
+     (cond ((equal env "array")
+           (let ((align (org-latex--align-string table info)))
+             (format "\\begin{array}{%s}\n%s\\end{array}" align contents)))
+          ((assoc env org-latex-table-matrix-macros)
+           (format "\\%s%s{\n%s}"
+                   env
+                   (or (plist-get attr :math-arguments) "")
+                   contents))
+          (t (format "\\begin{%s}\n%s\\end{%s}" env contents env)))
+     ;; Suffix.
+     (or (plist-get attr :math-suffix) "")
+     ;; Closing string.  If TABLE is in the middle of a table cluster,
+     ;; do not insert any.  If it closes such a cluster, be sure to
+     ;; close the cluster with a string matching the opening string.
+     (cond ((and next
+                (eq (org-element-type next) 'table)
+                (memq (org-element-property :post-blank table) '(0 nil))
+                (funcall same-mode-p next))
+           nil)
+          (inlinep "\\)")
+          ;; Find cluster beginning to know which environment to use.
+          ((let ((cluster-beg table) prev)
+             (while (and (setq prev (org-export-get-previous-element
+                                     cluster-beg info))
+                         (memq (org-element-property :post-blank prev)
+                               '(0 nil))
+                         (funcall same-mode-p prev))
+               (setq cluster-beg prev))
+             (and (or (org-element-property :caption cluster-beg)
+                      (org-element-property :name cluster-beg))
+                  "\n\\end{equation}")))
+          (t "\\]")))))
+
+
+;;;; Table Cell
+
+(defun org-latex-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL element from Org to LaTeX.
+CONTENTS is the cell contents.  INFO is a plist used as
+a communication channel."
+  (concat (if (and contents
+                  org-latex-table-scientific-notation
+                  (string-match orgtbl-exp-regexp contents))
+             ;; Use appropriate format string for scientific
+             ;; notation.
+             (format org-latex-table-scientific-notation
+                     (match-string 1 contents)
+                     (match-string 2 contents))
+           contents)
+         (when (org-export-get-next-element table-cell info) " & ")))
+
+
+;;;; Table Row
+
+(defun org-latex-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to LaTeX.
+CONTENTS is the contents of the row.  INFO is a plist used as
+a communication channel."
+  ;; Rules are ignored since table separators are deduced from
+  ;; borders of the current row.
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let* ((attr (org-export-read-attribute :attr_latex
+                                           (org-export-get-parent table-row)))
+          (longtablep (member (or (plist-get attr :environment)
+                                   org-latex-default-table-environment)
+                               '("longtable" "longtabu")))
+          (booktabsp (if (plist-member attr :booktabs)
+                         (plist-get attr :booktabs)
+                       org-latex-tables-booktabs))
+          ;; TABLE-ROW's borders are extracted from its first cell.
+          (borders (org-export-table-cell-borders
+                    (car (org-element-contents table-row)) info)))
+      (concat
+       ;; When BOOKTABS are activated enforce top-rule even when no
+       ;; hline was specifically marked.
+       (cond ((and booktabsp (memq 'top borders)) "\\toprule\n")
+            ((and (memq 'top borders) (memq 'above borders)) "\\hline\n"))
+       contents "\\\\\n"
+       (cond
+       ;; Special case for long tables. Define header and footers.
+       ((and longtablep (org-export-table-row-ends-header-p table-row info))
+        (format "%s
+\\endhead
+%s\\multicolumn{%d}{r}{Continued on next page} \\\\
+\\endfoot
+\\endlastfoot"
+                (if booktabsp "\\midrule" "\\hline")
+                (if booktabsp "\\midrule" "\\hline")
+                ;; Number of columns.
+                (cdr (org-export-table-dimensions
+                      (org-export-get-parent-table table-row) info))))
+       ;; When BOOKTABS are activated enforce bottom rule even when
+       ;; no hline was specifically marked.
+       ((and booktabsp (memq 'bottom borders)) "\\bottomrule")
+       ((and (memq 'bottom borders) (memq 'below borders)) "\\hline")
+       ((memq 'below borders) (if booktabsp "\\midrule" "\\hline")))))))
+
+
+;;;; Target
+
+(defun org-latex-target (target contents info)
+  "Transcode a TARGET object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format "\\label{%s}"
+         (org-export-solidify-link-text (org-element-property :value target))))
+
+
+;;;; Timestamp
+
+(defun org-latex-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((value (org-latex-plain-text
+               (org-timestamp-translate timestamp) info)))
+    (case (org-element-property :type timestamp)
+      ((active active-range) (format org-latex-active-timestamp-format value))
+      ((inactive inactive-range)
+       (format org-latex-inactive-timestamp-format value))
+      (otherwise (format org-latex-diary-timestamp-format value)))))
+
+
+;;;; Underline
+
+(defun org-latex-underline (underline contents info)
+  "Transcode UNDERLINE from Org to LaTeX.
+CONTENTS is the text with underline markup.  INFO is a plist
+holding contextual information."
+  (org-latex--text-markup contents 'underline))
+
+
+;;;; Verbatim
+
+(defun org-latex-verbatim (verbatim contents info)
+  "Transcode a VERBATIM object from Org to LaTeX.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-latex--text-markup (org-element-property :value verbatim) 'verbatim))
+
+
+;;;; Verse Block
+
+(defun org-latex-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to LaTeX.
+CONTENTS is verse block contents.  INFO is a plist holding
+contextual information."
+  (org-latex--wrap-label
+   verse-block
+   ;; In a verse environment, add a line break to each newline
+   ;; character and change each white space at beginning of a line
+   ;; into a space of 1 em.  Also change each blank line with
+   ;; a vertical space of 1 em.
+   (progn
+     (setq contents (replace-regexp-in-string
+                    "^ *\\\\\\\\$" "\\\\vspace*{1em}"
+                    (replace-regexp-in-string
+                     "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" contents)))
+     (while (string-match "^[ \t]+" contents)
+       (let ((new-str (format "\\hspace*{%dem}"
+                             (length (match-string 0 contents)))))
+        (setq contents (replace-match new-str nil t contents))))
+     (format "\\begin{verse}\n%s\\end{verse}" contents))))
+
+
+\f
+;;; End-user functions
+
+;;;###autoload
+(defun org-latex-export-as-latex
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer as a LaTeX buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Export is done in a buffer named \"*Org LATEX Export*\", which
+will be displayed when `org-export-show-temporary-export-buffer'
+is non-nil."
+  (interactive)
+  (org-export-to-buffer 'latex "*Org LATEX Export*"
+    async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
+
+;;;###autoload
+(defun org-latex-convert-region-to-latex ()
+  "Assume the current region has org-mode syntax, and convert it to LaTeX.
+This can be used in any buffer.  For example, you can write an
+itemized list in org-mode syntax in an LaTeX buffer and use this
+command to convert it."
+  (interactive)
+  (org-export-replace-region-by 'latex))
+
+;;;###autoload
+(defun org-latex-export-to-latex
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a LaTeX file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".tex" subtreep)))
+    (org-export-to-file 'latex outfile
+      async subtreep visible-only body-only ext-plist)))
+
+;;;###autoload
+(defun org-latex-export-to-pdf
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to LaTeX then process through to PDF.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return PDF file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".tex" subtreep)))
+    (org-export-to-file 'latex outfile
+      async subtreep visible-only body-only ext-plist
+      (lambda (file) (org-latex-compile file)))))
+
+(defun org-latex-compile (texfile &optional snippet)
+  "Compile a TeX file.
+
+TEXFILE is the name of the file being compiled.  Processing is
+done through the command specified in `org-latex-pdf-process'.
+
+When optional argument SNIPPET is non-nil, TEXFILE is a temporary
+file used to preview a LaTeX snippet.  In this case, do not
+create a log buffer and do not bother removing log files.
+
+Return PDF file name or an error if it couldn't be produced."
+  (let* ((base-name (file-name-sans-extension (file-name-nondirectory texfile)))
+        (full-name (file-truename texfile))
+        (out-dir (file-name-directory texfile))
+        ;; Properly set working directory for compilation.
+        (default-directory (if (file-name-absolute-p texfile)
+                               (file-name-directory full-name)
+                             default-directory))
+        errors)
+    (unless snippet (message (format "Processing LaTeX file %s..." texfile)))
+    (save-window-excursion
+      (cond
+       ;; A function is provided: Apply it.
+       ((functionp org-latex-pdf-process)
+       (funcall org-latex-pdf-process (shell-quote-argument texfile)))
+       ;; A list is provided: Replace %b, %f and %o with appropriate
+       ;; values in each command before applying it.  Output is
+       ;; redirected to "*Org PDF LaTeX Output*" buffer.
+       ((consp org-latex-pdf-process)
+       (let ((outbuf (and (not snippet)
+                          (get-buffer-create "*Org PDF LaTeX Output*"))))
+         (mapc
+          (lambda (command)
+            (shell-command
+             (replace-regexp-in-string
+              "%b" (shell-quote-argument base-name)
+              (replace-regexp-in-string
+               "%f" (shell-quote-argument full-name)
+               (replace-regexp-in-string
+                "%o" (shell-quote-argument out-dir) command t t) t t) t t)
+             outbuf))
+          org-latex-pdf-process)
+         ;; Collect standard errors from output buffer.
+         (setq errors (and (not snippet) (org-latex--collect-errors outbuf)))))
+       (t (error "No valid command to process to PDF")))
+      (let ((pdffile (concat out-dir base-name ".pdf")))
+       ;; Check for process failure.  Provide collected errors if
+       ;; possible.
+       (if (not (file-exists-p pdffile))
+           (error (concat (format "PDF file %s wasn't produced" pdffile)
+                          (when errors (concat ": " errors))))
+         ;; Else remove log files, when specified, and signal end of
+         ;; process to user, along with any error encountered.
+         (when (and (not snippet) org-latex-remove-logfiles)
+           (dolist (file (directory-files
+                          out-dir t
+                          (concat (regexp-quote base-name)
+                                  "\\(?:\\.[0-9]+\\)?"
+                                  "\\."
+                                  (regexp-opt org-latex-logfiles-extensions))))
+             (delete-file file)))
+         (message (concat "Process completed"
+                          (if (not errors) "."
+                            (concat " with errors: " errors)))))
+       ;; Return output file name.
+       pdffile))))
+
+(defun org-latex--collect-errors (buffer)
+  "Collect some kind of errors from \"pdflatex\" command output.
+
+BUFFER is the buffer containing output.
+
+Return collected error types as a string, or nil if there was
+none."
+  (with-current-buffer buffer
+    (save-excursion
+      (goto-char (point-max))
+      (when (re-search-backward "^[ \t]*This is .*?TeX.*?Version" nil t)
+       (let ((case-fold-search t)
+             (errors ""))
+         (dolist (latex-error org-latex-known-errors)
+           (when (save-excursion (re-search-forward (car latex-error) nil t))
+             (setq errors (concat errors " " (cdr latex-error)))))
+         (and (org-string-nw-p errors) (org-trim errors)))))))
+
+;;;###autoload
+(defun org-latex-publish-to-latex (plist filename pub-dir)
+  "Publish an Org file to LaTeX.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to 'latex filename ".tex" plist pub-dir))
+
+;;;###autoload
+(defun org-latex-publish-to-pdf (plist filename pub-dir)
+  "Publish an Org file to PDF (via LaTeX).
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  ;; Unlike to `org-latex-publish-to-latex', PDF file is generated
+  ;; in working directory and then moved to publishing directory.
+  (org-publish-attachment
+   plist
+   (org-latex-compile (org-publish-org-to 'latex filename ".tex" plist))
+   pub-dir))
+
+
+(provide 'ox-latex)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-latex.el ends here
diff --git a/lisp/org/ox-man.el b/lisp/org/ox-man.el
new file mode 100644 (file)
index 0000000..a160e4c
--- /dev/null
@@ -0,0 +1,1260 @@
+;; ox-man.el --- Man Back-End for Org Export Engine
+
+;; Copyright (C) 2011-2013  Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
+;;      Luis R Anaya <papoanaya aroba hot mail punto com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements a Man back-end for Org generic exporter.
+;;
+;; To test it, run
+;;
+;;   M-: (org-export-to-buffer 'man "*Test Man*") RET
+;;
+;; in an org-mode buffer then switch to the buffer to see the Man
+;; export.  See ox.el for more details on how this exporter works.
+;;
+;; It introduces one new buffer keywords:
+;; "MAN_CLASS_OPTIONS".
+
+;;; Code:
+
+(require 'ox)
+
+(eval-when-compile (require 'cl))
+
+(defvar org-export-man-default-packages-alist)
+(defvar org-export-man-packages-alist)
+(defvar orgtbl-exp-regexp)
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-backend 'man
+  '((babel-call . org-man-babel-call)
+    (bold . org-man-bold)
+    (center-block . org-man-center-block)
+    (clock . org-man-clock)
+    (code . org-man-code)
+    (comment . (lambda (&rest args) ""))
+    (comment-block . (lambda (&rest args) ""))
+    (drawer . org-man-drawer)
+    (dynamic-block . org-man-dynamic-block)
+    (entity . org-man-entity)
+    (example-block . org-man-example-block)
+    (export-block . org-man-export-block)
+    (export-snippet . org-man-export-snippet)
+    (fixed-width . org-man-fixed-width)
+    (footnote-definition . org-man-footnote-definition)
+    (footnote-reference . org-man-footnote-reference)
+    (headline . org-man-headline)
+    (horizontal-rule . org-man-horizontal-rule)
+    (inline-babel-call . org-man-inline-babel-call)
+    (inline-src-block . org-man-inline-src-block)
+    (inlinetask . org-man-inlinetask)
+    (italic . org-man-italic)
+    (item . org-man-item)
+    (keyword . org-man-keyword)
+    (line-break . org-man-line-break)
+    (link . org-man-link)
+    (paragraph . org-man-paragraph)
+    (plain-list . org-man-plain-list)
+    (plain-text . org-man-plain-text)
+    (planning . org-man-planning)
+    (property-drawer . (lambda (&rest args) ""))
+    (quote-block . org-man-quote-block)
+    (quote-section . org-man-quote-section)
+    (radio-target . org-man-radio-target)
+    (section . org-man-section)
+    (special-block . org-man-special-block)
+    (src-block . org-man-src-block)
+    (statistics-cookie . org-man-statistics-cookie)
+    (strike-through . org-man-strike-through)
+    (subscript . org-man-subscript)
+    (superscript . org-man-superscript)
+    (table . org-man-table)
+    (table-cell . org-man-table-cell)
+    (table-row . org-man-table-row)
+    (target . org-man-target)
+    (template . org-man-template)
+    (timestamp . org-man-timestamp)
+    (underline . org-man-underline)
+    (verbatim . org-man-verbatim)
+    (verse-block . org-man-verse-block))
+  :export-block "MAN"
+  :menu-entry
+  '(?m "Export to MAN"
+       ((?m "As MAN file" org-man-export-to-man)
+       (?p "As PDF file" org-man-export-to-pdf)
+       (?o "As PDF file and open"
+           (lambda (a s v b)
+             (if a (org-man-export-to-pdf t s v b)
+               (org-open-file (org-man-export-to-pdf nil s v b)))))))
+  :options-alist
+  '((:man-class "MAN_CLASS" nil nil t)
+    (:man-class-options "MAN_CLASS_OPTIONS" nil nil t)
+    (:man-header-extra "MAN_HEADER" nil nil newline)))
+
+
+\f
+;;; User Configurable Variables
+
+(defgroup org-export-man nil
+  "Options for exporting Org mode files to Man."
+  :tag "Org Export Man"
+  :group 'org-export)
+
+;;; Tables
+
+(defcustom org-man-tables-centered t
+  "When non-nil, tables are exported in a center environment."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-man-tables-verbatim nil
+  "When non-nil, tables are exported verbatim."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+
+(defcustom org-man-table-scientific-notation "%sE%s"
+  "Format string to display numbers in scientific notation.
+The format should have \"%s\" twice, for mantissa and exponent
+\(i.e. \"%s\\\\times10^{%s}\").
+
+When nil, no transformation is made."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+          (string :tag "Format string")
+          (const :tag "No formatting")))
+
+
+;;; Inlinetasks
+;; Src blocks
+
+(defcustom org-man-source-highlight nil
+  "Use GNU source highlight to embellish source blocks "
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+
+(defcustom org-man-source-highlight-langs
+  '((emacs-lisp "lisp") (lisp "lisp") (clojure "lisp")
+    (scheme "scheme")
+    (c "c") (cc "cpp") (csharp "csharp") (d "d")
+    (fortran "fortran") (cobol "cobol") (pascal "pascal")
+    (ada "ada") (asm "asm")
+    (perl "perl") (cperl "perl")
+    (python "python") (ruby "ruby") (tcl "tcl") (lua "lua")
+    (java "java") (javascript "javascript")
+    (tex "latex")
+    (shell-script "sh") (awk "awk") (diff "diff") (m4 "m4")
+    (ocaml "caml") (caml "caml")
+    (sql "sql") (sqlite "sql")
+    (html "html") (css "css") (xml "xml")
+    (bat "bat") (bison "bison") (clipper "clipper")
+    (ldap "ldap") (opa "opa")
+    (php "php") (postscript "postscript") (prolog "prolog")
+    (properties "properties") (makefile "makefile")
+    (tml "tml") (vala "vala") (vbscript "vbscript") (xorg "xorg"))
+  "Alist mapping languages to their listing language counterpart.
+The key is a symbol, the major mode symbol without the \"-mode\".
+The value is the string that should be inserted as the language
+parameter for the listings package.  If the mode name and the
+listings name are the same, the language does not need an entry
+in this list - but it does not hurt if it is present."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(repeat
+          (list
+           (symbol :tag "Major mode       ")
+           (string :tag "Listings language"))))
+
+
+
+(defvar org-man-custom-lang-environments nil
+  "Alist mapping languages to language-specific Man environments.
+
+It is used during export of src blocks by the listings and
+man packages.  For example,
+
+  \(setq org-man-custom-lang-environments
+     '\(\(python \"pythoncode\"\)\)\)
+
+would have the effect that if org encounters begin_src python
+during man export."
+)
+
+
+;;; Compilation
+
+(defcustom org-man-pdf-process
+  '("tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
+    "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
+    "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf")
+
+  "Commands to process a Man file to a PDF file.
+This is a list of strings, each of them will be given to the
+shell as a command.  %f in the command will be replaced by the
+full file name, %b by the file base name (i.e. without directory
+and extension parts) and %o by the base directory of the file.
+
+
+By default, Org uses 3 runs of to do the processing.
+
+Alternatively, this may be a Lisp function that does the
+processing.  This function should accept the file name as
+its single argument."
+  :group 'org-export-pdf
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+          (repeat :tag "Shell command sequence"
+                  (string :tag "Shell command"))
+          (const :tag "2 runs of pdfgroff"
+                 ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
+                  "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf" ))
+          (const :tag "3 runs of pdfgroff"
+                 ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
+                  "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
+                  "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"))
+          (function)))
+
+(defcustom org-man-logfiles-extensions
+  '("log" "out" "toc")
+  "The list of file extensions to consider as Man logfiles."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(repeat (string :tag "Extension")))
+
+(defcustom org-man-remove-logfiles t
+  "Non-nil means remove the logfiles produced by PDF production.
+These are the .aux, .log, .out, and .toc files."
+  :group 'org-export-man
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+
+\f
+;;; Internal Functions
+
+(defun org-man--caption/label-string (element info)
+  "Return caption and label Man string for ELEMENT.
+
+INFO is a plist holding contextual information.  If there's no
+caption nor label, return the empty string.
+
+For non-floats, see `org-man--wrap-label'."
+  (let ((label (org-element-property :label element))
+       (main (org-export-get-caption element))
+       (short (org-export-get-caption element t)))
+    (cond ((and (not main) (not label)) "")
+         ((not main) (format "\\fI%s\\fP" label))
+         ;; Option caption format with short name.
+         (short (format "\\fR%s\\fP - \\fI\\P - %s\n"
+                        (org-export-data short info)
+                        (org-export-data main info)))
+         ;; Standard caption format.
+         (t (format "\\fR%s\\fP" (org-export-data main info))))))
+
+(defun org-man--wrap-label (element output)
+  "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
+This function shouldn't be used for floats.  See
+`org-man--caption/label-string'."
+  (let ((label (org-element-property :name element)))
+    (if (or (not output) (not label) (string= output "") (string= label ""))
+        output
+      (concat (format "%s\n.br\n" label) output))))
+
+
+\f
+;;; Template
+
+(defun org-man-template (contents info)
+  "Return complete document string after Man conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (let* ((title (org-export-data (plist-get info :title) info))
+        (attr (read (format "(%s)"
+                            (mapconcat
+                             #'identity
+                             (list (plist-get info :man-class-options))
+                             " "))))
+        (section-item (plist-get attr :section-id)))
+
+    (concat
+
+     (cond
+      ((and title (stringp section-item))
+       (format ".TH \"%s\" \"%s\" \n" title section-item))
+      ((and (string= "" title) (stringp section-item))
+       (format ".TH \"%s\" \"%s\" \n" " " section-item))
+      (title
+       (format ".TH \"%s\" \"1\" \n" title))
+      (t
+       ".TH \" \" \"1\" "))
+     contents)))
+
+
+
+\f
+;;; Transcode Functions
+
+;;; Babel Call
+;;
+;; Babel Calls are ignored.
+
+
+;;; Bold
+
+(defun org-man-bold (bold contents info)
+  "Transcode BOLD from Org to Man.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (format "\\fB%s\\fP" contents))
+
+
+;;; Center Block
+
+(defun org-man-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to Man.
+CONTENTS holds the contents of the center block.  INFO is a plist
+holding contextual information."
+  (org-man--wrap-label
+   center-block
+   (format ".ce %d\n.nf\n%s\n.fi"
+           (- (length (split-string contents "\n")) 1 )
+           contents)))
+
+
+;;; Clock
+
+(defun org-man-clock (clock contents info)
+  "Transcode a CLOCK element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  "" )
+
+
+;;; Code
+
+(defun org-man-code (code contents info)
+  "Transcode a CODE object from Org to Man.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "\\fC%s\\fP" code))
+
+
+;;; Comment
+;;
+;; Comments are ignored.
+
+
+;;; Comment Block
+;;
+;; Comment Blocks are ignored.
+
+
+;;; Drawer
+
+(defun org-man-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to Man.
+   DRAWER holds the drawer information
+   CONTENTS holds the contents of the block.
+   INFO is a plist holding contextual information. "
+  contents)
+
+
+;;; Dynamic Block
+
+(defun org-man-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to Man.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information.  See `org-export-data'."
+  (org-man--wrap-label dynamic-block contents))
+
+
+;;; Entity
+
+(defun org-man-entity (entity contents info)
+  "Transcode an ENTITY object from Org to Man.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (org-element-property :utf-8 entity))
+
+
+;;; Example Block
+
+(defun org-man-example-block (example-block contents info)
+  "Transcode an EXAMPLE-BLOCK element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (org-man--wrap-label
+   example-block
+   (format ".RS\n.nf\n%s\n.fi\n.RE"
+           (org-export-format-code-default example-block info))))
+
+
+;;; Export Block
+
+(defun org-man-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (string= (org-element-property :type export-block) "MAN")
+    (org-remove-indentation (org-element-property :value export-block))))
+
+
+;;; Export Snippet
+
+(defun org-man-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (eq (org-export-snippet-backend export-snippet) 'man)
+    (org-element-property :value export-snippet)))
+
+
+;;; Fixed Width
+
+(defun org-man-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-man--wrap-label
+   fixed-width
+   (format "\\fC\n%s\\fP"
+           (org-remove-indentation
+            (org-element-property :value fixed-width)))))
+
+
+;;; Footnote Definition
+;;
+;; Footnote Definitions are ignored.
+
+;;; Footnote References
+;;
+;; Footnote References are Ignored
+
+
+;;; Headline
+
+(defun org-man-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to Man.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  (let* ((level (org-export-get-relative-level headline info))
+                (numberedp (org-export-numbered-headline-p headline info))
+                ;; Section formatting will set two placeholders: one for the
+                ;; title and the other for the contents.
+                (section-fmt
+                 (case level
+                       (1 ".SH \"%s\"\n%s")
+                       (2 ".SS \"%s\"\n%s")
+                       (3 ".SS \"%s\"\n%s")
+                       (t nil)))
+                (text (org-export-data (org-element-property :title headline) info)))
+
+    (cond
+     ;; Case 1: This is a footnote section: ignore it.
+     ((org-element-property :footnote-section-p headline) nil)
+
+     ;; Case 2. This is a deep sub-tree: export it as a list item.
+     ;;         Also export as items headlines for which no section
+     ;;         format has been found.
+     ((or (not section-fmt) (org-export-low-level-p headline info))
+      ;; Build the real contents of the sub-tree.
+      (let ((low-level-body
+                        (concat
+                         ;; If the headline is the first sibling, start a list.
+                         (when (org-export-first-sibling-p headline info)
+                               (format "%s\n" ".RS"))
+                         ;; Itemize headline
+                         ".TP\n.ft I\n" text "\n.ft\n"
+                         contents ".RE")))
+               ;; If headline is not the last sibling simply return
+               ;; LOW-LEVEL-BODY.  Otherwise, also close the list, before any
+               ;; blank line.
+               (if (not (org-export-last-sibling-p headline info)) low-level-body
+                 (replace-regexp-in-string
+                  "[ \t\n]*\\'" ""
+                  low-level-body))))
+
+     ;; Case 3. Standard headline.  Export it as a section.
+     (t (format section-fmt text contents )))))
+
+;;; Horizontal Rule
+;; Not supported
+
+;;; Inline Babel Call
+;;
+;; Inline Babel Calls are ignored.
+
+;;; Inline Src Block
+
+(defun org-man-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to Man.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((code (org-element-property :value inline-src-block)))
+    (cond
+     (org-man-source-highlight
+      (let* ((tmpdir (if (featurep 'xemacs)
+                         temp-directory
+                       temporary-file-directory ))
+             (in-file  (make-temp-name
+                        (expand-file-name "srchilite" tmpdir)))
+             (out-file (make-temp-name
+                        (expand-file-name "reshilite" tmpdir)))
+             (org-lang (org-element-property :language inline-src-block))
+             (lst-lang (cadr (assq (intern org-lang)
+                                   org-man-source-highlight-langs)))
+
+             (cmd (concat (expand-file-name "source-highlight")
+                          " -s " lst-lang
+                          " -f groff_man"
+                          " -i " in-file
+                          " -o " out-file )))
+
+        (if lst-lang
+            (let ((code-block "" ))
+              (with-temp-file in-file (insert code))
+              (shell-command cmd)
+              (setq code-block  (org-file-contents out-file))
+              (delete-file in-file)
+              (delete-file out-file)
+              code-block)
+          (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n"
+                  code))))
+
+     ;; Do not use a special package: transcode it verbatim.
+     (t
+      (concat ".RS\n.nf\n" "\\fC" "\n" code "\n"
+              "\\fP\n.fi\n.RE\n")))))
+
+
+;;; Inlinetask
+;;; Italic
+
+(defun org-man-italic (italic contents info)
+  "Transcode ITALIC from Org to Man.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (format "\\fI%s\\fP" contents))
+
+
+;;; Item
+
+
+(defun org-man-item (item contents info)
+
+  "Transcode an ITEM element from Org to Man.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+
+  (let* ((bullet (org-element-property :bullet item))
+         (type (org-element-property :type (org-element-property :parent item)))
+         (checkbox (case (org-element-property :checkbox item)
+                     (on "\\o'\\(sq\\(mu'")                    ;;
+                     (off "\\(sq ")                                    ;;
+                     (trans "\\o'\\(sq\\(mi'"   ))) ;;
+
+         (tag (let ((tag (org-element-property :tag item)))
+                ;; Check-boxes must belong to the tag.
+                (and tag (format "\\fB%s\\fP"
+                                 (concat checkbox
+                                         (org-export-data tag info)))))))
+
+    (if (and (null tag )
+                        (null checkbox))
+               (let* ((bullet (org-trim bullet))
+                          (marker (cond  ((string= "-" bullet) "\\(em")
+                                                         ((string= "*" bullet) "\\(bu")
+                                                         ((eq type 'ordered)
+                                                          (format "%s " (org-trim bullet)))
+                                                         (t "\\(dg"))))
+                 (concat ".IP " marker " 4\n"
+                                 (org-trim (or contents " " ))))
+                                        ; else
+      (concat ".TP\n" (or tag (concat " " checkbox)) "\n"
+              (org-trim (or contents " " ))))))
+
+;;; Keyword
+
+
+(defun org-man-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((key (org-element-property :key keyword))
+        (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "MAN") value)
+     ((string= key "INDEX") nil)
+     ((string= key "TOC"   ) nil))))
+
+
+;;; Line Break
+
+(defun org-man-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  ".br\n")
+
+
+;;; Link
+
+
+(defun org-man-link (link desc info)
+  "Transcode a LINK object from Org to Man.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information.  See
+`org-export-data'."
+
+  (let* ((type (org-element-property :type link))
+         (raw-path (org-element-property :path link))
+         ;; Ensure DESC really exists, or set it to nil.
+         (desc (and (not (string= desc "")) desc))
+
+         (path (cond
+                ((member type '("http" "https" "ftp" "mailto"))
+                 (concat type ":" raw-path))
+                ((string= type "file")
+                 (when (string-match "\\(.+\\)::.+" raw-path)
+                   (setq raw-path (match-string 1 raw-path)))
+                 (if (file-name-absolute-p raw-path)
+                     (concat "file://" (expand-file-name raw-path))
+                   (concat "file://" raw-path)))
+                (t raw-path)))
+         protocol)
+    (cond
+     ;; External link with a description part.
+     ((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc))
+     ;; External link without a description part.
+     (path (format "\\fI%s\\fP" path))
+     ;; No path, only description.  Try to do something useful.
+     (t (format "\\fI%s\\fP" desc)))))
+
+
+;;; Paragraph
+
+(defun org-man-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to Man.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  (let ((parent (plist-get (nth 1 paragraph) :parent)))
+    (when parent
+      (let ((parent-type (car parent))
+            (fixed-paragraph ""))
+        (cond ((and (eq parent-type 'item)
+                    (plist-get (nth 1 parent) :bullet ))
+               (setq fixed-paragraph (concat "" contents)))
+              ((eq parent-type 'section)
+               (setq fixed-paragraph (concat ".PP\n" contents)))
+              ((eq parent-type 'footnote-definition)
+               (setq fixed-paragraph contents))
+              (t (setq fixed-paragraph (concat "" contents))))
+        fixed-paragraph ))))
+
+
+;;; Plain List
+
+(defun org-man-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to Man.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  contents)
+
+;;; Plain Text
+
+(defun org-man-plain-text (text info)
+  "Transcode a TEXT string from Org to Man.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  (let ((output text))
+    ;; Protect various chars.
+    (setq output (replace-regexp-in-string
+                 "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
+                 "$\\" output nil t 1))
+    ;; Activate smart quotes.  Be sure to provide original TEXT string
+    ;; since OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output (org-export-activate-smart-quotes output :utf-8 info text)))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n"
+                                            output)))
+    ;; Return value.
+    output))
+
+
+
+;;; Planning
+
+
+;;; Property Drawer
+
+
+;;; Quote Block
+
+(defun org-man-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to Man.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (org-man--wrap-label
+   quote-block
+   (format ".RS\n%s\n.RE" contents)))
+
+;;; Quote Section
+
+(defun org-man-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((value (org-remove-indentation
+                (org-element-property :value quote-section))))
+    (when value (format ".RS\\fI%s\\fP\n.RE\n" value))))
+
+
+;;; Radio Target
+
+(defun org-man-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object from Org to Man.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  text )
+
+
+;;; Section
+
+(defun org-man-section (section contents info)
+  "Transcode a SECTION element from Org to Man.
+CONTENTS holds the contents of the section.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;; Special Block
+
+(defun org-man-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to Man.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((type (downcase (org-element-property :type special-block))))
+    (org-man--wrap-label
+     special-block
+     (format "%s\n" contents))))
+
+
+;;; Src Block
+
+(defun org-man-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to Man.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((lang (org-element-property :language src-block))
+         (code (org-element-property :value src-block))
+         (custom-env (and lang
+                          (cadr (assq (intern lang)
+                                      org-man-custom-lang-environments))))
+         (num-start (case (org-element-property :number-lines src-block)
+                      (continued (org-export-get-loc src-block info))
+                      (new 0)))
+         (retain-labels (org-element-property :retain-labels src-block)))
+    (cond
+     ;; Case 1.  No source fontification.
+     ((not org-man-source-highlight)
+      (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
+             (org-export-format-code-default src-block info)))
+     (org-man-source-highlight
+      (let* ((tmpdir (if (featurep 'xemacs)
+                        temp-directory
+                      temporary-file-directory ))
+
+            (in-file  (make-temp-name
+                       (expand-file-name "srchilite" tmpdir)))
+            (out-file (make-temp-name
+                       (expand-file-name "reshilite" tmpdir)))
+
+            (org-lang (org-element-property :language src-block))
+            (lst-lang (cadr (assq (intern org-lang)
+                                  org-man-source-highlight-langs)))
+
+            (cmd (concat "source-highlight"
+                         " -s " lst-lang
+                         " -f groff_man "
+                         " -i " in-file
+                         " -o " out-file)))
+
+       (if lst-lang
+           (let ((code-block ""))
+             (with-temp-file in-file (insert code))
+             (shell-command cmd)
+             (setq code-block  (org-file-contents out-file))
+             (delete-file in-file)
+             (delete-file out-file)
+             code-block)
+         (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" code)))))))
+
+
+;;; Statistics Cookie
+
+(defun org-man-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-element-property :value statistics-cookie))
+
+
+;;; Strike-Through
+
+(defun org-man-strike-through (strike-through contents info)
+  "Transcode STRIKE-THROUGH from Org to Man.
+CONTENTS is the text with strike-through markup.  INFO is a plist
+holding contextual information."
+  (format "\\fI%s\\fP" contents))
+
+;;; Subscript
+
+(defun org-man-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to Man.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format  "\\d\\s-2%s\\s+2\\u" contents))
+
+;;; Superscript "^_%s$
+
+(defun org-man-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to Man.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format  "\\u\\s-2%s\\s+2\\d" contents))
+
+
+;;; Table
+;;
+;; `org-man-table' is the entry point for table transcoding.  It
+;; takes care of tables with a "verbatim" attribute.  Otherwise, it
+;; delegates the job to either `org-man-table--table.el-table' or
+;; `org-man-table--org-table' functions, depending of the type of
+;; the table.
+;;
+;; `org-man-table--align-string' is a subroutine used to build
+;; alignment string for Org tables.
+
+(defun org-man-table (table contents info)
+  "Transcode a TABLE element from Org to Man.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (cond
+   ;; Case 1: verbatim table.
+   ((or org-man-tables-verbatim
+        (let ((attr (read (format "(%s)"
+                 (mapconcat
+                  #'identity
+                  (org-element-property :attr_man table)
+                  " ")))))
+
+          (and attr (plist-get attr :verbatim))))
+
+    (format ".nf\n\\fC%s\\fP\n.fi"
+            ;; Re-create table, without affiliated keywords.
+            (org-trim
+             (org-element-interpret-data
+              `(table nil ,@(org-element-contents table))))))
+   ;; Case 2: Standard table.
+   (t (org-man-table--org-table table contents info))))
+
+(defun org-man-table--align-string (divider table info)
+  "Return an appropriate Man alignment string.
+TABLE is the considered table.  INFO is a plist used as
+a communication channel."
+  (let (alignment)
+    ;; Extract column groups and alignment from first (non-rule) row.
+    (org-element-map
+       (org-element-map table 'table-row
+         (lambda (row)
+           (and (eq (org-element-property :type row) 'standard) row))
+         info 'first-match)
+       'table-cell
+      (lambda (cell)
+       (let* ((borders (org-export-table-cell-borders cell info))
+              (raw-width (org-export-table-cell-width cell info))
+              (width-cm (when raw-width (/ raw-width 5)))
+              (width (if raw-width (format "w(%dc)"
+                                           (if (< width-cm 1) 1 width-cm)) "")))
+         ;; Check left border for the first cell only.
+         (when (and (memq 'left borders) (not alignment))
+           (push "|" alignment))
+         (push
+          (case (org-export-table-cell-alignment cell info)
+            (left (concat "l" width divider))
+            (right (concat "r" width divider))
+            (center (concat "c" width divider)))
+          alignment)
+         (when (memq 'right borders) (push "|" alignment))))
+      info)
+    (apply 'concat (reverse alignment))))
+
+(defun org-man-table--org-table (table contents info)
+  "Return appropriate Man code for an Org table.
+
+TABLE is the table type element to transcode.  CONTENTS is its
+contents, as a string.  INFO is a plist used as a communication
+channel.
+
+This function assumes TABLE has `org' as its `:type' attribute."
+  (let* ((attr (org-export-read-attribute :attr_man table))
+        (label (org-element-property :name table))
+         (caption (and (not (plist-get attr :disable-caption))
+                      (org-man--caption/label-string table info)))
+         (divider (if (plist-get attr :divider) "|" " "))
+
+         ;; Determine alignment string.
+         (alignment (org-man-table--align-string divider table info))
+         ;; Extract others display options.
+
+         (lines (org-split-string contents "\n"))
+
+         (attr-list
+         (delq nil
+               (list
+                (and (plist-get attr :expand) "expand")
+                (let ((placement (plist-get attr :placement)))
+                  (cond ((string= placement 'center) "center")
+                        ((string= placement 'left) nil)
+                        (t (if org-man-tables-centered "center" ""))))
+                (or (plist-get attr :boxtype) "box"))))
+
+         (title-line  (plist-get attr :title-line))
+         (long-cells (plist-get attr :long-cells))
+
+         (table-format (concat
+                        (format "%s" (or (car attr-list) "" ))
+                        (or
+                         (let ((output-list '()))
+                           (when (cdr attr-list)
+                             (dolist (attr-item (cdr attr-list))
+                              (setq output-list (concat output-list  (format ",%s" attr-item)))))
+                           output-list)
+                         "")))
+
+        (first-line (when lines (org-split-string (car lines) "\t"))))
+    ;; Prepare the final format string for the table.
+
+
+    (cond
+     ;; Others.
+     (lines (concat ".TS\n " table-format ";\n"
+
+                    (format "%s.\n"
+                            (let ((final-line ""))
+                              (when title-line
+                                (dotimes (i (length first-line))
+                                  (setq final-line (concat final-line "cb" divider))))
+
+                              (setq final-line (concat final-line "\n"))
+
+                              (if alignment
+                                  (setq final-line (concat final-line alignment))
+                                (dotimes (i (length first-line))
+                                  (setq final-line (concat final-line "c" divider))))
+                              final-line ))
+
+                    (format "%s.TE\n"
+                            (let ((final-line "")
+                                  (long-line "")
+                                  (lines (org-split-string contents "\n")))
+
+                              (dolist (line-item lines)
+                                (setq long-line "")
+
+                                (if long-cells
+                                    (progn
+                                      (if (string= line-item "_")
+                                          (setq long-line (format "%s\n" line-item))
+                                        ;; else string =
+                                        (let ((cell-item-list (org-split-string line-item "\t")))
+                                          (dolist (cell-item cell-item-list)
+
+                                            (cond  ((eq cell-item (car (last cell-item-list)))
+                                                    (setq long-line (concat long-line
+                                                                            (format "T{\n%s\nT}\t\n"  cell-item ))))
+                                                   (t
+                                                    (setq long-line (concat long-line
+                                                                            (format "T{\n%s\nT}\t"  cell-item ))))))
+                                         long-line))
+                                     ;; else long cells
+                                     (setq final-line (concat final-line long-line )))
+
+                                  (setq final-line (concat final-line line-item "\n"))))
+                              final-line))
+
+                    (and caption (format ".TB \"%s\"" caption)))))))
+
+;;; Table Cell
+
+(defun org-man-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL element from Org to Man
+CONTENTS is the cell contents.  INFO is a plist used as
+a communication channel."
+    (concat (if (and contents
+                     org-man-table-scientific-notation
+                     (string-match orgtbl-exp-regexp contents))
+                ;; Use appropriate format string for scientific
+                ;; notation.
+              (format org-man-table-scientific-notation
+                        (match-string 1 contents)
+                        (match-string 2 contents))
+              contents )
+            (when (org-export-get-next-element table-cell info) "\t")))
+
+
+;;; Table Row
+
+(defun org-man-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to Man
+CONTENTS is the contents of the row.  INFO is a plist used as
+a communication channel."
+  ;; Rules are ignored since table separators are deduced from
+  ;; borders of the current row.
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let* ((attr (mapconcat 'identity
+                            (org-element-property
+                             :attr_man (org-export-get-parent table-row))
+                            " "))
+           ;; TABLE-ROW's borders are extracted from its first cell.
+           (borders
+            (org-export-table-cell-borders
+             (car (org-element-contents table-row)) info)))
+      (concat
+       ;; Mark horizontal lines
+       (cond  ((and (memq 'top borders) (memq 'above borders)) "_\n"))
+       contents
+
+       (cond
+        ;; When BOOKTABS are activated enforce bottom rule even when
+        ;; no hline was specifically marked.
+        ((and (memq 'bottom borders) (memq 'below borders)) "\n_")
+        ((memq 'below borders) "\n_"))))))
+
+
+;;; Target
+
+(defun org-man-target (target contents info)
+  "Transcode a TARGET object from Org to Man.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format "\\fI%s\\fP"
+          (org-export-solidify-link-text (org-element-property :value target))))
+
+
+;;; Timestamp
+
+(defun org-man-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to Man.
+  CONTENTS is nil.  INFO is a plist holding contextual
+  information."
+  "" )
+
+
+;;; Underline
+
+(defun org-man-underline (underline contents info)
+  "Transcode UNDERLINE from Org to Man.
+CONTENTS is the text with underline markup.  INFO is a plist
+holding contextual information."
+  (format "\\fI%s\\fP" contents))
+
+
+;;; Verbatim
+
+(defun org-man-verbatim (verbatim contents info)
+  "Transcode a VERBATIM object from Org to Man.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format ".nf\n%s\n.fi" contents))
+
+
+;;; Verse Block
+
+(defun org-man-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to Man.
+CONTENTS is verse block contents. INFO is a plist holding
+contextual information."
+  (format ".RS\n.ft I\n%s\n.ft\n.RE" contents))
+
+
+\f
+;;; Interactive functions
+
+(defun org-man-export-to-man
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a Man file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only the body
+without any markers.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".man" subtreep)))
+    (org-export-to-file 'man outfile
+      async subtreep visible-only body-only ext-plist)))
+
+(defun org-man-export-to-pdf
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to Groff then process through to PDF.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write between
+markers.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return PDF file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".man" subtreep)))
+    (org-export-to-file 'man outfile
+      async subtreep visible-only body-only ext-plist
+      (lambda (file) (org-latex-compile file)))))
+
+(defun org-man-compile (file)
+  "Compile a Groff file.
+
+FILE is the name of the file being compiled.  Processing is done
+through the command specified in `org-man-pdf-process'.
+
+Return PDF file name or an error if it couldn't be produced."
+  (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
+        (full-name (file-truename file))
+        (out-dir (file-name-directory file))
+        ;; Properly set working directory for compilation.
+        (default-directory (if (file-name-absolute-p file)
+                               (file-name-directory full-name)
+                             default-directory))
+         errors)
+    (message (format "Processing Groff file %s..." file))
+    (save-window-excursion
+      (cond
+       ;; A function is provided: Apply it.
+       ((functionp org-man-pdf-process)
+       (funcall org-man-pdf-process (shell-quote-argument file)))
+       ;; A list is provided: Replace %b, %f and %o with appropriate
+       ;; values in each command before applying it.  Output is
+       ;; redirected to "*Org PDF Groff Output*" buffer.
+       ((consp org-man-pdf-process)
+       (let ((outbuf (get-buffer-create "*Org PDF Groff Output*")))
+         (mapc
+          (lambda (command)
+            (shell-command
+             (replace-regexp-in-string
+              "%b" (shell-quote-argument base-name)
+              (replace-regexp-in-string
+               "%f" (shell-quote-argument full-name)
+               (replace-regexp-in-string
+                "%o" (shell-quote-argument out-dir) command t t) t t) t t)
+             outbuf))
+          org-man-pdf-process)
+         ;; Collect standard errors from output buffer.
+         (setq errors (org-man-collect-errors outbuf))))
+       (t (error "No valid command to process to PDF")))
+      (let ((pdffile (concat out-dir base-name ".pdf")))
+       ;; Check for process failure.  Provide collected errors if
+       ;; possible.
+       (if (not (file-exists-p pdffile))
+           (error (concat (format "PDF file %s wasn't produced" pdffile)
+                          (when errors (concat ": " errors))))
+         ;; Else remove log files, when specified, and signal end of
+         ;; process to user, along with any error encountered.
+         (when org-man-remove-logfiles
+           (dolist (ext org-man-logfiles-extensions)
+             (let ((file (concat out-dir base-name "." ext)))
+               (when (file-exists-p file) (delete-file file)))))
+         (message (concat "Process completed"
+                          (if (not errors) "."
+                            (concat " with errors: " errors)))))
+       ;; Return output file name.
+       pdffile))))
+
+(defun org-man-collect-errors (buffer)
+  "Collect some kind of errors from \"groff\" output
+BUFFER is the buffer containing output.
+Return collected error types as a string, or nil if there was
+none."
+  (with-current-buffer buffer
+    (save-excursion
+      (goto-char (point-max))
+      ;; Find final run
+      nil )))
+
+
+(provide 'ox-man)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-man.el ends here
diff --git a/lisp/org/ox-md.el b/lisp/org/ox-md.el
new file mode 100644 (file)
index 0000000..7842017
--- /dev/null
@@ -0,0 +1,485 @@
+;;; ox-md.el --- Markdown Back-End for Org Export Engine
+
+;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
+;; Keywords: org, wp, markdown
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library implements a Markdown back-end (vanilla flavor) for
+;; Org exporter, based on `html' back-end.  See Org manual for more
+;; information.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox-html)
+
+
+\f
+;;; User-Configurable Variables
+
+(defgroup org-export-md nil
+  "Options specific to Markdown export back-end."
+  :tag "Org Markdown"
+  :group 'org-export
+  :version "24.4"
+  :package-version '(Org . "8.0"))
+
+(defcustom org-md-headline-style 'atx
+  "Style used to format headlines.
+This variable can be set to either `atx' or `setext'."
+  :group 'org-export-md
+  :type '(choice
+         (const :tag "Use \"atx\" style" atx)
+         (const :tag "Use \"Setext\" style" setext)))
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-derived-backend 'md 'html
+  :export-block '("MD" "MARKDOWN")
+  :filters-alist '((:filter-parse-tree . org-md-separate-elements))
+  :menu-entry
+  '(?m "Export to Markdown"
+       ((?M "To temporary buffer"
+           (lambda (a s v b) (org-md-export-as-markdown a s v)))
+       (?m "To file" (lambda (a s v b) (org-md-export-to-markdown a s v)))
+       (?o "To file and open"
+           (lambda (a s v b)
+             (if a (org-md-export-to-markdown t s v)
+               (org-open-file (org-md-export-to-markdown nil s v)))))))
+  :translate-alist '((bold . org-md-bold)
+                    (code . org-md-verbatim)
+                    (comment . (lambda (&rest args) ""))
+                    (comment-block . (lambda (&rest args) ""))
+                    (example-block . org-md-example-block)
+                    (fixed-width . org-md-example-block)
+                    (footnote-definition . ignore)
+                    (footnote-reference . ignore)
+                    (headline . org-md-headline)
+                    (horizontal-rule . org-md-horizontal-rule)
+                    (inline-src-block . org-md-verbatim)
+                    (italic . org-md-italic)
+                    (item . org-md-item)
+                    (line-break . org-md-line-break)
+                    (link . org-md-link)
+                    (paragraph . org-md-paragraph)
+                    (plain-list . org-md-plain-list)
+                    (plain-text . org-md-plain-text)
+                    (quote-block . org-md-quote-block)
+                    (quote-section . org-md-example-block)
+                    (section . org-md-section)
+                    (src-block . org-md-example-block)
+                    (template . org-md-template)
+                    (verbatim . org-md-verbatim)))
+
+
+\f
+;;; Filters
+
+(defun org-md-separate-elements (tree backend info)
+  "Make sure elements are separated by at least one blank line.
+
+TREE is the parse tree being exported.  BACKEND is the export
+back-end used.  INFO is a plist used as a communication channel.
+
+Assume BACKEND is `md'."
+  (org-element-map tree org-element-all-elements
+    (lambda (elem)
+      (unless (eq (org-element-type elem) 'org-data)
+       (org-element-put-property
+        elem :post-blank
+        (let ((post-blank (org-element-property :post-blank elem)))
+          (if (not post-blank) 1 (max 1 post-blank)))))))
+  ;; Return updated tree.
+  tree)
+
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-md-bold (bold contents info)
+  "Transcode BOLD object into Markdown format.
+CONTENTS is the text within bold markup.  INFO is a plist used as
+a communication channel."
+  (format "**%s**" contents))
+
+
+;;;; Code and Verbatim
+
+(defun org-md-verbatim (verbatim contents info)
+  "Transcode VERBATIM object into Markdown format.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((value (org-element-property :value verbatim)))
+    (format (cond ((not (string-match "`" value)) "`%s`")
+                 ((or (string-match "\\``" value)
+                      (string-match "`\\'" value))
+                  "`` %s ``")
+                 (t "``%s``"))
+           value)))
+
+
+;;;; Example Block and Src Block
+
+(defun org-md-example-block (example-block contents info)
+  "Transcode EXAMPLE-BLOCK element into Markdown format.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (replace-regexp-in-string
+   "^" "    "
+   (org-remove-indentation
+    (org-element-property :value example-block))))
+
+
+;;;; Headline
+
+(defun org-md-headline (headline contents info)
+  "Transcode HEADLINE element into Markdown format.
+CONTENTS is the headline contents.  INFO is a plist used as
+a communication channel."
+  (unless (org-element-property :footnote-section-p headline)
+    (let* ((level (org-export-get-relative-level headline info))
+          (title (org-export-data (org-element-property :title headline) info))
+          (todo (and (plist-get info :with-todo-keywords)
+                     (let ((todo (org-element-property :todo-keyword
+                                                       headline)))
+                       (and todo (concat (org-export-data todo info) " ")))))
+          (tags (and (plist-get info :with-tags)
+                     (let ((tag-list (org-export-get-tags headline info)))
+                       (and tag-list
+                            (format "     :%s:"
+                                    (mapconcat 'identity tag-list ":"))))))
+          (priority
+           (and (plist-get info :with-priority)
+                (let ((char (org-element-property :priority headline)))
+                  (and char (format "[#%c] " char)))))
+          ;; Headline text without tags.
+          (heading (concat todo priority title)))
+      (cond
+       ;; Cannot create a headline.  Fall-back to a list.
+       ((or (org-export-low-level-p headline info)
+           (not (memq org-md-headline-style '(atx setext)))
+           (and (eq org-md-headline-style 'atx) (> level 6))
+           (and (eq org-md-headline-style 'setext) (> level 2)))
+       (let ((bullet
+              (if (not (org-export-numbered-headline-p headline info)) "-"
+                (concat (number-to-string
+                         (car (last (org-export-get-headline-number
+                                     headline info))))
+                        "."))))
+         (concat bullet (make-string (- 4 (length bullet)) ? ) heading tags
+                 "\n\n"
+                 (and contents
+                      (replace-regexp-in-string "^" "    " contents)))))
+       ;; Use "Setext" style.
+       ((eq org-md-headline-style 'setext)
+       (concat heading tags "\n"
+               (make-string (length heading) (if (= level 1) ?= ?-))
+               "\n\n"
+               contents))
+       ;; Use "atx" style.
+       (t (concat (make-string level ?#) " " heading tags "\n\n" contents))))))
+
+
+;;;; Horizontal Rule
+
+(defun org-md-horizontal-rule (horizontal-rule contents info)
+  "Transcode HORIZONTAL-RULE element into Markdown format.
+CONTENTS is the horizontal rule contents.  INFO is a plist used
+as a communication channel."
+  "---")
+
+
+;;;; Italic
+
+(defun org-md-italic (italic contents info)
+  "Transcode ITALIC object into Markdown format.
+CONTENTS is the text within italic markup.  INFO is a plist used
+as a communication channel."
+  (format "*%s*" contents))
+
+
+;;;; Item
+
+(defun org-md-item (item contents info)
+  "Transcode ITEM element into Markdown format.
+CONTENTS is the item contents.  INFO is a plist used as
+a communication channel."
+  (let* ((type (org-element-property :type (org-export-get-parent item)))
+        (struct (org-element-property :structure item))
+        (bullet (if (not (eq type 'ordered)) "-"
+                  (concat (number-to-string
+                           (car (last (org-list-get-item-number
+                                       (org-element-property :begin item)
+                                       struct
+                                       (org-list-prevs-alist struct)
+                                       (org-list-parents-alist struct)))))
+                          "."))))
+    (concat bullet
+           (make-string (- 4 (length bullet)) ? )
+           (case (org-element-property :checkbox item)
+             (on "[X] ")
+             (trans "[-] ")
+             (off "[ ] "))
+           (let ((tag (org-element-property :tag item)))
+             (and tag (format "**%s:** "(org-export-data tag info))))
+           (org-trim (replace-regexp-in-string "^" "    " contents)))))
+
+
+;;;; Line Break
+
+(defun org-md-line-break (line-break contents info)
+  "Transcode LINE-BREAK object into Markdown format.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  "  \n")
+
+
+;;;; Link
+
+(defun org-md-link (link contents info)
+  "Transcode LINE-BREAK object into Markdown format.
+CONTENTS is the link's description.  INFO is a plist used as
+a communication channel."
+  (let ((--link-org-files-as-html-maybe
+        (function
+         (lambda (raw-path info)
+           ;; Treat links to `file.org' as links to `file.html', if
+            ;; needed.  See `org-html-link-org-files-as-html'.
+           (cond
+            ((and org-html-link-org-files-as-html
+                  (string= ".org"
+                           (downcase (file-name-extension raw-path "."))))
+             (concat (file-name-sans-extension raw-path) "."
+                     (plist-get info :html-extension)))
+            (t raw-path)))))
+       (type (org-element-property :type link)))
+    (cond ((member type '("custom-id" "id"))
+          (let ((destination (org-export-resolve-id-link link info)))
+            (if (stringp destination)  ; External file.
+                (let ((path (funcall --link-org-files-as-html-maybe
+                                     destination info)))
+                  (if (not contents) (format "<%s>" path)
+                    (format "[%s](%s)" contents path)))
+              (concat
+               (and contents (concat contents " "))
+               (format "(%s)"
+                       (format (org-export-translate "See section %s" :html info)
+                               (mapconcat 'number-to-string
+                                          (org-export-get-headline-number
+                                           destination info)
+                                          ".")))))))
+         ((org-export-inline-image-p link org-html-inline-image-rules)
+          (let ((path (let ((raw-path (org-element-property :path link)))
+                        (if (not (file-name-absolute-p raw-path)) raw-path
+                          (expand-file-name raw-path)))))
+            (format "![%s](%s)"
+                    (let ((caption (org-export-get-caption
+                                    (org-export-get-parent-element link))))
+                      (when caption (org-export-data caption info)))
+                    path)))
+         ((string= type "coderef")
+          (let ((ref (org-element-property :path link)))
+            (format (org-export-get-coderef-format ref contents)
+                    (org-export-resolve-coderef ref info))))
+         ((equal type "radio")
+          (let ((destination (org-export-resolve-radio-link link info)))
+            (org-export-data (org-element-contents destination) info)))
+         ((equal type "fuzzy")
+          (let ((destination (org-export-resolve-fuzzy-link link info)))
+            (if (org-string-nw-p contents) contents
+              (when destination
+                (let ((number (org-export-get-ordinal destination info)))
+                  (when number
+                    (if (atom number) (number-to-string number)
+                      (mapconcat 'number-to-string number "."))))))))
+         (t (let* ((raw-path (org-element-property :path link))
+                   (path (cond
+                          ((member type '("http" "https" "ftp"))
+                           (concat type ":" raw-path))
+                          ((equal type "file")
+                           ;; Treat links to ".org" files as ".html",
+                           ;; if needed.
+                           (setq raw-path
+                                 (funcall --link-org-files-as-html-maybe
+                                          raw-path info))
+                           ;; If file path is absolute, prepend it
+                           ;; with protocol component - "file://".
+                           (if (not (file-name-absolute-p raw-path)) raw-path
+                             (concat "file://" (expand-file-name raw-path))))
+                          (t raw-path))))
+              (if (not contents) (format "<%s>" path)
+                (format "[%s](%s)" contents path)))))))
+
+
+;;;; Paragraph
+
+(defun org-md-paragraph (paragraph contents info)
+  "Transcode PARAGRAPH element into Markdown format.
+CONTENTS is the paragraph contents.  INFO is a plist used as
+a communication channel."
+  (let ((first-object (car (org-element-contents paragraph))))
+    ;; If paragraph starts with a #, protect it.
+    (if (and (stringp first-object) (string-match "\\`#" first-object))
+       (replace-regexp-in-string "\\`#" "\\#" contents nil t)
+      contents)))
+
+
+;;;; Plain List
+
+(defun org-md-plain-list (plain-list contents info)
+  "Transcode PLAIN-LIST element into Markdown format.
+CONTENTS is the plain-list contents.  INFO is a plist used as
+a communication channel."
+  contents)
+
+
+;;;; Plain Text
+
+(defun org-md-plain-text (text info)
+  "Transcode a TEXT string into Markdown format.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  (when (plist-get info :with-smart-quotes)
+    (setq text (org-export-activate-smart-quotes text :html info)))
+  ;; Protect ambiguous #.  This will protect # at the beginning of
+  ;; a line, but not at the beginning of a paragraph.  See
+  ;; `org-md-paragraph'.
+  (setq text (replace-regexp-in-string "\n#" "\n\\\\#" text))
+  ;; Protect ambiguous !
+  (setq text (replace-regexp-in-string "\\(!\\)\\[" "\\\\!" text nil nil 1))
+  ;; Protect `, *, _ and \
+  (setq text (replace-regexp-in-string "[`*_\\]" "\\\\\\&" text))
+  ;; Handle special strings, if required.
+  (when (plist-get info :with-special-strings)
+    (setq text (org-html-convert-special-strings text)))
+  ;; Handle break preservation, if required.
+  (when (plist-get info :preserve-breaks)
+    (setq text (replace-regexp-in-string "[ \t]*\n" "  \n" text)))
+  ;; Return value.
+  text)
+
+
+;;;; Quote Block
+
+(defun org-md-quote-block (quote-block contents info)
+  "Transcode QUOTE-BLOCK element into Markdown format.
+CONTENTS is the quote-block contents.  INFO is a plist used as
+a communication channel."
+  (replace-regexp-in-string
+   "^" "> "
+   (replace-regexp-in-string "\n\\'" "" contents)))
+
+
+;;;; Section
+
+(defun org-md-section (section contents info)
+  "Transcode SECTION element into Markdown format.
+CONTENTS is the section contents.  INFO is a plist used as
+a communication channel."
+  contents)
+
+
+;;;; Template
+
+(defun org-md-template (contents info)
+  "Return complete document string after Markdown conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist used
+as a communication channel."
+  contents)
+
+
+\f
+;;; Interactive function
+
+;;;###autoload
+(defun org-md-export-as-markdown (&optional async subtreep visible-only)
+  "Export current buffer to a Markdown buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+Export is done in a buffer named \"*Org MD Export*\", which will
+be displayed when `org-export-show-temporary-export-buffer' is
+non-nil."
+  (interactive)
+  (org-export-to-buffer 'md "*Org MD Export*"
+    async subtreep visible-only nil nil (lambda () (text-mode))))
+
+;;;###autoload
+(defun org-md-convert-region-to-md ()
+  "Assume the current region has org-mode syntax, and convert it to Markdown.
+This can be used in any buffer.  For example, you can write an
+itemized list in org-mode syntax in a Markdown buffer and use
+this command to convert it."
+  (interactive)
+  (org-export-replace-region-by 'md))
+
+
+;;;###autoload
+(defun org-md-export-to-markdown (&optional async subtreep visible-only)
+  "Export current buffer to a Markdown file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+Return output file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".md" subtreep)))
+    (org-export-to-file 'md outfile async subtreep visible-only)))
+
+
+(provide 'ox-md)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-md.el ends here
diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
new file mode 100644 (file)
index 0000000..d5d03e4
--- /dev/null
@@ -0,0 +1,4411 @@
+;;; ox-odt.el --- OpenDocument Text Exporter for Org Mode
+
+;; Copyright (C) 2010-2013 Free Software Foundation, Inc.
+
+;; Author: Jambunathan K <kjambunathan at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+;; Homepage: http://orgmode.org
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(eval-when-compile
+  (require 'cl)
+  (require 'table nil 'noerror))
+(require 'format-spec)
+(require 'ox)
+(require 'org-compat)
+
+;;; Define Back-End
+
+(org-export-define-backend 'odt
+  '((bold . org-odt-bold)
+    (center-block . org-odt-center-block)
+    (clock . org-odt-clock)
+    (code . org-odt-code)
+    (drawer . org-odt-drawer)
+    (dynamic-block . org-odt-dynamic-block)
+    (entity . org-odt-entity)
+    (example-block . org-odt-example-block)
+    (export-block . org-odt-export-block)
+    (export-snippet . org-odt-export-snippet)
+    (fixed-width . org-odt-fixed-width)
+    (footnote-definition . org-odt-footnote-definition)
+    (footnote-reference . org-odt-footnote-reference)
+    (headline . org-odt-headline)
+    (horizontal-rule . org-odt-horizontal-rule)
+    (inline-src-block . org-odt-inline-src-block)
+    (inlinetask . org-odt-inlinetask)
+    (italic . org-odt-italic)
+    (item . org-odt-item)
+    (keyword . org-odt-keyword)
+    (latex-environment . org-odt-latex-environment)
+    (latex-fragment . org-odt-latex-fragment)
+    (line-break . org-odt-line-break)
+    (link . org-odt-link)
+    (paragraph . org-odt-paragraph)
+    (plain-list . org-odt-plain-list)
+    (plain-text . org-odt-plain-text)
+    (planning . org-odt-planning)
+    (property-drawer . org-odt-property-drawer)
+    (quote-block . org-odt-quote-block)
+    (quote-section . org-odt-quote-section)
+    (radio-target . org-odt-radio-target)
+    (section . org-odt-section)
+    (special-block . org-odt-special-block)
+    (src-block . org-odt-src-block)
+    (statistics-cookie . org-odt-statistics-cookie)
+    (strike-through . org-odt-strike-through)
+    (subscript . org-odt-subscript)
+    (superscript . org-odt-superscript)
+    (table . org-odt-table)
+    (table-cell . org-odt-table-cell)
+    (table-row . org-odt-table-row)
+    (target . org-odt-target)
+    (template . org-odt-template)
+    (timestamp . org-odt-timestamp)
+    (underline . org-odt-underline)
+    (verbatim . org-odt-verbatim)
+    (verse-block . org-odt-verse-block))
+  :export-block "ODT"
+  :filters-alist '((:filter-parse-tree
+                   . (org-odt--translate-latex-fragments
+                      org-odt--translate-description-lists
+                      org-odt--translate-list-tables)))
+  :menu-entry
+  '(?o "Export to ODT"
+       ((?o "As ODT file" org-odt-export-to-odt)
+       (?O "As ODT file and open"
+           (lambda (a s v b)
+             (if a (org-odt-export-to-odt t s v)
+               (org-open-file (org-odt-export-to-odt nil s v) 'system))))))
+  :options-alist
+  '((:odt-styles-file "ODT_STYLES_FILE" nil nil t)
+    ;; Redefine regular option.
+    (:with-latex nil "tex" org-odt-with-latex)))
+
+
+;;; Dependencies
+
+;;; Hooks
+
+;;; Function Declarations
+
+(declare-function org-id-find-id-file "org-id" (id))
+(declare-function hfy-face-to-style "htmlfontify" (fn))
+(declare-function hfy-face-or-def-to-name "htmlfontify" (fn))
+(declare-function archive-zip-extract "arc-mode" (archive name))
+(declare-function org-create-math-formula "org" (latex-frag &optional mathml-file))
+(declare-function browse-url-file-url "browse-url" (file))
+
+
+\f
+;;; Internal Variables
+
+(defconst org-odt-lib-dir
+  (file-name-directory load-file-name)
+  "Location of ODT exporter.
+Use this to infer values of `org-odt-styles-dir' and
+`org-odt-schema-dir'.")
+
+(defvar org-odt-data-dir
+  (expand-file-name "../../etc/" org-odt-lib-dir)
+  "Data directory for ODT exporter.
+Use this to infer values of `org-odt-styles-dir' and
+`org-odt-schema-dir'.")
+
+(defconst org-odt-special-string-regexps
+  '(("\\\\-" . "&#x00ad;\\1")          ; shy
+    ("---\\([^-]\\)" . "&#x2014;\\1")  ; mdash
+    ("--\\([^-]\\)" . "&#x2013;\\1")   ; ndash
+    ("\\.\\.\\." . "&#x2026;"))                ; hellip
+  "Regular expressions for special string conversion.")
+
+(defconst org-odt-schema-dir-list
+  (list
+   (and org-odt-data-dir
+       (expand-file-name "./schema/" org-odt-data-dir)) ; bail out
+   (eval-when-compile
+     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
+         (expand-file-name "./schema/" org-odt-data-dir))))
+  "List of directories to search for OpenDocument schema files.
+Use this list to set the default value of
+`org-odt-schema-dir'.  The entries in this list are
+populated heuristically based on the values of `org-odt-lib-dir'
+and `org-odt-data-dir'.")
+
+(defconst org-odt-styles-dir-list
+  (list
+   (and org-odt-data-dir
+       (expand-file-name "./styles/" org-odt-data-dir)) ; bail out
+   (eval-when-compile
+     (and (boundp 'org-odt-data-dir) org-odt-data-dir ; see make install
+         (expand-file-name "./styles/" org-odt-data-dir)))
+   (expand-file-name "../../etc/styles/" org-odt-lib-dir) ; git
+   (expand-file-name "./etc/styles/" org-odt-lib-dir)  ; elpa
+   (expand-file-name "./org/" data-directory)         ; system
+   )
+  "List of directories to search for OpenDocument styles files.
+See `org-odt-styles-dir'.  The entries in this list are populated
+heuristically based on the values of `org-odt-lib-dir' and
+`org-odt-data-dir'.")
+
+(defconst org-odt-styles-dir
+  (let* ((styles-dir
+         (catch 'styles-dir
+           (message "Debug (ox-odt): Searching for OpenDocument styles files...")
+           (mapc (lambda (styles-dir)
+                   (when styles-dir
+                     (message "Debug (ox-odt): Trying %s..." styles-dir)
+                     (when (and (file-readable-p
+                                 (expand-file-name
+                                  "OrgOdtContentTemplate.xml" styles-dir))
+                                (file-readable-p
+                                 (expand-file-name
+                                  "OrgOdtStyles.xml" styles-dir)))
+                       (message "Debug (ox-odt): Using styles under %s"
+                                styles-dir)
+                       (throw 'styles-dir styles-dir))))
+                 org-odt-styles-dir-list)
+           nil)))
+    (unless styles-dir
+      (error "Error (ox-odt): Cannot find factory styles files, aborting"))
+    styles-dir)
+  "Directory that holds auxiliary XML files used by the ODT exporter.
+
+This directory contains the following XML files -
+ \"OrgOdtStyles.xml\" and \"OrgOdtContentTemplate.xml\".  These
+ XML files are used as the default values of
+ `org-odt-styles-file' and
+ `org-odt-content-template-file'.
+
+The default value of this variable varies depending on the
+version of org in use and is initialized from
+`org-odt-styles-dir-list'.  Note that the user could be using org
+from one of: org's own private git repository, GNU ELPA tar or
+standard Emacs.")
+
+(defconst org-odt-bookmark-prefix "OrgXref.")
+
+(defconst org-odt-manifest-file-entry-tag
+  "\n<manifest:file-entry manifest:media-type=\"%s\" manifest:full-path=\"%s\"%s/>")
+
+(defconst org-odt-file-extensions
+  '(("odt" . "OpenDocument Text")
+    ("ott" . "OpenDocument Text Template")
+    ("odm" . "OpenDocument Master Document")
+    ("ods" . "OpenDocument Spreadsheet")
+    ("ots" . "OpenDocument Spreadsheet Template")
+    ("odg" . "OpenDocument Drawing (Graphics)")
+    ("otg" . "OpenDocument Drawing Template")
+    ("odp" . "OpenDocument Presentation")
+    ("otp" . "OpenDocument Presentation Template")
+    ("odi" . "OpenDocument Image")
+    ("odf" . "OpenDocument Formula")
+    ("odc" . "OpenDocument Chart")))
+
+(defconst org-odt-table-style-format
+  "
+<style:style style:name=\"%s\" style:family=\"table\">
+  <style:table-properties style:rel-width=\"%s%%\" fo:margin-top=\"0cm\" fo:margin-bottom=\"0.20cm\" table:align=\"center\"/>
+</style:style>
+"
+  "Template for auto-generated Table styles.")
+
+(defvar org-odt-automatic-styles '()
+  "Registry of automatic styles for various OBJECT-TYPEs.
+The variable has the following form:
+\(\(OBJECT-TYPE-A
+  \(\(OBJECT-NAME-A.1 OBJECT-PROPS-A.1\)
+   \(OBJECT-NAME-A.2 OBJECT-PROPS-A.2\) ...\)\)
+ \(OBJECT-TYPE-B
+  \(\(OBJECT-NAME-B.1 OBJECT-PROPS-B.1\)
+   \(OBJECT-NAME-B.2 OBJECT-PROPS-B.2\) ...\)\)
+ ...\).
+
+OBJECT-TYPEs could be \"Section\", \"Table\", \"Figure\" etc.
+OBJECT-PROPS is (typically) a plist created by passing
+\"#+ATTR_ODT: \" option to `org-odt-parse-block-attributes'.
+
+Use `org-odt-add-automatic-style' to add update this variable.'")
+
+(defvar org-odt-object-counters nil
+  "Running counters for various OBJECT-TYPEs.
+Use this to generate automatic names and style-names. See
+`org-odt-add-automatic-style'.")
+
+(defvar org-odt-src-block-paragraph-format
+  "<style:style style:name=\"OrgSrcBlock\" style:family=\"paragraph\" style:parent-style-name=\"Preformatted_20_Text\">
+   <style:paragraph-properties fo:background-color=\"%s\" fo:padding=\"0.049cm\" fo:border=\"0.51pt solid #000000\" style:shadow=\"none\">
+    <style:background-image/>
+   </style:paragraph-properties>
+   <style:text-properties fo:color=\"%s\"/>
+  </style:style>"
+  "Custom paragraph style for colorized source and example blocks.
+This style is much the same as that of \"OrgFixedWidthBlock\"
+except that the foreground and background colors are set
+according to the default face identified by the `htmlfontify'.")
+
+(defvar hfy-optimisations)
+(defvar org-odt-embedded-formulas-count 0)
+(defvar org-odt-embedded-images-count 0)
+(defvar org-odt-image-size-probe-method
+  (append (and (executable-find "identify") '(imagemagick)) ; See Bug#10675
+         '(emacs fixed))
+  "Ordered list of methods for determining image sizes.")
+
+(defvar org-odt-default-image-sizes-alist
+  '(("as-char" . (5 . 0.4))
+    ("paragraph" . (5 . 5)))
+  "Hardcoded image dimensions one for each of the anchor
+  methods.")
+
+;; A4 page size is 21.0 by 29.7 cms
+;; The default page settings has 2cm margin on each of the sides. So
+;; the effective text area is 17.0 by 25.7 cm
+(defvar org-odt-max-image-size '(17.0 . 20.0)
+  "Limiting dimensions for an embedded image.")
+
+(defconst org-odt-label-styles
+  '(("math-formula" "%c" "text" "(%n)")
+    ("math-label" "(%n)" "text" "(%n)")
+    ("category-and-value" "%e %n: %c" "category-and-value" "%e %n")
+    ("value" "%e %n: %c" "value" "%n"))
+  "Specify how labels are applied and referenced.
+
+This is an alist where each element is of the form:
+
+  \(STYLE-NAME ATTACH-FMT REF-MODE REF-FMT)
+
+ATTACH-FMT controls how labels and captions are attached to an
+entity.  It may contain following specifiers - %e and %c.  %e is
+replaced with the CATEGORY-NAME.  %n is replaced with
+\"<text:sequence ...> SEQNO </text:sequence>\".  %c is replaced
+with CAPTION.
+
+REF-MODE and REF-FMT controls how label references are generated.
+The following XML is generated for a label reference -
+\"<text:sequence-ref text:reference-format=\"REF-MODE\" ...>
+REF-FMT </text:sequence-ref>\".  REF-FMT may contain following
+specifiers - %e and %n.  %e is replaced with the CATEGORY-NAME.
+%n is replaced with SEQNO.
+
+See also `org-odt-format-label'.")
+
+(defvar org-odt-category-map-alist
+  '(("__Table__" "Table" "value" "Table" org-odt--enumerable-p)
+    ("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)
+    ("__MathFormula__" "Text" "math-formula" "Equation" org-odt--enumerable-formula-p)
+    ("__DvipngImage__" "Equation" "value" "Equation" org-odt--enumerable-latex-image-p)
+    ("__Listing__" "Listing" "value" "Listing" org-odt--enumerable-p))
+  "Map a CATEGORY-HANDLE to OD-VARIABLE and LABEL-STYLE.
+
+This is a list where each entry is of the form:
+
+  \(CATEGORY-HANDLE OD-VARIABLE LABEL-STYLE CATEGORY-NAME ENUMERATOR-PREDICATE)
+
+CATEGORY_HANDLE identifies the captionable entity in question.
+
+OD-VARIABLE is the OpenDocument sequence counter associated with
+the entity.  These counters are declared within
+\"<text:sequence-decls>...</text:sequence-decls>\" block of
+`org-odt-content-template-file'.
+
+LABEL-STYLE is a key into `org-odt-label-styles' and specifies
+how a given entity should be captioned and referenced.
+
+CATEGORY-NAME is used for qualifying captions on export.
+
+ENUMERATOR-PREDICATE is used for assigning a sequence number to
+the entity.  See `org-odt--enumerate'.")
+
+(defvar org-odt-manifest-file-entries nil)
+(defvar hfy-user-sheet-assoc)
+
+(defvar org-odt-zip-dir nil
+  "Temporary work directory for OpenDocument exporter.")
+
+
+\f
+;;; User Configuration Variables
+
+(defgroup org-export-odt nil
+  "Options for exporting Org mode files to ODT."
+  :tag "Org Export ODT"
+  :group 'org-export)
+
+
+;;;; Debugging
+
+(defcustom org-odt-prettify-xml nil
+  "Specify whether or not the xml output should be prettified.
+When this option is turned on, `indent-region' is run on all
+component xml buffers before they are saved.  Turn this off for
+regular use.  Turn this on if you need to examine the xml
+visually."
+  :group 'org-export-odt
+  :version "24.1"
+  :type 'boolean)
+
+
+;;;; Document schema
+
+(require 'rng-loc)
+(defcustom org-odt-schema-dir
+  (let* ((schema-dir
+         (catch 'schema-dir
+           (message "Debug (ox-odt): Searching for OpenDocument schema files...")
+           (mapc
+            (lambda (schema-dir)
+              (when schema-dir
+                (message "Debug (ox-odt): Trying %s..." schema-dir)
+                (when (and (file-expand-wildcards
+                            (expand-file-name "od-manifest-schema*.rnc"
+                                              schema-dir))
+                           (file-expand-wildcards
+                            (expand-file-name "od-schema*.rnc"
+                                              schema-dir))
+                           (file-readable-p
+                            (expand-file-name "schemas.xml" schema-dir)))
+                  (message "Debug (ox-odt): Using schema files under %s"
+                           schema-dir)
+                  (throw 'schema-dir schema-dir))))
+            org-odt-schema-dir-list)
+           (message "Debug (ox-odt): No OpenDocument schema files installed")
+           nil)))
+    schema-dir)
+  "Directory that contains OpenDocument schema files.
+
+This directory contains:
+1. rnc files for OpenDocument schema
+2. a \"schemas.xml\" file that specifies locating rules needed
+   for auto validation of OpenDocument XML files.
+
+Use the customize interface to set this variable.  This ensures
+that `rng-schema-locating-files' is updated and auto-validation
+of OpenDocument XML takes place based on the value
+`rng-nxml-auto-validate-flag'.
+
+The default value of this variable varies depending on the
+version of org in use and is initialized from
+`org-odt-schema-dir-list'.  The OASIS schema files are available
+only in the org's private git repository.  It is *not* bundled
+with GNU ELPA tar or standard Emacs distribution."
+  :type '(choice
+         (const :tag "Not set" nil)
+         (directory :tag "Schema directory"))
+  :group 'org-export-odt
+  :version "24.1"
+  :set
+  (lambda (var value)
+    "Set `org-odt-schema-dir'.
+Also add it to `rng-schema-locating-files'."
+    (let ((schema-dir value))
+      (set var
+          (if (and
+               (file-expand-wildcards
+                (expand-file-name "od-manifest-schema*.rnc" schema-dir))
+               (file-expand-wildcards
+                (expand-file-name "od-schema*.rnc" schema-dir))
+               (file-readable-p
+                (expand-file-name "schemas.xml" schema-dir)))
+              schema-dir
+            (when value
+              (message "Error (ox-odt): %s has no OpenDocument schema files"
+                       value))
+            nil)))
+    (when org-odt-schema-dir
+      (eval-after-load 'rng-loc
+       '(add-to-list 'rng-schema-locating-files
+                     (expand-file-name "schemas.xml"
+                                       org-odt-schema-dir))))))
+
+
+;;;; Document styles
+
+(defcustom org-odt-content-template-file nil
+  "Template file for \"content.xml\".
+The exporter embeds the exported content just before
+\"</office:text>\" element.
+
+If unspecified, the file named \"OrgOdtContentTemplate.xml\"
+under `org-odt-styles-dir' is used."
+  :type '(choice (const nil)
+                (file))
+  :group 'org-export-odt
+  :version "24.1")
+
+(defcustom org-odt-styles-file nil
+  "Default styles file for use with ODT export.
+Valid values are one of:
+1. nil
+2. path to a styles.xml file
+3. path to a *.odt or a *.ott file
+4. list of the form (ODT-OR-OTT-FILE (FILE-MEMBER-1 FILE-MEMBER-2
+...))
+
+In case of option 1, an in-built styles.xml is used. See
+`org-odt-styles-dir' for more information.
+
+In case of option 3, the specified file is unzipped and the
+styles.xml embedded therein is used.
+
+In case of option 4, the specified ODT-OR-OTT-FILE is unzipped
+and FILE-MEMBER-1, FILE-MEMBER-2 etc are copied in to the
+generated odt file.  Use relative path for specifying the
+FILE-MEMBERS.  styles.xml must be specified as one of the
+FILE-MEMBERS.
+
+Use options 1, 2 or 3 only if styles.xml alone suffices for
+achieving the desired formatting.  Use option 4, if the styles.xml
+references additional files like header and footer images for
+achieving the desired formatting.
+
+Use \"#+ODT_STYLES_FILE: ...\" directive to set this variable on
+a per-file basis.  For example,
+
+#+ODT_STYLES_FILE: \"/path/to/styles.xml\" or
+#+ODT_STYLES_FILE: (\"/path/to/file.ott\" (\"styles.xml\" \"image/hdr.png\"))."
+  :group 'org-export-odt
+  :version "24.1"
+  :type
+  '(choice
+    (const :tag "Factory settings" nil)
+    (file :must-match t :tag "styles.xml")
+    (file :must-match t :tag "ODT or OTT file")
+    (list :tag "ODT or OTT file + Members"
+         (file :must-match t :tag "ODF Text or Text Template file")
+         (cons :tag "Members"
+               (file :tag "    Member" "styles.xml")
+               (repeat (file :tag "Member"))))))
+
+(defcustom org-odt-display-outline-level 2
+  "Outline levels considered for enumerating captioned entities."
+  :group 'org-export-odt
+  :version "24.2"
+  :type 'integer)
+
+;;;; Document conversion
+
+(defcustom org-odt-convert-processes
+  '(("LibreOffice"
+     "soffice --headless --convert-to %f%x --outdir %d %i")
+    ("unoconv"
+     "unoconv -f %f -o %d %i"))
+  "Specify a list of document converters and their usage.
+The converters in this list are offered as choices while
+customizing `org-odt-convert-process'.
+
+This variable is a list where each element is of the
+form (CONVERTER-NAME CONVERTER-CMD).  CONVERTER-NAME is the name
+of the converter.  CONVERTER-CMD is the shell command for the
+converter and can contain format specifiers.  These format
+specifiers are interpreted as below:
+
+%i input file name in full
+%I input file name as a URL
+%f format of the output file
+%o output file name in full
+%O output file name as a URL
+%d output dir in full
+%D output dir as a URL.
+%x extra options as set in `org-odt-convert-capabilities'."
+  :group 'org-export-odt
+  :version "24.1"
+  :type
+  '(choice
+    (const :tag "None" nil)
+    (alist :tag "Converters"
+          :key-type (string :tag "Converter Name")
+          :value-type (group (string :tag "Command line")))))
+
+(defcustom org-odt-convert-process "LibreOffice"
+  "Use this converter to convert from \"odt\" format to other formats.
+During customization, the list of converter names are populated
+from `org-odt-convert-processes'."
+  :group 'org-export-odt
+  :version "24.1"
+  :type '(choice :convert-widget
+                (lambda (w)
+                  (apply 'widget-convert (widget-type w)
+                         (eval (car (widget-get w :args)))))
+                `((const :tag "None" nil)
+                  ,@(mapcar (lambda (c)
+                              `(const :tag ,(car c) ,(car c)))
+                            org-odt-convert-processes))))
+
+(defcustom org-odt-convert-capabilities
+  '(("Text"
+     ("odt" "ott" "doc" "rtf" "docx")
+     (("pdf" "pdf") ("odt" "odt") ("rtf" "rtf") ("ott" "ott")
+      ("doc" "doc" ":\"MS Word 97\"") ("docx" "docx") ("html" "html")))
+    ("Web"
+     ("html")
+     (("pdf" "pdf") ("odt" "odt") ("html" "html")))
+    ("Spreadsheet"
+     ("ods" "ots" "xls" "csv" "xlsx")
+     (("pdf" "pdf") ("ots" "ots") ("html" "html") ("csv" "csv") ("ods" "ods")
+      ("xls" "xls") ("xlsx" "xlsx")))
+    ("Presentation"
+     ("odp" "otp" "ppt" "pptx")
+     (("pdf" "pdf") ("swf" "swf") ("odp" "odp") ("otp" "otp") ("ppt" "ppt")
+      ("pptx" "pptx") ("odg" "odg"))))
+  "Specify input and output formats of `org-odt-convert-process'.
+More correctly, specify the set of input and output formats that
+the user is actually interested in.
+
+This variable is an alist where each element is of the
+form (DOCUMENT-CLASS INPUT-FMT-LIST OUTPUT-FMT-ALIST).
+INPUT-FMT-LIST is a list of INPUT-FMTs.  OUTPUT-FMT-ALIST is an
+alist where each element is of the form (OUTPUT-FMT
+OUTPUT-FILE-EXTENSION EXTRA-OPTIONS).
+
+The variable is interpreted as follows:
+`org-odt-convert-process' can take any document that is in
+INPUT-FMT-LIST and produce any document that is in the
+OUTPUT-FMT-LIST.  A document converted to OUTPUT-FMT will have
+OUTPUT-FILE-EXTENSION as the file name extension.  OUTPUT-FMT
+serves dual purposes:
+- It is used for populating completion candidates during
+  `org-odt-convert' commands.
+- It is used as the value of \"%f\" specifier in
+  `org-odt-convert-process'.
+
+EXTRA-OPTIONS is used as the value of \"%x\" specifier in
+`org-odt-convert-process'.
+
+DOCUMENT-CLASS is used to group a set of file formats in
+INPUT-FMT-LIST in to a single class.
+
+Note that this variable inherently captures how LibreOffice based
+converters work.  LibreOffice maps documents of various formats
+to classes like Text, Web, Spreadsheet, Presentation etc and
+allow document of a given class (irrespective of its source
+format) to be converted to any of the export formats associated
+with that class.
+
+See default setting of this variable for an typical
+configuration."
+  :group 'org-export-odt
+  :version "24.1"
+  :type
+  '(choice
+    (const :tag "None" nil)
+    (alist :tag "Capabilities"
+          :key-type (string :tag "Document Class")
+          :value-type
+          (group (repeat :tag "Input formats" (string :tag "Input format"))
+                 (alist :tag "Output formats"
+                        :key-type (string :tag "Output format")
+                        :value-type
+                        (group (string :tag "Output file extension")
+                               (choice
+                                (const :tag "None" nil)
+                                (string :tag "Extra options"))))))))
+
+(defcustom org-odt-preferred-output-format nil
+  "Automatically post-process to this format after exporting to \"odt\".
+Command `org-odt-export-to-odt' exports first to \"odt\" format
+and then uses `org-odt-convert-process' to convert the
+resulting document to this format.  During customization of this
+variable, the list of valid values are populated based on
+`org-odt-convert-capabilities'.
+
+You can set this option on per-file basis using file local
+values.  See Info node `(emacs) File Variables'."
+  :group 'org-export-odt
+  :version "24.1"
+  :type '(choice :convert-widget
+                (lambda (w)
+                  (apply 'widget-convert (widget-type w)
+                         (eval (car (widget-get w :args)))))
+                `((const :tag "None" nil)
+                  ,@(mapcar (lambda (c)
+                              `(const :tag ,c ,c))
+                            (org-odt-reachable-formats "odt")))))
+;;;###autoload
+(put 'org-odt-preferred-output-format 'safe-local-variable 'stringp)
+
+
+;;;; Drawers
+
+(defcustom org-odt-format-drawer-function nil
+  "Function called to format a drawer in ODT code.
+
+The function must accept two parameters:
+  NAME      the drawer name, like \"LOGBOOK\"
+  CONTENTS  the contents of the drawer.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-odt-format-drawer-default \(name contents\)
+  \"Format a drawer element for ODT export.\"
+  contents\)"
+  :group 'org-export-odt
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+
+;;;; Headline
+
+(defcustom org-odt-format-headline-function nil
+  "Function to format headline text.
+
+This function will be called with 5 arguments:
+TODO      the todo keyword \(string or nil\).
+TODO-TYPE the type of todo \(symbol: `todo', `done', nil\)
+PRIORITY  the priority of the headline \(integer or nil\)
+TEXT      the main headline text \(string\).
+TAGS      the tags string, separated with colons \(string or nil\).
+
+The function result will be used as headline text."
+  :group 'org-export-odt
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+
+;;;; Inlinetasks
+
+(defcustom org-odt-format-inlinetask-function nil
+  "Function called to format an inlinetask in ODT code.
+
+The function must accept six parameters:
+  TODO      the todo keyword, as a string
+  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  PRIORITY  the inlinetask priority, as a string
+  NAME      the inlinetask name, as a string.
+  TAGS      the inlinetask tags, as a string.
+  CONTENTS  the contents of the inlinetask, as a string.
+
+The function should return the string to be exported."
+  :group 'org-export-odt
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'function)
+
+
+;;;; LaTeX
+
+(defcustom org-odt-with-latex org-export-with-latex
+  "Non-nil means process LaTeX math snippets.
+
+When set, the exporter will process LaTeX environments and
+fragments.
+
+This option can also be set with the +OPTIONS line,
+e.g. \"tex:mathjax\".  Allowed values are:
+
+nil            Ignore math snippets.
+`verbatim'     Keep everything in verbatim
+`dvipng'       Process the LaTeX fragments to images.  This will also
+               include processing of non-math environments.
+`imagemagick'  Convert the LaTeX fragments to pdf files and use
+               imagemagick to convert pdf files to png files.
+`mathjax'      Do MathJax preprocessing and arrange for MathJax.js to
+               be loaded.
+t              Synonym for `mathjax'."
+  :group 'org-export-odt
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Do not process math in any way" nil)
+         (const :tag "Use dvipng to make images" dvipng)
+         (const :tag "Use imagemagick to make images" imagemagick)
+         (const :tag "Use MathJax to display math" mathjax)
+         (const :tag "Leave math verbatim" verbatim)))
+
+
+;;;; Links
+
+(defcustom org-odt-inline-formula-rules
+  '(("file" . "\\.\\(mathml\\|mml\\|odf\\)\\'"))
+  "Rules characterizing formula files that can be inlined into ODT.
+
+A rule consists in an association whose key is the type of link
+to consider, and value is a regexp that will be matched against
+link's path."
+  :group 'org-export-odt
+  :type '(alist :key-type (string :tag "Type")
+               :value-type (regexp :tag "Path")))
+
+(defcustom org-odt-inline-image-rules
+  '(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\)\\'"))
+  "Rules characterizing image files that can be inlined into ODT.
+
+A rule consists in an association whose key is the type of link
+to consider, and value is a regexp that will be matched against
+link's path."
+  :group 'org-export-odt
+  :type '(alist :key-type (string :tag "Type")
+               :value-type (regexp :tag "Path")))
+
+(defcustom org-odt-pixels-per-inch 96.0
+  "Scaling factor for converting images pixels to inches.
+Use this for sizing of embedded images.  See Info node `(org)
+Images in ODT export' for more information."
+  :type 'float
+  :group 'org-export-odt
+  :version "24.4"
+  :package-version '(Org . "8.1"))
+
+
+;;;; Src Block
+
+(defcustom org-odt-create-custom-styles-for-srcblocks t
+  "Whether custom styles for colorized source blocks be automatically created.
+When this option is turned on, the exporter creates custom styles
+for source blocks based on the advice of `htmlfontify'.  Creation
+of custom styles happen as part of `org-odt-hfy-face-to-css'.
+
+When this option is turned off exporter does not create such
+styles.
+
+Use the latter option if you do not want the custom styles to be
+based on your current display settings.  It is necessary that the
+styles.xml already contains needed styles for colorizing to work.
+
+This variable is effective only if
+`org-odt-fontify-srcblocks' is turned on."
+  :group 'org-export-odt
+  :version "24.1"
+  :type 'boolean)
+
+(defcustom org-odt-fontify-srcblocks t
+  "Specify whether or not source blocks need to be fontified.
+Turn this option on if you want to colorize the source code
+blocks in the exported file.  For colorization to work, you need
+to make available an enhanced version of `htmlfontify' library."
+  :type 'boolean
+  :group 'org-export-odt
+  :version "24.1")
+
+
+;;;; Table
+
+(defcustom org-odt-table-styles
+  '(("OrgEquation" "OrgEquation"
+     ((use-first-column-styles . t)
+      (use-last-column-styles . t)))
+    ("TableWithHeaderRowAndColumn" "Custom"
+     ((use-first-row-styles . t)
+      (use-first-column-styles . t)))
+    ("TableWithFirstRowandLastRow" "Custom"
+     ((use-first-row-styles . t)
+      (use-last-row-styles . t)))
+    ("GriddedTable" "Custom" nil))
+  "Specify how Table Styles should be derived from a Table Template.
+This is a list where each element is of the
+form (TABLE-STYLE-NAME TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS).
+
+TABLE-STYLE-NAME is the style associated with the table through
+\"#+ATTR_ODT: :style TABLE-STYLE-NAME\" line.
+
+TABLE-TEMPLATE-NAME is a set of - upto 9 - automatic
+TABLE-CELL-STYLE-NAMEs and PARAGRAPH-STYLE-NAMEs (as defined
+below) that is included in
+`org-odt-content-template-file'.
+
+TABLE-CELL-STYLE-NAME := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
+                         \"TableCell\"
+PARAGRAPH-STYLE-NAME  := TABLE-TEMPLATE-NAME + TABLE-CELL-TYPE +
+                         \"TableParagraph\"
+TABLE-CELL-TYPE       := \"FirstRow\"   | \"LastColumn\" |
+                         \"FirstRow\"   | \"LastRow\"    |
+                         \"EvenRow\"    | \"OddRow\"     |
+                         \"EvenColumn\" | \"OddColumn\"  | \"\"
+where \"+\" above denotes string concatenation.
+
+TABLE-CELL-OPTIONS is an alist where each element is of the
+form (TABLE-CELL-STYLE-SELECTOR . ON-OR-OFF).
+TABLE-CELL-STYLE-SELECTOR := `use-first-row-styles'       |
+                             `use-last-row-styles'        |
+                             `use-first-column-styles'    |
+                             `use-last-column-styles'     |
+                             `use-banding-rows-styles'    |
+                             `use-banding-columns-styles' |
+                             `use-first-row-styles'
+ON-OR-OFF                 := `t' | `nil'
+
+For example, with the following configuration
+
+\(setq org-odt-table-styles
+      '\(\(\"TableWithHeaderRowsAndColumns\" \"Custom\"
+         \(\(use-first-row-styles . t\)
+          \(use-first-column-styles . t\)\)\)
+        \(\"TableWithHeaderColumns\" \"Custom\"
+         \(\(use-first-column-styles . t\)\)\)\)\)
+
+1. A table associated with \"TableWithHeaderRowsAndColumns\"
+   style will use the following table-cell styles -
+   \"CustomFirstRowTableCell\", \"CustomFirstColumnTableCell\",
+   \"CustomTableCell\" and the following paragraph styles
+   \"CustomFirstRowTableParagraph\",
+   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
+   as appropriate.
+
+2. A table associated with \"TableWithHeaderColumns\" style will
+   use the following table-cell styles -
+   \"CustomFirstColumnTableCell\", \"CustomTableCell\" and the
+   following paragraph styles
+   \"CustomFirstColumnTableParagraph\", \"CustomTableParagraph\"
+   as appropriate..
+
+Note that TABLE-TEMPLATE-NAME corresponds to the
+\"<table:table-template>\" elements contained within
+\"<office:styles>\".  The entries (TABLE-STYLE-NAME
+TABLE-TEMPLATE-NAME TABLE-CELL-OPTIONS) correspond to
+\"table:template-name\" and \"table:use-first-row-styles\" etc
+attributes of \"<table:table>\" element.  Refer ODF-1.2
+specification for more information.  Also consult the
+implementation filed under `org-odt-get-table-cell-styles'.
+
+The TABLE-STYLE-NAME \"OrgEquation\" is used internally for
+formatting of numbered display equations.  Do not delete this
+style from the list."
+  :group 'org-export-odt
+  :version "24.1"
+  :type '(choice
+          (const :tag "None" nil)
+          (repeat :tag "Table Styles"
+                  (list :tag "Table Style Specification"
+                       (string :tag "Table Style Name")
+                       (string  :tag "Table Template Name")
+                       (alist :options (use-first-row-styles
+                                        use-last-row-styles
+                                        use-first-column-styles
+                                        use-last-column-styles
+                                        use-banding-rows-styles
+                                        use-banding-columns-styles)
+                              :key-type symbol
+                              :value-type (const :tag "True" t))))))
+
+;;;; Timestamps
+
+(defcustom org-odt-use-date-fields nil
+  "Non-nil, if timestamps should be exported as date fields.
+
+When nil, export timestamps as plain text.
+
+When non-nil, map `org-time-stamp-custom-formats' to a pair of
+OpenDocument date-styles with names \"OrgDate1\" and \"OrgDate2\"
+respectively.  A timestamp with no time component is formatted
+with style \"OrgDate1\" while one with explicit hour and minutes
+is formatted with style \"OrgDate2\".
+
+This feature is experimental.  Most (but not all) of the common
+%-specifiers in `format-time-string' are supported.
+Specifically, locale-dependent specifiers like \"%c\", \"%x\" are
+formatted as canonical Org timestamps.  For finer control, avoid
+these %-specifiers.
+
+Textual specifiers like \"%b\", \"%h\", \"%B\", \"%a\", \"%A\"
+etc., are displayed by the application in the default language
+and country specified in `org-odt-styles-file'.  Note that the
+default styles file uses language \"en\" and country \"GB\".  You
+can localize the week day and month strings in the exported
+document by setting the default language and country either using
+the application UI or through a custom styles file.
+
+See `org-odt--build-date-styles' for implementation details."
+  :group 'org-export-odt
+  :type 'boolean)
+
+
+\f
+;;; Internal functions
+
+;;;; Date
+
+(defun org-odt--format-timestamp (timestamp &optional end iso-date-p)
+  (let* ((format-timestamp
+         (lambda (timestamp format &optional end utc)
+           (if timestamp
+               (org-timestamp-format timestamp format end utc)
+             (format-time-string format nil utc))))
+        (has-time-p (or (not timestamp)
+                        (org-timestamp-has-time-p timestamp)))
+        (iso-date (let ((format (if has-time-p "%Y-%m-%dT%H:%M:%S"
+                                  "%Y-%m-%dT%H:%M:%S")))
+                    (funcall format-timestamp timestamp format end))))
+    (if iso-date-p iso-date
+      (let* ((style (if has-time-p "OrgDate2" "OrgDate1"))
+            ;; LibreOffice does not care about end goes as content
+            ;; within the "<text:date>...</text:date>" field.  The
+            ;; displayed date is automagically corrected to match the
+            ;; format requested by "style:data-style-name" attribute.  So
+            ;; don't bother about formatting the date contents to be
+            ;; compatible with "OrgDate1" and "OrgDateTime" styles.  A
+            ;; simple Org-style date should suffice.
+            (date (let* ((formats
+                          (if org-display-custom-times
+                              (cons (substring
+                                     (car org-time-stamp-custom-formats) 1 -1)
+                                    (substring
+                                     (cdr org-time-stamp-custom-formats) 1 -1))
+                            '("%Y-%m-%d %a" . "%Y-%m-%d %a %H:%M")))
+                         (format (if has-time-p (cdr formats) (car formats))))
+                    (funcall format-timestamp timestamp format end)))
+            (repeater (let ((repeater-type (org-element-property
+                                            :repeater-type timestamp))
+                            (repeater-value (org-element-property
+                                             :repeater-value timestamp))
+                            (repeater-unit (org-element-property
+                                            :repeater-unit timestamp)))
+                        (concat
+                         (case repeater-type
+                           (catchup "++") (restart ".+") (cumulate "+"))
+                         (when repeater-value
+                           (number-to-string repeater-value))
+                         (case repeater-unit
+                           (hour "h") (day "d") (week "w") (month "m")
+                           (year "y"))))))
+       (concat
+        (format "<text:date text:date-value=\"%s\" style:data-style-name=\"%s\" text:fixed=\"true\">%s</text:date>"
+                iso-date style date)
+        (and (not (string= repeater ""))  " ")
+        repeater)))))
+
+;;;; Frame
+
+(defun org-odt--frame (text width height style &optional extra
+                             anchor-type &rest title-and-desc)
+  (let ((frame-attrs
+        (concat
+         (if width (format " svg:width=\"%0.2fcm\"" width) "")
+         (if height (format " svg:height=\"%0.2fcm\"" height) "")
+         extra
+         (format " text:anchor-type=\"%s\"" (or anchor-type "paragraph")))))
+    (format
+     "\n<draw:frame draw:style-name=\"%s\"%s>\n%s\n</draw:frame>"
+     style frame-attrs
+     (concat text
+            (let ((title (car title-and-desc))
+                  (desc (cadr title-and-desc)))
+              (concat (when title
+                        (format "<svg:title>%s</svg:title>"
+                                (org-odt--encode-plain-text title t)))
+                      (when desc
+                        (format "<svg:desc>%s</svg:desc>"
+                                (org-odt--encode-plain-text desc t)))))))))
+
+
+;;;; Library wrappers
+
+(defun org-odt--zip-extract (archive members target)
+  (when (atom members) (setq members (list members)))
+  (mapc (lambda (member)
+         (require 'arc-mode)
+         (let* ((--quote-file-name
+                 ;; This is shamelessly stolen from `archive-zip-extract'.
+                 (lambda (name)
+                   (if (or (not (memq system-type '(windows-nt ms-dos)))
+                           (and (boundp 'w32-quote-process-args)
+                                (null w32-quote-process-args)))
+                       (shell-quote-argument name)
+                     name)))
+                (target (funcall --quote-file-name target))
+                (archive (expand-file-name archive))
+                (archive-zip-extract
+                 (list "unzip" "-qq" "-o" "-d" target))
+                exit-code command-output)
+           (setq command-output
+                 (with-temp-buffer
+                   (setq exit-code (archive-zip-extract archive member))
+                   (buffer-string)))
+           (unless (zerop exit-code)
+             (message command-output)
+             (error "Extraction failed"))))
+       members))
+
+;;;; Target
+
+(defun org-odt--target (text id)
+  (if (not id) text
+    (concat
+     (format "\n<text:bookmark-start text:name=\"OrgXref.%s\"/>" id)
+     (format "\n<text:bookmark text:name=\"%s\"/>" id) text
+     (format "\n<text:bookmark-end text:name=\"OrgXref.%s\"/>" id))))
+
+;;;; Textbox
+
+(defun org-odt--textbox (text width height style &optional
+                               extra anchor-type)
+  (org-odt--frame
+   (format "\n<draw:text-box %s>%s\n</draw:text-box>"
+          (concat (format " fo:min-height=\"%0.2fcm\"" (or height .2))
+                  (and (not width)
+                       (format " fo:min-width=\"%0.2fcm\"" (or width .2))))
+          text)
+   width nil style extra anchor-type))
+
+
+
+;;;; Table of Contents
+
+(defun org-odt-begin-toc (index-title depth)
+  (concat
+   (format "
+    <text:table-of-content text:style-name=\"OrgIndexSection\" text:protected=\"true\" text:name=\"Table of Contents\">
+     <text:table-of-content-source text:outline-level=\"%d\">
+      <text:index-title-template text:style-name=\"Contents_20_Heading\">%s</text:index-title-template>
+" depth index-title)
+
+   (let ((levels (number-sequence 1 10)))
+     (mapconcat
+      (lambda (level)
+       (format
+        "
+      <text:table-of-content-entry-template text:outline-level=\"%d\" text:style-name=\"Contents_20_%d\">
+       <text:index-entry-link-start text:style-name=\"Internet_20_link\"/>
+       <text:index-entry-chapter/>
+       <text:index-entry-text/>
+       <text:index-entry-link-end/>
+      </text:table-of-content-entry-template>
+" level level)) levels ""))
+
+   (format  "
+     </text:table-of-content-source>
+
+     <text:index-body>
+      <text:index-title text:style-name=\"Sect1\" text:name=\"Table of Contents1_Head\">
+       <text:p text:style-name=\"Contents_20_Heading\">%s</text:p>
+      </text:index-title>
+ " index-title)))
+
+(defun org-odt-end-toc ()
+  (format "
+     </text:index-body>
+    </text:table-of-content>
+"))
+
+(defun* org-odt-format-toc-headline
+    (todo todo-type priority text tags
+         &key level section-number headline-label &allow-other-keys)
+  (setq text
+       (concat
+        ;; Section number.
+        (when section-number (concat section-number ". "))
+        ;; Todo.
+        (when todo
+          (let ((style (if (member todo org-done-keywords)
+                           "OrgDone" "OrgTodo")))
+            (format "<text:span text:style-name=\"%s\">%s</text:span> "
+                    style todo)))
+        (when priority
+          (let* ((style (format "OrgPriority-%s" priority))
+                 (priority (format "[#%c]" priority)))
+            (format "<text:span text:style-name=\"%s\">%s</text:span> "
+                    style priority)))
+        ;; Title.
+        text
+        ;; Tags.
+        (when tags
+          (concat
+           (format " <text:span text:style-name=\"%s\">[%s]</text:span>"
+                   "OrgTags"
+                   (mapconcat
+                    (lambda (tag)
+                      (format
+                       "<text:span text:style-name=\"%s\">%s</text:span>"
+                       "OrgTag" tag)) tags " : "))))))
+  (format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
+         headline-label text))
+
+(defun org-odt-toc (depth info)
+  (assert (wholenump depth))
+  ;; When a headline is marked as a radio target, as in the example below:
+  ;;
+  ;; ** <<<Some Heading>>>
+  ;;    Some text.
+  ;;
+  ;; suppress generation of radio targets.  i.e., Radio targets are to
+  ;; be marked as targets within /document body/ and *not* within
+  ;; /TOC/, as otherwise there will be duplicated anchors one in TOC
+  ;; and one in the document body.
+  ;;
+  ;; FIXME-1: Currently exported headings are memoized.  `org-export.el'
+  ;; doesn't provide a way to disable memoization.  So this doesn't
+  ;; work.
+  ;;
+  ;; FIXME-2: Are there any other objects that need to be suppressed
+  ;; within TOC?
+  (let* ((title (org-export-translate "Table of Contents" :utf-8 info))
+        (headlines (org-export-collect-headlines
+                    info (and (wholenump depth) depth)))
+        (backend (org-export-create-backend
+                  :parent (org-export-backend-name
+                           (plist-get info :back-end))
+                  :transcoders (mapcar
+                                (lambda (type) (cons type (lambda (d c i) c)))
+                                (list 'radio-target)))))
+    (when headlines
+      (concat
+       (org-odt-begin-toc title depth)
+       (mapconcat
+       (lambda (headline)
+         (let* ((entry (org-odt-format-headline--wrap
+                        headline backend info 'org-odt-format-toc-headline))
+                (level (org-export-get-relative-level headline info))
+                (style (format "Contents_20_%d" level)))
+           (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                   style entry)))
+       headlines "\n")
+       (org-odt-end-toc)))))
+
+
+;;;; Document styles
+
+(defun org-odt-add-automatic-style (object-type &optional object-props)
+  "Create an automatic style of type OBJECT-TYPE with param OBJECT-PROPS.
+OBJECT-PROPS is (typically) a plist created by passing
+\"#+ATTR_ODT: \" option of the object in question to
+`org-odt-parse-block-attributes'.
+
+Use `org-odt-object-counters' to generate an automatic
+OBJECT-NAME and STYLE-NAME.  If OBJECT-PROPS is non-nil, add a
+new entry in `org-odt-automatic-styles'.  Return (OBJECT-NAME
+. STYLE-NAME)."
+  (assert (stringp object-type))
+  (let* ((object (intern object-type))
+        (seqvar object)
+        (seqno (1+ (or (plist-get org-odt-object-counters seqvar) 0)))
+        (object-name (format "%s%d" object-type seqno)) style-name)
+    (setq org-odt-object-counters
+         (plist-put org-odt-object-counters seqvar seqno))
+    (when object-props
+      (setq style-name (format "Org%s" object-name))
+      (setq org-odt-automatic-styles
+           (plist-put org-odt-automatic-styles object
+                      (append (list (list style-name object-props))
+                              (plist-get org-odt-automatic-styles object)))))
+    (cons object-name style-name)))
+
+;;;; Checkbox
+
+(defun org-odt--checkbox (item)
+  "Return check-box string associated to ITEM."
+  (let ((checkbox (org-element-property :checkbox item)))
+    (if (not checkbox) ""
+      (format "<text:span text:style-name=\"%s\">%s</text:span>"
+             "OrgCode" (case checkbox
+                         (on "[&#x2713;] ") ; CHECK MARK
+                         (off "[ ] ")
+                         (trans "[-] "))))))
+
+;;; Template
+
+(defun org-odt--build-date-styles (fmt style)
+  ;; In LibreOffice 3.4.6, there doesn't seem to be a convenient way
+  ;; to modify the date fields.  A date could be modified by
+  ;; offsetting in days.  That's about it.  Also, date and time may
+  ;; have to be emitted as two fields - a date field and a time field
+  ;; - separately.
+
+  ;; One can add Form Controls to date and time fields so that they
+  ;; can be easily modified.  But then, the exported document will
+  ;; become tightly coupled with LibreOffice and may not function
+  ;; properly with other OpenDocument applications.
+
+  ;; I have a strange feeling that Date styles are a bit flaky at the
+  ;; moment.
+
+  ;; The feature is experimental.
+  (when (and fmt style)
+    (let* ((fmt-alist
+           '(("%A" . "<number:day-of-week number:style=\"long\"/>")
+             ("%B" . "<number:month number:textual=\"true\" number:style=\"long\"/>")
+             ("%H" . "<number:hours number:style=\"long\"/>")
+             ("%M" . "<number:minutes number:style=\"long\"/>")
+             ("%S" . "<number:seconds number:style=\"long\"/>")
+             ("%V" . "<number:week-of-year/>")
+             ("%Y" . "<number:year number:style=\"long\"/>")
+             ("%a" . "<number:day-of-week number:style=\"short\"/>")
+             ("%b" . "<number:month number:textual=\"true\" number:style=\"short\"/>")
+             ("%d" . "<number:day number:style=\"long\"/>")
+             ("%e" . "<number:day number:style=\"short\"/>")
+             ("%h" . "<number:month number:textual=\"true\" number:style=\"short\"/>")
+             ("%k" . "<number:hours number:style=\"short\"/>")
+             ("%m" . "<number:month number:style=\"long\"/>")
+             ("%p" . "<number:am-pm/>")
+             ("%y" . "<number:year number:style=\"short\"/>")))
+          (case-fold-search nil)
+          (re (mapconcat 'identity (mapcar 'car fmt-alist) "\\|"))
+          match rpl (start 0) (filler-beg 0) filler-end filler output)
+      (mapc
+       (lambda (pair)
+        (setq fmt (replace-regexp-in-string (car pair) (cdr pair) fmt t t)))
+       '(("\\(?:%[[:digit:]]*N\\)" . "") ; strip ns, us and ns
+        ("%C" . "Y")                    ; replace century with year
+        ("%D" . "%m/%d/%y")
+        ("%G" . "Y")                 ; year corresponding to iso week
+        ("%I" . "%H")                ; hour on a 12-hour clock
+        ("%R" . "%H:%M")
+        ("%T" . "%H:%M:%S")
+        ("%U\\|%W" . "%V")           ; week no. starting on Sun./Mon.
+        ("%Z" . "")                  ; time zone name
+        ("%c" . "%Y-%M-%d %a %H:%M" ) ; locale's date and time format
+        ("%g" . "%y")
+        ("%X" . "%x" )  ; locale's pref. time format
+        ("%j" . "")     ; day of the year
+        ("%l" . "%k")   ; like %I blank-padded
+        ("%s" . "")     ; no. of secs since 1970-01-01 00:00:00 +0000
+        ("%n" . "<text:line-break/>")
+        ("%r" . "%I:%M:%S %p")
+        ("%t" . "<text:tab/>")
+        ("%u\\|%w" . "")  ; numeric day of week - Mon (1-7), Sun(0-6)
+        ("%x" . "%Y-%M-%d %a")         ; locale's pref. time format
+        ("%z" . "")                    ; time zone in numeric form
+        ))
+      (while (string-match re fmt start)
+       (setq match (match-string 0 fmt))
+       (setq rpl (assoc-default match fmt-alist))
+       (setq start (match-end 0))
+       (setq filler-end (match-beginning 0))
+       (setq filler (substring fmt (prog1 filler-beg
+                                     (setq filler-beg (match-end 0)))
+                               filler-end))
+       (setq filler (and (not (string= filler ""))
+                         (format "<number:text>%s</number:text>"
+                                 (org-odt--encode-plain-text filler))))
+       (setq output (concat output "\n" filler "\n" rpl)))
+      (setq filler (substring fmt filler-beg))
+      (unless (string= filler "")
+       (setq output (concat output
+                            (format "\n<number:text>%s</number:text>"
+                                    (org-odt--encode-plain-text filler)))))
+      (format "\n<number:date-style style:name=\"%s\" %s>%s\n</number:date-style>"
+             style
+             (concat " number:automatic-order=\"true\""
+                     " number:format-source=\"fixed\"")
+             output ))))
+
+(defun org-odt-template (contents info)
+  "Return complete document string after ODT conversion.
+CONTENTS is the transcoded contents string.  RAW-DATA is the
+original parsed data.  INFO is a plist holding export options."
+  ;; Write meta file.
+  (let ((title (org-export-data (plist-get info :title) info))
+       (author (let ((author (plist-get info :author)))
+                 (if (not author) "" (org-export-data author info))))
+       (email (plist-get info :email))
+       (keywords (plist-get info :keywords))
+       (description (plist-get info :description)))
+    (write-region
+     (concat
+      "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+     <office:document-meta
+         xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"
+         xmlns:xlink=\"http://www.w3.org/1999/xlink\"
+         xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
+         xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"
+         xmlns:ooo=\"http://openoffice.org/2004/office\"
+         office:version=\"1.2\">
+       <office:meta>\n"
+      (format "<dc:creator>%s</dc:creator>\n" author)
+      (format "<meta:initial-creator>%s</meta:initial-creator>\n" author)
+      ;; Date, if required.
+      (when (plist-get info :with-date)
+       ;; Check if DATE is specified as an Org-timestamp.  If yes,
+       ;; include it as meta information.  Otherwise, just use
+       ;; today's date.
+       (let* ((date (let ((date (plist-get info :date)))
+                      (and (not (cdr date))
+                           (eq (org-element-type (car date)) 'timestamp)
+                           (car date)))))
+         (let ((iso-date (org-odt--format-timestamp date nil 'iso-date)))
+           (concat
+            (format "<dc:date>%s</dc:date>\n" iso-date)
+            (format "<meta:creation-date>%s</meta:creation-date>\n"
+                    iso-date)))))
+      (format "<meta:generator>%s</meta:generator>\n"
+             (let ((creator-info (plist-get info :with-creator)))
+               (if (or (not creator-info) (eq creator-info 'comment)) ""
+                 (plist-get info :creator))))
+      (format "<meta:keyword>%s</meta:keyword>\n" keywords)
+      (format "<dc:subject>%s</dc:subject>\n" description)
+      (format "<dc:title>%s</dc:title>\n" title)
+      "\n"
+      "  </office:meta>\n" "</office:document-meta>")
+     nil (concat org-odt-zip-dir "meta.xml"))
+    ;; Add meta.xml in to manifest.
+    (org-odt-create-manifest-file-entry "text/xml" "meta.xml"))
+
+  ;; Update styles file.
+  ;; Copy styles.xml.  Also dump htmlfontify styles, if there is any.
+  ;; Write styles file.
+  (let* ((styles-file (plist-get info :odt-styles-file))
+        (styles-file (and styles-file (read (org-trim styles-file))))
+        ;; Non-availability of styles.xml is not a critical
+        ;; error. For now, throw an error.
+        (styles-file (or styles-file
+                         org-odt-styles-file
+                         (expand-file-name "OrgOdtStyles.xml"
+                                           org-odt-styles-dir)
+                         (error "org-odt: Missing styles file?"))))
+    (cond
+     ((listp styles-file)
+      (let ((archive (nth 0 styles-file))
+           (members (nth 1 styles-file)))
+       (org-odt--zip-extract archive members org-odt-zip-dir)
+       (mapc
+        (lambda (member)
+          (when (org-file-image-p member)
+            (let* ((image-type (file-name-extension member))
+                   (media-type (format "image/%s" image-type)))
+              (org-odt-create-manifest-file-entry media-type member))))
+        members)))
+     ((and (stringp styles-file) (file-exists-p styles-file))
+      (let ((styles-file-type (file-name-extension styles-file)))
+       (cond
+        ((string= styles-file-type "xml")
+         (copy-file styles-file (concat org-odt-zip-dir "styles.xml") t))
+        ((member styles-file-type '("odt" "ott"))
+         (org-odt--zip-extract styles-file "styles.xml" org-odt-zip-dir)))))
+     (t
+      (error (format "Invalid specification of styles.xml file: %S"
+                    org-odt-styles-file))))
+
+    ;; create a manifest entry for styles.xml
+    (org-odt-create-manifest-file-entry "text/xml" "styles.xml")
+
+    ;; FIXME: Who is opening an empty styles.xml before this point?
+    (with-current-buffer
+       (find-file-noselect (concat org-odt-zip-dir "styles.xml") t)
+      (revert-buffer t t)
+
+      ;; Write custom styles for source blocks
+      ;; Save STYLES used for colorizing of source blocks.
+      ;; Update styles.xml with styles that were collected as part of
+      ;; `org-odt-hfy-face-to-css' callbacks.
+      (let ((styles (mapconcat (lambda (style) (format " %s\n" (cddr style)))
+                              hfy-user-sheet-assoc "")))
+       (when styles
+         (goto-char (point-min))
+         (when (re-search-forward "</office:styles>" nil t)
+           (goto-char (match-beginning 0))
+           (insert "\n<!-- Org Htmlfontify Styles -->\n" styles "\n"))))
+
+      ;; Update styles.xml - take care of outline numbering
+
+      ;; Don't make automatic backup of styles.xml file. This setting
+      ;; prevents the backed-up styles.xml file from being zipped in to
+      ;; odt file. This is more of a hackish fix. Better alternative
+      ;; would be to fix the zip command so that the output odt file
+      ;; includes only the needed files and excludes any auto-generated
+      ;; extra files like backups and auto-saves etc etc. Note that
+      ;; currently the zip command zips up the entire temp directory so
+      ;; that any auto-generated files created under the hood ends up in
+      ;; the resulting odt file.
+      (set (make-local-variable 'backup-inhibited) t)
+
+      ;; Outline numbering is retained only upto LEVEL.
+      ;; To disable outline numbering pass a LEVEL of 0.
+
+      (goto-char (point-min))
+      (let ((regex
+            "<text:outline-level-style\\([^>]*\\)text:level=\"\\([^\"]*\\)\"\\([^>]*\\)>")
+           (replacement
+            "<text:outline-level-style\\1text:level=\"\\2\" style:num-format=\"\">"))
+       (while (re-search-forward regex nil t)
+         (unless (let ((sec-num (plist-get info :section-numbers))
+                       (level (string-to-number (match-string 2))))
+                   (if (wholenump sec-num) (<= level sec-num) sec-num))
+           (replace-match replacement t nil))))
+      (save-buffer 0)))
+  ;; Update content.xml.
+
+  (let* ( ;; `org-display-custom-times' should be accessed right
+        ;; within the context of the Org buffer.  So obtain its
+        ;; value before moving on to temp-buffer context down below.
+        (custom-time-fmts
+         (if org-display-custom-times
+             (cons (substring (car org-time-stamp-custom-formats) 1 -1)
+                   (substring (cdr org-time-stamp-custom-formats) 1 -1))
+           '("%Y-%M-%d %a" . "%Y-%M-%d %a %H:%M"))))
+    (with-temp-buffer
+      (insert-file-contents
+       (or org-odt-content-template-file
+          (expand-file-name "OrgOdtContentTemplate.xml"
+                            org-odt-styles-dir)))
+      ;; Write automatic styles.
+      ;; - Position the cursor.
+      (goto-char (point-min))
+      (re-search-forward "  </office:automatic-styles>" nil t)
+      (goto-char (match-beginning 0))
+      ;; - Dump automatic table styles.
+      (loop for (style-name props) in
+           (plist-get org-odt-automatic-styles 'Table) do
+           (when (setq props (or (plist-get props :rel-width) "96"))
+             (insert (format org-odt-table-style-format style-name props))))
+      ;; - Dump date-styles.
+      (when org-odt-use-date-fields
+       (insert (org-odt--build-date-styles (car custom-time-fmts)
+                                             "OrgDate1")
+               (org-odt--build-date-styles (cdr custom-time-fmts)
+                                             "OrgDate2")))
+      ;; Update display level.
+      ;; - Remove existing sequence decls.  Also position the cursor.
+      (goto-char (point-min))
+      (when (re-search-forward "<text:sequence-decls" nil t)
+       (delete-region (match-beginning 0)
+                      (re-search-forward "</text:sequence-decls>" nil nil)))
+      ;; Update sequence decls according to user preference.
+      (insert
+       (format
+       "\n<text:sequence-decls>\n%s\n</text:sequence-decls>"
+       (mapconcat
+        (lambda (x)
+          (format
+           "<text:sequence-decl text:display-outline-level=\"%d\" text:name=\"%s\"/>"
+           org-odt-display-outline-level (nth 1 x)))
+        org-odt-category-map-alist "\n")))
+      ;; Position the cursor to document body.
+      (goto-char (point-min))
+      (re-search-forward "</office:text>" nil nil)
+      (goto-char (match-beginning 0))
+
+      ;; Preamble - Title, Author, Date etc.
+      (insert
+       (let* ((title (org-export-data (plist-get info :title) info))
+             (author (and (plist-get info :with-author)
+                          (let ((auth (plist-get info :author)))
+                            (and auth (org-export-data auth info)))))
+             (email (plist-get info :email))
+             ;; Switch on or off above vars based on user settings
+             (author (and (plist-get info :with-author) (or author email)))
+             (email (and (plist-get info :with-email) email)))
+        (concat
+         ;; Title.
+         (when title
+           (concat
+            (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                    "OrgTitle" (format "\n<text:title>%s</text:title>" title))
+            ;; Separator.
+            "\n<text:p text:style-name=\"OrgTitle\"/>"))
+         (cond
+          ((and author (not email))
+           ;; Author only.
+           (concat
+            (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                    "OrgSubtitle"
+                    (format "<text:initial-creator>%s</text:initial-creator>" author))
+            ;; Separator.
+            "\n<text:p text:style-name=\"OrgSubtitle\"/>"))
+          ((and author email)
+           ;; Author and E-mail.
+           (concat
+            (format
+             "\n<text:p text:style-name=\"%s\">%s</text:p>"
+             "OrgSubtitle"
+             (format
+              "<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
+              (concat "mailto:" email)
+              (format "<text:initial-creator>%s</text:initial-creator>" author)))
+            ;; Separator.
+            "\n<text:p text:style-name=\"OrgSubtitle\"/>")))
+         ;; Date, if required.
+         (when (plist-get info :with-date)
+           (let* ((date (plist-get info :date))
+                  ;; Check if DATE is specified as a timestamp.
+                  (timestamp (and (not (cdr date))
+                                  (eq (org-element-type (car date)) 'timestamp)
+                                  (car date))))
+             (concat
+              (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                      "OrgSubtitle"
+                      (if (and org-odt-use-date-fields timestamp)
+                          (org-odt--format-timestamp (car date))
+                        (org-export-data (plist-get info :date) info)))
+              ;; Separator
+              "<text:p text:style-name=\"OrgSubtitle\"/>"))))))
+      ;; Table of Contents
+      (let* ((with-toc (plist-get info :with-toc))
+            (depth (and with-toc (if (wholenump with-toc)
+                                     with-toc
+                                   (plist-get info :headline-levels)))))
+       (when depth (insert (or (org-odt-toc depth info) ""))))
+      ;; Contents.
+      (insert contents)
+      ;; Return contents.
+      (buffer-substring-no-properties (point-min) (point-max)))))
+
+
+\f
+;;; Transcode Functions
+
+;;;; Bold
+
+(defun org-odt-bold (bold contents info)
+  "Transcode BOLD from Org to ODT.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "Bold" contents))
+
+
+;;;; Center Block
+
+(defun org-odt-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the center block.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;;; Clock
+
+(defun org-odt-clock (clock contents info)
+  "Transcode a CLOCK element from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let ((timestamp (org-element-property :value clock))
+       (duration (org-element-property :duration clock)))
+    (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+           (if (eq (org-element-type (org-export-get-next-element clock info))
+                   'clock) "OrgClock" "OrgClockLastLine")
+           (concat
+            (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                    "OrgClockKeyword" org-clock-string)
+            (org-odt-timestamp timestamp contents info)
+            (and duration (format " (%s)" duration))))))
+
+
+;;;; Code
+
+(defun org-odt-code (code contents info)
+  "Transcode a CODE object from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "OrgCode" (org-odt--encode-plain-text
+                    (org-element-property :value code))))
+
+
+;;;; Comment
+
+;; Comments are ignored.
+
+
+;;;; Comment Block
+
+;; Comment Blocks are ignored.
+
+
+;;;; Drawer
+
+(defun org-odt-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to ODT.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let* ((name (org-element-property :drawer-name drawer))
+        (output (if (functionp org-odt-format-drawer-function)
+                    (funcall org-odt-format-drawer-function
+                             name contents)
+                  ;; If there's no user defined function: simply
+                  ;; display contents of the drawer.
+                  contents)))
+    output))
+
+
+;;;; Dynamic Block
+
+(defun org-odt-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information.  See `org-export-data'."
+  contents)
+
+
+;;;; Entity
+
+(defun org-odt-entity (entity contents info)
+  "Transcode an ENTITY object from Org to ODT.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (org-element-property :utf-8 entity))
+
+
+;;;; Example Block
+
+(defun org-odt-example-block (example-block contents info)
+  "Transcode a EXAMPLE-BLOCK element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-odt-format-code example-block info))
+
+
+;;;; Export Snippet
+
+(defun org-odt-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (eq (org-export-snippet-backend export-snippet) 'odt)
+    (org-element-property :value export-snippet)))
+
+
+;;;; Export Block
+
+(defun org-odt-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (string= (org-element-property :type export-block) "ODT")
+    (org-remove-indentation (org-element-property :value export-block))))
+
+
+;;;; Fixed Width
+
+(defun org-odt-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-odt-do-format-code (org-element-property :value fixed-width)))
+
+
+;;;; Footnote Definition
+
+;; Footnote Definitions are ignored.
+
+
+;;;; Footnote Reference
+
+(defun org-odt-footnote-reference (footnote-reference contents info)
+  "Transcode a FOOTNOTE-REFERENCE element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((--format-footnote-definition
+        (function
+         (lambda (n def)
+           (setq n (format "%d" n))
+           (let ((id (concat  "fn" n))
+                 (note-class "footnote")
+                 (par-style "Footnote"))
+             (format
+              "<text:note text:id=\"%s\" text:note-class=\"%s\">%s</text:note>"
+              id note-class
+              (concat
+               (format "<text:note-citation>%s</text:note-citation>" n)
+               (format "<text:note-body>%s</text:note-body>" def)))))))
+       (--format-footnote-reference
+        (function
+         (lambda (n)
+           (setq n (format "%d" n))
+           (let ((note-class "footnote")
+                 (ref-format "text")
+                 (ref-name (concat "fn" n)))
+             (format
+              "<text:span text:style-name=\"%s\">%s</text:span>"
+              "OrgSuperscript"
+              (format "<text:note-ref text:note-class=\"%s\" text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:note-ref>"
+                      note-class ref-format ref-name n)))))))
+    (concat
+     ;; Insert separator between two footnotes in a row.
+     (let ((prev (org-export-get-previous-element footnote-reference info)))
+       (and (eq (org-element-type prev) 'footnote-reference)
+           (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                   "OrgSuperscript" ",")))
+     ;; Transcode footnote reference.
+     (let ((n (org-export-get-footnote-number footnote-reference info)))
+       (cond
+       ((not (org-export-footnote-first-reference-p footnote-reference info))
+        (funcall --format-footnote-reference n))
+       ;; Inline definitions are secondary strings.
+       ;; Non-inline footnotes definitions are full Org data.
+       (t
+        (let* ((raw (org-export-get-footnote-definition
+                     footnote-reference info))
+               (def
+                (let ((def (org-trim
+                            (org-export-data-with-backend
+                             raw
+                             (org-export-create-backend
+                              :parent 'odt
+                              :transcoders
+                              '((paragraph . (lambda (p c i)
+                                               (org-odt--format-paragraph
+                                                p c "Footnote"
+                                                "OrgFootnoteCenter"
+                                                "OrgFootnoteQuotations")))))
+                             info))))
+                  (if (eq (org-element-type raw) 'org-data) def
+                    (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                            "Footnote" def)))))
+          (funcall --format-footnote-definition n def))))))))
+
+
+;;;; Headline
+
+(defun* org-odt-format-headline
+    (todo todo-type priority text tags
+         &key level section-number headline-label &allow-other-keys)
+  (concat
+   ;; Todo.
+   (when todo
+     (let ((style (if (member todo org-done-keywords) "OrgDone" "OrgTodo")))
+       (format "<text:span text:style-name=\"%s\">%s</text:span> "
+              style todo)))
+   (when priority
+     (let* ((style (format "OrgPriority-%s" priority))
+           (priority (format "[#%c]" priority)))
+       (format "<text:span text:style-name=\"%s\">%s</text:span> "
+              style priority)))
+   ;; Title.
+   text
+   ;; Tags.
+   (when tags
+     (concat
+      "<text:tab/>"
+      (format "<text:span text:style-name=\"%s\">[%s]</text:span>"
+             "OrgTags" (mapconcat
+                        (lambda (tag)
+                          (format
+                           "<text:span text:style-name=\"%s\">%s</text:span>"
+                           "OrgTag" tag)) tags " : "))))))
+
+(defun org-odt-format-headline--wrap (headline backend info
+                                              &optional format-function
+                                              &rest extra-keys)
+  "Transcode a HEADLINE element using BACKEND.
+INFO is a plist holding contextual information."
+  (setq backend (or backend (plist-get info :back-end)))
+  (let* ((level (+ (org-export-get-relative-level headline info)))
+        (headline-number (org-export-get-headline-number headline info))
+        (section-number (and (org-export-numbered-headline-p headline info)
+                             (mapconcat 'number-to-string
+                                        headline-number ".")))
+        (todo (and (plist-get info :with-todo-keywords)
+                   (let ((todo (org-element-property :todo-keyword headline)))
+                     (and todo
+                          (org-export-data-with-backend todo backend info)))))
+        (todo-type (and todo (org-element-property :todo-type headline)))
+        (priority (and (plist-get info :with-priority)
+                       (org-element-property :priority headline)))
+        (text (org-export-data-with-backend
+               (org-element-property :title headline) backend info))
+        (tags (and (plist-get info :with-tags)
+                   (org-export-get-tags headline info)))
+        (headline-label (concat "sec-" (mapconcat 'number-to-string
+                                                  headline-number "-")))
+        (format-function (cond
+                          ((functionp format-function) format-function)
+                          ((functionp org-odt-format-headline-function)
+                           (function*
+                            (lambda (todo todo-type priority text tags
+                                     &allow-other-keys)
+                              (funcall org-odt-format-headline-function
+                                       todo todo-type priority text tags))))
+                          (t 'org-odt-format-headline))))
+    (apply format-function
+          todo todo-type  priority text tags
+          :headline-label headline-label :level level
+          :section-number section-number extra-keys)))
+
+(defun org-odt-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to ODT.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  ;; Case 1: This is a footnote section: ignore it.
+  (unless (org-element-property :footnote-section-p headline)
+    (let* ((text (org-export-data (org-element-property :title headline) info))
+          ;; Create the headline text.
+          (full-text (org-odt-format-headline--wrap headline nil info))
+          ;; Get level relative to current parsed data.
+          (level (org-export-get-relative-level headline info))
+          ;; Get canonical label for the headline.
+          (id (concat "sec-" (mapconcat 'number-to-string
+                                        (org-export-get-headline-number
+                                         headline info) "-")))
+          ;; Get user-specified labels for the headline.
+          (extra-ids (list (org-element-property :CUSTOM_ID headline)
+                           (org-element-property :ID headline)))
+          ;; Extra targets.
+          (extra-targets
+           (mapconcat (lambda (x)
+                        (when x
+                          (let ((x (if (org-uuidgen-p x) (concat "ID-" x) x)))
+                            (org-odt--target
+                             "" (org-export-solidify-link-text x)))))
+                      extra-ids ""))
+          ;; Title.
+          (anchored-title (org-odt--target full-text id)))
+      (cond
+       ;; Case 2. This is a deep sub-tree: export it as a list item.
+       ;;         Also export as items headlines for which no section
+       ;;         format has been found.
+       ((org-export-low-level-p headline info)
+       ;; Build the real contents of the sub-tree.
+       (concat
+        (and (org-export-first-sibling-p headline info)
+             (format "\n<text:list text:style-name=\"%s\" %s>"
+                     ;; Choose style based on list type.
+                     (if (org-export-numbered-headline-p headline info)
+                         "OrgNumberedList" "OrgBulletedList")
+                     ;; If top-level list, re-start numbering.  Otherwise,
+                     ;; continue numbering.
+                     (format "text:continue-numbering=\"%s\""
+                             (let* ((parent (org-export-get-parent-headline
+                                             headline)))
+                               (if (and parent
+                                        (org-export-low-level-p parent info))
+                                   "true" "false")))))
+        (let ((headline-has-table-p
+               (let ((section (assq 'section (org-element-contents headline))))
+                 (assq 'table (and section (org-element-contents section))))))
+          (format "\n<text:list-item>\n%s\n%s"
+                  (concat
+                   (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                           "Text_20_body"
+                           (concat extra-targets anchored-title))
+                   contents)
+                  (if headline-has-table-p
+                      "</text:list-header>"
+                    "</text:list-item>")))
+        (and (org-export-last-sibling-p headline info)
+             "</text:list>")))
+       ;; Case 3. Standard headline.  Export it as a section.
+       (t
+       (concat
+        (format
+         "\n<text:h text:style-name=\"%s\" text:outline-level=\"%s\">%s</text:h>"
+         (format "Heading_20_%s" level)
+         level
+         (concat extra-targets anchored-title))
+        contents))))))
+
+
+;;;; Horizontal Rule
+
+(defun org-odt-horizontal-rule (horizontal-rule contents info)
+  "Transcode an HORIZONTAL-RULE  object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+         "Horizontal_20_Line" ""))
+
+
+;;;; Inline Babel Call
+
+;; Inline Babel Calls are ignored.
+
+
+;;;; Inline Src Block
+
+(defun org-odt--find-verb-separator (s)
+  "Return a character not used in string S.
+This is used to choose a separator for constructs like \\verb."
+  (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
+    (loop for c across ll
+         when (not (string-match (regexp-quote (char-to-string c)) s))
+         return (char-to-string c))))
+
+(defun org-odt-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((org-lang (org-element-property :language inline-src-block))
+        (code (org-element-property :value inline-src-block))
+        (separator (org-odt--find-verb-separator code)))
+    (error "FIXME")))
+
+
+;;;; Inlinetask
+
+(defun org-odt-inlinetask (inlinetask contents info)
+  "Transcode an INLINETASK element from Org to ODT.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (cond
+   ;; If `org-odt-format-inlinetask-function' is provided, call it
+   ;; with appropriate arguments.
+   ((functionp org-odt-format-inlinetask-function)
+    (let ((format-function
+          (function*
+           (lambda (todo todo-type priority text tags
+                    &key contents &allow-other-keys)
+             (funcall org-odt-format-inlinetask-function
+                      todo todo-type priority text tags contents)))))
+      (org-odt-format-headline--wrap
+       inlinetask nil info format-function :contents contents)))
+   ;; Otherwise, use a default template.
+   (t
+    (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+           "Text_20_body"
+           (org-odt--textbox
+            (concat
+             (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                     "OrgInlineTaskHeading"
+                     (org-odt-format-headline--wrap inlinetask nil info))
+             contents)
+            nil nil "OrgInlineTaskFrame" " style:rel-width=\"100%\"")))))
+
+;;;; Italic
+
+(defun org-odt-italic (italic contents info)
+  "Transcode ITALIC from Org to ODT.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "Emphasis" contents))
+
+
+;;;; Item
+
+(defun org-odt-item (item contents info)
+  "Transcode an ITEM element from Org to ODT.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((plain-list (org-export-get-parent item))
+        (type (org-element-property :type plain-list))
+        (counter (org-element-property :counter item))
+        (tag (let ((tag (org-element-property :tag item)))
+               (and tag
+                    (concat (org-odt--checkbox item)
+                            (org-export-data tag info))))))
+    (case type
+      ((ordered unordered descriptive-1 descriptive-2)
+       (format "\n<text:list-item>\n%s\n%s"
+              contents
+              (let* ((--element-has-a-table-p
+                      (function
+                       (lambda (element info)
+                         (loop for el in (org-element-contents element)
+                               thereis (eq (org-element-type el) 'table))))))
+                (cond
+                 ((funcall --element-has-a-table-p item info)
+                  "</text:list-header>")
+                 (t "</text:list-item>")))))
+      (t (error "Unknown list type: %S" type)))))
+
+;;;; Keyword
+
+(defun org-odt-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "ODT") value)
+     ((string= key "INDEX")
+      ;; FIXME
+      (ignore))
+     ((string= key "TOC")
+      (let ((value (downcase value)))
+       (cond
+        ((string-match "\\<headlines\\>" value)
+         (let ((depth (or (and (string-match "[0-9]+" value)
+                               (string-to-number (match-string 0 value)))
+                          (plist-get info :with-toc))))
+           (when (wholenump depth) (org-odt-toc depth info))))
+        ((member value '("tables" "figures" "listings"))
+         ;; FIXME
+         (ignore))))))))
+
+
+;;;; Latex Environment
+
+
+;; (eval-after-load 'ox-odt '(ad-deactivate 'org-format-latex-as-mathml))
+;; (defadvice org-format-latex-as-mathml       ; FIXME
+;;   (after org-odt-protect-latex-fragment activate)
+;;   "Encode LaTeX fragment as XML.
+;; Do this when translation to MathML fails."
+;;   (unless (> (length ad-return-value) 0)
+;;     (setq ad-return-value (org-odt--encode-plain-text (ad-get-arg 0)))))
+
+(defun org-odt-latex-environment (latex-environment contents info)
+  "Transcode a LATEX-ENVIRONMENT element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let* ((latex-frag (org-remove-indentation
+                     (org-element-property :value latex-environment))))
+    (org-odt-do-format-code latex-frag)))
+
+
+;;;; Latex Fragment
+
+;; (when latex-frag                    ; FIXME
+;;     (setq href (org-propertize href :title "LaTeX Fragment"
+;;                                :description latex-frag)))
+;; handle verbatim
+;; provide descriptions
+
+(defun org-odt-latex-fragment (latex-fragment contents info)
+  "Transcode a LATEX-FRAGMENT object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let* ((latex-frag (org-element-property :value latex-fragment))
+        (processing-type (plist-get info :with-latex)))
+    (format "<text:span text:style-name=\"%s\">%s</text:span>"
+           "OrgCode" (org-odt--encode-plain-text latex-frag t))))
+
+
+;;;; Line Break
+
+(defun org-odt-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  "<text:line-break/>")
+
+
+;;;; Link
+
+;;;; Links :: Label references
+
+(defun org-odt--enumerate (element info &optional predicate n)
+  (when predicate (assert (funcall predicate element info)))
+  (let* ((--numbered-parent-headline-at-<=-n
+         (function
+          (lambda (element n info)
+            (loop for x in (org-export-get-genealogy element)
+                  thereis (and (eq (org-element-type x) 'headline)
+                               (<= (org-export-get-relative-level x info) n)
+                               (org-export-numbered-headline-p x info)
+                               x)))))
+        (--enumerate
+         (function
+          (lambda (element scope info &optional predicate)
+            (let ((counter 0))
+              (org-element-map (or scope (plist-get info :parse-tree))
+                  (org-element-type element)
+                (lambda (el)
+                  (and (or (not predicate) (funcall predicate el info))
+                       (incf counter)
+                       (eq element el)
+                       counter))
+                info 'first-match)))))
+        (scope (funcall --numbered-parent-headline-at-<=-n
+                        element (or n org-odt-display-outline-level) info))
+        (ordinal (funcall --enumerate element scope info predicate))
+        (tag
+         (concat
+          ;; Section number.
+          (and scope
+               (mapconcat 'number-to-string
+                          (org-export-get-headline-number scope info) "."))
+          ;; Separator.
+          (and scope ".")
+          ;; Ordinal.
+          (number-to-string ordinal))))
+    tag))
+
+(defun org-odt-format-label (element info op)
+  "Return a label for ELEMENT.
+
+ELEMENT is a `link', `table', `src-block' or `paragraph' type
+element.  INFO is a plist used as a communication channel.  OP is
+either `definition' or `reference', depending on the purpose of
+the generated string.
+
+Return value is a string if OP is set to `reference' or a cons
+cell like CAPTION . SHORT-CAPTION) where CAPTION and
+SHORT-CAPTION are strings."
+  (assert (memq (org-element-type element) '(link table src-block paragraph)))
+  (let* ((caption-from
+         (case (org-element-type element)
+           (link (org-export-get-parent-element element))
+           (t element)))
+        ;; Get label and caption.
+        (label (org-element-property :name caption-from))
+        (caption (org-export-get-caption caption-from))
+        (short-caption (org-export-get-caption caption-from t))
+        ;; Transcode captions.
+        (caption (and caption (org-export-data caption info)))
+        ;; Currently short caption are sneaked in as object names.
+        ;;
+        ;; The advantages are:
+        ;;
+        ;; - Table Of Contents: Currently, there is no support for
+        ;;   building TOC for figures, listings and tables.  See
+        ;;   `org-odt-keyword'.  User instead has to rely on
+        ;;   external application for building such indices.  Within
+        ;;   LibreOffice, building an "Illustration Index" or "Index
+        ;;   of Tables" will create a table with long captions (only)
+        ;;   and building a table with "Object names" will create a
+        ;;   table with short captions.
+        ;;
+        ;; - Easy navigation: In LibreOffice, object names are
+        ;;   offered via the navigation bar.  This way one can
+        ;;   quickly locate and jump to object of his choice in the
+        ;;   exported document.
+        ;;
+        ;; The main disadvantage is that there cannot be any markups
+        ;; within object names i.e., one cannot embolden, italicize
+        ;; or underline text within short caption.  So suppress
+        ;; generation of <text:span >...</text:span> and other
+        ;; markups by overriding the default translators.  We
+        ;; probably shouldn't be suppressing translators for all
+        ;; elements in `org-element-all-objects', but for now this
+        ;; will do.
+        (short-caption
+         (let ((short-caption (or short-caption caption))
+               (backend (org-export-create-backend
+                         :parent (org-export-backend-name
+                                  (plist-get info :back-end))
+                         :transcoders
+                         (mapcar (lambda (type) (cons type (lambda (o c i) c)))
+                                 org-element-all-objects))))
+           (when short-caption
+             (org-export-data-with-backend short-caption backend info)))))
+    (when (or label caption)
+      (let* ((default-category
+              (case (org-element-type element)
+                (table "__Table__")
+                (src-block "__Listing__")
+                ((link paragraph)
+                 (cond
+                  ((org-odt--enumerable-latex-image-p element info)
+                   "__DvipngImage__")
+                  ((org-odt--enumerable-image-p element info)
+                   "__Figure__")
+                  ((org-odt--enumerable-formula-p element info)
+                   "__MathFormula__")
+                  (t (error "Don't know how to format label for link: %S"
+                            element))))
+                (t (error "Don't know how to format label for element type: %s"
+                          (org-element-type element)))))
+            seqno)
+       (assert default-category)
+       (destructuring-bind (counter label-style category predicate)
+           (assoc-default default-category org-odt-category-map-alist)
+         ;; Compute sequence number of the element.
+         (setq seqno (org-odt--enumerate element info predicate))
+         ;; Localize category string.
+         (setq category (org-export-translate category :utf-8 info))
+         (case op
+           ;; Case 1: Handle Label definition.
+           (definition
+             ;; Assign an internal label, if user has not provided one
+             (setq label (org-export-solidify-link-text
+                          (or label (format  "%s-%s" default-category seqno))))
+             (cons
+              (concat
+               ;; Sneak in a bookmark.  The bookmark is used when the
+               ;; labeled element is referenced with a link that
+               ;; provides its own description.
+               (format "\n<text:bookmark text:name=\"%s\"/>" label)
+               ;; Label definition: Typically formatted as below:
+               ;;     CATEGORY SEQ-NO: LONG CAPTION
+               ;; with translation for correct punctuation.
+               (format-spec
+                (org-export-translate
+                 (cadr (assoc-string label-style org-odt-label-styles t))
+                 :utf-8 info)
+                `((?e . ,category)
+                  (?n . ,(format
+                          "<text:sequence text:ref-name=\"%s\" text:name=\"%s\" text:formula=\"ooow:%s+1\" style:num-format=\"1\">%s</text:sequence>"
+                          label counter counter seqno))
+                  (?c . ,(or caption "")))))
+              short-caption))
+           ;; Case 2: Handle Label reference.
+           (reference
+            (assert label)
+            (setq label (org-export-solidify-link-text label))
+            (let* ((fmt (cddr (assoc-string label-style org-odt-label-styles t)))
+                   (fmt1 (car fmt))
+                   (fmt2 (cadr fmt)))
+              (format "<text:sequence-ref text:reference-format=\"%s\" text:ref-name=\"%s\">%s</text:sequence-ref>"
+                      fmt1 label (format-spec fmt2 `((?e . ,category)
+                                                     (?n . ,seqno))))))
+           (t (error "Unknown %S on label" op))))))))
+
+
+;;;; Links :: Inline Images
+
+(defun org-odt--copy-image-file (path)
+  "Returns the internal name of the file"
+  (let* ((image-type (file-name-extension path))
+        (media-type (format "image/%s" image-type))
+        (target-dir "Images/")
+        (target-file
+         (format "%s%04d.%s" target-dir
+                 (incf org-odt-embedded-images-count) image-type)))
+    (message "Embedding %s as %s..."
+            (substring-no-properties path) target-file)
+
+    (when (= 1 org-odt-embedded-images-count)
+      (make-directory (concat org-odt-zip-dir target-dir))
+      (org-odt-create-manifest-file-entry "" target-dir))
+
+    (copy-file path (concat org-odt-zip-dir target-file) 'overwrite)
+    (org-odt-create-manifest-file-entry media-type target-file)
+    target-file))
+
+(defun org-odt--image-size (file &optional user-width
+                                  user-height scale dpi embed-as)
+  (let* ((--pixels-to-cms
+         (function (lambda (pixels dpi)
+                     (let ((cms-per-inch 2.54)
+                           (inches (/ pixels dpi)))
+                       (* cms-per-inch inches)))))
+        (--size-in-cms
+         (function
+          (lambda (size-in-pixels dpi)
+            (and size-in-pixels
+                 (cons (funcall --pixels-to-cms (car size-in-pixels) dpi)
+                       (funcall --pixels-to-cms (cdr size-in-pixels) dpi))))))
+        (dpi (or dpi org-odt-pixels-per-inch))
+        (anchor-type (or embed-as "paragraph"))
+        (user-width (and (not scale) user-width))
+        (user-height (and (not scale) user-height))
+        (size
+         (and
+          (not (and user-height user-width))
+          (or
+           ;; Use Imagemagick.
+           (and (executable-find "identify")
+                (let ((size-in-pixels
+                       (let ((dim (shell-command-to-string
+                                   (format "identify -format \"%%w:%%h\" \"%s\""
+                                           file))))
+                         (when (string-match "\\([0-9]+\\):\\([0-9]+\\)" dim)
+                           (cons (string-to-number (match-string 1 dim))
+                                 (string-to-number (match-string 2 dim)))))))
+                  (funcall --size-in-cms size-in-pixels dpi)))
+           ;; Use Emacs.
+           (let ((size-in-pixels
+                  (ignore-errors       ; Emacs could be in batch mode
+                    (clear-image-cache)
+                    (image-size (create-image file) 'pixels))))
+             (funcall --size-in-cms size-in-pixels dpi))
+           ;; Use hard-coded values.
+           (cdr (assoc-string anchor-type
+                              org-odt-default-image-sizes-alist))
+           ;; Error out.
+           (error "Cannot determine image size, aborting"))))
+        (width (car size)) (height (cdr size)))
+    (cond
+     (scale
+      (setq width (* width scale) height (* height scale)))
+     ((and user-height user-width)
+      (setq width user-width height user-height))
+     (user-height
+      (setq width (* user-height (/ width height)) height user-height))
+     (user-width
+      (setq height (* user-width (/ height width)) width user-width))
+     (t (ignore)))
+    ;; ensure that an embedded image fits comfortably within a page
+    (let ((max-width (car org-odt-max-image-size))
+         (max-height (cdr org-odt-max-image-size)))
+      (when (or (> width max-width) (> height max-height))
+       (let* ((scale1 (/ max-width width))
+              (scale2 (/ max-height height))
+              (scale (min scale1 scale2)))
+         (setq width (* scale width) height (* scale height)))))
+    (cons width height)))
+
+(defun org-odt-link--inline-image (element info)
+  "Return ODT code for an inline image.
+LINK is the link pointing to the inline image.  INFO is a plist
+used as a communication channel."
+  (assert (eq (org-element-type element) 'link))
+  (let* ((src (let* ((type (org-element-property :type element))
+                    (raw-path (org-element-property :path element)))
+               (cond ((member type '("http" "https"))
+                      (concat type ":" raw-path))
+                     ((file-name-absolute-p raw-path)
+                      (expand-file-name raw-path))
+                     (t raw-path))))
+        (src-expanded (if (file-name-absolute-p src) src
+                        (expand-file-name src (file-name-directory
+                                               (plist-get info :input-file)))))
+        (href (format
+               "\n<draw:image xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>"
+               (org-odt--copy-image-file src-expanded)))
+        ;; Extract attributes from #+ATTR_ODT line.
+        (attr-from (case (org-element-type element)
+                     (link (org-export-get-parent-element element))
+                     (t element)))
+        ;; Convert attributes to a plist.
+        (attr-plist (org-export-read-attribute :attr_odt attr-from))
+        ;; Handle `:anchor', `:style' and `:attributes' properties.
+        (user-frame-anchor
+         (car (assoc-string (plist-get attr-plist :anchor)
+                            '(("as-char") ("paragraph") ("page")) t)))
+        (user-frame-style
+         (and user-frame-anchor (plist-get attr-plist :style)))
+        (user-frame-attrs
+         (and user-frame-anchor (plist-get attr-plist :attributes)))
+        (user-frame-params
+         (list user-frame-style user-frame-attrs user-frame-anchor))
+        ;; (embed-as (or embed-as user-frame-anchor "paragraph"))
+        ;;
+        ;; Handle `:width', `:height' and `:scale' properties.  Read
+        ;; them as numbers since we need them for computations.
+        (size (org-odt--image-size
+               src-expanded
+               (let ((width (plist-get attr-plist :width)))
+                 (and width (read width)))
+               (let ((length (plist-get attr-plist :length)))
+                 (and length (read length)))
+               (let ((scale (plist-get attr-plist :scale)))
+                 (and scale (read scale)))
+               nil                     ; embed-as
+               "paragraph"             ; FIXME
+               ))
+        (width (car size)) (height (cdr size))
+        (standalone-link-p (org-odt--standalone-link-p element info))
+        (embed-as (if standalone-link-p "paragraph" "as-char"))
+        (captions (org-odt-format-label element info 'definition))
+        (caption (car captions)) (short-caption (cdr captions))
+        (entity (concat (and caption "Captioned") embed-as "Image"))
+        ;; Check if this link was created by LaTeX-to-PNG converter.
+        (replaces (org-element-property
+                   :replaces (if (not standalone-link-p) element
+                               (org-export-get-parent-element element))))
+        ;; If yes, note down the type of the element - LaTeX Fragment
+        ;; or LaTeX environment.  It will go in to frame title.
+        (title (and replaces (capitalize
+                              (symbol-name (org-element-type replaces)))))
+
+        ;; If yes, note down its contents.  It will go in to frame
+        ;; description.  This quite useful for debugging.
+        (desc (and replaces (org-element-property :value replaces))))
+    (org-odt--render-image/formula entity href width height
+                                    captions user-frame-params title desc)))
+
+
+;;;; Links :: Math formula
+
+(defun org-odt-link--inline-formula (element info)
+  (let* ((src (let* ((type (org-element-property :type element))
+                    (raw-path (org-element-property :path element)))
+               (cond
+                ((file-name-absolute-p raw-path)
+                 (expand-file-name raw-path))
+                (t raw-path))))
+        (src-expanded (if (file-name-absolute-p src) src
+                        (expand-file-name src (file-name-directory
+                                               (plist-get info :input-file)))))
+        (href
+         (format
+          "\n<draw:object %s xlink:href=\"%s\" xlink:type=\"simple\"/>"
+          " xlink:show=\"embed\" xlink:actuate=\"onLoad\""
+          (file-name-directory (org-odt--copy-formula-file src-expanded))))
+        (standalone-link-p (org-odt--standalone-link-p element info))
+        (embed-as (if standalone-link-p 'paragraph 'character))
+        (captions (org-odt-format-label element info 'definition))
+        (caption (car captions)) (short-caption (cdr captions))
+        ;; Check if this link was created by LaTeX-to-MathML
+        ;; converter.
+        (replaces (org-element-property
+                   :replaces (if (not standalone-link-p) element
+                               (org-export-get-parent-element element))))
+        ;; If yes, note down the type of the element - LaTeX Fragment
+        ;; or LaTeX environment.  It will go in to frame title.
+        (title (and replaces (capitalize
+                              (symbol-name (org-element-type replaces)))))
+
+        ;; If yes, note down its contents.  It will go in to frame
+        ;; description.  This quite useful for debugging.
+        (desc (and replaces (org-element-property :value replaces)))
+        width height)
+    (cond
+     ((eq embed-as 'character)
+      (org-odt--render-image/formula "InlineFormula" href width height
+                                      nil nil title desc))
+     (t
+      (let* ((equation (org-odt--render-image/formula
+                       "CaptionedDisplayFormula" href width height
+                       captions nil title desc))
+            (label
+             (let* ((org-odt-category-map-alist
+                     '(("__MathFormula__" "Text" "math-label" "Equation"
+                        org-odt--enumerable-formula-p))))
+               (car (org-odt-format-label element info 'definition)))))
+       (concat equation "<text:tab/>" label))))))
+
+(defun org-odt--copy-formula-file (src-file)
+  "Returns the internal name of the file"
+  (let* ((target-dir (format "Formula-%04d/"
+                            (incf org-odt-embedded-formulas-count)))
+        (target-file (concat target-dir "content.xml")))
+    ;; Create a directory for holding formula file.  Also enter it in
+    ;; to manifest.
+    (make-directory (concat org-odt-zip-dir target-dir))
+    (org-odt-create-manifest-file-entry
+     "application/vnd.oasis.opendocument.formula" target-dir "1.2")
+    ;; Copy over the formula file from user directory to zip
+    ;; directory.
+    (message "Embedding %s as %s..." src-file target-file)
+    (let ((case-fold-search nil))
+      (cond
+       ;; Case 1: Mathml.
+       ((string-match "\\.\\(mathml\\|mml\\)\\'" src-file)
+       (copy-file src-file (concat org-odt-zip-dir target-file) 'overwrite))
+       ;; Case 2: OpenDocument formula.
+       ((string-match "\\.odf\\'" src-file)
+       (org-odt--zip-extract src-file "content.xml"
+                               (concat org-odt-zip-dir target-dir)))
+       (t (error "%s is not a formula file" src-file))))
+    ;; Enter the formula file in to manifest.
+    (org-odt-create-manifest-file-entry "text/xml" target-file)
+    target-file))
+
+;;;; Targets
+
+(defun org-odt--render-image/formula (cfg-key href width height &optional
+                                               captions user-frame-params
+                                               &rest title-and-desc)
+  (let* ((frame-cfg-alist
+         ;; Each element of this alist is of the form (CFG-HANDLE
+         ;; INNER-FRAME-PARAMS OUTER-FRAME-PARAMS).
+
+         ;; CFG-HANDLE is the key to the alist.
+
+         ;; INNER-FRAME-PARAMS and OUTER-FRAME-PARAMS specify the
+         ;; frame params for INNER-FRAME and OUTER-FRAME
+         ;; respectively.  See below.
+
+         ;; Configurations that are meant to be applied to
+         ;; non-captioned image/formula specifies no
+         ;; OUTER-FRAME-PARAMS.
+
+         ;; TERMINOLOGY
+         ;; ===========
+         ;; INNER-FRAME :: Frame that directly surrounds an
+         ;;                image/formula.
+
+         ;; OUTER-FRAME :: Frame that encloses the INNER-FRAME.  This
+         ;;                frame also contains the caption, if any.
+
+         ;; FRAME-PARAMS :: List of the form (FRAME-STYLE-NAME
+         ;;                 FRAME-ATTRIBUTES FRAME-ANCHOR).  Note
+         ;;                 that these are the last three arguments
+         ;;                 to `org-odt--frame'.
+
+         ;; Note that an un-captioned image/formula requires just an
+         ;; INNER-FRAME, while a captioned image/formula requires
+         ;; both an INNER and an OUTER-FRAME.
+         '(("As-CharImage" ("OrgInlineImage" nil "as-char"))
+           ("ParagraphImage" ("OrgDisplayImage" nil "paragraph"))
+           ("PageImage" ("OrgPageImage" nil "page"))
+           ("CaptionedAs-CharImage"
+            ("OrgCaptionedImage"
+             " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+            ("OrgInlineImage" nil "as-char"))
+           ("CaptionedParagraphImage"
+            ("OrgCaptionedImage"
+             " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+            ("OrgImageCaptionFrame" nil "paragraph"))
+           ("CaptionedPageImage"
+            ("OrgCaptionedImage"
+             " style:rel-width=\"100%\" style:rel-height=\"scale\"" "paragraph")
+            ("OrgPageImageCaptionFrame" nil "page"))
+           ("InlineFormula" ("OrgInlineFormula" nil "as-char"))
+           ("DisplayFormula" ("OrgDisplayFormula" nil "as-char"))
+           ("CaptionedDisplayFormula"
+            ("OrgCaptionedFormula" nil "paragraph")
+            ("OrgFormulaCaptionFrame" nil "paragraph"))))
+        (caption (car captions)) (short-caption (cdr captions))
+        ;; Retrieve inner and outer frame params, from configuration.
+        (frame-cfg (assoc-string cfg-key frame-cfg-alist t))
+        (inner (nth 1 frame-cfg))
+        (outer (nth 2 frame-cfg))
+        ;; User-specified frame params (from #+ATTR_ODT spec)
+        (user user-frame-params)
+        (--merge-frame-params (function
+                               (lambda (default user)
+                                 "Merge default and user frame params."
+                                 (if (not user) default
+                                   (assert (= (length default) 3))
+                                   (assert (= (length user) 3))
+                                   (loop for u in user
+                                         for d in default
+                                         collect (or u d)))))))
+    (cond
+     ;; Case 1: Image/Formula has no caption.
+     ;;         There is only one frame, one that surrounds the image
+     ;;         or formula.
+     ((not caption)
+      ;; Merge user frame params with that from configuration.
+      (setq inner (funcall --merge-frame-params inner user))
+      (apply 'org-odt--frame href width height
+            (append inner title-and-desc)))
+     ;; Case 2: Image/Formula is captioned or labeled.
+     ;;         There are two frames: The inner one surrounds the
+     ;;         image or formula.  The outer one contains the
+     ;;         caption/sequence number.
+     (t
+      ;; Merge user frame params with outer frame params.
+      (setq outer (funcall --merge-frame-params outer user))
+      ;; Short caption, if specified, goes as part of inner frame.
+      (setq inner (let ((frame-params (copy-sequence inner)))
+                   (setcar (cdr frame-params)
+                           (concat
+                            (cadr frame-params)
+                            (when short-caption
+                              (format " draw:name=\"%s\" " short-caption))))
+                   frame-params))
+      (apply 'org-odt--textbox
+            (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                    "Illustration"
+                    (concat
+                     (apply 'org-odt--frame href width height
+                            (append inner title-and-desc))
+                     caption))
+            width height outer)))))
+
+(defun org-odt--enumerable-p (element info)
+  ;; Element should have a caption or label.
+  (or (org-element-property :caption element)
+      (org-element-property :name element)))
+
+(defun org-odt--enumerable-image-p (element info)
+  (org-odt--standalone-link-p
+   element info
+   ;; Paragraph should have a caption or label.  It SHOULD NOT be a
+   ;; replacement element. (i.e., It SHOULD NOT be a result of LaTeX
+   ;; processing.)
+   (lambda (p)
+     (and (not (org-element-property :replaces p))
+         (or (org-element-property :caption p)
+             (org-element-property :name p))))
+   ;; Link should point to an image file.
+   (lambda (l)
+     (assert (eq (org-element-type l) 'link))
+     (org-export-inline-image-p l org-odt-inline-image-rules))))
+
+(defun org-odt--enumerable-latex-image-p (element info)
+  (org-odt--standalone-link-p
+   element info
+   ;; Paragraph should have a caption or label.  It SHOULD also be a
+   ;; replacement element. (i.e., It SHOULD be a result of LaTeX
+   ;; processing.)
+   (lambda (p)
+     (and (org-element-property :replaces p)
+         (or (org-element-property :caption p)
+             (org-element-property :name p))))
+   ;; Link should point to an image file.
+   (lambda (l)
+     (assert (eq (org-element-type l) 'link))
+     (org-export-inline-image-p l org-odt-inline-image-rules))))
+
+(defun org-odt--enumerable-formula-p (element info)
+  (org-odt--standalone-link-p
+   element info
+   ;; Paragraph should have a caption or label.
+   (lambda (p)
+     (or (org-element-property :caption p)
+        (org-element-property :name p)))
+   ;; Link should point to a MathML or ODF file.
+   (lambda (l)
+     (assert (eq (org-element-type l) 'link))
+     (org-export-inline-image-p l org-odt-inline-formula-rules))))
+
+(defun org-odt--standalone-link-p (element info &optional
+                                            paragraph-predicate
+                                            link-predicate)
+  "Test if ELEMENT is a standalone link for the purpose ODT export.
+INFO is a plist holding contextual information.
+
+Return non-nil, if ELEMENT is of type paragraph satisfying
+PARAGRAPH-PREDICATE and its sole content, save for whitespaces,
+is a link that satisfies LINK-PREDICATE.
+
+Return non-nil, if ELEMENT is of type link satisfying
+LINK-PREDICATE and its containing paragraph satisfies
+PARAGRAPH-PREDICATE in addition to having no other content save for
+leading and trailing whitespaces.
+
+Return nil, otherwise."
+  (let ((p (case (org-element-type element)
+            (paragraph element)
+            (link (and (or (not link-predicate)
+                           (funcall link-predicate element))
+                       (org-export-get-parent element)))
+            (t nil))))
+    (when (and p (eq (org-element-type p) 'paragraph))
+      (when (or (not paragraph-predicate)
+               (funcall paragraph-predicate p))
+       (let ((contents (org-element-contents p)))
+         (loop for x in contents
+               with inline-image-count = 0
+               always (case (org-element-type x)
+                        (plain-text
+                         (not (org-string-nw-p x)))
+                        (link
+                         (and (or (not link-predicate)
+                                  (funcall link-predicate x))
+                              (= (incf inline-image-count) 1)))
+                        (t nil))))))))
+
+(defun org-odt-link--infer-description (destination info)
+  ;; DESTINATION is a HEADLINE, a "<<target>>" or an element (like
+  ;; paragraph, verse-block etc) to which a "#+NAME: label" can be
+  ;; attached.  Note that labels that are attached to captioned
+  ;; entities - inline images, math formulae and tables - get resolved
+  ;; as part of `org-odt-format-label' and `org-odt--enumerate'.
+
+  ;; Create a cross-reference to DESTINATION but make best-efforts to
+  ;; create a *meaningful* description.  Check item numbers, section
+  ;; number and section title in that order.
+
+  ;; NOTE: Counterpart of `org-export-get-ordinal'.
+  ;; FIXME: Handle footnote-definition footnote-reference?
+  (let* ((genealogy (org-export-get-genealogy destination))
+        (data (reverse genealogy))
+        (label (case (org-element-type destination)
+                 (headline
+                  (format "sec-%s" (mapconcat 'number-to-string
+                                              (org-export-get-headline-number
+                                               destination info) "-")))
+                 (target
+                  (org-element-property :value destination))
+                 (t (error "FIXME: Resolve %S" destination)))))
+    (or
+     (let* ( ;; Locate top-level list.
+           (top-level-list
+            (loop for x on data
+                  when (eq (org-element-type (car x)) 'plain-list)
+                  return x))
+           ;; Get list item nos.
+           (item-numbers
+            (loop for (plain-list item . rest) on top-level-list by #'cddr
+                  until (not (eq (org-element-type plain-list) 'plain-list))
+                  collect (when (eq (org-element-property :type
+                                                          plain-list)
+                                    'ordered)
+                            (1+ (length (org-export-get-previous-element
+                                         item info t))))))
+           ;; Locate top-most listified headline.
+           (listified-headlines
+            (loop for x on data
+                  when (and (eq (org-element-type (car x)) 'headline)
+                            (org-export-low-level-p (car x) info))
+                  return x))
+           ;; Get listified headline numbers.
+           (listified-headline-nos
+            (loop for el in listified-headlines
+                  when (eq (org-element-type el) 'headline)
+                  collect (when (org-export-numbered-headline-p el info)
+                            (1+ (length (org-export-get-previous-element
+                                         el info t)))))))
+       ;; Combine item numbers from both the listified headlines and
+       ;; regular list items.
+
+       ;; Case 1: Check if all the parents of list item are numbered.
+       ;; If yes, link to the item proper.
+       (let ((item-numbers (append listified-headline-nos item-numbers)))
+        (when (and item-numbers (not (memq nil item-numbers)))
+          (format "<text:bookmark-ref text:reference-format=\"number-all-superior\" text:ref-name=\"%s\">%s</text:bookmark-ref>"
+                  (org-export-solidify-link-text label)
+                  (mapconcat (lambda (n) (if (not n) " "
+                                           (concat (number-to-string n) ".")))
+                             item-numbers "")))))
+     ;; Case 2: Locate a regular and numbered headline in the
+     ;; hierarchy.  Display its section number.
+     (let ((headline (loop for el in (cons destination genealogy)
+                          when (and (eq (org-element-type el) 'headline)
+                                    (not (org-export-low-level-p el info))
+                                    (org-export-numbered-headline-p el info))
+                          return el)))
+       ;; We found one.
+       (when headline
+        (format "<text:bookmark-ref text:reference-format=\"chapter\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+                (org-export-solidify-link-text label)
+                (mapconcat 'number-to-string (org-export-get-headline-number
+                                              headline info) "."))))
+     ;; Case 4: Locate a regular headline in the hierarchy.  Display
+     ;; its title.
+     (let ((headline (loop for el in (cons destination genealogy)
+                          when (and (eq (org-element-type el) 'headline)
+                                    (not (org-export-low-level-p el info)))
+                          return el)))
+       ;; We found one.
+       (when headline
+        (format "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+                (org-export-solidify-link-text label)
+                (let ((title (org-element-property :title headline)))
+                  (org-export-data title info)))))
+     (error "FIXME?"))))
+
+(defun org-odt-link (link desc info)
+  "Transcode a LINK object from Org to ODT.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information.  See
+`org-export-data'."
+  (let* ((type (org-element-property :type link))
+        (raw-path (org-element-property :path link))
+        ;; Ensure DESC really exists, or set it to nil.
+        (desc (and (not (string= desc "")) desc))
+        (imagep (org-export-inline-image-p
+                 link org-odt-inline-image-rules))
+        (path (cond
+               ((member type '("http" "https" "ftp" "mailto"))
+                (concat type ":" raw-path))
+               ((string= type "file")
+                (if (file-name-absolute-p raw-path)
+                    (concat "file://" (expand-file-name raw-path))
+                  (concat "file://" raw-path)))
+               (t raw-path)))
+        ;; Convert & to &amp; for correct XML representation
+        (path (replace-regexp-in-string "&" "&amp;" path))
+        protocol)
+    (cond
+     ;; Image file.
+     ((and (not desc) (org-export-inline-image-p
+                      link org-odt-inline-image-rules))
+      (org-odt-link--inline-image link info))
+     ;; Formula file.
+     ((and (not desc) (org-export-inline-image-p
+                      link org-odt-inline-formula-rules))
+      (org-odt-link--inline-formula link info))
+     ;; Radio target: Transcode target's contents and use them as
+     ;; link's description.
+     ((string= type "radio")
+      (let ((destination (org-export-resolve-radio-link link info)))
+       (when destination
+         (let ((desc (org-export-data (org-element-contents destination) info))
+               (href (org-export-solidify-link-text path)))
+           (format
+            "<text:bookmark-ref text:reference-format=\"text\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+            href desc)))))
+     ;; Links pointing to a headline: Find destination and build
+     ;; appropriate referencing command.
+     ((member type '("custom-id" "fuzzy" "id"))
+      (let ((destination (if (string= type "fuzzy")
+                            (org-export-resolve-fuzzy-link link info)
+                          (org-export-resolve-id-link link info))))
+       (case (org-element-type destination)
+         ;; Case 1: Fuzzy link points nowhere.
+         ('nil
+          (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                  "Emphasis"
+                  (or desc
+                      (org-export-data (org-element-property :raw-link link)
+                                       info))))
+         ;; Case 2: Fuzzy link points to a headline.
+         (headline
+          ;; If there's a description, create a hyperlink.
+          ;; Otherwise, try to provide a meaningful description.
+          (if (not desc) (org-odt-link--infer-description destination info)
+            (let* ((headline-no
+                    (org-export-get-headline-number destination info))
+                   (label
+                    (format "sec-%s"
+                            (mapconcat 'number-to-string headline-no "-"))))
+              (format
+               "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
+               label desc))))
+         ;; Case 3: Fuzzy link points to a target.
+         (target
+          ;; If there's a description, create a hyperlink.
+          ;; Otherwise, try to provide a meaningful description.
+          (if (not desc) (org-odt-link--infer-description destination info)
+            (let ((label (org-element-property :value destination)))
+              (format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
+                      (org-export-solidify-link-text label)
+                      desc))))
+         ;; Case 4: Fuzzy link points to some element (e.g., an
+         ;; inline image, a math formula or a table).
+         (otherwise
+          (let ((label-reference
+                 (ignore-errors (org-odt-format-label
+                                 destination info 'reference))))
+            (cond ((not label-reference)
+                   (org-odt-link--infer-description destination info))
+                  ;; LINK has no description.  Create
+                  ;; a cross-reference showing entity's sequence
+                  ;; number.
+                  ((not desc) label-reference)
+                  ;; LINK has description.  Insert a hyperlink with
+                  ;; user-provided description.
+                  (t
+                   (let ((label (org-element-property :name destination)))
+                     (format "<text:a xlink:type=\"simple\" xlink:href=\"#%s\">%s</text:a>"
+                             (org-export-solidify-link-text label)
+                             desc)))))))))
+     ;; Coderef: replace link with the reference name or the
+     ;; equivalent line number.
+     ((string= type "coderef")
+      (let* ((line-no (format "%d" (org-export-resolve-coderef path info)))
+            (href (concat "coderef-" path)))
+       (format
+        (org-export-get-coderef-format path desc)
+        (format
+         "<text:bookmark-ref text:reference-format=\"number\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
+         href line-no))))
+     ;; Link type is handled by a special function.
+     ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
+      (funcall protocol (org-link-unescape path) desc 'odt))
+     ;; External link with a description part.
+     ((and path desc)
+      (let ((link-contents (org-element-contents link)))
+       ;; Check if description is a link to an inline image.
+       (if (and (not (cdr link-contents))
+                (let ((desc-element (car link-contents)))
+                  (and (eq (org-element-type desc-element) 'link)
+                       (org-export-inline-image-p
+                        desc-element org-odt-inline-image-rules))))
+           ;; Format link as a clickable image.
+           (format "\n<draw:a xlink:type=\"simple\" xlink:href=\"%s\">\n%s\n</draw:a>"
+                   path desc)
+         ;; Otherwise, format it as a regular link.
+         (format "<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
+                 path desc))))
+     ;; External link without a description part.
+     (path
+      (format "<text:a xlink:type=\"simple\" xlink:href=\"%s\">%s</text:a>"
+             path path))
+     ;; No path, only description.  Try to do something useful.
+     (t (format "<text:span text:style-name=\"%s\">%s</text:span>"
+               "Emphasis" desc)))))
+
+
+;;;; Paragraph
+
+(defun org-odt--format-paragraph (paragraph contents default center quote)
+  "Format paragraph according to given styles.
+PARAGRAPH is a paragraph type element.  CONTENTS is the
+transcoded contents of that paragraph, as a string.  DEFAULT,
+CENTER and QUOTE are, respectively, style to use when paragraph
+belongs to no special environment, a center block, or a quote
+block."
+  (let* ((parent (org-export-get-parent paragraph))
+        (parent-type (org-element-type parent))
+        (style (case parent-type
+                 (quote-block quote)
+                 (center-block center)
+                 (t default))))
+    ;; If this paragraph is a leading paragraph in an item and the
+    ;; item has a checkbox, splice the checkbox and paragraph contents
+    ;; together.
+    (when (and (eq (org-element-type parent) 'item)
+              (eq paragraph (car (org-element-contents parent))))
+      (setq contents (concat (org-odt--checkbox parent) contents)))
+    (format "\n<text:p text:style-name=\"%s\">%s</text:p>" style contents)))
+
+(defun org-odt-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to ODT.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  (org-odt--format-paragraph
+   paragraph contents
+   (or (org-element-property :style paragraph) "Text_20_body")
+   "OrgCenter"
+   "Quotations"))
+
+
+;;;; Plain List
+
+(defun org-odt-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to ODT.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  (format "\n<text:list text:style-name=\"%s\" %s>\n%s</text:list>"
+         ;; Choose style based on list type.
+         (case (org-element-property :type plain-list)
+           (ordered "OrgNumberedList")
+           (unordered "OrgBulletedList")
+           (descriptive-1 "OrgDescriptionList")
+           (descriptive-2 "OrgDescriptionList"))
+         ;; If top-level list, re-start numbering.  Otherwise,
+         ;; continue numbering.
+         (format "text:continue-numbering=\"%s\""
+                 (let* ((parent (org-export-get-parent plain-list)))
+                   (if (and parent (eq (org-element-type parent) 'item))
+                       "true" "false")))
+         contents))
+
+;;;; Plain Text
+
+(defun org-odt--encode-tabs-and-spaces (line)
+  (replace-regexp-in-string
+   "\\([\t]\\|\\([ ]+\\)\\)"
+   (lambda (s)
+     (cond
+      ((string= s "\t") "<text:tab/>")
+      (t (let ((n (length s)))
+          (cond
+           ((= n 1) " ")
+           ((> n 1) (concat " " (format "<text:s text:c=\"%d\"/>" (1- n))))
+           (t ""))))))
+   line))
+
+(defun org-odt--encode-plain-text (text &optional no-whitespace-filling)
+  (mapc
+   (lambda (pair)
+     (setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))
+   '(("&" . "&amp;") ("<" . "&lt;") (">" . "&gt;")))
+  (if no-whitespace-filling text
+    (org-odt--encode-tabs-and-spaces text)))
+
+(defun org-odt-plain-text (text info)
+  "Transcode a TEXT string from Org to ODT.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  (let ((output text))
+    ;; Protect &, < and >.
+    (setq output (org-odt--encode-plain-text output t))
+    ;; Handle smart quotes.  Be sure to provide original string since
+    ;; OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output (org-export-activate-smart-quotes output :utf-8 info text)))
+    ;; Convert special strings.
+    (when (plist-get info :with-special-strings)
+      (mapc
+       (lambda (pair)
+        (setq output
+              (replace-regexp-in-string (car pair) (cdr pair) output t nil)))
+       org-odt-special-string-regexps))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string
+                   "\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>" output t)))
+    ;; Return value.
+    output))
+
+
+;;;; Planning
+
+(defun org-odt-planning (planning contents info)
+  "Transcode a PLANNING element from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+         "OrgPlanning"
+         (concat
+          (let ((closed (org-element-property :closed planning)))
+            (when closed
+              (concat
+               (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                       "OrgClosedKeyword" org-closed-string)
+               (org-odt-timestamp closed contents info))))
+          (let ((deadline (org-element-property :deadline planning)))
+            (when deadline
+              (concat
+               (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                       "OrgDeadlineKeyword" org-deadline-string)
+               (org-odt-timestamp deadline contents info))))
+          (let ((scheduled (org-element-property :scheduled planning)))
+            (when scheduled
+              (concat
+               (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                       "OrgScheduledKeyword" org-deadline-string)
+               (org-odt-timestamp scheduled contents info)))))))
+
+
+;;;; Property Drawer
+
+(defun org-odt-property-drawer (property-drawer contents info)
+  "Transcode a PROPERTY-DRAWER element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  ;; The property drawer isn't exported but we want separating blank
+  ;; lines nonetheless.
+  "")
+
+
+;;;; Quote Block
+
+(defun org-odt-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  contents)
+
+
+;;;; Quote Section
+
+(defun org-odt-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((value (org-remove-indentation
+               (org-element-property :value quote-section))))
+    (when value (org-odt-do-format-code value))))
+
+
+;;;; Section
+
+(defun org-odt-format-section (text style &optional name)
+  (let ((default-name (car (org-odt-add-automatic-style "Section"))))
+    (format "\n<text:section text:style-name=\"%s\" %s>\n%s\n</text:section>"
+           style
+           (format "text:name=\"%s\"" (or name default-name))
+           text)))
+
+
+(defun org-odt-section (section contents info) ; FIXME
+  "Transcode a SECTION element from Org to ODT.
+CONTENTS holds the contents of the section.  INFO is a plist
+holding contextual information."
+  contents)
+
+;;;; Radio Target
+
+(defun org-odt-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object from Org to ODT.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  (org-odt--target
+   text (org-export-solidify-link-text
+        (org-element-property :value radio-target))))
+
+
+;;;; Special Block
+
+(defun org-odt-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((type (downcase (org-element-property :type special-block)))
+       (attributes (org-export-read-attribute :attr_odt special-block)))
+    (cond
+     ;; Annotation.
+     ((string= type "annotation")
+      (let* ((author (or (plist-get attributes :author)
+                        (let ((author (plist-get info :author)))
+                          (and author (org-export-data author info)))))
+            (date (or (plist-get attributes :date)
+                      ;; FIXME: Is `car' right thing to do below?
+                      (car (plist-get info :date)))))
+       (format "\n<text:p>%s</text:p>"
+               (format "<office:annotation>\n%s\n</office:annotation>"
+                       (concat
+                        (and author
+                             (format "<dc:creator>%s</dc:creator>" author))
+                        (and date
+                             (format "<dc:date>%s</dc:date>"
+                                     (org-odt--format-timestamp date nil 'iso-date)))
+                        contents)))))
+     ;; Textbox.
+     ((string= type "textbox")
+      (let ((width (plist-get attributes :width))
+           (height (plist-get attributes :height))
+           (style (plist-get attributes :style))
+           (extra (plist-get attributes :extra))
+           (anchor (plist-get attributes :anchor)))
+       (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+               "Text_20_body" (org-odt--textbox contents width height
+                                                  style extra anchor))))
+     (t contents))))
+
+
+;;;; Src Block
+
+(defun org-odt-hfy-face-to-css (fn)
+  "Create custom style for face FN.
+When FN is the default face, use its foreground and background
+properties to create \"OrgSrcBlock\" paragraph style.  Otherwise
+use its color attribute to create a character style whose name
+is obtained from FN.  Currently all attributes of FN other than
+color are ignored.
+
+The style name for a face FN is derived using the following
+operations on the face name in that order - de-dash, CamelCase
+and prefix with \"OrgSrc\".  For example,
+`font-lock-function-name-face' is associated with
+\"OrgSrcFontLockFunctionNameFace\"."
+  (let* ((css-list (hfy-face-to-style fn))
+        (style-name (concat "OrgSrc"
+                             (mapconcat
+                              'capitalize (split-string
+                                           (hfy-face-or-def-to-name fn) "-")
+                              "")))
+        (color-val (cdr (assoc "color" css-list)))
+        (background-color-val (cdr (assoc "background" css-list)))
+        (style (and org-odt-create-custom-styles-for-srcblocks
+                    (cond
+                     ((eq fn 'default)
+                      (format org-odt-src-block-paragraph-format
+                              background-color-val color-val))
+                     (t
+                      (format
+                       "
+<style:style style:name=\"%s\" style:family=\"text\">
+  <style:text-properties fo:color=\"%s\"/>
+ </style:style>" style-name color-val))))))
+    (cons style-name style)))
+
+(defun org-odt-htmlfontify-string (line)
+  (let* ((hfy-html-quote-regex "\\([<\"&>      ]\\)")
+        (hfy-html-quote-map '(("\"" "&quot;")
+                              ("<" "&lt;")
+                              ("&" "&amp;")
+                              (">" "&gt;")
+                              (" " "<text:s/>")
+                              ("       " "<text:tab/>")))
+        (hfy-face-to-css 'org-odt-hfy-face-to-css)
+        (hfy-optimisations-1 (copy-sequence hfy-optimisations))
+        (hfy-optimisations (add-to-list 'hfy-optimisations-1
+                                        'body-text-only))
+        (hfy-begin-span-handler
+         (lambda (style text-block text-id text-begins-block-p)
+           (insert (format "<text:span text:style-name=\"%s\">" style))))
+        (hfy-end-span-handler (lambda nil (insert "</text:span>"))))
+    (org-no-warnings (htmlfontify-string line))))
+
+(defun org-odt-do-format-code
+  (code &optional lang refs retain-labels num-start)
+  (let* ((lang (or (assoc-default lang org-src-lang-modes) lang))
+        (lang-mode (and lang (intern (format "%s-mode" lang))))
+        (code-lines (org-split-string code "\n"))
+        (code-length (length code-lines))
+        (use-htmlfontify-p (and (functionp lang-mode)
+                                org-odt-fontify-srcblocks
+                                (require 'htmlfontify nil t)
+                                (fboundp 'htmlfontify-string)))
+        (code (if (not use-htmlfontify-p) code
+                (with-temp-buffer
+                  (insert code)
+                  (funcall lang-mode)
+                  (font-lock-fontify-buffer)
+                  (buffer-string))))
+        (fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string
+                     'org-odt--encode-plain-text))
+        (par-style (if use-htmlfontify-p "OrgSrcBlock"
+                     "OrgFixedWidthBlock"))
+        (i 0))
+    (assert (= code-length (length (org-split-string code "\n"))))
+    (setq code
+         (org-export-format-code
+          code
+          (lambda (loc line-num ref)
+            (setq par-style
+                  (concat par-style (and (= (incf i) code-length) "LastLine")))
+
+            (setq loc (concat loc (and ref retain-labels (format " (%s)" ref))))
+            (setq loc (funcall fontifier loc))
+            (when ref
+              (setq loc (org-odt--target loc (concat "coderef-" ref))))
+            (assert par-style)
+            (setq loc (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                              par-style loc))
+            (if (not line-num) loc
+              (format "\n<text:list-item>%s\n</text:list-item>" loc)))
+          num-start refs))
+    (cond
+     ((not num-start) code)
+     ((= num-start 0)
+      (format
+       "\n<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>%s</text:list>"
+       " text:continue-numbering=\"false\"" code))
+     (t
+      (format
+       "\n<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>%s</text:list>"
+       " text:continue-numbering=\"true\"" code)))))
+
+(defun org-odt-format-code (element info)
+  (let* ((lang (org-element-property :language element))
+        ;; Extract code and references.
+        (code-info (org-export-unravel-code element))
+        (code (car code-info))
+        (refs (cdr code-info))
+        ;; Does the src block contain labels?
+        (retain-labels (org-element-property :retain-labels element))
+        ;; Does it have line numbers?
+        (num-start (case (org-element-property :number-lines element)
+                     (continued (org-export-get-loc element info))
+                     (new 0))))
+    (org-odt-do-format-code code lang refs retain-labels num-start)))
+
+(defun org-odt-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to ODT.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((lang (org-element-property :language src-block))
+        (attributes (org-export-read-attribute :attr_odt src-block))
+        (captions (org-odt-format-label src-block info 'definition))
+        (caption (car captions)) (short-caption (cdr captions)))
+    (concat
+     (and caption
+         (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                 "Listing" caption))
+     (let ((--src-block (org-odt-format-code src-block info)))
+       (if (not (plist-get attributes :textbox)) --src-block
+        (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                "Text_20_body"
+                (org-odt--textbox --src-block nil nil nil)))))))
+
+
+;;;; Statistics Cookie
+
+(defun org-odt-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((cookie-value (org-element-property :value statistics-cookie)))
+    (format "<text:span text:style-name=\"%s\">%s</text:span>"
+           "OrgCode" cookie-value)))
+
+
+;;;; Strike-Through
+
+(defun org-odt-strike-through (strike-through contents info)
+  "Transcode STRIKE-THROUGH from Org to ODT.
+CONTENTS is the text with strike-through markup.  INFO is a plist
+holding contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "Strikethrough" contents))
+
+
+;;;; Subscript
+
+(defun org-odt-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to ODT.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "OrgSubscript" contents))
+
+
+;;;; Superscript
+
+(defun org-odt-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to ODT.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "OrgSuperscript" contents))
+
+
+;;;; Table Cell
+
+(defun org-odt-table-style-spec (element info)
+  (let* ((table (org-export-get-parent-table element))
+        (table-attributes (org-export-read-attribute :attr_odt table))
+        (table-style (plist-get table-attributes :style)))
+    (assoc table-style org-odt-table-styles)))
+
+(defun org-odt-get-table-cell-styles (table-cell info)
+  "Retrieve styles applicable to a table cell.
+R and C are (zero-based) row and column numbers of the table
+cell.  STYLE-SPEC is an entry in `org-odt-table-styles'
+applicable to the current table.  It is `nil' if the table is not
+associated with any style attributes.
+
+Return a cons of (TABLE-CELL-STYLE-NAME . PARAGRAPH-STYLE-NAME).
+
+When STYLE-SPEC is nil, style the table cell the conventional way
+- choose cell borders based on row and column groupings and
+choose paragraph alignment based on `org-col-cookies' text
+property.  See also
+`org-odt-get-paragraph-style-cookie-for-table-cell'.
+
+When STYLE-SPEC is non-nil, ignore the above cookie and return
+styles congruent with the ODF-1.2 specification."
+  (let* ((table-cell-address (org-export-table-cell-address table-cell info))
+        (r (car table-cell-address)) (c (cdr table-cell-address))
+        (style-spec (org-odt-table-style-spec table-cell info))
+        (table-dimensions (org-export-table-dimensions
+                           (org-export-get-parent-table table-cell)
+                           info)))
+    (when style-spec
+      ;; LibreOffice - particularly the Writer - honors neither table
+      ;; templates nor custom table-cell styles.  Inorder to retain
+      ;; inter-operability with LibreOffice, only automatic styles are
+      ;; used for styling of table-cells.  The current implementation is
+      ;; congruent with ODF-1.2 specification and hence is
+      ;; future-compatible.
+
+      ;; Additional Note: LibreOffice's AutoFormat facility for tables -
+      ;; which recognizes as many as 16 different cell types - is much
+      ;; richer. Unfortunately it is NOT amenable to easy configuration
+      ;; by hand.
+      (let* ((template-name (nth 1 style-spec))
+            (cell-style-selectors (nth 2 style-spec))
+            (cell-type
+             (cond
+              ((and (cdr (assoc 'use-first-column-styles cell-style-selectors))
+                    (= c 0)) "FirstColumn")
+              ((and (cdr (assoc 'use-last-column-styles cell-style-selectors))
+                    (= (1+ c) (cdr table-dimensions)))
+               "LastColumn")
+              ((and (cdr (assoc 'use-first-row-styles cell-style-selectors))
+                    (= r 0)) "FirstRow")
+              ((and (cdr (assoc 'use-last-row-styles cell-style-selectors))
+                    (= (1+ r) (car table-dimensions)))
+               "LastRow")
+              ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
+                    (= (% r 2) 1)) "EvenRow")
+              ((and (cdr (assoc 'use-banding-rows-styles cell-style-selectors))
+                    (= (% r 2) 0)) "OddRow")
+              ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
+                    (= (% c 2) 1)) "EvenColumn")
+              ((and (cdr (assoc 'use-banding-columns-styles cell-style-selectors))
+                    (= (% c 2) 0)) "OddColumn")
+              (t ""))))
+       (concat template-name cell-type)))))
+
+(defun org-odt-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL element from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let* ((table-cell-address (org-export-table-cell-address table-cell info))
+        (r (car table-cell-address))
+        (c (cdr table-cell-address))
+        (horiz-span (or (org-export-table-cell-width table-cell info) 0))
+        (table-row (org-export-get-parent table-cell))
+        (custom-style-prefix (org-odt-get-table-cell-styles
+                              table-cell info))
+        (paragraph-style
+         (or
+          (and custom-style-prefix
+               (format "%sTableParagraph" custom-style-prefix))
+          (concat
+           (cond
+            ((and (= 1 (org-export-table-row-group table-row info))
+                  (org-export-table-has-header-p
+                   (org-export-get-parent-table table-row) info))
+             "OrgTableHeading")
+            ((let* ((table (org-export-get-parent-table table-cell))
+                    (table-attrs (org-export-read-attribute :attr_odt table))
+                    (table-header-columns
+                     (let ((cols (plist-get table-attrs :header-columns)))
+                       (and cols (read cols)))))
+               (<= c (cond ((wholenump table-header-columns)
+                            (- table-header-columns 1))
+                           (table-header-columns 0)
+                           (t -1))))
+             "OrgTableHeading")
+            (t "OrgTableContents"))
+           (capitalize (symbol-name (org-export-table-cell-alignment
+                                     table-cell info))))))
+        (cell-style-name
+         (or
+          (and custom-style-prefix (format "%sTableCell"
+                                           custom-style-prefix))
+          (concat
+           "OrgTblCell"
+           (when (or (org-export-table-row-starts-rowgroup-p table-row info)
+                     (zerop r)) "T")
+           (when (org-export-table-row-ends-rowgroup-p table-row info) "B")
+           (when (and (org-export-table-cell-starts-colgroup-p table-cell info)
+                      (not (zerop c)) ) "L"))))
+        (cell-attributes
+         (concat
+          (format " table:style-name=\"%s\"" cell-style-name)
+          (and (> horiz-span 0)
+               (format " table:number-columns-spanned=\"%d\""
+                       (1+ horiz-span))))))
+    (unless contents (setq contents ""))
+    (concat
+     (assert paragraph-style)
+     (format "\n<table:table-cell%s>\n%s\n</table:table-cell>"
+            cell-attributes
+            (let ((table-cell-contents (org-element-contents table-cell)))
+              (if (memq (org-element-type (car table-cell-contents))
+                        org-element-all-elements)
+                  contents
+                (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                        paragraph-style contents))))
+     (let (s)
+       (dotimes (i horiz-span s)
+        (setq s (concat s "\n<table:covered-table-cell/>"))))
+     "\n")))
+
+
+;;;; Table Row
+
+(defun org-odt-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to ODT.
+CONTENTS is the contents of the row.  INFO is a plist used as a
+communication channel."
+  ;; Rules are ignored since table separators are deduced from
+  ;; borders of the current row.
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let* ((rowgroup-tags
+           (if (and (= 1 (org-export-table-row-group table-row info))
+                    (org-export-table-has-header-p
+                     (org-export-get-parent-table table-row) info))
+               ;; If the row belongs to the first rowgroup and the
+               ;; table has more than one row groups, then this row
+               ;; belongs to the header row group.
+               '("\n<table:table-header-rows>" . "\n</table:table-header-rows>")
+             ;; Otherwise, it belongs to non-header row group.
+             '("\n<table:table-rows>" . "\n</table:table-rows>"))))
+      (concat
+       ;; Does this row begin a rowgroup?
+       (when (org-export-table-row-starts-rowgroup-p table-row info)
+        (car rowgroup-tags))
+       ;; Actual table row
+       (format "\n<table:table-row>\n%s\n</table:table-row>" contents)
+       ;; Does this row end a rowgroup?
+       (when (org-export-table-row-ends-rowgroup-p table-row info)
+        (cdr rowgroup-tags))))))
+
+
+;;;; Table
+
+(defun org-odt-table-first-row-data-cells (table info)
+  (let ((table-row
+        (org-element-map table 'table-row
+          (lambda (row)
+            (unless (eq (org-element-property :type row) 'rule) row))
+          info 'first-match))
+       (special-column-p (org-export-table-has-special-column-p table)))
+    (if (not special-column-p) (org-element-contents table-row)
+      (cdr (org-element-contents table-row)))))
+
+(defun org-odt--table (table contents info)
+  "Transcode a TABLE element from Org to ODT.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (case (org-element-property :type table)
+    ;; Case 1: table.el doesn't support export to OD format.  Strip
+    ;; such tables from export.
+    (table.el
+     (prog1 nil
+       (message
+       (concat
+        "(ox-odt): Found table.el-type table in the source Org file."
+        "  table.el doesn't support export to ODT format."
+        "  Stripping the table from export."))))
+    ;; Case 2: Native Org tables.
+    (otherwise
+     (let* ((captions (org-odt-format-label table info 'definition))
+           (caption (car captions)) (short-caption (cdr captions))
+           (attributes (org-export-read-attribute :attr_odt table))
+           (custom-table-style (nth 1 (org-odt-table-style-spec table info)))
+           (table-column-specs
+            (function
+             (lambda (table info)
+               (let* ((table-style (or custom-table-style "OrgTable"))
+                      (column-style (format "%sColumn" table-style)))
+                 (mapconcat
+                  (lambda (table-cell)
+                    (let ((width (1+ (or (org-export-table-cell-width
+                                          table-cell info) 0)))
+                          (s (format
+                              "\n<table:table-column table:style-name=\"%s\"/>"
+                              column-style))
+                          out)
+                      (dotimes (i width out) (setq out (concat s out)))))
+                  (org-odt-table-first-row-data-cells table info) "\n"))))))
+       (concat
+       ;; caption.
+       (when caption
+         (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+                 "Table" caption))
+       ;; begin table.
+       (let* ((automatic-name
+               (org-odt-add-automatic-style "Table" attributes)))
+         (format
+          "\n<table:table table:style-name=\"%s\"%s>"
+          (or custom-table-style (cdr automatic-name) "OrgTable")
+          (concat (when short-caption
+                    (format " table:name=\"%s\"" short-caption)))))
+       ;; column specification.
+       (funcall table-column-specs table info)
+       ;; actual contents.
+       "\n" contents
+       ;; end table.
+       "</table:table>")))))
+
+(defun org-odt-table (table contents info)
+  "Transcode a TABLE element from Org to ODT.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information.
+
+Use `org-odt--table' to typeset the table.  Handle details
+pertaining to indentation here."
+  (let* ((--element-preceded-by-table-p
+         (function
+          (lambda (element info)
+            (loop for el in (org-export-get-previous-element element info t)
+                  thereis (eq (org-element-type el) 'table)))))
+        (--walk-list-genealogy-and-collect-tags
+         (function
+          (lambda (table info)
+            (let* ((genealogy (org-export-get-genealogy table))
+                   (list-genealogy
+                    (when (eq (org-element-type (car genealogy)) 'item)
+                      (loop for el in genealogy
+                            when (memq (org-element-type el)
+                                       '(item plain-list))
+                            collect el)))
+                   (llh-genealogy
+                    (apply 'nconc
+                           (loop for el in genealogy
+                                 when (and (eq (org-element-type el) 'headline)
+                                           (org-export-low-level-p el info))
+                                 collect
+                                 (list el
+                                       (assq 'headline
+                                             (org-element-contents
+                                              (org-export-get-parent el)))))))
+                   parent-list)
+              (nconc
+               ;; Handle list genealogy.
+               (loop for el in list-genealogy collect
+                     (case (org-element-type el)
+                       (plain-list
+                        (setq parent-list el)
+                        (cons "</text:list>"
+                              (format "\n<text:list text:style-name=\"%s\" %s>"
+                                      (case (org-element-property :type el)
+                                        (ordered "OrgNumberedList")
+                                        (unordered "OrgBulletedList")
+                                        (descriptive-1 "OrgDescriptionList")
+                                        (descriptive-2 "OrgDescriptionList"))
+                                      "text:continue-numbering=\"true\"")))
+                       (item
+                        (cond
+                         ((not parent-list)
+                          (if (funcall --element-preceded-by-table-p table info)
+                              '("</text:list-header>" . "<text:list-header>")
+                            '("</text:list-item>" . "<text:list-header>")))
+                         ((funcall --element-preceded-by-table-p
+                                   parent-list info)
+                          '("</text:list-header>" . "<text:list-header>"))
+                         (t '("</text:list-item>" . "<text:list-item>"))))))
+               ;; Handle low-level headlines.
+               (loop for el in llh-genealogy
+                     with step = 'item collect
+                     (case step
+                       (plain-list
+                        (setq step 'item) ; Flip-flop
+                        (setq parent-list el)
+                        (cons "</text:list>"
+                              (format "\n<text:list text:style-name=\"%s\" %s>"
+                                      (if (org-export-numbered-headline-p
+                                           el info)
+                                          "OrgNumberedList"
+                                        "OrgBulletedList")
+                                      "text:continue-numbering=\"true\"")))
+                       (item
+                        (setq step 'plain-list) ; Flip-flop
+                        (cond
+                         ((not parent-list)
+                          (if (funcall --element-preceded-by-table-p table info)
+                              '("</text:list-header>" . "<text:list-header>")
+                            '("</text:list-item>" . "<text:list-header>")))
+                         ((let ((section? (org-export-get-previous-element
+                                           parent-list info)))
+                            (and section?
+                                 (eq (org-element-type section?) 'section)
+                                 (assq 'table (org-element-contents section?))))
+                          '("</text:list-header>" . "<text:list-header>"))
+                         (t
+                          '("</text:list-item>" . "<text:list-item>")))))))))))
+        (close-open-tags (funcall --walk-list-genealogy-and-collect-tags
+                                  table info)))
+    ;; OpenDocument schema does not permit table to occur within a
+    ;; list item.
+
+    ;; One solution - the easiest and lightweight, in terms of
+    ;; implementation - is to put the table in an indented text box
+    ;; and make the text box part of the list-item.  Unfortunately if
+    ;; the table is big and spans multiple pages, the text box could
+    ;; overflow.  In this case, the following attribute will come
+    ;; handy.
+
+    ;; ,---- From OpenDocument-v1.1.pdf
+    ;; | 15.27.28 Overflow behavior
+    ;; |
+    ;; | For text boxes contained within text document, the
+    ;; | style:overflow-behavior property specifies the behavior of text
+    ;; | boxes where the containing text does not fit into the text
+    ;; | box.
+    ;; |
+    ;; | If the attribute's value is clip, the text that does not fit
+    ;; | into the text box is not displayed.
+    ;; |
+    ;; | If the attribute value is auto-create-new-frame, a new frame
+    ;; | will be created on the next page, with the same position and
+    ;; | dimensions of the original frame.
+    ;; |
+    ;; | If the style:overflow-behavior property's value is
+    ;; | auto-create-new-frame and the text box has a minimum width or
+    ;; | height specified, then the text box will grow until the page
+    ;; | bounds are reached before a new frame is created.
+    ;; `----
+
+    ;; Unfortunately, LibreOffice-3.4.6 doesn't honor
+    ;; auto-create-new-frame property and always resorts to clipping
+    ;; the text box.  This results in table being truncated.
+
+    ;; So we solve the problem the hard (and fun) way using list
+    ;; continuations.
+
+    ;; The problem only becomes more interesting if you take in to
+    ;; account the following facts:
+    ;;
+    ;; - Description lists are simulated as plain lists.
+    ;; - Low-level headlines can be listified.
+    ;; - In Org-mode, a table can occur not only as a regular list
+    ;;   item, but also within description lists and low-level
+    ;;   headlines.
+
+    ;; See `org-odt-translate-description-lists' and
+    ;; `org-odt-translate-low-level-headlines' for how this is
+    ;; tackled.
+
+    (concat "\n"
+           ;; Discontinue the list.
+           (mapconcat 'car close-open-tags "\n")
+           ;; Put the table in an indented section.
+           (let* ((table (org-odt--table table contents info))
+                  (level (/ (length (mapcar 'car close-open-tags)) 2))
+                  (style (format "OrgIndentedSection-Level-%d" level)))
+             (when table (org-odt-format-section table style)))
+           ;; Continue the list.
+           (mapconcat 'cdr (nreverse close-open-tags) "\n"))))
+
+
+;;;; Target
+
+(defun org-odt-target (target contents info)
+  "Transcode a TARGET object from Org to ODT.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((value (org-element-property :value target)))
+    (org-odt--target "" (org-export-solidify-link-text value))))
+
+
+;;;; Timestamp
+
+(defun org-odt-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (let* ((raw-value (org-element-property :raw-value timestamp))
+        (type (org-element-property :type timestamp)))
+    (if (not org-odt-use-date-fields)
+       (let ((value (org-odt-plain-text
+                     (org-timestamp-translate timestamp) info)))
+         (case (org-element-property :type timestamp)
+           ((active active-range)
+            (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                    "OrgActiveTimestamp" value))
+           ((inactive inactive-range)
+            (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                    "OrgInactiveTimestamp" value))
+           (otherwise value)))
+      (case type
+       (active
+        (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                "OrgActiveTimestamp"
+                (format "&lt;%s&gt;" (org-odt--format-timestamp timestamp))))
+       (inactive
+        (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                "OrgInactiveTimestamp"
+                (format "[%s]" (org-odt--format-timestamp timestamp))))
+       (active-range
+        (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                "OrgActiveTimestamp"
+                (format "&lt;%s&gt;&#x2013;&lt;%s&gt;"
+                        (org-odt--format-timestamp timestamp)
+                        (org-odt--format-timestamp timestamp 'end))))
+       (inactive-range
+        (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                "OrgInactiveTimestamp"
+                (format "[%s]&#x2013;[%s]"
+                        (org-odt--format-timestamp timestamp)
+                        (org-odt--format-timestamp timestamp 'end))))
+       (otherwise
+        (format "<text:span text:style-name=\"%s\">%s</text:span>"
+                "OrgDiaryTimestamp"
+                (org-odt-plain-text (org-timestamp-translate timestamp)
+                                      info)))))))
+
+
+;;;; Underline
+
+(defun org-odt-underline (underline contents info)
+  "Transcode UNDERLINE from Org to ODT.
+CONTENTS is the text with underline markup.  INFO is a plist
+holding contextual information."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "Underline" contents))
+
+
+;;;; Verbatim
+
+(defun org-odt-verbatim (verbatim contents info)
+  "Transcode a VERBATIM object from Org to ODT.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (format "<text:span text:style-name=\"%s\">%s</text:span>"
+         "OrgCode" (org-odt--encode-plain-text
+                    (org-element-property :value verbatim))))
+
+
+;;;; Verse Block
+
+(defun org-odt-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to ODT.
+CONTENTS is verse block contents.  INFO is a plist holding
+contextual information."
+  ;; Add line breaks to each line of verse.
+  (setq contents (replace-regexp-in-string
+                 "\\(<text:line-break/>\\)?[ \t]*\n"
+                 "<text:line-break/>" contents))
+  ;; Replace tabs and spaces.
+  (setq contents (org-odt--encode-tabs-and-spaces contents))
+  ;; Surround it in a verse environment.
+  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+         "OrgVerse" contents))
+
+
+\f
+;;; Filters
+
+;;;; LaTeX fragments
+
+(defun org-odt--translate-latex-fragments (tree backend info)
+  (let ((processing-type (plist-get info :with-latex))
+       (count 0))
+    ;; Normalize processing-type to one of dvipng, mathml or verbatim.
+    ;; If the desired converter is not available, force verbatim
+    ;; processing.
+    (case processing-type
+      ((t mathml)
+       (if (and (fboundp 'org-format-latex-mathml-available-p)
+               (org-format-latex-mathml-available-p))
+          (setq processing-type 'mathml)
+        (message "LaTeX to MathML converter not available.")
+        (setq processing-type 'verbatim)))
+      ((dvipng imagemagick)
+       (unless (and (org-check-external-command "latex" "" t)
+                   (org-check-external-command
+                    (if (eq processing-type 'dvipng) "dvipng" "convert") "" t))
+        (message "LaTeX to PNG converter not available.")
+        (setq processing-type 'verbatim)))
+      (otherwise
+       (message "Unknown LaTeX option.  Forcing verbatim.")
+       (setq processing-type 'verbatim)))
+
+    ;; Store normalized value for later use.
+    (when (plist-get info :with-latex)
+      (plist-put info :with-latex processing-type))
+    (message "Formatting LaTeX using %s" processing-type)
+
+    ;; Convert `latex-fragment's and `latex-environment's.
+    (when (memq processing-type '(mathml dvipng imagemagick))
+      (org-element-map tree '(latex-fragment latex-environment)
+       (lambda (latex-*)
+         (incf count)
+         (let* ((latex-frag (org-element-property :value latex-*))
+                (input-file (plist-get info :input-file))
+                (cache-dir (file-name-directory input-file))
+                (cache-subdir (concat
+                               (case processing-type
+                                 ((dvipng imagemagick) "ltxpng/")
+                                 (mathml "ltxmathml/"))
+                               (file-name-sans-extension
+                                (file-name-nondirectory input-file))))
+                (display-msg
+                 (case processing-type
+                   ((dvipng imagemagick) (format "Creating LaTeX Image %d..." count))
+                   (mathml (format "Creating MathML snippet %d..." count))))
+                ;; Get an Org-style link to PNG image or the MathML
+                ;; file.
+                (org-link
+                 (let ((link (with-temp-buffer
+                               (insert latex-frag)
+                               (org-format-latex cache-subdir cache-dir
+                                                 nil display-msg
+                                                 nil nil processing-type)
+                               (buffer-substring-no-properties
+                                (point-min) (point-max)))))
+                   (if (not (string-match "file:\\([^]]*\\)" link))
+                       (prog1 nil (message "LaTeX Conversion failed."))
+                     link))))
+           (when org-link
+             ;; Conversion succeeded.  Parse above Org-style link to a
+             ;; `link' object.
+             (let* ((link (car (org-element-map (with-temp-buffer
+                                                  (org-mode)
+                                                  (insert org-link)
+                                                  (org-element-parse-buffer))
+                                   'link 'identity))))
+               ;; Orphan the link.
+               (org-element-put-property link :parent nil)
+               (let* (
+                      (replacement
+                       (case (org-element-type latex-*)
+                         ;; Case 1: LaTeX environment.
+                         ;; Mimic a "standalone image or formula" by
+                         ;; enclosing the `link' in a `paragraph'.
+                         ;; Copy over original attributes, captions to
+                         ;; the enclosing paragraph.
+                         (latex-environment
+                          (org-element-adopt-elements
+                           (list 'paragraph
+                                 (list :style "OrgFormula"
+                                       :name (org-element-property :name
+                                                                   latex-*)
+                                       :caption (org-element-property :caption
+                                                                      latex-*)))
+                           link))
+                         ;; Case 2: LaTeX fragment.
+                         ;; No special action.
+                         (latex-fragment link))))
+                 ;; Note down the object that link replaces.
+                 (org-element-put-property replacement :replaces
+                                           (list (org-element-type latex-*)
+                                                 (list :value latex-frag)))
+                 ;; Replace now.
+                 (org-element-set-element latex-* replacement))))))
+       info)))
+  tree)
+
+
+;;;; Description lists
+
+;; This translator is necessary to handle indented tables in a uniform
+;; manner.  See comment in `org-odt--table'.
+
+(defun org-odt--translate-description-lists (tree backend info)
+  ;; OpenDocument has no notion of a description list.  So simulate it
+  ;; using plain lists.  Description lists in the exported document
+  ;; are typeset in the same manner as they are in a typical HTML
+  ;; document.
+  ;;
+  ;; Specifically, a description list like this:
+  ;;
+  ;;     ,----
+  ;;     | - term-1 :: definition-1
+  ;;     | - term-2 :: definition-2
+  ;;     `----
+  ;;
+  ;; gets translated in to the following form:
+  ;;
+  ;;     ,----
+  ;;     | - term-1
+  ;;     |   - definition-1
+  ;;     | - term-2
+  ;;     |   - definition-2
+  ;;     `----
+  ;;
+  ;; Further effect is achieved by fixing the OD styles as below:
+  ;;
+  ;; 1. Set the :type property of the simulated lists to
+  ;;    `descriptive-1' and `descriptive-2'.  Map these to list-styles
+  ;;    that has *no* bullets whatsoever.
+  ;;
+  ;; 2. The paragraph containing the definition term is styled to be
+  ;;    in bold.
+  ;;
+  (org-element-map tree 'plain-list
+    (lambda (el)
+      (when (equal (org-element-property :type el) 'descriptive)
+       (org-element-set-element
+        el
+        (apply 'org-element-adopt-elements
+               (list 'plain-list (list :type 'descriptive-1))
+               (mapcar
+                (lambda (item)
+                  (org-element-adopt-elements
+                   (list 'item (list :checkbox (org-element-property
+                                                :checkbox item)))
+                   (list 'paragraph (list :style "Text_20_body_20_bold")
+                         (or (org-element-property :tag item) "(no term)"))
+                   (org-element-adopt-elements
+                    (list 'plain-list (list :type 'descriptive-2))
+                    (apply 'org-element-adopt-elements
+                           (list 'item nil)
+                           (org-element-contents item)))))
+                (org-element-contents el)))))
+      nil)
+    info)
+  tree)
+
+;;;; List tables
+
+;; Lists that are marked with attribute `:list-table' are called as
+;; list tables.  They will be rendered as a table within the exported
+;; document.
+
+;; Consider an example.  The following list table
+;;
+;; #+attr_odt :list-table t
+;; - Row 1
+;;   - 1.1
+;;   - 1.2
+;;   - 1.3
+;; - Row 2
+;;   - 2.1
+;;   - 2.2
+;;   - 2.3
+;;
+;; will be exported as though it were an Org table like the one show
+;; below.
+;;
+;; | Row 1 | 1.1 | 1.2 | 1.3 |
+;; | Row 2 | 2.1 | 2.2 | 2.3 |
+;;
+;; Note that org-tables are NOT multi-line and each line is mapped to
+;; a unique row in the exported document.  So if an exported table
+;; needs to contain a single paragraph (with copious text) it needs to
+;; be typed up in a single line.  Editing such long lines using the
+;; table editor will be a cumbersome task.  Furthermore inclusion of
+;; multi-paragraph text in a table cell is well-nigh impossible.
+;;
+;; A LIST-TABLE circumvents above problems.
+;;
+;; Note that in the example above the list items could be paragraphs
+;; themselves and the list can be arbitrarily deep.
+;;
+;; Inspired by following thread:
+;; https://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01101.html
+
+;; Translate lists to tables
+
+(defun org-odt--translate-list-tables (tree backend info)
+  (org-element-map tree 'plain-list
+    (lambda (l1-list)
+      (when (org-export-read-attribute :attr_odt l1-list :list-table)
+       ;; Replace list with table.
+       (org-element-set-element
+        l1-list
+        ;; Build replacement table.
+        (apply 'org-element-adopt-elements
+               (list 'table '(:type org :attr_odt (":style \"GriddedTable\"")))
+               (org-element-map l1-list 'item
+                 (lambda (l1-item)
+                   (let* ((l1-item-contents (org-element-contents l1-item))
+                          l1-item-leading-text l2-list)
+                     ;; Remove Level-2 list from the Level-item.  It
+                     ;; will be subsequently attached as table-cells.
+                     (let ((cur l1-item-contents) prev)
+                       (while (and cur (not (eq (org-element-type (car cur))
+                                                'plain-list)))
+                         (setq prev cur)
+                         (setq cur (cdr cur)))
+                       (when prev
+                         (setcdr prev nil)
+                         (setq l2-list (car cur)))
+                       (setq l1-item-leading-text l1-item-contents))
+                     ;; Level-1 items start a table row.
+                     (apply 'org-element-adopt-elements
+                            (list 'table-row (list :type 'standard))
+                            ;;  Leading text of level-1 item define
+                            ;;  the first table-cell.
+                            (apply 'org-element-adopt-elements
+                                   (list 'table-cell nil)
+                                   l1-item-leading-text)
+                            ;; Level-2 items define subsequent
+                            ;; table-cells of the row.
+                            (org-element-map l2-list 'item
+                              (lambda (l2-item)
+                                (apply 'org-element-adopt-elements
+                                       (list 'table-cell nil)
+                                       (org-element-contents l2-item)))
+                              info nil 'item))))
+                 info nil 'item))))
+      nil)
+    info)
+  tree)
+
+\f
+;;; Interactive functions
+
+(defun org-odt-create-manifest-file-entry (&rest args)
+  (push args org-odt-manifest-file-entries))
+
+(defun org-odt-write-manifest-file ()
+  (make-directory (concat org-odt-zip-dir "META-INF"))
+  (let ((manifest-file (concat org-odt-zip-dir "META-INF/manifest.xml")))
+    (with-current-buffer
+       (let ((nxml-auto-insert-xml-declaration-flag nil))
+         (find-file-noselect manifest-file t))
+      (insert
+       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+     <manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\" manifest:version=\"1.2\">\n")
+      (mapc
+       (lambda (file-entry)
+        (let* ((version (nth 2 file-entry))
+               (extra (if (not version) ""
+                        (format " manifest:version=\"%s\"" version))))
+          (insert
+           (format org-odt-manifest-file-entry-tag
+                   (nth 0 file-entry) (nth 1 file-entry) extra))))
+       org-odt-manifest-file-entries)
+      (insert "\n</manifest:manifest>"))))
+
+(defmacro org-odt--export-wrap (out-file &rest body)
+  `(let* ((--out-file ,out-file)
+         (out-file-type (file-name-extension --out-file))
+         (org-odt-xml-files '("META-INF/manifest.xml" "content.xml"
+                                "meta.xml" "styles.xml"))
+         ;; Initialize temporary workarea.  All files that end up in
+         ;; the exported document get parked/created here.
+         (org-odt-zip-dir (file-name-as-directory
+                             (make-temp-file (format "%s-" out-file-type) t)))
+         (org-odt-manifest-file-entries nil)
+         (--cleanup-xml-buffers
+          (function
+           (lambda nil
+             ;; Kill all XML buffers.
+             (mapc (lambda (file)
+                     (let ((buf (find-buffer-visiting
+                                 (concat org-odt-zip-dir file))))
+                       (when buf
+                         (with-current-buffer buf
+                           (set-buffer-modified-p nil)
+                           (kill-buffer buf)))))
+                   org-odt-xml-files)
+             ;; Delete temporary directory and also other embedded
+             ;; files that get copied there.
+             (delete-directory org-odt-zip-dir t)))))
+     (condition-case err
+        (progn
+          (unless (executable-find "zip")
+            ;; Not at all OSes ship with zip by default
+            (error "Executable \"zip\" needed for creating OpenDocument files"))
+          ;; Do export.  This creates a bunch of xml files ready to be
+          ;; saved and zipped.
+          (progn ,@body)
+          ;; Create a manifest entry for content.xml.
+          (org-odt-create-manifest-file-entry "text/xml" "content.xml")
+          ;; Write mimetype file
+          (let* ((mimetypes
+                  '(("odt" . "application/vnd.oasis.opendocument.text")
+                    ("odf" .  "application/vnd.oasis.opendocument.formula")))
+                 (mimetype (cdr (assoc-string out-file-type mimetypes t))))
+            (unless mimetype
+              (error "Unknown OpenDocument backend %S" out-file-type))
+            (write-region mimetype nil (concat org-odt-zip-dir "mimetype"))
+            (org-odt-create-manifest-file-entry mimetype "/" "1.2"))
+          ;; Write out the manifest entries before zipping
+          (org-odt-write-manifest-file)
+          ;; Save all XML files.
+          (mapc (lambda (file)
+                  (let ((buf (find-buffer-visiting
+                              (concat org-odt-zip-dir file))))
+                    (when buf
+                      (with-current-buffer buf
+                        ;; Prettify output if needed.
+                        (when org-odt-prettify-xml
+                          (indent-region (point-min) (point-max)))
+                        (save-buffer 0)))))
+                org-odt-xml-files)
+          ;; Run zip.
+          (let* ((target --out-file)
+                 (target-name (file-name-nondirectory target))
+                 (cmds `(("zip" "-mX0" ,target-name "mimetype")
+                         ("zip" "-rmTq" ,target-name "."))))
+            ;; If a file with same name as the desired output file
+            ;; exists, remove it.
+            (when (file-exists-p target)
+              (delete-file target))
+            ;; Zip up the xml files.
+            (let ((coding-system-for-write 'no-conversion) exitcode err-string)
+              (message "Creating ODT file...")
+              ;; Switch temporarily to content.xml.  This way Zip
+              ;; process will inherit `org-odt-zip-dir' as the current
+              ;; directory.
+              (with-current-buffer
+                  (find-file-noselect (concat org-odt-zip-dir "content.xml") t)
+                (mapc
+                 (lambda (cmd)
+                   (message "Running %s" (mapconcat 'identity cmd " "))
+                   (setq err-string
+                         (with-output-to-string
+                           (setq exitcode
+                                 (apply 'call-process (car cmd)
+                                        nil standard-output nil (cdr cmd)))))
+                   (or (zerop exitcode)
+                       (error (concat "Unable to create OpenDocument file."
+                                      (format "  Zip failed with error (%s)"
+                                              err-string)))))
+                 cmds)))
+            ;; Move the zip file from temporary work directory to
+            ;; user-mandated location.
+            (rename-file (concat org-odt-zip-dir target-name) target)
+            (message "Created %s" (expand-file-name target))
+            ;; Cleanup work directory and work files.
+            (funcall --cleanup-xml-buffers)
+            ;; Open the OpenDocument file in archive-mode for
+            ;; examination.
+            (find-file-noselect target t)
+            ;; Return exported file.
+            (cond
+             ;; Case 1: Conversion desired on exported file.  Run the
+             ;; converter on the OpenDocument file.  Return the
+             ;; converted file.
+             (org-odt-preferred-output-format
+              (or (org-odt-convert target org-odt-preferred-output-format)
+                  target))
+             ;; Case 2: No further conversion.  Return exported
+             ;; OpenDocument file.
+             (t target))))
+       (error
+       ;; Cleanup work directory and work files.
+       (funcall --cleanup-xml-buffers)
+       (message "OpenDocument export failed: %s"
+                (error-message-string err))))))
+
+
+;;;; Export to OpenDocument formula
+
+;;;###autoload
+(defun org-odt-export-as-odf (latex-frag &optional odf-file)
+  "Export LATEX-FRAG as OpenDocument formula file ODF-FILE.
+Use `org-create-math-formula' to convert LATEX-FRAG first to
+MathML.  When invoked as an interactive command, use
+`org-latex-regexps' to infer LATEX-FRAG from currently active
+region.  If no LaTeX fragments are found, prompt for it.  Push
+MathML source to kill ring depending on the value of
+`org-export-copy-to-kill-ring'."
+  (interactive
+   `(,(let (frag)
+       (setq frag (and (setq frag (and (region-active-p)
+                                       (buffer-substring (region-beginning)
+                                                         (region-end))))
+                       (loop for e in org-latex-regexps
+                             thereis (when (string-match (nth 1 e) frag)
+                                       (match-string (nth 2 e) frag)))))
+       (read-string "LaTeX Fragment: " frag nil frag))
+     ,(let ((odf-filename (expand-file-name
+                          (concat
+                           (file-name-sans-extension
+                            (or (file-name-nondirectory buffer-file-name)))
+                           "." "odf")
+                          (file-name-directory buffer-file-name))))
+       (read-file-name "ODF filename: " nil odf-filename nil
+                       (file-name-nondirectory odf-filename)))))
+  (let ((filename (or odf-file
+                     (expand-file-name
+                      (concat
+                       (file-name-sans-extension
+                        (or (file-name-nondirectory buffer-file-name)))
+                       "." "odf")
+                      (file-name-directory buffer-file-name)))))
+    (org-odt--export-wrap
+     filename
+     (let* ((buffer (progn
+                     (require 'nxml-mode)
+                     (let ((nxml-auto-insert-xml-declaration-flag nil))
+                       (find-file-noselect (concat org-odt-zip-dir
+                                                   "content.xml") t))))
+           (coding-system-for-write 'utf-8)
+           (save-buffer-coding-system 'utf-8))
+       (set-buffer buffer)
+       (set-buffer-file-coding-system coding-system-for-write)
+       (let ((mathml (org-create-math-formula latex-frag)))
+        (unless mathml (error "No Math formula created"))
+        (insert mathml)
+        ;; Add MathML to kill ring, if needed.
+        (when (org-export--copy-to-kill-ring-p)
+          (org-kill-new (buffer-string))))))))
+
+;;;###autoload
+(defun org-odt-export-as-odf-and-open ()
+  "Export LaTeX fragment as OpenDocument formula and immediately open it.
+Use `org-odt-export-as-odf' to read LaTeX fragment and OpenDocument
+formula file."
+  (interactive)
+  (org-open-file (call-interactively 'org-odt-export-as-odf) 'system))
+
+
+;;;; Export to OpenDocument Text
+
+;;;###autoload
+(defun org-odt-export-to-odt (&optional async subtreep visible-only ext-plist)
+  "Export current buffer to a ODT file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".odt" subtreep)))
+    (if async
+       (org-export-async-start (lambda (f) (org-export-add-to-stack f 'odt))
+         `(expand-file-name
+           (org-odt--export-wrap
+            ,outfile
+            (let* ((org-odt-embedded-images-count 0)
+                   (org-odt-embedded-formulas-count 0)
+                   (org-odt-automatic-styles nil)
+                   (org-odt-object-counters nil)
+                   ;; Let `htmlfontify' know that we are interested in
+                   ;; collecting styles.
+                   (hfy-user-sheet-assoc nil))
+              ;; Initialize content.xml and kick-off the export
+              ;; process.
+              (let ((out-buf
+                     (progn
+                       (require 'nxml-mode)
+                       (let ((nxml-auto-insert-xml-declaration-flag nil))
+                         (find-file-noselect
+                          (concat org-odt-zip-dir "content.xml") t))))
+                    (output (org-export-as
+                             'odt ,subtreep ,visible-only nil ,ext-plist)))
+                (with-current-buffer out-buf
+                  (erase-buffer)
+                  (insert output)))))))
+      (org-odt--export-wrap
+       outfile
+       (let* ((org-odt-embedded-images-count 0)
+             (org-odt-embedded-formulas-count 0)
+             (org-odt-automatic-styles nil)
+             (org-odt-object-counters nil)
+             ;; Let `htmlfontify' know that we are interested in collecting
+             ;; styles.
+             (hfy-user-sheet-assoc nil))
+        ;; Initialize content.xml and kick-off the export process.
+        (let ((output (org-export-as 'odt subtreep visible-only nil ext-plist))
+              (out-buf (progn
+                         (require 'nxml-mode)
+                         (let ((nxml-auto-insert-xml-declaration-flag nil))
+                           (find-file-noselect
+                            (concat org-odt-zip-dir "content.xml") t)))))
+          (with-current-buffer out-buf (erase-buffer) (insert output))))))))
+
+
+;;;; Convert between OpenDocument and other formats
+
+(defun org-odt-reachable-p (in-fmt out-fmt)
+  "Return non-nil if IN-FMT can be converted to OUT-FMT."
+  (catch 'done
+    (let ((reachable-formats (org-odt-do-reachable-formats in-fmt)))
+      (dolist (e reachable-formats)
+       (let ((out-fmt-spec (assoc out-fmt (cdr e))))
+         (when out-fmt-spec
+           (throw 'done (cons (car e) out-fmt-spec))))))))
+
+(defun org-odt-do-convert (in-file out-fmt &optional prefix-arg)
+  "Workhorse routine for `org-odt-convert'."
+  (require 'browse-url)
+  (let* ((in-file (expand-file-name (or in-file buffer-file-name)))
+        (dummy (or (file-readable-p in-file)
+                   (error "Cannot read %s" in-file)))
+        (in-fmt (file-name-extension in-file))
+        (out-fmt (or out-fmt (error "Output format unspecified")))
+        (how (or (org-odt-reachable-p in-fmt out-fmt)
+                 (error "Cannot convert from %s format to %s format?"
+                        in-fmt out-fmt)))
+        (convert-process (car how))
+        (out-file (concat (file-name-sans-extension in-file) "."
+                          (nth 1 (or (cdr how) out-fmt))))
+        (extra-options (or (nth 2 (cdr how)) ""))
+        (out-dir (file-name-directory in-file))
+        (cmd (format-spec convert-process
+                          `((?i . ,(shell-quote-argument in-file))
+                            (?I . ,(browse-url-file-url in-file))
+                            (?f . ,out-fmt)
+                            (?o . ,out-file)
+                            (?O . ,(browse-url-file-url out-file))
+                            (?d . , (shell-quote-argument out-dir))
+                            (?D . ,(browse-url-file-url out-dir))
+                            (?x . ,extra-options)))))
+    (when (file-exists-p out-file)
+      (delete-file out-file))
+
+    (message "Executing %s" cmd)
+    (let ((cmd-output (shell-command-to-string cmd)))
+      (message "%s" cmd-output))
+
+    (cond
+     ((file-exists-p out-file)
+      (message "Exported to %s" out-file)
+      (when prefix-arg
+       (message "Opening %s..."  out-file)
+       (org-open-file out-file 'system))
+      out-file)
+     (t
+      (message "Export to %s failed" out-file)
+      nil))))
+
+(defun org-odt-do-reachable-formats (in-fmt)
+  "Return verbose info about formats to which IN-FMT can be converted.
+Return a list where each element is of the
+form (CONVERTER-PROCESS . OUTPUT-FMT-ALIST).  See
+`org-odt-convert-processes' for CONVERTER-PROCESS and see
+`org-odt-convert-capabilities' for OUTPUT-FMT-ALIST."
+  (let* ((converter
+         (and org-odt-convert-process
+              (cadr (assoc-string org-odt-convert-process
+                                  org-odt-convert-processes t))))
+        (capabilities
+         (and org-odt-convert-process
+              (cadr (assoc-string org-odt-convert-process
+                                  org-odt-convert-processes t))
+              org-odt-convert-capabilities))
+        reachable-formats)
+    (when converter
+      (dolist (c capabilities)
+       (when (member in-fmt (nth 1 c))
+         (push (cons converter (nth 2 c)) reachable-formats))))
+    reachable-formats))
+
+(defun org-odt-reachable-formats (in-fmt)
+  "Return list of formats to which IN-FMT can be converted.
+The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
+  (let (l)
+    (mapc (lambda (e) (add-to-list 'l e))
+         (apply 'append (mapcar
+                         (lambda (e) (mapcar 'car (cdr e)))
+                         (org-odt-do-reachable-formats in-fmt))))
+    l))
+
+(defun org-odt-convert-read-params ()
+  "Return IN-FILE and OUT-FMT params for `org-odt-do-convert'.
+This is a helper routine for interactive use."
+  (let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
+        (in-file (read-file-name "File to be converted: "
+                                 nil buffer-file-name t))
+        (in-fmt (file-name-extension in-file))
+        (out-fmt-choices (org-odt-reachable-formats in-fmt))
+        (out-fmt
+         (or (and out-fmt-choices
+                  (funcall input "Output format: "
+                           out-fmt-choices nil nil nil))
+             (error
+              "No known converter or no known output formats for %s files"
+              in-fmt))))
+    (list in-file out-fmt)))
+
+;;;###autoload
+(defun org-odt-convert (&optional in-file out-fmt prefix-arg)
+  "Convert IN-FILE to format OUT-FMT using a command line converter.
+IN-FILE is the file to be converted.  If unspecified, it defaults
+to variable `buffer-file-name'.  OUT-FMT is the desired output
+format.  Use `org-odt-convert-process' as the converter.
+If PREFIX-ARG is non-nil then the newly converted file is opened
+using `org-open-file'."
+  (interactive
+   (append (org-odt-convert-read-params) current-prefix-arg))
+  (org-odt-do-convert in-file out-fmt prefix-arg))
+
+;;; Library Initializations
+
+(mapc
+ (lambda (desc)
+   ;; Let Emacs open all OpenDocument files in archive mode
+   (add-to-list 'auto-mode-alist
+               (cons (concat  "\\." (car desc) "\\'") 'archive-mode)))
+ org-odt-file-extensions)
+
+(provide 'ox-odt)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-odt.el ends here
diff --git a/lisp/org/ox-org.el b/lisp/org/ox-org.el
new file mode 100644 (file)
index 0000000..cecad56
--- /dev/null
@@ -0,0 +1,257 @@
+;;; ox-org.el --- Org Back-End for Org Export Engine
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
+;; Keywords: org, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library implements an Org back-end for Org exporter.
+;;
+;; It introduces two interactive functions, `org-org-export-as-org'
+;; and `org-org-export-to-org', which export, respectively, to
+;; a temporary buffer and to a file.
+;;
+;; A publishing function is also provided: `org-org-publish-to-org'.
+
+;;; Code:
+(require 'ox)
+(declare-function htmlize-buffer "htmlize" (&optional buffer))
+
+(defgroup org-export-org nil
+  "Options for exporting Org mode files to Org."
+  :tag "Org Export Org"
+  :group 'org-export
+  :version "24.4"
+  :package-version '(Org . "8.0"))
+
+(define-obsolete-variable-alias
+  'org-export-htmlized-org-css-url 'org-org-htmlized-css-url "24.4")
+(defcustom org-org-htmlized-css-url nil
+  "URL pointing to the CSS defining colors for htmlized Emacs buffers.
+Normally when creating an htmlized version of an Org buffer,
+htmlize will create the CSS to define the font colors.  However,
+this does not work when converting in batch mode, and it also can
+look bad if different people with different fontification setup
+work on the same website.  When this variable is non-nil,
+creating an htmlized version of an Org buffer using
+`org-org-export-as-org' will include a link to this URL if the
+setting of `org-html-htmlize-output-type' is 'css."
+  :group 'org-export-org
+  :type '(choice
+         (const :tag "Don't include external stylesheet link" nil)
+         (string :tag "URL or local href")))
+
+(org-export-define-backend 'org
+  '((babel-call . org-org-identity)
+    (bold . org-org-identity)
+    (center-block . org-org-identity)
+    (clock . org-org-identity)
+    (code . org-org-identity)
+    (comment . (lambda (&rest args) ""))
+    (comment-block . (lambda (&rest args) ""))
+    (diary-sexp . org-org-identity)
+    (drawer . org-org-identity)
+    (dynamic-block . org-org-identity)
+    (entity . org-org-identity)
+    (example-block . org-org-identity)
+    (fixed-width . org-org-identity)
+    (footnote-definition . org-org-identity)
+    (footnote-reference . org-org-identity)
+    (headline . org-org-headline)
+    (horizontal-rule . org-org-identity)
+    (inline-babel-call . org-org-identity)
+    (inline-src-block . org-org-identity)
+    (inlinetask . org-org-identity)
+    (italic . org-org-identity)
+    (item . org-org-identity)
+    (keyword . org-org-keyword)
+    (latex-environment . org-org-identity)
+    (latex-fragment . org-org-identity)
+    (line-break . org-org-identity)
+    (link . org-org-identity)
+    (node-property . org-org-identity)
+    (paragraph . org-org-identity)
+    (plain-list . org-org-identity)
+    (planning . org-org-identity)
+    (property-drawer . org-org-identity)
+    (quote-block . org-org-identity)
+    (quote-section . org-org-identity)
+    (radio-target . org-org-identity)
+    (section . org-org-identity)
+    (special-block . org-org-identity)
+    (src-block . org-org-identity)
+    (statistics-cookie . org-org-identity)
+    (strike-through . org-org-identity)
+    (subscript . org-org-identity)
+    (superscript . org-org-identity)
+    (table . org-org-identity)
+    (table-cell . org-org-identity)
+    (table-row . org-org-identity)
+    (target . org-org-identity)
+    (timestamp . org-org-identity)
+    (underline . org-org-identity)
+    (verbatim . org-org-identity)
+    (verse-block . org-org-identity))
+  :menu-entry
+  '(?O "Export to Org"
+       ((?O "As Org buffer" org-org-export-as-org)
+       (?o "As Org file" org-org-export-to-org)
+       (?v "As Org file and open"
+           (lambda (a s v b)
+             (if a (org-org-export-to-org t s v b)
+               (org-open-file (org-org-export-to-org nil s v b))))))))
+
+(defun org-org-identity (blob contents info)
+  "Transcode BLOB element or object back into Org syntax.
+CONTENTS is its contents, as a string or nil.  INFO is ignored."
+  (org-export-expand blob contents t))
+
+(defun org-org-headline (headline contents info)
+  "Transcode HEADLINE element back into Org syntax.
+CONTENTS is its contents, as a string or nil.  INFO is ignored."
+  (unless (plist-get info :with-todo-keywords)
+    (org-element-put-property headline :todo-keyword nil))
+  (unless (plist-get info :with-tags)
+    (org-element-put-property headline :tags nil))
+  (unless (plist-get info :with-priority)
+    (org-element-put-property headline :priority nil))
+  (org-element-put-property headline :level
+                           (org-export-get-relative-level headline info))
+  (org-element-headline-interpreter headline contents))
+
+(defun org-org-keyword (keyword contents info)
+  "Transcode KEYWORD element back into Org syntax.
+CONTENTS is nil.  INFO is ignored.  This function ignores
+keywords targeted at other export back-ends."
+  (unless (member (org-element-property :key keyword)
+                 (mapcar
+                  (lambda (block-cons)
+                    (and (eq (cdr block-cons) 'org-element-export-block-parser)
+                         (car block-cons)))
+                  org-element-block-name-alist))
+    (org-element-keyword-interpreter keyword nil)))
+
+;;;###autoload
+(defun org-org-export-as-org (&optional async subtreep visible-only ext-plist)
+  "Export current buffer to an Org buffer.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should be accessible
+through the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Export is done in a buffer named \"*Org ORG Export*\", which will
+be displayed when `org-export-show-temporary-export-buffer' is
+non-nil."
+  (interactive)
+  (org-export-to-buffer 'org "*Org ORG Export*"
+    async subtreep visible-only nil ext-plist (lambda () (org-mode))))
+
+;;;###autoload
+(defun org-org-export-to-org (&optional async subtreep visible-only ext-plist)
+  "Export current buffer to an org file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".org" subtreep)))
+    (org-export-to-file 'org outfile
+      async subtreep visible-only nil ext-plist)))
+
+;;;###autoload
+(defun org-org-publish-to-org (plist filename pub-dir)
+  "Publish an org file to org.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to 'org filename ".org" plist pub-dir)
+  (when (plist-get plist :htmlized-source)
+    (require 'htmlize)
+    (require 'ox-html)
+    (let* ((org-inhibit-startup t)
+          (htmlize-output-type 'css)
+          (html-ext (concat "." (or (plist-get plist :html-extension)
+                                    org-html-extension "html")))
+          (visitingp (find-buffer-visiting filename))
+          (work-buffer (or visitingp (find-file filename)))
+          newbuf)
+      (font-lock-fontify-buffer)
+      (show-all)
+      (org-show-block-all)
+      (setq newbuf (htmlize-buffer))
+      (with-current-buffer newbuf
+       (when org-org-htmlized-css-url
+         (goto-char (point-min))
+         (and (re-search-forward
+               "<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*" nil t)
+              (replace-match
+               (format
+                "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
+                org-org-htmlized-css-url) t t)))
+       (write-file (concat pub-dir (file-name-nondirectory filename) html-ext)))
+      (kill-buffer newbuf)
+      (unless visitingp (kill-buffer work-buffer)))
+    (set-buffer-modified-p nil)))
+
+
+(provide 'ox-org)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-org.el ends here
diff --git a/lisp/org/ox-publish.el b/lisp/org/ox-publish.el
new file mode 100644 (file)
index 0000000..67a57fa
--- /dev/null
@@ -0,0 +1,1238 @@
+;;; ox-publish.el --- Publish Related Org Mode Files as a Website
+;; Copyright (C) 2006-2013 Free Software Foundation, Inc.
+
+;; Author: David O'Toole <dto@gnu.org>
+;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
+;; Keywords: hypermedia, outlines, wp
+
+;; This file is part of GNU Emacs.
+;;
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This program allow configurable publishing of related sets of
+;; Org mode files as a complete website.
+;;
+;; ox-publish.el can do the following:
+;;
+;; + Publish all one's Org files to a given export back-end
+;; + Upload HTML, images, attachments and other files to a web server
+;; + Exclude selected private pages from publishing
+;; + Publish a clickable sitemap of pages
+;; + Manage local timestamps for publishing only changed files
+;; + Accept plugin functions to extend range of publishable content
+;;
+;; Documentation for publishing is in the manual.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'format-spec)
+(require 'ox)
+
+
+\f
+;;; Variables
+
+(defvar org-publish-temp-files nil
+  "Temporary list of files to be published.")
+
+;; Here, so you find the variable right before it's used the first time:
+(defvar org-publish-cache nil
+  "This will cache timestamps and titles for files in publishing projects.
+Blocks could hash sha1 values here.")
+
+(defgroup org-publish nil
+  "Options for publishing a set of Org-mode and related files."
+  :tag "Org Publishing"
+  :group 'org)
+
+(defcustom org-publish-project-alist nil
+  "Association list to control publishing behavior.
+Each element of the alist is a publishing 'project.'  The CAR of
+each element is a string, uniquely identifying the project.  The
+CDR of each element is in one of the following forms:
+
+1. A well-formed property list with an even number of elements,
+   alternating keys and values, specifying parameters for the
+   publishing process.
+
+     \(:property value :property value ... )
+
+2. A meta-project definition, specifying of a list of
+   sub-projects:
+
+     \(:components (\"project-1\" \"project-2\" ...))
+
+When the CDR of an element of org-publish-project-alist is in
+this second form, the elements of the list after `:components'
+are taken to be components of the project, which group together
+files requiring different publishing options.  When you publish
+such a project with \\[org-publish], the components all publish.
+
+When a property is given a value in `org-publish-project-alist',
+its setting overrides the value of the corresponding user
+variable (if any) during publishing.  However, options set within
+a file override everything.
+
+Most properties are optional, but some should always be set:
+
+  `:base-directory'
+
+    Directory containing publishing source files.
+
+  `:base-extension'
+
+    Extension (without the dot!) of source files.  This can be
+    a regular expression.  If not given, \"org\" will be used as
+    default extension.
+
+  `:publishing-directory'
+
+    Directory (possibly remote) where output files will be
+    published.
+
+The `:exclude' property may be used to prevent certain files from
+being published.  Its value may be a string or regexp matching
+file names you don't want to be published.
+
+The `:include' property may be used to include extra files.  Its
+value may be a list of filenames to include.  The filenames are
+considered relative to the base directory.
+
+When both `:include' and `:exclude' properties are given values,
+the exclusion step happens first.
+
+One special property controls which back-end function to use for
+publishing files in the project.  This can be used to extend the
+set of file types publishable by `org-publish', as well as the
+set of output formats.
+
+  `:publishing-function'
+
+    Function to publish file.  Each back-end may define its
+    own (i.e. `org-latex-publish-to-pdf',
+    `org-html-publish-to-html').  May be a list of functions, in
+    which case each function in the list is invoked in turn.
+
+Another property allows you to insert code that prepares
+a project for publishing.  For example, you could call GNU Make
+on a certain makefile, to ensure published files are built up to
+date.
+
+  `:preparation-function'
+
+    Function to be called before publishing this project.  This
+    may also be a list of functions.
+
+  `:completion-function'
+
+    Function to be called after publishing this project.  This
+    may also be a list of functions.
+
+Some properties control details of the Org publishing process,
+and are equivalent to the corresponding user variables listed in
+the right column.  Back-end specific properties may also be
+included.  See the back-end documentation for more information.
+
+  :author                   `user-full-name'
+  :creator                  `org-export-creator-string'
+  :email                    `user-mail-address'
+  :exclude-tags             `org-export-exclude-tags'
+  :headline-levels          `org-export-headline-levels'
+  :language                 `org-export-default-language'
+  :preserve-breaks          `org-export-preserve-breaks'
+  :section-numbers          `org-export-with-section-numbers'
+  :select-tags              `org-export-select-tags'
+  :time-stamp-file          `org-export-time-stamp-file'
+  :with-archived-trees      `org-export-with-archived-trees'
+  :with-author              `org-export-with-author'
+  :with-creator             `org-export-with-creator'
+  :with-date                `org-export-with-date'
+  :with-drawers             `org-export-with-drawers'
+  :with-email               `org-export-with-email'
+  :with-emphasize           `org-export-with-emphasize'
+  :with-entities            `org-export-with-entities'
+  :with-fixed-width         `org-export-with-fixed-width'
+  :with-footnotes           `org-export-with-footnotes'
+  :with-inlinetasks         `org-export-with-inlinetasks'
+  :with-latex               `org-export-with-latex'
+  :with-priority            `org-export-with-priority'
+  :with-smart-quotes        `org-export-with-smart-quotes'
+  :with-special-strings     `org-export-with-special-strings'
+  :with-statistics-cookies' `org-export-with-statistics-cookies'
+  :with-sub-superscript     `org-export-with-sub-superscripts'
+  :with-toc                 `org-export-with-toc'
+  :with-tables              `org-export-with-tables'
+  :with-tags                `org-export-with-tags'
+  :with-tasks               `org-export-with-tasks'
+  :with-timestamps          `org-export-with-timestamps'
+  :with-planning            `org-export-with-planning'
+  :with-todo-keywords       `org-export-with-todo-keywords'
+
+The following properties may be used to control publishing of
+a site-map of files or summary page for a given project.
+
+  `:auto-sitemap'
+
+    Whether to publish a site-map during
+    `org-publish-current-project' or `org-publish-all'.
+
+  `:sitemap-filename'
+
+    Filename for output of sitemap.  Defaults to \"sitemap.org\".
+
+  `:sitemap-title'
+
+    Title of site-map page.  Defaults to name of file.
+
+  `:sitemap-function'
+
+    Plugin function to use for generation of site-map.  Defaults
+    to `org-publish-org-sitemap', which generates a plain list of
+    links to all files in the project.
+
+  `:sitemap-style'
+
+    Can be `list' (site-map is just an itemized list of the
+    titles of the files involved) or `tree' (the directory
+    structure of the source files is reflected in the site-map).
+    Defaults to `tree'.
+
+  `:sitemap-sans-extension'
+
+    Remove extension from site-map's file-names.  Useful to have
+    cool URIs (see http://www.w3.org/Provider/Style/URI).
+    Defaults to nil.
+
+If you create a site-map file, adjust the sorting like this:
+
+  `:sitemap-sort-folders'
+
+    Where folders should appear in the site-map.  Set this to
+    `first' (default) or `last' to display folders first or last,
+    respectively.  Any other value will mix files and folders.
+
+  `:sitemap-sort-files'
+
+    The site map is normally sorted alphabetically.  You can
+    change this behaviour setting this to `anti-chronologically',
+    `chronologically', or nil.
+
+  `:sitemap-ignore-case'
+
+    Should sorting be case-sensitive?  Default nil.
+
+The following property control the creation of a concept index.
+
+  `:makeindex'
+
+    Create a concept index.  The file containing the index has to
+    be called \"theindex.org\".  If it doesn't exist in the
+    project, it will be generated.  Contents of the index are
+    stored in the file \"theindex.inc\", which can be included in
+    \"theindex.org\".
+
+Other properties affecting publication.
+
+  `:body-only'
+
+    Set this to t to publish only the body of the documents."
+  :group 'org-export-publish
+  :type 'alist)
+
+(defcustom org-publish-use-timestamps-flag t
+  "Non-nil means use timestamp checking to publish only changed files.
+When nil, do no timestamp checking and always publish all files."
+  :group 'org-export-publish
+  :type 'boolean)
+
+(defcustom org-publish-timestamp-directory
+  (convert-standard-filename "~/.org-timestamps/")
+  "Name of directory in which to store publishing timestamps."
+  :group 'org-export-publish
+  :type 'directory)
+
+(defcustom org-publish-list-skipped-files t
+  "Non-nil means show message about files *not* published."
+  :group 'org-export-publish
+  :type 'boolean)
+
+(defcustom org-publish-sitemap-sort-files 'alphabetically
+  "Method to sort files in site-maps.
+Possible values are `alphabetically', `chronologically',
+`anti-chronologically' and nil.
+
+If `alphabetically', files will be sorted alphabetically.  If
+`chronologically', files will be sorted with older modification
+time first.  If `anti-chronologically', files will be sorted with
+newer modification time first.  nil won't sort files.
+
+You can overwrite this default per project in your
+`org-publish-project-alist', using `:sitemap-sort-files'."
+  :group 'org-export-publish
+  :type 'symbol)
+
+(defcustom org-publish-sitemap-sort-folders 'first
+  "A symbol, denoting if folders are sorted first in sitemaps.
+Possible values are `first', `last', and nil.
+If `first', folders will be sorted before files.
+If `last', folders are sorted to the end after the files.
+Any other value will not mix files and folders.
+
+You can overwrite this default per project in your
+`org-publish-project-alist', using `:sitemap-sort-folders'."
+  :group 'org-export-publish
+  :type 'symbol)
+
+(defcustom org-publish-sitemap-sort-ignore-case nil
+  "Non-nil when site-map sorting should ignore case.
+
+You can overwrite this default per project in your
+`org-publish-project-alist', using `:sitemap-ignore-case'."
+  :group 'org-export-publish
+  :type 'boolean)
+
+(defcustom org-publish-sitemap-date-format "%Y-%m-%d"
+  "Format for printing a date in the sitemap.
+See `format-time-string' for allowed formatters."
+  :group 'org-export-publish
+  :type 'string)
+
+(defcustom org-publish-sitemap-file-entry-format "%t"
+  "Format string for site-map file entry.
+You could use brackets to delimit on what part the link will be.
+
+%t is the title.
+%a is the author.
+%d is the date formatted using `org-publish-sitemap-date-format'."
+  :group 'org-export-publish
+  :type 'string)
+
+
+\f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Timestamp-related functions
+
+(defun org-publish-timestamp-filename (filename &optional pub-dir pub-func)
+  "Return path to timestamp file for filename FILENAME."
+  (setq filename (concat filename "::" (or pub-dir "") "::"
+                        (format "%s" (or pub-func ""))))
+  (concat "X" (if (fboundp 'sha1) (sha1 filename) (md5 filename))))
+
+(defun org-publish-needed-p
+  (filename &optional pub-dir pub-func true-pub-dir base-dir)
+  "Non-nil if FILENAME should be published in PUB-DIR using PUB-FUNC.
+TRUE-PUB-DIR is where the file will truly end up.  Currently we
+are not using this - maybe it can eventually be used to check if
+the file is present at the target location, and how old it is.
+Right now we cannot do this, because we do not know under what
+file name the file will be stored - the publishing function can
+still decide about that independently."
+  (let ((rtn (if (not org-publish-use-timestamps-flag) t
+              (org-publish-cache-file-needs-publishing
+               filename pub-dir pub-func base-dir))))
+    (if rtn (message "Publishing file %s using `%s'" filename pub-func)
+      (when org-publish-list-skipped-files
+       (message   "Skipping unmodified file %s" filename)))
+    rtn))
+
+(defun org-publish-update-timestamp
+  (filename &optional pub-dir pub-func base-dir)
+  "Update publishing timestamp for file FILENAME.
+If there is no timestamp, create one."
+  (let ((key (org-publish-timestamp-filename filename pub-dir pub-func))
+       (stamp (org-publish-cache-ctime-of-src filename)))
+    (org-publish-cache-set key stamp)))
+
+(defun org-publish-remove-all-timestamps ()
+  "Remove all files in the timestamp directory."
+  (let ((dir org-publish-timestamp-directory)
+       files)
+    (when (and (file-exists-p dir) (file-directory-p dir))
+      (mapc 'delete-file (directory-files dir 'full "[^.]\\'"))
+      (org-publish-reset-cache))))
+
+
+\f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Getting project information out of `org-publish-project-alist'
+
+(defun org-publish-expand-projects (projects-alist)
+  "Expand projects in PROJECTS-ALIST.
+This splices all the components into the list."
+  (let ((rest projects-alist) rtn p components)
+    (while (setq p (pop rest))
+      (if (setq components (plist-get (cdr p) :components))
+         (setq rest (append
+                     (mapcar (lambda (x) (assoc x org-publish-project-alist))
+                             components)
+                     rest))
+       (push p rtn)))
+    (nreverse (delete-dups (delq nil rtn)))))
+
+(defvar org-publish-sitemap-sort-files)
+(defvar org-publish-sitemap-sort-folders)
+(defvar org-publish-sitemap-ignore-case)
+(defvar org-publish-sitemap-requested)
+(defvar org-publish-sitemap-date-format)
+(defvar org-publish-sitemap-file-entry-format)
+(defun org-publish-compare-directory-files (a b)
+  "Predicate for `sort', that sorts folders and files for sitemap."
+  (let ((retval t))
+    (when (or org-publish-sitemap-sort-files org-publish-sitemap-sort-folders)
+      ;; First we sort files:
+      (when org-publish-sitemap-sort-files
+       (case org-publish-sitemap-sort-files
+         (alphabetically
+          (let* ((adir (file-directory-p a))
+                 (aorg (and (string-match "\\.org$" a) (not adir)))
+                 (bdir (file-directory-p b))
+                 (borg (and (string-match "\\.org$" b) (not bdir)))
+                 (A (if aorg (concat (file-name-directory a)
+                                     (org-publish-find-title a)) a))
+                 (B (if borg (concat (file-name-directory b)
+                                     (org-publish-find-title b)) b)))
+            (setq retval (if org-publish-sitemap-ignore-case
+                             (not (string-lessp (upcase B) (upcase A)))
+                           (not (string-lessp B A))))))
+         ((anti-chronologically chronologically)
+          (let* ((adate (org-publish-find-date a))
+                 (bdate (org-publish-find-date b))
+                 (A (+ (lsh (car adate) 16) (cadr adate)))
+                 (B (+ (lsh (car bdate) 16) (cadr bdate))))
+            (setq retval
+                  (if (eq org-publish-sitemap-sort-files 'chronologically) (<= A B)
+                    (>= A B)))))))
+      ;; Directory-wise wins:
+      (when org-publish-sitemap-sort-folders
+        ;; a is directory, b not:
+        (cond
+         ((and (file-directory-p a) (not (file-directory-p b)))
+          (setq retval (equal org-publish-sitemap-sort-folders 'first)))
+        ;; a is not a directory, but b is:
+         ((and (not (file-directory-p a)) (file-directory-p b))
+          (setq retval (equal org-publish-sitemap-sort-folders 'last))))))
+    retval))
+
+(defun org-publish-get-base-files-1
+  (base-dir &optional recurse match skip-file skip-dir)
+  "Set `org-publish-temp-files' with files from BASE-DIR directory.
+If RECURSE is non-nil, check BASE-DIR recursively.  If MATCH is
+non-nil, restrict this list to the files matching the regexp
+MATCH.  If SKIP-FILE is non-nil, skip file matching the regexp
+SKIP-FILE.  If SKIP-DIR is non-nil, don't check directories
+matching the regexp SKIP-DIR when recursing through BASE-DIR."
+  (mapc (lambda (f)
+         (let ((fd-p (file-directory-p f))
+               (fnd (file-name-nondirectory f)))
+           (if (and fd-p recurse
+                    (not (string-match "^\\.+$" fnd))
+                    (if skip-dir (not (string-match skip-dir fnd)) t))
+               (org-publish-get-base-files-1
+                f recurse match skip-file skip-dir)
+             (unless (or fd-p ;; this is a directory
+                         (and skip-file (string-match skip-file fnd))
+                         (not (file-exists-p (file-truename f)))
+                         (not (string-match match fnd)))
+
+               (pushnew f org-publish-temp-files)))))
+       (let ((all-files (if (not recurse) (directory-files base-dir t match)
+                          ;; If RECURSE is non-nil, we want all files
+                          ;; matching MATCH and sub-directories.
+                          (org-remove-if-not
+                           (lambda (file)
+                             (or (file-directory-p file)
+                                 (and match (string-match match file))))
+                           (directory-files base-dir t)))))
+         (if (not org-publish-sitemap-requested) all-files
+           (sort all-files 'org-publish-compare-directory-files)))))
+
+(defun org-publish-get-base-files (project &optional exclude-regexp)
+  "Return a list of all files in PROJECT.
+If EXCLUDE-REGEXP is set, this will be used to filter out
+matching filenames."
+  (let* ((project-plist (cdr project))
+        (base-dir (file-name-as-directory
+                   (plist-get project-plist :base-directory)))
+        (include-list (plist-get project-plist :include))
+        (recurse (plist-get project-plist :recursive))
+        (extension (or (plist-get project-plist :base-extension) "org"))
+        ;; sitemap-... variables are dynamically scoped for
+        ;; org-publish-compare-directory-files:
+        (org-publish-sitemap-requested
+         (plist-get project-plist :auto-sitemap))
+        (sitemap-filename
+         (or (plist-get project-plist :sitemap-filename) "sitemap.org"))
+        (org-publish-sitemap-sort-folders
+         (if (plist-member project-plist :sitemap-sort-folders)
+             (plist-get project-plist :sitemap-sort-folders)
+           org-publish-sitemap-sort-folders))
+        (org-publish-sitemap-sort-files
+         (cond ((plist-member project-plist :sitemap-sort-files)
+                (plist-get project-plist :sitemap-sort-files))
+               ;; For backward compatibility:
+               ((plist-member project-plist :sitemap-alphabetically)
+                (if (plist-get project-plist :sitemap-alphabetically)
+                    'alphabetically nil))
+               (t org-publish-sitemap-sort-files)))
+        (org-publish-sitemap-ignore-case
+         (if (plist-member project-plist :sitemap-ignore-case)
+             (plist-get project-plist :sitemap-ignore-case)
+           org-publish-sitemap-sort-ignore-case))
+        (match (if (eq extension 'any) "^[^\\.]"
+                 (concat "^[^\\.].*\\.\\(" extension "\\)$"))))
+    ;; Make sure `org-publish-sitemap-sort-folders' has an accepted
+    ;; value.
+    (unless (memq org-publish-sitemap-sort-folders '(first last))
+      (setq org-publish-sitemap-sort-folders nil))
+
+    (setq org-publish-temp-files nil)
+    (if org-publish-sitemap-requested
+       (pushnew (expand-file-name (concat base-dir sitemap-filename))
+                 org-publish-temp-files))
+    (org-publish-get-base-files-1 base-dir recurse match
+                                 ;; FIXME distinguish exclude regexp
+                                 ;; for skip-file and skip-dir?
+                                 exclude-regexp exclude-regexp)
+    (mapc (lambda (f)
+           (pushnew
+            (expand-file-name (concat base-dir f))
+            org-publish-temp-files))
+         include-list)
+    org-publish-temp-files))
+
+(defun org-publish-get-project-from-filename (filename &optional up)
+  "Return the project that FILENAME belongs to."
+  (let* ((filename (expand-file-name filename))
+        project-name)
+
+    (catch 'p-found
+      (dolist (prj org-publish-project-alist)
+       (unless (plist-get (cdr prj) :components)
+         ;; [[info:org:Selecting%20files]] shows how this is supposed to work:
+         (let* ((r (plist-get (cdr prj) :recursive))
+                (b (expand-file-name (file-name-as-directory
+                                      (plist-get (cdr prj) :base-directory))))
+                (x (or (plist-get (cdr prj) :base-extension) "org"))
+                (e (plist-get (cdr prj) :exclude))
+                (i (plist-get (cdr prj) :include))
+                (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$")))
+           (when
+               (or (and i
+                        (member filename
+                                (mapcar (lambda (file)
+                                          (expand-file-name file b))
+                                        i)))
+                   (and (not (and e (string-match e filename)))
+                        (string-match xm filename)))
+             (setq project-name (car prj))
+             (throw 'p-found project-name))))))
+    (when up
+      (dolist (prj org-publish-project-alist)
+       (if (member project-name (plist-get (cdr prj) :components))
+           (setq project-name (car prj)))))
+    (assoc project-name org-publish-project-alist)))
+
+
+\f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Tools for publishing functions in back-ends
+
+(defun org-publish-org-to (backend filename extension plist &optional pub-dir)
+  "Publish an Org file to a specified back-end.
+
+BACKEND is a symbol representing the back-end used for
+transcoding.  FILENAME is the filename of the Org file to be
+published.  EXTENSION is the extension used for the output
+string, with the leading dot.  PLIST is the property list for the
+given project.
+
+Optional argument PUB-DIR, when non-nil is the publishing
+directory.
+
+Return output file name."
+  (unless (or (not pub-dir) (file-exists-p pub-dir)) (make-directory pub-dir t))
+  ;; Check if a buffer visiting FILENAME is already open.
+  (let* ((org-inhibit-startup t)
+        (visitingp (find-buffer-visiting filename))
+        (work-buffer (or visitingp (find-file-noselect filename))))
+    (prog1 (with-current-buffer work-buffer
+            (let ((output-file
+                   (org-export-output-file-name extension nil pub-dir))
+                  (body-p (plist-get plist :body-only)))
+              (org-export-to-file backend output-file
+                nil nil nil body-p
+                ;; Add `org-publish-collect-numbering' and
+                ;; `org-publish-collect-index' to final output
+                ;; filters.  The latter isn't dependent on
+                ;; `:makeindex', since we want to keep it up-to-date
+                ;; in cache anyway.
+                (org-combine-plists
+                 plist
+                 `(:filter-final-output
+                   ,(cons 'org-publish-collect-numbering
+                          (cons 'org-publish-collect-index
+                                (plist-get plist :filter-final-output))))))))
+      ;; Remove opened buffer in the process.
+      (unless visitingp (kill-buffer work-buffer)))))
+
+(defun org-publish-attachment (plist filename pub-dir)
+  "Publish a file with no transformation of any kind.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (unless (file-directory-p pub-dir)
+    (make-directory pub-dir t))
+  (or (equal (expand-file-name (file-name-directory filename))
+            (file-name-as-directory (expand-file-name pub-dir)))
+      (copy-file filename
+                (expand-file-name (file-name-nondirectory filename) pub-dir)
+                t)))
+
+
+\f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Publishing files, sets of files, and indices
+
+(defun org-publish-file (filename &optional project no-cache)
+  "Publish file FILENAME from PROJECT.
+If NO-CACHE is not nil, do not initialize org-publish-cache and
+write it to disk.  This is needed, since this function is used to
+publish single files, when entire projects are published.
+See `org-publish-projects'."
+  (let* ((project
+         (or project
+             (or (org-publish-get-project-from-filename filename)
+                 (error "File %s not part of any known project"
+                        (abbreviate-file-name filename)))))
+        (project-plist (cdr project))
+        (ftname (expand-file-name filename))
+        (publishing-function
+         (or (plist-get project-plist :publishing-function)
+             (error "No publishing function chosen")))
+        (base-dir
+         (file-name-as-directory
+          (expand-file-name
+           (or (plist-get project-plist :base-directory)
+               (error "Project %s does not have :base-directory defined"
+                      (car project))))))
+        (pub-dir
+         (file-name-as-directory
+          (file-truename
+           (or (eval (plist-get project-plist :publishing-directory))
+               (error "Project %s does not have :publishing-directory defined"
+                      (car project))))))
+        tmp-pub-dir)
+
+    (unless no-cache (org-publish-initialize-cache (car project)))
+
+    (setq tmp-pub-dir
+         (file-name-directory
+          (concat pub-dir
+                  (and (string-match (regexp-quote base-dir) ftname)
+                       (substring ftname (match-end 0))))))
+    (if (listp publishing-function)
+       ;; allow chain of publishing functions
+       (mapc (lambda (f)
+               (when (org-publish-needed-p
+                      filename pub-dir f tmp-pub-dir base-dir)
+                 (funcall f project-plist filename tmp-pub-dir)
+                 (org-publish-update-timestamp filename pub-dir f base-dir)))
+             publishing-function)
+      (when (org-publish-needed-p
+            filename pub-dir publishing-function tmp-pub-dir base-dir)
+       (funcall publishing-function project-plist filename tmp-pub-dir)
+       (org-publish-update-timestamp
+        filename pub-dir publishing-function base-dir)))
+    (unless no-cache (org-publish-write-cache-file))))
+
+(defun org-publish-projects (projects)
+  "Publish all files belonging to the PROJECTS alist.
+If `:auto-sitemap' is set, publish the sitemap too.  If
+`:makeindex' is set, also produce a file theindex.org."
+  (mapc
+   (lambda (project)
+     ;; Each project uses its own cache file:
+     (org-publish-initialize-cache (car project))
+     (let* ((project-plist (cdr project))
+           (exclude-regexp (plist-get project-plist :exclude))
+           (sitemap-p (plist-get project-plist :auto-sitemap))
+           (sitemap-filename (or (plist-get project-plist :sitemap-filename)
+                                 "sitemap.org"))
+           (sitemap-function (or (plist-get project-plist :sitemap-function)
+                                 'org-publish-org-sitemap))
+           (org-publish-sitemap-date-format
+            (or (plist-get project-plist :sitemap-date-format)
+                org-publish-sitemap-date-format))
+           (org-publish-sitemap-file-entry-format
+            (or (plist-get project-plist :sitemap-file-entry-format)
+                org-publish-sitemap-file-entry-format))
+           (preparation-function
+            (plist-get project-plist :preparation-function))
+           (completion-function (plist-get project-plist :completion-function))
+           (files (org-publish-get-base-files project exclude-regexp))
+           (theindex
+            (expand-file-name "theindex.org"
+                              (plist-get project-plist :base-directory))))
+       (when preparation-function (run-hooks 'preparation-function))
+       (if sitemap-p (funcall sitemap-function project sitemap-filename))
+       ;; Publish all files from PROJECT excepted "theindex.org".  Its
+       ;; publishing will be deferred until "theindex.inc" is
+       ;; populated.
+       (dolist (file files)
+        (unless (equal file theindex)
+          (org-publish-file file project t)))
+       ;; Populate "theindex.inc", if needed, and publish
+       ;; "theindex.org".
+       (when (plist-get project-plist :makeindex)
+        (org-publish-index-generate-theindex
+         project (plist-get project-plist :base-directory))
+        (org-publish-file theindex project t))
+       (when completion-function (run-hooks 'completion-function))
+       (org-publish-write-cache-file)))
+   (org-publish-expand-projects projects)))
+
+(defun org-publish-org-sitemap (project &optional sitemap-filename)
+  "Create a sitemap of pages in set defined by PROJECT.
+Optionally set the filename of the sitemap with SITEMAP-FILENAME.
+Default for SITEMAP-FILENAME is 'sitemap.org'."
+  (let* ((project-plist (cdr project))
+        (dir (file-name-as-directory
+              (plist-get project-plist :base-directory)))
+        (localdir (file-name-directory dir))
+        (indent-str (make-string 2 ?\ ))
+        (exclude-regexp (plist-get project-plist :exclude))
+        (files (nreverse
+                (org-publish-get-base-files project exclude-regexp)))
+        (sitemap-filename (concat dir (or sitemap-filename "sitemap.org")))
+        (sitemap-title (or (plist-get project-plist :sitemap-title)
+                         (concat "Sitemap for project " (car project))))
+        (sitemap-style (or (plist-get project-plist :sitemap-style)
+                           'tree))
+        (sitemap-sans-extension
+         (plist-get project-plist :sitemap-sans-extension))
+        (visiting (find-buffer-visiting sitemap-filename))
+        (ifn (file-name-nondirectory sitemap-filename))
+        file sitemap-buffer)
+    (with-current-buffer
+       (let ((org-inhibit-startup t))
+         (setq sitemap-buffer
+               (or visiting (find-file sitemap-filename))))
+      (erase-buffer)
+      (insert (concat "#+TITLE: " sitemap-title "\n\n"))
+      (while (setq file (pop files))
+       (let ((fn (file-name-nondirectory file))
+             (link (file-relative-name file dir))
+             (oldlocal localdir))
+         (when sitemap-sans-extension
+           (setq link (file-name-sans-extension link)))
+         ;; sitemap shouldn't list itself
+         (unless (equal (file-truename sitemap-filename)
+                        (file-truename file))
+           (if (eq sitemap-style 'list)
+               (message "Generating list-style sitemap for %s" sitemap-title)
+             (message "Generating tree-style sitemap for %s" sitemap-title)
+             (setq localdir (concat (file-name-as-directory dir)
+                                    (file-name-directory link)))
+             (unless (string= localdir oldlocal)
+               (if (string= localdir dir)
+                   (setq indent-str (make-string 2 ?\ ))
+                 (let ((subdirs
+                        (split-string
+                         (directory-file-name
+                          (file-name-directory
+                           (file-relative-name localdir dir))) "/"))
+                       (subdir "")
+                       (old-subdirs (split-string
+                                     (file-relative-name oldlocal dir) "/")))
+                   (setq indent-str (make-string 2 ?\ ))
+                   (while (string= (car old-subdirs) (car subdirs))
+                     (setq indent-str (concat indent-str (make-string 2 ?\ )))
+                     (pop old-subdirs)
+                     (pop subdirs))
+                   (dolist (d subdirs)
+                     (setq subdir (concat subdir d "/"))
+                     (insert (concat indent-str " + " d "\n"))
+                     (setq indent-str (make-string
+                                       (+ (length indent-str) 2) ?\ )))))))
+           ;; This is common to 'flat and 'tree
+           (let ((entry
+                  (org-publish-format-file-entry
+                   org-publish-sitemap-file-entry-format file project-plist))
+                 (regexp "\\(.*\\)\\[\\([^][]+\\)\\]\\(.*\\)"))
+             (cond ((string-match-p regexp entry)
+                    (string-match regexp entry)
+                    (insert (concat indent-str " + " (match-string 1 entry)
+                                    "[[file:" link "]["
+                                    (match-string 2 entry)
+                                    "]]" (match-string 3 entry) "\n")))
+                   (t
+                    (insert (concat indent-str " + [[file:" link "]["
+                                    entry
+                                    "]]\n"))))))))
+      (save-buffer))
+    (or visiting (kill-buffer sitemap-buffer))))
+
+(defun org-publish-format-file-entry (fmt file project-plist)
+  (format-spec
+   fmt
+   `((?t . ,(org-publish-find-title file t))
+     (?d . ,(format-time-string org-publish-sitemap-date-format
+                               (org-publish-find-date file)))
+     (?a . ,(or (plist-get project-plist :author) user-full-name)))))
+
+(defun org-publish-find-title (file &optional reset)
+  "Find the title of FILE in project."
+  (or
+   (and (not reset) (org-publish-cache-get-file-property file :title nil t))
+   (let* ((org-inhibit-startup t)
+         (visiting (find-buffer-visiting file))
+         (buffer (or visiting (find-file-noselect file))))
+     (with-current-buffer buffer
+       (org-mode)
+       (let ((title
+             (let ((property (plist-get (org-export-get-environment) :title)))
+               (if property (org-element-interpret-data property)
+                 (file-name-nondirectory (file-name-sans-extension file))))))
+        (unless visiting (kill-buffer buffer))
+        (org-publish-cache-set-file-property file :title title)
+        title)))))
+
+(defun org-publish-find-date (file)
+  "Find the date of FILE in project.
+This function assumes FILE is either a directory or an Org file.
+If FILE is an Org file and provides a DATE keyword use it.  In
+any other case use the file system's modification time.  Return
+time in `current-time' format."
+  (if (file-directory-p file) (nth 5 (file-attributes file))
+    (let* ((visiting (find-buffer-visiting file))
+          (file-buf (or visiting (find-file-noselect file nil)))
+          (date (plist-get
+                 (with-current-buffer file-buf
+                   (let ((org-inhibit-startup t)) (org-mode))
+                   (org-export-get-environment))
+                 :date)))
+      (unless visiting (kill-buffer file-buf))
+      ;; DATE is either a timestamp object or a secondary string.  If it
+      ;; is a timestamp or if the secondary string contains a timestamp,
+      ;; convert it to internal format.  Otherwise, use FILE
+      ;; modification time.
+      (cond ((eq (org-element-type date) 'timestamp)
+            (org-time-string-to-time (org-element-interpret-data date)))
+           ((let ((ts (and (consp date) (assq 'timestamp date))))
+              (and ts
+                   (let ((value (org-element-interpret-data ts)))
+                     (and (org-string-nw-p value)
+                          (org-time-string-to-time value))))))
+           ((file-exists-p file) (nth 5 (file-attributes file)))
+           (t (error "No such file: \"%s\"" file))))))
+
+
+\f
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Interactive publishing functions
+
+;;;###autoload
+(defalias 'org-publish-project 'org-publish)
+
+;;;###autoload
+(defun org-publish (project &optional force async)
+  "Publish PROJECT.
+
+PROJECT is either a project name, as a string, or a project
+alist (see `org-publish-project-alist' variable).
+
+When optional argument FORCE is non-nil, force publishing all
+files in PROJECT.  With a non-nil optional argument ASYNC,
+publishing will be done asynchronously, in another process."
+  (interactive
+   (list
+    (assoc (org-icompleting-read
+           "Publish project: "
+           org-publish-project-alist nil t)
+          org-publish-project-alist)
+    current-prefix-arg))
+  (let ((project-alist  (if (not (stringp project)) (list project)
+                         ;; If this function is called in batch mode,
+                         ;; project is still a string here.
+                         (list (assoc project org-publish-project-alist)))))
+    (if async
+       (org-export-async-start 'ignore
+         `(let ((org-publish-use-timestamps-flag
+                 (if ',force nil ,org-publish-use-timestamps-flag)))
+            (org-publish-projects ',project-alist)))
+      (save-window-excursion
+       (let* ((org-publish-use-timestamps-flag
+               (if force nil org-publish-use-timestamps-flag)))
+         (org-publish-projects project-alist))))))
+
+;;;###autoload
+(defun org-publish-all (&optional force async)
+  "Publish all projects.
+With prefix argument FORCE, remove all files in the timestamp
+directory and force publishing all projects.  With a non-nil
+optional argument ASYNC, publishing will be done asynchronously,
+in another process."
+  (interactive "P")
+  (if async
+      (org-export-async-start 'ignore
+       `(progn
+          (when ',force (org-publish-remove-all-timestamps))
+          (let ((org-publish-use-timestamps-flag
+                 (if ',force nil ,org-publish-use-timestamps-flag)))
+            (org-publish-projects ',org-publish-project-alist))))
+    (when force (org-publish-remove-all-timestamps))
+    (save-window-excursion
+      (let ((org-publish-use-timestamps-flag
+            (if force nil org-publish-use-timestamps-flag)))
+       (org-publish-projects org-publish-project-alist)))))
+
+
+;;;###autoload
+(defun org-publish-current-file (&optional force async)
+  "Publish the current file.
+With prefix argument FORCE, force publish the file.  When
+optional argument ASYNC is non-nil, publishing will be done
+asynchronously, in another process."
+  (interactive "P")
+  (let ((file (buffer-file-name (buffer-base-buffer))))
+    (if async
+       (org-export-async-start 'ignore
+         `(let ((org-publish-use-timestamps-flag
+                 (if ',force nil ,org-publish-use-timestamps-flag)))
+            (org-publish-file ,file)))
+      (save-window-excursion
+       (let ((org-publish-use-timestamps-flag
+              (if force nil org-publish-use-timestamps-flag)))
+         (org-publish-file file))))))
+
+;;;###autoload
+(defun org-publish-current-project (&optional force async)
+  "Publish the project associated with the current file.
+With a prefix argument, force publishing of all files in
+the project."
+  (interactive "P")
+  (save-window-excursion
+    (let ((project (org-publish-get-project-from-filename
+                   (buffer-file-name (buffer-base-buffer)) 'up)))
+      (if project (org-publish project force async)
+       (error "File %s is not part of any known project"
+              (buffer-file-name (buffer-base-buffer)))))))
+
+
+\f
+;;; Index generation
+
+(defun org-publish-collect-index (output backend info)
+  "Update index for a file in cache.
+
+OUTPUT is the output from transcoding current file.  BACKEND is
+the back-end that was used for transcoding.  INFO is a plist
+containing publishing and export options.
+
+The index relative to current file is stored as an alist.  An
+association has the following shape: (TERM FILE-NAME PARENT),
+where TERM is the indexed term, as a string, FILE-NAME is the
+original full path of the file where the term in encountered, and
+PARENT is a reference to the headline, if any, containing the
+original index keyword.  When non-nil, this reference is a cons
+cell.  Its CAR is a symbol among `id', `custom-id' and `name' and
+its CDR is a string."
+  (let ((file (plist-get info :input-file)))
+    (org-publish-cache-set-file-property
+     file :index
+     (delete-dups
+      (org-element-map (plist-get info :parse-tree) 'keyword
+       (lambda (k)
+         (when (equal (org-element-property :key k) "INDEX")
+           (let ((parent (org-export-get-parent-headline k)))
+             (list (org-element-property :value k)
+                   file
+                   (cond
+                    ((not parent) nil)
+                    ((let ((id (org-element-property :ID parent)))
+                       (and id (cons 'id id))))
+                    ((let ((id (org-element-property :CUSTOM_ID parent)))
+                       (and id (cons 'custom-id id))))
+                    (t (cons 'name
+                             ;; Remove statistics cookie.
+                             (replace-regexp-in-string
+                              "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
+                              (org-element-property :raw-value parent)))))))))
+       info))))
+  ;; Return output unchanged.
+  output)
+
+(defun org-publish-index-generate-theindex (project directory)
+  "Retrieve full index from cache and build \"theindex.org\".
+PROJECT is the project the index relates to.  DIRECTORY is the
+publishing directory."
+  (let ((all-files (org-publish-get-base-files
+                   project (plist-get (cdr project) :exclude)))
+       full-index)
+    ;; Compile full index and sort it alphabetically.
+    (dolist (file all-files
+                 (setq full-index
+                       (sort (nreverse full-index)
+                             (lambda (a b) (string< (downcase (car a))
+                                               (downcase (car b)))))))
+      (let ((index (org-publish-cache-get-file-property file :index)))
+       (dolist (term index)
+         (unless (member term full-index) (push term full-index)))))
+    ;; Write "theindex.inc" in DIRECTORY.
+    (with-temp-file (expand-file-name "theindex.inc" directory)
+      (let ((current-letter nil) (last-entry nil))
+       (dolist (idx full-index)
+         (let* ((entry (org-split-string (car idx) "!"))
+                (letter (upcase (substring (car entry) 0 1)))
+                ;; Transform file into a path relative to publishing
+                ;; directory.
+                (file (file-relative-name
+                       (nth 1 idx)
+                       (plist-get (cdr project) :base-directory))))
+           ;; Check if another letter has to be inserted.
+           (unless (string= letter current-letter)
+             (insert (format "* %s\n" letter)))
+           ;; Compute the first difference between last entry and
+           ;; current one: it tells the level at which new items
+           ;; should be added.
+           (let* ((rank (if (equal entry last-entry) (1- (length entry))
+                          (loop for n from 0 to (length entry)
+                                unless (equal (nth n entry) (nth n last-entry))
+                                return n)))
+                  (len (length (nthcdr rank entry))))
+             ;; For each term after the first difference, create
+             ;; a new sub-list with the term as body.  Moreover,
+             ;; linkify the last term.
+             (dotimes (n len)
+               (insert
+                (concat
+                 (make-string (* (+ rank n) 2) ? ) "  - "
+                 (if (not (= (1- len) n)) (nth (+ rank n) entry)
+                   ;; Last term: Link it to TARGET, if possible.
+                   (let ((target (nth 2 idx)))
+                     (format
+                      "[[%s][%s]]"
+                      ;; Destination.
+                      (case (car target)
+                        ('nil (format "file:%s" file))
+                        (id (format "id:%s" (cdr target)))
+                        (custom-id (format "file:%s::#%s" file (cdr target)))
+                        (otherwise (format "file:%s::*%s" file (cdr target))))
+                      ;; Description.
+                      (car (last entry)))))
+                 "\n"))))
+           (setq current-letter letter last-entry entry))))
+      ;; Create "theindex.org", if it doesn't exist yet, and provide
+      ;; a default index file.
+      (let ((index.org (expand-file-name "theindex.org" directory)))
+       (unless (file-exists-p index.org)
+         (with-temp-file index.org
+           (insert "#+TITLE: Index\n\n#+INCLUDE: \"theindex.inc\"\n\n")))))))
+
+
+\f
+;;; External Fuzzy Links Resolution
+;;
+;; This part implements tools to resolve [[file.org::*Some headline]]
+;; links, where "file.org" belongs to the current project.
+
+(defun org-publish-collect-numbering (output backend info)
+  (org-publish-cache-set-file-property
+   (plist-get info :input-file) :numbering
+   (mapcar (lambda (entry)
+            (cons (org-split-string
+                   (replace-regexp-in-string
+                    "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
+                    (org-element-property :raw-value (car entry))))
+                  (cdr entry)))
+          (plist-get info :headline-numbering)))
+  ;; Return output unchanged.
+  output)
+
+(defun org-publish-resolve-external-fuzzy-link (file fuzzy)
+  "Return numbering for headline matching FUZZY search in FILE.
+
+Return value is a list of numbers, or nil.  This function allows
+to resolve external fuzzy links like:
+
+  [[file.org::*fuzzy][description]"
+  (when org-publish-cache
+    (cdr (assoc (org-split-string
+                (if (eq (aref fuzzy 0) ?*) (substring fuzzy 1) fuzzy))
+               (org-publish-cache-get-file-property
+                (expand-file-name file) :numbering nil t)))))
+
+
+\f
+;;; Caching functions
+
+(defun org-publish-write-cache-file (&optional free-cache)
+  "Write `org-publish-cache' to file.
+If FREE-CACHE, empty the cache."
+  (unless org-publish-cache
+    (error "`org-publish-write-cache-file' called, but no cache present"))
+
+  (let ((cache-file (org-publish-cache-get ":cache-file:")))
+    (unless cache-file
+      (error "Cannot find cache-file name in `org-publish-write-cache-file'"))
+    (with-temp-file cache-file
+      (let (print-level print-length)
+       (insert "(setq org-publish-cache (make-hash-table :test 'equal :weakness nil :size 100))\n")
+       (maphash (lambda (k v)
+                  (insert
+                   (format (concat "(puthash %S "
+                                   (if (or (listp v) (symbolp v))
+                                       "'" "")
+                                   "%S org-publish-cache)\n") k v)))
+                org-publish-cache)))
+    (when free-cache (org-publish-reset-cache))))
+
+(defun org-publish-initialize-cache (project-name)
+  "Initialize the projects cache if not initialized yet and return it."
+
+  (unless project-name
+    (error "Cannot initialize `org-publish-cache' without projects name in `org-publish-initialize-cache'"))
+
+  (unless (file-exists-p org-publish-timestamp-directory)
+    (make-directory org-publish-timestamp-directory t))
+  (unless (file-directory-p org-publish-timestamp-directory)
+    (error "Org publish timestamp: %s is not a directory"
+          org-publish-timestamp-directory))
+
+  (unless (and org-publish-cache
+              (string= (org-publish-cache-get ":project:") project-name))
+    (let* ((cache-file
+           (concat
+            (expand-file-name org-publish-timestamp-directory)
+            project-name ".cache"))
+          (cexists (file-exists-p cache-file)))
+
+      (when org-publish-cache (org-publish-reset-cache))
+
+      (if cexists (load-file cache-file)
+       (setq org-publish-cache
+             (make-hash-table :test 'equal :weakness nil :size 100))
+       (org-publish-cache-set ":project:" project-name)
+       (org-publish-cache-set ":cache-file:" cache-file))
+      (unless cexists (org-publish-write-cache-file nil))))
+  org-publish-cache)
+
+(defun org-publish-reset-cache ()
+  "Empty org-publish-cache and reset it nil."
+  (message "%s" "Resetting org-publish-cache")
+  (when (hash-table-p org-publish-cache)
+    (clrhash org-publish-cache))
+  (setq org-publish-cache nil))
+
+(defun org-publish-cache-file-needs-publishing
+  (filename &optional pub-dir pub-func base-dir)
+  "Check the timestamp of the last publishing of FILENAME.
+Return non-nil if the file needs publishing.  Also check if
+any included files have been more recently published, so that
+the file including them will be republished as well."
+  (unless org-publish-cache
+    (error
+     "`org-publish-cache-file-needs-publishing' called, but no cache present"))
+  (let* ((case-fold-search t)
+        (key (org-publish-timestamp-filename filename pub-dir pub-func))
+        (pstamp (org-publish-cache-get key))
+        (org-inhibit-startup t)
+        (visiting (find-buffer-visiting filename))
+        included-files-ctime buf)
+
+    (when (equal (file-name-extension filename) "org")
+      (setq buf (find-file (expand-file-name filename)))
+      (with-current-buffer buf
+       (goto-char (point-min))
+       (while (re-search-forward
+               "^#\\+INCLUDE:[ \t]+\"\\([^\t\n\r\"]*\\)\"[ \t]*.*$" nil t)
+         (let* ((included-file (expand-file-name (match-string 1))))
+           (add-to-list 'included-files-ctime
+                        (org-publish-cache-ctime-of-src included-file) t))))
+      (unless visiting (kill-buffer buf)))
+    (if (null pstamp) t
+      (let ((ctime (org-publish-cache-ctime-of-src filename)))
+       (or (< pstamp ctime)
+           (when included-files-ctime
+             (not (null (delq nil (mapcar (lambda(ct) (< ctime ct))
+                                          included-files-ctime))))))))))
+
+(defun org-publish-cache-set-file-property
+  (filename property value &optional project-name)
+  "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
+Use cache file of PROJECT-NAME.  If the entry does not exist, it
+will be created.  Return VALUE."
+  ;; Evtl. load the requested cache file:
+  (if project-name (org-publish-initialize-cache project-name))
+  (let ((pl (org-publish-cache-get filename)))
+    (if pl (progn (plist-put pl property value) value)
+      (org-publish-cache-get-file-property
+       filename property value nil project-name))))
+
+(defun org-publish-cache-get-file-property
+  (filename property &optional default no-create project-name)
+  "Return the value for a PROPERTY of file FILENAME in publishing cache.
+Use cache file of PROJECT-NAME. Return the value of that PROPERTY
+or DEFAULT, if the value does not yet exist.  If the entry will
+be created, unless NO-CREATE is not nil."
+  ;; Evtl. load the requested cache file:
+  (if project-name (org-publish-initialize-cache project-name))
+  (let ((pl (org-publish-cache-get filename)) retval)
+    (if pl
+       (if (plist-member pl property)
+           (setq retval (plist-get pl property))
+         (setq retval default))
+      ;; no pl yet:
+      (unless no-create
+       (org-publish-cache-set filename (list property default)))
+      (setq retval default))
+    retval))
+
+(defun org-publish-cache-get (key)
+  "Return the value stored in `org-publish-cache' for key KEY.
+Returns nil, if no value or nil is found, or the cache does not
+exist."
+  (unless org-publish-cache
+    (error "`org-publish-cache-get' called, but no cache present"))
+  (gethash key org-publish-cache))
+
+(defun org-publish-cache-set (key value)
+  "Store KEY VALUE pair in `org-publish-cache'.
+Returns value on success, else nil."
+  (unless org-publish-cache
+    (error "`org-publish-cache-set' called, but no cache present"))
+  (puthash key value org-publish-cache))
+
+(defun org-publish-cache-ctime-of-src (file)
+  "Get the ctime of FILE as an integer."
+  (let ((attr (file-attributes
+              (expand-file-name (or (file-symlink-p file) file)
+                                (file-name-directory file)))))
+    (+ (lsh (car (nth 5 attr)) 16)
+       (cadr (nth 5 attr)))))
+
+
+(provide 'ox-publish)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-publish.el ends here
diff --git a/lisp/org/ox-texinfo.el b/lisp/org/ox-texinfo.el
new file mode 100644 (file)
index 0000000..0126170
--- /dev/null
@@ -0,0 +1,1891 @@
+;;; ox-texinfo.el --- Texinfo Back-End for Org Export Engine
+
+;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
+;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements a Texinfo back-end for Org generic
+;; exporter.
+;;
+;; To test it, run
+;;
+;;   M-: (org-export-to-buffer 'texinfo "*Test Texinfo*") RET
+;;
+;; in an Org mode buffer then switch to the buffer to see the Texinfo
+;; export.  See ox.el for more details on how this exporter works.
+;;
+
+;; It introduces nine new buffer keywords: "TEXINFO_CLASS",
+;; "TEXINFO_FILENAME", "TEXINFO_HEADER", "TEXINFO_POST_HEADER",
+;; "TEXINFO_DIR_CATEGORY", "TEXINFO_DIR_TITLE", "TEXINFO_DIR_DESC"
+;; "SUBTITLE" and "SUBAUTHOR".
+
+;;
+;; It introduces 1 new headline property keywords:
+;; "TEXINFO_MENU_TITLE" for optional menu titles.
+;;
+;; To include inline code snippets (for example for generating @kbd{}
+;; and @key{} commands), the following export-snippet keys are
+;; accepted:
+;;
+;;     texinfo
+;;     info
+;;
+;; You can add them for export snippets via any of the below:
+;;
+;;    (add-to-list 'org-export-snippet-translation-alist
+;;                 '("info" . "texinfo"))
+;;
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'ox)
+
+(defvar orgtbl-exp-regexp)
+
+
+\f
+;;; Define Back-End
+
+(org-export-define-backend 'texinfo
+  '((bold . org-texinfo-bold)
+    (center-block . org-texinfo-center-block)
+    (clock . org-texinfo-clock)
+    (code . org-texinfo-code)
+    (comment . org-texinfo-comment)
+    (comment-block . org-texinfo-comment-block)
+    (drawer . org-texinfo-drawer)
+    (dynamic-block . org-texinfo-dynamic-block)
+    (entity . org-texinfo-entity)
+    (example-block . org-texinfo-example-block)
+    (export-block . org-texinfo-export-block)
+    (export-snippet . org-texinfo-export-snippet)
+    (fixed-width . org-texinfo-fixed-width)
+    (footnote-definition . org-texinfo-footnote-definition)
+    (footnote-reference . org-texinfo-footnote-reference)
+    (headline . org-texinfo-headline)
+    (inline-src-block . org-texinfo-inline-src-block)
+    (inlinetask . org-texinfo-inlinetask)
+    (italic . org-texinfo-italic)
+    (item . org-texinfo-item)
+    (keyword . org-texinfo-keyword)
+    (line-break . org-texinfo-line-break)
+    (link . org-texinfo-link)
+    (paragraph . org-texinfo-paragraph)
+    (plain-list . org-texinfo-plain-list)
+    (plain-text . org-texinfo-plain-text)
+    (planning . org-texinfo-planning)
+    (property-drawer . org-texinfo-property-drawer)
+    (quote-block . org-texinfo-quote-block)
+    (quote-section . org-texinfo-quote-section)
+    (radio-target . org-texinfo-radio-target)
+    (section . org-texinfo-section)
+    (special-block . org-texinfo-special-block)
+    (src-block . org-texinfo-src-block)
+    (statistics-cookie . org-texinfo-statistics-cookie)
+    (subscript . org-texinfo-subscript)
+    (superscript . org-texinfo-superscript)
+    (table . org-texinfo-table)
+    (table-cell . org-texinfo-table-cell)
+    (table-row . org-texinfo-table-row)
+    (target . org-texinfo-target)
+    (template . org-texinfo-template)
+    (timestamp . org-texinfo-timestamp)
+    (verbatim . org-texinfo-verbatim)
+    (verse-block . org-texinfo-verse-block))
+  :export-block "TEXINFO"
+  :filters-alist
+  '((:filter-headline . org-texinfo-filter-section-blank-lines)
+    (:filter-section . org-texinfo-filter-section-blank-lines))
+  :menu-entry
+  '(?i "Export to Texinfo"
+       ((?t "As TEXI file" org-texinfo-export-to-texinfo)
+       (?i "As INFO file" org-texinfo-export-to-info)))
+  :options-alist
+  '((:texinfo-filename "TEXINFO_FILENAME" nil org-texinfo-filename t)
+    (:texinfo-class "TEXINFO_CLASS" nil org-texinfo-default-class t)
+    (:texinfo-header "TEXINFO_HEADER" nil nil newline)
+    (:texinfo-post-header "TEXINFO_POST_HEADER" nil nil newline)
+    (:subtitle "SUBTITLE" nil nil newline)
+    (:subauthor "SUBAUTHOR" nil nil newline)
+    (:texinfo-dircat "TEXINFO_DIR_CATEGORY" nil nil t)
+    (:texinfo-dirtitle "TEXINFO_DIR_TITLE" nil nil t)
+    (:texinfo-dirdesc "TEXINFO_DIR_DESC" nil nil t)))
+
+
+\f
+;;; User Configurable Variables
+
+(defgroup org-export-texinfo nil
+  "Options for exporting Org mode files to Texinfo."
+  :tag "Org Export Texinfo"
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :group 'org-export)
+
+;;; Preamble
+
+(defcustom org-texinfo-filename nil
+  "Default filename for Texinfo output."
+  :group 'org-export-texinfo
+  :type '(string :tag "Export Filename"))
+
+(defcustom org-texinfo-coding-system nil
+  "Default document encoding for Texinfo output.
+
+If `nil' it will default to `buffer-file-coding-system'."
+  :group 'org-export-texinfo
+  :type 'coding-system)
+
+(defcustom org-texinfo-default-class "info"
+  "The default Texinfo class."
+  :group 'org-export-texinfo
+  :type '(string :tag "Texinfo class"))
+
+(defcustom org-texinfo-classes
+  '(("info"
+     "\\input texinfo    @c -*- texinfo -*-"
+     ("@chapter %s" . "@unnumbered %s")
+     ("@section %s" . "@unnumberedsec %s")
+     ("@subsection %s" . "@unnumberedsubsec %s")
+     ("@subsubsection %s" . "@unnumberedsubsubsec %s")))
+  "Alist of Texinfo classes and associated header and structure.
+If #+Texinfo_CLASS is set in the buffer, use its value and the
+associated information.  Here is the structure of each cell:
+
+  \(class-name
+    header-string
+    \(numbered-section . unnumbered-section\)
+    ...\)
+
+The sectioning structure
+------------------------
+
+The sectioning structure of the class is given by the elements
+following the header string.  For each sectioning level, a number
+of strings is specified.  A %s formatter is mandatory in each
+section string and will be replaced by the title of the section.
+
+Instead of a list of sectioning commands, you can also specify
+a function name.  That function will be called with two
+parameters, the \(reduced) level of the headline, and a predicate
+non-nil when the headline should be numbered.  It must return
+a format string in which the section title will be added."
+  :group 'org-export-texinfo
+  :type '(repeat
+         (list (string :tag "Texinfo class")
+               (string :tag "Texinfo header")
+               (repeat :tag "Levels" :inline t
+                       (choice
+                        (cons :tag "Heading"
+                              (string :tag "  numbered")
+                              (string :tag "unnumbered"))
+                        (function :tag "Hook computing sectioning"))))))
+
+;;; Headline
+
+(defcustom org-texinfo-format-headline-function nil
+  "Function to format headline text.
+
+This function will be called with 5 arguments:
+TODO      the todo keyword (string or nil).
+TODO-TYPE the type of todo (symbol: `todo', `done', nil)
+PRIORITY  the priority of the headline (integer or nil)
+TEXT      the main headline text (string).
+TAGS      the tags as a list of strings (list of strings or nil).
+
+The function result will be used in the section format string.
+
+As an example, one could set the variable to the following, in
+order to reproduce the default set-up:
+
+\(defun org-texinfo-format-headline (todo todo-type priority text tags)
+  \"Default format function for a headline.\"
+  \(concat (when todo
+            \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo))
+         \(when priority
+            \(format \"\\\\framebox{\\\\#%c} \" priority))
+         text
+         \(when tags
+            \(format \"\\\\hfill{}\\\\textsc{%s}\"
+              \(mapconcat 'identity tags \":\"))))"
+  :group 'org-export-texinfo
+  :type 'function)
+
+;;; Node listing (menu)
+
+(defcustom org-texinfo-node-description-column 32
+  "Column at which to start the description in the node
+  listings.
+
+If a node title is greater than this length, the description will
+be placed after the end of the title."
+  :group 'org-export-texinfo
+  :type 'integer)
+
+;;; Footnotes
+;;
+;; Footnotes are inserted directly
+
+;;; Timestamps
+
+(defcustom org-texinfo-active-timestamp-format "@emph{%s}"
+  "A printf format string to be applied to active timestamps."
+  :group 'org-export-texinfo
+  :type 'string)
+
+(defcustom org-texinfo-inactive-timestamp-format "@emph{%s}"
+  "A printf format string to be applied to inactive timestamps."
+  :group 'org-export-texinfo
+  :type 'string)
+
+(defcustom org-texinfo-diary-timestamp-format "@emph{%s}"
+  "A printf format string to be applied to diary timestamps."
+  :group 'org-export-texinfo
+  :type 'string)
+
+;;; Links
+
+(defcustom org-texinfo-link-with-unknown-path-format "@indicateurl{%s}"
+  "Format string for links with unknown path type."
+  :group 'org-export-texinfo
+  :type 'string)
+
+;;; Tables
+
+(defcustom org-texinfo-tables-verbatim nil
+  "When non-nil, tables are exported verbatim."
+  :group 'org-export-texinfo
+  :type 'boolean)
+
+(defcustom org-texinfo-table-scientific-notation "%s\\,(%s)"
+  "Format string to display numbers in scientific notation.
+The format should have \"%s\" twice, for mantissa and exponent
+\(i.e. \"%s\\\\times10^{%s}\").
+
+When nil, no transformation is made."
+  :group 'org-export-texinfo
+  :type '(choice
+         (string :tag "Format string")
+         (const :tag "No formatting")))
+
+(defcustom org-texinfo-def-table-markup "@samp"
+  "Default setting for @table environments.")
+
+;;; Text markup
+
+(defcustom org-texinfo-text-markup-alist '((bold . "@strong{%s}")
+                                          (code . code)
+                                          (italic . "@emph{%s}")
+                                          (verbatim . verb)
+                                          (comment . "@c %s"))
+  "Alist of Texinfo expressions to convert text markup.
+
+The key must be a symbol among `bold', `italic' and `comment'.
+The value is a formatting string to wrap fontified text with.
+
+Value can also be set to the following symbols: `verb' and
+`code'.  For the former, Org will use \"@verb\" to
+create a format string and select a delimiter character that
+isn't in the string.  For the latter, Org will use \"@code\"
+to typeset and try to protect special characters.
+
+If no association can be found for a given markup, text will be
+returned as-is."
+  :group 'org-export-texinfo
+  :type 'alist
+  :options '(bold code italic verbatim comment))
+
+;;; Drawers
+
+(defcustom org-texinfo-format-drawer-function nil
+  "Function called to format a drawer in Texinfo code.
+
+The function must accept two parameters:
+  NAME      the drawer name, like \"LOGBOOK\"
+  CONTENTS  the contents of the drawer.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-texinfo-format-drawer-default \(name contents\)
+  \"Format a drawer element for Texinfo export.\"
+  contents\)"
+  :group 'org-export-texinfo
+  :type 'function)
+
+;;; Inlinetasks
+
+(defcustom org-texinfo-format-inlinetask-function nil
+  "Function called to format an inlinetask in Texinfo code.
+
+The function must accept six parameters:
+  TODO      the todo keyword, as a string
+  TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
+  PRIORITY  the inlinetask priority, as a string
+  NAME      the inlinetask name, as a string.
+  TAGS      the inlinetask tags, as a list of strings.
+  CONTENTS  the contents of the inlinetask, as a string.
+
+The function should return the string to be exported.
+
+For example, the variable could be set to the following function
+in order to mimic default behaviour:
+
+\(defun org-texinfo-format-inlinetask \(todo type priority name tags contents\)
+\"Format an inline task element for Texinfo export.\"
+  \(let ((full-title
+        \(concat
+         \(when todo
+            \(format \"@strong{%s} \" todo))
+         \(when priority (format \"#%c \" priority))
+         title
+         \(when tags
+            \(format \":%s:\"
+                    \(mapconcat 'identity tags \":\")))))
+    \(format (concat \"@center %s\n\n\"
+                   \"%s\"
+                    \"\n\"))
+           full-title contents))"
+  :group 'org-export-texinfo
+  :type 'function)
+
+;;; Src blocks
+;;
+;; Src Blocks are example blocks, except for LISP
+
+;;; Compilation
+
+(defcustom org-texinfo-info-process
+  '("makeinfo %f")
+  "Commands to process a Texinfo file to an INFO file.
+This is list of strings, each of them will be given to the shell
+as a command.  %f in the command will be replaced by the full
+file name, %b by the file base name \(i.e without extension) and
+%o by the base directory of the file."
+  :group 'org-export-texinfo
+  :type '(repeat :tag "Shell command sequence"
+                (string :tag "Shell command")))
+
+(defcustom org-texinfo-logfiles-extensions
+  '("aux" "toc" "cp" "fn" "ky" "pg" "tp" "vr")
+  "The list of file extensions to consider as Texinfo logfiles.
+The logfiles will be remove if `org-texinfo-remove-logfiles' is
+non-nil."
+  :group 'org-export-texinfo
+  :type '(repeat (string :tag "Extension")))
+
+(defcustom org-texinfo-remove-logfiles t
+  "Non-nil means remove the logfiles produced by compiling a Texinfo file.
+By default, logfiles are files with these extensions: .aux, .toc,
+.cp, .fn, .ky, .pg and .tp.  To define the set of logfiles to remove,
+set `org-texinfo-logfiles-extensions'."
+  :group 'org-export-latex
+  :type 'boolean)
+
+
+;;; Constants
+(defconst org-texinfo-max-toc-depth 4
+  "Maximum depth for creation of detailed menu listings.  Beyond
+  this depth Texinfo will not recognize the nodes and will cause
+  errors.  Left as a constant in case this value ever changes.")
+
+(defconst org-texinfo-supported-coding-systems
+  '("US-ASCII" "UTF-8" "ISO-8859-15" "ISO-8859-1" "ISO-8859-2" "koi8-r" "koi8-u")
+  "List of coding systems supported by Texinfo, as strings.
+Specified coding system will be matched against these strings.
+If two strings share the same prefix (e.g. \"ISO-8859-1\" and
+\"ISO-8859-15\"), the most specific one has to be listed first.")
+
+\f
+;;; Internal Functions
+
+(defun org-texinfo-filter-section-blank-lines (headline back-end info)
+  "Filter controlling number of blank lines after a section."
+  (let ((blanks (make-string 2 ?\n)))
+    (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline)))
+
+(defun org-texinfo--find-verb-separator (s)
+  "Return a character not used in string S.
+This is used to choose a separator for constructs like \\verb."
+  (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
+    (loop for c across ll
+         when (not (string-match (regexp-quote (char-to-string c)) s))
+         return (char-to-string c))))
+
+(defun org-texinfo--make-option-string (options)
+  "Return a comma separated string of keywords and values.
+OPTIONS is an alist where the key is the options keyword as
+a string, and the value a list containing the keyword value, or
+nil."
+  (mapconcat (lambda (pair)
+              (concat (first pair)
+                      (when (> (length (second pair)) 0)
+                        (concat "=" (second pair)))))
+            options
+            ","))
+
+(defun org-texinfo--text-markup (text markup)
+  "Format TEXT depending on MARKUP text markup.
+See `org-texinfo-text-markup-alist' for details."
+  (let ((fmt (cdr (assq markup org-texinfo-text-markup-alist))))
+    (cond
+     ;; No format string: Return raw text.
+     ((not fmt) text)
+     ((eq 'verb fmt)
+      (let ((separator (org-texinfo--find-verb-separator text)))
+       (concat "@verb{" separator text separator "}")))
+     ((eq 'code fmt)
+      (let ((start 0)
+           (rtn "")
+           char)
+       (while (string-match "[@{}]" text)
+         (setq char (match-string 0 text))
+         (if (> (match-beginning 0) 0)
+             (setq rtn (concat rtn (substring text 0 (match-beginning 0)))))
+         (setq text (substring text (1+ (match-beginning 0))))
+         (setq char (concat "@" char)
+               rtn (concat rtn char)))
+       (setq text (concat rtn text)
+             fmt "@code{%s}")
+       (format fmt text)))
+     ;; Else use format string.
+     (t (format fmt text)))))
+
+(defun org-texinfo--get-node (headline info)
+  "Return node entry associated to HEADLINE.
+INFO is a plist used as a communication channel."
+  (let ((menu-title (org-export-get-alt-title headline info)))
+    (org-texinfo--sanitize-menu
+     (replace-regexp-in-string
+      "%" "%%"
+      (if menu-title (org-export-data menu-title info)
+       (org-texinfo--sanitize-headline
+        (org-element-property :title headline) info))))))
+
+;;; Headline sanitizing
+
+(defun org-texinfo--sanitize-headline (headline info)
+  "Remove all formatting from the text of a headline for use in
+  node and menu listing."
+  (mapconcat 'identity
+            (org-texinfo--sanitize-headline-contents headline info) " "))
+
+(defun org-texinfo--sanitize-headline-contents (headline info)
+  "Retrieve the content of the headline.
+
+Any content that can contain further formatting is checked
+recursively, to ensure that nested content is also properly
+retrieved."
+  (loop for contents in headline append
+       (cond
+        ;; already a string
+        ((stringp contents)
+         (list (replace-regexp-in-string " $" "" contents)))
+        ;; Is exported as-is (value)
+        ((org-element-map contents '(verbatim code)
+           (lambda (value) (org-element-property :value value)) info))
+        ;; Has content and recurse into the content
+        ((org-element-contents contents)
+         (org-texinfo--sanitize-headline-contents
+          (org-element-contents contents) info)))))
+
+;;; Menu sanitizing
+
+(defun org-texinfo--sanitize-menu (title)
+  "Remove invalid characters from TITLE for use in menus and
+nodes.
+
+Based on Texinfo specifications, the following must be removed:
+@ { } ( ) : . ,"
+  (replace-regexp-in-string "[@{}():,.]" "" title))
+
+;;; Content sanitizing
+
+(defun org-texinfo--sanitize-content (text)
+  "Ensure characters are properly escaped when used in headlines or blocks.
+
+Escape characters are: @ { }"
+  (replace-regexp-in-string "\\\([@{}]\\\)" "@\\1" text))
+
+;;; Menu creation
+
+(defun org-texinfo--build-menu (tree level info &optional detailed)
+  "Create the @menu/@end menu information from TREE at headline
+level LEVEL.
+
+TREE contains the parse-tree to work with, either of the entire
+document or of a specific parent headline.  LEVEL indicates what
+level of headlines to look at when generating the menu.  INFO is
+a plist containing contextual information.
+
+Detailed determines whether to build a single level of menu, or
+recurse into all children as well."
+  (let ((menu (org-texinfo--generate-menu-list tree level info))
+       output text-menu)
+    (cond
+     (detailed
+      ;; Looping is done within the menu generation.
+      (setq text-menu (org-texinfo--generate-detailed menu level info)))
+     (t
+      (setq text-menu (org-texinfo--generate-menu-items menu info))))
+    (when text-menu
+      (setq output (org-texinfo--format-menu text-menu))
+      (mapconcat 'identity output "\n"))))
+
+(defun org-texinfo--generate-detailed (menu level info)
+  "Generate a detailed listing of all subheadings within MENU starting at LEVEL.
+
+MENU is the parse-tree to work with.  LEVEL is the starting level
+for the menu headlines and from which recursion occurs.  INFO is
+a plist containing contextual information."
+  (when level
+    (let ((max-depth (min org-texinfo-max-toc-depth
+                     (plist-get info :headline-levels))))
+      (when (> max-depth level)
+       (loop for headline in menu append
+             (let* ((title (org-texinfo--menu-headlines headline info))
+                    ;; Create list of menu entries for the next level
+                    (sublist (org-texinfo--generate-menu-list
+                              headline (1+ level) info))
+                    ;; Generate the menu items for that level.  If
+                    ;; there are none omit that heading completely,
+                    ;; otherwise join the title to it's related entries.
+                    (submenu (if (org-texinfo--generate-menu-items sublist info)
+                                 (append (list title)
+                                         (org-texinfo--generate-menu-items sublist info))
+                               'nil))
+                    ;; Start the process over the next level down.
+                    (recursion (org-texinfo--generate-detailed sublist (1+ level) info)))
+               (setq recursion (append submenu recursion))
+               recursion))))))
+
+(defun org-texinfo--generate-menu-list (tree level info)
+  "Generate the list of headlines that are within a given level
+of the tree for further formatting.
+
+TREE is the parse-tree containing the headlines.  LEVEL is the
+headline level to generate a list of.  INFO is a plist holding
+contextual information."
+  (org-element-map tree 'headline
+    (lambda (head)
+      (and (= (org-export-get-relative-level head info) level)
+          ;; Do not take note of footnotes or copying headlines.
+          (not (org-element-property :COPYING head))
+          (not (org-element-property :footnote-section-p head))
+          ;; Collect headline.
+          head))
+    info))
+
+(defun org-texinfo--generate-menu-items (items info)
+  "Generate a list of headline information from the listing ITEMS.
+
+ITEMS is a list of the headlines to be converted into entries.
+INFO is a plist containing contextual information.
+
+Returns a list containing the following information from each
+headline: length, title, description.  This is used to format the
+menu using `org-texinfo--format-menu'."
+  (loop for headline in items collect
+       (let* ((menu-title (org-texinfo--sanitize-menu
+                           (org-export-data
+                            (org-export-get-alt-title headline info)
+                            info)))
+              (title (org-texinfo--sanitize-menu
+                      (org-texinfo--sanitize-headline
+                       (org-element-property :title headline) info)))
+              (descr (org-export-data
+                      (org-element-property :DESCRIPTION headline)
+                      info))
+              (menu-entry (if (string= "" menu-title) title menu-title))
+              (len (length menu-entry))
+              (output (list len menu-entry descr)))
+         output)))
+
+(defun org-texinfo--menu-headlines (headline info)
+  "Retrieve the title from HEADLINE.
+
+INFO is a plist holding contextual information.
+
+Return the headline as a list of (length title description) with
+length of -1 and nil description.  This is used in
+`org-texinfo--format-menu' to identify headlines as opposed to
+entries."
+  (let ((title (org-export-data
+               (org-element-property :title headline) info)))
+    (list -1 title 'nil)))
+
+(defun org-texinfo--format-menu (text-menu)
+  "Format the TEXT-MENU items to be properly printed in the menu.
+
+Each entry in the menu should be provided as (length title
+description).
+
+Headlines in the detailed menu are given length -1 to ensure they
+are never confused with other entries.  They also have no
+description.
+
+Other menu items are output as:
+    Title::     description
+
+With the spacing between :: and description based on the length
+of the longest menu entry."
+
+  (let (output)
+    (setq output
+          (mapcar (lambda (name)
+                    (let* ((title   (nth 1 name))
+                           (desc    (nth 2 name))
+                           (length  (nth 0 name))
+                          (column  (max
+                                    ;;6 is "* " ":: " for inserted text
+                                    length
+                                    (-
+                                     org-texinfo-node-description-column
+                                     6)))
+                          (spacing (- column length)
+                                   ))
+                      (if (> length -1)
+                          (concat "* " title "::  "
+                                  (make-string spacing ?\s)
+                                  (if desc
+                                      (concat desc)))
+                        (concat "\n" title "\n"))))
+                 text-menu))
+    output))
+
+;;; Template
+
+(defun org-texinfo-template (contents info)
+  "Return complete document string after Texinfo conversion.
+CONTENTS is the transcoded contents string.  INFO is a plist
+holding export options."
+  (let* ((title (org-export-data (plist-get info :title) info))
+        (info-filename (or (plist-get info :texinfo-filename)
+                           (file-name-nondirectory
+                            (org-export-output-file-name ".info"))))
+        (author (org-export-data (plist-get info :author) info))
+        (lang (org-export-data (plist-get info :language) info))
+        (texinfo-header (plist-get info :texinfo-header))
+        (texinfo-post-header (plist-get info :texinfo-post-header))
+        (subtitle (plist-get info :subtitle))
+        (subauthor (plist-get info :subauthor))
+        (class (plist-get info :texinfo-class))
+        (header (nth 1 (assoc class org-texinfo-classes)))
+        (copying
+         (org-element-map (plist-get info :parse-tree) 'headline
+           (lambda (hl) (and (org-element-property :COPYING hl) hl)) info t))
+        (dircat (plist-get info :texinfo-dircat))
+        (dirtitle (plist-get info :texinfo-dirtitle))
+        (dirdesc (plist-get info :texinfo-dirdesc))
+        ;; Spacing to align description (column 32 - 3 for `* ' and
+        ;; `.' in text.
+        (dirspacing (- 29 (length dirtitle)))
+        (menu (org-texinfo-make-menu info 'main))
+        (detail-menu (org-texinfo-make-menu info 'detailed)))
+    (concat
+     ;; Header
+     header "\n"
+     "@c %**start of header\n"
+     ;; Filename and Title
+     "@setfilename " info-filename "\n"
+     "@settitle " title "\n"
+     ;; Coding system.
+     (format
+      "@documentencoding %s\n"
+      (catch 'coding-system
+       (let ((case-fold-search t)
+             (name (symbol-name (or org-texinfo-coding-system
+                                    buffer-file-coding-system))))
+         (dolist (system org-texinfo-supported-coding-systems "UTF-8")
+           (when (org-string-match-p (regexp-quote system) name)
+             (throw 'coding-system system))))))
+     "\n"
+     (format "@documentlanguage %s\n" lang)
+     "\n\n"
+     "@c Version and Contact Info\n"
+     "@set AUTHOR " author "\n"
+
+     ;; Additional Header Options set by `#+TEXINFO_HEADER
+     (if texinfo-header
+        (concat "\n"
+                texinfo-header
+                "\n"))
+
+     "@c %**end of header\n"
+     "@finalout\n"
+     "\n\n"
+
+     ;; Additional Header Options set by #+TEXINFO_POST_HEADER
+     (if texinfo-post-header
+        (concat "\n"
+                texinfo-post-header
+                "\n"))
+
+     ;; Copying
+     "@copying\n"
+     ;; Only export the content of the headline, do not need the
+     ;; initial headline.
+     (org-export-data (nth 2 copying) info)
+     "@end copying\n"
+     "\n\n"
+
+     ;; Info directory information
+     ;; Only supply if both title and category are provided
+     (if (and dircat dirtitle)
+        (concat "@dircategory " dircat "\n"
+                "@direntry\n"
+                "* " dirtitle "."
+                (make-string dirspacing ?\s)
+                dirdesc "\n"
+                "@end direntry\n"))
+     "\n\n"
+
+     ;; Title
+     "@titlepage\n"
+     "@title " title "\n\n"
+     (if subtitle
+        (concat "@subtitle " subtitle "\n"))
+     "@author " author "\n"
+     (if subauthor
+        (concat subauthor "\n"))
+     "\n"
+     "@c The following two commands start the copyright page.\n"
+     "@page\n"
+     "@vskip 0pt plus 1filll\n"
+     "@insertcopying\n"
+     "@end titlepage\n\n"
+     "@c Output the table of contents at the beginning.\n"
+     "@contents\n\n"
+
+     ;; Configure Top Node when not for Tex
+     "@ifnottex\n"
+     "@node Top\n"
+     "@top " title " Manual\n"
+     "@insertcopying\n"
+     "@end ifnottex\n\n"
+
+     ;; Do not output menus if they are empty
+     (if menu
+        ;; Menu
+        (concat "@menu\n"
+                menu
+                "\n\n"
+                ;; Detailed Menu
+                (if detail-menu
+                    (concat "@detailmenu\n"
+                            " --- The Detailed Node Listing ---\n"
+                            detail-menu
+                            "\n\n"
+                            "@end detailmenu\n"))
+                "@end menu\n"))
+     "\n\n"
+
+     ;; Document's body.
+     contents
+     "\n"
+     ;; Creator.
+     (let ((creator-info (plist-get info :with-creator)))
+       (cond
+       ((not creator-info) "")
+       ((eq creator-info 'comment)
+        (format "@c %s\n" (plist-get info :creator)))
+       (t (concat (plist-get info :creator) "\n"))))
+     ;; Document end.
+     "\n@bye")))
+
+
+\f
+;;; Transcode Functions
+
+;;; Bold
+
+(defun org-texinfo-bold (bold contents info)
+  "Transcode BOLD from Org to Texinfo.
+CONTENTS is the text with bold markup.  INFO is a plist holding
+contextual information."
+  (org-texinfo--text-markup contents 'bold))
+
+;;; Center Block
+
+(defun org-texinfo-center-block (center-block contents info)
+  "Transcode a CENTER-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist used
+as a communication channel."
+  contents)
+
+;;; Clock
+
+(defun org-texinfo-clock (clock contents info)
+  "Transcode a CLOCK element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "@noindent"
+   (format "@strong{%s} " org-clock-string)
+   (format org-texinfo-inactive-timestamp-format
+          (concat (org-translate-time
+                   (org-element-property :raw-value
+                                         (org-element-property :value clock)))
+                  (let ((time (org-element-property :duration clock)))
+                    (and time (format " (%s)" time)))))
+   "@*"))
+
+;;; Code
+
+(defun org-texinfo-code (code contents info)
+  "Transcode a CODE object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-texinfo--text-markup (org-element-property :value code) 'code))
+
+;;; Comment
+
+(defun org-texinfo-comment (comment contents info)
+  "Transcode a COMMENT object from Org to Texinfo.
+CONTENTS is the text in the comment.  INFO is a plist holding
+contextual information."
+  (org-texinfo--text-markup (org-element-property :value comment) 'comment))
+
+;;; Comment Block
+
+(defun org-texinfo-comment-block (comment-block contents info)
+  "Transcode a COMMENT-BLOCK object from Org to Texinfo.
+CONTENTS is the text within the block.  INFO is a plist holding
+contextual information."
+  (format "@ignore\n%s@end ignore" (org-element-property :value comment-block)))
+
+;;; Drawer
+
+(defun org-texinfo-drawer (drawer contents info)
+  "Transcode a DRAWER element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let* ((name (org-element-property :drawer-name drawer))
+        (output (if (functionp org-texinfo-format-drawer-function)
+                    (funcall org-texinfo-format-drawer-function
+                             name contents)
+                  ;; If there's no user defined function: simply
+                  ;; display contents of the drawer.
+                  contents)))
+    output))
+
+;;; Dynamic Block
+
+(defun org-texinfo-dynamic-block (dynamic-block contents info)
+  "Transcode a DYNAMIC-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information.  See `org-export-data'."
+  contents)
+
+;;; Entity
+
+(defun org-texinfo-entity (entity contents info)
+  "Transcode an ENTITY object from Org to Texinfo.
+CONTENTS are the definition itself.  INFO is a plist holding
+contextual information."
+  (let ((ent (org-element-property :latex entity)))
+    (if (org-element-property :latex-math-p entity) (format "@math{%s}" ent) ent)))
+
+;;; Example Block
+
+(defun org-texinfo-example-block (example-block contents info)
+  "Transcode an EXAMPLE-BLOCK element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format "@verbatim\n%s@end verbatim"
+         (org-export-format-code-default example-block info)))
+
+;;; Export Block
+
+(defun org-texinfo-export-block (export-block contents info)
+  "Transcode a EXPORT-BLOCK element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (string= (org-element-property :type export-block) "TEXINFO")
+    (org-remove-indentation (org-element-property :value export-block))))
+
+;;; Export Snippet
+
+(defun org-texinfo-export-snippet (export-snippet contents info)
+  "Transcode a EXPORT-SNIPPET object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (when (eq (org-export-snippet-backend export-snippet) 'texinfo)
+    (org-element-property :value export-snippet)))
+
+;;; Fixed Width
+
+(defun org-texinfo-fixed-width (fixed-width contents info)
+  "Transcode a FIXED-WIDTH element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (format "@example\n%s\n@end example"
+         (org-remove-indentation
+          (org-texinfo--sanitize-content
+           (org-element-property :value fixed-width)))))
+
+;;; Footnote Reference
+;;
+
+(defun org-texinfo-footnote-reference (footnote contents info)
+  "Create a footnote reference for FOOTNOTE.
+
+FOOTNOTE is the footnote to define.  CONTENTS is nil.  INFO is a
+plist holding contextual information."
+  (let ((def (org-export-get-footnote-definition footnote info)))
+    (format "@footnote{%s}"
+           (org-trim (org-export-data def info)))))
+
+;;; Headline
+
+(defun org-texinfo-headline (headline contents info)
+  "Transcode a HEADLINE element from Org to Texinfo.
+CONTENTS holds the contents of the headline.  INFO is a plist
+holding contextual information."
+  (let* ((class (plist-get info :texinfo-class))
+        (level (org-export-get-relative-level headline info))
+        (numberedp (org-export-numbered-headline-p headline info))
+        (class-sectioning (assoc class org-texinfo-classes))
+        ;; Find the index type, if any
+        (index (org-element-property :INDEX headline))
+        ;; Check if it is an appendix
+        (appendix (org-element-property :APPENDIX headline))
+        ;; Retrieve headline text
+        (text (org-texinfo--sanitize-headline
+               (org-element-property :title headline) info))
+        ;; Create node info, to insert it before section formatting.
+        ;; Use custom menu title if present
+        (node (format "@node %s\n" (org-texinfo--get-node headline info)))
+        ;; Menus must be generated with first child, otherwise they
+        ;; will not nest properly
+        (menu (let* ((first (org-export-first-sibling-p headline info))
+                     (parent (org-export-get-parent-headline headline))
+                     (title (org-texinfo--sanitize-headline
+                             (org-element-property :title parent) info))
+                     heading listing
+                     (tree (plist-get info :parse-tree)))
+                (if first
+                    (org-element-map (plist-get info :parse-tree) 'headline
+                      (lambda (ref)
+                        (if (member title (org-element-property :title ref))
+                            (push ref heading)))
+                      info t))
+                (setq listing (org-texinfo--build-menu
+                               (car heading) level info))
+                (if listing
+                    (setq listing (replace-regexp-in-string
+                                   "%" "%%" listing)
+                          listing (format
+                                   "\n@menu\n%s\n@end menu\n\n" listing))
+                  'nil)))
+        ;; Section formatting will set two placeholders: one for the
+        ;; title and the other for the contents.
+        (section-fmt
+         (let ((sec (if (and (symbolp (nth 2 class-sectioning))
+                             (fboundp (nth 2 class-sectioning)))
+                        (funcall (nth 2 class-sectioning) level numberedp)
+                      (nth (1+ level) class-sectioning))))
+           (cond
+            ;; No section available for that LEVEL.
+            ((not sec) nil)
+            ;; Section format directly returned by a function.
+            ((stringp sec) sec)
+            ;; (numbered-section . unnumbered-section)
+            ((not (consp (cdr sec)))
+             (cond
+              ;;If an index, always unnumbered
+              (index
+               (concat menu node (cdr sec) "\n%s"))
+              (appendix
+               (concat menu node (replace-regexp-in-string
+                                  "unnumbered"
+                                  "appendix"
+                                  (cdr sec)) "\n%s"))
+               ;; Otherwise number as needed.
+              (t
+               (concat menu node
+                       (funcall
+                        (if numberedp #'car #'cdr) sec) "\n%s")))))))
+        (todo
+         (and (plist-get info :with-todo-keywords)
+              (let ((todo (org-element-property :todo-keyword headline)))
+                (and todo (org-export-data todo info)))))
+        (todo-type (and todo (org-element-property :todo-type headline)))
+        (tags (and (plist-get info :with-tags)
+                   (org-export-get-tags headline info)))
+        (priority (and (plist-get info :with-priority)
+                       (org-element-property :priority headline)))
+        ;; Create the headline text along with a no-tag version.  The
+        ;; latter is required to remove tags from table of contents.
+        (full-text (org-texinfo--sanitize-content
+                    (if (functionp org-texinfo-format-headline-function)
+                        ;; User-defined formatting function.
+                        (funcall org-texinfo-format-headline-function
+                                 todo todo-type priority text tags)
+                      ;; Default formatting.
+                      (concat
+                       (when todo
+                         (format "@strong{%s} " todo))
+                       (when priority (format "@emph{#%s} " priority))
+                       text
+                       (when tags
+                         (format " :%s:"
+                                 (mapconcat 'identity tags ":")))))))
+        (full-text-no-tag
+         (org-texinfo--sanitize-content
+          (if (functionp org-texinfo-format-headline-function)
+              ;; User-defined formatting function.
+              (funcall org-texinfo-format-headline-function
+                       todo todo-type priority text nil)
+            ;; Default formatting.
+            (concat
+             (when todo (format "@strong{%s} " todo))
+             (when priority (format "@emph{#%c} " priority))
+             text))))
+        (pre-blanks
+         (make-string (org-element-property :pre-blank headline) 10)))
+    (cond
+     ;; Case 1: This is a footnote section: ignore it.
+     ((org-element-property :footnote-section-p headline) nil)
+     ;; Case 2: This is the `copying' section: ignore it
+     ;;         This is used elsewhere.
+     ((org-element-property :COPYING headline) nil)
+     ;; Case 3: An index.  If it matches one of the known indexes,
+     ;;         print it as such following the contents, otherwise
+     ;;         print the contents and leave the index up to the user.
+     (index
+      (format
+       section-fmt full-text
+       (concat pre-blanks contents "\n"
+              (if (member index '("cp" "fn" "ky" "pg" "tp" "vr"))
+                  (concat "@printindex " index)))))
+     ;; Case 4: This is a deep sub-tree: export it as a list item.
+     ;;         Also export as items headlines for which no section
+     ;;         format has been found.
+     ((or (not section-fmt) (org-export-low-level-p headline info))
+      ;; Build the real contents of the sub-tree.
+      (let ((low-level-body
+            (concat
+             ;; If the headline is the first sibling, start a list.
+             (when (org-export-first-sibling-p headline info)
+               (format "@%s\n" (if numberedp 'enumerate 'itemize)))
+             ;; Itemize headline
+             "@item\n" full-text "\n" pre-blanks contents)))
+       ;; If headline is not the last sibling simply return
+       ;; LOW-LEVEL-BODY.  Otherwise, also close the list, before any
+       ;; blank line.
+       (if (not (org-export-last-sibling-p headline info)) low-level-body
+         (replace-regexp-in-string
+          "[ \t\n]*\\'"
+          (format "\n@end %s" (if numberedp 'enumerate 'itemize))
+          low-level-body))))
+     ;; Case 5: Standard headline.  Export it as a section.
+     (t
+      (cond
+       ((not (and tags (eq (plist-get info :with-tags) 'not-in-toc)))
+       ;; Regular section.  Use specified format string.
+       (format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text
+               (concat pre-blanks contents)))
+       ((string-match "\\`@\\(.*?\\){" section-fmt)
+       ;; If tags should be removed from table of contents, insert
+       ;; title without tags as an alternative heading in sectioning
+       ;; command.
+       (format (replace-match (concat (match-string 1 section-fmt) "[%s]")
+                              nil nil section-fmt 1)
+               ;; Replace square brackets with parenthesis since
+               ;; square brackets are not supported in optional
+               ;; arguments.
+               (replace-regexp-in-string
+                "\\[" "("
+                (replace-regexp-in-string
+                 "\\]" ")"
+                 full-text-no-tag))
+               full-text
+               (concat pre-blanks contents)))
+       (t
+       ;; Impossible to add an alternative heading.  Fallback to
+       ;; regular sectioning format string.
+       (format (replace-regexp-in-string "%]" "%%]" section-fmt) full-text
+               (concat pre-blanks contents))))))))
+
+;;; Inline Src Block
+
+(defun org-texinfo-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((code (org-element-property :value inline-src-block))
+        (separator (org-texinfo--find-verb-separator code)))
+    (concat "@verb{" separator code separator "}")))
+
+;;; Inlinetask
+
+(defun org-texinfo-inlinetask (inlinetask contents info)
+  "Transcode an INLINETASK element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let ((title (org-export-data (org-element-property :title inlinetask) info))
+       (todo (and (plist-get info :with-todo-keywords)
+                  (let ((todo (org-element-property :todo-keyword inlinetask)))
+                    (and todo (org-export-data todo info)))))
+       (todo-type (org-element-property :todo-type inlinetask))
+       (tags (and (plist-get info :with-tags)
+                  (org-export-get-tags inlinetask info)))
+       (priority (and (plist-get info :with-priority)
+                      (org-element-property :priority inlinetask))))
+    ;; If `org-texinfo-format-inlinetask-function' is provided, call it
+    ;; with appropriate arguments.
+    (if (functionp org-texinfo-format-inlinetask-function)
+       (funcall org-texinfo-format-inlinetask-function
+                todo todo-type priority title tags contents)
+      ;; Otherwise, use a default template.
+      (let ((full-title
+            (concat
+             (when todo (format "@strong{%s} " todo))
+             (when priority (format "#%c " priority))
+             title
+             (when tags (format ":%s:"
+                                (mapconcat 'identity tags ":"))))))
+       (format (concat "@center %s\n\n"
+                       "%s"
+                       "\n")
+               full-title contents)))))
+
+;;; Italic
+
+(defun org-texinfo-italic (italic contents info)
+  "Transcode ITALIC from Org to Texinfo.
+CONTENTS is the text with italic markup.  INFO is a plist holding
+contextual information."
+  (org-texinfo--text-markup contents 'italic))
+
+;;; Item
+
+(defun org-texinfo-item (item contents info)
+  "Transcode an ITEM element from Org to Texinfo.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((tag (org-element-property :tag item))
+        (desc (org-export-data tag info)))
+    (concat "\n@item " (if tag desc) "\n"
+           (and contents (org-trim contents)) "\n")))
+
+;;; Keyword
+
+(defun org-texinfo-keyword (keyword contents info)
+  "Transcode a KEYWORD element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((key (org-element-property :key keyword))
+       (value (org-element-property :value keyword)))
+    (cond
+     ((string= key "TEXINFO") value)
+     ((string= key "CINDEX") (format "@cindex %s" value))
+     ((string= key "FINDEX") (format "@findex %s" value))
+     ((string= key "KINDEX") (format "@kindex %s" value))
+     ((string= key "PINDEX") (format "@pindex %s" value))
+     ((string= key "TINDEX") (format "@tindex %s" value))
+     ((string= key "VINDEX") (format "@vindex %s" value)))))
+
+;;; Line Break
+
+(defun org-texinfo-line-break (line-break contents info)
+  "Transcode a LINE-BREAK object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  "@*\n")
+
+;;; Link
+
+(defun org-texinfo-link (link desc info)
+  "Transcode a LINK object from Org to Texinfo.
+
+DESC is the description part of the link, or the empty string.
+INFO is a plist holding contextual information.  See
+`org-export-data'."
+  (let* ((type (org-element-property :type link))
+        (raw-path (org-element-property :path link))
+        ;; Ensure DESC really exists, or set it to nil.
+        (desc (and (not (string= desc "")) desc))
+        (path (cond
+               ((member type '("http" "https" "ftp"))
+                (concat type ":" raw-path))
+               ((string= type "file")
+                (if (file-name-absolute-p raw-path)
+                    (concat "file://" (expand-file-name raw-path))
+                  (concat "file://" raw-path)))
+               (t raw-path)))
+        (email (if (string= type "mailto")
+                   (let ((text (replace-regexp-in-string
+                                "@" "@@" raw-path)))
+                     (concat text (if desc (concat "," desc))))))
+        protocol)
+    (cond
+     ;; Links pointing to a headline: Find destination and build
+     ;; appropriate referencing command.
+     ((member type '("custom-id" "id"))
+      (let ((destination (org-export-resolve-id-link link info)))
+       (case (org-element-type destination)
+         ;; Id link points to an external file.
+         (plain-text
+          (if desc (format "@uref{file://%s,%s}" destination desc)
+            (format "@uref{file://%s}" destination)))
+         ;; LINK points to a headline.  Use the headline as the NODE target
+         (headline
+          (format "@ref{%s,%s}"
+                  (org-texinfo--get-node destination info)
+                  (or desc "")))
+         (otherwise
+          (let ((path (org-export-solidify-link-text path)))
+            (if (not desc) (format "@ref{%s}" path)
+              (format "@ref{%s,,%s}" path desc)))))))
+     ((member type '("info"))
+      (let* ((info-path (split-string path "[:#]"))
+            (info-manual (car info-path))
+            (info-node (or (cadr info-path) "top"))
+            (title (or desc "")))
+       (format "@ref{%s,%s,,%s,}" info-node title info-manual)))
+     ((member type '("fuzzy"))
+      (let ((destination (org-export-resolve-fuzzy-link link info)))
+       (case (org-element-type destination)
+         ;; Id link points to an external file.
+         (plain-text
+          (if desc (format "@uref{file://%s,%s}" destination desc)
+            (format "@uref{file://%s}" destination)))
+         ;; LINK points to a headline.  Use the headline as the NODE target
+         (headline
+          (format "@ref{%s,%s}"
+                  (org-texinfo--get-node destination info)
+                  (or desc "")))
+         (otherwise
+          (let ((path (org-export-solidify-link-text path)))
+            (if (not desc) (format "@ref{%s}" path)
+              (format "@ref{%s,,%s}" path desc)))))))
+     ;; Special case for email addresses
+     (email
+      (format "@email{%s}" email))
+     ;; External link with a description part.
+     ((and path desc) (format "@uref{%s,%s}" path desc))
+     ;; External link without a description part.
+     (path (format "@uref{%s}" path))
+     ;; No path, only description.  Try to do something useful.
+     (t (format org-texinfo-link-with-unknown-path-format desc)))))
+
+
+;;; Menu
+
+(defun org-texinfo-make-menu (info level)
+  "Create the menu for inclusion in the texifo document.
+
+INFO is the parsed buffer that contains the headlines.  LEVEL
+determines whether to make the main menu, or the detailed menu.
+
+This is only used for generating the primary menu.  In-Node menus
+are generated directly."
+  (let ((parse (plist-get info :parse-tree)))
+    (cond
+     ;; Generate the main menu
+     ((eq level 'main) (org-texinfo--build-menu parse 1 info))
+     ;; Generate the detailed (recursive) menu
+     ((eq level 'detailed)
+      ;; Requires recursion
+      ;;(org-texinfo--build-detailed-menu parse top info)
+      (org-texinfo--build-menu parse 1 info 'detailed)))))
+
+;;; Paragraph
+
+(defun org-texinfo-paragraph (paragraph contents info)
+  "Transcode a PARAGRAPH element from Org to Texinfo.
+CONTENTS is the contents of the paragraph, as a string.  INFO is
+the plist used as a communication channel."
+  contents)
+
+;;; Plain List
+
+(defun org-texinfo-plain-list (plain-list contents info)
+  "Transcode a PLAIN-LIST element from Org to Texinfo.
+CONTENTS is the contents of the list.  INFO is a plist holding
+contextual information."
+  (let* ((attr (org-export-read-attribute :attr_texinfo plain-list))
+        (indic (or (plist-get attr :indic)
+                   org-texinfo-def-table-markup))
+        (type (org-element-property :type plain-list))
+        (table-type (plist-get attr :table-type))
+        ;; Ensure valid texinfo table type.
+        (table-type (if (member table-type '("ftable" "vtable")) table-type
+                      "table"))
+        (list-type (cond
+                    ((eq type 'ordered) "enumerate")
+                    ((eq type 'unordered) "itemize")
+                    ((eq type 'descriptive) table-type))))
+    (format "@%s%s\n@end %s"
+           (if (eq type 'descriptive)
+               (concat list-type " " indic)
+             list-type)
+           contents
+           list-type)))
+
+;;; Plain Text
+
+(defun org-texinfo-plain-text (text info)
+  "Transcode a TEXT string from Org to Texinfo.
+TEXT is the string to transcode.  INFO is a plist holding
+contextual information."
+  ;; First protect @, { and }.
+  (let ((output (org-texinfo--sanitize-content text)))
+    ;; Activate smart quotes.  Be sure to provide original TEXT string
+    ;; since OUTPUT may have been modified.
+    (when (plist-get info :with-smart-quotes)
+      (setq output
+           (org-export-activate-smart-quotes output :texinfo info text)))
+    ;; LaTeX into @LaTeX{} and TeX into @TeX{}
+    (let ((case-fold-search nil)
+         (start 0))
+      (while (string-match "\\(\\(?:La\\)?TeX\\)" output start)
+       (setq output (replace-match
+                     (format "@%s{}" (match-string 1 output)) nil t output)
+             start (match-end 0))))
+    ;; Convert special strings.
+    (when (plist-get info :with-special-strings)
+      (while (string-match (regexp-quote "...") output)
+       (setq output (replace-match "@dots{}" nil t output))))
+    ;; Handle break preservation if required.
+    (when (plist-get info :preserve-breaks)
+      (setq output (replace-regexp-in-string
+                   "\\(\\\\\\\\\\)?[ \t]*\n" " @*\n" output)))
+    ;; Return value.
+    output))
+
+;;; Planning
+
+(defun org-texinfo-planning (planning contents info)
+  "Transcode a PLANNING element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (concat
+   "@noindent"
+   (mapconcat
+    'identity
+    (delq nil
+         (list
+          (let ((closed (org-element-property :closed planning)))
+            (when closed
+              (concat
+               (format "@strong{%s} " org-closed-string)
+               (format org-texinfo-inactive-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value closed))))))
+          (let ((deadline (org-element-property :deadline planning)))
+            (when deadline
+              (concat
+               (format "@strong{%s} " org-deadline-string)
+               (format org-texinfo-active-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value deadline))))))
+          (let ((scheduled (org-element-property :scheduled planning)))
+            (when scheduled
+              (concat
+               (format "@strong{%s} " org-scheduled-string)
+               (format org-texinfo-active-timestamp-format
+                       (org-translate-time
+                        (org-element-property :raw-value scheduled))))))))
+    " ")
+   "@*"))
+
+;;; Property Drawer
+
+(defun org-texinfo-property-drawer (property-drawer contents info)
+  "Transcode a PROPERTY-DRAWER element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  ;; The property drawer isn't exported but we want separating blank
+  ;; lines nonetheless.
+  "")
+
+;;; Quote Block
+
+(defun org-texinfo-quote-block (quote-block contents info)
+  "Transcode a QUOTE-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist
+holding contextual information."
+  (let* ((title (org-element-property :name quote-block))
+        (start-quote (concat "@quotation"
+                             (if title
+                                 (format " %s" title)))))
+    (format "%s\n%s@end quotation" start-quote contents)))
+
+;;; Quote Section
+
+(defun org-texinfo-quote-section (quote-section contents info)
+  "Transcode a QUOTE-SECTION element from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (let ((value (org-remove-indentation
+               (org-element-property :value quote-section))))
+    (when value (format "@verbatim\n%s@end verbatim" value))))
+
+;;; Radio Target
+
+(defun org-texinfo-radio-target (radio-target text info)
+  "Transcode a RADIO-TARGET object from Org to Texinfo.
+TEXT is the text of the target.  INFO is a plist holding
+contextual information."
+  (format "@anchor{%s}%s"
+         (org-export-solidify-link-text
+          (org-element-property :value radio-target))
+         text))
+
+;;; Section
+
+(defun org-texinfo-section (section contents info)
+  "Transcode a SECTION element from Org to Texinfo.
+CONTENTS holds the contents of the section.  INFO is a plist
+holding contextual information."
+  contents)
+
+;;; Special Block
+
+(defun org-texinfo-special-block (special-block contents info)
+  "Transcode a SPECIAL-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the block.  INFO is a plist used
+as a communication channel."
+  contents)
+
+;;; Src Block
+
+(defun org-texinfo-src-block (src-block contents info)
+  "Transcode a SRC-BLOCK element from Org to Texinfo.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((lang (org-element-property :language src-block))
+        (lisp-p (string-match-p "lisp" lang))
+        (src-contents (org-texinfo--sanitize-content
+                  (org-export-format-code-default src-block info))))
+    (cond
+     ;; Case 1.  Lisp Block
+     (lisp-p
+      (format "@lisp\n%s@end lisp"
+             src-contents))
+     ;; Case 2.  Other blocks
+     (t
+      (format "@example\n%s@end example"
+             src-contents)))))
+
+;;; Statistics Cookie
+
+(defun org-texinfo-statistics-cookie (statistics-cookie contents info)
+  "Transcode a STATISTICS-COOKIE object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual information."
+  (org-element-property :value statistics-cookie))
+
+;;; Subscript
+
+(defun org-texinfo-subscript (subscript contents info)
+  "Transcode a SUBSCRIPT object from Org to Texinfo.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "@math{_%s}" contents))
+
+;;; Superscript
+
+(defun org-texinfo-superscript (superscript contents info)
+  "Transcode a SUPERSCRIPT object from Org to Texinfo.
+CONTENTS is the contents of the object.  INFO is a plist holding
+contextual information."
+  (format "@math{^%s}" contents))
+
+;;; Table
+;;
+;; `org-texinfo-table' is the entry point for table transcoding.  It
+;; takes care of tables with a "verbatim" attribute.  Otherwise, it
+;; delegates the job to either `org-texinfo-table--table.el-table' or
+;; `org-texinfo-table--org-table' functions, depending of the type of
+;; the table.
+;;
+;; `org-texinfo-table--align-string' is a subroutine used to build
+;; alignment string for Org tables.
+
+(defun org-texinfo-table (table contents info)
+  "Transcode a TABLE element from Org to Texinfo.
+CONTENTS is the contents of the table.  INFO is a plist holding
+contextual information."
+  (cond
+   ;; Case 1: verbatim table.
+   ((or org-texinfo-tables-verbatim
+       (let ((attr (mapconcat 'identity
+                              (org-element-property :attr_latex table)
+                              " ")))
+         (and attr (string-match "\\<verbatim\\>" attr))))
+    (format "@verbatim \n%s\n@end verbatim"
+           ;; Re-create table, without affiliated keywords.
+           (org-trim
+            (org-element-interpret-data
+             `(table nil ,@(org-element-contents table))))))
+   ;; Case 2: table.el table.  Convert it using appropriate tools.
+   ((eq (org-element-property :type table) 'table.el)
+    (org-texinfo-table--table.el-table table contents info))
+   ;; Case 3: Standard table.
+   (t (org-texinfo-table--org-table table contents info))))
+
+(defun org-texinfo-table-column-widths (table info)
+  "Determine the largest table cell in each column to process alignment.
+
+TABLE is the table element to transcode.  INFO is a plist used as
+a communication channel."
+  (let* ((rows (org-element-map table 'table-row 'identity info))
+        (collected (loop for row in rows collect
+                         (org-element-map row 'table-cell 'identity info)))
+        (number-cells (length (car collected)))
+        cells counts)
+    (loop for row in collected do
+         (push (mapcar (lambda (ref)
+                         (let* ((start (org-element-property :contents-begin ref))
+                                (end (org-element-property :contents-end ref))
+                                (length (- end start)))
+                           length)) row) cells))
+    (setq cells (org-remove-if 'null cells))
+    (push (loop for count from 0 to (- number-cells 1) collect
+               (loop for item in cells collect
+                     (nth count item))) counts)
+    (mapconcat (lambda (size)
+                (make-string size ?a)) (mapcar (lambda (ref)
+                                                 (apply 'max `(,@ref))) (car counts))
+                "} {")))
+
+(defun org-texinfo-table--org-table (table contents info)
+  "Return appropriate Texinfo code for an Org table.
+
+TABLE is the table type element to transcode.  CONTENTS is its
+contents, as a string.  INFO is a plist used as a communication
+channel.
+
+This function assumes TABLE has `org' as its `:type' attribute."
+  (let* ((attr (org-export-read-attribute :attr_texinfo table))
+        (col-width (plist-get attr :columns))
+        (columns (if col-width
+                     (format "@columnfractions %s"
+                             col-width)
+                   (format "{%s}"
+                           (org-texinfo-table-column-widths
+                            table info)))))
+    ;; Prepare the final format string for the table.
+    (cond
+     ;; Longtable.
+     ;; Others.
+     (t (concat
+        (format "@multitable %s\n%s@end multitable"
+                columns
+                contents))))))
+
+(defun org-texinfo-table--table.el-table (table contents info)
+  "Returns nothing.
+
+Rather than return an invalid table, nothing is returned."
+  'nil)
+
+;;; Table Cell
+
+(defun org-texinfo-table-cell (table-cell contents info)
+  "Transcode a TABLE-CELL element from Org to Texinfo.
+CONTENTS is the cell contents.  INFO is a plist used as
+a communication channel."
+  (concat (if (and contents
+                  org-texinfo-table-scientific-notation
+                  (string-match orgtbl-exp-regexp contents))
+             ;; Use appropriate format string for scientific
+             ;; notation.
+             (format org-texinfo-table-scientific-notation
+                     (match-string 1 contents)
+                     (match-string 2 contents))
+           contents)
+         (when (org-export-get-next-element table-cell info) "\n@tab ")))
+
+;;; Table Row
+
+(defun org-texinfo-table-row (table-row contents info)
+  "Transcode a TABLE-ROW element from Org to Texinfo.
+CONTENTS is the contents of the row.  INFO is a plist used as
+a communication channel."
+  ;; Rules are ignored since table separators are deduced from
+  ;; borders of the current row.
+  (when (eq (org-element-property :type table-row) 'standard)
+   (let ((rowgroup-tag
+         (cond
+          ;; Case 1: Belongs to second or subsequent rowgroup.
+          ((not (= 1 (org-export-table-row-group table-row info)))
+           "@item ")
+          ;; Case 2: Row is from first rowgroup.  Table has >=1 rowgroups.
+          ((org-export-table-has-header-p
+            (org-export-get-parent-table table-row) info)
+           "@headitem ")
+          ;; Case 3: Row is from first and only row group.
+          (t "@item "))))
+     (when (eq (org-element-property :type table-row) 'standard)
+       (concat rowgroup-tag contents "\n")))))
+
+;;; Target
+
+(defun org-texinfo-target (target contents info)
+  "Transcode a TARGET object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (format "@anchor{%s}"
+         (org-export-solidify-link-text (org-element-property :value target))))
+
+;;; Timestamp
+
+(defun org-texinfo-timestamp (timestamp contents info)
+  "Transcode a TIMESTAMP object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist holding contextual
+information."
+  (let ((value (org-texinfo-plain-text
+               (org-timestamp-translate timestamp) info)))
+    (case (org-element-property :type timestamp)
+      ((active active-range)
+       (format org-texinfo-active-timestamp-format value))
+      ((inactive inactive-range)
+       (format org-texinfo-inactive-timestamp-format value))
+      (t (format org-texinfo-diary-timestamp-format value)))))
+
+;;; Verbatim
+
+(defun org-texinfo-verbatim (verbatim contents info)
+  "Transcode a VERBATIM object from Org to Texinfo.
+CONTENTS is nil.  INFO is a plist used as a communication
+channel."
+  (org-texinfo--text-markup (org-element-property :value verbatim) 'verbatim))
+
+;;; Verse Block
+
+(defun org-texinfo-verse-block (verse-block contents info)
+  "Transcode a VERSE-BLOCK element from Org to Texinfo.
+CONTENTS is verse block contents. INFO is a plist holding
+contextual information."
+  ;; In a verse environment, add a line break to each newline
+  ;; character and change each white space at beginning of a line
+  ;; into a space of 1 em.  Also change each blank line with
+  ;; a vertical space of 1 em.
+  (progn
+    (setq contents (replace-regexp-in-string
+                   "^ *\\\\\\\\$" "\\\\vspace*{1em}"
+                   (replace-regexp-in-string
+                    "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n" contents)))
+    (while (string-match "^[ \t]+" contents)
+      (let ((new-str (format "\\hspace*{%dem}"
+                            (length (match-string 0 contents)))))
+       (setq contents (replace-match new-str nil t contents))))
+    (format "\\begin{verse}\n%s\\end{verse}" contents)))
+
+\f
+;;; Interactive functions
+
+(defun org-texinfo-export-to-texinfo
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to a Texinfo file.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+Return output file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".texi" subtreep))
+       (org-export-coding-system `,org-texinfo-coding-system))
+    (org-export-to-file 'texinfo outfile
+      async subtreep visible-only body-only ext-plist)))
+
+(defun org-texinfo-export-to-info
+  (&optional async subtreep visible-only body-only ext-plist)
+  "Export current buffer to Texinfo then process through to INFO.
+
+If narrowing is active in the current buffer, only export its
+narrowed part.
+
+If a region is active, export that region.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting file should be accessible through
+the `org-export-stack' interface.
+
+When optional argument SUBTREEP is non-nil, export the sub-tree
+at point, extracting information from the headline properties
+first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only write code
+between \"\\begin{document}\" and \"\\end{document}\".
+
+EXT-PLIST, when provided, is a property list with external
+parameters overriding Org default settings, but still inferior to
+file-local settings.
+
+When optional argument PUB-DIR is set, use it as the publishing
+directory.
+
+Return INFO file's name."
+  (interactive)
+  (let ((outfile (org-export-output-file-name ".texi" subtreep))
+       (org-export-coding-system `,org-texinfo-coding-system))
+    (org-export-to-file 'texinfo outfile
+      async subtreep visible-only body-only ext-plist
+      (lambda (file) (org-texinfo-compile file)))))
+
+;;;###autoload
+(defun org-texinfo-publish-to-texinfo (plist filename pub-dir)
+  "Publish an org file to Texinfo.
+
+FILENAME is the filename of the Org file to be published.  PLIST
+is the property list for the given project.  PUB-DIR is the
+publishing directory.
+
+Return output file name."
+  (org-publish-org-to 'texinfo filename ".texi" plist pub-dir))
+
+;;;###autoload
+(defun org-texinfo-convert-region-to-texinfo ()
+  "Assume the current region has org-mode syntax, and convert it to Texinfo.
+This can be used in any buffer.  For example, you can write an
+itemized list in org-mode syntax in an Texinfo buffer and use
+this command to convert it."
+  (interactive)
+  (org-export-replace-region-by 'texinfo))
+
+(defun org-texinfo-compile (file)
+  "Compile a texinfo file.
+
+FILE is the name of the file being compiled.  Processing is
+done through the command specified in `org-texinfo-info-process'.
+
+Return INFO file name or an error if it couldn't be produced."
+  (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
+        (full-name (file-truename file))
+        (out-dir (file-name-directory file))
+        ;; Properly set working directory for compilation.
+        (default-directory (if (file-name-absolute-p file)
+                               (file-name-directory full-name)
+                             default-directory))
+        errors)
+    (message (format "Processing Texinfo file %s..." file))
+    (save-window-excursion
+      (cond
+       ;; A function is provided: Apply it.
+       ((functionp org-texinfo-info-process)
+       (funcall org-texinfo-info-process (shell-quote-argument file)))
+       ;; A list is provided: Replace %b, %f and %o with appropriate
+       ;; values in each command before applying it.  Output is
+       ;; redirected to "*Org INFO Texinfo Output*" buffer.
+       ((consp org-texinfo-info-process)
+       (let ((outbuf (get-buffer-create "*Org INFO Texinfo Output*")))
+         (mapc
+          (lambda (command)
+            (shell-command
+             (replace-regexp-in-string
+              "%b" (shell-quote-argument base-name)
+              (replace-regexp-in-string
+               "%f" (shell-quote-argument full-name)
+               (replace-regexp-in-string
+                "%o" (shell-quote-argument out-dir) command t t) t t) t t)
+             outbuf))
+          org-texinfo-info-process)
+         ;; Collect standard errors from output buffer.
+         (setq errors (org-texinfo-collect-errors outbuf))))
+       (t (error "No valid command to process to Info")))
+      (let ((infofile (concat out-dir base-name ".info")))
+       ;; Check for process failure.  Provide collected errors if
+       ;; possible.
+       (if (not (file-exists-p infofile))
+           (error (concat (format "INFO file %s wasn't produced" infofile)
+                          (when errors (concat ": " errors))))
+         ;; Else remove log files, when specified, and signal end of
+         ;; process to user, along with any error encountered.
+         (when org-texinfo-remove-logfiles
+           (dolist (ext org-texinfo-logfiles-extensions)
+             (let ((file (concat out-dir base-name "." ext)))
+               (when (file-exists-p file) (delete-file file)))))
+         (message (concat "Process completed"
+                          (if (not errors) "."
+                            (concat " with errors: " errors)))))
+       ;; Return output file name.
+       infofile))))
+
+(defun org-texinfo-collect-errors (buffer)
+  "Collect some kind of errors from \"makeinfo\" command output.
+
+BUFFER is the buffer containing output.
+
+Return collected error types as a string, or nil if there was
+none."
+  (with-current-buffer buffer
+    (save-excursion
+      (goto-char (point-min))
+      ;; Find final "makeinfo" run.
+      (when t
+       (let ((case-fold-search t)
+             (errors ""))
+         (when (save-excursion
+                 (re-search-forward "perhaps incorrect sectioning?" nil t))
+           (setq errors (concat errors " [incorrect sectioning]")))
+         (when (save-excursion
+                 (re-search-forward "missing close brace" nil t))
+           (setq errors (concat errors " [syntax error]")))
+         (when (save-excursion
+                 (re-search-forward "Unknown command" nil t))
+           (setq errors (concat errors " [undefined @command]")))
+         (when (save-excursion
+                 (re-search-forward "No matching @end" nil t))
+           (setq errors (concat errors " [block incomplete]")))
+         (when (save-excursion
+                 (re-search-forward "requires a sectioning" nil t))
+           (setq errors (concat errors " [invalid section command]")))
+         (when (save-excursion
+                 (re-search-forward "\\[unexpected\]" nil t))
+           (setq errors (concat errors " [unexpected error]")))
+         (when (save-excursion
+                 (re-search-forward "misplaced " nil t))
+           (setq errors (concat errors " [syntax error]")))
+         (and (org-string-nw-p errors) (org-trim errors)))))))
+
+
+(provide 'ox-texinfo)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox-texinfo.el ends here
diff --git a/lisp/org/ox.el b/lisp/org/ox.el
new file mode 100644 (file)
index 0000000..6b88f1a
--- /dev/null
@@ -0,0 +1,6210 @@
+;;; ox.el --- Generic Export Engine for Org Mode
+
+;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
+
+;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
+;; Keywords: outlines, hypermedia, calendar, wp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This library implements a generic export engine for Org, built on
+;; its syntactical parser: Org Elements.
+;;
+;; Besides that parser, the generic exporter is made of three distinct
+;; parts:
+;;
+;; - The communication channel consists in a property list, which is
+;;   created and updated during the process.  Its use is to offer
+;;   every piece of information, would it be about initial environment
+;;   or contextual data, all in a single place.  The exhaustive list
+;;   of properties is given in "The Communication Channel" section of
+;;   this file.
+;;
+;; - The transcoder walks the parse tree, ignores or treat as plain
+;;   text elements and objects according to export options, and
+;;   eventually calls back-end specific functions to do the real
+;;   transcoding, concatenating their return value along the way.
+;;
+;; - The filter system is activated at the very beginning and the very
+;;   end of the export process, and each time an element or an object
+;;   has been converted.  It is the entry point to fine-tune standard
+;;   output from back-end transcoders.  See "The Filter System"
+;;   section for more information.
+;;
+;; The core function is `org-export-as'.  It returns the transcoded
+;; buffer as a string.
+;;
+;; An export back-end is defined with `org-export-define-backend'.
+;; This function can also support specific buffer keywords, OPTION
+;; keyword's items and filters.  Refer to function's documentation for
+;; more information.
+;;
+;; If the new back-end shares most properties with another one,
+;; `org-export-define-derived-backend' can be used to simplify the
+;; process.
+;;
+;; Any back-end can define its own variables.  Among them, those
+;; customizable should belong to the `org-export-BACKEND' group.
+;;
+;; Tools for common tasks across back-ends are implemented in the
+;; following part of the file.
+;;
+;; Then, a wrapper macro for asynchronous export,
+;; `org-export-async-start', along with tools to display results. are
+;; given in the penultimate part.
+;;
+;; Eventually, a dispatcher (`org-export-dispatch') for standard
+;; back-ends is provided in the last one.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+(require 'org-element)
+(require 'org-macro)
+(require 'ob-exp)
+
+(declare-function org-publish "ox-publish" (project &optional force async))
+(declare-function org-publish-all "ox-publish" (&optional force async))
+(declare-function
+ org-publish-current-file "ox-publish" (&optional force async))
+(declare-function org-publish-current-project "ox-publish"
+                 (&optional force async))
+
+(defvar org-publish-project-alist)
+(defvar org-table-number-fraction)
+(defvar org-table-number-regexp)
+
+
+\f
+;;; Internal Variables
+;;
+;; Among internal variables, the most important is
+;; `org-export-options-alist'.  This variable define the global export
+;; options, shared between every exporter, and how they are acquired.
+
+(defconst org-export-max-depth 19
+  "Maximum nesting depth for headlines, counting from 0.")
+
+(defconst org-export-options-alist
+  '((:author "AUTHOR" nil user-full-name t)
+    (:creator "CREATOR" nil org-export-creator-string)
+    (:date "DATE" nil nil t)
+    (:description "DESCRIPTION" nil nil newline)
+    (:email "EMAIL" nil user-mail-address t)
+    (:exclude-tags "EXCLUDE_TAGS" nil org-export-exclude-tags split)
+    (:headline-levels nil "H" org-export-headline-levels)
+    (:keywords "KEYWORDS" nil nil space)
+    (:language "LANGUAGE" nil org-export-default-language t)
+    (:preserve-breaks nil "\\n" org-export-preserve-breaks)
+    (:section-numbers nil "num" org-export-with-section-numbers)
+    (:select-tags "SELECT_TAGS" nil org-export-select-tags split)
+    (:time-stamp-file nil "timestamp" org-export-time-stamp-file)
+    (:title "TITLE" nil nil space)
+    (:with-archived-trees nil "arch" org-export-with-archived-trees)
+    (:with-author nil "author" org-export-with-author)
+    (:with-clocks nil "c" org-export-with-clocks)
+    (:with-creator nil "creator" org-export-with-creator)
+    (:with-date nil "date" org-export-with-date)
+    (:with-drawers nil "d" org-export-with-drawers)
+    (:with-email nil "email" org-export-with-email)
+    (:with-emphasize nil "*" org-export-with-emphasize)
+    (:with-entities nil "e" org-export-with-entities)
+    (:with-fixed-width nil ":" org-export-with-fixed-width)
+    (:with-footnotes nil "f" org-export-with-footnotes)
+    (:with-inlinetasks nil "inline" org-export-with-inlinetasks)
+    (:with-latex nil "tex" org-export-with-latex)
+    (:with-planning nil "p" org-export-with-planning)
+    (:with-priority nil "pri" org-export-with-priority)
+    (:with-smart-quotes nil "'" org-export-with-smart-quotes)
+    (:with-special-strings nil "-" org-export-with-special-strings)
+    (:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
+    (:with-sub-superscript nil "^" org-export-with-sub-superscripts)
+    (:with-toc nil "toc" org-export-with-toc)
+    (:with-tables nil "|" org-export-with-tables)
+    (:with-tags nil "tags" org-export-with-tags)
+    (:with-tasks nil "tasks" org-export-with-tasks)
+    (:with-timestamps nil "<" org-export-with-timestamps)
+    (:with-todo-keywords nil "todo" org-export-with-todo-keywords))
+  "Alist between export properties and ways to set them.
+
+The CAR of the alist is the property name, and the CDR is a list
+like (KEYWORD OPTION DEFAULT BEHAVIOUR) where:
+
+KEYWORD is a string representing a buffer keyword, or nil.  Each
+  property defined this way can also be set, during subtree
+  export, through a headline property named after the keyword
+  with the \"EXPORT_\" prefix (i.e. DATE keyword and EXPORT_DATE
+  property).
+OPTION is a string that could be found in an #+OPTIONS: line.
+DEFAULT is the default value for the property.
+BEHAVIOUR determines how Org should handle multiple keywords for
+  the same property.  It is a symbol among:
+  nil       Keep old value and discard the new one.
+  t         Replace old value with the new one.
+  `space'   Concatenate the values, separating them with a space.
+  `newline' Concatenate the values, separating them with
+           a newline.
+  `split'   Split values at white spaces, and cons them to the
+           previous list.
+
+Values set through KEYWORD and OPTION have precedence over
+DEFAULT.
+
+All these properties should be back-end agnostic.  Back-end
+specific properties are set through `org-export-define-backend'.
+Properties redefined there have precedence over these.")
+
+(defconst org-export-special-keywords '("FILETAGS" "SETUPFILE" "OPTIONS")
+  "List of in-buffer keywords that require special treatment.
+These keywords are not directly associated to a property.  The
+way they are handled must be hard-coded into
+`org-export--get-inbuffer-options' function.")
+
+(defconst org-export-filters-alist
+  '((:filter-bold . org-export-filter-bold-functions)
+    (:filter-babel-call . org-export-filter-babel-call-functions)
+    (:filter-center-block . org-export-filter-center-block-functions)
+    (:filter-clock . org-export-filter-clock-functions)
+    (:filter-code . org-export-filter-code-functions)
+    (:filter-comment . org-export-filter-comment-functions)
+    (:filter-comment-block . org-export-filter-comment-block-functions)
+    (:filter-diary-sexp . org-export-filter-diary-sexp-functions)
+    (:filter-drawer . org-export-filter-drawer-functions)
+    (:filter-dynamic-block . org-export-filter-dynamic-block-functions)
+    (:filter-entity . org-export-filter-entity-functions)
+    (:filter-example-block . org-export-filter-example-block-functions)
+    (:filter-export-block . org-export-filter-export-block-functions)
+    (:filter-export-snippet . org-export-filter-export-snippet-functions)
+    (:filter-final-output . org-export-filter-final-output-functions)
+    (:filter-fixed-width . org-export-filter-fixed-width-functions)
+    (:filter-footnote-definition . org-export-filter-footnote-definition-functions)
+    (:filter-footnote-reference . org-export-filter-footnote-reference-functions)
+    (:filter-headline . org-export-filter-headline-functions)
+    (:filter-horizontal-rule . org-export-filter-horizontal-rule-functions)
+    (:filter-inline-babel-call . org-export-filter-inline-babel-call-functions)
+    (:filter-inline-src-block . org-export-filter-inline-src-block-functions)
+    (:filter-inlinetask . org-export-filter-inlinetask-functions)
+    (:filter-italic . org-export-filter-italic-functions)
+    (:filter-item . org-export-filter-item-functions)
+    (:filter-keyword . org-export-filter-keyword-functions)
+    (:filter-latex-environment . org-export-filter-latex-environment-functions)
+    (:filter-latex-fragment . org-export-filter-latex-fragment-functions)
+    (:filter-line-break . org-export-filter-line-break-functions)
+    (:filter-link . org-export-filter-link-functions)
+    (:filter-node-property . org-export-filter-node-property-functions)
+    (:filter-options . org-export-filter-options-functions)
+    (:filter-paragraph . org-export-filter-paragraph-functions)
+    (:filter-parse-tree . org-export-filter-parse-tree-functions)
+    (:filter-plain-list . org-export-filter-plain-list-functions)
+    (:filter-plain-text . org-export-filter-plain-text-functions)
+    (:filter-planning . org-export-filter-planning-functions)
+    (:filter-property-drawer . org-export-filter-property-drawer-functions)
+    (:filter-quote-block . org-export-filter-quote-block-functions)
+    (:filter-quote-section . org-export-filter-quote-section-functions)
+    (:filter-radio-target . org-export-filter-radio-target-functions)
+    (:filter-section . org-export-filter-section-functions)
+    (:filter-special-block . org-export-filter-special-block-functions)
+    (:filter-src-block . org-export-filter-src-block-functions)
+    (:filter-statistics-cookie . org-export-filter-statistics-cookie-functions)
+    (:filter-strike-through . org-export-filter-strike-through-functions)
+    (:filter-subscript . org-export-filter-subscript-functions)
+    (:filter-superscript . org-export-filter-superscript-functions)
+    (:filter-table . org-export-filter-table-functions)
+    (:filter-table-cell . org-export-filter-table-cell-functions)
+    (:filter-table-row . org-export-filter-table-row-functions)
+    (:filter-target . org-export-filter-target-functions)
+    (:filter-timestamp . org-export-filter-timestamp-functions)
+    (:filter-underline . org-export-filter-underline-functions)
+    (:filter-verbatim . org-export-filter-verbatim-functions)
+    (:filter-verse-block . org-export-filter-verse-block-functions))
+  "Alist between filters properties and initial values.
+
+The key of each association is a property name accessible through
+the communication channel.  Its value is a configurable global
+variable defining initial filters.
+
+This list is meant to install user specified filters.  Back-end
+developers may install their own filters using
+`org-export-define-backend'.  Filters defined there will always
+be prepended to the current list, so they always get applied
+first.")
+
+(defconst org-export-default-inline-image-rule
+  `(("file" .
+     ,(format "\\.%s\\'"
+             (regexp-opt
+              '("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
+                "xpm" "pbm" "pgm" "ppm") t))))
+  "Default rule for link matching an inline image.
+This rule applies to links with no description.  By default, it
+will be considered as an inline image if it targets a local file
+whose extension is either \"png\", \"jpeg\", \"jpg\", \"gif\",
+\"tiff\", \"tif\", \"xbm\", \"xpm\", \"pbm\", \"pgm\" or \"ppm\".
+See `org-export-inline-image-p' for more information about
+rules.")
+
+(defvar org-export-async-debug nil
+  "Non-nil means asynchronous export process should leave data behind.
+
+This data is found in the appropriate \"*Org Export Process*\"
+buffer, and in files prefixed with \"org-export-process\" and
+located in `temporary-file-directory'.
+
+When non-nil, it will also set `debug-on-error' to a non-nil
+value in the external process.")
+
+(defvar org-export-stack-contents nil
+  "Record asynchronously generated export results and processes.
+This is an alist: its CAR is the source of the
+result (destination file or buffer for a finished process,
+original buffer for a running one) and its CDR is a list
+containing the back-end used, as a symbol, and either a process
+or the time at which it finished.  It is used to build the menu
+from `org-export-stack'.")
+
+(defvar org-export--registered-backends nil
+  "List of backends currently available in the exporter.
+This variable is set with `org-export-define-backend' and
+`org-export-define-derived-backend' functions.")
+
+(defvar org-export-dispatch-last-action nil
+  "Last command called from the dispatcher.
+The value should be a list.  Its CAR is the action, as a symbol,
+and its CDR is a list of export options.")
+
+(defvar org-export-dispatch-last-position (make-marker)
+  "The position where the last export command was created using the dispatcher.
+This marker will be used with `C-u C-c C-e' to make sure export repetition
+uses the same subtree if the previous command was restricted to a subtree.")
+
+;; For compatibility with Org < 8
+(defvar org-export-current-backend nil
+  "Name, if any, of the back-end used during an export process.
+
+Its value is a symbol such as `html', `latex', `ascii', or nil if
+the back-end is anonymous (see `org-export-create-backend') or if
+there is no export process in progress.
+
+It can be used to teach Babel blocks how to act differently
+according to the back-end used.")
+
+\f
+;;; User-configurable Variables
+;;
+;; Configuration for the masses.
+;;
+;; They should never be accessed directly, as their value is to be
+;; stored in a property list (cf. `org-export-options-alist').
+;; Back-ends will read their value from there instead.
+
+(defgroup org-export nil
+  "Options for exporting Org mode files."
+  :tag "Org Export"
+  :group 'org)
+
+(defgroup org-export-general nil
+  "General options for export engine."
+  :tag "Org Export General"
+  :group 'org-export)
+
+(defcustom org-export-with-archived-trees 'headline
+  "Whether sub-trees with the ARCHIVE tag should be exported.
+
+This can have three different values:
+nil         Do not export, pretend this tree is not present.
+t           Do export the entire tree.
+`headline'  Only export the headline, but skip the tree below it.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"arch:nil\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "Not at all" nil)
+         (const :tag "Headline only" headline)
+         (const :tag "Entirely" t)))
+
+(defcustom org-export-with-author t
+  "Non-nil means insert author name into the exported file.
+This option can also be set with the OPTIONS keyword,
+e.g. \"author:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-clocks nil
+  "Non-nil means export CLOCK keywords.
+This option can also be set with the OPTIONS keyword,
+e.g. \"c:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-creator 'comment
+  "Non-nil means the postamble should contain a creator sentence.
+
+The sentence can be set in `org-export-creator-string' and
+defaults to \"Generated by Org mode XX in Emacs XXX.\".
+
+If the value is `comment' insert it as a comment."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "No creator sentence" nil)
+         (const :tag "Sentence as a comment" 'comment)
+         (const :tag "Insert the sentence" t)))
+
+(defcustom org-export-with-date t
+  "Non-nil means insert date in the exported document.
+This option can also be set with the OPTIONS keyword,
+e.g. \"date:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-date-timestamp-format nil
+  "Time-stamp format string to use for DATE keyword.
+
+The format string, when specified, only applies if date consists
+in a single time-stamp.  Otherwise its value will be ignored.
+
+See `format-time-string' for details on how to build this
+string."
+  :group 'org-export-general
+  :type '(choice
+         (string :tag "Time-stamp format string")
+         (const :tag "No format string" nil)))
+
+(defcustom org-export-creator-string
+  (format "Emacs %s (Org mode %s)"
+         emacs-version
+         (if (fboundp 'org-version) (org-version) "unknown version"))
+  "Information about the creator of the document.
+This option can also be set on with the CREATOR keyword."
+  :group 'org-export-general
+  :type '(string :tag "Creator string"))
+
+(defcustom org-export-with-drawers '(not "LOGBOOK")
+  "Non-nil means export contents of standard drawers.
+
+When t, all drawers are exported.  This may also be a list of
+drawer names to export.  If that list starts with `not', only
+drawers with such names will be ignored.
+
+This variable doesn't apply to properties drawers.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"d:nil\"."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "All drawers" t)
+         (const :tag "None" nil)
+         (repeat :tag "Selected drawers"
+                 (string :tag "Drawer name"))
+         (list :tag "Ignored drawers"
+               (const :format "" not)
+               (repeat :tag "Specify names of drawers to ignore during export"
+                       :inline t
+                       (string :tag "Drawer name")))))
+
+(defcustom org-export-with-email nil
+  "Non-nil means insert author email into the exported file.
+This option can also be set with the OPTIONS keyword,
+e.g. \"email:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-emphasize t
+  "Non-nil means interpret *word*, /word/, _word_ and +word+.
+
+If the export target supports emphasizing text, the word will be
+typeset in bold, italic, with an underline or strike-through,
+respectively.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"*:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-exclude-tags '("noexport")
+  "Tags that exclude a tree from export.
+
+All trees carrying any of these tags will be excluded from
+export.  This is without condition, so even subtrees inside that
+carry one of the `org-export-select-tags' will be removed.
+
+This option can also be set with the EXCLUDE_TAGS keyword."
+  :group 'org-export-general
+  :type '(repeat (string :tag "Tag")))
+
+(defcustom org-export-with-fixed-width t
+  "Non-nil means lines starting with \":\" will be in fixed width font.
+
+This can be used to have pre-formatted text, fragments of code
+etc.  For example:
+  : ;; Some Lisp examples
+  : (while (defc cnt)
+  :   (ding))
+will be looking just like this in also HTML.  See also the QUOTE
+keyword.  Not all export backends support this.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"::nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-footnotes t
+  "Non-nil means Org footnotes should be exported.
+This option can also be set with the OPTIONS keyword,
+e.g. \"f:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-latex t
+  "Non-nil means process LaTeX environments and fragments.
+
+This option can also be set with the OPTIONS line,
+e.g. \"tex:verbatim\".  Allowed values are:
+
+nil         Ignore math snippets.
+`verbatim'  Keep everything in verbatim.
+t           Allow export of math snippets."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+         (const :tag "Do not process math in any way" nil)
+         (const :tag "Interpret math snippets" t)
+         (const :tag "Leave math verbatim" verbatim)))
+
+(defcustom org-export-headline-levels 3
+  "The last level which is still exported as a headline.
+
+Inferior levels will usually produce itemize or enumerate lists
+when exported, but back-end behaviour may differ.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"H:2\"."
+  :group 'org-export-general
+  :type 'integer)
+
+(defcustom org-export-default-language "en"
+  "The default language for export and clocktable translations, as a string.
+This may have an association in
+`org-clock-clocktable-language-setup',
+`org-export-smart-quotes-alist' and `org-export-dictionary'.
+This option can also be set with the LANGUAGE keyword."
+  :group 'org-export-general
+  :type '(string :tag "Language"))
+
+(defcustom org-export-preserve-breaks nil
+  "Non-nil means preserve all line breaks when exporting.
+This option can also be set with the OPTIONS keyword,
+e.g. \"\\n:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-entities t
+  "Non-nil means interpret entities when exporting.
+
+For example, HTML export converts \\alpha to &alpha; and \\AA to
+&Aring;.
+
+For a list of supported names, see the constant `org-entities'
+and the user option `org-entities-user'.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"e:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-inlinetasks t
+  "Non-nil means inlinetasks should be exported.
+This option can also be set with the OPTIONS keyword,
+e.g. \"inline:nil\"."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-with-planning nil
+  "Non-nil means include planning info in export.
+
+Planning info is the line containing either SCHEDULED:,
+DEADLINE:, CLOSED: time-stamps, or a combination of them.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"p:t\"."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-with-priority nil
+  "Non-nil means include priority cookies in export.
+This option can also be set with the OPTIONS keyword,
+e.g. \"pri:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-section-numbers t
+  "Non-nil means add section numbers to headlines when exporting.
+
+When set to an integer n, numbering will only happen for
+headlines whose relative level is higher or equal to n.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"num:t\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-select-tags '("export")
+  "Tags that select a tree for export.
+
+If any such tag is found in a buffer, all trees that do not carry
+one of these tags will be ignored during export.  Inside trees
+that are selected like this, you can still deselect a subtree by
+tagging it with one of the `org-export-exclude-tags'.
+
+This option can also be set with the SELECT_TAGS keyword."
+  :group 'org-export-general
+  :type '(repeat (string :tag "Tag")))
+
+(defcustom org-export-with-smart-quotes nil
+  "Non-nil means activate smart quotes during export.
+This option can also be set with the OPTIONS keyword,
+e.g., \"':t\".
+
+When setting this to non-nil, you need to take care of
+using the correct Babel package when exporting to LaTeX.
+E.g., you can load Babel for french like this:
+
+#+LATEX_HEADER: \\usepackage[french]{babel}"
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-with-special-strings t
+  "Non-nil means interpret \"\\-\", \"--\" and \"---\" for export.
+
+When this option is turned on, these strings will be exported as:
+
+   Org     HTML     LaTeX    UTF-8
+  -----+----------+--------+-------
+   \\-    &shy;      \\-
+   --    &ndash;    --         –
+   ---   &mdash;    ---        —
+   ...   &hellip;   \\ldots     …
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"-:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-statistics-cookies t
+  "Non-nil means include statistics cookies in export.
+This option can also be set with the OPTIONS keyword,
+e.g. \"stat:nil\""
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-with-sub-superscripts t
+  "Non-nil means interpret \"_\" and \"^\" for export.
+
+When this option is turned on, you can use TeX-like syntax for
+sub- and superscripts.  Several characters after \"_\" or \"^\"
+will be considered as a single item - so grouping with {} is
+normally not needed.  For example, the following things will be
+parsed as single sub- or superscripts.
+
+ 10^24   or   10^tau     several digits will be considered 1 item.
+ 10^-12  or   10^-tau    a leading sign with digits or a word
+ x^2-y^3                 will be read as x^2 - y^3, because items are
+                        terminated by almost any nonword/nondigit char.
+ x_{i^2} or   x^(2-i)    braces or parenthesis do grouping.
+
+Still, ambiguity is possible - so when in doubt use {} to enclose
+the sub/superscript.  If you set this variable to the symbol
+`{}', the braces are *required* in order to trigger
+interpretations as sub/superscript.  This can be helpful in
+documents that need \"_\" frequently in plain text.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"^:nil\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "Interpret them" t)
+         (const :tag "Curly brackets only" {})
+         (const :tag "Do not interpret them" nil)))
+
+(defcustom org-export-with-toc t
+  "Non-nil means create a table of contents in exported files.
+
+The TOC contains headlines with levels up
+to`org-export-headline-levels'.  When an integer, include levels
+up to N in the toc, this may then be different from
+`org-export-headline-levels', but it will not be allowed to be
+larger than the number of headline levels.  When nil, no table of
+contents is made.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"toc:nil\" or \"toc:3\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "No Table of Contents" nil)
+         (const :tag "Full Table of Contents" t)
+         (integer :tag "TOC to level")))
+
+(defcustom org-export-with-tables t
+  "If non-nil, lines starting with \"|\" define a table.
+For example:
+
+  | Name        | Address  | Birthday  |
+  |-------------+----------+-----------|
+  | Arthur Dent | England  | 29.2.2100 |
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"|:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-tags t
+  "If nil, do not export tags, just remove them from headlines.
+
+If this is the symbol `not-in-toc', tags will be removed from
+table of contents entries, but still be shown in the headlines of
+the document.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"tags:nil\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "Off" nil)
+         (const :tag "Not in TOC" not-in-toc)
+         (const :tag "On" t)))
+
+(defcustom org-export-with-tasks t
+  "Non-nil means include TODO items for export.
+
+This may have the following values:
+t                    include tasks independent of state.
+`todo'               include only tasks that are not yet done.
+`done'               include only tasks that are already done.
+nil                  ignore all tasks.
+list of keywords     include tasks with these keywords.
+
+This option can also be set with the OPTIONS keyword,
+e.g. \"tasks:nil\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "All tasks" t)
+         (const :tag "No tasks" nil)
+         (const :tag "Not-done tasks" todo)
+         (const :tag "Only done tasks" done)
+         (repeat :tag "Specific TODO keywords"
+                 (string :tag "Keyword"))))
+
+(defcustom org-export-time-stamp-file t
+  "Non-nil means insert a time stamp into the exported file.
+The time stamp shows when the file was created. This option can
+also be set with the OPTIONS keyword, e.g. \"timestamp:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-with-timestamps t
+  "Non nil means allow timestamps in export.
+
+It can be set to any of the following values:
+  t          export all timestamps.
+  `active'   export active timestamps only.
+  `inactive' export inactive timestamps only.
+  nil        do not export timestamps
+
+This only applies to timestamps isolated in a paragraph
+containing only timestamps.  Other timestamps are always
+exported.
+
+This option can also be set with the OPTIONS keyword, e.g.
+\"<:nil\"."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "All timestamps" t)
+         (const :tag "Only active timestamps" active)
+         (const :tag "Only inactive timestamps" inactive)
+         (const :tag "No timestamp" nil)))
+
+(defcustom org-export-with-todo-keywords t
+  "Non-nil means include TODO keywords in export.
+When nil, remove all these keywords from the export.  This option
+can also be set with the OPTIONS keyword, e.g.  \"todo:nil\"."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-allow-bind-keywords nil
+  "Non-nil means BIND keywords can define local variable values.
+This is a potential security risk, which is why the default value
+is nil.  You can also allow them through local buffer variables."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-snippet-translation-alist nil
+  "Alist between export snippets back-ends and exporter back-ends.
+
+This variable allows to provide shortcuts for export snippets.
+
+For example, with a value of '\(\(\"h\" . \"html\"\)\), the
+HTML back-end will recognize the contents of \"@@h:<b>@@\" as
+HTML code while every other back-end will ignore it."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(repeat
+         (cons (string :tag "Shortcut")
+               (string :tag "Back-end"))))
+
+(defcustom org-export-coding-system nil
+  "Coding system for the exported file."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'coding-system)
+
+(defcustom org-export-copy-to-kill-ring 'if-interactive
+  "Should we push exported content to the kill ring?"
+  :group 'org-export-general
+  :version "24.3"
+  :type '(choice
+         (const :tag "Always" t)
+         (const :tag "When export is done interactively" if-interactive)
+         (const :tag "Never" nil)))
+
+(defcustom org-export-initial-scope 'buffer
+  "The initial scope when exporting with `org-export-dispatch'.
+This variable can be either set to `buffer' or `subtree'."
+  :group 'org-export-general
+  :type '(choice
+         (const :tag "Export current buffer" buffer)
+         (const :tag "Export current subtree" subtree)))
+
+(defcustom org-export-show-temporary-export-buffer t
+  "Non-nil means show buffer after exporting to temp buffer.
+When Org exports to a file, the buffer visiting that file is ever
+shown, but remains buried.  However, when exporting to
+a temporary buffer, that buffer is popped up in a second window.
+When this variable is nil, the buffer remains buried also in
+these cases."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-in-background nil
+  "Non-nil means export and publishing commands will run in background.
+Results from an asynchronous export are never displayed
+automatically.  But you can retrieve them with \\[org-export-stack]."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+(defcustom org-export-async-init-file user-init-file
+  "File used to initialize external export process.
+Value must be an absolute file name.  It defaults to user's
+initialization file.  Though, a specific configuration makes the
+process faster and the export more portable."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(file :must-match t))
+
+(defcustom org-export-dispatch-use-expert-ui nil
+  "Non-nil means using a non-intrusive `org-export-dispatch'.
+In that case, no help buffer is displayed.  Though, an indicator
+for current export scope is added to the prompt (\"b\" when
+output is restricted to body only, \"s\" when it is restricted to
+the current subtree, \"v\" when only visible elements are
+considered for export, \"f\" when publishing functions should be
+passed the FORCE argument and \"a\" when the export should be
+asynchronous).  Also, \[?] allows to switch back to standard
+mode."
+  :group 'org-export-general
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'boolean)
+
+
+\f
+;;; Defining Back-ends
+;;
+;; An export back-end is a structure with `org-export-backend' type
+;; and `name', `parent', `transcoders', `options', `filters', `blocks'
+;; and `menu' slots.
+;;
+;; At the lowest level, a back-end is created with
+;; `org-export-create-backend' function.
+;;
+;; A named back-end can be registered with
+;; `org-export-register-backend' function.  A registered back-end can
+;; later be referred to by its name, with `org-export-get-backend'
+;; function.  Also, such a back-end can become the parent of a derived
+;; back-end from which slot values will be inherited by default.
+;; `org-export-derived-backend-p' can check if a given back-end is
+;; derived from a list of back-end names.
+;;
+;; `org-export-get-all-transcoders', `org-export-get-all-options' and
+;; `org-export-get-all-filters' return the full alist of transcoders,
+;; options and filters, including those inherited from ancestors.
+;;
+;; At a higher level, `org-export-define-backend' is the standard way
+;; to define an export back-end.  If the new back-end is similar to
+;; a registered back-end, `org-export-define-derived-backend' may be
+;; used instead.
+;;
+;; Eventually `org-export-barf-if-invalid-backend' returns an error
+;; when a given back-end hasn't been registered yet.
+
+(defstruct (org-export-backend (:constructor org-export-create-backend)
+                              (:copier nil))
+  name parent transcoders options filters blocks menu)
+
+(defun org-export-get-backend (name)
+  "Return export back-end named after NAME.
+NAME is a symbol.  Return nil if no such back-end is found."
+  (catch 'found
+    (dolist (b org-export--registered-backends)
+      (when (eq (org-export-backend-name b) name)
+       (throw 'found b)))))
+
+(defun org-export-register-backend (backend)
+  "Register BACKEND as a known export back-end.
+BACKEND is a structure with `org-export-backend' type."
+  ;; Refuse to register an unnamed back-end.
+  (unless (org-export-backend-name backend)
+    (error "Cannot register a unnamed export back-end"))
+  ;; Refuse to register a back-end with an unknown parent.
+  (let ((parent (org-export-backend-parent backend)))
+    (when (and parent (not (org-export-get-backend parent)))
+      (error "Cannot use unknown \"%s\" back-end as a parent" parent)))
+  ;; Register dedicated export blocks in the parser.
+  (dolist (name (org-export-backend-blocks backend))
+    (add-to-list 'org-element-block-name-alist
+                (cons name 'org-element-export-block-parser)))
+  ;; If a back-end with the same name as BACKEND is already
+  ;; registered, replace it with BACKEND.  Otherwise, simply add
+  ;; BACKEND to the list of registered back-ends.
+  (let ((old (org-export-get-backend (org-export-backend-name backend))))
+    (if old (setcar (memq old org-export--registered-backends) backend)
+      (push backend org-export--registered-backends))))
+
+(defun org-export-barf-if-invalid-backend (backend)
+  "Signal an error if BACKEND isn't defined."
+  (unless (org-export-backend-p backend)
+    (error "Unknown \"%s\" back-end: Aborting export" backend)))
+
+(defun org-export-derived-backend-p (backend &rest backends)
+  "Non-nil if BACKEND is derived from one of BACKENDS.
+BACKEND is an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.  BACKENDS is constituted of symbols."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (when backend
+    (catch 'exit
+      (while (org-export-backend-parent backend)
+       (when (memq (org-export-backend-name backend) backends)
+         (throw 'exit t))
+       (setq backend
+             (org-export-get-backend (org-export-backend-parent backend))))
+      (memq (org-export-backend-name backend) backends))))
+
+(defun org-export-get-all-transcoders (backend)
+  "Return full translation table for BACKEND.
+
+BACKEND is an export back-end, as return by, e.g,,
+`org-export-create-backend'.  Return value is an alist where
+keys are element or object types, as symbols, and values are
+transcoders.
+
+Unlike to `org-export-backend-transcoders', this function
+also returns transcoders inherited from parent back-ends,
+if any."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (when backend
+    (let ((transcoders (org-export-backend-transcoders backend))
+         parent)
+      (while (setq parent (org-export-backend-parent backend))
+       (setq backend (org-export-get-backend parent))
+       (setq transcoders
+             (append transcoders (org-export-backend-transcoders backend))))
+      transcoders)))
+
+(defun org-export-get-all-options (backend)
+  "Return export options for BACKEND.
+
+BACKEND is an export back-end, as return by, e.g,,
+`org-export-create-backend'.  See `org-export-options-alist'
+for the shape of the return value.
+
+Unlike to `org-export-backend-options', this function also
+returns options inherited from parent back-ends, if any."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (when backend
+    (let ((options (org-export-backend-options backend))
+         parent)
+      (while (setq parent (org-export-backend-parent backend))
+       (setq backend (org-export-get-backend parent))
+       (setq options (append options (org-export-backend-options backend))))
+      options)))
+
+(defun org-export-get-all-filters (backend)
+  "Return complete list of filters for BACKEND.
+
+BACKEND is an export back-end, as return by, e.g,,
+`org-export-create-backend'.  Return value is an alist where
+keys are symbols and values lists of functions.
+
+Unlike to `org-export-backend-filters', this function also
+returns filters inherited from parent back-ends, if any."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (when backend
+    (let ((filters (org-export-backend-filters backend))
+         parent)
+      (while (setq parent (org-export-backend-parent backend))
+       (setq backend (org-export-get-backend parent))
+       (setq filters (append filters (org-export-backend-filters backend))))
+      filters)))
+
+(defun org-export-define-backend (backend transcoders &rest body)
+  "Define a new back-end BACKEND.
+
+TRANSCODERS is an alist between object or element types and
+functions handling them.
+
+These functions should return a string without any trailing
+space, or nil.  They must accept three arguments: the object or
+element itself, its contents or nil when it isn't recursive and
+the property list used as a communication channel.
+
+Contents, when not nil, are stripped from any global indentation
+\(although the relative one is preserved).  They also always end
+with a single newline character.
+
+If, for a given type, no function is found, that element or
+object type will simply be ignored, along with any blank line or
+white space at its end.  The same will happen if the function
+returns the nil value.  If that function returns the empty
+string, the type will be ignored, but the blank lines or white
+spaces will be kept.
+
+In addition to element and object types, one function can be
+associated to the `template' (or `inner-template') symbol and
+another one to the `plain-text' symbol.
+
+The former returns the final transcoded string, and can be used
+to add a preamble and a postamble to document's body.  It must
+accept two arguments: the transcoded string and the property list
+containing export options.  A function associated to `template'
+will not be applied if export has option \"body-only\".
+A function associated to `inner-template' is always applied.
+
+The latter, when defined, is to be called on every text not
+recognized as an element or an object.  It must accept two
+arguments: the text string and the information channel.  It is an
+appropriate place to protect special chars relative to the
+back-end.
+
+BODY can start with pre-defined keyword arguments.  The following
+keywords are understood:
+
+  :export-block
+
+    String, or list of strings, representing block names that
+    will not be parsed.  This is used to specify blocks that will
+    contain raw code specific to the back-end.  These blocks
+    still have to be handled by the relative `export-block' type
+    translator.
+
+  :filters-alist
+
+    Alist between filters and function, or list of functions,
+    specific to the back-end.  See `org-export-filters-alist' for
+    a list of all allowed filters.  Filters defined here
+    shouldn't make a back-end test, as it may prevent back-ends
+    derived from this one to behave properly.
+
+  :menu-entry
+
+    Menu entry for the export dispatcher.  It should be a list
+    like:
+
+      '(KEY DESCRIPTION-OR-ORDINAL ACTION-OR-MENU)
+
+    where :
+
+      KEY is a free character selecting the back-end.
+
+      DESCRIPTION-OR-ORDINAL is either a string or a number.
+
+      If it is a string, is will be used to name the back-end in
+      its menu entry.  If it is a number, the following menu will
+      be displayed as a sub-menu of the back-end with the same
+      KEY.  Also, the number will be used to determine in which
+      order such sub-menus will appear (lowest first).
+
+      ACTION-OR-MENU is either a function or an alist.
+
+      If it is an action, it will be called with four
+      arguments (booleans): ASYNC, SUBTREEP, VISIBLE-ONLY and
+      BODY-ONLY.  See `org-export-as' for further explanations on
+      some of them.
+
+      If it is an alist, associations should follow the
+      pattern:
+
+        '(KEY DESCRIPTION ACTION)
+
+      where KEY, DESCRIPTION and ACTION are described above.
+
+    Valid values include:
+
+      '(?m \"My Special Back-end\" my-special-export-function)
+
+      or
+
+      '(?l \"Export to LaTeX\"
+           \(?p \"As PDF file\" org-latex-export-to-pdf)
+           \(?o \"As PDF file and open\"
+               \(lambda (a s v b)
+                 \(if a (org-latex-export-to-pdf t s v b)
+                   \(org-open-file
+                    \(org-latex-export-to-pdf nil s v b)))))))
+
+      or the following, which will be added to the previous
+      sub-menu,
+
+      '(?l 1
+          \((?B \"As TEX buffer (Beamer)\" org-beamer-export-as-latex)
+           \(?P \"As PDF file (Beamer)\" org-beamer-export-to-pdf)))
+
+  :options-alist
+
+    Alist between back-end specific properties introduced in
+    communication channel and how their value are acquired.  See
+    `org-export-options-alist' for more information about
+    structure of the values."
+  (declare (indent 1))
+  (let (blocks filters menu-entry options contents)
+    (while (keywordp (car body))
+      (case (pop body)
+        (:export-block (let ((names (pop body)))
+                        (setq blocks (if (consp names) (mapcar 'upcase names)
+                                       (list (upcase names))))))
+       (:filters-alist (setq filters (pop body)))
+       (:menu-entry (setq menu-entry (pop body)))
+        (:options-alist (setq options (pop body)))
+        (t (pop body))))
+    (org-export-register-backend
+     (org-export-create-backend :name backend
+                               :transcoders transcoders
+                               :options options
+                               :filters filters
+                               :blocks blocks
+                               :menu menu-entry))))
+
+(defun org-export-define-derived-backend (child parent &rest body)
+  "Create a new back-end as a variant of an existing one.
+
+CHILD is the name of the derived back-end.  PARENT is the name of
+the parent back-end.
+
+BODY can start with pre-defined keyword arguments.  The following
+keywords are understood:
+
+  :export-block
+
+    String, or list of strings, representing block names that
+    will not be parsed.  This is used to specify blocks that will
+    contain raw code specific to the back-end.  These blocks
+    still have to be handled by the relative `export-block' type
+    translator.
+
+  :filters-alist
+
+    Alist of filters that will overwrite or complete filters
+    defined in PARENT back-end.  See `org-export-filters-alist'
+    for a list of allowed filters.
+
+  :menu-entry
+
+    Menu entry for the export dispatcher.  See
+    `org-export-define-backend' for more information about the
+    expected value.
+
+  :options-alist
+
+    Alist of back-end specific properties that will overwrite or
+    complete those defined in PARENT back-end.  Refer to
+    `org-export-options-alist' for more information about
+    structure of the values.
+
+  :translate-alist
+
+    Alist of element and object types and transcoders that will
+    overwrite or complete transcode table from PARENT back-end.
+    Refer to `org-export-define-backend' for detailed information
+    about transcoders.
+
+As an example, here is how one could define \"my-latex\" back-end
+as a variant of `latex' back-end with a custom template function:
+
+  \(org-export-define-derived-backend 'my-latex 'latex
+     :translate-alist '((template . my-latex-template-fun)))
+
+The back-end could then be called with, for example:
+
+  \(org-export-to-buffer 'my-latex \"*Test my-latex*\")"
+  (declare (indent 2))
+  (let (blocks filters menu-entry options transcoders contents)
+    (while (keywordp (car body))
+      (case (pop body)
+       (:export-block (let ((names (pop body)))
+                        (setq blocks (if (consp names) (mapcar 'upcase names)
+                                       (list (upcase names))))))
+        (:filters-alist (setq filters (pop body)))
+       (:menu-entry (setq menu-entry (pop body)))
+        (:options-alist (setq options (pop body)))
+        (:translate-alist (setq transcoders (pop body)))
+        (t (pop body))))
+    (org-export-register-backend
+     (org-export-create-backend :name child
+                               :parent parent
+                               :transcoders transcoders
+                               :options options
+                               :filters filters
+                               :blocks blocks
+                               :menu menu-entry))))
+
+
+\f
+;;; The Communication Channel
+;;
+;; During export process, every function has access to a number of
+;; properties.  They are of two types:
+;;
+;; 1. Environment options are collected once at the very beginning of
+;;    the process, out of the original buffer and configuration.
+;;    Collecting them is handled by `org-export-get-environment'
+;;    function.
+;;
+;;    Most environment options are defined through the
+;;    `org-export-options-alist' variable.
+;;
+;; 2. Tree properties are extracted directly from the parsed tree,
+;;    just before export, by `org-export-collect-tree-properties'.
+;;
+;; Here is the full list of properties available during transcode
+;; process, with their category and their value type.
+;;
+;; + `:author' :: Author's name.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:back-end' :: Current back-end used for transcoding.
+;;   - category :: tree
+;;   - type :: symbol
+;;
+;; + `:creator' :: String to write as creation information.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:date' :: String to use as date.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:description' :: Description text for the current data.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:email' :: Author's email.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:exclude-tags' :: Tags for exclusion of subtrees from export
+;;      process.
+;;   - category :: option
+;;   - type :: list of strings
+;;
+;; + `:export-options' :: List of export options available for current
+;;      process.
+;;   - category :: none
+;;   - type :: list of symbols, among `subtree', `body-only' and
+;;      `visible-only'.
+;;
+;; + `:exported-data' :: Hash table used for memoizing
+;;     `org-export-data'.
+;;   - category :: tree
+;;   - type :: hash table
+;;
+;; + `:filetags' :: List of global tags for buffer.  Used by
+;;   `org-export-get-tags' to get tags with inheritance.
+;;   - category :: option
+;;   - type :: list of strings
+;;
+;; + `:footnote-definition-alist' :: Alist between footnote labels and
+;;      their definition, as parsed data.  Only non-inlined footnotes
+;;      are represented in this alist.  Also, every definition isn't
+;;      guaranteed to be referenced in the parse tree.  The purpose of
+;;      this property is to preserve definitions from oblivion
+;;      (i.e. when the parse tree comes from a part of the original
+;;      buffer), it isn't meant for direct use in a back-end.  To
+;;      retrieve a definition relative to a reference, use
+;;      `org-export-get-footnote-definition' instead.
+;;   - category :: option
+;;   - type :: alist (STRING . LIST)
+;;
+;; + `:headline-levels' :: Maximum level being exported as an
+;;      headline.  Comparison is done with the relative level of
+;;      headlines in the parse tree, not necessarily with their
+;;      actual level.
+;;   - category :: option
+;;   - type :: integer
+;;
+;; + `:headline-offset' :: Difference between relative and real level
+;;      of headlines in the parse tree.  For example, a value of -1
+;;      means a level 2 headline should be considered as level
+;;      1 (cf. `org-export-get-relative-level').
+;;   - category :: tree
+;;   - type :: integer
+;;
+;; + `:headline-numbering' :: Alist between headlines and their
+;;      numbering, as a list of numbers
+;;      (cf. `org-export-get-headline-number').
+;;   - category :: tree
+;;   - type :: alist (INTEGER . LIST)
+;;
+;; + `:id-alist' :: Alist between ID strings and destination file's
+;;      path, relative to current directory.  It is used by
+;;      `org-export-resolve-id-link' to resolve ID links targeting an
+;;      external file.
+;;   - category :: option
+;;   - type :: alist (STRING . STRING)
+;;
+;; + `:ignore-list' :: List of elements and objects that should be
+;;      ignored during export.
+;;   - category :: tree
+;;   - type :: list of elements and objects
+;;
+;; + `:input-file' :: Full path to input file, if any.
+;;   - category :: option
+;;   - type :: string or nil
+;;
+;; + `:keywords' :: List of keywords attached to data.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:language' :: Default language used for translations.
+;;   - category :: option
+;;   - type :: string
+;;
+;; + `:parse-tree' :: Whole parse tree, available at any time during
+;;      transcoding.
+;;   - category :: option
+;;   - type :: list (as returned by `org-element-parse-buffer')
+;;
+;; + `:preserve-breaks' :: Non-nil means transcoding should preserve
+;;      all line breaks.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:section-numbers' :: Non-nil means transcoding should add
+;;      section numbers to headlines.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:select-tags' :: List of tags enforcing inclusion of sub-trees
+;;      in transcoding.  When such a tag is present, subtrees without
+;;      it are de facto excluded from the process.  See
+;;      `use-select-tags'.
+;;   - category :: option
+;;   - type :: list of strings
+;;
+;; + `:time-stamp-file' :: Non-nil means transcoding should insert
+;;      a time stamp in the output.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:translate-alist' :: Alist between element and object types and
+;;      transcoding functions relative to the current back-end.
+;;      Special keys `inner-template', `template' and `plain-text' are
+;;      also possible.
+;;   - category :: option
+;;   - type :: alist (SYMBOL . FUNCTION)
+;;
+;; + `:with-archived-trees' :: Non-nil when archived subtrees should
+;;      also be transcoded.  If it is set to the `headline' symbol,
+;;      only the archived headline's name is retained.
+;;   - category :: option
+;;   - type :: symbol (nil, t, `headline')
+;;
+;; + `:with-author' :: Non-nil means author's name should be included
+;;      in the output.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-clocks' :: Non-nil means clock keywords should be exported.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-creator' :: Non-nil means a creation sentence should be
+;;      inserted at the end of the transcoded string.  If the value
+;;      is `comment', it should be commented.
+;;   - category :: option
+;;   - type :: symbol (`comment', nil, t)
+;;
+;; + `:with-date' :: Non-nil means output should contain a date.
+;;   - category :: option
+;;   - type :. symbol (nil, t)
+;;
+;; + `:with-drawers' :: Non-nil means drawers should be exported.  If
+;;      its value is a list of names, only drawers with such names
+;;      will be transcoded.  If that list starts with `not', drawer
+;;      with these names will be skipped.
+;;   - category :: option
+;;   - type :: symbol (nil, t) or list of strings
+;;
+;; + `:with-email' :: Non-nil means output should contain author's
+;;                   email.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-emphasize' :: Non-nil means emphasized text should be
+;;      interpreted.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-fixed-width' :: Non-nil if transcoder should interpret
+;;      strings starting with a colon as a fixed-with (verbatim) area.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-footnotes' :: Non-nil if transcoder should interpret
+;;      footnotes.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-latex' :: Non-nil means `latex-environment' elements and
+;;    `latex-fragment' objects should appear in export output.  When
+;;    this property is set to `verbatim', they will be left as-is.
+;;   - category :: option
+;;   - type :: symbol (`verbatim', nil, t)
+;;
+;; + `:with-planning' :: Non-nil means transcoding should include
+;;      planning info.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-priority' :: Non-nil means transcoding should include
+;;      priority cookies.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-smart-quotes' :: Non-nil means activate smart quotes in
+;;      plain text.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-special-strings' :: Non-nil means transcoding should
+;;      interpret special strings in plain text.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-sub-superscript' :: Non-nil means transcoding should
+;;      interpret subscript and superscript.  With a value of "{}",
+;;      only interpret those using curly brackets.
+;;   - category :: option
+;;   - type :: symbol (nil, {}, t)
+;;
+;; + `:with-tables' :: Non-nil means transcoding should interpret
+;;      tables.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+;;
+;; + `:with-tags' :: Non-nil means transcoding should keep tags in
+;;      headlines.  A `not-in-toc' value will remove them from the
+;;      table of contents, if any, nonetheless.
+;;   - category :: option
+;;   - type :: symbol (nil, t, `not-in-toc')
+;;
+;; + `:with-tasks' :: Non-nil means transcoding should include
+;;      headlines with a TODO keyword.  A `todo' value will only
+;;      include headlines with a todo type keyword while a `done'
+;;      value will do the contrary.  If a list of strings is provided,
+;;      only tasks with keywords belonging to that list will be kept.
+;;   - category :: option
+;;   - type :: symbol (t, todo, done, nil) or list of strings
+;;
+;; + `:with-timestamps' :: Non-nil means transcoding should include
+;;      time stamps.  Special value `active' (resp. `inactive') ask to
+;;      export only active (resp. inactive) timestamps.  Otherwise,
+;;      completely remove them.
+;;   - category :: option
+;;   - type :: symbol: (`active', `inactive', t, nil)
+;;
+;; + `:with-toc' :: Non-nil means that a table of contents has to be
+;;      added to the output.  An integer value limits its depth.
+;;   - category :: option
+;;   - type :: symbol (nil, t or integer)
+;;
+;; + `:with-todo-keywords' :: Non-nil means transcoding should
+;;      include TODO keywords.
+;;   - category :: option
+;;   - type :: symbol (nil, t)
+
+
+;;;; Environment Options
+;;
+;; Environment options encompass all parameters defined outside the
+;; scope of the parsed data.  They come from five sources, in
+;; increasing precedence order:
+;;
+;; - Global variables,
+;; - Buffer's attributes,
+;; - Options keyword symbols,
+;; - Buffer keywords,
+;; - Subtree properties.
+;;
+;; The central internal function with regards to environment options
+;; is `org-export-get-environment'.  It updates global variables with
+;; "#+BIND:" keywords, then retrieve and prioritize properties from
+;; the different sources.
+;;
+;;  The internal functions doing the retrieval are:
+;;  `org-export--get-global-options',
+;;  `org-export--get-buffer-attributes',
+;;  `org-export--parse-option-keyword',
+;;  `org-export--get-subtree-options' and
+;;  `org-export--get-inbuffer-options'
+;;
+;; Also, `org-export--list-bound-variables' collects bound variables
+;; along with their value in order to set them as buffer local
+;; variables later in the process.
+
+(defun org-export-get-environment (&optional backend subtreep ext-plist)
+  "Collect export options from the current buffer.
+
+Optional argument BACKEND is an export back-end, as returned by
+`org-export-create-backend'.
+
+When optional argument SUBTREEP is non-nil, assume the export is
+done against the current sub-tree.
+
+Third optional argument EXT-PLIST is a property list with
+external parameters overriding Org default settings, but still
+inferior to file-local settings."
+  ;; First install #+BIND variables since these must be set before
+  ;; global options are read.
+  (dolist (pair (org-export--list-bound-variables))
+    (org-set-local (car pair) (nth 1 pair)))
+  ;; Get and prioritize export options...
+  (org-combine-plists
+   ;; ... from global variables...
+   (org-export--get-global-options backend)
+   ;; ... from an external property list...
+   ext-plist
+   ;; ... from in-buffer settings...
+   (org-export--get-inbuffer-options backend)
+   ;; ... and from subtree, when appropriate.
+   (and subtreep (org-export--get-subtree-options backend))
+   ;; Eventually add misc. properties.
+   (list
+    :back-end
+    backend
+    :translate-alist (org-export-get-all-transcoders backend)
+    :footnote-definition-alist
+    ;; Footnotes definitions must be collected in the original
+    ;; buffer, as there's no insurance that they will still be in
+    ;; the parse tree, due to possible narrowing.
+    (let (alist)
+      (org-with-wide-buffer
+       (goto-char (point-min))
+       (while (re-search-forward org-footnote-definition-re nil t)
+        (let ((def (save-match-data (org-element-at-point))))
+          (when (eq (org-element-type def) 'footnote-definition)
+            (push
+             (cons (org-element-property :label def)
+                   (let ((cbeg (org-element-property :contents-begin def)))
+                     (when cbeg
+                       (org-element--parse-elements
+                        cbeg (org-element-property :contents-end def)
+                        nil nil nil nil (list 'org-data nil)))))
+             alist))))
+       alist))
+    :id-alist
+    ;; Collect id references.
+    (let (alist)
+      (org-with-wide-buffer
+       (goto-char (point-min))
+       (while (re-search-forward "\\[\\[id:\\S-+?\\]" nil t)
+        (let ((link (org-element-context)))
+          (when (eq (org-element-type link) 'link)
+            (let* ((id (org-element-property :path link))
+                   (file (org-id-find-id-file id)))
+              (when file
+                (push (cons id (file-relative-name file)) alist)))))))
+      alist))))
+
+(defun org-export--parse-option-keyword (options &optional backend)
+  "Parse an OPTIONS line and return values as a plist.
+Optional argument BACKEND is an export back-end, as returned by,
+e.g., `org-export-create-backend'.  It specifies which back-end
+specific items to read, if any."
+  (let* ((all
+         ;; Priority is given to back-end specific options.
+         (append (and backend (org-export-get-all-options backend))
+                 org-export-options-alist))
+        plist)
+    (dolist (option all)
+      (let ((property (car option))
+           (item (nth 2 option)))
+       (when (and item
+                  (not (plist-member plist property))
+                  (string-match (concat "\\(\\`\\|[ \t]\\)"
+                                        (regexp-quote item)
+                                        ":\\(([^)\n]+)\\|[^ \t\n\r;,.]*\\)")
+                                options))
+         (setq plist (plist-put plist
+                                property
+                                (car (read-from-string
+                                      (match-string 2 options))))))))
+    plist))
+
+(defun org-export--get-subtree-options (&optional backend)
+  "Get export options in subtree at point.
+Optional argument BACKEND is an export back-end, as returned by,
+e.g., `org-export-create-backend'.  It specifies back-end used
+for export.  Return options as a plist."
+  ;; For each buffer keyword, create a headline property setting the
+  ;; same property in communication channel. The name for the property
+  ;; is the keyword with "EXPORT_" appended to it.
+  (org-with-wide-buffer
+   (let (prop plist)
+     ;; Make sure point is at a heading.
+     (if (org-at-heading-p) (org-up-heading-safe) (org-back-to-heading t))
+     ;; Take care of EXPORT_TITLE. If it isn't defined, use headline's
+     ;; title as its fallback value.
+     (when (setq prop (or (org-entry-get (point) "EXPORT_TITLE")
+                         (progn (looking-at org-todo-line-regexp)
+                                (org-match-string-no-properties 3))))
+       (setq plist
+            (plist-put
+             plist :title
+             (org-element-parse-secondary-string
+              prop (org-element-restriction 'keyword)))))
+     ;; EXPORT_OPTIONS are parsed in a non-standard way.
+     (when (setq prop (org-entry-get (point) "EXPORT_OPTIONS"))
+       (setq plist
+            (nconc plist (org-export--parse-option-keyword prop backend))))
+     ;; Handle other keywords.  TITLE keyword is excluded as it has
+     ;; been handled already.
+     (let ((seen '("TITLE")))
+       (mapc
+       (lambda (option)
+         (let ((property (car option))
+               (keyword (nth 1 option)))
+           (when (and keyword (not (member keyword seen)))
+             (let* ((subtree-prop (concat "EXPORT_" keyword))
+                    ;; Export properties are not case-sensitive.
+                    (value (let ((case-fold-search t))
+                             (org-entry-get (point) subtree-prop))))
+               (push keyword seen)
+               (when (and value (not (plist-member plist property)))
+                 (setq plist
+                       (plist-put
+                        plist
+                        property
+                        (cond
+                         ;; Parse VALUE if required.
+                         ((member keyword org-element-document-properties)
+                          (org-element-parse-secondary-string
+                           value (org-element-restriction 'keyword)))
+                         ;; If BEHAVIOUR is `split' expected value is
+                         ;; a list of strings, not a string.
+                         ((eq (nth 4 option) 'split) (org-split-string value))
+                         (t value)))))))))
+       ;; Look for both general keywords and back-end specific
+       ;; options, with priority given to the latter.
+       (append (and backend (org-export-get-all-options backend))
+               org-export-options-alist)))
+     ;; Return value.
+     plist)))
+
+(defun org-export--get-inbuffer-options (&optional backend)
+  "Return current buffer export options, as a plist.
+
+Optional argument BACKEND, when non-nil, is an export back-end,
+as returned by, e.g., `org-export-create-backend'.  It specifies
+which back-end specific options should also be read in the
+process.
+
+Assume buffer is in Org mode.  Narrowing, if any, is ignored."
+  (let* (plist
+        get-options                    ; For byte-compiler.
+        (case-fold-search t)
+        (options (append
+                  ;; Priority is given to back-end specific options.
+                  (and backend (org-export-get-all-options backend))
+                  org-export-options-alist))
+        (regexp (format "^[ \t]*#\\+%s:"
+                        (regexp-opt (nconc (delq nil (mapcar 'cadr options))
+                                           org-export-special-keywords))))
+        (find-properties
+         (lambda (keyword)
+           ;; Return all properties associated to KEYWORD.
+           (let (properties)
+             (dolist (option options properties)
+               (when (equal (nth 1 option) keyword)
+                 (pushnew (car option) properties))))))
+        (get-options
+         (lambda (&optional files plist)
+           ;; Recursively read keywords in buffer.  FILES is a list
+           ;; of files read so far.  PLIST is the current property
+           ;; list obtained.
+           (org-with-wide-buffer
+            (goto-char (point-min))
+            (while (re-search-forward regexp nil t)
+              (let ((element (org-element-at-point)))
+                (when (eq (org-element-type element) 'keyword)
+                  (let ((key (org-element-property :key element))
+                        (val (org-element-property :value element)))
+                    (cond
+                     ;; Options in `org-export-special-keywords'.
+                     ((equal key "SETUPFILE")
+                      (let ((file (expand-file-name
+                                   (org-remove-double-quotes (org-trim val)))))
+                        ;; Avoid circular dependencies.
+                        (unless (member file files)
+                          (with-temp-buffer
+                            (insert (org-file-contents file 'noerror))
+                            (let ((org-inhibit-startup t)) (org-mode))
+                            (setq plist (funcall get-options
+                                                 (cons file files) plist))))))
+                     ((equal key "OPTIONS")
+                      (setq plist
+                            (org-combine-plists
+                             plist
+                             (org-export--parse-option-keyword val backend))))
+                     ((equal key "FILETAGS")
+                      (setq plist
+                            (org-combine-plists
+                             plist
+                             (list :filetags
+                                   (org-uniquify
+                                    (append (org-split-string val ":")
+                                            (plist-get plist :filetags)))))))
+                     (t
+                      ;; Options in `org-export-options-alist'.
+                      (dolist (property (funcall find-properties key))
+                        (let ((behaviour (nth 4 (assq property options))))
+                          (setq plist
+                                (plist-put
+                                 plist property
+                                 ;; Handle value depending on specified
+                                 ;; BEHAVIOUR.
+                                 (case behaviour
+                                   (space
+                                    (if (not (plist-get plist property))
+                                        (org-trim val)
+                                      (concat (plist-get plist property)
+                                              " "
+                                              (org-trim val))))
+                                   (newline
+                                    (org-trim
+                                     (concat (plist-get plist property)
+                                             "\n"
+                                             (org-trim val))))
+                                   (split `(,@(plist-get plist property)
+                                            ,@(org-split-string val)))
+                                   ('t val)
+                                   (otherwise
+                                    (if (not (plist-member plist property)) val
+                                      (plist-get plist property))))))))))))))
+            ;; Return final value.
+            plist))))
+    ;; Read options in the current buffer.
+    (setq plist (funcall get-options
+                        (and buffer-file-name (list buffer-file-name)) nil))
+    ;; Parse keywords specified in `org-element-document-properties'
+    ;; and return PLIST.
+    (dolist (keyword org-element-document-properties plist)
+      (dolist (property (funcall find-properties keyword))
+       (let ((value (plist-get plist property)))
+         (when (stringp value)
+           (setq plist
+                 (plist-put plist property
+                            (org-element-parse-secondary-string
+                             value (org-element-restriction 'keyword))))))))))
+
+(defun org-export--get-buffer-attributes ()
+  "Return properties related to buffer attributes, as a plist."
+  ;; Store full path of input file name, or nil.  For internal use.
+  (let ((visited-file (buffer-file-name (buffer-base-buffer))))
+    (list :input-file visited-file
+         :title (if (not visited-file) (buffer-name (buffer-base-buffer))
+                  (file-name-sans-extension
+                   (file-name-nondirectory visited-file))))))
+
+(defun org-export--get-global-options (&optional backend)
+  "Return global export options as a plist.
+Optional argument BACKEND, if non-nil, is an export back-end, as
+returned by, e.g., `org-export-create-backend'.  It specifies
+which back-end specific export options should also be read in the
+process."
+  (let (plist
+       ;; Priority is given to back-end specific options.
+       (all (append (and backend (org-export-get-all-options backend))
+                    org-export-options-alist)))
+    (dolist (cell all plist)
+      (let ((prop (car cell))
+           (default-value (nth 3 cell)))
+       (unless (or (not default-value) (plist-member plist prop))
+         (setq plist
+               (plist-put
+                plist
+                prop
+                ;; Eval default value provided.  If keyword is
+                ;; a member of `org-element-document-properties',
+                ;; parse it as a secondary string before storing it.
+                (let ((value (eval (nth 3 cell))))
+                  (if (not (stringp value)) value
+                    (let ((keyword (nth 1 cell)))
+                      (if (member keyword org-element-document-properties)
+                          (org-element-parse-secondary-string
+                           value (org-element-restriction 'keyword))
+                        value)))))))))))
+
+(defun org-export--list-bound-variables ()
+  "Return variables bound from BIND keywords in current buffer.
+Also look for BIND keywords in setup files.  The return value is
+an alist where associations are (VARIABLE-NAME VALUE)."
+  (when org-export-allow-bind-keywords
+    (let* (collect-bind                        ; For byte-compiler.
+          (collect-bind
+           (lambda (files alist)
+             ;; Return an alist between variable names and their
+             ;; value.  FILES is a list of setup files names read so
+             ;; far, used to avoid circular dependencies.  ALIST is
+             ;; the alist collected so far.
+             (let ((case-fold-search t))
+               (org-with-wide-buffer
+                (goto-char (point-min))
+                (while (re-search-forward
+                        "^[ \t]*#\\+\\(BIND\\|SETUPFILE\\):" nil t)
+                  (let ((element (org-element-at-point)))
+                    (when (eq (org-element-type element) 'keyword)
+                      (let ((val (org-element-property :value element)))
+                        (if (equal (org-element-property :key element) "BIND")
+                            (push (read (format "(%s)" val)) alist)
+                          ;; Enter setup file.
+                          (let ((file (expand-file-name
+                                       (org-remove-double-quotes val))))
+                            (unless (member file files)
+                              (with-temp-buffer
+                                (let ((org-inhibit-startup t)) (org-mode))
+                                (insert (org-file-contents file 'noerror))
+                                (setq alist
+                                      (funcall collect-bind
+                                               (cons file files)
+                                               alist))))))))))
+                alist)))))
+      ;; Return value in appropriate order of appearance.
+      (nreverse (funcall collect-bind nil nil)))))
+
+
+;;;; Tree Properties
+;;
+;; Tree properties are information extracted from parse tree.  They
+;; are initialized at the beginning of the transcoding process by
+;; `org-export-collect-tree-properties'.
+;;
+;; Dedicated functions focus on computing the value of specific tree
+;; properties during initialization.  Thus,
+;; `org-export--populate-ignore-list' lists elements and objects that
+;; should be skipped during export, `org-export--get-min-level' gets
+;; the minimal exportable level, used as a basis to compute relative
+;; level for headlines.  Eventually
+;; `org-export--collect-headline-numbering' builds an alist between
+;; headlines and their numbering.
+
+(defun org-export-collect-tree-properties (data info)
+  "Extract tree properties from parse tree.
+
+DATA is the parse tree from which information is retrieved.  INFO
+is a list holding export options.
+
+Following tree properties are set or updated:
+
+`:exported-data' Hash table used to memoize results from
+                 `org-export-data'.
+
+`:footnote-definition-alist' List of footnotes definitions in
+                   original buffer and current parse tree.
+
+`:headline-offset' Offset between true level of headlines and
+                  local level.  An offset of -1 means a headline
+                  of level 2 should be considered as a level
+                  1 headline in the context.
+
+`:headline-numbering' Alist of all headlines as key an the
+                     associated numbering as value.
+
+`:ignore-list'     List of elements that should be ignored during
+                   export.
+
+Return updated plist."
+  ;; Install the parse tree in the communication channel, in order to
+  ;; use `org-export-get-genealogy' and al.
+  (setq info (plist-put info :parse-tree data))
+  ;; Get the list of elements and objects to ignore, and put it into
+  ;; `:ignore-list'.  Do not overwrite any user ignore that might have
+  ;; been done during parse tree filtering.
+  (setq info
+       (plist-put info
+                  :ignore-list
+                  (append (org-export--populate-ignore-list data info)
+                          (plist-get info :ignore-list))))
+  ;; Compute `:headline-offset' in order to be able to use
+  ;; `org-export-get-relative-level'.
+  (setq info
+       (plist-put info
+                  :headline-offset
+                  (- 1 (org-export--get-min-level data info))))
+  ;; Update footnotes definitions list with definitions in parse tree.
+  ;; This is required since buffer expansion might have modified
+  ;; boundaries of footnote definitions contained in the parse tree.
+  ;; This way, definitions in `footnote-definition-alist' are bound to
+  ;; match those in the parse tree.
+  (let ((defs (plist-get info :footnote-definition-alist)))
+    (org-element-map data 'footnote-definition
+      (lambda (fn)
+       (push (cons (org-element-property :label fn)
+                   `(org-data nil ,@(org-element-contents fn)))
+             defs)))
+    (setq info (plist-put info :footnote-definition-alist defs)))
+  ;; Properties order doesn't matter: get the rest of the tree
+  ;; properties.
+  (nconc
+   `(:headline-numbering ,(org-export--collect-headline-numbering data info)
+     :exported-data ,(make-hash-table :test 'eq :size 4001))
+   info))
+
+(defun org-export--get-min-level (data options)
+  "Return minimum exportable headline's level in DATA.
+DATA is parsed tree as returned by `org-element-parse-buffer'.
+OPTIONS is a plist holding export options."
+  (catch 'exit
+    (let ((min-level 10000))
+      (mapc
+       (lambda (blob)
+        (when (and (eq (org-element-type blob) 'headline)
+                   (not (org-element-property :footnote-section-p blob))
+                   (not (memq blob (plist-get options :ignore-list))))
+          (setq min-level (min (org-element-property :level blob) min-level)))
+        (when (= min-level 1) (throw 'exit 1)))
+       (org-element-contents data))
+      ;; If no headline was found, for the sake of consistency, set
+      ;; minimum level to 1 nonetheless.
+      (if (= min-level 10000) 1 min-level))))
+
+(defun org-export--collect-headline-numbering (data options)
+  "Return numbering of all exportable headlines in a parse tree.
+
+DATA is the parse tree.  OPTIONS is the plist holding export
+options.
+
+Return an alist whose key is a headline and value is its
+associated numbering \(in the shape of a list of numbers\) or nil
+for a footnotes section."
+  (let ((numbering (make-vector org-export-max-depth 0)))
+    (org-element-map data 'headline
+      (lambda (headline)
+       (unless (org-element-property :footnote-section-p headline)
+         (let ((relative-level
+                (1- (org-export-get-relative-level headline options))))
+           (cons
+            headline
+            (loop for n across numbering
+                  for idx from 0 to org-export-max-depth
+                  when (< idx relative-level) collect n
+                  when (= idx relative-level) collect (aset numbering idx (1+ n))
+                  when (> idx relative-level) do (aset numbering idx 0))))))
+      options)))
+
+(defun org-export--populate-ignore-list (data options)
+  "Return list of elements and objects to ignore during export.
+DATA is the parse tree to traverse.  OPTIONS is the plist holding
+export options."
+  (let* (ignore
+        walk-data
+        ;; First find trees containing a select tag, if any.
+        (selected (org-export--selected-trees data options))
+        (walk-data
+         (lambda (data)
+           ;; Collect ignored elements or objects into IGNORE-LIST.
+           (let ((type (org-element-type data)))
+             (if (org-export--skip-p data options selected) (push data ignore)
+               (if (and (eq type 'headline)
+                        (eq (plist-get options :with-archived-trees) 'headline)
+                        (org-element-property :archivedp data))
+                   ;; If headline is archived but tree below has
+                   ;; to be skipped, add it to ignore list.
+                   (mapc (lambda (e) (push e ignore))
+                         (org-element-contents data))
+                 ;; Move into secondary string, if any.
+                 (let ((sec-prop
+                        (cdr (assq type org-element-secondary-value-alist))))
+                   (when sec-prop
+                     (mapc walk-data (org-element-property sec-prop data))))
+                 ;; Move into recursive objects/elements.
+                 (mapc walk-data (org-element-contents data))))))))
+    ;; Main call.
+    (funcall walk-data data)
+    ;; Return value.
+    ignore))
+
+(defun org-export--selected-trees (data info)
+  "Return list of headlines and inlinetasks with a select tag in their tree.
+DATA is parsed data as returned by `org-element-parse-buffer'.
+INFO is a plist holding export options."
+  (let* (selected-trees
+        walk-data                      ; For byte-compiler.
+        (walk-data
+         (function
+          (lambda (data genealogy)
+            (let ((type (org-element-type data)))
+              (cond
+               ((memq type '(headline inlinetask))
+                (let ((tags (org-element-property :tags data)))
+                  (if (loop for tag in (plist-get info :select-tags)
+                            thereis (member tag tags))
+                      ;; When a select tag is found, mark full
+                      ;; genealogy and every headline within the tree
+                      ;; as acceptable.
+                      (setq selected-trees
+                            (append
+                             genealogy
+                             (org-element-map data '(headline inlinetask)
+                               'identity)
+                             selected-trees))
+                    ;; If at a headline, continue searching in tree,
+                    ;; recursively.
+                    (when (eq type 'headline)
+                      (mapc (lambda (el)
+                              (funcall walk-data el (cons data genealogy)))
+                            (org-element-contents data))))))
+               ((or (eq type 'org-data)
+                    (memq type org-element-greater-elements))
+                (mapc (lambda (el) (funcall walk-data el genealogy))
+                      (org-element-contents data)))))))))
+    (funcall walk-data data nil)
+    selected-trees))
+
+(defun org-export--skip-p (blob options selected)
+  "Non-nil when element or object BLOB should be skipped during export.
+OPTIONS is the plist holding export options.  SELECTED, when
+non-nil, is a list of headlines or inlinetasks belonging to
+a tree with a select tag."
+  (case (org-element-type blob)
+    (clock (not (plist-get options :with-clocks)))
+    (drawer
+     (let ((with-drawers-p (plist-get options :with-drawers)))
+       (or (not with-drawers-p)
+          (and (consp with-drawers-p)
+               ;; If `:with-drawers' value starts with `not', ignore
+               ;; every drawer whose name belong to that list.
+               ;; Otherwise, ignore drawers whose name isn't in that
+               ;; list.
+               (let ((name (org-element-property :drawer-name blob)))
+                 (if (eq (car with-drawers-p) 'not)
+                     (member-ignore-case name (cdr with-drawers-p))
+                   (not (member-ignore-case name with-drawers-p))))))))
+    ((footnote-definition footnote-reference)
+     (not (plist-get options :with-footnotes)))
+    ((headline inlinetask)
+     (let ((with-tasks (plist-get options :with-tasks))
+          (todo (org-element-property :todo-keyword blob))
+          (todo-type (org-element-property :todo-type blob))
+          (archived (plist-get options :with-archived-trees))
+          (tags (org-element-property :tags blob)))
+       (or
+       (and (eq (org-element-type blob) 'inlinetask)
+            (not (plist-get options :with-inlinetasks)))
+       ;; Ignore subtrees with an exclude tag.
+       (loop for k in (plist-get options :exclude-tags)
+             thereis (member k tags))
+       ;; When a select tag is present in the buffer, ignore any tree
+       ;; without it.
+       (and selected (not (memq blob selected)))
+       ;; Ignore commented sub-trees.
+       (org-element-property :commentedp blob)
+       ;; Ignore archived subtrees if `:with-archived-trees' is nil.
+       (and (not archived) (org-element-property :archivedp blob))
+       ;; Ignore tasks, if specified by `:with-tasks' property.
+       (and todo
+            (or (not with-tasks)
+                (and (memq with-tasks '(todo done))
+                     (not (eq todo-type with-tasks)))
+                (and (consp with-tasks) (not (member todo with-tasks))))))))
+    ((latex-environment latex-fragment) (not (plist-get options :with-latex)))
+    (planning (not (plist-get options :with-planning)))
+    (statistics-cookie (not (plist-get options :with-statistics-cookies)))
+    (table-cell
+     (and (org-export-table-has-special-column-p
+          (org-export-get-parent-table blob))
+         (not (org-export-get-previous-element blob options))))
+    (table-row (org-export-table-row-is-special-p blob options))
+    (timestamp
+     ;; `:with-timestamps' only applies to isolated timestamps
+     ;; objects, i.e. timestamp objects in a paragraph containing only
+     ;; timestamps and whitespaces.
+     (when (let ((parent (org-export-get-parent-element blob)))
+            (and (memq (org-element-type parent) '(paragraph verse-block))
+                 (not (org-element-map parent
+                          (cons 'plain-text
+                                (remq 'timestamp org-element-all-objects))
+                        (lambda (obj)
+                          (or (not (stringp obj)) (org-string-nw-p obj)))
+                        options t))))
+       (case (plist-get options :with-timestamps)
+        ('nil t)
+        (active
+         (not (memq (org-element-property :type blob) '(active active-range))))
+        (inactive
+         (not (memq (org-element-property :type blob)
+                    '(inactive inactive-range)))))))))
+
+\f
+;;; The Transcoder
+;;
+;; `org-export-data' reads a parse tree (obtained with, i.e.
+;; `org-element-parse-buffer') and transcodes it into a specified
+;; back-end output.  It takes care of filtering out elements or
+;; objects according to export options and organizing the output blank
+;; lines and white space are preserved.  The function memoizes its
+;; results, so it is cheap to call it within transcoders.
+;;
+;; It is possible to modify locally the back-end used by
+;; `org-export-data' or even use a temporary back-end by using
+;; `org-export-data-with-backend'.
+;;
+;; Internally, three functions handle the filtering of objects and
+;; elements during the export.  In particular,
+;; `org-export-ignore-element' marks an element or object so future
+;; parse tree traversals skip it, `org-export--interpret-p' tells which
+;; elements or objects should be seen as real Org syntax and
+;; `org-export-expand' transforms the others back into their original
+;; shape
+;;
+;; `org-export-transcoder' is an accessor returning appropriate
+;; translator function for a given element or object.
+
+(defun org-export-transcoder (blob info)
+  "Return appropriate transcoder for BLOB.
+INFO is a plist containing export directives."
+  (let ((type (org-element-type blob)))
+    ;; Return contents only for complete parse trees.
+    (if (eq type 'org-data) (lambda (blob contents info) contents)
+      (let ((transcoder (cdr (assq type (plist-get info :translate-alist)))))
+       (and (functionp transcoder) transcoder)))))
+
+(defun org-export-data (data info)
+  "Convert DATA into current back-end format.
+
+DATA is a parse tree, an element or an object or a secondary
+string.  INFO is a plist holding export options.
+
+Return transcoded string."
+  (let ((memo (gethash data (plist-get info :exported-data) 'no-memo)))
+    (if (not (eq memo 'no-memo)) memo
+      (let* ((type (org-element-type data))
+            (results
+             (cond
+              ;; Ignored element/object.
+              ((memq data (plist-get info :ignore-list)) nil)
+              ;; Plain text.
+              ((eq type 'plain-text)
+               (org-export-filter-apply-functions
+                (plist-get info :filter-plain-text)
+                (let ((transcoder (org-export-transcoder data info)))
+                  (if transcoder (funcall transcoder data info) data))
+                info))
+              ;; Uninterpreted element/object: change it back to Org
+              ;; syntax and export again resulting raw string.
+              ((not (org-export--interpret-p data info))
+               (org-export-data
+                (org-export-expand
+                 data
+                 (mapconcat (lambda (blob) (org-export-data blob info))
+                            (org-element-contents data)
+                            ""))
+                info))
+              ;; Secondary string.
+              ((not type)
+               (mapconcat (lambda (obj) (org-export-data obj info)) data ""))
+              ;; Element/Object without contents or, as a special case,
+              ;; headline with archive tag and archived trees restricted
+              ;; to title only.
+              ((or (not (org-element-contents data))
+                   (and (eq type 'headline)
+                        (eq (plist-get info :with-archived-trees) 'headline)
+                        (org-element-property :archivedp data)))
+               (let ((transcoder (org-export-transcoder data info)))
+                 (or (and (functionp transcoder)
+                          (funcall transcoder data nil info))
+                     ;; Export snippets never return a nil value so
+                     ;; that white spaces following them are never
+                     ;; ignored.
+                     (and (eq type 'export-snippet) ""))))
+              ;; Element/Object with contents.
+              (t
+               (let ((transcoder (org-export-transcoder data info)))
+                 (when transcoder
+                   (let* ((greaterp (memq type org-element-greater-elements))
+                          (objectp
+                           (and (not greaterp)
+                                (memq type org-element-recursive-objects)))
+                          (contents
+                           (mapconcat
+                            (lambda (element) (org-export-data element info))
+                            (org-element-contents
+                             (if (or greaterp objectp) data
+                               ;; Elements directly containing objects
+                               ;; must have their indentation normalized
+                               ;; first.
+                               (org-element-normalize-contents
+                                data
+                                ;; When normalizing contents of the first
+                                ;; paragraph in an item or a footnote
+                                ;; definition, ignore first line's
+                                ;; indentation: there is none and it
+                                ;; might be misleading.
+                                (when (eq type 'paragraph)
+                                  (let ((parent (org-export-get-parent data)))
+                                    (and
+                                     (eq (car (org-element-contents parent))
+                                         data)
+                                     (memq (org-element-type parent)
+                                           '(footnote-definition item))))))))
+                            "")))
+                     (funcall transcoder data
+                              (if (not greaterp) contents
+                                (org-element-normalize-string contents))
+                              info))))))))
+       ;; Final result will be memoized before being returned.
+       (puthash
+        data
+        (cond
+         ((not results) nil)
+         ((memq type '(org-data plain-text nil)) results)
+         ;; Append the same white space between elements or objects as in
+         ;; the original buffer, and call appropriate filters.
+         (t
+          (let ((results
+                 (org-export-filter-apply-functions
+                  (plist-get info (intern (format ":filter-%s" type)))
+                  (let ((post-blank (or (org-element-property :post-blank data)
+                                        0)))
+                    (if (memq type org-element-all-elements)
+                        (concat (org-element-normalize-string results)
+                                (make-string post-blank ?\n))
+                      (concat results (make-string post-blank ? ))))
+                  info)))
+            results)))
+        (plist-get info :exported-data))))))
+
+(defun org-export-data-with-backend (data backend info)
+  "Convert DATA into BACKEND format.
+
+DATA is an element, an object, a secondary string or a string.
+BACKEND is a symbol.  INFO is a plist used as a communication
+channel.
+
+Unlike to `org-export-with-backend', this function will
+recursively convert DATA using BACKEND translation table."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (org-export-data
+   data
+   ;; Set-up a new communication channel with translations defined in
+   ;; BACKEND as the translate table and a new hash table for
+   ;; memoization.
+   (org-combine-plists
+    info
+    (list :back-end backend
+         :translate-alist (org-export-get-all-transcoders backend)
+         ;; Size of the hash table is reduced since this function
+         ;; will probably be used on small trees.
+         :exported-data (make-hash-table :test 'eq :size 401)))))
+
+(defun org-export--interpret-p (blob info)
+  "Non-nil if element or object BLOB should be interpreted during export.
+If nil, BLOB will appear as raw Org syntax.  Check is done
+according to export options INFO, stored as a plist."
+  (case (org-element-type blob)
+    ;; ... entities...
+    (entity (plist-get info :with-entities))
+    ;; ... emphasis...
+    ((bold italic strike-through underline)
+     (plist-get info :with-emphasize))
+    ;; ... fixed-width areas.
+    (fixed-width (plist-get info :with-fixed-width))
+    ;; ... LaTeX environments and fragments...
+    ((latex-environment latex-fragment)
+     (let ((with-latex-p (plist-get info :with-latex)))
+       (and with-latex-p (not (eq with-latex-p 'verbatim)))))
+    ;; ... sub/superscripts...
+    ((subscript superscript)
+     (let ((sub/super-p (plist-get info :with-sub-superscript)))
+       (if (eq sub/super-p '{})
+          (org-element-property :use-brackets-p blob)
+        sub/super-p)))
+    ;; ... tables...
+    (table (plist-get info :with-tables))
+    (otherwise t)))
+
+(defun org-export-expand (blob contents &optional with-affiliated)
+  "Expand a parsed element or object to its original state.
+
+BLOB is either an element or an object.  CONTENTS is its
+contents, as a string or nil.
+
+When optional argument WITH-AFFILIATED is non-nil, add affiliated
+keywords before output."
+  (let ((type (org-element-type blob)))
+    (concat (and with-affiliated (memq type org-element-all-elements)
+                (org-element--interpret-affiliated-keywords blob))
+           (funcall (intern (format "org-element-%s-interpreter" type))
+                    blob contents))))
+
+(defun org-export-ignore-element (element info)
+  "Add ELEMENT to `:ignore-list' in INFO.
+
+Any element in `:ignore-list' will be skipped when using
+`org-element-map'.  INFO is modified by side effects."
+  (plist-put info :ignore-list (cons element (plist-get info :ignore-list))))
+
+
+\f
+;;; The Filter System
+;;
+;; Filters allow end-users to tweak easily the transcoded output.
+;; They are the functional counterpart of hooks, as every filter in
+;; a set is applied to the return value of the previous one.
+;;
+;; Every set is back-end agnostic.  Although, a filter is always
+;; called, in addition to the string it applies to, with the back-end
+;; used as argument, so it's easy for the end-user to add back-end
+;; specific filters in the set.  The communication channel, as
+;; a plist, is required as the third argument.
+;;
+;; From the developer side, filters sets can be installed in the
+;; process with the help of `org-export-define-backend', which
+;; internally stores filters as an alist.  Each association has a key
+;; among the following symbols and a function or a list of functions
+;; as value.
+;;
+;; - `:filter-options' applies to the property list containing export
+;;   options.  Unlike to other filters, functions in this list accept
+;;   two arguments instead of three: the property list containing
+;;   export options and the back-end.  Users can set its value through
+;;   `org-export-filter-options-functions' variable.
+;;
+;; - `:filter-parse-tree' applies directly to the complete parsed
+;;   tree.  Users can set it through
+;;   `org-export-filter-parse-tree-functions' variable.
+;;
+;; - `:filter-final-output' applies to the final transcoded string.
+;;   Users can set it with `org-export-filter-final-output-functions'
+;;   variable
+;;
+;; - `:filter-plain-text' applies to any string not recognized as Org
+;;   syntax.  `org-export-filter-plain-text-functions' allows users to
+;;   configure it.
+;;
+;; - `:filter-TYPE' applies on the string returned after an element or
+;;   object of type TYPE has been transcoded.  A user can modify
+;;   `org-export-filter-TYPE-functions'
+;;
+;; All filters sets are applied with
+;; `org-export-filter-apply-functions' function.  Filters in a set are
+;; applied in a LIFO fashion.  It allows developers to be sure that
+;; their filters will be applied first.
+;;
+;; Filters properties are installed in communication channel with
+;; `org-export-install-filters' function.
+;;
+;; Eventually, two hooks (`org-export-before-processing-hook' and
+;; `org-export-before-parsing-hook') are run at the beginning of the
+;; export process and just before parsing to allow for heavy structure
+;; modifications.
+
+
+;;;; Hooks
+
+(defvar org-export-before-processing-hook nil
+  "Hook run at the beginning of the export process.
+
+This is run before include keywords and macros are expanded and
+Babel code blocks executed, on a copy of the original buffer
+being exported.  Visibility and narrowing are preserved.  Point
+is at the beginning of the buffer.
+
+Every function in this hook will be called with one argument: the
+back-end currently used, as a symbol.")
+
+(defvar org-export-before-parsing-hook nil
+  "Hook run before parsing an export buffer.
+
+This is run after include keywords and macros have been expanded
+and Babel code blocks executed, on a copy of the original buffer
+being exported.  Visibility and narrowing are preserved.  Point
+is at the beginning of the buffer.
+
+Every function in this hook will be called with one argument: the
+back-end currently used, as a symbol.")
+
+
+;;;; Special Filters
+
+(defvar org-export-filter-options-functions nil
+  "List of functions applied to the export options.
+Each filter is called with two arguments: the export options, as
+a plist, and the back-end, as a symbol.  It must return
+a property list containing export options.")
+
+(defvar org-export-filter-parse-tree-functions nil
+  "List of functions applied to the parsed tree.
+Each filter is called with three arguments: the parse tree, as
+returned by `org-element-parse-buffer', the back-end, as
+a symbol, and the communication channel, as a plist.  It must
+return the modified parse tree to transcode.")
+
+(defvar org-export-filter-plain-text-functions nil
+  "List of functions applied to plain text.
+Each filter is called with three arguments: a string which
+contains no Org syntax, the back-end, as a symbol, and the
+communication channel, as a plist.  It must return a string or
+nil.")
+
+(defvar org-export-filter-final-output-functions nil
+  "List of functions applied to the transcoded string.
+Each filter is called with three arguments: the full transcoded
+string, the back-end, as a symbol, and the communication channel,
+as a plist.  It must return a string that will be used as the
+final export output.")
+
+
+;;;; Elements Filters
+
+(defvar org-export-filter-babel-call-functions nil
+  "List of functions applied to a transcoded babel-call.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-center-block-functions nil
+  "List of functions applied to a transcoded center block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-clock-functions nil
+  "List of functions applied to a transcoded clock.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-comment-functions nil
+  "List of functions applied to a transcoded comment.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-comment-block-functions nil
+  "List of functions applied to a transcoded comment-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-diary-sexp-functions nil
+  "List of functions applied to a transcoded diary-sexp.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-drawer-functions nil
+  "List of functions applied to a transcoded drawer.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-dynamic-block-functions nil
+  "List of functions applied to a transcoded dynamic-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-example-block-functions nil
+  "List of functions applied to a transcoded example-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-export-block-functions nil
+  "List of functions applied to a transcoded export-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-fixed-width-functions nil
+  "List of functions applied to a transcoded fixed-width.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-footnote-definition-functions nil
+  "List of functions applied to a transcoded footnote-definition.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-headline-functions nil
+  "List of functions applied to a transcoded headline.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-horizontal-rule-functions nil
+  "List of functions applied to a transcoded horizontal-rule.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-inlinetask-functions nil
+  "List of functions applied to a transcoded inlinetask.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-item-functions nil
+  "List of functions applied to a transcoded item.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-keyword-functions nil
+  "List of functions applied to a transcoded keyword.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-latex-environment-functions nil
+  "List of functions applied to a transcoded latex-environment.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-node-property-functions nil
+  "List of functions applied to a transcoded node-property.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-paragraph-functions nil
+  "List of functions applied to a transcoded paragraph.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-plain-list-functions nil
+  "List of functions applied to a transcoded plain-list.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-planning-functions nil
+  "List of functions applied to a transcoded planning.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-property-drawer-functions nil
+  "List of functions applied to a transcoded property-drawer.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-quote-block-functions nil
+  "List of functions applied to a transcoded quote block.
+Each filter is called with three arguments: the transcoded quote
+data, as a string, the back-end, as a symbol, and the
+communication channel, as a plist.  It must return a string or
+nil.")
+
+(defvar org-export-filter-quote-section-functions nil
+  "List of functions applied to a transcoded quote-section.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-section-functions nil
+  "List of functions applied to a transcoded section.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-special-block-functions nil
+  "List of functions applied to a transcoded special block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-src-block-functions nil
+  "List of functions applied to a transcoded src-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-table-functions nil
+  "List of functions applied to a transcoded table.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-table-cell-functions nil
+  "List of functions applied to a transcoded table-cell.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-table-row-functions nil
+  "List of functions applied to a transcoded table-row.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-verse-block-functions nil
+  "List of functions applied to a transcoded verse block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+
+;;;; Objects Filters
+
+(defvar org-export-filter-bold-functions nil
+  "List of functions applied to transcoded bold text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-code-functions nil
+  "List of functions applied to transcoded code text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-entity-functions nil
+  "List of functions applied to a transcoded entity.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-export-snippet-functions nil
+  "List of functions applied to a transcoded export-snippet.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-footnote-reference-functions nil
+  "List of functions applied to a transcoded footnote-reference.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-inline-babel-call-functions nil
+  "List of functions applied to a transcoded inline-babel-call.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-inline-src-block-functions nil
+  "List of functions applied to a transcoded inline-src-block.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-italic-functions nil
+  "List of functions applied to transcoded italic text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-latex-fragment-functions nil
+  "List of functions applied to a transcoded latex-fragment.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-line-break-functions nil
+  "List of functions applied to a transcoded line-break.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-link-functions nil
+  "List of functions applied to a transcoded link.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-radio-target-functions nil
+  "List of functions applied to a transcoded radio-target.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-statistics-cookie-functions nil
+  "List of functions applied to a transcoded statistics-cookie.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-strike-through-functions nil
+  "List of functions applied to transcoded strike-through text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-subscript-functions nil
+  "List of functions applied to a transcoded subscript.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-superscript-functions nil
+  "List of functions applied to a transcoded superscript.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-target-functions nil
+  "List of functions applied to a transcoded target.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-timestamp-functions nil
+  "List of functions applied to a transcoded timestamp.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-underline-functions nil
+  "List of functions applied to transcoded underline text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+(defvar org-export-filter-verbatim-functions nil
+  "List of functions applied to transcoded verbatim text.
+Each filter is called with three arguments: the transcoded data,
+as a string, the back-end, as a symbol, and the communication
+channel, as a plist.  It must return a string or nil.")
+
+
+;;;; Filters Tools
+;;
+;; Internal function `org-export-install-filters' installs filters
+;; hard-coded in back-ends (developer filters) and filters from global
+;; variables (user filters) in the communication channel.
+;;
+;; Internal function `org-export-filter-apply-functions' takes care
+;; about applying each filter in order to a given data.  It ignores
+;; filters returning a nil value but stops whenever a filter returns
+;; an empty string.
+
+(defun org-export-filter-apply-functions (filters value info)
+  "Call every function in FILTERS.
+
+Functions are called with arguments VALUE, current export
+back-end's name and INFO.  A function returning a nil value will
+be skipped.  If it returns the empty string, the process ends and
+VALUE is ignored.
+
+Call is done in a LIFO fashion, to be sure that developer
+specified filters, if any, are called first."
+  (catch 'exit
+    (let* ((backend (plist-get info :back-end))
+          (backend-name (and backend (org-export-backend-name backend))))
+      (dolist (filter filters value)
+       (let ((result (funcall filter value backend-name info)))
+         (cond ((not result) value)
+               ((equal value "") (throw 'exit nil))
+               (t (setq value result))))))))
+
+(defun org-export-install-filters (info)
+  "Install filters properties in communication channel.
+INFO is a plist containing the current communication channel.
+Return the updated communication channel."
+  (let (plist)
+    ;; Install user-defined filters with `org-export-filters-alist'
+    ;; and filters already in INFO (through ext-plist mechanism).
+    (mapc (lambda (p)
+           (let* ((prop (car p))
+                  (info-value (plist-get info prop))
+                  (default-value (symbol-value (cdr p))))
+             (setq plist
+                   (plist-put plist prop
+                              ;; Filters in INFO will be called
+                              ;; before those user provided.
+                              (append (if (listp info-value) info-value
+                                        (list info-value))
+                                      default-value)))))
+         org-export-filters-alist)
+    ;; Prepend back-end specific filters to that list.
+    (mapc (lambda (p)
+           ;; Single values get consed, lists are appended.
+           (let ((key (car p)) (value (cdr p)))
+             (when value
+               (setq plist
+                     (plist-put
+                      plist key
+                      (if (atom value) (cons value (plist-get plist key))
+                        (append value (plist-get plist key))))))))
+         (org-export-get-all-filters (plist-get info :back-end)))
+    ;; Return new communication channel.
+    (org-combine-plists info plist)))
+
+
+\f
+;;; Core functions
+;;
+;; This is the room for the main function, `org-export-as', along with
+;; its derivative, `org-export-string-as'.
+;; `org-export--copy-to-kill-ring-p' determines if output of these
+;; function should be added to kill ring.
+;;
+;; Note that `org-export-as' doesn't really parse the current buffer,
+;; but a copy of it (with the same buffer-local variables and
+;; visibility), where macros and include keywords are expanded and
+;; Babel blocks are executed, if appropriate.
+;; `org-export-with-buffer-copy' macro prepares that copy.
+;;
+;; File inclusion is taken care of by
+;; `org-export-expand-include-keyword' and
+;; `org-export--prepare-file-contents'.  Structure wise, including
+;; a whole Org file in a buffer often makes little sense.  For
+;; example, if the file contains a headline and the include keyword
+;; was within an item, the item should contain the headline.  That's
+;; why file inclusion should be done before any structure can be
+;; associated to the file, that is before parsing.
+;;
+;; `org-export-insert-default-template' is a command to insert
+;; a default template (or a back-end specific template) at point or in
+;; current subtree.
+
+(defun org-export-copy-buffer ()
+  "Return a copy of the current buffer.
+The copy preserves Org buffer-local variables, visibility and
+narrowing."
+  (let ((copy-buffer-fun (org-export--generate-copy-script (current-buffer)))
+       (new-buf (generate-new-buffer (buffer-name))))
+    (with-current-buffer new-buf
+      (funcall copy-buffer-fun)
+      (set-buffer-modified-p nil))
+    new-buf))
+
+(defmacro org-export-with-buffer-copy (&rest body)
+  "Apply BODY in a copy of the current buffer.
+The copy preserves local variables, visibility and contents of
+the original buffer.  Point is at the beginning of the buffer
+when BODY is applied."
+  (declare (debug t))
+  (org-with-gensyms (buf-copy)
+    `(let ((,buf-copy (org-export-copy-buffer)))
+       (unwind-protect
+          (with-current-buffer ,buf-copy
+            (goto-char (point-min))
+            (progn ,@body))
+        (and (buffer-live-p ,buf-copy)
+             ;; Kill copy without confirmation.
+             (progn (with-current-buffer ,buf-copy
+                      (restore-buffer-modified-p nil))
+                    (kill-buffer ,buf-copy)))))))
+
+(defun org-export--generate-copy-script (buffer)
+  "Generate a function duplicating BUFFER.
+
+The copy will preserve local variables, visibility, contents and
+narrowing of the original buffer.  If a region was active in
+BUFFER, contents will be narrowed to that region instead.
+
+The resulting function can be evaluated at a later time, from
+another buffer, effectively cloning the original buffer there.
+
+The function assumes BUFFER's major mode is `org-mode'."
+  (with-current-buffer buffer
+    `(lambda ()
+       (let ((inhibit-modification-hooks t))
+        ;; Set major mode. Ignore `org-mode-hook' as it has been run
+        ;; already in BUFFER.
+        (let ((org-mode-hook nil) (org-inhibit-startup t)) (org-mode))
+        ;; Copy specific buffer local variables and variables set
+        ;; through BIND keywords.
+        ,@(let ((bound-variables (org-export--list-bound-variables))
+                vars)
+            (dolist (entry (buffer-local-variables (buffer-base-buffer)) vars)
+              (when (consp entry)
+                (let ((var (car entry))
+                      (val (cdr entry)))
+                  (and (not (eq var 'org-font-lock-keywords))
+                       (or (memq var
+                                 '(default-directory
+                                    buffer-file-name
+                                    buffer-file-coding-system))
+                           (assq var bound-variables)
+                           (string-match "^\\(org-\\|orgtbl-\\)"
+                                         (symbol-name var)))
+                       ;; Skip unreadable values, as they cannot be
+                       ;; sent to external process.
+                       (or (not val) (ignore-errors (read (format "%S" val))))
+                       (push `(set (make-local-variable (quote ,var))
+                                   (quote ,val))
+                             vars))))))
+        ;; Whole buffer contents.
+        (insert
+         ,(org-with-wide-buffer
+           (buffer-substring-no-properties
+            (point-min) (point-max))))
+        ;; Narrowing.
+        ,(if (org-region-active-p)
+             `(narrow-to-region ,(region-beginning) ,(region-end))
+           `(narrow-to-region ,(point-min) ,(point-max)))
+        ;; Current position of point.
+        (goto-char ,(point))
+        ;; Overlays with invisible property.
+        ,@(let (ov-set)
+            (mapc
+             (lambda (ov)
+               (let ((invis-prop (overlay-get ov 'invisible)))
+                 (when invis-prop
+                   (push `(overlay-put
+                           (make-overlay ,(overlay-start ov)
+                                         ,(overlay-end ov))
+                           'invisible (quote ,invis-prop))
+                         ov-set))))
+             (overlays-in (point-min) (point-max)))
+            ov-set)))))
+
+;;;###autoload
+(defun org-export-as
+  (backend &optional subtreep visible-only body-only ext-plist)
+  "Transcode current Org buffer into BACKEND code.
+
+BACKEND is either an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.
+
+If narrowing is active in the current buffer, only transcode its
+narrowed part.
+
+If a region is active, transcode that region.
+
+When optional argument SUBTREEP is non-nil, transcode the
+sub-tree at point, extracting information from the headline
+properties first.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+When optional argument BODY-ONLY is non-nil, only return body
+code, without surrounding template.
+
+Optional argument EXT-PLIST, when provided, is a property list
+with external parameters overriding Org default settings, but
+still inferior to file-local settings.
+
+Return code as a string."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (org-export-barf-if-invalid-backend backend)
+  (save-excursion
+    (save-restriction
+      ;; Narrow buffer to an appropriate region or subtree for
+      ;; parsing.  If parsing subtree, be sure to remove main headline
+      ;; too.
+      (cond ((org-region-active-p)
+            (narrow-to-region (region-beginning) (region-end)))
+           (subtreep
+            (org-narrow-to-subtree)
+            (goto-char (point-min))
+            (forward-line)
+            (narrow-to-region (point) (point-max))))
+      ;; Initialize communication channel with original buffer
+      ;; attributes, unavailable in its copy.
+      (let* ((org-export-current-backend (org-export-backend-name backend))
+            (info (org-combine-plists
+                   (list :export-options
+                         (delq nil
+                               (list (and subtreep 'subtree)
+                                     (and visible-only 'visible-only)
+                                     (and body-only 'body-only))))
+                   (org-export--get-buffer-attributes)))
+            tree)
+       ;; Update communication channel and get parse tree.  Buffer
+       ;; isn't parsed directly.  Instead, a temporary copy is
+       ;; created, where include keywords, macros are expanded and
+       ;; code blocks are evaluated.
+       (org-export-with-buffer-copy
+        ;; Run first hook with current back-end's name as argument.
+        (run-hook-with-args 'org-export-before-processing-hook
+                            (org-export-backend-name backend))
+        (org-export-expand-include-keyword)
+        ;; Update macro templates since #+INCLUDE keywords might have
+        ;; added some new ones.
+        (org-macro-initialize-templates)
+        (org-macro-replace-all org-macro-templates)
+        (org-export-execute-babel-code)
+        ;; Update radio targets since keyword inclusion might have
+        ;; added some more.
+        (org-update-radio-target-regexp)
+        ;; Run last hook with current back-end's name as argument.
+        (goto-char (point-min))
+        (save-excursion
+          (run-hook-with-args 'org-export-before-parsing-hook
+                              (org-export-backend-name backend)))
+        ;; Update communication channel with environment.  Also
+        ;; install user's and developer's filters.
+        (setq info
+              (org-export-install-filters
+               (org-combine-plists
+                info (org-export-get-environment backend subtreep ext-plist))))
+        ;; Expand export-specific set of macros: {{{author}}},
+        ;; {{{date}}}, {{{email}}} and {{{title}}}.  It must be done
+        ;; once regular macros have been expanded, since document
+        ;; keywords may contain one of them.
+        (org-macro-replace-all
+         (list (cons "author"
+                     (org-element-interpret-data (plist-get info :author)))
+               (cons "date"
+                     (org-element-interpret-data (plist-get info :date)))
+               ;; EMAIL is not a parsed keyword: store it as-is.
+               (cons "email" (or (plist-get info :email) ""))
+               (cons "title"
+                     (org-element-interpret-data (plist-get info :title)))))
+        ;; Call options filters and update export options.  We do not
+        ;; use `org-export-filter-apply-functions' here since the
+        ;; arity of such filters is different.
+        (let ((backend-name (org-export-backend-name backend)))
+          (dolist (filter (plist-get info :filter-options))
+            (let ((result (funcall filter info backend-name)))
+              (when result (setq info result)))))
+        ;; Parse buffer and call parse-tree filter on it.
+        (setq tree
+              (org-export-filter-apply-functions
+               (plist-get info :filter-parse-tree)
+               (org-element-parse-buffer nil visible-only) info))
+        ;; Now tree is complete, compute its properties and add them
+        ;; to communication channel.
+        (setq info
+              (org-combine-plists
+               info (org-export-collect-tree-properties tree info)))
+        ;; Eventually transcode TREE.  Wrap the resulting string into
+        ;; a template.
+        (let* ((body (org-element-normalize-string
+                      (or (org-export-data tree info) "")))
+               (inner-template (cdr (assq 'inner-template
+                                          (plist-get info :translate-alist))))
+               (full-body (if (not (functionp inner-template)) body
+                            (funcall inner-template body info)))
+               (template (cdr (assq 'template
+                                    (plist-get info :translate-alist)))))
+          ;; Remove all text properties since they cannot be
+          ;; retrieved from an external process.  Finally call
+          ;; final-output filter and return result.
+          (org-no-properties
+           (org-export-filter-apply-functions
+            (plist-get info :filter-final-output)
+            (if (or (not (functionp template)) body-only) full-body
+              (funcall template full-body info))
+            info))))))))
+
+;;;###autoload
+(defun org-export-string-as (string backend &optional body-only ext-plist)
+  "Transcode STRING into BACKEND code.
+
+BACKEND is either an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.
+
+When optional argument BODY-ONLY is non-nil, only return body
+code, without preamble nor postamble.
+
+Optional argument EXT-PLIST, when provided, is a property list
+with external parameters overriding Org default settings, but
+still inferior to file-local settings.
+
+Return code as a string."
+  (with-temp-buffer
+    (insert string)
+    (let ((org-inhibit-startup t)) (org-mode))
+    (org-export-as backend nil nil body-only ext-plist)))
+
+;;;###autoload
+(defun org-export-replace-region-by (backend)
+  "Replace the active region by its export to BACKEND.
+BACKEND is either an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end."
+  (if (not (org-region-active-p))
+      (user-error "No active region to replace")
+    (let* ((beg (region-beginning))
+          (end (region-end))
+          (str (buffer-substring beg end)) rpl)
+      (setq rpl (org-export-string-as str backend t))
+      (delete-region beg end)
+      (insert rpl))))
+
+;;;###autoload
+(defun org-export-insert-default-template (&optional backend subtreep)
+  "Insert all export keywords with default values at beginning of line.
+
+BACKEND is a symbol referring to the name of a registered export
+back-end, for which specific export options should be added to
+the template, or `default' for default template.  When it is nil,
+the user will be prompted for a category.
+
+If SUBTREEP is non-nil, export configuration will be set up
+locally for the subtree through node properties."
+  (interactive)
+  (unless (derived-mode-p 'org-mode) (user-error "Not in an Org mode buffer"))
+  (when (and subtreep (org-before-first-heading-p))
+    (user-error "No subtree to set export options for"))
+  (let ((node (and subtreep (save-excursion (org-back-to-heading t) (point))))
+       (backend
+        (or backend
+            (intern
+             (org-completing-read
+              "Options category: "
+              (cons "default"
+                    (mapcar (lambda (b)
+                              (symbol-name (org-export-backend-name b)))
+                            org-export--registered-backends))))))
+       options keywords)
+    ;; Populate OPTIONS and KEYWORDS.
+    (dolist (entry (cond ((eq backend 'default) org-export-options-alist)
+                        ((org-export-backend-p backend)
+                         (org-export-get-all-options backend))
+                        (t (org-export-get-all-options
+                            (org-export-get-backend backend)))))
+      (let ((keyword (nth 1 entry))
+            (option (nth 2 entry)))
+        (cond
+         (keyword (unless (assoc keyword keywords)
+                    (let ((value
+                           (if (eq (nth 4 entry) 'split)
+                               (mapconcat 'identity (eval (nth 3 entry)) " ")
+                             (eval (nth 3 entry)))))
+                      (push (cons keyword value) keywords))))
+         (option (unless (assoc option options)
+                   (push (cons option (eval (nth 3 entry))) options))))))
+    ;; Move to an appropriate location in order to insert options.
+    (unless subtreep (beginning-of-line))
+    ;; First get TITLE, DATE, AUTHOR and EMAIL if they belong to the
+    ;; list of available keywords.
+    (when (assoc "TITLE" keywords)
+      (let ((title
+            (or (let ((visited-file (buffer-file-name (buffer-base-buffer))))
+                  (and visited-file
+                       (file-name-sans-extension
+                        (file-name-nondirectory visited-file))))
+                (buffer-name (buffer-base-buffer)))))
+       (if (not subtreep) (insert (format "#+TITLE: %s\n" title))
+         (org-entry-put node "EXPORT_TITLE" title))))
+    (when (assoc "DATE" keywords)
+      (let ((date (with-temp-buffer (org-insert-time-stamp (current-time)))))
+       (if (not subtreep) (insert "#+DATE: " date "\n")
+         (org-entry-put node "EXPORT_DATE" date))))
+    (when (assoc "AUTHOR" keywords)
+      (let ((author (cdr (assoc "AUTHOR" keywords))))
+       (if subtreep (org-entry-put node "EXPORT_AUTHOR" author)
+         (insert
+          (format "#+AUTHOR:%s\n"
+                  (if (not (org-string-nw-p author)) ""
+                    (concat " " author)))))))
+    (when (assoc "EMAIL" keywords)
+      (let ((email (cdr (assoc "EMAIL" keywords))))
+       (if subtreep (org-entry-put node "EXPORT_EMAIL" email)
+         (insert
+          (format "#+EMAIL:%s\n"
+                  (if (not (org-string-nw-p email)) ""
+                    (concat " " email)))))))
+    ;; Then (multiple) OPTIONS lines.  Never go past fill-column.
+    (when options
+      (let ((items
+            (mapcar
+             #'(lambda (opt) (format "%s:%S" (car opt) (cdr opt)))
+             (sort options (lambda (k1 k2) (string< (car k1) (car k2)))))))
+       (if subtreep
+           (org-entry-put
+            node "EXPORT_OPTIONS" (mapconcat 'identity items " "))
+         (while items
+           (insert "#+OPTIONS:")
+           (let ((width 10))
+             (while (and items
+                         (< (+ width (length (car items)) 1) fill-column))
+               (let ((item (pop items)))
+                 (insert " " item)
+                 (incf width (1+ (length item))))))
+           (insert "\n")))))
+    ;; And the rest of keywords.
+    (dolist (key (sort keywords (lambda (k1 k2) (string< (car k1) (car k2)))))
+      (unless (member (car key) '("TITLE" "DATE" "AUTHOR" "EMAIL"))
+        (let ((val (cdr key)))
+          (if subtreep (org-entry-put node (concat "EXPORT_" (car key)) val)
+            (insert
+             (format "#+%s:%s\n"
+                     (car key)
+                     (if (org-string-nw-p val) (format " %s" val) "")))))))))
+
+(defun org-export-expand-include-keyword (&optional included dir)
+  "Expand every include keyword in buffer.
+Optional argument INCLUDED is a list of included file names along
+with their line restriction, when appropriate.  It is used to
+avoid infinite recursion.  Optional argument DIR is the current
+working directory.  It is used to properly resolve relative
+paths."
+  (let ((case-fold-search t))
+    (goto-char (point-min))
+    (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t)
+      (let ((element (save-match-data (org-element-at-point))))
+       (when (eq (org-element-type element) 'keyword)
+         (beginning-of-line)
+         ;; Extract arguments from keyword's value.
+         (let* ((value (org-element-property :value element))
+                (ind (org-get-indentation))
+                (file (and (string-match
+                            "^\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value)
+                           (prog1 (expand-file-name
+                                   (org-remove-double-quotes
+                                    (match-string 1 value))
+                                   dir)
+                             (setq value (replace-match "" nil nil value)))))
+                (lines
+                 (and (string-match
+                       ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
+                       value)
+                      (prog1 (match-string 1 value)
+                        (setq value (replace-match "" nil nil value)))))
+                (env (cond ((string-match "\\<example\\>" value) 'example)
+                           ((string-match "\\<src\\(?: +\\(.*\\)\\)?" value)
+                            (match-string 1 value))))
+                ;; Minimal level of included file defaults to the child
+                ;; level of the current headline, if any, or one.  It
+                ;; only applies is the file is meant to be included as
+                ;; an Org one.
+                (minlevel
+                 (and (not env)
+                      (if (string-match ":minlevel +\\([0-9]+\\)" value)
+                          (prog1 (string-to-number (match-string 1 value))
+                            (setq value (replace-match "" nil nil value)))
+                        (let ((cur (org-current-level)))
+                          (if cur (1+ (org-reduced-level cur)) 1))))))
+           ;; Remove keyword.
+           (delete-region (point) (progn (forward-line) (point)))
+           (cond
+            ((not file) nil)
+            ((not (file-readable-p file))
+             (error "Cannot include file %s" file))
+            ;; Check if files has already been parsed.  Look after
+            ;; inclusion lines too, as different parts of the same file
+            ;; can be included too.
+            ((member (list file lines) included)
+             (error "Recursive file inclusion: %s" file))
+            (t
+             (cond
+              ((eq env 'example)
+               (insert
+                (let ((ind-str (make-string ind ? ))
+                      (contents
+                       (org-escape-code-in-string
+                        (org-export--prepare-file-contents file lines))))
+                  (format "%s#+BEGIN_EXAMPLE\n%s%s#+END_EXAMPLE\n"
+                          ind-str contents ind-str))))
+              ((stringp env)
+               (insert
+                (let ((ind-str (make-string ind ? ))
+                      (contents
+                       (org-escape-code-in-string
+                        (org-export--prepare-file-contents file lines))))
+                  (format "%s#+BEGIN_SRC %s\n%s%s#+END_SRC\n"
+                          ind-str env contents ind-str))))
+              (t
+               (insert
+                (with-temp-buffer
+                  (let ((org-inhibit-startup t)) (org-mode))
+                  (insert
+                   (org-export--prepare-file-contents file lines ind minlevel))
+                  (org-export-expand-include-keyword
+                   (cons (list file lines) included)
+                   (file-name-directory file))
+                  (buffer-string)))))))))))))
+
+(defun org-export--prepare-file-contents (file &optional lines ind minlevel)
+  "Prepare the contents of FILE for inclusion and return them as a string.
+
+When optional argument LINES is a string specifying a range of
+lines, include only those lines.
+
+Optional argument IND, when non-nil, is an integer specifying the
+global indentation of returned contents.  Since its purpose is to
+allow an included file to stay in the same environment it was
+created \(i.e. a list item), it doesn't apply past the first
+headline encountered.
+
+Optional argument MINLEVEL, when non-nil, is an integer
+specifying the level that any top-level headline in the included
+file should have."
+  (with-temp-buffer
+    (insert-file-contents file)
+    (when lines
+      (let* ((lines (split-string lines "-"))
+            (lbeg (string-to-number (car lines)))
+            (lend (string-to-number (cadr lines)))
+            (beg (if (zerop lbeg) (point-min)
+                   (goto-char (point-min))
+                   (forward-line (1- lbeg))
+                   (point)))
+            (end (if (zerop lend) (point-max)
+                   (goto-char (point-min))
+                   (forward-line (1- lend))
+                   (point))))
+       (narrow-to-region beg end)))
+    ;; Remove blank lines at beginning and end of contents.  The logic
+    ;; behind that removal is that blank lines around include keyword
+    ;; override blank lines in included file.
+    (goto-char (point-min))
+    (org-skip-whitespace)
+    (beginning-of-line)
+    (delete-region (point-min) (point))
+    (goto-char (point-max))
+    (skip-chars-backward " \r\t\n")
+    (forward-line)
+    (delete-region (point) (point-max))
+    ;; If IND is set, preserve indentation of include keyword until
+    ;; the first headline encountered.
+    (when ind
+      (unless (eq major-mode 'org-mode)
+       (let ((org-inhibit-startup t)) (org-mode)))
+      (goto-char (point-min))
+      (let ((ind-str (make-string ind ? )))
+       (while (not (or (eobp) (looking-at org-outline-regexp-bol)))
+         ;; Do not move footnote definitions out of column 0.
+         (unless (and (looking-at org-footnote-definition-re)
+                      (eq (org-element-type (org-element-at-point))
+                          'footnote-definition))
+           (insert ind-str))
+         (forward-line))))
+    ;; When MINLEVEL is specified, compute minimal level for headlines
+    ;; in the file (CUR-MIN), and remove stars to each headline so
+    ;; that headlines with minimal level have a level of MINLEVEL.
+    (when minlevel
+      (unless (eq major-mode 'org-mode)
+       (let ((org-inhibit-startup t)) (org-mode)))
+      (org-with-limited-levels
+       (let ((levels (org-map-entries
+                     (lambda () (org-reduced-level (org-current-level))))))
+        (when levels
+          (let ((offset (- minlevel (apply 'min levels))))
+            (unless (zerop offset)
+              (when org-odd-levels-only (setq offset (* offset 2)))
+              ;; Only change stars, don't bother moving whole
+              ;; sections.
+              (org-map-entries
+               (lambda () (if (< offset 0) (delete-char (abs offset))
+                       (insert (make-string offset ?*)))))))))))
+    (org-element-normalize-string (buffer-string))))
+
+(defun org-export-execute-babel-code ()
+  "Execute every Babel code in the visible part of current buffer."
+  ;; Get a pristine copy of current buffer so Babel references can be
+  ;; properly resolved.
+  (let ((reference (org-export-copy-buffer)))
+    (unwind-protect (let ((org-current-export-file reference))
+                     (org-babel-exp-process-buffer))
+      (kill-buffer reference))))
+
+(defun org-export--copy-to-kill-ring-p ()
+  "Return a non-nil value when output should be added to the kill ring.
+See also `org-export-copy-to-kill-ring'."
+  (if (eq org-export-copy-to-kill-ring 'if-interactive)
+      (not (or executing-kbd-macro noninteractive))
+    (eq org-export-copy-to-kill-ring t)))
+
+
+\f
+;;; Tools For Back-Ends
+;;
+;; A whole set of tools is available to help build new exporters.  Any
+;; function general enough to have its use across many back-ends
+;; should be added here.
+
+;;;; For Affiliated Keywords
+;;
+;; `org-export-read-attribute' reads a property from a given element
+;;  as a plist.  It can be used to normalize affiliated keywords'
+;;  syntax.
+;;
+;; Since captions can span over multiple lines and accept dual values,
+;; their internal representation is a bit tricky.  Therefore,
+;; `org-export-get-caption' transparently returns a given element's
+;; caption as a secondary string.
+
+(defun org-export-read-attribute (attribute element &optional property)
+  "Turn ATTRIBUTE property from ELEMENT into a plist.
+
+When optional argument PROPERTY is non-nil, return the value of
+that property within attributes.
+
+This function assumes attributes are defined as \":keyword
+value\" pairs.  It is appropriate for `:attr_html' like
+properties.
+
+All values will become strings except the empty string and
+\"nil\", which will become nil.  Also, values containing only
+double quotes will be read as-is, which means that \"\" value
+will become the empty string."
+  (let* ((prepare-value
+         (lambda (str)
+           (save-match-data
+             (cond ((member str '(nil "" "nil")) nil)
+                   ((string-match "^\"\\(\"+\\)?\"$" str)
+                    (or (match-string 1 str) ""))
+                   (t str)))))
+        (attributes
+         (let ((value (org-element-property attribute element)))
+           (when value
+             (let ((s (mapconcat 'identity value " ")) result)
+               (while (string-match
+                       "\\(?:^\\|[ \t]+\\)\\(:[-a-zA-Z0-9_]+\\)\\([ \t]+\\|$\\)"
+                       s)
+                 (let ((value (substring s 0 (match-beginning 0))))
+                   (push (funcall prepare-value value) result))
+                 (push (intern (match-string 1 s)) result)
+                 (setq s (substring s (match-end 0))))
+               ;; Ignore any string before first property with `cdr'.
+               (cdr (nreverse (cons (funcall prepare-value s) result))))))))
+    (if property (plist-get attributes property) attributes)))
+
+(defun org-export-get-caption (element &optional shortp)
+  "Return caption from ELEMENT as a secondary string.
+
+When optional argument SHORTP is non-nil, return short caption,
+as a secondary string, instead.
+
+Caption lines are separated by a white space."
+  (let ((full-caption (org-element-property :caption element)) caption)
+    (dolist (line full-caption (cdr caption))
+      (let ((cap (funcall (if shortp 'cdr 'car) line)))
+       (when cap
+         (setq caption (nconc (list " ") (copy-sequence cap) caption)))))))
+
+
+;;;; For Derived Back-ends
+;;
+;; `org-export-with-backend' is a function allowing to locally use
+;; another back-end to transcode some object or element.  In a derived
+;; back-end, it may be used as a fall-back function once all specific
+;; cases have been treated.
+
+(defun org-export-with-backend (backend data &optional contents info)
+  "Call a transcoder from BACKEND on DATA.
+BACKEND is an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.  DATA is an Org element, object, secondary
+string or string.  CONTENTS, when non-nil, is the transcoded
+contents of DATA element, as a string.  INFO, when non-nil, is
+the communication channel used for export, as a plist."
+  (when (symbolp backend) (setq backend (org-export-get-backend backend)))
+  (org-export-barf-if-invalid-backend backend)
+  (let ((type (org-element-type data)))
+    (if (memq type '(nil org-data)) (error "No foreign transcoder available")
+      (let* ((all-transcoders (org-export-get-all-transcoders backend))
+            (transcoder (cdr (assq type all-transcoders))))
+       (if (not (functionp transcoder))
+           (error "No foreign transcoder available")
+         (funcall
+          transcoder data contents
+          (org-combine-plists
+           info (list :back-end backend
+                      :translate-alist all-transcoders
+                      :exported-data (make-hash-table :test 'eq :size 401)))))))))
+
+
+;;;; For Export Snippets
+;;
+;; Every export snippet is transmitted to the back-end.  Though, the
+;; latter will only retain one type of export-snippet, ignoring
+;; others, based on the former's target back-end.  The function
+;; `org-export-snippet-backend' returns that back-end for a given
+;; export-snippet.
+
+(defun org-export-snippet-backend (export-snippet)
+  "Return EXPORT-SNIPPET targeted back-end as a symbol.
+Translation, with `org-export-snippet-translation-alist', is
+applied."
+  (let ((back-end (org-element-property :back-end export-snippet)))
+    (intern
+     (or (cdr (assoc back-end org-export-snippet-translation-alist))
+        back-end))))
+
+
+;;;; For Footnotes
+;;
+;; `org-export-collect-footnote-definitions' is a tool to list
+;; actually used footnotes definitions in the whole parse tree, or in
+;; a headline, in order to add footnote listings throughout the
+;; transcoded data.
+;;
+;; `org-export-footnote-first-reference-p' is a predicate used by some
+;; back-ends, when they need to attach the footnote definition only to
+;; the first occurrence of the corresponding label.
+;;
+;; `org-export-get-footnote-definition' and
+;; `org-export-get-footnote-number' provide easier access to
+;; additional information relative to a footnote reference.
+
+(defun org-export-collect-footnote-definitions (data info)
+  "Return an alist between footnote numbers, labels and definitions.
+
+DATA is the parse tree from which definitions are collected.
+INFO is the plist used as a communication channel.
+
+Definitions are sorted by order of references.  They either
+appear as Org data or as a secondary string for inlined
+footnotes.  Unreferenced definitions are ignored."
+  (let* (num-alist
+        collect-fn                     ; for byte-compiler.
+        (collect-fn
+         (function
+          (lambda (data)
+            ;; Collect footnote number, label and definition in DATA.
+            (org-element-map data 'footnote-reference
+              (lambda (fn)
+                (when (org-export-footnote-first-reference-p fn info)
+                  (let ((def (org-export-get-footnote-definition fn info)))
+                    (push
+                     (list (org-export-get-footnote-number fn info)
+                           (org-element-property :label fn)
+                           def)
+                     num-alist)
+                    ;; Also search in definition for nested footnotes.
+                    (when (eq (org-element-property :type fn) 'standard)
+                      (funcall collect-fn def)))))
+              ;; Don't enter footnote definitions since it will happen
+              ;; when their first reference is found.
+              info nil 'footnote-definition)))))
+    (funcall collect-fn (plist-get info :parse-tree))
+    (reverse num-alist)))
+
+(defun org-export-footnote-first-reference-p (footnote-reference info)
+  "Non-nil when a footnote reference is the first one for its label.
+
+FOOTNOTE-REFERENCE is the footnote reference being considered.
+INFO is the plist used as a communication channel."
+  (let ((label (org-element-property :label footnote-reference)))
+    ;; Anonymous footnotes are always a first reference.
+    (if (not label) t
+      ;; Otherwise, return the first footnote with the same LABEL and
+      ;; test if it is equal to FOOTNOTE-REFERENCE.
+      (let* (search-refs               ; for byte-compiler.
+            (search-refs
+             (function
+              (lambda (data)
+                (org-element-map data 'footnote-reference
+                  (lambda (fn)
+                    (cond
+                     ((string= (org-element-property :label fn) label)
+                      (throw 'exit fn))
+                     ;; If FN isn't inlined, be sure to traverse its
+                     ;; definition before resuming search.  See
+                     ;; comments in `org-export-get-footnote-number'
+                     ;; for more information.
+                     ((eq (org-element-property :type fn) 'standard)
+                      (funcall search-refs
+                               (org-export-get-footnote-definition fn info)))))
+                  ;; Don't enter footnote definitions since it will
+                  ;; happen when their first reference is found.
+                  info 'first-match 'footnote-definition)))))
+       (eq (catch 'exit (funcall search-refs (plist-get info :parse-tree)))
+           footnote-reference)))))
+
+(defun org-export-get-footnote-definition (footnote-reference info)
+  "Return definition of FOOTNOTE-REFERENCE as parsed data.
+INFO is the plist used as a communication channel.  If no such
+definition can be found, return the \"DEFINITION NOT FOUND\"
+string."
+  (let ((label (org-element-property :label footnote-reference)))
+    (or (org-element-property :inline-definition footnote-reference)
+        (cdr (assoc label (plist-get info :footnote-definition-alist)))
+       "DEFINITION NOT FOUND.")))
+
+(defun org-export-get-footnote-number (footnote info)
+  "Return number associated to a footnote.
+
+FOOTNOTE is either a footnote reference or a footnote definition.
+INFO is the plist used as a communication channel."
+  (let* ((label (org-element-property :label footnote))
+        seen-refs
+        search-ref                     ; For byte-compiler.
+        (search-ref
+         (function
+          (lambda (data)
+            ;; Search footnote references through DATA, filling
+            ;; SEEN-REFS along the way.
+            (org-element-map data 'footnote-reference
+              (lambda (fn)
+                (let ((fn-lbl (org-element-property :label fn)))
+                  (cond
+                   ;; Anonymous footnote match: return number.
+                   ((and (not fn-lbl) (eq fn footnote))
+                    (throw 'exit (1+ (length seen-refs))))
+                   ;; Labels match: return number.
+                   ((and label (string= label fn-lbl))
+                    (throw 'exit (1+ (length seen-refs))))
+                   ;; Anonymous footnote: it's always a new one.
+                   ;; Also, be sure to return nil from the `cond' so
+                   ;; `first-match' doesn't get us out of the loop.
+                   ((not fn-lbl) (push 'inline seen-refs) nil)
+                   ;; Label not seen so far: add it so SEEN-REFS.
+                   ;;
+                   ;; Also search for subsequent references in
+                   ;; footnote definition so numbering follows
+                   ;; reading logic.  Note that we don't have to care
+                   ;; about inline definitions, since
+                   ;; `org-element-map' already traverses them at the
+                   ;; right time.
+                   ;;
+                   ;; Once again, return nil to stay in the loop.
+                   ((not (member fn-lbl seen-refs))
+                    (push fn-lbl seen-refs)
+                    (funcall search-ref
+                             (org-export-get-footnote-definition fn info))
+                    nil))))
+              ;; Don't enter footnote definitions since it will
+              ;; happen when their first reference is found.
+              info 'first-match 'footnote-definition)))))
+    (catch 'exit (funcall search-ref (plist-get info :parse-tree)))))
+
+
+;;;; For Headlines
+;;
+;; `org-export-get-relative-level' is a shortcut to get headline
+;; level, relatively to the lower headline level in the parsed tree.
+;;
+;; `org-export-get-headline-number' returns the section number of an
+;; headline, while `org-export-number-to-roman' allows to convert it
+;; to roman numbers.
+;;
+;; `org-export-low-level-p', `org-export-first-sibling-p' and
+;; `org-export-last-sibling-p' are three useful predicates when it
+;; comes to fulfill the `:headline-levels' property.
+;;
+;; `org-export-get-tags', `org-export-get-category' and
+;; `org-export-get-node-property' extract useful information from an
+;; headline or a parent headline.  They all handle inheritance.
+;;
+;; `org-export-get-alt-title' tries to retrieve an alternative title,
+;; as a secondary string, suitable for table of contents.  It falls
+;; back onto default title.
+
+(defun org-export-get-relative-level (headline info)
+  "Return HEADLINE relative level within current parsed tree.
+INFO is a plist holding contextual information."
+  (+ (org-element-property :level headline)
+     (or (plist-get info :headline-offset) 0)))
+
+(defun org-export-low-level-p (headline info)
+  "Non-nil when HEADLINE is considered as low level.
+
+INFO is a plist used as a communication channel.
+
+A low level headlines has a relative level greater than
+`:headline-levels' property value.
+
+Return value is the difference between HEADLINE relative level
+and the last level being considered as high enough, or nil."
+  (let ((limit (plist-get info :headline-levels)))
+    (when (wholenump limit)
+      (let ((level (org-export-get-relative-level headline info)))
+        (and (> level limit) (- level limit))))))
+
+(defun org-export-get-headline-number (headline info)
+  "Return HEADLINE numbering as a list of numbers.
+INFO is a plist holding contextual information."
+  (cdr (assoc headline (plist-get info :headline-numbering))))
+
+(defun org-export-numbered-headline-p (headline info)
+  "Return a non-nil value if HEADLINE element should be numbered.
+INFO is a plist used as a communication channel."
+  (let ((sec-num (plist-get info :section-numbers))
+       (level (org-export-get-relative-level headline info)))
+    (if (wholenump sec-num) (<= level sec-num) sec-num)))
+
+(defun org-export-number-to-roman (n)
+  "Convert integer N into a roman numeral."
+  (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
+                ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
+                (  10 . "X") (  9 . "IX") (  5 . "V") (  4 . "IV")
+                (   1 . "I")))
+       (res ""))
+    (if (<= n 0)
+       (number-to-string n)
+      (while roman
+       (if (>= n (caar roman))
+           (setq n (- n (caar roman))
+                 res (concat res (cdar roman)))
+         (pop roman)))
+      res)))
+
+(defun org-export-get-tags (element info &optional tags inherited)
+  "Return list of tags associated to ELEMENT.
+
+ELEMENT has either an `headline' or an `inlinetask' type.  INFO
+is a plist used as a communication channel.
+
+Select tags (see `org-export-select-tags') and exclude tags (see
+`org-export-exclude-tags') are removed from the list.
+
+When non-nil, optional argument TAGS should be a list of strings.
+Any tag belonging to this list will also be removed.
+
+When optional argument INHERITED is non-nil, tags can also be
+inherited from parent headlines and FILETAGS keywords."
+  (org-remove-if
+   (lambda (tag) (or (member tag (plist-get info :select-tags))
+               (member tag (plist-get info :exclude-tags))
+               (member tag tags)))
+   (if (not inherited) (org-element-property :tags element)
+     ;; Build complete list of inherited tags.
+     (let ((current-tag-list (org-element-property :tags element)))
+       (mapc
+       (lambda (parent)
+         (mapc
+          (lambda (tag)
+            (when (and (memq (org-element-type parent) '(headline inlinetask))
+                       (not (member tag current-tag-list)))
+              (push tag current-tag-list)))
+          (org-element-property :tags parent)))
+       (org-export-get-genealogy element))
+       ;; Add FILETAGS keywords and return results.
+       (org-uniquify (append (plist-get info :filetags) current-tag-list))))))
+
+(defun org-export-get-node-property (property blob &optional inherited)
+  "Return node PROPERTY value for BLOB.
+
+PROPERTY is an upcase symbol (i.e. `:COOKIE_DATA').  BLOB is an
+element or object.
+
+If optional argument INHERITED is non-nil, the value can be
+inherited from a parent headline.
+
+Return value is a string or nil."
+  (let ((headline (if (eq (org-element-type blob) 'headline) blob
+                   (org-export-get-parent-headline blob))))
+    (if (not inherited) (org-element-property property blob)
+      (let ((parent headline) value)
+       (catch 'found
+         (while parent
+           (when (plist-member (nth 1 parent) property)
+             (throw 'found (org-element-property property parent)))
+           (setq parent (org-element-property :parent parent))))))))
+
+(defun org-export-get-category (blob info)
+  "Return category for element or object BLOB.
+
+INFO is a plist used as a communication channel.
+
+CATEGORY is automatically inherited from a parent headline, from
+#+CATEGORY: keyword or created out of original file name.  If all
+fail, the fall-back value is \"???\"."
+  (or (let ((headline (if (eq (org-element-type blob) 'headline) blob
+                       (org-export-get-parent-headline blob))))
+       ;; Almost like `org-export-node-property', but we cannot trust
+       ;; `plist-member' as every headline has a `:CATEGORY'
+       ;; property, would it be nil or equal to "???" (which has the
+       ;; same meaning).
+       (let ((parent headline) value)
+         (catch 'found
+           (while parent
+             (let ((category (org-element-property :CATEGORY parent)))
+               (and category (not (equal "???" category))
+                    (throw 'found category)))
+             (setq parent (org-element-property :parent parent))))))
+      (org-element-map (plist-get info :parse-tree) 'keyword
+       (lambda (kwd)
+         (when (equal (org-element-property :key kwd) "CATEGORY")
+           (org-element-property :value kwd)))
+       info 'first-match)
+      (let ((file (plist-get info :input-file)))
+       (and file (file-name-sans-extension (file-name-nondirectory file))))
+      "???"))
+
+(defun org-export-get-alt-title (headline info)
+  "Return alternative title for HEADLINE, as a secondary string.
+INFO is a plist used as a communication channel.  If no optional
+title is defined, fall-back to the regular title."
+  (or (org-element-property :alt-title headline)
+      (org-element-property :title headline)))
+
+(defun org-export-first-sibling-p (headline info)
+  "Non-nil when HEADLINE is the first sibling in its sub-tree.
+INFO is a plist used as a communication channel."
+  (not (eq (org-element-type (org-export-get-previous-element headline info))
+          'headline)))
+
+(defun org-export-last-sibling-p (headline info)
+  "Non-nil when HEADLINE is the last sibling in its sub-tree.
+INFO is a plist used as a communication channel."
+  (not (org-export-get-next-element headline info)))
+
+
+;;;; For Keywords
+;;
+;; `org-export-get-date' returns a date appropriate for the document
+;;  to about to be exported.  In particular, it takes care of
+;;  `org-export-date-timestamp-format'.
+
+(defun org-export-get-date (info &optional fmt)
+  "Return date value for the current document.
+
+INFO is a plist used as a communication channel.  FMT, when
+non-nil, is a time format string that will be applied on the date
+if it consists in a single timestamp object.  It defaults to
+`org-export-date-timestamp-format' when nil.
+
+A proper date can be a secondary string, a string or nil.  It is
+meant to be translated with `org-export-data' or alike."
+  (let ((date (plist-get info :date))
+       (fmt (or fmt org-export-date-timestamp-format)))
+    (cond ((not date) nil)
+         ((and fmt
+               (not (cdr date))
+               (eq (org-element-type (car date)) 'timestamp))
+          (org-timestamp-format (car date) fmt))
+         (t date))))
+
+
+;;;; For Links
+;;
+;; `org-export-solidify-link-text' turns a string into a safer version
+;; for links, replacing most non-standard characters with hyphens.
+;;
+;; `org-export-get-coderef-format' returns an appropriate format
+;; string for coderefs.
+;;
+;; `org-export-inline-image-p' returns a non-nil value when the link
+;; provided should be considered as an inline image.
+;;
+;; `org-export-resolve-fuzzy-link' searches destination of fuzzy links
+;; (i.e. links with "fuzzy" as type) within the parsed tree, and
+;; returns an appropriate unique identifier when found, or nil.
+;;
+;; `org-export-resolve-id-link' returns the first headline with
+;; specified id or custom-id in parse tree, the path to the external
+;; file with the id or nil when neither was found.
+;;
+;; `org-export-resolve-coderef' associates a reference to a line
+;; number in the element it belongs, or returns the reference itself
+;; when the element isn't numbered.
+
+(defun org-export-solidify-link-text (s)
+  "Take link text S and make a safe target out of it."
+  (save-match-data
+    (mapconcat 'identity (org-split-string s "[^a-zA-Z0-9_.-:]+") "-")))
+
+(defun org-export-get-coderef-format (path desc)
+  "Return format string for code reference link.
+PATH is the link path.  DESC is its description."
+  (save-match-data
+    (cond ((not desc) "%s")
+         ((string-match (regexp-quote (concat "(" path ")")) desc)
+          (replace-match "%s" t t desc))
+         (t desc))))
+
+(defun org-export-inline-image-p (link &optional rules)
+  "Non-nil if LINK object points to an inline image.
+
+Optional argument is a set of RULES defining inline images.  It
+is an alist where associations have the following shape:
+
+  \(TYPE . REGEXP)
+
+Applying a rule means apply REGEXP against LINK's path when its
+type is TYPE.  The function will return a non-nil value if any of
+the provided rules is non-nil.  The default rule is
+`org-export-default-inline-image-rule'.
+
+This only applies to links without a description."
+  (and (not (org-element-contents link))
+       (let ((case-fold-search t)
+            (rules (or rules org-export-default-inline-image-rule)))
+        (catch 'exit
+          (mapc
+           (lambda (rule)
+             (and (string= (org-element-property :type link) (car rule))
+                  (string-match (cdr rule)
+                                (org-element-property :path link))
+                  (throw 'exit t)))
+           rules)
+          ;; Return nil if no rule matched.
+          nil))))
+
+(defun org-export-resolve-coderef (ref info)
+  "Resolve a code reference REF.
+
+INFO is a plist used as a communication channel.
+
+Return associated line number in source code, or REF itself,
+depending on src-block or example element's switches."
+  (org-element-map (plist-get info :parse-tree) '(example-block src-block)
+    (lambda (el)
+      (with-temp-buffer
+       (insert (org-trim (org-element-property :value el)))
+       (let* ((label-fmt (regexp-quote
+                          (or (org-element-property :label-fmt el)
+                              org-coderef-label-format)))
+              (ref-re
+               (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)\\)[ \t]*$"
+                       (replace-regexp-in-string "%s" ref label-fmt nil t))))
+         ;; Element containing REF is found.  Resolve it to either
+         ;; a label or a line number, as needed.
+         (when (re-search-backward ref-re nil t)
+           (cond
+            ((org-element-property :use-labels el) ref)
+            ((eq (org-element-property :number-lines el) 'continued)
+             (+ (org-export-get-loc el info) (line-number-at-pos)))
+            (t (line-number-at-pos)))))))
+    info 'first-match))
+
+(defun org-export-resolve-fuzzy-link (link info)
+  "Return LINK destination.
+
+INFO is a plist holding contextual information.
+
+Return value can be an object, an element, or nil:
+
+- If LINK path matches a target object (i.e. <<path>>) return it.
+
+- If LINK path exactly matches the name affiliated keyword
+  \(i.e. #+NAME: path) of an element, return that element.
+
+- If LINK path exactly matches any headline name, return that
+  element.  If more than one headline share that name, priority
+  will be given to the one with the closest common ancestor, if
+  any, or the first one in the parse tree otherwise.
+
+- Otherwise, return nil.
+
+Assume LINK type is \"fuzzy\".  White spaces are not
+significant."
+  (let* ((raw-path (org-element-property :path link))
+        (match-title-p (eq (aref raw-path 0) ?*))
+        ;; Split PATH at white spaces so matches are space
+        ;; insensitive.
+        (path (org-split-string
+               (if match-title-p (substring raw-path 1) raw-path)))
+        ;; Cache for destinations that are not position dependent.
+        (link-cache
+         (or (plist-get info :resolve-fuzzy-link-cache)
+             (plist-get (setq info (plist-put info :resolve-fuzzy-link-cache
+                                              (make-hash-table :test 'equal)))
+                        :resolve-fuzzy-link-cache)))
+        (cached (gethash path link-cache 'not-found)))
+    (cond
+     ;; Destination is not position dependent: use cached value.
+     ((and (not match-title-p) (not (eq cached 'not-found))) cached)
+     ;; First try to find a matching "<<path>>" unless user specified
+     ;; he was looking for a headline (path starts with a "*"
+     ;; character).
+     ((and (not match-title-p)
+          (let ((match (org-element-map (plist-get info :parse-tree) 'target
+                         (lambda (blob)
+                           (and (equal (org-split-string
+                                        (org-element-property :value blob))
+                                       path)
+                                blob))
+                         info 'first-match)))
+            (and match (puthash path match link-cache)))))
+     ;; Then try to find an element with a matching "#+NAME: path"
+     ;; affiliated keyword.
+     ((and (not match-title-p)
+          (let ((match (org-element-map (plist-get info :parse-tree)
+                           org-element-all-elements
+                         (lambda (el)
+                           (let ((name (org-element-property :name el)))
+                             (when (and name
+                                        (equal (org-split-string name) path))
+                               el)))
+                         info 'first-match)))
+            (and match (puthash path match link-cache)))))
+     ;; Last case: link either points to a headline or to nothingness.
+     ;; Try to find the source, with priority given to headlines with
+     ;; the closest common ancestor.  If such candidate is found,
+     ;; return it, otherwise return nil.
+     (t
+      (let ((find-headline
+            (function
+             ;; Return first headline whose `:raw-value' property is
+             ;; NAME in parse tree DATA, or nil.  Statistics cookies
+             ;; are ignored.
+             (lambda (name data)
+               (org-element-map data 'headline
+                 (lambda (headline)
+                   (when (equal (org-split-string
+                                 (replace-regexp-in-string
+                                  "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
+                                  (org-element-property :raw-value headline)))
+                                name)
+                     headline))
+                 info 'first-match)))))
+       ;; Search among headlines sharing an ancestor with link, from
+       ;; closest to farthest.
+       (catch 'exit
+         (mapc
+          (lambda (parent)
+            (let ((foundp (funcall find-headline path parent)))
+              (when foundp (throw 'exit foundp))))
+          (let ((parent-hl (org-export-get-parent-headline link)))
+            (if (not parent-hl) (list (plist-get info :parse-tree))
+              (cons parent-hl (org-export-get-genealogy parent-hl)))))
+         ;; No destination found: return nil.
+         (and (not match-title-p) (puthash path nil link-cache))))))))
+
+(defun org-export-resolve-id-link (link info)
+  "Return headline referenced as LINK destination.
+
+INFO is a plist used as a communication channel.
+
+Return value can be the headline element matched in current parse
+tree, a file name or nil.  Assume LINK type is either \"id\" or
+\"custom-id\"."
+  (let ((id (org-element-property :path link)))
+    ;; First check if id is within the current parse tree.
+    (or (org-element-map (plist-get info :parse-tree) 'headline
+         (lambda (headline)
+           (when (or (string= (org-element-property :ID headline) id)
+                     (string= (org-element-property :CUSTOM_ID headline) id))
+             headline))
+         info 'first-match)
+       ;; Otherwise, look for external files.
+       (cdr (assoc id (plist-get info :id-alist))))))
+
+(defun org-export-resolve-radio-link (link info)
+  "Return radio-target object referenced as LINK destination.
+
+INFO is a plist used as a communication channel.
+
+Return value can be a radio-target object or nil.  Assume LINK
+has type \"radio\"."
+  (let ((path (replace-regexp-in-string
+              "[ \r\t\n]+" " " (org-element-property :path link))))
+    (org-element-map (plist-get info :parse-tree) 'radio-target
+      (lambda (radio)
+       (and (eq (compare-strings
+                 (replace-regexp-in-string
+                  "[ \r\t\n]+" " " (org-element-property :value radio))
+                 nil nil path nil nil t)
+                t)
+            radio))
+      info 'first-match)))
+
+
+;;;; For References
+;;
+;; `org-export-get-ordinal' associates a sequence number to any object
+;; or element.
+
+(defun org-export-get-ordinal (element info &optional types predicate)
+  "Return ordinal number of an element or object.
+
+ELEMENT is the element or object considered.  INFO is the plist
+used as a communication channel.
+
+Optional argument TYPES, when non-nil, is a list of element or
+object types, as symbols, that should also be counted in.
+Otherwise, only provided element's type is considered.
+
+Optional argument PREDICATE is a function returning a non-nil
+value if the current element or object should be counted in.  It
+accepts two arguments: the element or object being considered and
+the plist used as a communication channel.  This allows to count
+only a certain type of objects (i.e. inline images).
+
+Return value is a list of numbers if ELEMENT is a headline or an
+item.  It is nil for keywords.  It represents the footnote number
+for footnote definitions and footnote references.  If ELEMENT is
+a target, return the same value as if ELEMENT was the closest
+table, item or headline containing the target.  In any other
+case, return the sequence number of ELEMENT among elements or
+objects of the same type."
+  ;; Ordinal of a target object refer to the ordinal of the closest
+  ;; table, item, or headline containing the object.
+  (when (eq (org-element-type element) 'target)
+    (setq element
+         (loop for parent in (org-export-get-genealogy element)
+               when
+               (memq
+                (org-element-type parent)
+                '(footnote-definition footnote-reference headline item
+                                      table))
+               return parent)))
+  (case (org-element-type element)
+    ;; Special case 1: A headline returns its number as a list.
+    (headline (org-export-get-headline-number element info))
+    ;; Special case 2: An item returns its number as a list.
+    (item (let ((struct (org-element-property :structure element)))
+           (org-list-get-item-number
+            (org-element-property :begin element)
+            struct
+            (org-list-prevs-alist struct)
+            (org-list-parents-alist struct))))
+    ((footnote-definition footnote-reference)
+     (org-export-get-footnote-number element info))
+    (otherwise
+     (let ((counter 0))
+       ;; Increment counter until ELEMENT is found again.
+       (org-element-map (plist-get info :parse-tree)
+          (or types (org-element-type element))
+        (lambda (el)
+          (cond
+           ((eq element el) (1+ counter))
+           ((not predicate) (incf counter) nil)
+           ((funcall predicate el info) (incf counter) nil)))
+        info 'first-match)))))
+
+
+;;;; For Src-Blocks
+;;
+;; `org-export-get-loc' counts number of code lines accumulated in
+;; src-block or example-block elements with a "+n" switch until
+;; a given element, excluded.  Note: "-n" switches reset that count.
+;;
+;; `org-export-unravel-code' extracts source code (along with a code
+;; references alist) from an `element-block' or `src-block' type
+;; element.
+;;
+;; `org-export-format-code' applies a formatting function to each line
+;; of code, providing relative line number and code reference when
+;; appropriate.  Since it doesn't access the original element from
+;; which the source code is coming, it expects from the code calling
+;; it to know if lines should be numbered and if code references
+;; should appear.
+;;
+;; Eventually, `org-export-format-code-default' is a higher-level
+;; function (it makes use of the two previous functions) which handles
+;; line numbering and code references inclusion, and returns source
+;; code in a format suitable for plain text or verbatim output.
+
+(defun org-export-get-loc (element info)
+  "Return accumulated lines of code up to ELEMENT.
+
+INFO is the plist used as a communication channel.
+
+ELEMENT is excluded from count."
+  (let ((loc 0))
+    (org-element-map (plist-get info :parse-tree)
+       `(src-block example-block ,(org-element-type element))
+      (lambda (el)
+       (cond
+        ;; ELEMENT is reached: Quit the loop.
+        ((eq el element))
+        ;; Only count lines from src-block and example-block elements
+        ;; with a "+n" or "-n" switch.  A "-n" switch resets counter.
+        ((not (memq (org-element-type el) '(src-block example-block))) nil)
+        ((let ((linums (org-element-property :number-lines el)))
+           (when linums
+             ;; Accumulate locs or reset them.
+             (let ((lines (org-count-lines
+                           (org-trim (org-element-property :value el)))))
+               (setq loc (if (eq linums 'new) lines (+ loc lines))))))
+         ;; Return nil to stay in the loop.
+         nil)))
+      info 'first-match)
+    ;; Return value.
+    loc))
+
+(defun org-export-unravel-code (element)
+  "Clean source code and extract references out of it.
+
+ELEMENT has either a `src-block' an `example-block' type.
+
+Return a cons cell whose CAR is the source code, cleaned from any
+reference and protective comma and CDR is an alist between
+relative line number (integer) and name of code reference on that
+line (string)."
+  (let* ((line 0) refs
+        ;; Get code and clean it.  Remove blank lines at its
+        ;; beginning and end.
+        (code (replace-regexp-in-string
+               "\\`\\([ \t]*\n\\)+" ""
+               (replace-regexp-in-string
+                "\\([ \t]*\n\\)*[ \t]*\\'" "\n"
+                (org-element-property :value element))))
+        ;; Get format used for references.
+        (label-fmt (regexp-quote
+                    (or (org-element-property :label-fmt element)
+                        org-coderef-label-format)))
+        ;; Build a regexp matching a loc with a reference.
+        (with-ref-re
+         (format "^.*?\\S-.*?\\([ \t]*\\(%s\\)[ \t]*\\)$"
+                 (replace-regexp-in-string
+                  "%s" "\\([-a-zA-Z0-9_ ]+\\)" label-fmt nil t))))
+    ;; Return value.
+    (cons
+     ;; Code with references removed.
+     (org-element-normalize-string
+      (mapconcat
+       (lambda (loc)
+        (incf line)
+        (if (not (string-match with-ref-re loc)) loc
+          ;; Ref line: remove ref, and signal its position in REFS.
+          (push (cons line (match-string 3 loc)) refs)
+          (replace-match "" nil nil loc 1)))
+       (org-split-string code "\n") "\n"))
+     ;; Reference alist.
+     refs)))
+
+(defun org-export-format-code (code fun &optional num-lines ref-alist)
+  "Format CODE by applying FUN line-wise and return it.
+
+CODE is a string representing the code to format.  FUN is
+a function.  It must accept three arguments: a line of
+code (string), the current line number (integer) or nil and the
+reference associated to the current line (string) or nil.
+
+Optional argument NUM-LINES can be an integer representing the
+number of code lines accumulated until the current code.  Line
+numbers passed to FUN will take it into account.  If it is nil,
+FUN's second argument will always be nil.  This number can be
+obtained with `org-export-get-loc' function.
+
+Optional argument REF-ALIST can be an alist between relative line
+number (i.e. ignoring NUM-LINES) and the name of the code
+reference on it.  If it is nil, FUN's third argument will always
+be nil.  It can be obtained through the use of
+`org-export-unravel-code' function."
+  (let ((--locs (org-split-string code "\n"))
+       (--line 0))
+    (org-element-normalize-string
+     (mapconcat
+      (lambda (--loc)
+       (incf --line)
+       (let ((--ref (cdr (assq --line ref-alist))))
+         (funcall fun --loc (and num-lines (+ num-lines --line)) --ref)))
+      --locs "\n"))))
+
+(defun org-export-format-code-default (element info)
+  "Return source code from ELEMENT, formatted in a standard way.
+
+ELEMENT is either a `src-block' or `example-block' element.  INFO
+is a plist used as a communication channel.
+
+This function takes care of line numbering and code references
+inclusion.  Line numbers, when applicable, appear at the
+beginning of the line, separated from the code by two white
+spaces.  Code references, on the other hand, appear flushed to
+the right, separated by six white spaces from the widest line of
+code."
+  ;; Extract code and references.
+  (let* ((code-info (org-export-unravel-code element))
+         (code (car code-info))
+        (code-lines (org-split-string code "\n")))
+    (if (null code-lines) ""
+      (let* ((refs (and (org-element-property :retain-labels element)
+                       (cdr code-info)))
+            ;; Handle line numbering.
+            (num-start (case (org-element-property :number-lines element)
+                         (continued (org-export-get-loc element info))
+                         (new 0)))
+            (num-fmt
+             (and num-start
+                  (format "%%%ds  "
+                          (length (number-to-string
+                                   (+ (length code-lines) num-start))))))
+            ;; Prepare references display, if required.  Any reference
+            ;; should start six columns after the widest line of code,
+            ;; wrapped with parenthesis.
+            (max-width
+             (+ (apply 'max (mapcar 'length code-lines))
+                (if (not num-start) 0 (length (format num-fmt num-start))))))
+       (org-export-format-code
+        code
+        (lambda (loc line-num ref)
+          (let ((number-str (and num-fmt (format num-fmt line-num))))
+            (concat
+             number-str
+             loc
+             (and ref
+                  (concat (make-string
+                           (- (+ 6 max-width)
+                              (+ (length loc) (length number-str))) ? )
+                          (format "(%s)" ref))))))
+        num-start refs)))))
+
+
+;;;; For Tables
+;;
+;; `org-export-table-has-special-column-p' and and
+;; `org-export-table-row-is-special-p' are predicates used to look for
+;; meta-information about the table structure.
+;;
+;; `org-table-has-header-p' tells when the rows before the first rule
+;;  should be considered as table's header.
+;;
+;; `org-export-table-cell-width', `org-export-table-cell-alignment'
+;; and `org-export-table-cell-borders' extract information from
+;; a table-cell element.
+;;
+;; `org-export-table-dimensions' gives the number on rows and columns
+;; in the table, ignoring horizontal rules and special columns.
+;; `org-export-table-cell-address', given a table-cell object, returns
+;; the absolute address of a cell. On the other hand,
+;; `org-export-get-table-cell-at' does the contrary.
+;;
+;; `org-export-table-cell-starts-colgroup-p',
+;; `org-export-table-cell-ends-colgroup-p',
+;; `org-export-table-row-starts-rowgroup-p',
+;; `org-export-table-row-ends-rowgroup-p',
+;; `org-export-table-row-starts-header-p' and
+;; `org-export-table-row-ends-header-p' indicate position of current
+;; row or cell within the table.
+
+(defun org-export-table-has-special-column-p (table)
+  "Non-nil when TABLE has a special column.
+All special columns will be ignored during export."
+  ;; The table has a special column when every first cell of every row
+  ;; has an empty value or contains a symbol among "/", "#", "!", "$",
+  ;; "*" "_" and "^".  Though, do not consider a first row containing
+  ;; only empty cells as special.
+  (let ((special-column-p 'empty))
+    (catch 'exit
+      (mapc
+       (lambda (row)
+        (when (eq (org-element-property :type row) 'standard)
+          (let ((value (org-element-contents
+                        (car (org-element-contents row)))))
+            (cond ((member value '(("/") ("#") ("!") ("$") ("*") ("_") ("^")))
+                   (setq special-column-p 'special))
+                  ((not value))
+                  (t (throw 'exit nil))))))
+       (org-element-contents table))
+      (eq special-column-p 'special))))
+
+(defun org-export-table-has-header-p (table info)
+  "Non-nil when TABLE has a header.
+
+INFO is a plist used as a communication channel.
+
+A table has a header when it contains at least two row groups."
+  (let ((cache (or (plist-get info :table-header-cache)
+                  (plist-get (setq info
+                                   (plist-put info :table-header-cache
+                                              (make-hash-table :test 'eq)))
+                             :table-header-cache))))
+    (or (gethash table cache)
+       (let ((rowgroup 1) row-flag)
+         (puthash
+          table
+          (org-element-map table 'table-row
+            (lambda (row)
+              (cond
+               ((> rowgroup 1) t)
+               ((and row-flag (eq (org-element-property :type row) 'rule))
+                (incf rowgroup) (setq row-flag nil))
+               ((and (not row-flag) (eq (org-element-property :type row)
+                                        'standard))
+                (setq row-flag t) nil)))
+            info 'first-match)
+          cache)))))
+
+(defun org-export-table-row-is-special-p (table-row info)
+  "Non-nil if TABLE-ROW is considered special.
+
+INFO is a plist used as the communication channel.
+
+All special rows will be ignored during export."
+  (when (eq (org-element-property :type table-row) 'standard)
+    (let ((first-cell (org-element-contents
+                      (car (org-element-contents table-row)))))
+      ;; A row is special either when...
+      (or
+       ;; ... it starts with a field only containing "/",
+       (equal first-cell '("/"))
+       ;; ... the table contains a special column and the row start
+       ;; with a marking character among, "^", "_", "$" or "!",
+       (and (org-export-table-has-special-column-p
+            (org-export-get-parent table-row))
+           (member first-cell '(("^") ("_") ("$") ("!"))))
+       ;; ... it contains only alignment cookies and empty cells.
+       (let ((special-row-p 'empty))
+        (catch 'exit
+          (mapc
+           (lambda (cell)
+             (let ((value (org-element-contents cell)))
+               ;; Since VALUE is a secondary string, the following
+               ;; checks avoid expanding it with `org-export-data'.
+               (cond ((not value))
+                     ((and (not (cdr value))
+                           (stringp (car value))
+                           (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'"
+                                         (car value)))
+                      (setq special-row-p 'cookie))
+                     (t (throw 'exit nil)))))
+           (org-element-contents table-row))
+          (eq special-row-p 'cookie)))))))
+
+(defun org-export-table-row-group (table-row info)
+  "Return TABLE-ROW's group number, as an integer.
+
+INFO is a plist used as the communication channel.
+
+Return value is the group number, as an integer, or nil for
+special rows and rows separators.  First group is also table's
+header."
+  (let ((cache (or (plist-get info :table-row-group-cache)
+                  (plist-get (setq info
+                                   (plist-put info :table-row-group-cache
+                                              (make-hash-table :test 'eq)))
+                             :table-row-group-cache))))
+    (cond ((gethash table-row cache))
+         ((eq (org-element-property :type table-row) 'rule) nil)
+         (t (let ((group 0) row-flag)
+              (org-element-map (org-export-get-parent table-row) 'table-row
+                (lambda (row)
+                  (if (eq (org-element-property :type row) 'rule)
+                      (setq row-flag nil)
+                    (unless row-flag (incf group) (setq row-flag t)))
+                  (when (eq table-row row) (puthash table-row group cache)))
+                info 'first-match))))))
+
+(defun org-export-table-cell-width (table-cell info)
+  "Return TABLE-CELL contents width.
+
+INFO is a plist used as the communication channel.
+
+Return value is the width given by the last width cookie in the
+same column as TABLE-CELL, or nil."
+  (let* ((row (org-export-get-parent table-cell))
+        (table (org-export-get-parent row))
+        (cells (org-element-contents row))
+        (columns (length cells))
+        (column (- columns (length (memq table-cell cells))))
+        (cache (or (plist-get info :table-cell-width-cache)
+                   (plist-get (setq info
+                                    (plist-put info :table-cell-width-cache
+                                               (make-hash-table :test 'eq)))
+                              :table-cell-width-cache)))
+        (width-vector (or (gethash table cache)
+                          (puthash table (make-vector columns 'empty) cache)))
+        (value (aref width-vector column)))
+    (if (not (eq value 'empty)) value
+      (let (cookie-width)
+       (dolist (row (org-element-contents table)
+                    (aset width-vector column cookie-width))
+         (when (org-export-table-row-is-special-p row info)
+           ;; In a special row, try to find a width cookie at COLUMN.
+           (let* ((value (org-element-contents
+                          (elt (org-element-contents row) column)))
+                  (cookie (car value)))
+             ;; The following checks avoid expanding unnecessarily
+             ;; the cell with `org-export-data'.
+             (when (and value
+                        (not (cdr value))
+                        (stringp cookie)
+                        (string-match "\\`<[lrc]?\\([0-9]+\\)?>\\'" cookie)
+                        (match-string 1 cookie))
+               (setq cookie-width
+                     (string-to-number (match-string 1 cookie)))))))))))
+
+(defun org-export-table-cell-alignment (table-cell info)
+  "Return TABLE-CELL contents alignment.
+
+INFO is a plist used as the communication channel.
+
+Return alignment as specified by the last alignment cookie in the
+same column as TABLE-CELL.  If no such cookie is found, a default
+alignment value will be deduced from fraction of numbers in the
+column (see `org-table-number-fraction' for more information).
+Possible values are `left', `right' and `center'."
+  ;; Load `org-table-number-fraction' and `org-table-number-regexp'.
+  (require 'org-table)
+  (let* ((row (org-export-get-parent table-cell))
+        (table (org-export-get-parent row))
+        (cells (org-element-contents row))
+        (columns (length cells))
+        (column (- columns (length (memq table-cell cells))))
+        (cache (or (plist-get info :table-cell-alignment-cache)
+                   (plist-get (setq info
+                                    (plist-put info :table-cell-alignment-cache
+                                               (make-hash-table :test 'eq)))
+                              :table-cell-alignment-cache)))
+        (align-vector (or (gethash table cache)
+                          (puthash table (make-vector columns nil) cache))))
+    (or (aref align-vector column)
+       (let ((number-cells 0)
+             (total-cells 0)
+             cookie-align
+             previous-cell-number-p)
+         (dolist (row (org-element-contents (org-export-get-parent row)))
+           (cond
+            ;; In a special row, try to find an alignment cookie at
+            ;; COLUMN.
+            ((org-export-table-row-is-special-p row info)
+             (let ((value (org-element-contents
+                           (elt (org-element-contents row) column))))
+               ;; Since VALUE is a secondary string, the following
+               ;; checks avoid useless expansion through
+               ;; `org-export-data'.
+               (when (and value
+                          (not (cdr value))
+                          (stringp (car value))
+                          (string-match "\\`<\\([lrc]\\)?\\([0-9]+\\)?>\\'"
+                                        (car value))
+                          (match-string 1 (car value)))
+                 (setq cookie-align (match-string 1 (car value))))))
+            ;; Ignore table rules.
+            ((eq (org-element-property :type row) 'rule))
+            ;; In a standard row, check if cell's contents are
+            ;; expressing some kind of number.  Increase NUMBER-CELLS
+            ;; accordingly.  Though, don't bother if an alignment
+            ;; cookie has already defined cell's alignment.
+            ((not cookie-align)
+             (let ((value (org-export-data
+                           (org-element-contents
+                            (elt (org-element-contents row) column))
+                           info)))
+               (incf total-cells)
+               ;; Treat an empty cell as a number if it follows
+               ;; a number.
+               (if (not (or (string-match org-table-number-regexp value)
+                            (and (string= value "") previous-cell-number-p)))
+                   (setq previous-cell-number-p nil)
+                 (setq previous-cell-number-p t)
+                 (incf number-cells))))))
+         ;; Return value.  Alignment specified by cookies has
+         ;; precedence over alignment deduced from cell's contents.
+         (aset align-vector
+               column
+               (cond ((equal cookie-align "l") 'left)
+                     ((equal cookie-align "r") 'right)
+                     ((equal cookie-align "c") 'center)
+                     ((>= (/ (float number-cells) total-cells)
+                          org-table-number-fraction)
+                      'right)
+                     (t 'left)))))))
+
+(defun org-export-table-cell-borders (table-cell info)
+  "Return TABLE-CELL borders.
+
+INFO is a plist used as a communication channel.
+
+Return value is a list of symbols, or nil.  Possible values are:
+`top', `bottom', `above', `below', `left' and `right'.  Note:
+`top' (resp. `bottom') only happen for a cell in the first
+row (resp. last row) of the table, ignoring table rules, if any.
+
+Returned borders ignore special rows."
+  (let* ((row (org-export-get-parent table-cell))
+        (table (org-export-get-parent-table table-cell))
+        borders)
+    ;; Top/above border?  TABLE-CELL has a border above when a rule
+    ;; used to demarcate row groups can be found above.  Hence,
+    ;; finding a rule isn't sufficient to push `above' in BORDERS:
+    ;; another regular row has to be found above that rule.
+    (let (rule-flag)
+      (catch 'exit
+       (mapc (lambda (row)
+               (cond ((eq (org-element-property :type row) 'rule)
+                      (setq rule-flag t))
+                     ((not (org-export-table-row-is-special-p row info))
+                      (if rule-flag (throw 'exit (push 'above borders))
+                        (throw 'exit nil)))))
+             ;; Look at every row before the current one.
+             (cdr (memq row (reverse (org-element-contents table)))))
+       ;; No rule above, or rule found starts the table (ignoring any
+       ;; special row): TABLE-CELL is at the top of the table.
+       (when rule-flag (push 'above borders))
+       (push 'top borders)))
+    ;; Bottom/below border? TABLE-CELL has a border below when next
+    ;; non-regular row below is a rule.
+    (let (rule-flag)
+      (catch 'exit
+       (mapc (lambda (row)
+               (cond ((eq (org-element-property :type row) 'rule)
+                      (setq rule-flag t))
+                     ((not (org-export-table-row-is-special-p row info))
+                      (if rule-flag (throw 'exit (push 'below borders))
+                        (throw 'exit nil)))))
+             ;; Look at every row after the current one.
+             (cdr (memq row (org-element-contents table))))
+       ;; No rule below, or rule found ends the table (modulo some
+       ;; special row): TABLE-CELL is at the bottom of the table.
+       (when rule-flag (push 'below borders))
+       (push 'bottom borders)))
+    ;; Right/left borders?  They can only be specified by column
+    ;; groups.  Column groups are defined in a row starting with "/".
+    ;; Also a column groups row only contains "<", "<>", ">" or blank
+    ;; cells.
+    (catch 'exit
+      (let ((column (let ((cells (org-element-contents row)))
+                     (- (length cells) (length (memq table-cell cells))))))
+       (mapc
+        (lambda (row)
+          (unless (eq (org-element-property :type row) 'rule)
+            (when (equal (org-element-contents
+                          (car (org-element-contents row)))
+                         '("/"))
+              (let ((column-groups
+                     (mapcar
+                      (lambda (cell)
+                        (let ((value (org-element-contents cell)))
+                          (when (member value '(("<") ("<>") (">") nil))
+                            (car value))))
+                      (org-element-contents row))))
+                ;; There's a left border when previous cell, if
+                ;; any, ends a group, or current one starts one.
+                (when (or (and (not (zerop column))
+                               (member (elt column-groups (1- column))
+                                       '(">" "<>")))
+                          (member (elt column-groups column) '("<" "<>")))
+                  (push 'left borders))
+                ;; There's a right border when next cell, if any,
+                ;; starts a group, or current one ends one.
+                (when (or (and (/= (1+ column) (length column-groups))
+                               (member (elt column-groups (1+ column))
+                                       '("<" "<>")))
+                          (member (elt column-groups column) '(">" "<>")))
+                  (push 'right borders))
+                (throw 'exit nil)))))
+        ;; Table rows are read in reverse order so last column groups
+        ;; row has precedence over any previous one.
+        (reverse (org-element-contents table)))))
+    ;; Return value.
+    borders))
+
+(defun org-export-table-cell-starts-colgroup-p (table-cell info)
+  "Non-nil when TABLE-CELL is at the beginning of a row group.
+INFO is a plist used as a communication channel."
+  ;; A cell starts a column group either when it is at the beginning
+  ;; of a row (or after the special column, if any) or when it has
+  ;; a left border.
+  (or (eq (org-element-map (org-export-get-parent table-cell) 'table-cell
+           'identity info 'first-match)
+         table-cell)
+      (memq 'left (org-export-table-cell-borders table-cell info))))
+
+(defun org-export-table-cell-ends-colgroup-p (table-cell info)
+  "Non-nil when TABLE-CELL is at the end of a row group.
+INFO is a plist used as a communication channel."
+  ;; A cell ends a column group either when it is at the end of a row
+  ;; or when it has a right border.
+  (or (eq (car (last (org-element-contents
+                        (org-export-get-parent table-cell))))
+            table-cell)
+      (memq 'right (org-export-table-cell-borders table-cell info))))
+
+(defun org-export-table-row-starts-rowgroup-p (table-row info)
+  "Non-nil when TABLE-ROW is at the beginning of a column group.
+INFO is a plist used as a communication channel."
+  (unless (or (eq (org-element-property :type table-row) 'rule)
+             (org-export-table-row-is-special-p table-row info))
+    (let ((borders (org-export-table-cell-borders
+                   (car (org-element-contents table-row)) info)))
+      (or (memq 'top borders) (memq 'above borders)))))
+
+(defun org-export-table-row-ends-rowgroup-p (table-row info)
+  "Non-nil when TABLE-ROW is at the end of a column group.
+INFO is a plist used as a communication channel."
+  (unless (or (eq (org-element-property :type table-row) 'rule)
+             (org-export-table-row-is-special-p table-row info))
+    (let ((borders (org-export-table-cell-borders
+                   (car (org-element-contents table-row)) info)))
+      (or (memq 'bottom borders) (memq 'below borders)))))
+
+(defun org-export-table-row-starts-header-p (table-row info)
+  "Non-nil when TABLE-ROW is the first table header's row.
+INFO is a plist used as a communication channel."
+  (and (org-export-table-has-header-p
+       (org-export-get-parent-table table-row) info)
+       (org-export-table-row-starts-rowgroup-p table-row info)
+       (= (org-export-table-row-group table-row info) 1)))
+
+(defun org-export-table-row-ends-header-p (table-row info)
+  "Non-nil when TABLE-ROW is the last table header's row.
+INFO is a plist used as a communication channel."
+  (and (org-export-table-has-header-p
+       (org-export-get-parent-table table-row) info)
+       (org-export-table-row-ends-rowgroup-p table-row info)
+       (= (org-export-table-row-group table-row info) 1)))
+
+(defun org-export-table-row-number (table-row info)
+  "Return TABLE-ROW number.
+INFO is a plist used as a communication channel.  Return value is
+zero-based and ignores separators.  The function returns nil for
+special columns and separators."
+  (when (and (eq (org-element-property :type table-row) 'standard)
+            (not (org-export-table-row-is-special-p table-row info)))
+    (let ((number 0))
+      (org-element-map (org-export-get-parent-table table-row) 'table-row
+       (lambda (row)
+         (cond ((eq row table-row) number)
+               ((eq (org-element-property :type row) 'standard)
+                (incf number) nil)))
+       info 'first-match))))
+
+(defun org-export-table-dimensions (table info)
+  "Return TABLE dimensions.
+
+INFO is a plist used as a communication channel.
+
+Return value is a CONS like (ROWS . COLUMNS) where
+ROWS (resp. COLUMNS) is the number of exportable
+rows (resp. columns)."
+  (let (first-row (columns 0) (rows 0))
+    ;; Set number of rows, and extract first one.
+    (org-element-map table 'table-row
+      (lambda (row)
+       (when (eq (org-element-property :type row) 'standard)
+         (incf rows)
+         (unless first-row (setq first-row row)))) info)
+    ;; Set number of columns.
+    (org-element-map first-row 'table-cell (lambda (cell) (incf columns)) info)
+    ;; Return value.
+    (cons rows columns)))
+
+(defun org-export-table-cell-address (table-cell info)
+  "Return address of a regular TABLE-CELL object.
+
+TABLE-CELL is the cell considered.  INFO is a plist used as
+a communication channel.
+
+Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
+zero-based index.  Only exportable cells are considered.  The
+function returns nil for other cells."
+  (let* ((table-row (org-export-get-parent table-cell))
+        (row-number (org-export-table-row-number table-row info)))
+    (when row-number
+      (cons row-number
+           (let ((col-count 0))
+             (org-element-map table-row 'table-cell
+               (lambda (cell)
+                 (if (eq cell table-cell) col-count (incf col-count) nil))
+               info 'first-match))))))
+
+(defun org-export-get-table-cell-at (address table info)
+  "Return regular table-cell object at ADDRESS in TABLE.
+
+Address is a CONS cell (ROW . COLUMN), where ROW and COLUMN are
+zero-based index.  TABLE is a table type element.  INFO is
+a plist used as a communication channel.
+
+If no table-cell, among exportable cells, is found at ADDRESS,
+return nil."
+  (let ((column-pos (cdr address)) (column-count 0))
+    (org-element-map
+       ;; Row at (car address) or nil.
+       (let ((row-pos (car address)) (row-count 0))
+         (org-element-map table 'table-row
+           (lambda (row)
+             (cond ((eq (org-element-property :type row) 'rule) nil)
+                   ((= row-count row-pos) row)
+                   (t (incf row-count) nil)))
+           info 'first-match))
+       'table-cell
+      (lambda (cell)
+       (if (= column-count column-pos) cell
+         (incf column-count) nil))
+      info 'first-match)))
+
+
+;;;; For Tables Of Contents
+;;
+;; `org-export-collect-headlines' builds a list of all exportable
+;; headline elements, maybe limited to a certain depth.  One can then
+;; easily parse it and transcode it.
+;;
+;; Building lists of tables, figures or listings is quite similar.
+;; Once the generic function `org-export-collect-elements' is defined,
+;; `org-export-collect-tables', `org-export-collect-figures' and
+;; `org-export-collect-listings' can be derived from it.
+
+(defun org-export-collect-headlines (info &optional n)
+  "Collect headlines in order to build a table of contents.
+
+INFO is a plist used as a communication channel.
+
+When optional argument N is an integer, it specifies the depth of
+the table of contents.  Otherwise, it is set to the value of the
+last headline level.  See `org-export-headline-levels' for more
+information.
+
+Return a list of all exportable headlines as parsed elements.
+Footnote sections, if any, will be ignored."
+  (let ((limit (plist-get info :headline-levels)))
+    (setq n (if (wholenump n) (min n limit) limit))
+    (org-element-map (plist-get info :parse-tree) 'headline
+      #'(lambda (headline)
+         (unless (org-element-property :footnote-section-p headline)
+           (let ((level (org-export-get-relative-level headline info)))
+             (and (<= level n) headline))))
+      info)))
+
+(defun org-export-collect-elements (type info &optional predicate)
+  "Collect referenceable elements of a determined type.
+
+TYPE can be a symbol or a list of symbols specifying element
+types to search.  Only elements with a caption are collected.
+
+INFO is a plist used as a communication channel.
+
+When non-nil, optional argument PREDICATE is a function accepting
+one argument, an element of type TYPE.  It returns a non-nil
+value when that element should be collected.
+
+Return a list of all elements found, in order of appearance."
+  (org-element-map (plist-get info :parse-tree) type
+    (lambda (element)
+      (and (org-element-property :caption element)
+          (or (not predicate) (funcall predicate element))
+          element))
+    info))
+
+(defun org-export-collect-tables (info)
+  "Build a list of tables.
+INFO is a plist used as a communication channel.
+
+Return a list of table elements with a caption."
+  (org-export-collect-elements 'table info))
+
+(defun org-export-collect-figures (info predicate)
+  "Build a list of figures.
+
+INFO is a plist used as a communication channel.  PREDICATE is
+a function which accepts one argument: a paragraph element and
+whose return value is non-nil when that element should be
+collected.
+
+A figure is a paragraph type element, with a caption, verifying
+PREDICATE.  The latter has to be provided since a \"figure\" is
+a vague concept that may depend on back-end.
+
+Return a list of elements recognized as figures."
+  (org-export-collect-elements 'paragraph info predicate))
+
+(defun org-export-collect-listings (info)
+  "Build a list of src blocks.
+
+INFO is a plist used as a communication channel.
+
+Return a list of src-block elements with a caption."
+  (org-export-collect-elements 'src-block info))
+
+
+;;;; Smart Quotes
+;;
+;; The main function for the smart quotes sub-system is
+;; `org-export-activate-smart-quotes', which replaces every quote in
+;; a given string from the parse tree with its "smart" counterpart.
+;;
+;; Dictionary for smart quotes is stored in
+;; `org-export-smart-quotes-alist'.
+;;
+;; Internally, regexps matching potential smart quotes (checks at
+;; string boundaries are also necessary) are defined in
+;; `org-export-smart-quotes-regexps'.
+
+(defconst org-export-smart-quotes-alist
+  '(("da"
+     ;; one may use: »...«, "...", ›...‹, or '...'.
+     ;; http://sproget.dk/raad-og-regler/retskrivningsregler/retskrivningsregler/a7-40-60/a7-58-anforselstegn/
+     ;; LaTeX quotes require Babel!
+     (opening-double-quote :utf-8 "»" :html "&raquo;" :latex ">>"
+                          :texinfo "@guillemetright{}")
+     (closing-double-quote :utf-8 "«" :html "&laquo;" :latex "<<"
+                          :texinfo "@guillemetleft{}")
+     (opening-single-quote :utf-8 "›" :html "&rsaquo;" :latex "\\frq{}"
+                          :texinfo "@guilsinglright{}")
+     (closing-single-quote :utf-8 "‹" :html "&lsaquo;" :latex "\\flq{}"
+                          :texinfo "@guilsingleft{}")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("de"
+     (opening-double-quote :utf-8 "„" :html "&bdquo;" :latex "\"`"
+                          :texinfo "@quotedblbase{}")
+     (closing-double-quote :utf-8 "“" :html "&ldquo;" :latex "\"'"
+                          :texinfo "@quotedblleft{}")
+     (opening-single-quote :utf-8 "‚" :html "&sbquo;" :latex "\\glq{}"
+                          :texinfo "@quotesinglbase{}")
+     (closing-single-quote :utf-8 "‘" :html "&lsquo;" :latex "\\grq{}"
+                          :texinfo "@quoteleft{}")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("en"
+     (opening-double-quote :utf-8 "“" :html "&ldquo;" :latex "``" :texinfo "``")
+     (closing-double-quote :utf-8 "”" :html "&rdquo;" :latex "''" :texinfo "''")
+     (opening-single-quote :utf-8 "‘" :html "&lsquo;" :latex "`" :texinfo "`")
+     (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "'" :texinfo "'")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("es"
+     (opening-double-quote :utf-8 "«" :html "&laquo;" :latex "\\guillemotleft{}"
+                          :texinfo "@guillemetleft{}")
+     (closing-double-quote :utf-8 "»" :html "&raquo;" :latex "\\guillemotright{}"
+                          :texinfo "@guillemetright{}")
+     (opening-single-quote :utf-8 "“" :html "&ldquo;" :latex "``" :texinfo "``")
+     (closing-single-quote :utf-8 "”" :html "&rdquo;" :latex "''" :texinfo "''")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("fr"
+     (opening-double-quote :utf-8 "« " :html "&laquo;&nbsp;" :latex "\\og "
+                          :texinfo "@guillemetleft{}@tie{}")
+     (closing-double-quote :utf-8 " »" :html "&nbsp;&raquo;" :latex "\\fg{}"
+                          :texinfo "@tie{}@guillemetright{}")
+     (opening-single-quote :utf-8 "« " :html "&laquo;&nbsp;" :latex "\\og "
+                          :texinfo "@guillemetleft{}@tie{}")
+     (closing-single-quote :utf-8 " »" :html "&nbsp;&raquo;" :latex "\\fg{}"
+                          :texinfo "@tie{}@guillemetright{}")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("no"
+     ;; https://nn.wikipedia.org/wiki/Sitatteikn
+     (opening-double-quote :utf-8 "«" :html "&laquo;" :latex "\\guillemotleft{}"
+                          :texinfo "@guillemetleft{}")
+     (closing-double-quote :utf-8 "»" :html "&raquo;" :latex "\\guillemotright{}"
+                          :texinfo "@guillemetright{}")
+     (opening-single-quote :utf-8 "‘" :html "&lsquo;" :latex "`" :texinfo "`")
+     (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "'" :texinfo "'")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("nb"
+     ;; https://nn.wikipedia.org/wiki/Sitatteikn
+     (opening-double-quote :utf-8 "«" :html "&laquo;" :latex "\\guillemotleft{}"
+                          :texinfo "@guillemetleft{}")
+     (closing-double-quote :utf-8 "»" :html "&raquo;" :latex "\\guillemotright{}"
+                          :texinfo "@guillemetright{}")
+     (opening-single-quote :utf-8 "‘" :html "&lsquo;" :latex "`" :texinfo "`")
+     (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "'" :texinfo "'")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("nn"
+     ;; https://nn.wikipedia.org/wiki/Sitatteikn
+     (opening-double-quote :utf-8 "«" :html "&laquo;" :latex "\\guillemotleft{}"
+                          :texinfo "@guillemetleft{}")
+     (closing-double-quote :utf-8 "»" :html "&raquo;" :latex "\\guillemotright{}"
+                          :texinfo "@guillemetright{}")
+     (opening-single-quote :utf-8 "‘" :html "&lsquo;" :latex "`" :texinfo "`")
+     (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "'" :texinfo "'")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    ("sv"
+     ;; based on https://sv.wikipedia.org/wiki/Citattecken
+     (opening-double-quote :utf-8 "”" :html "&rdquo;" :latex "’’" :texinfo "’’")
+     (closing-double-quote :utf-8 "”" :html "&rdquo;" :latex "’’" :texinfo "’’")
+     (opening-single-quote :utf-8 "’" :html "&rsquo;" :latex "’" :texinfo "`")
+     (closing-single-quote :utf-8 "’" :html "&rsquo;" :latex "’" :texinfo "'")
+     (apostrophe :utf-8 "’" :html "&rsquo;"))
+    )
+  "Smart quotes translations.
+
+Alist whose CAR is a language string and CDR is an alist with
+quote type as key and a plist associating various encodings to
+their translation as value.
+
+A quote type can be any symbol among `opening-double-quote',
+`closing-double-quote', `opening-single-quote',
+`closing-single-quote' and `apostrophe'.
+
+Valid encodings include `:utf-8', `:html', `:latex' and
+`:texinfo'.
+
+If no translation is found, the quote character is left as-is.")
+
+(defconst org-export-smart-quotes-regexps
+  (list
+   ;; Possible opening quote at beginning of string.
+   "\\`\\([\"']\\)\\(\\w\\|\\s.\\|\\s_\\)"
+   ;; Possible closing quote at beginning of string.
+   "\\`\\([\"']\\)\\(\\s-\\|\\s)\\|\\s.\\)"
+   ;; Possible apostrophe at beginning of string.
+   "\\`\\('\\)\\S-"
+   ;; Opening single and double quotes.
+   "\\(?:\\s-\\|\\s(\\)\\([\"']\\)\\(?:\\w\\|\\s.\\|\\s_\\)"
+   ;; Closing single and double quotes.
+   "\\(?:\\w\\|\\s.\\|\\s_\\)\\([\"']\\)\\(?:\\s-\\|\\s)\\|\\s.\\)"
+   ;; Apostrophe.
+   "\\S-\\('\\)\\S-"
+   ;; Possible opening quote at end of string.
+   "\\(?:\\s-\\|\\s(\\)\\([\"']\\)\\'"
+   ;; Possible closing quote at end of string.
+   "\\(?:\\w\\|\\s.\\|\\s_\\)\\([\"']\\)\\'"
+   ;; Possible apostrophe at end of string.
+   "\\S-\\('\\)\\'")
+  "List of regexps matching a quote or an apostrophe.
+In every regexp, quote or apostrophe matched is put in group 1.")
+
+(defun org-export-activate-smart-quotes (s encoding info &optional original)
+  "Replace regular quotes with \"smart\" quotes in string S.
+
+ENCODING is a symbol among `:html', `:latex', `:texinfo' and
+`:utf-8'.  INFO is a plist used as a communication channel.
+
+The function has to retrieve information about string
+surroundings in parse tree.  It can only happen with an
+unmodified string.  Thus, if S has already been through another
+process, a non-nil ORIGINAL optional argument will provide that
+original string.
+
+Return the new string."
+  (if (equal s "") ""
+    (let* ((prev (org-export-get-previous-element (or original s) info))
+          ;; Try to be flexible when computing number of blanks
+          ;; before object.  The previous object may be a string
+          ;; introduced by the back-end and not completely parsed.
+          (pre-blank (and prev
+                          (or (org-element-property :post-blank prev)
+                              ;; A string with missing `:post-blank'
+                              ;; property.
+                              (and (stringp prev)
+                                   (string-match " *\\'" prev)
+                                   (length (match-string 0 prev)))
+                              ;; Fallback value.
+                              0)))
+          (next (org-export-get-next-element (or original s) info))
+          (get-smart-quote
+           (lambda (q type)
+             ;; Return smart quote associated to a give quote Q, as
+             ;; a string.  TYPE is a symbol among `open', `close' and
+             ;; `apostrophe'.
+             (let ((key (case type
+                          (apostrophe 'apostrophe)
+                          (open (if (equal "'" q) 'opening-single-quote
+                                  'opening-double-quote))
+                          (otherwise (if (equal "'" q) 'closing-single-quote
+                                       'closing-double-quote)))))
+               (or (plist-get
+                    (cdr (assq key
+                               (cdr (assoc (plist-get info :language)
+                                           org-export-smart-quotes-alist))))
+                    encoding)
+                   q)))))
+      (if (or (equal "\"" s) (equal "'" s))
+         ;; Only a quote: no regexp can match.  We have to check both
+         ;; sides and decide what to do.
+         (cond ((and (not prev) (not next)) s)
+               ((not prev) (funcall get-smart-quote s 'open))
+               ((and (not next) (zerop pre-blank))
+                (funcall get-smart-quote s 'close))
+               ((not next) s)
+               ((zerop pre-blank) (funcall get-smart-quote s 'apostrophe))
+               (t (funcall get-smart-quote 'open)))
+       ;; 1. Replace quote character at the beginning of S.
+       (cond
+        ;; Apostrophe?
+        ((and prev (zerop pre-blank)
+              (string-match (nth 2 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'apostrophe)
+                  nil t s 1)))
+        ;; Closing quote?
+        ((and prev (zerop pre-blank)
+              (string-match (nth 1 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'close)
+                  nil t s 1)))
+        ;; Opening quote?
+        ((and (or (not prev) (> pre-blank 0))
+              (string-match (nth 0 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'open)
+                  nil t s 1))))
+       ;; 2. Replace quotes in the middle of the string.
+       (setq s (replace-regexp-in-string
+                ;; Opening quotes.
+                (nth 3 org-export-smart-quotes-regexps)
+                (lambda (text)
+                  (funcall get-smart-quote (match-string 1 text) 'open))
+                s nil t 1))
+       (setq s (replace-regexp-in-string
+                ;; Closing quotes.
+                (nth 4 org-export-smart-quotes-regexps)
+                (lambda (text)
+                  (funcall get-smart-quote (match-string 1 text) 'close))
+                s nil t 1))
+       (setq s (replace-regexp-in-string
+                ;; Apostrophes.
+                (nth 5 org-export-smart-quotes-regexps)
+                (lambda (text)
+                  (funcall get-smart-quote (match-string 1 text) 'apostrophe))
+                s nil t 1))
+       ;; 3. Replace quote character at the end of S.
+       (cond
+        ;; Apostrophe?
+        ((and next (string-match (nth 8 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'apostrophe)
+                  nil t s 1)))
+        ;; Closing quote?
+        ((and (not next)
+              (string-match (nth 7 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'close)
+                  nil t s 1)))
+        ;; Opening quote?
+        ((and next (string-match (nth 6 org-export-smart-quotes-regexps) s))
+         (setq s (replace-match
+                  (funcall get-smart-quote (match-string 1 s) 'open)
+                  nil t s 1))))
+       ;; Return string with smart quotes.
+       s))))
+
+;;;; Topology
+;;
+;; Here are various functions to retrieve information about the
+;; neighbourhood of a given element or object.  Neighbours of interest
+;; are direct parent (`org-export-get-parent'), parent headline
+;; (`org-export-get-parent-headline'), first element containing an
+;; object, (`org-export-get-parent-element'), parent table
+;; (`org-export-get-parent-table'), previous element or object
+;; (`org-export-get-previous-element') and next element or object
+;; (`org-export-get-next-element').
+;;
+;; `org-export-get-genealogy' returns the full genealogy of a given
+;; element or object, from closest parent to full parse tree.
+
+(defsubst org-export-get-parent (blob)
+  "Return BLOB parent or nil.
+BLOB is the element or object considered."
+  (org-element-property :parent blob))
+
+(defun org-export-get-genealogy (blob)
+  "Return full genealogy relative to a given element or object.
+
+BLOB is the element or object being considered.
+
+Ancestors are returned from closest to farthest, the last one
+being the full parse tree."
+  (let (genealogy (parent blob))
+    (while (setq parent (org-element-property :parent parent))
+      (push parent genealogy))
+    (nreverse genealogy)))
+
+(defun org-export-get-parent-headline (blob)
+  "Return BLOB parent headline or nil.
+BLOB is the element or object being considered."
+  (let ((parent blob))
+    (while (and (setq parent (org-element-property :parent parent))
+               (not (eq (org-element-type parent) 'headline))))
+    parent))
+
+(defun org-export-get-parent-element (object)
+  "Return first element containing OBJECT or nil.
+OBJECT is the object to consider."
+  (let ((parent object))
+    (while (and (setq parent (org-element-property :parent parent))
+               (memq (org-element-type parent) org-element-all-objects)))
+    parent))
+
+(defun org-export-get-parent-table (object)
+  "Return OBJECT parent table or nil.
+OBJECT is either a `table-cell' or `table-element' type object."
+  (let ((parent object))
+    (while (and (setq parent (org-element-property :parent parent))
+               (not (eq (org-element-type parent) 'table))))
+    parent))
+
+(defun org-export-get-previous-element (blob info &optional n)
+  "Return previous element or object.
+
+BLOB is an element or object.  INFO is a plist used as
+a communication channel.  Return previous exportable element or
+object, a string, or nil.
+
+When optional argument N is a positive integer, return a list
+containing up to N siblings before BLOB, from farthest to
+closest.  With any other non-nil value, return a list containing
+all of them."
+  (let ((siblings
+        ;; An object can belong to the contents of its parent or
+        ;; to a secondary string.  We check the latter option
+        ;; first.
+        (let ((parent (org-export-get-parent blob)))
+          (or (let ((sec-value (org-element-property
+                                (cdr (assq (org-element-type parent)
+                                           org-element-secondary-value-alist))
+                                parent)))
+                (and (memq blob sec-value) sec-value))
+              (org-element-contents parent))))
+       prev)
+    (catch 'exit
+      (mapc (lambda (obj)
+             (cond ((memq obj (plist-get info :ignore-list)))
+                   ((null n) (throw 'exit obj))
+                   ((not (wholenump n)) (push obj prev))
+                   ((zerop n) (throw 'exit prev))
+                   (t (decf n) (push obj prev))))
+           (cdr (memq blob (reverse siblings))))
+      prev)))
+
+(defun org-export-get-next-element (blob info &optional n)
+  "Return next element or object.
+
+BLOB is an element or object.  INFO is a plist used as
+a communication channel.  Return next exportable element or
+object, a string, or nil.
+
+When optional argument N is a positive integer, return a list
+containing up to N siblings after BLOB, from closest to farthest.
+With any other non-nil value, return a list containing all of
+them."
+  (let ((siblings
+        ;; An object can belong to the contents of its parent or to
+        ;; a secondary string.  We check the latter option first.
+        (let ((parent (org-export-get-parent blob)))
+          (or (let ((sec-value (org-element-property
+                                (cdr (assq (org-element-type parent)
+                                           org-element-secondary-value-alist))
+                                parent)))
+                (cdr (memq blob sec-value)))
+              (cdr (memq blob (org-element-contents parent))))))
+       next)
+    (catch 'exit
+      (mapc (lambda (obj)
+             (cond ((memq obj (plist-get info :ignore-list)))
+                   ((null n) (throw 'exit obj))
+                   ((not (wholenump n)) (push obj next))
+                   ((zerop n) (throw 'exit (nreverse next)))
+                   (t (decf n) (push obj next))))
+           siblings)
+      (nreverse next))))
+
+
+;;;; Translation
+;;
+;; `org-export-translate' translates a string according to the language
+;; specified by the LANGUAGE keyword.  `org-export-dictionary' contains
+;; the dictionary used for the translation.
+
+(defconst org-export-dictionary
+  '(("%e %n: %c"
+     ("fr" :default "%e %n : %c" :html "%e&nbsp;%n&nbsp;: %c"))
+    ("Author"
+     ("ca" :default "Autor")
+     ("cs" :default "Autor")
+     ("da" :default "Forfatter")
+     ("de" :default "Autor")
+     ("eo" :html "A&#365;toro")
+     ("es" :default "Autor")
+     ("fi" :html "Tekij&auml;")
+     ("fr" :default "Auteur")
+     ("hu" :default "Szerz&otilde;")
+     ("is" :html "H&ouml;fundur")
+     ("it" :default "Autore")
+     ("ja" :html "&#33879;&#32773;" :utf-8 "著者")
+     ("nl" :default "Auteur")
+     ("no" :default "Forfatter")
+     ("nb" :default "Forfatter")
+     ("nn" :default "Forfattar")
+     ("pl" :default "Autor")
+     ("ru" :html "&#1040;&#1074;&#1090;&#1086;&#1088;" :utf-8 "Автор")
+     ("sv" :html "F&ouml;rfattare")
+     ("uk" :html "&#1040;&#1074;&#1090;&#1086;&#1088;" :utf-8 "Автор")
+     ("zh-CN" :html "&#20316;&#32773;" :utf-8 "作者")
+     ("zh-TW" :html "&#20316;&#32773;" :utf-8 "作者"))
+    ("Date"
+     ("ca" :default "Data")
+     ("cs" :default "Datum")
+     ("da" :default "Dato")
+     ("de" :default "Datum")
+     ("eo" :default "Dato")
+     ("es" :default "Fecha")
+     ("fi" :html "P&auml;iv&auml;m&auml;&auml;r&auml;")
+     ("hu" :html "D&aacute;tum")
+     ("is" :default "Dagsetning")
+     ("it" :default "Data")
+     ("ja" :html "&#26085;&#20184;" :utf-8 "日付")
+     ("nl" :default "Datum")
+     ("no" :default "Dato")
+     ("nb" :default "Dato")
+     ("nn" :default "Dato")
+     ("pl" :default "Data")
+     ("ru" :html "&#1044;&#1072;&#1090;&#1072;" :utf-8 "Дата")
+     ("sv" :default "Datum")
+     ("uk" :html "&#1044;&#1072;&#1090;&#1072;" :utf-8 "Дата")
+     ("zh-CN" :html "&#26085;&#26399;" :utf-8 "日期")
+     ("zh-TW" :html "&#26085;&#26399;" :utf-8 "日期"))
+    ("Equation"
+     ("da" :default "Ligning")
+     ("de" :default "Gleichung")
+     ("es" :html "Ecuaci&oacute;n" :default "Ecuación")
+     ("fr" :ascii "Equation" :default "Équation")
+     ("no" :default "Ligning")
+     ("nb" :default "Ligning")
+     ("nn" :default "Likning")
+     ("sv" :default "Ekvation")
+     ("zh-CN" :html "&#26041;&#31243;" :utf-8 "方程"))
+    ("Figure"
+     ("da" :default "Figur")
+     ("de" :default "Abbildung")
+     ("es" :default "Figura")
+     ("ja" :html "&#22259;" :utf-8 "図")
+     ("no" :default "Illustrasjon")
+     ("nb" :default "Illustrasjon")
+     ("nn" :default "Illustrasjon")
+     ("sv" :default "Illustration")
+     ("zh-CN" :html "&#22270;" :utf-8 "图"))
+    ("Figure %d:"
+     ("da" :default "Figur %d")
+     ("de" :default "Abbildung %d:")
+     ("es" :default "Figura %d:")
+     ("fr" :default "Figure %d :" :html "Figure&nbsp;%d&nbsp;:")
+     ("ja" :html "&#22259;%d: " :utf-8 "図%d: ")
+     ("no" :default "Illustrasjon %d")
+     ("nb" :default "Illustrasjon %d")
+     ("nn" :default "Illustrasjon %d")
+     ("sv" :default "Illustration %d")
+     ("zh-CN" :html "&#22270;%d&nbsp;" :utf-8 "图%d "))
+    ("Footnotes"
+     ("ca" :html "Peus de p&agrave;gina")
+     ("cs" :default "Pozn\xe1mky pod carou")
+     ("da" :default "Fodnoter")
+     ("de" :html "Fu&szlig;noten" :default "Fußnoten")
+     ("eo" :default "Piednotoj")
+     ("es" :html "Nota al pie de p&aacute;gina" :default "Nota al pie de página")
+     ("fi" :default "Alaviitteet")
+     ("fr" :default "Notes de bas de page")
+     ("hu" :html "L&aacute;bjegyzet")
+     ("is" :html "Aftanm&aacute;lsgreinar")
+     ("it" :html "Note a pi&egrave; di pagina")
+     ("ja" :html "&#33050;&#27880;" :utf-8 "脚注")
+     ("nl" :default "Voetnoten")
+     ("no" :default "Fotnoter")
+     ("nb" :default "Fotnoter")
+     ("nn" :default "Fotnotar")
+     ("pl" :default "Przypis")
+     ("ru" :html "&#1057;&#1085;&#1086;&#1089;&#1082;&#1080;" :utf-8 "Сноски")
+     ("sv" :default "Fotnoter")
+     ("uk" :html "&#1055;&#1088;&#1080;&#1084;&#1110;&#1090;&#1082;&#1080;"
+      :utf-8 "Примітки")
+     ("zh-CN" :html "&#33050;&#27880;" :utf-8 "脚注")
+     ("zh-TW" :html "&#33139;&#35387;" :utf-8 "腳註"))
+    ("List of Listings"
+     ("da" :default "Programmer")
+     ("de" :default "Programmauflistungsverzeichnis")
+     ("es" :default "Indice de Listados de programas")
+     ("fr" :default "Liste des programmes")
+     ("no" :default "Dataprogrammer")
+     ("nb" :default "Dataprogrammer")
+     ("zh-CN" :html "&#20195;&#30721;&#30446;&#24405;" :utf-8 "代码目录"))
+    ("List of Tables"
+     ("da" :default "Tabeller")
+     ("de" :default "Tabellenverzeichnis")
+     ("es" :default "Indice de tablas")
+     ("fr" :default "Liste des tableaux")
+     ("no" :default "Tabeller")
+     ("nb" :default "Tabeller")
+     ("nn" :default "Tabeller")
+     ("sv" :default "Tabeller")
+     ("zh-CN" :html "&#34920;&#26684;&#30446;&#24405;" :utf-8 "表格目录"))
+    ("Listing %d:"
+     ("da" :default "Program %d")
+     ("de" :default "Programmlisting %d")
+     ("es" :default "Listado de programa %d")
+     ("fr" :default "Programme %d :" :html "Programme&nbsp;%d&nbsp;:")
+     ("no" :default "Dataprogram")
+     ("nb" :default "Dataprogram")
+     ("zh-CN" :html "&#20195;&#30721;%d&nbsp;" :utf-8 "代码%d "))
+    ("See section %s"
+     ("da" :default "jævnfør afsnit %s")
+     ("de" :default "siehe Abschnitt %s")
+     ("es" :default "vea seccion %s")
+     ("fr" :default "cf. section %s")
+     ("zh-CN" :html "&#21442;&#35265;&#31532;%d&#33410;" :utf-8 "参见第%s节"))
+    ("Table"
+     ("de" :default "Tabelle")
+     ("es" :default "Tabla")
+     ("fr" :default "Tableau")
+     ("ja" :html "&#34920;" :utf-8 "表")
+     ("zh-CN" :html "&#34920;" :utf-8 "表"))
+    ("Table %d:"
+     ("da" :default "Tabel %d")
+     ("de" :default "Tabelle %d")
+     ("es" :default "Tabla %d")
+     ("fr" :default "Tableau %d :")
+     ("ja" :html "&#34920;%d:" :utf-8 "表%d:")
+     ("no" :default "Tabell %d")
+     ("nb" :default "Tabell %d")
+     ("nn" :default "Tabell %d")
+     ("sv" :default "Tabell %d")
+     ("zh-CN" :html "&#34920;%d&nbsp;" :utf-8 "表%d "))
+    ("Table of Contents"
+     ("ca" :html "&Iacute;ndex")
+     ("cs" :default "Obsah")
+     ("da" :default "Indhold")
+     ("de" :default "Inhaltsverzeichnis")
+     ("eo" :default "Enhavo")
+     ("es" :html "&Iacute;ndice")
+     ("fi" :html "Sis&auml;llysluettelo")
+     ("fr" :ascii "Sommaire" :default "Table des matières")
+     ("hu" :html "Tartalomjegyz&eacute;k")
+     ("is" :default "Efnisyfirlit")
+     ("it" :default "Indice")
+     ("ja" :html "&#30446;&#27425;" :utf-8 "目次")
+     ("nl" :default "Inhoudsopgave")
+     ("no" :default "Innhold")
+     ("nb" :default "Innhold")
+     ("nn" :default "Innhald")
+     ("pl" :html "Spis tre&#x015b;ci")
+     ("ru" :html "&#1057;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1077;"
+      :utf-8 "Содержание")
+     ("sv" :html "Inneh&aring;ll")
+     ("uk" :html "&#1047;&#1084;&#1110;&#1089;&#1090;" :utf-8 "Зміст")
+     ("zh-CN" :html "&#30446;&#24405;" :utf-8 "目录")
+     ("zh-TW" :html "&#30446;&#37636;" :utf-8 "目錄"))
+    ("Unknown reference"
+     ("da" :default "ukendt reference")
+     ("de" :default "Unbekannter Verweis")
+     ("es" :default "referencia desconocida")
+     ("fr" :ascii "Destination inconnue" :default "Référence inconnue")
+     ("zh-CN" :html "&#26410;&#30693;&#24341;&#29992;" :utf-8 "未知引用")))
+  "Dictionary for export engine.
+
+Alist whose CAR is the string to translate and CDR is an alist
+whose CAR is the language string and CDR is a plist whose
+properties are possible charsets and values translated terms.
+
+It is used as a database for `org-export-translate'. Since this
+function returns the string as-is if no translation was found,
+the variable only needs to record values different from the
+entry.")
+
+(defun org-export-translate (s encoding info)
+  "Translate string S according to language specification.
+
+ENCODING is a symbol among `:ascii', `:html', `:latex', `:latin1'
+and `:utf-8'.  INFO is a plist used as a communication channel.
+
+Translation depends on `:language' property. Return the
+translated string. If no translation is found, try to fall back
+to `:default' encoding. If it fails, return S."
+  (let* ((lang (plist-get info :language))
+        (translations (cdr (assoc lang
+                                  (cdr (assoc s org-export-dictionary))))))
+    (or (plist-get translations encoding)
+       (plist-get translations :default)
+       s)))
+
+
+\f
+;;; Asynchronous Export
+;;
+;; `org-export-async-start' is the entry point for asynchronous
+;; export.  It recreates current buffer (including visibility,
+;; narrowing and visited file) in an external Emacs process, and
+;; evaluates a command there.  It then applies a function on the
+;; returned results in the current process.
+;;
+;; At a higher level, `org-export-to-buffer' and `org-export-to-file'
+;; allow to export to a buffer or a file, asynchronously or not.
+;;
+;; `org-export-output-file-name' is an auxiliary function meant to be
+;; used with `org-export-to-file'.  With a given extension, it tries
+;; to provide a canonical file name to write export output to.
+;;
+;; Asynchronously generated results are never displayed directly.
+;; Instead, they are stored in `org-export-stack-contents'.  They can
+;; then be retrieved by calling `org-export-stack'.
+;;
+;; Export Stack is viewed through a dedicated major mode
+;;`org-export-stack-mode' and tools: `org-export-stack-refresh',
+;;`org-export-stack-delete', `org-export-stack-view' and
+;;`org-export-stack-clear'.
+;;
+;; For back-ends, `org-export-add-to-stack' add a new source to stack.
+;; It should be used whenever `org-export-async-start' is called.
+
+(defmacro org-export-async-start  (fun &rest body)
+  "Call function FUN on the results returned by BODY evaluation.
+
+BODY evaluation happens in an asynchronous process, from a buffer
+which is an exact copy of the current one.
+
+Use `org-export-add-to-stack' in FUN in order to register results
+in the stack.
+
+This is a low level function.  See also `org-export-to-buffer'
+and `org-export-to-file' for more specialized functions."
+  (declare (indent 1) (debug t))
+  (org-with-gensyms (process temp-file copy-fun proc-buffer coding)
+    ;; Write the full sexp evaluating BODY in a copy of the current
+    ;; buffer to a temporary file, as it may be too long for program
+    ;; args in `start-process'.
+    `(with-temp-message "Initializing asynchronous export process"
+       (let ((,copy-fun (org-export--generate-copy-script (current-buffer)))
+             (,temp-file (make-temp-file "org-export-process"))
+             (,coding buffer-file-coding-system))
+         (with-temp-file ,temp-file
+           (insert
+            ;; Null characters (from variable values) are inserted
+            ;; within the file.  As a consequence, coding system for
+            ;; buffer contents will not be recognized properly.  So,
+            ;; we make sure it is the same as the one used to display
+            ;; the original buffer.
+            (format ";; -*- coding: %s; -*-\n%S"
+                    ,coding
+                    `(with-temp-buffer
+                       (when org-export-async-debug '(setq debug-on-error t))
+                       ;; Ignore `kill-emacs-hook' and code evaluation
+                       ;; queries from Babel as we need a truly
+                       ;; non-interactive process.
+                       (setq kill-emacs-hook nil
+                             org-babel-confirm-evaluate-answer-no t)
+                       ;; Initialize export framework.
+                       (require 'ox)
+                       ;; Re-create current buffer there.
+                       (funcall ,,copy-fun)
+                       (restore-buffer-modified-p nil)
+                       ;; Sexp to evaluate in the buffer.
+                       (print (progn ,,@body))))))
+         ;; Start external process.
+         (let* ((process-connection-type nil)
+                (,proc-buffer (generate-new-buffer-name "*Org Export Process*"))
+                (,process
+                 (start-process
+                  "org-export-process" ,proc-buffer
+                  (expand-file-name invocation-name invocation-directory)
+                  "-Q" "--batch"
+                  "-l" org-export-async-init-file
+                  "-l" ,temp-file)))
+           ;; Register running process in stack.
+           (org-export-add-to-stack (get-buffer ,proc-buffer) nil ,process)
+           ;; Set-up sentinel in order to catch results.
+           (let ((handler ,fun))
+             (set-process-sentinel
+              ,process
+              `(lambda (p status)
+                 (let ((proc-buffer (process-buffer p)))
+                   (when (eq (process-status p) 'exit)
+                     (unwind-protect
+                         (if (zerop (process-exit-status p))
+                             (unwind-protect
+                                 (let ((results
+                                        (with-current-buffer proc-buffer
+                                          (goto-char (point-max))
+                                          (backward-sexp)
+                                          (read (current-buffer)))))
+                                   (funcall ,handler results))
+                               (unless org-export-async-debug
+                                 (and (get-buffer proc-buffer)
+                                      (kill-buffer proc-buffer))))
+                           (org-export-add-to-stack proc-buffer nil p)
+                           (ding)
+                           (message "Process '%s' exited abnormally" p))
+                       (unless org-export-async-debug
+                         (delete-file ,,temp-file)))))))))))))
+
+;;;###autoload
+(defun org-export-to-buffer
+  (backend buffer
+          &optional async subtreep visible-only body-only ext-plist
+          post-process)
+  "Call `org-export-as' with output to a specified buffer.
+
+BACKEND is either an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.
+
+BUFFER is the name of the output buffer.  If it already exists,
+it will be erased first, otherwise, it will be created.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer should then be accessible
+through the `org-export-stack' interface.  When ASYNC is nil, the
+buffer is displayed if `org-export-show-temporary-export-buffer'
+is non-nil.
+
+Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
+EXT-PLIST are similar to those used in `org-export-as', which
+see.
+
+Optional argument POST-PROCESS is a function which should accept
+no argument.  It is always called within the current process,
+from BUFFER, with point at its beginning.  Export back-ends can
+use it to set a major mode there, e.g,
+
+  \(defun org-latex-export-as-latex
+    \(&optional async subtreep visible-only body-only ext-plist)
+    \(interactive)
+    \(org-export-to-buffer 'latex \"*Org LATEX Export*\"
+      async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
+
+This function returns BUFFER."
+  (declare (indent 2))
+  (if async
+      (org-export-async-start
+         `(lambda (output)
+            (with-current-buffer (get-buffer-create ,buffer)
+              (erase-buffer)
+              (setq buffer-file-coding-system ',buffer-file-coding-system)
+              (insert output)
+              (goto-char (point-min))
+              (org-export-add-to-stack (current-buffer) ',backend)
+              (ignore-errors (funcall ,post-process))))
+       `(org-export-as
+         ',backend ,subtreep ,visible-only ,body-only ',ext-plist))
+    (let ((output
+          (org-export-as backend subtreep visible-only body-only ext-plist))
+         (buffer (get-buffer-create buffer))
+         (encoding buffer-file-coding-system))
+      (when (and (org-string-nw-p output) (org-export--copy-to-kill-ring-p))
+       (org-kill-new output))
+      (with-current-buffer buffer
+       (erase-buffer)
+       (setq buffer-file-coding-system encoding)
+       (insert output)
+       (goto-char (point-min))
+       (and (functionp post-process) (funcall post-process)))
+      (when org-export-show-temporary-export-buffer
+       (switch-to-buffer-other-window buffer))
+      buffer)))
+
+;;;###autoload
+(defun org-export-to-file
+  (backend file &optional async subtreep visible-only body-only ext-plist
+          post-process)
+  "Call `org-export-as' with output to a specified file.
+
+BACKEND is either an export back-end, as returned by, e.g.,
+`org-export-create-backend', or a symbol referring to
+a registered back-end.  FILE is the name of the output file, as
+a string.
+
+A non-nil optional argument ASYNC means the process should happen
+asynchronously.  The resulting buffer file then be accessible
+through the `org-export-stack' interface.
+
+Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
+EXT-PLIST are similar to those used in `org-export-as', which
+see.
+
+Optional argument POST-PROCESS is called with FILE as its
+argument and happens asynchronously when ASYNC is non-nil.  It
+has to return a file name, or nil.  Export back-ends can use this
+to send the output file through additional processing, e.g,
+
+  \(defun org-latex-export-to-latex
+    \(&optional async subtreep visible-only body-only ext-plist)
+    \(interactive)
+    \(let ((outfile (org-export-output-file-name \".tex\" subtreep)))
+      \(org-export-to-file 'latex outfile
+        async subtreep visible-only body-only ext-plist
+        \(lambda (file) (org-latex-compile file)))
+
+The function returns either a file name returned by POST-PROCESS,
+or FILE."
+  (declare (indent 2))
+  (if (not (file-writable-p file)) (error "Output file not writable")
+    (let ((encoding (or org-export-coding-system buffer-file-coding-system)))
+      (if async
+          (org-export-async-start
+             `(lambda (file)
+                (org-export-add-to-stack (expand-file-name file) ',backend))
+           `(let ((output
+                   (org-export-as
+                    ',backend ,subtreep ,visible-only ,body-only
+                    ',ext-plist)))
+              (with-temp-buffer
+                (insert output)
+                (let ((coding-system-for-write ',encoding))
+                  (write-file ,file)))
+              (or (ignore-errors (funcall ',post-process ,file)) ,file)))
+        (let ((output (org-export-as
+                       backend subtreep visible-only body-only ext-plist)))
+          (with-temp-buffer
+            (insert output)
+            (let ((coding-system-for-write encoding))
+             (write-file file)))
+          (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p output))
+            (org-kill-new output))
+          ;; Get proper return value.
+          (or (and (functionp post-process) (funcall post-process file))
+             file))))))
+
+(defun org-export-output-file-name (extension &optional subtreep pub-dir)
+  "Return output file's name according to buffer specifications.
+
+EXTENSION is a string representing the output file extension,
+with the leading dot.
+
+With a non-nil optional argument SUBTREEP, try to determine
+output file's name by looking for \"EXPORT_FILE_NAME\" property
+of subtree at point.
+
+When optional argument PUB-DIR is set, use it as the publishing
+directory.
+
+When optional argument VISIBLE-ONLY is non-nil, don't export
+contents of hidden elements.
+
+Return file name as a string."
+  (let* ((visited-file (buffer-file-name (buffer-base-buffer)))
+        (base-name
+         ;; File name may come from EXPORT_FILE_NAME subtree
+         ;; property, assuming point is at beginning of said
+         ;; sub-tree.
+         (file-name-sans-extension
+          (or (and subtreep
+                   (org-entry-get
+                    (save-excursion
+                      (ignore-errors (org-back-to-heading) (point)))
+                    "EXPORT_FILE_NAME" t))
+              ;; File name may be extracted from buffer's associated
+              ;; file, if any.
+              (and visited-file (file-name-nondirectory visited-file))
+              ;; Can't determine file name on our own: Ask user.
+              (let ((read-file-name-function
+                     (and org-completion-use-ido 'ido-read-file-name)))
+                (read-file-name
+                 "Output file: " pub-dir nil nil nil
+                 (lambda (name)
+                   (string= (file-name-extension name t) extension)))))))
+        (output-file
+         ;; Build file name.  Enforce EXTENSION over whatever user
+         ;; may have come up with.  PUB-DIR, if defined, always has
+         ;; precedence over any provided path.
+         (cond
+          (pub-dir
+           (concat (file-name-as-directory pub-dir)
+                   (file-name-nondirectory base-name)
+                   extension))
+          ((file-name-absolute-p base-name) (concat base-name extension))
+          (t (concat (file-name-as-directory ".") base-name extension)))))
+    ;; If writing to OUTPUT-FILE would overwrite original file, append
+    ;; EXTENSION another time to final name.
+    (if (and visited-file (org-file-equal-p visited-file output-file))
+       (concat output-file extension)
+      output-file)))
+
+(defun org-export-add-to-stack (source backend &optional process)
+  "Add a new result to export stack if not present already.
+
+SOURCE is a buffer or a file name containing export results.
+BACKEND is a symbol representing export back-end used to generate
+it.
+
+Entries already pointing to SOURCE and unavailable entries are
+removed beforehand.  Return the new stack."
+  (setq org-export-stack-contents
+       (cons (list source backend (or process (current-time)))
+             (org-export-stack-remove source))))
+
+(defun org-export-stack ()
+  "Menu for asynchronous export results and running processes."
+  (interactive)
+  (let ((buffer (get-buffer-create "*Org Export Stack*")))
+    (set-buffer buffer)
+    (when (zerop (buffer-size)) (org-export-stack-mode))
+    (org-export-stack-refresh)
+    (pop-to-buffer buffer))
+  (message "Type \"q\" to quit, \"?\" for help"))
+
+(defun org-export--stack-source-at-point ()
+  "Return source from export results at point in stack."
+  (let ((source (car (nth (1- (org-current-line)) org-export-stack-contents))))
+    (if (not source) (error "Source unavailable, please refresh buffer")
+      (let ((source-name (if (stringp source) source (buffer-name source))))
+       (if (save-excursion
+             (beginning-of-line)
+             (looking-at (concat ".* +" (regexp-quote source-name) "$")))
+           source
+         ;; SOURCE is not consistent with current line.  The stack
+         ;; view is outdated.
+         (error "Source unavailable; type `g' to update buffer"))))))
+
+(defun org-export-stack-clear ()
+  "Remove all entries from export stack."
+  (interactive)
+  (setq org-export-stack-contents nil))
+
+(defun org-export-stack-refresh (&rest dummy)
+  "Refresh the asynchronous export stack.
+DUMMY is ignored.  Unavailable sources are removed from the list.
+Return the new stack."
+  (let ((inhibit-read-only t))
+    (org-preserve-lc
+     (erase-buffer)
+     (insert (concat
+             (let ((counter 0))
+               (mapconcat
+                (lambda (entry)
+                  (let ((proc-p (processp (nth 2 entry))))
+                    (concat
+                     ;; Back-end.
+                     (format " %-12s  " (or (nth 1 entry) ""))
+                     ;; Age.
+                     (let ((data (nth 2 entry)))
+                       (if proc-p (format " %6s  " (process-status data))
+                         ;; Compute age of the results.
+                         (org-format-seconds
+                          "%4h:%.2m  "
+                          (float-time (time-since data)))))
+                     ;; Source.
+                     (format " %s"
+                             (let ((source (car entry)))
+                               (if (stringp source) source
+                                 (buffer-name source)))))))
+                ;; Clear stack from exited processes, dead buffers or
+                ;; non-existent files.
+                (setq org-export-stack-contents
+                      (org-remove-if-not
+                       (lambda (el)
+                         (if (processp (nth 2 el))
+                             (buffer-live-p (process-buffer (nth 2 el)))
+                           (let ((source (car el)))
+                             (if (bufferp source) (buffer-live-p source)
+                               (file-exists-p source)))))
+                       org-export-stack-contents)) "\n")))))))
+
+(defun org-export-stack-remove (&optional source)
+  "Remove export results at point from stack.
+If optional argument SOURCE is non-nil, remove it instead."
+  (interactive)
+  (let ((source (or source (org-export--stack-source-at-point))))
+    (setq org-export-stack-contents
+         (org-remove-if (lambda (el) (equal (car el) source))
+                        org-export-stack-contents))))
+
+(defun org-export-stack-view (&optional in-emacs)
+  "View export results at point in stack.
+With an optional prefix argument IN-EMACS, force viewing files
+within Emacs."
+  (interactive "P")
+  (let ((source (org-export--stack-source-at-point)))
+    (cond ((processp source)
+          (org-switch-to-buffer-other-window (process-buffer source)))
+         ((bufferp source) (org-switch-to-buffer-other-window source))
+         (t (org-open-file source in-emacs)))))
+
+(defvar org-export-stack-mode-map
+  (let ((km (make-sparse-keymap)))
+    (define-key km " " 'next-line)
+    (define-key km "n" 'next-line)
+    (define-key km "\C-n" 'next-line)
+    (define-key km [down] 'next-line)
+    (define-key km "p" 'previous-line)
+    (define-key km "\C-p" 'previous-line)
+    (define-key km "\C-?" 'previous-line)
+    (define-key km [up] 'previous-line)
+    (define-key km "C" 'org-export-stack-clear)
+    (define-key km "v" 'org-export-stack-view)
+    (define-key km (kbd "RET") 'org-export-stack-view)
+    (define-key km "d" 'org-export-stack-remove)
+    km)
+  "Keymap for Org Export Stack.")
+
+(define-derived-mode org-export-stack-mode special-mode "Org-Stack"
+  "Mode for displaying asynchronous export stack.
+
+Type \\[org-export-stack] to visualize the asynchronous export
+stack.
+
+In an Org Export Stack buffer, use \\<org-export-stack-mode-map>\\[org-export-stack-view] to view export output
+on current line, \\[org-export-stack-remove] to remove it from the stack and \\[org-export-stack-clear] to clear
+stack completely.
+
+Removing entries in an Org Export Stack buffer doesn't affect
+files or buffers, only the display.
+
+\\{org-export-stack-mode-map}"
+  (abbrev-mode 0)
+  (auto-fill-mode 0)
+  (setq buffer-read-only t
+       buffer-undo-list t
+       truncate-lines t
+       header-line-format
+       '(:eval
+         (format "  %-12s | %6s | %s" "Back-End" "Age" "Source")))
+  (org-add-hook 'post-command-hook 'org-export-stack-refresh nil t)
+  (set (make-local-variable 'revert-buffer-function)
+       'org-export-stack-refresh))
+
+
+\f
+;;; The Dispatcher
+;;
+;; `org-export-dispatch' is the standard interactive way to start an
+;; export process.  It uses `org-export--dispatch-ui' as a subroutine
+;; for its interface, which, in turn, delegates response to key
+;; pressed to `org-export--dispatch-action'.
+
+;;;###autoload
+(defun org-export-dispatch (&optional arg)
+  "Export dispatcher for Org mode.
+
+It provides an access to common export related tasks in a buffer.
+Its interface comes in two flavors: standard and expert.
+
+While both share the same set of bindings, only the former
+displays the valid keys associations in a dedicated buffer.
+Scrolling (resp. line-wise motion) in this buffer is done with
+SPC and DEL (resp. C-n and C-p) keys.
+
+Set variable `org-export-dispatch-use-expert-ui' to switch to one
+flavor or the other.
+
+When ARG is \\[universal-argument], repeat the last export action, with the same set
+of options used back then, on the current buffer.
+
+When ARG is \\[universal-argument] \\[universal-argument], display the asynchronous export stack."
+  (interactive "P")
+  (let* ((input
+         (cond ((equal arg '(16)) '(stack))
+               ((and arg org-export-dispatch-last-action))
+               (t (save-window-excursion
+                    (unwind-protect
+                        (progn
+                          ;; Remember where we are
+                          (move-marker org-export-dispatch-last-position
+                                       (point)
+                                       (org-base-buffer (current-buffer)))
+                          ;; Get and store an export command
+                          (setq org-export-dispatch-last-action
+                                (org-export--dispatch-ui
+                                 (list org-export-initial-scope
+                                       (and org-export-in-background 'async))
+                                 nil
+                                 org-export-dispatch-use-expert-ui)))
+                      (and (get-buffer "*Org Export Dispatcher*")
+                           (kill-buffer "*Org Export Dispatcher*")))))))
+        (action (car input))
+        (optns (cdr input)))
+    (unless (memq 'subtree optns)
+      (move-marker org-export-dispatch-last-position nil))
+    (case action
+      ;; First handle special hard-coded actions.
+      (template (org-export-insert-default-template nil optns))
+      (stack (org-export-stack))
+      (publish-current-file
+       (org-publish-current-file (memq 'force optns) (memq 'async optns)))
+      (publish-current-project
+       (org-publish-current-project (memq 'force optns) (memq 'async optns)))
+      (publish-choose-project
+       (org-publish (assoc (org-icompleting-read
+                           "Publish project: "
+                           org-publish-project-alist nil t)
+                          org-publish-project-alist)
+                   (memq 'force optns)
+                   (memq 'async optns)))
+      (publish-all (org-publish-all (memq 'force optns) (memq 'async optns)))
+      (otherwise
+       (save-excursion
+        (when arg
+          ;; Repeating command, maybe move cursor to restore subtree
+          ;; context.
+          (if (eq (marker-buffer org-export-dispatch-last-position)
+                  (org-base-buffer (current-buffer)))
+              (goto-char org-export-dispatch-last-position)
+            ;; We are in a different buffer, forget position.
+            (move-marker org-export-dispatch-last-position nil)))
+        (funcall action
+                 ;; Return a symbol instead of a list to ease
+                 ;; asynchronous export macro use.
+                 (and (memq 'async optns) t)
+                 (and (memq 'subtree optns) t)
+                 (and (memq 'visible optns) t)
+                 (and (memq 'body optns) t)))))))
+
+(defun org-export--dispatch-ui (options first-key expertp)
+  "Handle interface for `org-export-dispatch'.
+
+OPTIONS is a list containing current interactive options set for
+export.  It can contain any of the following symbols:
+`body'    toggles a body-only export
+`subtree' restricts export to current subtree
+`visible' restricts export to visible part of buffer.
+`force'   force publishing files.
+`async'   use asynchronous export process
+
+FIRST-KEY is the key pressed to select the first level menu.  It
+is nil when this menu hasn't been selected yet.
+
+EXPERTP, when non-nil, triggers expert UI.  In that case, no help
+buffer is provided, but indications about currently active
+options are given in the prompt.  Moreover, \[?] allows to switch
+back to standard interface."
+  (let* ((fontify-key
+         (lambda (key &optional access-key)
+           ;; Fontify KEY string.  Optional argument ACCESS-KEY, when
+           ;; non-nil is the required first-level key to activate
+           ;; KEY.  When its value is t, activate KEY independently
+           ;; on the first key, if any.  A nil value means KEY will
+           ;; only be activated at first level.
+           (if (or (eq access-key t) (eq access-key first-key))
+               (org-propertize key 'face 'org-warning)
+             key)))
+        (fontify-value
+         (lambda (value)
+           ;; Fontify VALUE string.
+           (org-propertize value 'face 'font-lock-variable-name-face)))
+        ;; Prepare menu entries by extracting them from registered
+        ;; back-ends and sorting them by access key and by ordinal,
+        ;; if any.
+        (entries
+         (sort (sort (delq nil
+                           (mapcar 'org-export-backend-menu
+                                   org-export--registered-backends))
+                     (lambda (a b)
+                       (let ((key-a (nth 1 a))
+                             (key-b (nth 1 b)))
+                         (cond ((and (numberp key-a) (numberp key-b))
+                                (< key-a key-b))
+                               ((numberp key-b) t)))))
+               'car-less-than-car))
+        ;; Compute a list of allowed keys based on the first key
+        ;; pressed, if any.  Some keys
+        ;; (?^B, ?^V, ?^S, ?^F, ?^A, ?&, ?# and ?q) are always
+        ;; available.
+        (allowed-keys
+         (nconc (list 2 22 19 6 1)
+                (if (not first-key) (org-uniquify (mapcar 'car entries))
+                  (let (sub-menu)
+                    (dolist (entry entries (sort (mapcar 'car sub-menu) '<))
+                      (when (eq (car entry) first-key)
+                        (setq sub-menu (append (nth 2 entry) sub-menu))))))
+                (cond ((eq first-key ?P) (list ?f ?p ?x ?a))
+                      ((not first-key) (list ?P)))
+                (list ?& ?#)
+                (when expertp (list ??))
+                (list ?q)))
+        ;; Build the help menu for standard UI.
+        (help
+         (unless expertp
+           (concat
+            ;; Options are hard-coded.
+            (format "[%s] Body only:    %s           [%s] Visible only:     %s
+\[%s] Export scope: %s       [%s] Force publishing: %s
+\[%s] Async export: %s\n\n"
+                    (funcall fontify-key "C-b" t)
+                    (funcall fontify-value
+                             (if (memq 'body options) "On " "Off"))
+                    (funcall fontify-key "C-v" t)
+                    (funcall fontify-value
+                             (if (memq 'visible options) "On " "Off"))
+                    (funcall fontify-key "C-s" t)
+                    (funcall fontify-value
+                             (if (memq 'subtree options) "Subtree" "Buffer "))
+                    (funcall fontify-key "C-f" t)
+                    (funcall fontify-value
+                             (if (memq 'force options) "On " "Off"))
+                    (funcall fontify-key "C-a" t)
+                    (funcall fontify-value
+                             (if (memq 'async options) "On " "Off")))
+            ;; Display registered back-end entries.  When a key
+            ;; appears for the second time, do not create another
+            ;; entry, but append its sub-menu to existing menu.
+            (let (last-key)
+              (mapconcat
+               (lambda (entry)
+                 (let ((top-key (car entry)))
+                   (concat
+                    (unless (eq top-key last-key)
+                      (setq last-key top-key)
+                      (format "\n[%s] %s\n"
+                              (funcall fontify-key (char-to-string top-key))
+                              (nth 1 entry)))
+                    (let ((sub-menu (nth 2 entry)))
+                      (unless (functionp sub-menu)
+                        ;; Split sub-menu into two columns.
+                        (let ((index -1))
+                          (concat
+                           (mapconcat
+                            (lambda (sub-entry)
+                              (incf index)
+                              (format
+                               (if (zerop (mod index 2)) "    [%s] %-26s"
+                                 "[%s] %s\n")
+                               (funcall fontify-key
+                                        (char-to-string (car sub-entry))
+                                        top-key)
+                               (nth 1 sub-entry)))
+                            sub-menu "")
+                           (when (zerop (mod index 2)) "\n"))))))))
+               entries ""))
+            ;; Publishing menu is hard-coded.
+            (format "\n[%s] Publish
+    [%s] Current file              [%s] Current project
+    [%s] Choose project            [%s] All projects\n\n\n"
+                    (funcall fontify-key "P")
+                    (funcall fontify-key "f" ?P)
+                    (funcall fontify-key "p" ?P)
+                    (funcall fontify-key "x" ?P)
+                    (funcall fontify-key "a" ?P))
+            (format "[%s] Export stack                  [%s] Insert template\n"
+                    (funcall fontify-key "&" t)
+                    (funcall fontify-key "#" t))
+            (format "[%s] %s"
+                    (funcall fontify-key "q" t)
+                    (if first-key "Main menu" "Exit")))))
+        ;; Build prompts for both standard and expert UI.
+        (standard-prompt (unless expertp "Export command: "))
+        (expert-prompt
+         (when expertp
+           (format
+            "Export command (C-%s%s%s%s%s) [%s]: "
+            (if (memq 'body options) (funcall fontify-key "b" t) "b")
+            (if (memq 'visible options) (funcall fontify-key "v" t) "v")
+            (if (memq 'subtree options) (funcall fontify-key "s" t) "s")
+            (if (memq 'force options) (funcall fontify-key "f" t) "f")
+            (if (memq 'async options) (funcall fontify-key "a" t) "a")
+            (mapconcat (lambda (k)
+                         ;; Strip control characters.
+                         (unless (< k 27) (char-to-string k)))
+                       allowed-keys "")))))
+    ;; With expert UI, just read key with a fancy prompt.  In standard
+    ;; UI, display an intrusive help buffer.
+    (if expertp
+       (org-export--dispatch-action
+        expert-prompt allowed-keys entries options first-key expertp)
+      ;; At first call, create frame layout in order to display menu.
+      (unless (get-buffer "*Org Export Dispatcher*")
+       (delete-other-windows)
+       (org-switch-to-buffer-other-window
+        (get-buffer-create "*Org Export Dispatcher*"))
+       (setq cursor-type nil
+             header-line-format "Use SPC, DEL, C-n or C-p to navigate.")
+       ;; Make sure that invisible cursor will not highlight square
+       ;; brackets.
+       (set-syntax-table (copy-syntax-table))
+       (modify-syntax-entry ?\[ "w"))
+      ;; At this point, the buffer containing the menu exists and is
+      ;; visible in the current window.  So, refresh it.
+      (with-current-buffer "*Org Export Dispatcher*"
+       ;; Refresh help.  Maintain display continuity by re-visiting
+       ;; previous window position.
+       (let ((pos (window-start)))
+         (erase-buffer)
+         (insert help)
+         (set-window-start nil pos)))
+      (org-fit-window-to-buffer)
+      (org-export--dispatch-action
+       standard-prompt allowed-keys entries options first-key expertp))))
+
+(defun org-export--dispatch-action
+  (prompt allowed-keys entries options first-key expertp)
+  "Read a character from command input and act accordingly.
+
+PROMPT is the displayed prompt, as a string.  ALLOWED-KEYS is
+a list of characters available at a given step in the process.
+ENTRIES is a list of menu entries.  OPTIONS, FIRST-KEY and
+EXPERTP are the same as defined in `org-export--dispatch-ui',
+which see.
+
+Toggle export options when required.  Otherwise, return value is
+a list with action as CAR and a list of interactive export
+options as CDR."
+  (let (key)
+    ;; Scrolling: when in non-expert mode, act on motion keys (C-n,
+    ;; C-p, SPC, DEL).
+    (while (and (setq key (read-char-exclusive prompt))
+               (not expertp)
+               (memq key '(14 16 ?\s ?\d)))
+      (case key
+       (14 (if (not (pos-visible-in-window-p (point-max)))
+               (ignore-errors (scroll-up 1))
+             (message "End of buffer")
+             (sit-for 1)))
+       (16 (if (not (pos-visible-in-window-p (point-min)))
+               (ignore-errors (scroll-down 1))
+             (message "Beginning of buffer")
+             (sit-for 1)))
+       (?\s (if (not (pos-visible-in-window-p (point-max)))
+                (scroll-up nil)
+              (message "End of buffer")
+              (sit-for 1)))
+       (?\d (if (not (pos-visible-in-window-p (point-min)))
+                (scroll-down nil)
+              (message "Beginning of buffer")
+              (sit-for 1)))))
+    (cond
+     ;; Ignore undefined associations.
+     ((not (memq key allowed-keys))
+      (ding)
+      (unless expertp (message "Invalid key") (sit-for 1))
+      (org-export--dispatch-ui options first-key expertp))
+     ;; q key at first level aborts export.  At second level, cancel
+     ;; first key instead.
+     ((eq key ?q) (if (not first-key) (error "Export aborted")
+                   (org-export--dispatch-ui options nil expertp)))
+     ;; Help key: Switch back to standard interface if expert UI was
+     ;; active.
+     ((eq key ??) (org-export--dispatch-ui options first-key nil))
+     ;; Send request for template insertion along with export scope.
+     ((eq key ?#) (cons 'template (memq 'subtree options)))
+     ;; Switch to asynchronous export stack.
+     ((eq key ?&) '(stack))
+     ;; Toggle options: C-b (2) C-v (22) C-s (19) C-f (6) C-a (1).
+     ((memq key '(2 22 19 6 1))
+      (org-export--dispatch-ui
+       (let ((option (case key (2 'body) (22 'visible) (19 'subtree)
+                          (6 'force) (1 'async))))
+        (if (memq option options) (remq option options)
+          (cons option options)))
+       first-key expertp))
+     ;; Action selected: Send key and options back to
+     ;; `org-export-dispatch'.
+     ((or first-key (functionp (nth 2 (assq key entries))))
+      (cons (cond
+            ((not first-key) (nth 2 (assq key entries)))
+            ;; Publishing actions are hard-coded.  Send a special
+            ;; signal to `org-export-dispatch'.
+            ((eq first-key ?P)
+             (case key
+               (?f 'publish-current-file)
+               (?p 'publish-current-project)
+               (?x 'publish-choose-project)
+               (?a 'publish-all)))
+            ;; Return first action associated to FIRST-KEY + KEY
+            ;; path. Indeed, derived backends can share the same
+            ;; FIRST-KEY.
+            (t (catch 'found
+                 (mapc (lambda (entry)
+                         (let ((match (assq key (nth 2 entry))))
+                           (when match (throw 'found (nth 2 match)))))
+                       (member (assq first-key entries) entries)))))
+           options))
+     ;; Otherwise, enter sub-menu.
+     (t (org-export--dispatch-ui options key expertp)))))
+
+
+
+(provide 'ox)
+
+;; Local variables:
+;; generated-autoload-file: "org-loaddefs.el"
+;; End:
+
+;;; ox.el ends here
index e6eaea985af43f20bb277d01bc2bb731561f8fa4..293ae6856e97999524d5dedd9395f70836c59186 100644 (file)
@@ -79,7 +79,8 @@ searching backwards at another AC_... command."
   (setq-local parens-require-spaces nil) ; for M4 arg lists
   (setq-local defun-prompt-regexp "^[ \t]*A[CM]_\\(\\sw\\|\\s_\\)+")
   (setq-local comment-start "dnl ")
-  (setq-local comment-start-skip "\\(?:\\(\\W\\|\\`\\)dnl\\|#\\) +")
+  ;; We want to avoid matching "dnl" in other text.
+  (setq-local comment-start-skip "\\(?:\\(\\W\\|^\\)dnl\\|#\\) +")
   (setq-local syntax-propertize-function
              (syntax-propertize-rules ("\\<dnl\\>" (0 "<"))))
   (setq-local font-lock-defaults
index 0d25e1355e75d1e0777102982c937df0ea1791c2..973ed916694a19199e2cc1bc75d786147fd76b77 100644 (file)
@@ -1261,12 +1261,15 @@ comment at the start of cc-engine.el for more info."
              ;; looking for more : and ?.
              (setq c-maybe-labelp nil
                    skip-chars (substring c-stmt-delim-chars 0 -2)))
-            ;; At a CPP construct?
-            ((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol)
-                  (save-excursion
-                    (forward-line 0)
-                    (looking-at c-opt-cpp-prefix)))
-             (c-end-of-macro))
+            ;; At a CPP construct or a "#" or "##" operator?
+            ((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol))
+             (if (save-excursion
+                   (skip-chars-backward " \t")
+                   (and (bolp)
+                        (or (bobp)
+                            (not (eq (char-before (1- (point))) ?\\)))))
+                 (c-end-of-macro)
+               (skip-chars-forward c-opt-cpp-symbol)))
             ((memq (char-after) non-skip-list)
              (throw 'done (point)))))
          ;; In trailing space after an as yet undetected virtual semicolon?
@@ -8492,10 +8495,12 @@ comment at the start of cc-engine.el for more info."
         (or (not (looking-at "\\s)"))
             (c-go-up-list-backward))
         (cond
-         ((and (looking-at c-symbol-key) (c-on-identifier))
+         ((and (looking-at c-symbol-key) (c-on-identifier)
+               (not before-identifier))
           (setq before-identifier t))
          ((and before-identifier
-               (looking-at c-postfix-decl-spec-key))
+               (or (eq (char-after) ?,)
+                   (looking-at c-postfix-decl-spec-key)))
           (setq before-identifier nil)
           t)
          ((looking-at c-brace-list-key) nil)
index bcd4a5f28f87e69b15263b06b3d202d2ae495d40..ada83ac41b4d7da1575df42ab7aa32646105524a 100644 (file)
@@ -1884,7 +1884,7 @@ higher."
                "\\)\\>"
                ;; Disallow various common punctuation chars that can't come
                ;; before the '{' of the enum list, to avoid searching too far.
-               "[^\]\[{}();,/#=]*"
+               "[^\]\[{}();/#=]*"
                "{")
               '((c-font-lock-declarators limit t nil)
                 (save-match-data
index 85a9074760d37503584fea9b663f50bf6db8063c..a5cd863f2e1fb9f9853b9e0f9ae60c658b16e98c 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Dave Love <fx@gnu.org>
 ;; Maintainer: Ted Zlatanov <tzz@lifelogs.com>
 ;; Keywords: languages
-;; Version: 1.2
+;; Version: 1.3
 
 ;; This file is part of GNU Emacs.
 
 ;; (add-to-list 'auto-mode-alist '("^cf\\." . cfengine2-mode))
 ;; (add-to-list 'auto-mode-alist '("^cfagent.conf\\'" . cfengine2-mode))
 
+;; It's *highly* recommended that you enable the eldoc minor mode:
+
+;; (add-hook 'cfengine-mode-hook 'turn-on-eldoc-mode)
+
 ;; This is not the same as the mode written by Rolf Ebert
 ;; <ebert@waporo.muc.de>, distributed with cfengine-2.0.5.  It does
 ;; better fontification and indentation, inter alia.
   :group 'cfengine
   :type 'integer)
 
+(defcustom cfengine-cf-promises
+  (or (executable-find "cf-promises")
+      (executable-find "/var/cfengine/bin/cf-promises")
+      (executable-find "/usr/bin/cf-promises")
+      (executable-find "/usr/local/bin/cf-promises")
+      (executable-find "~/bin/cf-promises"))
+  "The location of the cf-promises executable.
+Used for syntax discovery and checking.  Set to nil to disable
+the `compile-command' override and the ElDoc support."
+  :group 'cfengine
+  :type 'file)
+
 (defcustom cfengine-parameters-indent '(promise pname 0)
   "*Indentation of CFEngine3 promise parameters (hanging indent).
 
@@ -127,6 +143,9 @@ bundle agent rcfiles
 (defvar cfengine-mode-debug nil
   "Whether `cfengine-mode' should print debugging info.")
 
+(defvar cfengine-mode-syntax-cache nil
+  "Cache for `cfengine-mode' syntax trees obtained from 'cf-promises -s json'.")
+
 (defcustom cfengine-mode-abbrevs nil
   "Abbrevs for CFEngine2 mode."
   :group 'cfengine
@@ -167,7 +186,7 @@ This includes those for cfservd as well as cfagent.")
   (defconst cfengine3-vartypes
     (mapcar
      'symbol-name
-     '(string int real slist ilist rlist irange rrange counter))
+     '(string int real slist ilist rlist irange rrange counter data))
     "List of the CFEngine 3.x variable types."))
 
 (defvar cfengine2-font-lock-keywords
@@ -501,6 +520,116 @@ Intended as the value of `indent-line-function'."
 ;; CLASS: [.|&!()a-zA-Z0-9_\200-\377]+::
 ;; CATEGORY: [a-zA-Z_]+:
 
+(defun cfengine3--current-word (&optional bounds)
+  "Propose a word around point in the current CFEngine 3 buffer."
+  (let ((c (char-after (point)))
+        (s (syntax-ppss)))
+    (when (not (nth 3 s)) ; not inside a string
+      (if bounds
+          (save-excursion
+            (let ((oldpoint (point))
+                  start end)
+              (skip-syntax-backward "w_") (setq start (point))
+              (goto-char oldpoint)
+              (skip-syntax-forward "w_") (setq end (point))
+              (when (not (and (eq start oldpoint)
+                              (eq end oldpoint)))
+                (list start (point)))))
+        (and c
+             (memq (char-syntax c) '(?_ ?w))
+             (current-word))))))
+
+(defun cfengine3--current-function ()
+  "Look up current CFEngine 3 function"
+  (let* ((syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache))
+         (flist (assoc 'functions syntax)))
+    (when flist
+      (let ((w (cfengine3--current-word)))
+        (and w (assq (intern w) flist))))))
+
+;; format from "cf-promises -s json", e.g. "sort" function:
+;; ((category . "data")
+;;  (variadic . :json-false)
+;;  (parameters . [((range . "[a-zA-Z0-9_$(){}\\[\\].:]+") (type . "string"))
+;;                 ((range . "lex,int,real,IP,ip,MAC,mac") (type . "option"))])
+;;  (returnType . "slist")
+;;  (status . "normal"))
+
+(defun cfengine3-format-function-docstring (fdef)
+  (let* ((f (format "%s" (car-safe fdef)))
+         (def (cdr fdef))
+         (rtype (cdr (assq 'returnType def)))
+         (plist (cdr (assq 'parameters def)))
+         (has-some-parameters (> (length plist) 0))
+         (variadic (eq t (cdr (assq 'variadic def)))))
+
+    ;; (format "[%S]%s %s(%s%s)" def
+    (format "%s %s(%s%s)"
+            (if rtype
+                (propertize rtype 'face 'font-lock-variable-name-face)
+              "???")
+            (propertize f 'face 'font-lock-function-name-face)
+            (mapconcat (lambda (p)
+                         (let ((type (cdr (assq 'type p)))
+                               (range (cdr (assq 'range p))))
+                           (cond
+                            ((not (stringp type)) "???type???")
+                            ((not (stringp range)) "???range???")
+                            ;; options are lists of possible keywords
+                            ((equal type "option")
+                             (propertize (concat "[" range "]")
+                                         'face
+                                         'font-lock-keyword-face))
+                            ;; anything else is a type name as a variable
+                            (t (propertize type
+                                           'face
+                                           'font-lock-variable-name-face)))))
+                       plist
+                       ", ")
+            (if variadic
+                (if has-some-parameters ", ..." "...")
+              ""))))
+
+(defun cfengine3-make-syntax-cache ()
+  "Build the CFEngine 3 syntax cache.
+Calls `cfengine-cf-promises' with \"-s json\""
+  (when cfengine-cf-promises
+    (let ((loaded-json-lib (require 'json nil t))
+          (syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache)))
+      (if (not loaded-json-lib)
+          (message "JSON library could not be loaded!")
+        (unless syntax
+          (with-demoted-errors
+              (with-temp-buffer
+                (call-process-shell-command cfengine-cf-promises
+                                            nil   ; no input
+                                            t     ; current buffer
+                                            nil   ; no redisplay
+                                            "-s" "json")
+                (goto-char (point-min))
+                (setq syntax (json-read))
+                (setq cfengine-mode-syntax-cache
+                      (cons (cons cfengine-cf-promises syntax)
+                            cfengine-mode-syntax-cache)))))))))
+
+(defun cfengine3-documentation-function ()
+  "Document CFengine 3 functions around point.
+Intended as the value of `eldoc-documentation-function', which
+see.  Use it by executing `turn-on-eldoc-mode'."
+  (cfengine3-make-syntax-cache)
+  (let ((fdef (cfengine3--current-function)))
+    (when fdef
+      (cfengine3-format-function-docstring fdef))))
+
+(defun cfengine3-completion-function ()
+  "Return completions for function name around or before point."
+  (cfengine3-make-syntax-cache)
+  (let* ((bounds (cfengine3--current-word t))
+         (syntax (assoc cfengine-cf-promises cfengine-mode-syntax-cache))
+         (flist (assoc 'functions syntax)))
+    (when bounds
+      (append bounds (list (cdr flist))))))
+
 (defun cfengine-common-settings ()
   (set (make-local-variable 'syntax-propertize-function)
        ;; In the main syntax-table, \ is marked as a punctuation, because
@@ -549,6 +678,21 @@ to the action header."
           nil nil nil beginning-of-defun))
   (setq-local prettify-symbols-alist cfengine3--prettify-symbols-alist)
 
+  ;; `compile-command' is almost never a `make' call with CFEngine so
+  ;; we override it
+  (when cfengine-cf-promises
+    (set (make-local-variable 'compile-command)
+         (concat cfengine-cf-promises
+                 " -f "
+                 (when buffer-file-name
+                   (shell-quote-argument buffer-file-name)))))
+
+  (set (make-local-variable 'eldoc-documentation-function)
+       #'cfengine3-documentation-function)
+
+  (add-hook 'completion-at-point-functions
+            #'cfengine3-completion-function nil t)
+
   ;; Use defuns as the essential syntax block.
   (set (make-local-variable 'beginning-of-defun-function)
        #'cfengine3-beginning-of-defun)
index 3b86ddc1567553f2010f9ab517980466c1717455..54f037285244f7e9ad0b631a3ac53f37d370f02e 100644 (file)
@@ -513,7 +513,7 @@ listed text properties PROP# are given values VAL# as well."
   "Directory to restore to when doing `recompile'.")
 
 (defvar compilation-directory-matcher
-  '("\\(?:Entering\\|Leavin\\(g\\)\\) directory `\\(.+\\)'$" (2 . 1))
+  '("\\(?:Entering\\|Leavin\\(g\\)\\) directory [`']\\(.+\\)'$" (2 . 1))
   "A list for tracking when directories are entered or left.
 If nil, do not track directories, e.g. if all file names are absolute.  The
 first element is the REGEXP matching these messages.  It can match any number
@@ -526,7 +526,7 @@ directory we were in before the last entering message.  If you change this,
 you may also want to change `compilation-page-delimiter'.")
 
 (defvar compilation-page-delimiter
-  "^\\(?:\f\\|.*\\(?:Entering\\|Leaving\\) directory `.+'\n\\)+"
+  "^\\(?:\f\\|.*\\(?:Entering\\|Leaving\\) directory [`'].+'\n\\)+"
   "Value of `page-delimiter' in Compilation mode.")
 
 (defvar compilation-mode-font-lock-keywords
index 8a7d1e77bd22f6a192ace21d48a8ed032bcbac73..36b05c89ea1587bb471fe0ec37026bea4adbefa4 100644 (file)
@@ -8900,8 +8900,9 @@ do extra unwind via `cperl-unwind-to-safe'."
                  (beginning-of-line)
                  (eq (get-text-property (setq beg (point)) 'syntax-type)
                      'multiline)))
-      (if (setq beg (cperl-beginning-of-property beg 'syntax-type))
-         (goto-char beg)))
+      (let ((new-beg (cperl-beginning-of-property beg 'syntax-type)))
+       (setq beg (if (= new-beg beg) nil new-beg))
+       (goto-char new-beg)))
     (setq beg (point))
     (goto-char end)
     (while (and end
index caa33d36440a91e705c51fd5e69ffb2b7bfbef47..4c2dfc9828580783c73afc85b3d5397cce37ccfc 100644 (file)
@@ -3912,7 +3912,7 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
  {/Effect EffectP def
   /fP F ForegroundP SetRGB BackgroundP aload pop true BG S
   /Effect 0 def
-  ( :) S false BG}if
+  ( :) S false BG}{pop}ifelse
  xw yw moveto
  hT EL RA
  xp yw moveto
index 2f1f7b3c8d377b843fec1d9b96fc540e4ec3fc0f..4b0a012e5383165d28acc0767c901bb33cca84f9 100644 (file)
@@ -1016,11 +1016,15 @@ no input, and GDB is waiting for input."
 
 (declare-function tooltip-show "tooltip" (text &optional use-echo-area))
 
+(defconst gdb--string-regexp "\"\\(?:[^\\\"]\\|\\\\.\\)*\"")
+
 (defun gdb-tooltip-print (expr)
   (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
     (goto-char (point-min))
     (cond
-     ((re-search-forward ".*value=\\(\".*\"\\)" nil t)
+     ((re-search-forward (concat ".*value=\\(" gdb--string-regexp
+                                 "\\)")
+                         nil t)
       (tooltip-show
        (concat expr " = " (read (match-string 1)))
        (or gud-tooltip-echo-area
@@ -1198,7 +1202,8 @@ With arg, enter name of variable to be watched in the minibuffer."
 
 (defun gdb-var-evaluate-expression-handler (varnum changed)
   (goto-char (point-min))
-  (re-search-forward ".*value=\\(\".*\"\\)" nil t)
+  (re-search-forward (concat ".*value=\\(" gdb--string-regexp "\\)")
+                     nil t)
   (let ((var (assoc varnum gdb-var-list)))
     (when var
       (if changed (setcar (nthcdr 5 var) 'changed))
@@ -2124,7 +2129,8 @@ a GDB/MI reply message."
        '&' c-string"
   (when (< gdbmi-bnf-offset (length gud-marker-acc))
     (if (and (member (aref gud-marker-acc gdbmi-bnf-offset) '(?~ ?@ ?&))
-             (string-match "\\([~@&]\\)\\(\".*?\"\\)\n" gud-marker-acc
+             (string-match (concat "\\([~@&]\\)\\(" gdb--string-regexp "\\)\n")
+                           gud-marker-acc
                            gdbmi-bnf-offset))
         (let ((prefix (match-string 1 gud-marker-acc))
               (c-string (match-string 2 gud-marker-acc)))
@@ -2586,9 +2592,10 @@ incompatible with GDB/MI output syntax."
               (insert "]"))))))
     (goto-char (point-min))
     (insert "{")
-    (while (re-search-forward
-           "\\([[:alnum:]-_]+\\)=\\({\\|\\[\\|\"\"\\|\".*?[^\\]\"\\)" nil t)
-      (replace-match "\"\\1\":\\2" nil nil))
+    (let ((re (concat "\\([[:alnum:]-_]+\\)=\\({\\|\\[\\|\"\"\\|"
+                      gdb--string-regexp "\\)")))
+      (while (re-search-forward re nil t)
+        (replace-match "\"\\1\":\\2" nil nil)))
     (goto-char (point-max))
     (insert "}")))
 
@@ -2812,8 +2819,12 @@ See `def-gdb-auto-update-handler'."
                             (or (bindat-get-field breakpoint 'disp) "")
                             (let ((flag (bindat-get-field breakpoint 'enabled)))
                               (if (string-equal flag "y")
-                                  (propertize "y" 'font-lock-face  font-lock-warning-face)
-                                (propertize "n" 'font-lock-face  font-lock-comment-face)))
+                                  (eval-when-compile
+                                    (propertize "y" 'font-lock-face
+                                                font-lock-warning-face))
+                                (eval-when-compile
+                                  (propertize "n" 'font-lock-face
+                                              font-lock-comment-face))))
                             (bindat-get-field breakpoint 'addr)
                             (or (bindat-get-field breakpoint 'times) "")
                             (if (and type (string-match ".*watchpoint" type))
@@ -2865,7 +2876,8 @@ See `def-gdb-auto-update-handler'."
              (gdb-put-breakpoint-icon (string-equal flag "y") bptno
                                       (string-to-number line)))))))))
 
-(defvar gdb-source-file-regexp "fullname=\"\\(.*?\\)\"")
+(defconst gdb-source-file-regexp
+  (concat "fullname=\\(" gdb--string-regexp "\\)"))
 
 (defun gdb-get-location (bptno line flag)
   "Find the directory containing the relevant source file.
@@ -2874,6 +2886,7 @@ Put in buffer and place breakpoint icon."
   (catch 'file-not-found
     (if (re-search-forward gdb-source-file-regexp nil t)
        (delete (cons bptno "File not found") gdb-location-alist)
+      ;; FIXME: Why/how do we use (match-string 1) when the search failed?
       (push (cons bptno (match-string 1)) gdb-location-alist)
       (gdb-resync)
       (unless (assoc bptno gdb-location-alist)
@@ -4214,7 +4227,7 @@ If buffers already exist for any of these files, `gud-minor-mode'
 is set in them."
   (goto-char (point-min))
   (while (re-search-forward gdb-source-file-regexp nil t)
-    (push (match-string 1) gdb-source-file-list))
+    (push (read (match-string 1)) gdb-source-file-list))
   (dolist (buffer (buffer-list))
     (with-current-buffer buffer
       (when (member buffer-file-name gdb-source-file-list)
@@ -4253,14 +4266,15 @@ overlay arrow in source buffer."
                 (setq gud-overlay-arrow-position (make-marker))
                 (set-marker gud-overlay-arrow-position position))))))))
 
-(defvar gdb-prompt-name-regexp "value=\"\\(.*?\\)\"")
+(defconst gdb-prompt-name-regexp
+  (concat "value=\\(" gdb--string-regexp "\\)"))
 
 (defun gdb-get-prompt ()
   "Find prompt for GDB session."
   (goto-char (point-min))
   (setq gdb-prompt-name nil)
   (re-search-forward gdb-prompt-name-regexp nil t)
-  (setq gdb-prompt-name (match-string 1))
+  (setq gdb-prompt-name (read (match-string 1)))
   ;; Insert first prompt.
   (setq gdb-filter-output (concat gdb-filter-output gdb-prompt-name)))
 
@@ -4541,7 +4555,7 @@ Kills the gdb buffers, and resets variables and the source buffers."
 buffers, if required."
   (goto-char (point-min))
   (if (re-search-forward gdb-source-file-regexp nil t)
-      (setq gdb-main-file (match-string 1)))
+      (setq gdb-main-file (read (match-string 1))))
   (if gdb-many-windows
       (gdb-setup-windows)
     (gdb-get-buffer-create 'gdb-breakpoints-buffer)
index 14f6aa154d7228dd5362ff60040d69e61109e04f..4097a9cd97e3c06282f4528e65d77d7379bf3fb2 100644 (file)
@@ -66,7 +66,7 @@ pdb (Python), and jdb."
   :group 'gud)
 
 (global-set-key (vconcat gud-key-prefix "\C-l") 'gud-refresh)
-(define-key ctl-x-map " " 'gud-break)  ;; backward compatibility hack
+;; (define-key ctl-x-map " " 'gud-break); backward compatibility hack
 
 (defvar gud-marker-filter nil)
 (put 'gud-marker-filter 'permanent-local t)
@@ -2159,10 +2159,8 @@ relative to a classpath directory."
                    (split-string
                     ;; Eliminate any subclass references in the class
                     ;; name string. These start with a "$"
-                    ((lambda (x)
-                       (if (string-match "$.*" x)
-                           (replace-match "" t t x) p))
-                     p)
+                     (if (string-match "$.*" p)
+                         (replace-match "" t t p) p)
                     "\\.") "/")
         ".java"))
        (cplist (append gud-jdb-sourcepath gud-jdb-classpath))
index d73e9489d7cbf2b96b6aab0785103af2123b57b4..a9953e271dcfaeb62f6f54e0dcb4f61a95836c6d 100644 (file)
@@ -91,6 +91,21 @@ mode.  Default is whitespace followed by 0 or 1 single-letter colon-keyword
     (define-key map "\C-c\C-v" 'lisp-show-variable-documentation)
     map))
 
+(easy-menu-define
+  inferior-lisp-menu
+  inferior-lisp-mode-map
+  "Inferior Lisp Menu"
+  '("Inf-Lisp"
+    ["Eval Last Sexp" lisp-eval-last-sexp t]
+    "--"
+    ["Load File..." lisp-load-file t]
+    ["Compile File..." lisp-compile-file t]
+    "--"
+    ["Show Arglist..." lisp-show-arglist t]
+    ["Describe Symbol..." lisp-describe-sym t]
+    ["Show Documentation for Function..." lisp-show-function-documentation t]
+    ["Show Documentation for Variable..." lisp-show-variable-documentation t]))
+
 ;;; These commands augment Lisp mode, so you can process Lisp code in
 ;;; the source files.
 (define-key lisp-mode-map "\M-\C-x"  'lisp-eval-defun)     ; Gnu convention
index 899bf151a2c025c9abd8b749460d5b4e28174abe..f128441a54e28e7668b9b1bf5dbdeeb0f936ff45 100644 (file)
@@ -1724,20 +1724,32 @@ sentence."
                  (if all "'-all', " "")
                  str)))
   (let ((lines inferior-octave-output-list))
-    (when (string-match "error: \\(.*\\)$" (car lines))
+    (when (and (stringp (car lines))
+               (string-match "error: \\(.*\\)$" (car lines)))
       (error "%s" (match-string 1 (car lines))))
     (with-help-window octave-help-buffer
-      (princ (mapconcat 'identity lines "\n"))
       (with-current-buffer octave-help-buffer
+        (if lines
+            (insert (mapconcat 'identity lines "\n"))
+          (insert (format "Nothing found for \"%s\".\n" str)))
         ;; Bound to t so that `help-buffer' returns current buffer for
         ;; `help-setup-xref'.
         (let ((help-xref-following t))
           (help-setup-xref (list 'octave-lookfor str all)
                            (called-interactively-p 'interactive)))
         (goto-char (point-min))
-        (while (re-search-forward "^\\([^[:blank:]]+\\) " nil 'noerror)
-          (make-text-button (match-beginning 1) (match-end 1)
-                            :type 'octave-help-function))
+        (when lines
+          (while (re-search-forward "^\\([^[:blank:]]+\\) " nil 'noerror)
+            (make-text-button (match-beginning 1) (match-end 1)
+                              :type 'octave-help-function)))
+        (unless all
+          (goto-char (point-max))
+          (insert "\nRetry with ")
+          (insert-text-button "'-all'"
+                              'follow-link t
+                              'action #'(lambda (_b)
+                                          (octave-lookfor str '-all)))
+          (insert ".\n"))
         (octave-help-mode)))))
 
 (defcustom octave-source-directories nil
index 0f3c1504ee9c409bb2bf1f15d07b9c286b3cdf6f..c766189c4d27d5816c5020708d2b1e3439d2f7e2 100644 (file)
@@ -1,4 +1,4 @@
-;;; prolog.el --- major mode for Prolog (and Mercury) -*- coding: utf-8 -*-
+;;; prolog.el --- major mode for Prolog (and Mercury) -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1986-1987, 1997-1999, 2002-2003, 2011-2013 Free
 ;; Software Foundation, Inc.
@@ -376,29 +376,8 @@ The version numbers are of the format (Major . Minor)."
   :group 'prolog-indentation
   :type 'integer)
 
-(defcustom prolog-align-comments-flag t
-  "Non-nil means automatically align comments when indenting."
-  :version "24.1"
-  :group 'prolog-indentation
-  :type 'boolean)
-
-(defcustom prolog-indent-mline-comments-flag t
-  "Non-nil means indent contents of /* */ comments.
-Otherwise leave such lines as they are."
-  :version "24.1"
-  :group 'prolog-indentation
-  :type 'boolean)
-
-(defcustom prolog-object-end-to-0-flag t
-  "Non-nil means indent closing '}' in SICStus object definitions to level 0.
-Otherwise indent to `prolog-indent-width'."
-  :version "24.1"
-  :group 'prolog-indentation
-  :type 'boolean)
-
 (defcustom prolog-left-indent-regexp "\\(;\\|\\*?->\\)"
-  "Regexp for character sequences after which next line is indented.
-Next line after such a regexp is indented to the opening parenthesis level."
+  "Regexp for `prolog-electric-if-then-else-flag'."
   :version "24.1"
   :group 'prolog-indentation
   :type 'regexp)
@@ -503,12 +482,6 @@ Legal values:
 
 ;; Keyboard
 
-(defcustom prolog-electric-newline-flag (not (fboundp 'electric-indent-mode))
-  "Non-nil means automatically indent the next line when the user types RET."
-  :version "24.1"
-  :group 'prolog-keyboard
-  :type 'boolean)
-
 (defcustom prolog-hungry-delete-key-flag nil
   "Non-nil means delete key consumes all preceding spaces."
   :version "24.1"
@@ -545,14 +518,6 @@ If underscore is pressed not on a variable then it behaves as usual."
   :group 'prolog-keyboard
   :type 'boolean)
 
-(defcustom prolog-electric-tab-flag nil
-  "Non-nil means make TAB key electric.
-Electric TAB inserts spaces after parentheses, ->, and ;
-in ( If -> Then ; Else) and ( Disj1 ; Disj2 ) style expressions."
-  :version "24.1"
-  :group 'prolog-keyboard
-  :type 'boolean)
-
 (defcustom prolog-electric-if-then-else-flag nil
   "Non-nil makes `(', `>' and `;' electric
 to automatically indent if-then-else constructs."
@@ -739,14 +704,6 @@ is non-nil for this variable."
 
 ;; Miscellaneous
 
-(defcustom prolog-use-prolog-tokenizer-flag
-  (not (fboundp 'syntax-propertize-rules))
-  "Non-nil means use the internal prolog tokenizer for indentation etc.
-Otherwise use `parse-partial-sexp' which is faster but sometimes incorrect."
-  :version "24.1"
-  :group 'prolog-other
-  :type 'boolean)
-
 (defcustom prolog-imenu-flag t
   "Non-nil means add a clause index menu for all prolog files."
   :version "24.1"
@@ -831,117 +788,12 @@ This is really kludgy, and unneeded (i.e. obsolete) in Emacs>=24."
       (modify-syntax-entry ?/ ". 14" table)
       )
     table))
-(defvar prolog-mode-abbrev-table nil)
-
-(if (eval-when-compile
-      (and (string-match "[[:upper:]]" "A")
-           (with-temp-buffer
-             (insert "A") (skip-chars-backward "[:upper:]") (bolp))))
-    (progn
-      (defconst prolog-upper-case-string "[:upper:]"
-        "A string containing a char-range matching all upper case characters.")
-      (defconst prolog-lower-case-string "[:lower:]"
-        "A string containing a char-range matching all lower case characters."))
-
-  ;; GNU Emacs compatibility: GNU Emacs does not differentiate between
-  ;; ints and chars, or at least these two are interchangeable.
-  (defalias 'prolog-int-to-char
-    (if (fboundp 'int-to-char) #'int-to-char #'identity))
-
-  (defalias 'prolog-char-to-int
-    (if (fboundp 'char-to-int) #'char-to-int #'identity))
-
-  (defun prolog-ints-intervals (ints)
-    "Return a list of intervals (from . to) covering INTS."
-    (when ints
-      (setq ints (sort ints '<))
-      (let ((prev (car ints))
-            (interval-start (car ints))
-            intervals)
-        (while ints
-          (let ((next (car ints)))
-            (when (> next (1+ prev))   ; start of new interval
-             (setq intervals (cons (cons interval-start prev) intervals))
-             (setq interval-start next))
-            (setq prev next)
-            (setq ints (cdr ints))))
-        (setq intervals (cons (cons interval-start prev) intervals))
-        (reverse intervals))))
-
-  (defun prolog-dash-letters (string)
-    "Return a condensed regexp covering all letters in STRING."
-    (let ((intervals (prolog-ints-intervals (mapcar #'prolog-char-to-int
-                                                    (string-to-list string))))
-          codes)
-      (while intervals
-        (let* ((i (car intervals))
-               (from (car i))
-               (to (cdr i))
-               (c (cond ((= from to) `(,from))
-                        ((= (1+ from) to) `(,from ,to))
-                        (t `(,from ?- ,to)))))
-          (setq codes (cons c codes)))
-        (setq intervals (cdr intervals)))
-      (apply 'concat (reverse codes))))
-
-  (let ((up_string "")
-        (low_string ""))
-    ;; Use `map-char-table' if it is defined. Otherwise enumerate all
-    ;; numbers between 0 and 255. `map-char-table' is probably safer.
-    ;;
-    ;; `map-char-table' causes problems under Emacs 23.0.0.1, the
-    ;; while loop seems to do its job well (Ryszard Szopa)
-    ;;
-    ;;(if (and (not (featurep 'xemacs))
-    ;;          (fboundp 'map-char-table))
-    ;;    (map-char-table
-    ;;     (lambda (key value)
-    ;;       (cond
-    ;;        ((and
-    ;;          (eq (prolog-int-to-char key) (downcase key))
-    ;;          (eq (prolog-int-to-char key) (upcase key)))
-    ;;         ;; Do nothing if upper and lower case are the same
-    ;;         )
-    ;;        ((eq (prolog-int-to-char key) (downcase key))
-    ;;         ;; The char is lower case
-    ;;         (setq low_string (format "%s%c" low_string key)))
-    ;;        ((eq (prolog-int-to-char key) (upcase key))
-    ;;         ;; The char is upper case
-    ;;         (setq up_string (format "%s%c" up_string key)))
-    ;;        ))
-    ;;     (current-case-table))
-    ;; `map-char-table' was undefined.
-    (let ((key 0))
-      (while (< key 256)
-        (cond
-         ((and
-           (eq (prolog-int-to-char key) (downcase key))
-           (eq (prolog-int-to-char key) (upcase key)))
-          ;; Do nothing if upper and lower case are the same
-          )
-         ((eq (prolog-int-to-char key) (downcase key))
-          ;; The char is lower case
-          (setq low_string (format "%s%c" low_string key)))
-         ((eq (prolog-int-to-char key) (upcase key))
-          ;; The char is upper case
-          (setq up_string (format "%s%c" up_string key)))
-         )
-        (setq key (1+ key))))
-    ;; )
-    ;; The strings are single-byte strings.
-    (defconst prolog-upper-case-string (prolog-dash-letters up_string)
-      "A string containing a char-range matching all upper case characters.")
-    (defconst prolog-lower-case-string (prolog-dash-letters low_string)
-      "A string containing a char-range matching all lower case characters.")
-    ))
 
 (defconst prolog-atom-char-regexp
-  (if (string-match "[[:alnum:]]" "0")
-      "[[:alnum:]_$]"
-    (format "[%s%s0-9_$]" prolog-lower-case-string prolog-upper-case-string))
+  "[[:alnum:]_$]"
   "Regexp specifying characters which constitute atoms without quoting.")
 (defconst prolog-atom-regexp
-  (format "[%s$]%s*" prolog-lower-case-string prolog-atom-char-regexp))
+  (format "[[:lower:]$]%s*" prolog-atom-char-regexp))
 
 (defconst prolog-left-paren "[[({]"     ;FIXME: Why not \\s(?
   "The characters used as left parentheses for the indentation code.")
@@ -988,8 +840,6 @@ This is really kludgy, and unneeded (i.e. obsolete) in Emacs>=24."
 
 (require 'smie)
 
-(defvar prolog-use-smie t)
-
 (defun prolog-smie-forward-token ()
   ;; FIXME: Add support for 0'<char>, if needed after adding it to
   ;; syntax-propertize-functions.
@@ -1073,6 +923,13 @@ This is really kludgy, and unneeded (i.e. obsolete) in Emacs>=24."
   (pcase (cons kind token)
     (`(:elem . basic) prolog-indent-width)
     (`(:after . ".") '(column . 0)) ;; To work around smie-closer-alist.
+    ;; Allow indentation of if-then-else as:
+    ;;    (   test
+    ;;     -> thenrule
+    ;;     ;  elserule
+    ;;    )
+    (`(:before . ,(or `"->" `";"))
+     (and (smie-rule-bolp) (smie-rule-parent-p "(") (smie-rule-parent 1)))
     (`(:after . ,(or `":-" `"->" `"-->")) prolog-indent-width)))
 
 \f
@@ -1140,17 +997,16 @@ VERSION is of the format (Major . Minor)"
 
 (defun prolog-mode-variables ()
   "Set some common variables to Prolog code specific values."
-  (setq local-abbrev-table prolog-mode-abbrev-table)
-  (set (make-local-variable 'paragraph-start)
-       (concat "[ \t]*$\\|" page-delimiter)) ;'%%..'
-  (set (make-local-variable 'paragraph-separate) paragraph-start)
-  (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
-  (set (make-local-variable 'normal-auto-fill-function) 'prolog-do-auto-fill)
-  (set (make-local-variable 'comment-start) "%")
-  (set (make-local-variable 'comment-end) "")
-  (set (make-local-variable 'comment-add) 1)
-  (set (make-local-variable 'comment-start-skip) "\\(?:/\\*+ *\\|%%+ *\\)")
-  (set (make-local-variable 'parens-require-spaces) nil)
+  (setq-local local-abbrev-table prolog-mode-abbrev-table)
+  (setq-local paragraph-start (concat "[ \t]*$\\|" page-delimiter)) ;'%%..'
+  (setq-local paragraph-separate paragraph-start)
+  (setq-local paragraph-ignore-fill-prefix t)
+  (setq-local normal-auto-fill-function 'prolog-do-auto-fill)
+  (setq-local comment-start "%")
+  (setq-local comment-end "")
+  (setq-local comment-add 1)
+  (setq-local comment-start-skip "\\(?:/\\*+ *\\|%%+ *\\)")
+  (setq-local parens-require-spaces nil)
   ;; Initialize Prolog system specific variables
   (dolist (var '(prolog-keywords prolog-types prolog-mode-specificators
                  prolog-determinism-specificators prolog-directives
@@ -1160,19 +1016,14 @@ VERSION is of the format (Major . Minor)"
     (set (intern (concat (symbol-name var) "-i"))
          (prolog-find-value-by-system (symbol-value var))))
   (when (null (prolog-program-name))
-    (set (make-local-variable 'compile-command) (prolog-compile-string)))
-  (set (make-local-variable 'font-lock-defaults)
-       '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
-  (set (make-local-variable 'syntax-propertize-function)
-      prolog-syntax-propertize-function)
-
-  (if prolog-use-smie
-      ;; Setup SMIE.
-      (smie-setup prolog-smie-grammar #'prolog-smie-rules
-                  :forward-token #'prolog-smie-forward-token
-                  :backward-token #'prolog-smie-backward-token)
-    (set (make-local-variable 'indent-line-function) 'prolog-indent-line))
-  )
+    (setq-local compile-command (prolog-compile-string)))
+  (setq-local font-lock-defaults
+              '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
+  (setq-local syntax-propertize-function prolog-syntax-propertize-function)
+
+  (smie-setup prolog-smie-grammar #'prolog-smie-rules
+              :forward-token #'prolog-smie-forward-token
+              :backward-token #'prolog-smie-backward-token))
 
 (defun prolog-mode-keybindings-common (map)
   "Define keybindings common to both Prolog modes in MAP."
@@ -1193,25 +1044,12 @@ VERSION is of the format (Major . Minor)"
   (define-key map "\C-\M-e" 'prolog-end-of-predicate)
   (define-key map "\M-\C-c" 'prolog-mark-clause)
   (define-key map "\M-\C-h" 'prolog-mark-predicate)
-  (define-key map "\M-\C-n" 'prolog-forward-list)
-  (define-key map "\M-\C-p" 'prolog-backward-list)
   (define-key map "\C-c\C-n" 'prolog-insert-predicate-template)
   (define-key map "\C-c\C-s" 'prolog-insert-predspec)
   (define-key map "\M-\r" 'prolog-insert-next-clause)
   (define-key map "\C-c\C-va" 'prolog-variables-to-anonymous)
   (define-key map "\C-c\C-v\C-s" 'prolog-view-predspec)
 
-  (define-key map [Backspace] 'prolog-electric-delete)
-  (define-key map "." 'prolog-electric-dot)
-  (define-key map "_" 'prolog-electric-underscore)
-  (define-key map "(" 'prolog-electric-if-then-else)
-  (define-key map ";" 'prolog-electric-if-then-else)
-  (define-key map ">" 'prolog-electric-if-then-else)
-  (define-key map ":" 'prolog-electric-colon)
-  (define-key map "-" 'prolog-electric-dash)
-  (if prolog-electric-newline-flag
-      (define-key map "\r" 'newline-and-indent))
-
   ;; If we're running SICStus, then map C-c C-c e/d to enabling
   ;; and disabling of the source-level debugging facilities.
   ;(if (and (eq prolog-system 'sicstus)
@@ -1258,8 +1096,6 @@ VERSION is of the format (Major . Minor)"
 (defvar prolog-mode-hook nil
   "List of functions to call after the prolog mode has initialized.")
 
-(unless (fboundp 'prog-mode)
-  (defalias 'prog-mode 'fundamental-mode))
 ;;;###autoload
 (define-derived-mode prolog-mode prog-mode "Prolog"
   "Major mode for editing Prolog code.
@@ -1273,9 +1109,7 @@ To find out what version of Prolog mode you are running, enter
 `\\[prolog-mode-version]'.
 
 Commands:
-\\{prolog-mode-map}
-Entry to this mode calls the value of `prolog-mode-hook'
-if that value is non-nil."
+\\{prolog-mode-map}"
   (setq mode-name (concat "Prolog"
                           (cond
                            ((eq prolog-system 'eclipse) "[ECLiPSe]")
@@ -1285,7 +1119,7 @@ if that value is non-nil."
                            (t ""))))
   (prolog-mode-variables)
   (dolist (ar prolog-align-rules) (add-to-list 'align-rules-list ar))
-
+  (add-hook 'post-self-insert-hook #'prolog-post-self-insert nil t)
   ;; `imenu' entry moved to the appropriate hook for consistency.
 
   ;; Load SICStus debugger if suitable
@@ -1305,7 +1139,7 @@ if that value is non-nil."
 (define-derived-mode mercury-mode prolog-mode "Prolog[Mercury]"
   "Major mode for editing Mercury programs.
 Actually this is just customized `prolog-mode'."
-  (set (make-local-variable 'prolog-system) 'mercury))
+  (setq-local prolog-system 'mercury))
 
 \f
 ;;-------------------------------------------------------------------
@@ -1393,9 +1227,9 @@ To find out what version of Prolog mode you are running, enter
   (setq mode-line-process '(": %s"))
   (prolog-mode-variables)
   (setq comint-prompt-regexp (prolog-prompt-regexp))
-  (set (make-local-variable 'shell-dirstack-query) "pwd.")
-  (set (make-local-variable 'compilation-error-regexp-alist)
-       prolog-inferior-error-regexp-alist)
+  (setq-local shell-dirstack-query "pwd.")
+  (setq-local compilation-error-regexp-alist
+              prolog-inferior-error-regexp-alist)
   (compilation-shell-minor-mode)
   (prolog-inferior-menu))
 
@@ -1430,22 +1264,22 @@ With prefix argument ARG, restart the Prolog process if running before."
     ))
 
 (defun prolog-inferior-guess-flavor (&optional ignored)
-  (setq prolog-system
-        (when (or (numberp prolog-system) (markerp prolog-system))
-          (save-excursion
-            (goto-char (1+ prolog-system))
-            (cond
-             ((looking-at "GNU Prolog") 'gnu)
-             ((looking-at "Welcome to SWI-Prolog\\|%.*\\<swi_") 'swi)
-             ((looking-at ".*\n") nil) ;There's at least one line.
-             (t prolog-system)))))
+  (setq-local prolog-system
+              (when (or (numberp prolog-system) (markerp prolog-system))
+                (save-excursion
+                  (goto-char (1+ prolog-system))
+                  (cond
+                   ((looking-at "GNU Prolog") 'gnu)
+                   ((looking-at "Welcome to SWI-Prolog\\|%.*\\<swi_") 'swi)
+                   ((looking-at ".*\n") nil) ;There's at least one line.
+                   (t prolog-system)))))
   (when (symbolp prolog-system)
     (remove-hook 'comint-output-filter-functions
                  'prolog-inferior-guess-flavor t)
     (when prolog-system
       (setq comint-prompt-regexp (prolog-prompt-regexp))
       (if (eq prolog-system 'gnu)
-          (set (make-local-variable 'comint-process-echoes) t)))))
+          (setq-local comint-process-echoes t)))))
 
 (defun prolog-ensure-process (&optional wait)
   "If Prolog process is not running, run it.
@@ -1461,21 +1295,22 @@ the variable `prolog-prompt-regexp'."
              (prolog-program-name) nil (prolog-program-switches))
       (unless prolog-system
         ;; Setup auto-detection.
-        (set (make-local-variable 'prolog-system)
-             ;; Force re-detection.
-             (let* ((proc (get-buffer-process (current-buffer)))
-                    (pmark (and proc (marker-position (process-mark proc)))))
-               (cond
-                ((null pmark) (1- (point-min)))
-                ;; The use of insert-before-markers in comint.el together with
-                ;; the potential use of comint-truncate-buffer in the output
-                ;; filter, means that it's difficult to reliably keep track of
-                ;; the buffer position where the process's output started.
-                ;; If possible we use a marker at "start - 1", so that
-                ;; insert-before-marker at `start' won't shift it.  And if not,
-                ;; we fall back on using a plain integer.
-                ((> pmark (point-min)) (copy-marker (1- pmark)))
-                (t (1- pmark)))))
+        (setq-local
+         prolog-system
+         ;; Force re-detection.
+         (let* ((proc (get-buffer-process (current-buffer)))
+                (pmark (and proc (marker-position (process-mark proc)))))
+           (cond
+            ((null pmark) (1- (point-min)))
+            ;; The use of insert-before-markers in comint.el together with
+            ;; the potential use of comint-truncate-buffer in the output
+            ;; filter, means that it's difficult to reliably keep track of
+            ;; the buffer position where the process's output started.
+            ;; If possible we use a marker at "start - 1", so that
+            ;; insert-before-marker at `start' won't shift it.  And if not,
+            ;; we fall back on using a plain integer.
+            ((> pmark (point-min)) (copy-marker (1- pmark)))
+            (t (1- pmark)))))
         (add-hook 'comint-output-filter-functions
                   'prolog-inferior-guess-flavor nil t))
       (if wait
@@ -1742,16 +1577,16 @@ This function must be called from the source code buffer."
       (compilation-mode)
       ;; FIXME: This doesn't seem to cooperate well with new(ish) compile.el.
       ;; Setting up font-locking for this buffer
-      (set (make-local-variable 'font-lock-defaults)
-           '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
+      (setq-local font-lock-defaults
+                  '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
       (if (eq prolog-system 'sicstus)
           ;; FIXME: This looks really problematic: not only is this using
           ;; the old compilation-parse-errors-function, but
           ;; prolog-parse-sicstus-compilation-errors only accepts one argument
           ;; whereas compile.el calls it with 2 (and did so at least since
           ;; Emacs-20).
-            (set (make-local-variable 'compilation-parse-errors-function)
-               'prolog-parse-sicstus-compilation-errors))
+          (setq-local compilation-parse-errors-function
+                      'prolog-parse-sicstus-compilation-errors))
       (setq buffer-read-only nil)
       (insert command-string "\n"))
     (display-buffer buffer)
@@ -1978,663 +1813,272 @@ Argument BOUND is a buffer position limiting searching."
 ;; Set everything up
 (defun prolog-font-lock-keywords ()
   "Set up font lock keywords for the current Prolog system."
-  ;(when window-system
-    (require 'font-lock)
-
-    ;; Define Prolog faces
-    (defface prolog-redo-face
-      '((((class grayscale)) (:italic t))
-        (((class color)) (:foreground "darkorchid"))
-        (t (:italic t)))
-      "Prolog mode face for highlighting redo trace lines."
-      :group 'prolog-faces)
-    (defface prolog-exit-face
-      '((((class grayscale)) (:underline t))
-        (((class color) (background dark)) (:foreground "green"))
-        (((class color) (background light)) (:foreground "ForestGreen"))
-        (t (:underline t)))
-      "Prolog mode face for highlighting exit trace lines."
-      :group 'prolog-faces)
-    (defface prolog-exception-face
-      '((((class grayscale)) (:bold t :italic t :underline t))
-        (((class color)) (:bold t :foreground "black" :background "Khaki"))
-        (t (:bold t :italic t :underline t)))
-      "Prolog mode face for highlighting exception trace lines."
-      :group 'prolog-faces)
-    (defface prolog-warning-face
-      '((((class grayscale)) (:underline t))
-        (((class color) (background dark)) (:foreground "blue"))
-        (((class color) (background light)) (:foreground "MidnightBlue"))
-        (t (:underline t)))
-      "Face name to use for compiler warnings."
-      :group 'prolog-faces)
-    (defface prolog-builtin-face
-      '((((class color) (background light)) (:foreground "Purple"))
-        (((class color) (background dark)) (:foreground "Cyan"))
-        (((class grayscale) (background light))
-         :foreground "LightGray" :bold t)
-        (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
-        (t (:bold t)))
-      "Face name to use for compiler warnings."
-      :group 'prolog-faces)
-    (defvar prolog-warning-face
-      (if (prolog-face-name-p 'font-lock-warning-face)
-          'font-lock-warning-face
-        'prolog-warning-face)
-      "Face name to use for built in predicates.")
-    (defvar prolog-builtin-face
-      (if (prolog-face-name-p 'font-lock-builtin-face)
-          'font-lock-builtin-face
-        'prolog-builtin-face)
-      "Face name to use for built in predicates.")
-    (defvar prolog-redo-face 'prolog-redo-face
-      "Face name to use for redo trace lines.")
-    (defvar prolog-exit-face 'prolog-exit-face
-      "Face name to use for exit trace lines.")
-    (defvar prolog-exception-face 'prolog-exception-face
-      "Face name to use for exception trace lines.")
-
-    ;; Font Lock Patterns
-    (let (
-          ;; "Native" Prolog patterns
-          (head-predicates
-           (list (format "^\\(%s\\)\\((\\|[ \t]*:-\\)" prolog-atom-regexp)
-                 1 font-lock-function-name-face))
-           ;(list (format "^%s" prolog-atom-regexp)
-           ;      0 font-lock-function-name-face))
-          (head-predicates-1
-           (list (format "\\.[ \t]*\\(%s\\)" prolog-atom-regexp)
-                 1 font-lock-function-name-face) )
-          (variables
-           '("\\<\\([_A-Z][a-zA-Z0-9_]*\\)"
-             1 font-lock-variable-name-face))
-          (important-elements
-           (list (if (eq prolog-system 'mercury)
-                     "[][}{;|]\\|\\\\[+=]\\|<?=>?"
-                   "[][}{!;|]\\|\\*->")
-                 0 'font-lock-keyword-face))
-          (important-elements-1
-           '("[^-*]\\(->\\)" 1 font-lock-keyword-face))
-          (predspecs                        ; module:predicate/cardinality
-           (list (format "\\<\\(%s:\\|\\)%s/[0-9]+"
-                         prolog-atom-regexp prolog-atom-regexp)
-                 0 font-lock-function-name-face 'prepend))
-          (keywords                        ; directives (queries)
-           (list
-            (if (eq prolog-system 'mercury)
-                (concat
-                 "\\<\\("
-                 (regexp-opt prolog-keywords-i)
-                 "\\|"
-                 (regexp-opt
-                  prolog-determinism-specificators-i)
-                 "\\)\\>")
-              (concat
-               "^[?:]- *\\("
-               (regexp-opt prolog-keywords-i)
-               "\\)\\>"))
-              1 prolog-builtin-face))
-          ;; SICStus specific patterns
-          (sicstus-object-methods
-           (if (eq prolog-system 'sicstus)
-               '(prolog-font-lock-object-matcher
-                 1 font-lock-function-name-face)))
-          ;; Mercury specific patterns
-          (types
-           (if (eq prolog-system 'mercury)
-               (list
-                (regexp-opt prolog-types-i 'words)
-                0 'font-lock-type-face)))
-          (modes
-           (if (eq prolog-system 'mercury)
-               (list
-                (regexp-opt prolog-mode-specificators-i 'words)
-                0 'font-lock-constant-face)))
-          (directives
-           (if (eq prolog-system 'mercury)
-               (list
-                (regexp-opt prolog-directives-i 'words)
-                0 'prolog-warning-face)))
-          ;; Inferior mode specific patterns
-          (prompt
-           ;; FIXME: Should be handled by comint already.
-           (list (prolog-prompt-regexp) 0 'font-lock-keyword-face))
-          (trace-exit
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exit\\):"
-               1 prolog-exit-face))
-            ((eq prolog-system 'swi)
-             '("[ \t]*\\(Exit\\):[ \t]*([ \t0-9]*)" 1 prolog-exit-face))
-            (t nil)))
-          (trace-fail
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Fail\\):"
-               1 prolog-warning-face))
-            ((eq prolog-system 'swi)
-             '("[ \t]*\\(Fail\\):[ \t]*([ \t0-9]*)" 1 prolog-warning-face))
-            (t nil)))
-          (trace-redo
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Redo\\):"
-               1 prolog-redo-face))
-            ((eq prolog-system 'swi)
-             '("[ \t]*\\(Redo\\):[ \t]*([ \t0-9]*)" 1 prolog-redo-face))
-            (t nil)))
-          (trace-call
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Call\\):"
-               1 font-lock-function-name-face))
-            ((eq prolog-system 'swi)
-             '("[ \t]*\\(Call\\):[ \t]*([ \t0-9]*)"
+  ;;(when window-system
+  (require 'font-lock)
+
+  ;; Define Prolog faces
+  (defface prolog-redo-face
+    '((((class grayscale)) (:italic t))
+      (((class color)) (:foreground "darkorchid"))
+      (t (:italic t)))
+    "Prolog mode face for highlighting redo trace lines."
+    :group 'prolog-faces)
+  (defface prolog-exit-face
+    '((((class grayscale)) (:underline t))
+      (((class color) (background dark)) (:foreground "green"))
+      (((class color) (background light)) (:foreground "ForestGreen"))
+      (t (:underline t)))
+    "Prolog mode face for highlighting exit trace lines."
+    :group 'prolog-faces)
+  (defface prolog-exception-face
+    '((((class grayscale)) (:bold t :italic t :underline t))
+      (((class color)) (:bold t :foreground "black" :background "Khaki"))
+      (t (:bold t :italic t :underline t)))
+    "Prolog mode face for highlighting exception trace lines."
+    :group 'prolog-faces)
+  (defface prolog-warning-face
+    '((((class grayscale)) (:underline t))
+      (((class color) (background dark)) (:foreground "blue"))
+      (((class color) (background light)) (:foreground "MidnightBlue"))
+      (t (:underline t)))
+    "Face name to use for compiler warnings."
+    :group 'prolog-faces)
+  (defface prolog-builtin-face
+    '((((class color) (background light)) (:foreground "Purple"))
+      (((class color) (background dark)) (:foreground "Cyan"))
+      (((class grayscale) (background light))
+       :foreground "LightGray" :bold t)
+      (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
+      (t (:bold t)))
+    "Face name to use for compiler warnings."
+    :group 'prolog-faces)
+  (defvar prolog-warning-face
+    (if (prolog-face-name-p 'font-lock-warning-face)
+        'font-lock-warning-face
+      'prolog-warning-face)
+    "Face name to use for built in predicates.")
+  (defvar prolog-builtin-face
+    (if (prolog-face-name-p 'font-lock-builtin-face)
+        'font-lock-builtin-face
+      'prolog-builtin-face)
+    "Face name to use for built in predicates.")
+  (defvar prolog-redo-face 'prolog-redo-face
+    "Face name to use for redo trace lines.")
+  (defvar prolog-exit-face 'prolog-exit-face
+    "Face name to use for exit trace lines.")
+  (defvar prolog-exception-face 'prolog-exception-face
+    "Face name to use for exception trace lines.")
+
+  ;; Font Lock Patterns
+  (let (
+        ;; "Native" Prolog patterns
+        (head-predicates
+         (list (format "^\\(%s\\)\\((\\|[ \t]*:-\\)" prolog-atom-regexp)
                1 font-lock-function-name-face))
-            (t nil)))
-          (trace-exception
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exception\\):"
-               1 prolog-exception-face))
-            ((eq prolog-system 'swi)
-             '("[ \t]*\\(Exception\\):[ \t]*([ \t0-9]*)"
-               1 prolog-exception-face))
-            (t nil)))
-          (error-message-identifier
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("{\\([A-Z]* ?ERROR:\\)" 1 prolog-exception-face prepend))
-            ((eq prolog-system 'swi)
-             '("^[[]\\(WARNING:\\)" 1 prolog-builtin-face prepend))
-            (t nil)))
-          (error-whole-messages
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("{\\([A-Z]* ?ERROR:.*\\)}[ \t]*$"
-               1 font-lock-comment-face append))
-            ((eq prolog-system 'swi)
-             '("^[[]WARNING:[^]]*[]]$" 0 font-lock-comment-face append))
-            (t nil)))
-          (error-warning-messages
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           ;; Mostly errors that SICStus asks the user about how to solve,
-           ;; such as "NAME CLASH:" for example.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("^[A-Z ]*[A-Z]+:" 0 prolog-warning-face))
-            (t nil)))
-          (warning-messages
-           ;; FIXME: Add to compilation-error-regexp-alist instead.
-           (cond
-            ((eq prolog-system 'sicstus)
-             '("\\({ ?\\(Warning\\|WARNING\\) ?:.*}\\)[ \t]*$"
-               2 prolog-warning-face prepend))
-            (t nil))))
-
-      ;; Make font lock list
-      (delq
-       nil
-       (cond
-        ((eq major-mode 'prolog-mode)
+                                       ;(list (format "^%s" prolog-atom-regexp)
+                                       ;      0 font-lock-function-name-face))
+        (head-predicates-1
+         (list (format "\\.[ \t]*\\(%s\\)" prolog-atom-regexp)
+               1 font-lock-function-name-face) )
+        (variables
+         '("\\<\\([_A-Z][a-zA-Z0-9_]*\\)"
+           1 font-lock-variable-name-face))
+        (important-elements
+         (list (if (eq prolog-system 'mercury)
+                   "[][}{;|]\\|\\\\[+=]\\|<?=>?"
+                 "[][}{!;|]\\|\\*->")
+               0 'font-lock-keyword-face))
+        (important-elements-1
+         '("[^-*]\\(->\\)" 1 font-lock-keyword-face))
+        (predspecs                      ; module:predicate/cardinality
+         (list (format "\\<\\(%s:\\|\\)%s/[0-9]+"
+                       prolog-atom-regexp prolog-atom-regexp)
+               0 font-lock-function-name-face 'prepend))
+        (keywords                       ; directives (queries)
          (list
-          head-predicates
-          head-predicates-1
-          variables
-          important-elements
-          important-elements-1
-          predspecs
-          keywords
-          sicstus-object-methods
-          types
-          modes
-          directives))
-        ((eq major-mode 'prolog-inferior-mode)
-         (list
-         prompt
-         error-message-identifier
-         error-whole-messages
-         error-warning-messages
-         warning-messages
-         predspecs
-         trace-exit
-         trace-fail
-         trace-redo
-         trace-call
-         trace-exception))
-        ((eq major-mode 'compilation-mode)
-         (list
-         error-message-identifier
-         error-whole-messages
-         error-warning-messages
-         warning-messages
-         predspecs))))
-      ))
-
-\f
-;;-------------------------------------------------------------------
-;; Indentation stuff
-;;-------------------------------------------------------------------
-
-;; NB: This function *MUST* have this optional argument since XEmacs
-;; assumes it. This does not mean we have to use it...
-(defun prolog-indent-line (&optional _whole-exp)
-  "Indent current line as Prolog code.
-With argument, indent any additional lines of the same clause
-rigidly along with this one (not yet)."
-  (interactive "p")
-  (let ((indent (prolog-indent-level))
-        (pos (- (point-max) (point))))
-    (beginning-of-line)
-    (skip-chars-forward " \t")
-    (indent-line-to indent)
-    (if (> (- (point-max) pos) (point))
-        (goto-char (- (point-max) pos)))
-
-    ;; Align comments
-    (if (and prolog-align-comments-flag
-             (save-excursion
-               (line-beginning-position)
-               ;; (let ((start (comment-search-forward (line-end-position) t)))
-               ;;   (and start             ;There's a comment to indent.
-               ;;       ;; If it's first on the line, we've indented it already
-               ;;       ;; and prolog-goto-comment-column would inf-loop.
-               ;;       (progn (goto-char start) (skip-chars-backward " \t")
-               ;;              (not (bolp)))))))
-               (and (looking-at comment-start-skip)
-                    ;; The definition of comment-start-skip used in this
-                    ;; mode is unusual in that it only matches at BOL.
-                    (progn (skip-chars-forward " \t")
-                           (not (eq (point) (match-end 1)))))))
-        (save-excursion
-          (prolog-goto-comment-column t)))
-
-    ;; Insert spaces if needed
-    (if (or prolog-electric-tab-flag prolog-electric-if-then-else-flag)
-        (prolog-insert-spaces-after-paren))
+          (if (eq prolog-system 'mercury)
+              (concat
+               "\\<\\("
+               (regexp-opt prolog-keywords-i)
+               "\\|"
+               (regexp-opt
+                prolog-determinism-specificators-i)
+               "\\)\\>")
+            (concat
+             "^[?:]- *\\("
+             (regexp-opt prolog-keywords-i)
+             "\\)\\>"))
+          1 prolog-builtin-face))
+        ;; SICStus specific patterns
+        (sicstus-object-methods
+         (if (eq prolog-system 'sicstus)
+             '(prolog-font-lock-object-matcher
+               1 font-lock-function-name-face)))
+        ;; Mercury specific patterns
+        (types
+         (if (eq prolog-system 'mercury)
+             (list
+              (regexp-opt prolog-types-i 'words)
+              0 'font-lock-type-face)))
+        (modes
+         (if (eq prolog-system 'mercury)
+             (list
+              (regexp-opt prolog-mode-specificators-i 'words)
+              0 'font-lock-constant-face)))
+        (directives
+         (if (eq prolog-system 'mercury)
+             (list
+              (regexp-opt prolog-directives-i 'words)
+              0 'prolog-warning-face)))
+        ;; Inferior mode specific patterns
+        (prompt
+         ;; FIXME: Should be handled by comint already.
+         (list (prolog-prompt-regexp) 0 'font-lock-keyword-face))
+        (trace-exit
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exit\\):"
+             1 prolog-exit-face))
+          ((eq prolog-system 'swi)
+           '("[ \t]*\\(Exit\\):[ \t]*([ \t0-9]*)" 1 prolog-exit-face))
+          (t nil)))
+        (trace-fail
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Fail\\):"
+             1 prolog-warning-face))
+          ((eq prolog-system 'swi)
+           '("[ \t]*\\(Fail\\):[ \t]*([ \t0-9]*)" 1 prolog-warning-face))
+          (t nil)))
+        (trace-redo
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Redo\\):"
+             1 prolog-redo-face))
+          ((eq prolog-system 'swi)
+           '("[ \t]*\\(Redo\\):[ \t]*([ \t0-9]*)" 1 prolog-redo-face))
+          (t nil)))
+        (trace-call
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Call\\):"
+             1 font-lock-function-name-face))
+          ((eq prolog-system 'swi)
+           '("[ \t]*\\(Call\\):[ \t]*([ \t0-9]*)"
+             1 font-lock-function-name-face))
+          (t nil)))
+        (trace-exception
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exception\\):"
+             1 prolog-exception-face))
+          ((eq prolog-system 'swi)
+           '("[ \t]*\\(Exception\\):[ \t]*([ \t0-9]*)"
+             1 prolog-exception-face))
+          (t nil)))
+        (error-message-identifier
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("{\\([A-Z]* ?ERROR:\\)" 1 prolog-exception-face prepend))
+          ((eq prolog-system 'swi)
+           '("^[[]\\(WARNING:\\)" 1 prolog-builtin-face prepend))
+          (t nil)))
+        (error-whole-messages
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("{\\([A-Z]* ?ERROR:.*\\)}[ \t]*$"
+             1 font-lock-comment-face append))
+          ((eq prolog-system 'swi)
+           '("^[[]WARNING:[^]]*[]]$" 0 font-lock-comment-face append))
+          (t nil)))
+        (error-warning-messages
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         ;; Mostly errors that SICStus asks the user about how to solve,
+         ;; such as "NAME CLASH:" for example.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("^[A-Z ]*[A-Z]+:" 0 prolog-warning-face))
+          (t nil)))
+        (warning-messages
+         ;; FIXME: Add to compilation-error-regexp-alist instead.
+         (cond
+          ((eq prolog-system 'sicstus)
+           '("\\({ ?\\(Warning\\|WARNING\\) ?:.*}\\)[ \t]*$"
+             2 prolog-warning-face prepend))
+          (t nil))))
+
+    ;; Make font lock list
+    (delq
+     nil
+     (cond
+      ((eq major-mode 'prolog-mode)
+       (list
+        head-predicates
+        head-predicates-1
+        variables
+        important-elements
+        important-elements-1
+        predspecs
+        keywords
+        sicstus-object-methods
+        types
+        modes
+        directives))
+      ((eq major-mode 'prolog-inferior-mode)
+       (list
+        prompt
+        error-message-identifier
+        error-whole-messages
+        error-warning-messages
+        warning-messages
+        predspecs
+        trace-exit
+        trace-fail
+        trace-redo
+        trace-call
+        trace-exception))
+      ((eq major-mode 'compilation-mode)
+       (list
+        error-message-identifier
+        error-whole-messages
+        error-warning-messages
+        warning-messages
+        predspecs))))
     ))
 
-(defun prolog-indent-level ()
-  "Compute prolog indentation level."
-  (save-excursion
-    (beginning-of-line)
-    (let ((totbal (prolog-region-paren-balance
-                   (prolog-clause-start t) (point)))
-          (oldpoint (point)))
-      (skip-chars-forward " \t")
-      (cond
-       ((looking-at "%%%") (prolog-indentation-level-of-line))
-                                             ;Large comment starts
-       ((looking-at "%[^%]") comment-column) ;Small comment starts
-       ((bobp) 0)                            ;Beginning of buffer
-
-       ;; If we found '}' then we must check if it's the
-       ;; end of an object declaration or something else.
-       ((and (looking-at "}")
-             (save-excursion
-               (forward-char 1)
-               ;; Goto to matching {
-               (if prolog-use-prolog-tokenizer-flag
-                   (prolog-backward-list)
-                 (backward-list))
-               (skip-chars-backward " \t")
-               (backward-char 2)
-               (looking-at "::")))
-        ;; It was an object
-        (if prolog-object-end-to-0-flag
-            0
-          prolog-indent-width))
-
-       ;;End of /* */ comment
-       ((looking-at "\\*/")
-        (save-excursion
-          (prolog-find-start-of-mline-comment)
-          (skip-chars-backward " \t")
-          (- (current-column) 2)))
-
-       ;; Here we check if the current line is within a /* */ pair
-       ((and (looking-at "[^%/]")
-             (eq (prolog-in-string-or-comment) 'cmt))
-        (if prolog-indent-mline-comments-flag
-            (prolog-find-start-of-mline-comment)
-          ;; Same as before
-          (prolog-indentation-level-of-line)))
-
-       (t
-        (let ((empty t) ind linebal)
-          ;; See previous indentation
-          (while empty
-            (forward-line -1)
-            (beginning-of-line)
-            (if (bobp)
-                (setq empty nil)
-              (skip-chars-forward " \t")
-              (if (not (or (not (member (prolog-in-string-or-comment)
-                                        '(nil txt)))
-                           (looking-at "%")
-                           (looking-at "\n")))
-                  (setq empty nil))))
-
-          ;; Store this line's indentation
-          (setq ind (if (bobp)
-                        0                ;Beginning of buffer.
-                      (current-column))) ;Beginning of clause.
-
-          ;; Compute the balance of the line
-          (setq linebal (prolog-paren-balance))
-          ;;(message "bal of previous line %d totbal %d" linebal totbal)
-          (if (< linebal 0)
-              (progn
-                ;; Add 'indent-level' mode to find-unmatched-paren instead?
-                (end-of-line)
-                (setq ind (prolog-find-indent-of-matching-paren))))
-
-          ;;(message "ind %d" ind)
-          (beginning-of-line)
-
-          ;; Check if the line ends with ":-", ".", ":: {", "}" (might be
-          ;; unnecessary), "&" or ")" (The last four concerns SICStus objects)
-          (cond
-           ;; If the last char of the line is a '&' then set the indent level
-           ;; to prolog-indent-width (used in SICStus objects)
-           ((and (eq prolog-system 'sicstus)
-                 (looking-at ".+&[ \t]*\\(%.*\\|\\)$"))
-            (setq ind prolog-indent-width))
-
-           ;; Increase indentation if the previous line was the head of a rule
-           ;; and does not contain a '.'
-           ((and (looking-at (format ".*%s[^\\.]*[ \t]*\\(%%.*\\|\\)$"
-                                     prolog-head-delimiter))
-                 ;; We must check that the match is at a paren balance of 0.
-                 (save-excursion
-                   (let ((p (point)))
-                     (re-search-forward prolog-head-delimiter)
-                     (>= 0 (prolog-region-paren-balance p (point))))))
-            (let ((headindent
-                   (if (< (prolog-paren-balance) 0)
-                       (save-excursion
-                         (end-of-line)
-                         (prolog-find-indent-of-matching-paren))
-                     (prolog-indentation-level-of-line))))
-              (setq ind (+ headindent prolog-indent-width))))
-
-           ;; The previous line was the head of an object
-           ((looking-at ".+ *::.*{[ \t]*$")
-            (setq ind prolog-indent-width))
-
-           ;; If a '.' is found at the end of the previous line, then
-           ;; decrease the indentation. (The \\(%.*\\|\\) part of the
-           ;; regexp is for comments at the end of the line)
-           ((and (looking-at "^.+\\.[ \t]*\\(%.*\\|\\)$")
-                 ;; Make sure that the '.' found is not in a comment or string
-                 (save-excursion
-                   (end-of-line)
-                   (re-search-backward "\\.[ \t]*\\(%.*\\|\\)$" (point-min))
-                   ;; Guard against the real '.' being followed by a
-                   ;; commented '.'.
-                   (if (eq (prolog-in-string-or-comment) 'cmt)
-                       ;; commented out '.'
-                       (let ((here (line-beginning-position)))
-                         (end-of-line)
-                         (re-search-backward "\\.[ \t]*%.*$" here t))
-                     (not (prolog-in-string-or-comment))
-                     )
-                   ))
-            (setq ind 0))
-
-           ;; If a '.' is found at the end of the previous line, then
-           ;; decrease the indentation. (The /\\*.*\\*/ part of the
-           ;; regexp is for C-like comments at the end of the
-           ;; line--can we merge with the case above?).
-           ((and (looking-at "^.+\\.[ \t]*\\(/\\*.*\\|\\)$")
-                 ;; Make sure that the '.' found is not in a comment or string
-                 (save-excursion
-                   (end-of-line)
-                   (re-search-backward "\\.[ \t]*\\(/\\*.*\\|\\)$" (point-min))
-                   ;; Guard against the real '.' being followed by a
-                   ;; commented '.'.
-                   (if (eq (prolog-in-string-or-comment) 'cmt)
-                       ;; commented out '.'
-                       (let ((here (line-beginning-position)))
-                         (end-of-line)
-                         (re-search-backward "\\.[ \t]*/\\*.*$" here t))
-                     (not (prolog-in-string-or-comment))
-                     )
-                   ))
-            (setq ind 0))
-
-           )
-
-          ;; If the last non comment char is a ',' or left paren or a left-
-          ;; indent-regexp then indent to open parenthesis level
-          (if (and
-               (> totbal 0)
-               ;; SICStus objects have special syntax rules if point is
-               ;; not inside additional parens (objects are defined
-               ;; within {...})
-               (not (and (eq prolog-system 'sicstus)
-                         (= totbal 1)
-                         (prolog-in-object))))
-              (if (looking-at
-                   (format "\\(%s\\|%s\\|0'.\\|[0-9]+'[0-9a-zA-Z]+\\|[^\n\'\"%%]\\)*\\(,\\|%s\\|%s\\)\[ \t]*\\(%%.*\\|\\)$"
-                           prolog-quoted-atom-regexp prolog-string-regexp
-                           prolog-left-paren prolog-left-indent-regexp))
-                  (progn
-                    (goto-char oldpoint)
-                    (setq ind (prolog-find-unmatched-paren
-                               (if prolog-paren-indent-p
-                                   'termdependent
-                                 'skipwhite)))
-                    ;;(setq ind (prolog-find-unmatched-paren 'termdependent))
-                    )
-                (goto-char oldpoint)
-                (setq ind (prolog-find-unmatched-paren nil))
-                ))
-
-
-          ;; Return the indentation level
-          ind
-          ))))))
-
-(defun prolog-find-indent-of-matching-paren ()
-  "Find the indentation level based on the matching parenthesis.
-Indentation level is set to the one the point is after when the function is
-called."
-  (save-excursion
-    ;; Go to the matching paren
-    (if prolog-use-prolog-tokenizer-flag
-        (prolog-backward-list)
-      (backward-list))
-
-    ;; If this was the first paren on the line then return this line's
-    ;; indentation level
-    (if (prolog-paren-is-the-first-on-line-p)
-        (prolog-indentation-level-of-line)
-      ;; It was not the first one
-      (progn
-         ;; Find the next paren
-         (prolog-goto-next-paren 0)
-
-         ;; If this paren is a left one then use its column as indent level,
-         ;; if not then recurse this function
-         (if (looking-at prolog-left-paren)
-             (+ (current-column) 1)
-           (progn
-              (forward-char 1)
-              (prolog-find-indent-of-matching-paren)))
-         ))
-    ))
+\f
 
-(defun prolog-indentation-level-of-line ()
-  "Return the indentation level of the current line."
+(defun prolog-find-unmatched-paren ()
+  "Return the column of the last unmatched left parenthesis."
   (save-excursion
-    (beginning-of-line)
-    (skip-chars-forward " \t")
+    (goto-char (or (car (nth 9 (syntax-ppss))) (point-min)))
     (current-column)))
 
-(defun prolog-paren-is-the-first-on-line-p ()
-  "Return t if the parenthesis under the point is the first one on the line.
-Return nil otherwise.
-Note: does not check if the point is actually at a parenthesis!"
-  (save-excursion
-    (let ((begofline (line-beginning-position)))
-      (if (= begofline (point))
-          t
-        (if (prolog-goto-next-paren begofline)
-            nil
-          t)))))
-
-(defun prolog-find-unmatched-paren (&optional mode)
-  "Return the column of the last unmatched left parenthesis.
-If MODE is `skipwhite' then any white space after the parenthesis is added to
-the answer.
-If MODE is `plusone' then the parenthesis' column +1 is returned.
-If MODE is `termdependent' then if the unmatched parenthesis is part of
-a compound term the function will work as `skipwhite', otherwise
-it will return the column paren plus the value of `prolog-paren-indent'.
-If MODE is nil or not set then the parenthesis' exact column is returned."
-  (save-excursion
-    ;; If the next paren we find is a left one we're finished, if it's
-    ;; a right one then we go back one step and recurse
-    (prolog-goto-next-paren 0)
-
-    (let ((roundparen (looking-at "(")))
-      (if (looking-at prolog-left-paren)
-          (let ((not-part-of-term
-                 (save-excursion
-                   (backward-char 1)
-                   (looking-at "[ \t]"))))
-            (if (eq mode nil)
-                (current-column)
-              (if (and roundparen
-                       (eq mode 'termdependent)
-                       not-part-of-term)
-                  (+ (current-column)
-                     (if prolog-electric-tab-flag
-                         ;; Electric TAB
-                         prolog-paren-indent
-                       ;; Not electric TAB
-                       (if (looking-at ".[ \t]*$")
-                           2
-                         prolog-paren-indent))
-                     )
-
-                (forward-char 1)
-                (if (or (eq mode 'skipwhite) (eq mode 'termdependent) )
-                    (skip-chars-forward " \t"))
-                (current-column))))
-        ;; Not looking at left paren
-        (progn
-          (forward-char 1)
-          ;; Go to the matching paren. When we get there we have a total
-          ;; balance of 0.
-          (if prolog-use-prolog-tokenizer-flag
-              (prolog-backward-list)
-            (backward-list))
-          (prolog-find-unmatched-paren mode)))
-      )))
-
 
 (defun prolog-paren-balance ()
   "Return the parenthesis balance of the current line.
-A return value of n means n more left parentheses than right ones."
+A return value of N means N more left parentheses than right ones."
   (save-excursion
-    (end-of-line)
-    (prolog-region-paren-balance (line-beginning-position) (point))))
-
-(defun prolog-region-paren-balance (beg end)
-  "Return the summed parenthesis balance in the region.
-The region is limited by BEG and END positions."
-  (save-excursion
-    (let ((state (if prolog-use-prolog-tokenizer-flag
-                     (prolog-tokenize beg end)
-                   (parse-partial-sexp beg end))))
-      (nth 0 state))))
-
-(defun prolog-goto-next-paren (limit-pos)
-  "Move the point to the next parenthesis earlier in the buffer.
-Return t if a match was found before LIMIT-POS.  Return nil otherwise."
-  (let ((retval (re-search-backward
-                 (concat prolog-left-paren "\\|" prolog-right-paren)
-                 limit-pos t)))
-
-    ;; If a match was found but it was in a string or comment, then recurse
-    (if (and retval (prolog-in-string-or-comment))
-        (prolog-goto-next-paren limit-pos)
-      retval)
-    ))
+    (car (parse-partial-sexp (line-beginning-position)
+                             (line-end-position)))))
 
-(defun prolog-in-string-or-comment ()
-  "Check whether string, atom, or comment is under current point.
-Return:
- `txt' if the point is in a string, atom, or character code expression
- `cmt' if the point is in a comment
- nil otherwise."
-  (save-excursion
-    (let* ((start
-            (if (eq prolog-parse-mode 'beg-of-line)
-                ;; 'beg-of-line
-                (save-excursion
-                  (let (safepoint)
-                    (beginning-of-line)
-                    (setq safepoint (point))
-                    (while (and (> (point) (point-min))
-                                (progn
-                                  (forward-line -1)
-                                  (end-of-line)
-                                  (if (not (bobp))
-                                      (backward-char 1))
-                                  (looking-at "\\\\"))
-                                )
-                      (beginning-of-line)
-                      (setq safepoint (point)))
-                    safepoint))
-              ;; 'beg-of-clause
-              (prolog-clause-start)))
-           (end (point))
-           (state (if prolog-use-prolog-tokenizer-flag
-                      (prolog-tokenize start end)
-                    (if (fboundp 'syntax-ppss)
-                        (syntax-ppss)
-                      (parse-partial-sexp start end)))))
-      (cond
-       ((nth 3 state) 'txt) ; String
-       ((nth 4 state) 'cmt) ; Comment
-       (t
-        (cond
-         ((looking-at "%") 'cmt) ; Start of a comment
-         ((looking-at "/\\*") 'cmt) ; Start of a comment
-         ((looking-at "\'") 'txt) ; Start of an atom
-         ((looking-at "\"") 'txt) ; Start of a string
-         (t nil)
-         ))))
-    ))
-
-(defun prolog-find-start-of-mline-comment ()
-  "Return the start column of a /* */ comment.
-This assumes that the point is inside a comment."
-  (re-search-backward "/\\*" (point-min) t)
-  (forward-char 2)
-  (skip-chars-forward " \t")
-  (current-column))
-
-(defun prolog-insert-spaces-after-paren ()
+(defun prolog-electric--if-then-else ()
   "Insert spaces after the opening parenthesis, \"then\" (->) and \"else\" (;) branches.
 Spaces are inserted if all preceding objects on the line are
 whitespace characters, parentheses, or then/else branches."
-  (save-excursion
-    (let ((regexp (concat "(\\|" prolog-left-indent-regexp))
-          level)
-      (beginning-of-line)
-      (skip-chars-forward " \t")
-      (when (looking-at regexp)
+  (when prolog-electric-if-then-else-flag
+    (save-excursion
+      (let ((regexp (concat "(\\|" prolog-left-indent-regexp))
+            level)
+        (beginning-of-line)
+        (skip-chars-forward " \t")
         ;; Treat "( If -> " lines specially.
         ;;(setq incr (if (looking-at "(.*->")
         ;;               2
@@ -2651,12 +2095,12 @@ whitespace characters, parentheses, or then/else branches."
             (delete-region start (point)))
           (indent-to level)
           (skip-chars-forward " \t"))
-        )))
-  (when (save-excursion
-          (backward-char 2)
-          (looking-at "\\s ;\\|\\s (\\|->")) ; (looking-at "\\s \\((\\|;\\)"))
-    (skip-chars-forward " \t"))
-  )
+        ))
+    (when (save-excursion
+            (backward-char 2)
+            (looking-at "\\s ;\\|\\s (\\|->")) ; (looking-at "\\s \\((\\|;\\)"))
+      (skip-chars-forward " \t"))
+    ))
 
 ;;;; Comment filling
 
@@ -2741,7 +2185,7 @@ between them)."
   ;; fill 'txt entities?
   (when (save-excursion
           (end-of-line)
-          (equal (prolog-in-string-or-comment) 'cmt))
+          (nth 4 (syntax-ppss)))
     (let* ((bounds (prolog-comment-limits))
            (cbeg (car bounds))
            (type (nth 2 bounds))
@@ -2810,162 +2254,6 @@ In effect it sets the `fill-prefix' when inside comments and then calls
       (replace-regexp-in-string regexp newtext str nil literal))))
 \f
 ;;-------------------------------------------------------------------
-;; The tokenizer
-;;-------------------------------------------------------------------
-
-(defconst prolog-tokenize-searchkey
-  (concat "[0-9]+'"
-          "\\|"
-          "['\"]"
-          "\\|"
-          prolog-left-paren
-          "\\|"
-          prolog-right-paren
-          "\\|"
-          "%"
-          "\\|"
-          "/\\*"
-          ))
-
-(defun prolog-tokenize (beg end &optional stopcond)
-  "Tokenize a region of prolog code between BEG and END.
-STOPCOND decides the stop condition of the parsing.  Valid values
-are 'zerodepth which stops the parsing at the first right parenthesis
-where the parenthesis depth is zero, 'skipover which skips over
-the current entity (e.g. a list, a string, etc.) and nil.
-
-The function returns a list with the following information:
- 0. parenthesis depth
- 3. 'atm if END is inside an atom
-    'str if END is inside a string
-    'chr if END is in a character code expression (0'x)
-    nil otherwise
- 4. non-nil if END is inside a comment
- 5. end position (always equal to END if STOPCOND is nil)
-The rest of the elements are undefined."
-  (save-excursion
-    (let* ((end2 (1+ end))
-           oldp
-           (depth 0)
-           (quoted nil)
-           inside_cmt
-           (endpos end2)
-           skiptype ; The type of entity we'll skip over
-           )
-      (goto-char beg)
-
-      (if (and (eq stopcond 'skipover)
-               (looking-at "[^[({'\"]"))
-          (setq endpos (point))                ; Stay where we are
-        (while (and
-                (re-search-forward prolog-tokenize-searchkey end2 t)
-                (< (point) end2))
-          (progn
-            (setq oldp (point))
-            (goto-char (match-beginning 0))
-            (cond
-             ;; Atoms and strings
-             ((looking-at "'")
-              ;; Find end of atom
-              (if (re-search-forward "[^\\]'" end2 'limit)
-                  ;; Found end of atom
-                  (progn
-                    (setq oldp end2)
-                    (if (and (eq stopcond 'skipover)
-                             (not skiptype))
-                        (setq endpos (point))
-                      (setq oldp (point)))) ; Continue tokenizing
-                (setq quoted 'atm)))
-
-             ((looking-at "\"")
-              ;; Find end of string
-              (if (re-search-forward "[^\\]\"" end2 'limit)
-                  ;; Found end of string
-                  (progn
-                    (setq oldp end2)
-                    (if (and (eq stopcond 'skipover)
-                             (not skiptype))
-                        (setq endpos (point))
-                      (setq oldp (point)))) ; Continue tokenizing
-                (setq quoted 'str)))
-
-             ;; Paren stuff
-             ((looking-at prolog-left-paren)
-              (setq depth (1+ depth))
-              (setq skiptype 'paren))
-
-             ((looking-at prolog-right-paren)
-              (setq depth (1- depth))
-              (if (and
-                   (or (eq stopcond 'zerodepth)
-                       (and (eq stopcond 'skipover)
-                            (eq skiptype 'paren)))
-                   (= depth 0))
-                  (progn
-                    (setq endpos (1+ (point)))
-                    (setq oldp end2))))
-
-             ;; Comment stuff
-             ((looking-at comment-start)
-              (end-of-line)
-              ;; (if (>= (point) end2)
-              (if (>= (point) end)
-                  (progn
-                    (setq inside_cmt t)
-                    (setq oldp end2))
-                (setq oldp (point))))
-
-             ((looking-at "/\\*")
-              (if (re-search-forward "\\*/" end2 'limit)
-                  (setq oldp (point))
-                (setq inside_cmt t)
-                (setq oldp end2)))
-
-             ;; 0'char
-             ((looking-at "0'")
-              (setq oldp (1+ (match-end 0)))
-              (if (> oldp end)
-                  (setq quoted 'chr)))
-
-             ;; base'number
-             ((looking-at "[0-9]+'")
-              (goto-char (match-end 0))
-              (skip-chars-forward "0-9a-zA-Z")
-              (setq oldp (point)))
-
-
-             )
-            (goto-char oldp)
-            ))                                ; End of while
-        )
-
-      ;; Deal with multi-line comments
-      (and (prolog-inside-mline-comment end)
-           (setq inside_cmt t))
-
-      ;; Create return list
-      (list depth nil nil quoted inside_cmt endpos)
-      )))
-
-(defun prolog-inside-mline-comment (here)
-  (save-excursion
-    (goto-char here)
-    (let* ((next-close (save-excursion (search-forward "*/" nil t)))
-           (next-open  (save-excursion (search-forward "/*" nil t)))
-           (prev-open  (save-excursion (search-backward "/*" nil t)))
-           (prev-close (save-excursion (search-backward "*/" nil t)))
-           (unmatched-next-close (and next-close
-                                      (or (not next-open)
-                                          (> next-open next-close))))
-           (unmatched-prev-open  (and prev-open
-                                      (or (not prev-close)
-                                          (> prev-open prev-close))))
-           )
-      (or unmatched-next-close unmatched-prev-open)
-      )))
-
-\f
-;;-------------------------------------------------------------------
 ;; Online help
 ;;-------------------------------------------------------------------
 
@@ -3357,7 +2645,7 @@ When called with prefix argument ARG, disable zipping instead."
     (let ((state (prolog-clause-info))
           (object (prolog-in-object)))
       (if (or (equal (nth 0 state) "")
-              (equal (prolog-in-string-or-comment) 'cmt))
+              (nth 4 (syntax-ppss)))
           nil
         (if (and (eq prolog-system 'sicstus)
                  object)
@@ -3465,7 +2753,7 @@ STRING should be given if the last search was by `string-match' on STRING."
 (defun prolog-clause-start (&optional not-allow-methods)
   "Return the position at the start of the head of the current clause.
 If NOTALLOWMETHODS is non-nil then do not match on methods in
-objects (relevant only if 'prolog-system' is set to 'sicstus)."
+objects (relevant only if `prolog-system' is set to `sicstus')."
   (save-excursion
     (let ((notdone t)
           (retval (point-min)))
@@ -3501,11 +2789,8 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
                 ;; ######
                 ;; (re-search-backward "^[a-z$']" nil t))
                 (let ((case-fold-search nil))
-                  (re-search-backward
-                   ;; (format "^[%s$']" prolog-lower-case-string)
-                   ;; FIXME: Use [:lower:]
-                   (format "^\\([%s$']\\|[:?]-\\)" prolog-lower-case-string)
-                   nil t)))
+                  (re-search-backward "^\\([[:lower:]$']\\|[:?]-\\)"
+                                      nil t)))
           (let ((bal (prolog-paren-balance)))
             (cond
              ((> bal 0)
@@ -3531,7 +2816,7 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
 (defun prolog-clause-end (&optional not-allow-methods)
   "Return the position at the end of the current clause.
 If NOTALLOWMETHODS is non-nil then do not match on methods in
-objects (relevant only if 'prolog-system' is set to 'sicstus)."
+objects (relevant only if `prolog-system' is set to `sicstus')."
   (save-excursion
     (beginning-of-line) ; Necessary since we use "^...." for the search.
     (if (re-search-forward
@@ -3545,7 +2830,7 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
             "^\\(%s\\|%s\\|[^\n\'\"%%]\\)*\\.[ \t]*\\(\\|%%.*\\)$"
             prolog-quoted-atom-regexp prolog-string-regexp))
          nil t)
-        (if (and (prolog-in-string-or-comment)
+        (if (and (nth 8 (syntax-ppss))
                  (not (eobp)))
             (progn
               (forward-char)
@@ -3568,7 +2853,7 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
       ;; Retrieve the arity.
       (if (looking-at prolog-left-paren)
           (let ((endp (save-excursion
-                        (prolog-forward-list) (point))))
+                        (forward-list) (point))))
             (setq arity 1)
             (forward-char 1)            ; Skip the opening paren.
             (while (progn
@@ -3580,9 +2865,8 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
                     (forward-char 1)    ; Skip the comma.
                     )
                 ;; We found a string, list or something else we want
-                ;; to skip over. Always use prolog-tokenize,
-                ;; parse-partial-sexp does not have a 'skipover mode.
-                (goto-char (nth 5 (prolog-tokenize (point) endp 'skipover))))
+                ;; to skip over.
+                (forward-sexp 1))
               )))
       (list predname arity))))
 
@@ -3602,36 +2886,6 @@ objects (relevant only if 'prolog-system' is set to 'sicstus)."
           (match-string 1)
         nil))))
 
-(defun prolog-forward-list ()
-  "Move the point to the matching right parenthesis."
-  (interactive)
-  (if prolog-use-prolog-tokenizer-flag
-      (let ((state (prolog-tokenize (point) (point-max) 'zerodepth)))
-        (goto-char (nth 5 state)))
-    (forward-list)))
-
-;; NB: This could be done more efficiently!
-(defun prolog-backward-list ()
-  "Move the point to the matching left parenthesis."
-  (interactive)
-  (if prolog-use-prolog-tokenizer-flag
-      (let ((bal 0)
-            (paren-regexp (concat prolog-left-paren "\\|" prolog-right-paren))
-            (notdone t))
-        ;; FIXME: Doesn't this incorrectly count 0'( and 0') ?
-        (while (and notdone (re-search-backward paren-regexp nil t))
-          (cond
-           ((looking-at prolog-left-paren)
-            (if (not (prolog-in-string-or-comment))
-                (setq bal (1+ bal)))
-            (if (= bal 0)
-                (setq notdone nil)))
-           ((looking-at prolog-right-paren)
-            (if (not (prolog-in-string-or-comment))
-                (setq bal (1- bal))))
-           )))
-    (backward-list)))
-
 (defun prolog-beginning-of-clause ()
   "Move to the beginning of current clause.
 If already at the beginning of clause, move to previous clause."
@@ -3764,23 +3018,6 @@ The module name should be written manually just before the semi-colon."
       (interactive "r")
       (comment-region beg end -1))))
 
-(defun prolog-goto-comment-column (&optional nocreate)
-  "Move comments on the current line to the correct position.
-If NOCREATE is nil (or omitted) and there is no comment on the line, then
-a new comment is created."
-  (interactive)
-  (beginning-of-line)
-  (if (or (not nocreate)
-          (and
-           (re-search-forward
-            (format "^\\(\\(%s\\|%s\\|[^\n\'\"%%]\\)*\\)%% *"
-                    prolog-quoted-atom-regexp prolog-string-regexp)
-            (line-end-position) 'limit)
-           (progn
-             (goto-char (match-beginning 0))
-             (not (eq (prolog-in-string-or-comment) 'txt)))))
-      (indent-for-comment)))
-
 (defun prolog-indent-predicate ()
   "Indent the current predicate."
   (interactive)
@@ -3813,130 +3050,72 @@ a new comment is created."
     (goto-char pos)
     (goto-char (prolog-pred-start))))
 
-;; Stolen from `cc-mode.el':
-(defun prolog-electric-delete (arg)
-  "Delete preceding character or whitespace.
-If `prolog-hungry-delete-key-flag' is non-nil, then all preceding whitespace is
-consumed.  If however an ARG is supplied, or `prolog-hungry-delete-key-flag' is
-nil, or point is inside a literal then the function
-`backward-delete-char' is called."
-  (interactive "P")
-  (if (or (not prolog-hungry-delete-key-flag)
-          arg
-          (prolog-in-string-or-comment))
-      (funcall 'backward-delete-char (prefix-numeric-value arg))
-    (let ((here (point)))
-      (skip-chars-backward " \t\n")
-      (if (/= (point) here)
-          (delete-region (point) here)
-        (funcall 'backward-delete-char 1)
-        ))))
-
-;; For XEmacs compatibility (suggested by Per Mildner)
-(put 'prolog-electric-delete 'pending-delete 'supersede)
-
-(defun prolog-electric-if-then-else (arg)
-  "If `prolog-electric-if-then-else-flag' is non-nil, indent if-then-else constructs.
-Bound to the >, ; and ( keys."
-  ;; FIXME: Use post-self-insert-hook or electric-indent-mode.
-  (interactive "P")
-  (self-insert-command (prefix-numeric-value arg))
-  (if prolog-electric-if-then-else-flag (prolog-insert-spaces-after-paren)))
-
-(defun prolog-electric-colon (arg)
+(defun prolog-electric--colon ()
   "If `prolog-electric-colon-flag' is non-nil, insert the electric `:' construct.
 That is, insert space (if appropriate), `:-' and newline if colon is pressed
-at the end of a line that starts in the first column (i.e., clause
-heads)."
-  ;; FIXME: Use post-self-insert-hook.
-  (interactive "P")
-  (if (and prolog-electric-colon-flag
-          (null arg)
-          (eolp)
-          ;(not (string-match "^\\s " (thing-at-point 'line))))
-           (not (string-match "^\\(\\s \\|%\\)" (thing-at-point 'line))))
-      (progn
-        (unless (save-excursion (backward-char 1) (looking-at "\\s "))
-          (insert " "))
-       (insert ":-\n")
-        (indent-according-to-mode))
-    (self-insert-command (prefix-numeric-value arg))))
-
-(defun prolog-electric-dash (arg)
+at the end of a line that starts in the first column (i.e., clause heads)."
+  (when (and prolog-electric-colon-flag
+             (eq (char-before) ?:)
+             (not current-prefix-arg)
+             (eolp)
+             (not (memq (char-after (line-beginning-position))
+                        '(?\s ?\t ?\%))))
+    (unless (memq (char-before (1- (point))) '(?\s ?\t))
+      (save-excursion (forward-char -1) (insert " ")))
+    (insert "-\n")
+    (indent-according-to-mode)))
+
+(defun prolog-electric--dash ()
   "If `prolog-electric-dash-flag' is non-nil, insert the electric `-' construct.
 that is, insert space (if appropriate), `-->' and newline if dash is pressed
-at the end of a line that starts in the first column (i.e., DCG
-heads)."
-  ;; FIXME: Use post-self-insert-hook.
-  (interactive "P")
-  (if (and prolog-electric-dash-flag
-          (null arg)
-          (eolp)
-          ;(not (string-match "^\\s " (thing-at-point 'line))))
-           (not (string-match "^\\(\\s \\|%\\)" (thing-at-point 'line))))
-      (progn
-        (unless (save-excursion (backward-char 1) (looking-at "\\s "))
-          (insert " "))
-       (insert "-->\n")
-       (indent-according-to-mode))
-    (self-insert-command (prefix-numeric-value arg))))
-
-(defun prolog-electric-dot (arg)
-  "Insert dot and newline or a head of a new clause.
-
-If `prolog-electric-dot-flag' is nil, then simply insert dot.
-Otherwise::
+at the end of a line that starts in the first column (i.e., DCG heads)."
+  (when (and prolog-electric-dash-flag
+             (eq (char-before) ?-)
+             (not current-prefix-arg)
+             (eolp)
+             (not (memq (char-after (line-beginning-position))
+                        '(?\s ?\t ?\%))))
+    (unless (memq (char-before (1- (point))) '(?\s ?\t))
+      (save-excursion (forward-char -1) (insert " ")))
+    (insert "->\n")
+    (indent-according-to-mode)))
+
+(defun prolog-electric--dot ()
+  "Make dot electric, if `prolog-electric-dot-flag' is non-nil.
 When invoked at the end of nonempty line, insert dot and newline.
 When invoked at the end of an empty line, insert a recursive call to
 the current predicate.
 When invoked at the beginning of line, insert a head of a new clause
-of the current predicate.
-
-When called with prefix argument ARG, insert just dot."
-  ;; FIXME: Use post-self-insert-hook.
-  (interactive "P")
+of the current predicate."
   ;; Check for situations when the electricity should not be active
   (if (or (not prolog-electric-dot-flag)
-          arg
-          (prolog-in-string-or-comment)
+          (not (eq (char-before) ?\.))
+          current-prefix-arg
+          (nth 8 (syntax-ppss))
           ;; Do not be electric in a floating point number or an operator
           (not
-           (or
-            ;; (re-search-backward
-            ;; ######
-            ;; "\\(^\\|[])}a-zA-Z_!'0-9]+\\)[ \t]*\\=" nil t)))
-            (save-excursion
-              (re-search-backward
-               ;; "\\(^\\|[])}_!'0-9]+\\)[ \t]*\\=" nil t)))
-               "\\(^\\|[])}_!'0-9]+\\)[ \t]*\\="
-               nil t))
-            (save-excursion
-              (re-search-backward
-               ;; "\\(^\\|[])}a-zA-Z]+\\)[ \t]*\\=" nil t)))
-               (format "\\(^\\|[])}%s]+\\)[ \t]*\\="
-                       prolog-lower-case-string) ;FIXME: [:lower:]
-               nil t))
-              (save-excursion
-              (re-search-backward
-               ;; "\\(^\\|[])}a-zA-Z]+\\)[ \t]*\\=" nil t)))
-               (format "\\(^\\|[])}%s]+\\)[ \t]*\\="
-                       prolog-upper-case-string) ;FIXME: [:upper:]
-               nil t))
-             )
-            )
+           (save-excursion
+             (forward-char -1)
+             (skip-chars-backward " \t")
+             (let ((num (> (skip-chars-backward "0-9") 0)))
+               (or (bolp)
+                   (memq (char-syntax (char-before))
+                         (if num '(?w ?_) '(?\) ?w ?_)))))))
           ;; Do not be electric if inside a parenthesis pair.
-          (not (= (prolog-region-paren-balance (prolog-clause-start) (point))
+          (not (= (car (syntax-ppss))
                   0))
           )
-      (funcall 'self-insert-command (prefix-numeric-value arg))
+      nil ;;Not electric.
     (cond
      ;; Beginning of line
-     ((bolp)
+     ((save-excursion (forward-char -1) (bolp))
+      (delete-region (1- (point)) (point)) ;Delete the dot that called us.
       (prolog-insert-predicate-template))
      ;; At an empty line with at least one whitespace
      ((save-excursion
         (beginning-of-line)
-        (looking-at "[ \t]+$"))
+        (looking-at "[ \t]+\\.$"))
+      (delete-region (1- (point)) (point)) ;Delete the dot that called us.
       (prolog-insert-predicate-template)
       (when prolog-electric-dot-full-predicate-template
        (save-excursion
@@ -3944,47 +3123,31 @@ When called with prefix argument ARG, insert just dot."
          (insert ".\n"))))
      ;; Default
      (t
-      (insert ".\n"))
+      (insert "\n"))
      )))
 
-(defun prolog-electric-underscore ()
+(defun prolog-electric--underscore ()
   "Replace variable with an underscore.
 If `prolog-electric-underscore-flag' is non-nil and the point is
 on a variable then replace the variable with underscore and skip
-the following comma and whitespace, if any.
-If the point is not on a variable then insert underscore."
-  ;; FIXME: Use post-self-insert-hook.
-  (interactive)
-  (if prolog-electric-underscore-flag
-      (let (;start
-            (case-fold-search nil)
-            (oldp (point)))
-        ;; ######
-        ;;(skip-chars-backward "a-zA-Z_")
-        (skip-chars-backward
-         (format "%s%s_"
-                 ;; FIXME: Why not "a-zA-Z"?
-                 prolog-lower-case-string
-                 prolog-upper-case-string))
-
-        ;(setq start (point))
-        (if (and (not (prolog-in-string-or-comment))
-                 ;; ######
-                 ;; (looking-at "\\<[_A-Z][a-zA-Z_0-9]*\\>"))
-                 (looking-at (format "\\<[_%s][%s%s_0-9]*\\>"
-                                     ;; FIXME: Use [:upper:] and friends.
-                                     prolog-upper-case-string
-                                     prolog-lower-case-string
-                                     prolog-upper-case-string)))
-            (progn
-              (replace-match "_")
-              (skip-chars-forward ", \t\n"))
-          (goto-char oldp)
-          (self-insert-command 1))
-        )
-    (self-insert-command 1))
-  )
-
+the following comma and whitespace, if any."
+  (when prolog-electric-underscore-flag
+    (let ((case-fold-search nil))
+      (when (and (not (nth 8 (syntax-ppss)))
+                 (eq (char-before) ?_)
+                 (save-excursion
+                   (skip-chars-backward "[:alpha:]_")
+                   (looking-at "\\<_[_[:upper:]][[:alnum:]_]*\\_>")))
+        (replace-match "_")
+        (skip-chars-forward ", \t\n")))))
+
+(defun prolog-post-self-insert ()
+  (pcase last-command-event
+    (`?_ (prolog-electric--underscore))
+    (`?- (prolog-electric--dash))
+    (`?: (prolog-electric--colon))
+    ((or `?\( `?\; `?>) (prolog-electric--if-then-else))
+    (`?. (prolog-electric--dot))))
 
 (defun prolog-find-term (functor arity &optional prefix)
   "Go to the position at the start of the next occurrence of a term.
@@ -4188,11 +3351,12 @@ PREFIX is the prefix of the search regexp."
   (easy-menu-add prolog-edit-menu-runtime)
 
   ;; Add predicate index menu
-  (set (make-local-variable 'imenu-create-index-function)
-       'imenu-default-create-index-function)
+  (setq-local imenu-create-index-function
+              'imenu-default-create-index-function)
   ;;Milan (this has problems with object methods...)  ###### Does it? (Stefan)
-  (setq imenu-prev-index-position-function 'prolog-beginning-of-predicate)
-  (setq imenu-extract-index-name-function 'prolog-get-predspec)
+  (setq-local imenu-prev-index-position-function
+              #'prolog-beginning-of-predicate)
+  (setq-local imenu-extract-index-name-function #'prolog-get-predspec)
 
   (if (and prolog-imenu-flag
            (< (count-lines (point-min) (point-max)) prolog-imenu-max-lines))
index ce727391ce8fcc90a626230b0d00c2707b3bdf28..7a90f0bb5ee0cf7cc0380eded04c2e4d1987125b 100644 (file)
@@ -1968,8 +1968,8 @@ startup."
       (python-shell-parse-command)
       (python-shell-internal-get-process-name) nil t))))
 
-(defun python-shell-get-process ()
-  "Get inferior Python process for current buffer and return it."
+(defun python-shell-get-buffer ()
+  "Get inferior Python buffer for current buffer and return it."
   (let* ((dedicated-proc-name (python-shell-get-process-name t))
          (dedicated-proc-buffer-name (format "*%s*" dedicated-proc-name))
          (global-proc-name  (python-shell-get-process-name nil))
@@ -1977,8 +1977,12 @@ startup."
          (dedicated-running (comint-check-proc dedicated-proc-buffer-name))
          (global-running (comint-check-proc global-proc-buffer-name)))
     ;; Always prefer dedicated
-    (get-buffer-process (or (and dedicated-running dedicated-proc-buffer-name)
-                            (and global-running global-proc-buffer-name)))))
+    (or (and dedicated-running dedicated-proc-buffer-name)
+        (and global-running global-proc-buffer-name))))
+
+(defun python-shell-get-process ()
+  "Get inferior Python process for current buffer and return it."
+  (get-buffer-process (python-shell-get-buffer)))
 
 (defun python-shell-get-or-create-process ()
   "Get or create an inferior Python process for current buffer and return it."
@@ -2032,27 +2036,30 @@ there for compatibility with CEDET.")
 (define-obsolete-variable-alias
   'python-preoutput-result 'python-shell-internal-last-output "24.3")
 
-(defun python-shell-send-string (string &optional process msg)
+(defun python-shell--save-temp-file (string)
+  (let* ((temporary-file-directory
+          (if (file-remote-p default-directory)
+              (concat (file-remote-p default-directory) "/tmp")
+            temporary-file-directory))
+         (temp-file-name (make-temp-file "py"))
+         (coding-system-for-write 'utf-8))
+    (with-temp-file temp-file-name
+      (insert "# -*- coding: utf-8 -*-\n") ;Not needed for Python-3.
+      (insert string)
+      (delete-trailing-whitespace))
+    temp-file-name))
+
+(defun python-shell-send-string (string &optional process)
   "Send STRING to inferior Python PROCESS.
 When MSG is non-nil messages the first line of STRING."
   (interactive "sPython command: ")
-  (let ((process (or process (python-shell-get-or-create-process)))
-        (lines (split-string string "\n" t)))
-    (and msg (message "Sent: %s..." (nth 0 lines)))
-    (if (> (length lines) 1)
-        (let* ((temporary-file-directory
-                (if (file-remote-p default-directory)
-                    (concat (file-remote-p default-directory) "/tmp")
-                  temporary-file-directory))
-               (temp-file-name (make-temp-file "py"))
-               (file-name (or (buffer-file-name) temp-file-name)))
-          (with-temp-file temp-file-name
-            (insert string)
-            (delete-trailing-whitespace))
-          (python-shell-send-file file-name process temp-file-name))
+  (let ((process (or process (python-shell-get-or-create-process))))
+    (if (string-match ".\n+." string)   ;Multiline.
+        (let* ((temp-file-name (python-shell--save-temp-file string)))
+          (python-shell-send-file temp-file-name process temp-file-name))
       (comint-send-string process string)
-      (when (or (not (string-match "\n$" string))
-                (string-match "\n[ \t].*\n?$" string))
+      (when (or (not (string-match "\n\\'" string))
+                (string-match "\n[ \t].*\n?\\'" string))
         (comint-send-string process "\n")))))
 
 (defvar python-shell-output-filter-in-progress nil)
@@ -2091,7 +2098,7 @@ detecting a prompt at the end of the buffer."
             (substring python-shell-output-filter-buffer (match-end 0)))))
   "")
 
-(defun python-shell-send-string-no-output (string &optional process msg)
+(defun python-shell-send-string-no-output (string &optional process)
   "Send STRING to PROCESS and inhibit output.
 When MSG is non-nil messages the first line of STRING.  Return
 the output."
@@ -2102,7 +2109,7 @@ the output."
         (inhibit-quit t))
     (or
      (with-local-quit
-       (python-shell-send-string string process msg)
+       (python-shell-send-string string process)
        (while python-shell-output-filter-in-progress
          ;; `python-shell-output-filter' takes care of setting
          ;; `python-shell-output-filter-in-progress' to NIL after it
@@ -2124,7 +2131,7 @@ Returns the output.  See `python-shell-send-string-no-output'."
          ;; Makes this function compatible with the old
          ;; python-send-receive. (At least for CEDET).
          (replace-regexp-in-string "_emacs_out +" "" string)
-         (python-shell-internal-get-or-create-process) nil)))
+         (python-shell-internal-get-or-create-process))))
 
 (define-obsolete-function-alias
   'python-send-receive 'python-shell-internal-send-string "24.3")
@@ -2132,6 +2139,12 @@ Returns the output.  See `python-shell-send-string-no-output'."
 (define-obsolete-function-alias
   'python-send-string 'python-shell-internal-send-string "24.3")
 
+(defvar python--use-fake-loc nil
+  "If non-nil, use `compilation-fake-loc' to trace errors back to the buffer.
+If nil, regions of text are prepended by the corresponding number of empty
+lines and Python is told to output error messages referring to the whole
+source file.")
+
 (defun python-shell-buffer-substring (start end &optional nomain)
   "Send buffer substring from START to END formatted for shell.
 This is a wrapper over `buffer-substring' that takes care of
@@ -2144,7 +2157,8 @@ the python shell:
   3. Wraps indented regions under an \"if True:\" block so the
      interpreter evaluates them correctly."
   (let ((substring (buffer-substring-no-properties start end))
-        (fillstr (make-string (1- (line-number-at-pos start)) ?\n))
+        (fillstr (unless python--use-fake-loc
+                   (make-string (1- (line-number-at-pos start)) ?\n)))
         (toplevel-block-p (save-excursion
                             (goto-char start)
                             (or (zerop (line-number-at-pos start))
@@ -2153,9 +2167,14 @@ the python shell:
                                   (zerop (current-indentation)))))))
     (with-temp-buffer
       (python-mode)
-      (insert fillstr)
+      (if fillstr (insert fillstr))
       (insert substring)
       (goto-char (point-min))
+      (unless python--use-fake-loc
+        ;; python-shell--save-temp-file adds an extra coding line, which would
+        ;; throw off the line-counts, so let's try to compensate here.
+        (if (looking-at "[ \t]*[#\n]")
+            (delete-region (point) (line-beginning-position 2))))
       (when (not toplevel-block-p)
         (insert "if True:")
         (delete-region (point) (line-end-position)))
@@ -2179,11 +2198,26 @@ the python shell:
                  (line-number-at-pos if-name-main-start)) ?\n)))))
       (buffer-substring-no-properties (point-min) (point-max)))))
 
-(defun python-shell-send-region (start end)
+(declare-function compilation-fake-loc "compile"
+                  (marker file &optional line col))
+
+(defun python-shell-send-region (start end &optional nomain)
   "Send the region delimited by START and END to inferior Python process."
   (interactive "r")
-  (python-shell-send-string
-   (python-shell-buffer-substring start end) nil t))
+  (let* ((python--use-fake-loc
+          (or python--use-fake-loc (not buffer-file-name)))
+         (string (python-shell-buffer-substring start end nomain))
+         (process (python-shell-get-or-create-process))
+         (_ (string-match "\\`\n*\\(.*\\)" string)))
+    (message "Sent: %s..." (match-string 1 string))
+    (let* ((temp-file-name (python-shell--save-temp-file string))
+           (file-name (or (buffer-file-name) temp-file-name)))
+      (python-shell-send-file file-name process temp-file-name)
+      (unless python--use-fake-loc
+        (with-current-buffer (process-buffer process)
+          (compilation-fake-loc (copy-marker start) temp-file-name
+                                2)) ;; Not 1, because of the added coding line.
+        ))))
 
 (defun python-shell-send-buffer (&optional arg)
   "Send the entire buffer to inferior Python process.
@@ -2192,9 +2226,7 @@ by \"if __name__== '__main__':\""
   (interactive "P")
   (save-restriction
     (widen)
-    (python-shell-send-string
-     (python-shell-buffer-substring
-      (point-min) (point-max) (not arg)))))
+    (python-shell-send-region (point-min) (point-max) (not arg))))
 
 (defun python-shell-send-defun (arg)
   "Send the current defun to inferior Python process.
@@ -3544,15 +3576,22 @@ list is returned as is."
       (reverse acc))))
 
 \f
+(defun python-electric-pair-string-delimiter ()
+  (when (and electric-pair-mode
+             (memq last-command-event '(?\" ?\'))
+             (let ((count 0))
+               (while (eq (char-before (- (point) count)) last-command-event)
+                 (cl-incf count))
+               (= count 3)))
+    (save-excursion (insert (make-string 3 last-command-event)))))
+
 (defvar electric-indent-inhibit)
 
 ;;;###autoload
 (define-derived-mode python-mode prog-mode "Python"
   "Major mode for editing Python files.
 
-\\{python-mode-map}
-Entry to this mode calls the value of `python-mode-hook'
-if that value is non-nil."
+\\{python-mode-map}"
   (set (make-local-variable 'tab-width) 8)
   (set (make-local-variable 'indent-tabs-mode) nil)
 
@@ -3576,7 +3615,11 @@ if that value is non-nil."
   (set (make-local-variable 'indent-region-function) #'python-indent-region)
   ;; Because indentation is not redundant, we cannot safely reindent code.
   (setq-local electric-indent-inhibit t)
-  
+
+  ;; Add """ ... """ pairing to electric-pair-mode.
+  (add-hook 'post-self-insert-hook
+            #'python-electric-pair-string-delimiter 'append t)
+
   (set (make-local-variable 'paragraph-start) "\\s-*$")
   (set (make-local-variable 'fill-paragraph-function)
        'python-fill-paragraph)
index a29540ad3a3dfd6b7bf19f0797bcd0cf85ed343f..28c44307ff2c97e63e2212fd30cb7065c6898162 100644 (file)
@@ -39,8 +39,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
-
 (defgroup ruby nil
   "Major mode for editing Ruby code."
   :prefix "ruby-"
@@ -141,9 +139,6 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
 (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]")
   "Regexp to match symbols.")
 
-(define-abbrev-table 'ruby-mode-abbrev-table ()
-  "Abbrev table in use in Ruby mode buffers.")
-
 (defvar ruby-use-smie t)
 
 (defvar ruby-mode-map
@@ -152,12 +147,36 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
       (define-key map (kbd "M-C-b") 'ruby-backward-sexp)
       (define-key map (kbd "M-C-f") 'ruby-forward-sexp)
       (define-key map (kbd "M-C-q") 'ruby-indent-exp))
+    (when ruby-use-smie
+      (define-key map (kbd "M-C-d") 'smie-down-list))
     (define-key map (kbd "M-C-p") 'ruby-beginning-of-block)
     (define-key map (kbd "M-C-n") 'ruby-end-of-block)
     (define-key map (kbd "C-c {") 'ruby-toggle-block)
     map)
   "Keymap used in Ruby mode.")
 
+(easy-menu-define
+  ruby-mode-menu
+  ruby-mode-map
+  "Ruby Mode Menu"
+  '("Ruby"
+    ["Beginning of Block" ruby-beginning-of-block t]
+    ["End of Block" ruby-end-of-block t]
+    ["Toggle Block" ruby-toggle-block t]
+    "--"
+    ["Backward Sexp" ruby-backward-sexp
+     :visible (not ruby-use-smie)]
+    ["Backward Sexp" backward-sexp
+     :visible ruby-use-smie]
+    ["Forward Sexp" ruby-forward-sexp
+     :visible (not ruby-use-smie)]
+    ["Forward Sexp" forward-sexp
+     :visible ruby-use-smie]
+    ["Indent Sexp" ruby-indent-exp
+     :visible (not ruby-use-smie)]
+    ["Indent Sexp" prog-indent-sexp
+     :visible ruby-use-smie]))
+
 (defvar ruby-mode-syntax-table
   (let ((table (make-syntax-table)))
     (modify-syntax-entry ?\' "\"" table)
@@ -192,20 +211,28 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
 
 (defcustom ruby-indent-tabs-mode nil
   "Indentation can insert tabs in Ruby mode if this is non-nil."
-  :type 'boolean :group 'ruby)
+  :type 'boolean
+  :group 'ruby
+  :safe 'booleanp)
 
 (defcustom ruby-indent-level 2
   "Indentation of Ruby statements."
-  :type 'integer :group 'ruby)
+  :type 'integer
+  :group 'ruby
+  :safe 'integerp)
 
 (defcustom ruby-comment-column (default-value 'comment-column)
   "Indentation column of comments."
-  :type 'integer :group 'ruby)
+  :type 'integer
+  :group 'ruby
+  :safe 'integerp)
 
 (defcustom ruby-deep-arglist t
   "Deep indent lists in parenthesis when non-nil.
 Also ignores spaces after parenthesis when 'space."
-  :group 'ruby)
+  :type 'boolean
+  :group 'ruby
+  :safe 'booleanp)
 
 (defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t)
   "Deep indent lists in parenthesis when non-nil.
@@ -229,76 +256,111 @@ explicitly declared in magic comment."
   :group 'ruby)
 
 (defcustom ruby-insert-encoding-magic-comment t
-  "Insert a magic Emacs 'coding' comment upon save if this is non-nil."
+  "Insert a magic Ruby encoding comment upon save if this is non-nil.
+The encoding will be auto-detected.  The format of the encoding comment
+is customizable via `ruby-encoding-magic-comment-style'.
+
+When set to `always-utf8' an utf-8 comment will always be added,
+even if it's not required."
   :type 'boolean :group 'ruby)
 
+(defcustom ruby-encoding-magic-comment-style 'ruby
+  "The style of the magic encoding comment to use."
+  :type '(choice
+          (const :tag "Emacs Style" emacs)
+          (const :tag "Ruby Style" ruby)
+          (const :tag "Custom Style" custom))
+  :group 'ruby)
+
+(defcustom ruby-custom-encoding-magic-comment-template "# coding: %s"
+  "The encoding comment template to be used when
+`ruby-encoding-magic-comment-style' is set to `custom'."
+  :type 'string
+  :group 'ruby)
+
 (defcustom ruby-use-encoding-map t
   "Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
   :type 'boolean :group 'ruby)
 
-;; Safe file variables
-(put 'ruby-indent-tabs-mode 'safe-local-variable 'booleanp)
-(put 'ruby-indent-level 'safe-local-variable 'integerp)
-(put 'ruby-comment-column 'safe-local-variable 'integerp)
-(put 'ruby-deep-arglist 'safe-local-variable 'booleanp)
-
 ;;; SMIE support
 
 (require 'smie)
 
+;; Here's a simplified BNF grammar, for reference:
+;; http://www.cse.buffalo.edu/~regan/cse305/RubyBNF.pdf
 (defconst ruby-smie-grammar
-  ;; FIXME: Add support for Cucumber.
   (smie-prec2->grammar
-   (smie-bnf->prec2
-    '((id)
-      (insts (inst) (insts ";" insts))
-      (inst (exp) (inst "iuwu-mod" exp))
-      (exp  (exp1) (exp "," exp) (exp "=" exp) (exp "-" exp)  (exp "+" exp)
-            (id " @ " exp))
-      (exp1 (exp2) (exp2 "?" exp1 ":" exp1))
-      (exp2 ("def" insts "end")
-            ("begin" insts-rescue-insts "end")
-            ("do" insts "end")
-            ("class" insts "end") ("module" insts "end")
-            ("for" for-body "end")
-            ("[" expseq "]")
-            ("{" hashvals "}")
-            ("{" insts "}")
-            ("while" insts "end")
-            ("until" insts "end")
-            ("unless" insts "end")
-            ("if" if-body "end")
-            ("case"  cases "end"))
-      (formal-params ("opening-|" exp "|"))
-      (for-body (for-head ";" insts))
-      (for-head (id "in" exp))
-      (cases (exp "then" insts) ;; FIXME: Ruby also allows (exp ":" insts).
-             (cases "when" cases) (insts "else" insts))
-      (expseq (exp) );;(expseq "," expseq)
-      (hashvals (id "=>" exp1) (hashvals "," hashvals))
-      (insts-rescue-insts (insts)
-                          (insts-rescue-insts "rescue" insts-rescue-insts)
-                          (insts-rescue-insts "ensure" insts-rescue-insts))
-      (itheni (insts) (exp "then" insts))
-      (ielsei (itheni) (itheni "else" insts))
-      (if-body (ielsei) (if-body "elsif" if-body)))
-    '((nonassoc "in") (assoc ";") (right " @ ")
-      (assoc ",") (right "=") (assoc "-" "+"))
-    '((assoc "when"))
-    '((assoc "elsif"))
-    '((assoc "rescue" "ensure"))
-    '((assoc ",")))))
+   (smie-merge-prec2s
+    (smie-bnf->prec2
+     '((id)
+       (insts (inst) (insts ";" insts))
+       (inst (exp) (inst "iuwu-mod" exp)
+             ;; Somewhat incorrect (both can be used multiple times),
+             ;; but avoids lots of conflicts:
+             (exp "and" exp) (exp "or" exp))
+       (exp  (exp1) (exp "," exp) (exp "=" exp)
+             (id " @ " exp)
+             (exp "." id))
+       (exp1 (exp2) (exp2 "?" exp1 ":" exp1))
+       (exp2 ("def" insts "end")
+             ("begin" insts-rescue-insts "end")
+             ("do" insts "end")
+             ("class" insts "end") ("module" insts "end")
+             ("for" for-body "end")
+             ("[" expseq "]")
+             ("{" hashvals "}")
+             ("{" insts "}")
+             ("while" insts "end")
+             ("until" insts "end")
+             ("unless" insts "end")
+             ("if" if-body "end")
+             ("case"  cases "end"))
+       (formal-params ("opening-|" exp "closing-|"))
+       (for-body (for-head ";" insts))
+       (for-head (id "in" exp))
+       (cases (exp "then" insts)
+              (cases "when" cases) (insts "else" insts))
+       (expseq (exp) );;(expseq "," expseq)
+       (hashvals (id "=>" exp1) (hashvals "," hashvals))
+       (insts-rescue-insts (insts)
+                           (insts-rescue-insts "rescue" insts-rescue-insts)
+                           (insts-rescue-insts "ensure" insts-rescue-insts))
+       (itheni (insts) (exp "then" insts))
+       (ielsei (itheni) (itheni "else" insts))
+       (if-body (ielsei) (if-body "elsif" if-body)))
+     '((nonassoc "in") (assoc ";") (right " @ ")
+       (assoc ",") (right "=") (assoc "."))
+     '((assoc "when"))
+     '((assoc "elsif"))
+     '((assoc "rescue" "ensure"))
+     '((assoc ",")))
+
+    (smie-precs->prec2
+     '((right "=")
+       (right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^="
+              "<<=" ">>=" "&&=" "||=")
+       (left ".." "...")
+       (left "+" "-")
+       (left "*" "/" "%" "**")
+       (left "&&" "||")
+       (left "^" "&" "|")
+       (nonassoc "<=>")
+       (nonassoc ">" ">=" "<" "<=")
+       (nonassoc "==" "===" "!=")
+       (nonassoc "=~" "!~")
+       (left "<<" ">>"))))))
 
 (defun ruby-smie--bosp ()
   (save-excursion (skip-chars-backward " \t")
-                  (or (bolp) (eq (char-before) ?\;))))
+                  (or (bolp) (memq (char-before) '(?\; ?=)))))
 
 (defun ruby-smie--implicit-semi-p ()
   (save-excursion
     (skip-chars-backward " \t")
     (not (or (bolp)
              (and (memq (char-before)
-                        '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\))
+                        '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\ ?& ?> ?< ?%
+                          ?~ ?^))
                   ;; Make sure it's not the end of a regexp.
                   (not (eq (car (syntax-after (1- (point)))) 7)))
              (and (eq (char-before) ?\?)
@@ -306,9 +368,12 @@ explicitly declared in magic comment."
              (and (eq (char-before) ?=)
                   (string-match "\\`\\s." (save-excursion
                                             (ruby-smie--backward-token))))
+             (and (eq (char-before) ?|)
+                  (member (save-excursion (ruby-smie--backward-token))
+                          '("|" "||")))
              (and (eq (car (syntax-after (1- (point)))) 2)
-                  (equal (save-excursion (ruby-smie--backward-token))
-                         "iuwu-mod"))
+                  (member (save-excursion (ruby-smie--backward-token))
+                          '("iuwu-mod" "and" "or")))
              (save-excursion
                (forward-comment 1)
                (eq (char-after) ?.))))))
@@ -325,28 +390,44 @@ explicitly declared in magic comment."
     (or (eq ?\{ (char-before))
         (looking-back "\\_<do" (- (point) 2)))))
 
+(defun ruby-smie--closing-pipe-p ()
+  (save-excursion
+    (if (eq ?| (char-before)) (forward-char -1))
+    (and (re-search-backward "|" (line-beginning-position) t)
+         (ruby-smie--opening-pipe-p))))
+
 (defun ruby-smie--args-separator-p (pos)
   (and
+   (< pos (line-end-position))
    (or (eq (char-syntax (preceding-char)) '?w)
+       ;; FIXME: Check that the preceding token is not a keyword.
+       ;; This isn't very important most of the time, though.
        (and (memq (preceding-char) '(?! ??))
             (eq (char-syntax (char-before (1- (point)))) '?w)))
-   (< pos (point-max))
-   (memq (char-syntax (char-after pos)) '(?w ?\"))))
-
-(defun ruby-smie--forward-id ()
-  (when (and (not (eobp))
-             (eq ?w (char-syntax (char-after))))
-    (let ((tok (smie-default-forward-token)))
-      (when (eq ?. (char-after))
-        (forward-char 1)
-        (setq tok (concat tok "." (ruby-smie--forward-id))))
-      tok)))
+   (save-excursion
+     (goto-char pos)
+     (or (and (eq (char-syntax (char-after)) ?w)
+              (not (looking-at (regexp-opt '("unless" "if" "while" "until" "or"
+                                             "else" "elsif" "do" "end" "and")
+                                           'symbols))))
+         (memq (syntax-after pos) '(7 15))
+         (looking-at "[([]\\|[-+!~:]\\sw")))))
+
+(defun ruby-smie--at-dot-call ()
+  (and (eq ?w (char-syntax (following-char)))
+       (eq (char-before) ?.)
+       (not (eq (char-before (1- (point))) ?.))))
 
 (defun ruby-smie--forward-token ()
   (let ((pos (point)))
     (skip-chars-forward " \t")
     (cond
-     ((looking-at "\\s\"") "")          ;A heredoc or a string.
+     ((looking-at "\\s\"") ;A heredoc or a string.
+      (if (not (looking-at "\n"))
+          ""
+        ;; Tokenize the whole heredoc as semicolon.
+        (goto-char (scan-sexps (point) 1))
+        ";"))
      ((and (looking-at "[\n#]")
            (ruby-smie--implicit-semi-p)) ;Only add implicit ; when needed.
       (if (eolp) (forward-char 1) (forward-comment 1))
@@ -361,13 +442,21 @@ explicitly declared in magic comment."
                (ruby-smie--args-separator-p (prog1 (point) (goto-char pos)))))
         " @ ")
        (t
-        (let ((tok (smie-default-forward-token)))
+        (let ((dot (ruby-smie--at-dot-call))
+              (tok (smie-default-forward-token)))
+          (when dot
+            (setq tok (concat "." tok)))
           (cond
            ((member tok '("unless" "if" "while" "until"))
             (if (save-excursion (forward-word -1) (ruby-smie--bosp))
                 tok "iuwu-mod"))
-           ((equal tok "|")
-            (if (ruby-smie--opening-pipe-p) "opening-|" tok))
+           ((string-match-p "\\`|[*&]?\\'" tok)
+            (forward-char (- 1 (length tok)))
+            (setq tok "|")
+            (cond
+             ((ruby-smie--opening-pipe-p) "opening-|")
+             ((ruby-smie--closing-pipe-p) "closing-|")
+             (t tok)))
            ((and (equal tok "") (looking-at "\\\\\n"))
             (goto-char (match-end 0)) (ruby-smie--forward-token))
            ((equal tok "do")
@@ -377,25 +466,18 @@ explicitly declared in magic comment."
                  (line-end-position))
               (ruby-smie--forward-token)) ;Fully redundant.
              (t ";")))
-           ((equal tok ".") (concat tok (ruby-smie--forward-id)))
            (t tok)))))))))
 
-(defun ruby-smie--backward-id ()
-  (when (and (not (bobp))
-             (eq ?w (char-syntax (char-before))))
-    (let ((tok (smie-default-backward-token)))
-      (when (eq ?. (char-before))
-        (forward-char -1)
-        (setq tok (concat (ruby-smie--backward-id) "." tok)))
-      tok)))
-
 (defun ruby-smie--backward-token ()
   (let ((pos (point)))
     (forward-comment (- (point)))
     (cond
      ((and (> pos (line-end-position)) (ruby-smie--implicit-semi-p))
       (skip-chars-forward " \t") ";")
-     ((and (bolp) (not (bobp))) "")         ;Presumably a heredoc.
+     ((and (bolp) (not (bobp)))         ;Presumably a heredoc.
+      ;; Tokenize the whole heredoc as semicolon.
+      (goto-char (scan-sexps (point) -1))
+      ";")
      ((and (> pos (point)) (not (bolp))
            (ruby-smie--args-separator-p pos))
       ;; We have "ID SPC ID", which is a method call, but it binds less tightly
@@ -403,9 +485,9 @@ explicitly declared in magic comment."
       ;; In some textbooks, "e1 @ e2" is used to mean "call e1 with arg e2".
       " @ ")
      (t
-      (let ((tok (smie-default-backward-token)))
-        (when (eq ?. (char-before))
-          (forward-char -1)
+      (let ((tok (smie-default-backward-token))
+            (dot (ruby-smie--at-dot-call)))
+        (when dot
           (setq tok (concat "." tok)))
         (when (and (eq ?: (char-before)) (string-match "\\`\\s." tok))
           (forward-char -1) (setq tok (concat ":" tok))) ;; bug#15208.
@@ -414,7 +496,13 @@ explicitly declared in magic comment."
           (if (ruby-smie--bosp)
               tok "iuwu-mod"))
          ((equal tok "|")
-          (if (ruby-smie--opening-pipe-p) "opening-|" tok))
+          (cond
+           ((ruby-smie--opening-pipe-p) "opening-|")
+           ((ruby-smie--closing-pipe-p) "closing-|")
+           (t tok)))
+         ((string-match-p "\\`|[*&]\\'" tok)
+          (forward-char 1)
+          (substring tok 1))
          ((and (equal tok "") (eq ?\\ (char-before)) (looking-at "\n"))
           (forward-char -1) (ruby-smie--backward-token))
          ((equal tok "do")
@@ -425,13 +513,13 @@ explicitly declared in magic comment."
                (line-end-position))
             (ruby-smie--backward-token)) ;Fully redundant.
            (t ";")))
-         ;; FIXME: We shouldn't merge the dot with preceding token here
-         ;; either, but not doing that breaks indentation of hanging
-         ;; method calls with dot on the first line.
-         ((equal tok ".")
-          (concat (ruby-smie--backward-id) tok))
          (t tok)))))))
 
+(defun ruby-smie--indent-to-stmt ()
+  (save-excursion
+    (smie-backward-sexp ";")
+    (cons 'column (smie-indent-virtual))))
+
 (defun ruby-smie-rules (kind token)
   (pcase (cons kind token)
     (`(:elem . basic) ruby-indent-level)
@@ -439,25 +527,47 @@ explicitly declared in magic comment."
     ;; should be aligned with the first.
     (`(:elem . args) (if (looking-at "\\s\"") 0))
     ;; (`(:after . ",") (smie-rule-separator kind))
-    (`(:after . ";")
-     (if (smie-rule-parent-p "def" "begin" "do" "class" "module" "for"
-                             "while" "until" "unless"
-                             "if" "then" "elsif" "else" "when"
-                             "rescue" "ensure")
-         (smie-rule-parent ruby-indent-level)
-       ;; For (invalid) code between switch and case.
-       ;; (if (smie-parent-p "switch") 4)
-       0))
+    (`(:before . ";")
+     (cond
+      ((smie-rule-parent-p "def" "begin" "do" "class" "module" "for"
+                           "while" "until" "unless"
+                           "if" "then" "elsif" "else" "when"
+                           "rescue" "ensure" "{")
+       (smie-rule-parent ruby-indent-level))
+      ;; For (invalid) code between switch and case.
+      ;; (if (smie-parent-p "switch") 4)
+      ))
     (`(:before . ,(or `"(" `"[" `"{"))
-     ;; Treat purely syntactic block-constructs as being part of their parent,
-     ;; when the opening statement is hanging.
-     (when (smie-rule-hanging-p)
-       (smie-backward-sexp 'halfsexp) (smie-indent-virtual)))
-    (`(:after . ,(or "=" "iuwu-mod")) 2)
-    (`(:before . "do") (smie-rule-parent))
+     (cond
+      ((and (equal token "{")
+            (not (smie-rule-prev-p "(" "{" "[" "," "=>" "=" "return" ";"))
+            (save-excursion
+              (forward-comment -1)
+              (not (eq (preceding-char) ?:))))
+       ;; Curly block opener.
+       (ruby-smie--indent-to-stmt))
+      ((smie-rule-hanging-p)
+       ;; Treat purely syntactic block-constructs as being part of their parent,
+       ;; when the opening statement is hanging.
+       (let ((state (smie-backward-sexp 'halfsexp)))
+         (when (eq t (car state)) (goto-char (cadr state))))
+       (cons 'column  (smie-indent-virtual)))))
+    (`(:after . " @ ") (smie-rule-parent))
+    (`(:before . "do") (ruby-smie--indent-to-stmt))
+    (`(,(or :before :after) . ".")
+     (unless (smie-rule-parent-p ".")
+       (smie-rule-parent ruby-indent-level)))
     (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
     (`(:before . ,(or `"when"))
      (if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level
+    (`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&"
+                     "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
+                     "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
+                     "<<=" ">>=" "&&=" "||=" "and" "or"))
+     (if (smie-rule-parent-p ";" nil) ruby-indent-level))
+    (`(:before . "begin")
+     (unless (save-excursion (skip-chars-backward " \t") (bolp))
+       (smie-rule-parent)))
     ))
 
 (defun ruby-imenu-create-index-in-block (prefix beg end)
@@ -511,62 +621,77 @@ explicitly declared in magic comment."
 
 (defun ruby-mode-variables ()
   "Set up initial buffer-local variables for Ruby mode."
-  (set-syntax-table ruby-mode-syntax-table)
-  (setq local-abbrev-table ruby-mode-abbrev-table)
   (setq indent-tabs-mode ruby-indent-tabs-mode)
   (if ruby-use-smie
       (smie-setup ruby-smie-grammar #'ruby-smie-rules
                   :forward-token  #'ruby-smie--forward-token
                   :backward-token #'ruby-smie--backward-token)
-    (set (make-local-variable 'indent-line-function) 'ruby-indent-line))
-  (set (make-local-variable 'require-final-newline) t)
-  (set (make-local-variable 'comment-start) "# ")
-  (set (make-local-variable 'comment-end) "")
-  (set (make-local-variable 'comment-column) ruby-comment-column)
-  (set (make-local-variable 'comment-start-skip) "#+ *")
-  (set (make-local-variable 'parse-sexp-ignore-comments) t)
-  (set (make-local-variable 'parse-sexp-lookup-properties) t)
-  (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
-  (set (make-local-variable 'paragraph-separate) paragraph-start)
-  (set (make-local-variable 'paragraph-ignore-fill-prefix) t))
+    (setq-local indent-line-function 'ruby-indent-line))
+  (setq-local require-final-newline t)
+  (setq-local comment-start "# ")
+  (setq-local comment-end "")
+  (setq-local comment-column ruby-comment-column)
+  (setq-local comment-start-skip "#+ *")
+  (setq-local parse-sexp-ignore-comments t)
+  (setq-local parse-sexp-lookup-properties t)
+  (setq-local paragraph-start (concat "$\\|" page-delimiter))
+  (setq-local paragraph-separate paragraph-start)
+  (setq-local paragraph-ignore-fill-prefix t))
+
+(defun ruby--insert-coding-comment (encoding)
+  "Insert a magic coding comment for ENCODING.
+The style of the comment is controlled by `ruby-encoding-magic-comment-style'."
+  (let ((encoding-magic-comment-template
+         (pcase ruby-encoding-magic-comment-style
+           (`ruby "# coding: %s")
+           (`emacs "# -*- coding: %s -*-")
+           (`custom
+            ruby-custom-encoding-magic-comment-template))))
+    (insert
+     (format encoding-magic-comment-template encoding)
+     "\n")))
+
+(defun ruby--detect-encoding ()
+  (if (eq ruby-insert-encoding-magic-comment 'always-utf8)
+      "utf-8"
+    (let ((coding-system
+           (or save-buffer-coding-system
+               buffer-file-coding-system)))
+      (if coding-system
+          (setq coding-system
+                (or (coding-system-get coding-system 'mime-charset)
+                    (coding-system-change-eol-conversion coding-system nil))))
+      (if coding-system
+          (symbol-name
+           (if ruby-use-encoding-map
+               (let ((elt (assq coding-system ruby-encoding-map)))
+                 (if elt (cdr elt) coding-system))
+             coding-system))
+        "ascii-8bit"))))
+
+(defun ruby--encoding-comment-required-p ()
+  (or (eq ruby-insert-encoding-magic-comment 'always-utf8)
+      (re-search-forward "[^\0-\177]" nil t)))
 
 (defun ruby-mode-set-encoding ()
   "Insert a magic comment header with the proper encoding if necessary."
   (save-excursion
     (widen)
     (goto-char (point-min))
-    (when (re-search-forward "[^\0-\177]" nil t)
+    (when (ruby--encoding-comment-required-p)
       (goto-char (point-min))
-      (let ((coding-system
-             (or save-buffer-coding-system
-                 buffer-file-coding-system)))
-        (if coding-system
-            (setq coding-system
-                  (or (coding-system-get coding-system 'mime-charset)
-                      (coding-system-change-eol-conversion coding-system nil))))
-        (setq coding-system
-              (if coding-system
-                  (symbol-name
-                   (if ruby-use-encoding-map
-                       (let ((elt (assq coding-system ruby-encoding-map)))
-                         (if elt (cdr elt) coding-system))
-                     coding-system))
-                "ascii-8bit"))
+      (let ((coding-system (ruby--detect-encoding)))
         (when coding-system
           (if (looking-at "^#!") (beginning-of-line 2))
-          (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)")
+          (cond ((looking-at "\\s *#\\s *.*\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)")
+                 ;; update existing encoding comment if necessary
                  (unless (string= (match-string 2) coding-system)
                    (goto-char (match-beginning 2))
                    (delete-region (point) (match-end 2))
-                   (and (looking-at "-\*-")
-                        (let ((n (skip-chars-backward " ")))
-                          (cond ((= n 0) (insert "  ") (backward-char))
-                                ((= n -1) (insert " "))
-                                ((forward-char)))))
                    (insert coding-system)))
                 ((looking-at "\\s *#.*coding\\s *[:=]"))
                 (t (when ruby-insert-encoding-magic-comment
-                     (insert "# -*- coding: " coding-system " -*-\n"))))
+                     (ruby--insert-coding-comment coding-system))))
           (when (buffer-modified-p)
             (basic-save-buffer-1)))))))
 
@@ -586,7 +711,7 @@ explicitly declared in magic comment."
   "Indent the current line to COLUMN."
   (when column
     (let (shift top beg)
-      (and (< column 0) (error "invalid nest"))
+      (and (< column 0) (error "Invalid nesting"))
       (setq shift (current-column))
       (beginning-of-line)
       (setq beg (point))
@@ -677,7 +802,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
       (forward-char -1))
     (cond ((zerop n))
           (no-error nil)
-          ((error "unterminated string")))))
+          ((error "Unterminated string")))))
 
 (defun ruby-deep-indent-paren-p (c)
   "TODO: document."
@@ -703,7 +828,8 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
        ((looking-at "[\"`]")            ;skip string
         (cond
          ((and (not (eobp))
-               (ruby-forward-string (buffer-substring (point) (1+ (point))) end t t))
+               (ruby-forward-string (buffer-substring (point) (1+ (point)))
+                                    end t t))
           nil)
          (t
           (setq in-string (point))
@@ -888,7 +1014,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
           (setq in-string (match-end 0))
           (goto-char ruby-indent-point)))
        (t
-        (error (format "bad string %s"
+        (error (format "Bad string %s"
                        (buffer-substring (point) pnt)
                        ))))))
   (list in-string nest depth pcol))
@@ -963,7 +1089,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
                (setq indent (current-column)))))
        ((and (nth 2 state) (> (nth 2 state) 0)) ; in nest
         (if (null (cdr (nth 1 state)))
-            (error "invalid nest"))
+            (error "Invalid nesting"))
         (goto-char (cdr (nth 1 state)))
         (forward-word -1)               ; skip back a keyword
         (setq begin (point))
@@ -1010,7 +1136,8 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
             (while (and (re-search-forward "#" pos t)
                         (setq end (1- (point)))
                         (or (ruby-special-char-p end)
-                            (and (setq state (ruby-parse-region parse-start end))
+                            (and (setq state (ruby-parse-region
+                                              parse-start end))
                                  (nth 0 state))))
               (setq end nil))
             (goto-char (or end pos))
@@ -1021,7 +1148,8 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
           (and
            (or (and (looking-at ruby-symbol-re)
                     (skip-chars-backward ruby-symbol-chars)
-                    (looking-at (concat "\\<\\(" ruby-block-hanging-re "\\)\\>"))
+                    (looking-at (concat "\\<\\(" ruby-block-hanging-re
+                                        "\\)\\>"))
                     (not (eq (point) (nth 3 state)))
                     (save-excursion
                       (goto-char (match-end 0))
@@ -1065,7 +1193,8 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'."
                  (cond
                   ((and
                     (null op-end)
-                    (not (looking-at (concat "\\<\\(" ruby-block-hanging-re "\\)\\>")))
+                    (not (looking-at (concat "\\<\\(" ruby-block-hanging-re
+                                             "\\)\\>")))
                     (eq (ruby-deep-indent-paren-p t) 'space)
                     (not (bobp)))
                    (widen)
@@ -1202,7 +1331,8 @@ With ARG, do it many times.  Negative ARG means move backward."
                      (skip-chars-forward ",.:;|&^~=!?\\+\\-\\*")
                      (looking-at "\\s("))
                    (goto-char (scan-sexps (point) 1)))
-                  ((and (looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))
+                  ((and (looking-at (concat "\\<\\(" ruby-block-beg-re
+                                            "\\)\\>"))
                         (not (eq (char-before (point)) ?.))
                         (not (eq (char-before (point)) ?:)))
                    (ruby-end-of-block)
@@ -1219,7 +1349,8 @@ With ARG, do it many times.  Negative ARG means move backward."
                          (progn
                            (setq expr (or expr (ruby-expr-beg)
                                           (looking-at "%\\sw?\\Sw\\|[\"'`/]")))
-                           (nth 1 (setq state (apply 'ruby-parse-partial nil state))))
+                           (nth 1 (setq state (apply #'ruby-parse-partial
+                                                     nil state))))
                        (setq expr t)
                        (skip-chars-forward "<"))
                      (not expr))))
@@ -1243,10 +1374,11 @@ With ARG, do it many times.  Negative ARG means move forward."
             (forward-char -1)
             (cond ((looking-at "\\s)")
                    (goto-char (scan-sexps (1+ (point)) -1))
-                   (case (char-before)
-                     (?% (forward-char -1))
-                     ((?q ?Q ?w ?W ?r ?x)
-                      (if (eq (char-before (1- (point))) ?%) (forward-char -2))))
+                   (pcase (char-before)
+                     (`?% (forward-char -1))
+                     ((or `?q `?Q `?w `?W `?r `?x)
+                      (if (eq (char-before (1- (point))) ?%)
+                          (forward-char -2))))
                    nil)
                   ((looking-at "\\s\"\\|\\\\\\S_")
                    (let ((c (char-to-string (char-before (match-end 0)))))
@@ -1260,13 +1392,14 @@ With ARG, do it many times.  Negative ARG means move forward."
                   (t
                    (forward-char 1)
                    (while (progn (forward-word -1)
-                                 (case (char-before)
-                                   (?_ t)
-                                   (?. (forward-char -1) t)
-                                   ((?$ ?@)
+                                 (pcase (char-before)
+                                   (`?_ t)
+                                   (`?. (forward-char -1) t)
+                                   ((or `?$ `?@)
                                     (forward-char -1)
-                                    (and (eq (char-before) (char-after)) (forward-char -1)))
-                                   (?:
+                                    (and (eq (char-before) (char-after))
+                                         (forward-char -1)))
+                                   (`?:
                                     (forward-char -1)
                                     (eq (char-before) :)))))
                    (if (looking-at ruby-block-end-re)
@@ -1426,7 +1559,8 @@ See `add-log-current-defun-function'."
       (insert "}")
       (goto-char orig)
       (delete-char 2)
-      (insert "{")
+      ;; Maybe this should be customizable, let's see if anyone asks.
+      (insert "{ ")
       (setq beg-marker (point-marker))
       (when (looking-at "\\s +|")
         (delete-char (- (match-end 0) (match-beginning 0) 1))
@@ -1456,8 +1590,9 @@ If the result is do-end block, it will always be multiline."
   (let ((start (point)) beg end)
     (end-of-line)
     (unless
-        (if (and (re-search-backward "\\({\\)\\|\\_<do\\(\\s \\|$\\||\\)")
+        (if (and (re-search-backward "\\(?:[^#]\\)\\({\\)\\|\\(\\_<do\\_>\\)")
                  (progn
+                   (goto-char (or (match-beginning 1) (match-beginning 2)))
                    (setq beg (point))
                    (save-match-data (ruby-forward-sexp))
                    (setq end (point))
@@ -1467,349 +1602,182 @@ If the result is do-end block, it will always be multiline."
               (ruby-do-end-to-brace beg end)))
       (goto-char start))))
 
-(declare-function ruby-syntax-propertize-heredoc "ruby-mode" (limit))
-(declare-function ruby-syntax-enclosing-percent-literal "ruby-mode" (limit))
-(declare-function ruby-syntax-propertize-percent-literal "ruby-mode" (limit))
-;; Unusual code layout confuses the byte-compiler.
-(declare-function ruby-syntax-propertize-expansion "ruby-mode" ())
-(declare-function ruby-syntax-expansion-allowed-p "ruby-mode" (parse-state))
-(declare-function ruby-syntax-propertize-function "ruby-mode" (start end))
-
-(if (eval-when-compile (fboundp #'syntax-propertize-rules))
-    ;; New code that works independently from font-lock.
-    (progn
-      (eval-and-compile
-        (defconst ruby-percent-literal-beg-re
-          "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)"
-          "Regexp to match the beginning of percent literal.")
-
-        (defconst ruby-syntax-methods-before-regexp
-          '("gsub" "gsub!" "sub" "sub!" "scan" "split" "split!" "index" "match"
-            "assert_match" "Given" "Then" "When")
-          "Methods that can take regexp as the first argument.
+(eval-and-compile
+  (defconst ruby-percent-literal-beg-re
+    "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)"
+    "Regexp to match the beginning of percent literal.")
+
+  (defconst ruby-syntax-methods-before-regexp
+    '("gsub" "gsub!" "sub" "sub!" "scan" "split" "split!" "index" "match"
+      "assert_match" "Given" "Then" "When")
+    "Methods that can take regexp as the first argument.
 It will be properly highlighted even when the call omits parens.")
 
-        (defvar ruby-syntax-before-regexp-re
-          (concat
-           ;; Special tokens that can't be followed by a division operator.
-           "\\(^\\|[[=(,~;<>]"
-           ;; Distinguish ternary operator tokens.
-           ;; FIXME: They don't really have to be separated with spaces.
-           "\\|[?:] "
-           ;; Control flow keywords and operators following bol or whitespace.
-           "\\|\\(?:^\\|\\s \\)"
-           (regexp-opt '("if" "elsif" "unless" "while" "until" "when" "and"
-                         "or" "not" "&&" "||"))
-           ;; Method name from the list.
-           "\\|\\_<"
-           (regexp-opt ruby-syntax-methods-before-regexp)
-           "\\)\\s *")
-          "Regexp to match text that can be followed by a regular expression."))
-
-      (defun ruby-syntax-propertize-function (start end)
-        "Syntactic keywords for Ruby mode.  See `syntax-propertize-function'."
-        (let (case-fold-search)
-          (goto-char start)
-          (remove-text-properties start end '(ruby-expansion-match-data))
-          (ruby-syntax-propertize-heredoc end)
-          (ruby-syntax-enclosing-percent-literal end)
-          (funcall
-           (syntax-propertize-rules
-            ;; $' $" $` .... are variables.
-            ;; ?' ?" ?` are character literals (one-char strings in 1.9+).
-            ("\\([?$]\\)[#\"'`]"
-             (1 (unless (save-excursion
-                          ;; Not within a string.
-                          (nth 3 (syntax-ppss (match-beginning 0))))
-                  (string-to-syntax "\\"))))
-            ;; Regular expressions.  Start with matching unescaped slash.
-            ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)"
-             (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1)))))
-                  (when (or
-                         ;; Beginning of a regexp.
-                         (and (null (nth 8 state))
-                              (save-excursion
-                                (forward-char -1)
-                                (looking-back ruby-syntax-before-regexp-re
-                                              (point-at-bol))))
-                         ;; End of regexp.  We don't match the whole
-                         ;; regexp at once because it can have
-                         ;; string interpolation inside, or span
-                         ;; several lines.
-                         (eq ?/ (nth 3 state)))
-                    (string-to-syntax "\"/")))))
-            ;; Expression expansions in strings.  We're handling them
-            ;; here, so that the regexp rule never matches inside them.
-            (ruby-expression-expansion-re
-             (0 (ignore (ruby-syntax-propertize-expansion))))
-            ("^=en\\(d\\)\\_>" (1 "!"))
-            ("^\\(=\\)begin\\_>" (1 "!"))
-            ;; Handle here documents.
-            ((concat ruby-here-doc-beg-re ".*\\(\n\\)")
-             (7 (unless (or (nth 8 (save-excursion
-                                     (syntax-ppss (match-beginning 0))))
-                            (ruby-singleton-class-p (match-beginning 0)))
-                  (put-text-property (match-beginning 7) (match-end 7)
-                                     'syntax-table (string-to-syntax "\""))
-                  (ruby-syntax-propertize-heredoc end))))
-            ;; Handle percent literals: %w(), %q{}, etc.
-            ((concat "\\(?:^\\|[[ \t\n<+(,=]\\)" ruby-percent-literal-beg-re)
-             (1 (prog1 "|" (ruby-syntax-propertize-percent-literal end)))))
-           (point) end)))
-
-      (defun ruby-syntax-propertize-heredoc (limit)
-        (let ((ppss (syntax-ppss))
-              (res '()))
-          (when (eq ?\n (nth 3 ppss))
-            (save-excursion
-              (goto-char (nth 8 ppss))
-              (beginning-of-line)
-              (while (re-search-forward ruby-here-doc-beg-re
-                                        (line-end-position) t)
-                (unless (ruby-singleton-class-p (match-beginning 0))
-                  (push (concat (ruby-here-doc-end-match) "\n") res))))
-            (save-excursion
-              ;; With multiple openers on the same line, we don't know in which
-              ;; part `start' is, so we have to go back to the beginning.
-              (when (cdr res)
-                (goto-char (nth 8 ppss))
-                (setq res (nreverse res)))
-              (while (and res (re-search-forward (pop res) limit 'move))
-                (if (null res)
-                    (put-text-property (1- (point)) (point)
-                                       'syntax-table (string-to-syntax "\""))))
-              ;; End up at bol following the heredoc openers.
-              ;; Propertize expression expansions from this point forward.
-              ))))
-
-      (defun ruby-syntax-enclosing-percent-literal (limit)
-        (let ((state (syntax-ppss))
-              (start (point)))
-          ;; When already inside percent literal, re-propertize it.
-          (when (eq t (nth 3 state))
-            (goto-char (nth 8 state))
-            (when (looking-at ruby-percent-literal-beg-re)
-              (ruby-syntax-propertize-percent-literal limit))
-            (when (< (point) start) (goto-char start)))))
-
-      (defun ruby-syntax-propertize-percent-literal (limit)
-        (goto-char (match-beginning 2))
-        ;; Not inside a simple string or comment.
-        (when (eq t (nth 3 (syntax-ppss)))
-          (let* ((op (char-after))
-                 (ops (char-to-string op))
-                 (cl (or (cdr (aref (syntax-table) op))
-                         (cdr (assoc op '((?< . ?>))))))
-                 parse-sexp-lookup-properties)
-            (save-excursion
-              (condition-case nil
-                  (progn
-                    (if cl              ; Paired delimiters.
-                        ;; Delimiter pairs of the same kind can be nested
-                        ;; inside the literal, as long as they are balanced.
-                        ;; Create syntax table that ignores other characters.
-                        (with-syntax-table (make-char-table 'syntax-table nil)
-                          (modify-syntax-entry op (concat "(" (char-to-string cl)))
-                          (modify-syntax-entry cl (concat ")" ops))
-                          (modify-syntax-entry ?\\ "\\")
-                          (save-restriction
-                            (narrow-to-region (point) limit)
-                            (forward-list))) ; skip to the paired character
-                      ;; Single character delimiter.
-                      (re-search-forward (concat "[^\\]\\(?:\\\\\\\\\\)*"
-                                                 (regexp-quote ops)) limit nil))
-                    ;; Found the closing delimiter.
-                    (put-text-property (1- (point)) (point) 'syntax-table
-                                       (string-to-syntax "|")))
-                ;; Unclosed literal, do nothing.
-                ((scan-error search-failed)))))))
-
-      (defun ruby-syntax-propertize-expansion ()
-        ;; Save the match data to a text property, for font-locking later.
-        ;; Set the syntax of all double quotes and backticks to punctuation.
-        (let* ((beg (match-beginning 2))
-               (end (match-end 2))
-               (state (and beg (save-excursion (syntax-ppss beg)))))
-          (when (ruby-syntax-expansion-allowed-p state)
-            (put-text-property beg (1+ beg) 'ruby-expansion-match-data
-                               (match-data))
-            (goto-char beg)
-            (while (re-search-forward "[\"`]" end 'move)
-              (put-text-property (match-beginning 0) (match-end 0)
-                                 'syntax-table (string-to-syntax "."))))))
-
-      (defun ruby-syntax-expansion-allowed-p (parse-state)
-        "Return non-nil if expression expansion is allowed."
-        (let ((term (nth 3 parse-state)))
-          (cond
-           ((memq term '(?\" ?` ?\n ?/)))
-           ((eq term t)
-            (save-match-data
-              (save-excursion
-                (goto-char (nth 8 parse-state))
-                (looking-at "%\\(?:[QWrxI]\\|\\W\\)")))))))
-
-      (defun ruby-syntax-propertize-expansions (start end)
-        (save-excursion
-          (goto-char start)
-          (while (re-search-forward ruby-expression-expansion-re end 'move)
-            (ruby-syntax-propertize-expansion))))
-      )
-
-  ;; For Emacsen where syntax-propertize-rules is not (yet) available,
-  ;; fallback on the old font-lock-syntactic-keywords stuff.
-
-  (defconst ruby-here-doc-end-re
-    "^\\([ \t]+\\)?\\(.*\\)\\(\n\\)"
-    "Regexp to match the end of heredocs.
-
-This will actually match any line with one or more characters.
-It's useful in that it divides up the match string so that
-`ruby-here-doc-beg-match' can search for the beginning of the heredoc.")
-
-  (defun ruby-here-doc-beg-match ()
-    "Return a regexp to find the beginning of a heredoc.
-
-This should only be called after matching against `ruby-here-doc-end-re'."
-    (let ((contents (concat
-                     (regexp-quote (concat (match-string 2) (match-string 3)))
-                     (if (string= (match-string 3) "_") "\\B" "\\b"))))
-      (concat "<<"
-              (let ((match (match-string 1)))
-                (if (and match (> (length match) 0))
-                    (concat "\\(?:-\\([\"']?\\)\\|\\([\"']\\)"
-                            (match-string 1) "\\)"
-                            contents "\\(\\1\\|\\2\\)")
-                  (concat "-?\\([\"']\\|\\)" contents "\\1"))))))
-
-  (defconst ruby-font-lock-syntactic-keywords
-    `(
-    ;; the last $', $", $` in the respective string is not variable
-    ;; the last ?', ?", ?` in the respective string is not ascii code
-    ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)"
-     (2 (7 . nil))
-     (4 (7 . nil)))
-    ;; $' $" $` .... are variables
-    ;; ?' ?" ?` are ascii codes
-    ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" 3 (1 . nil))
-    ;; regexps
-    ("\\(^\\|[[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
-     (4 (7 . ?/))
-     (6 (7 . ?/)))
-    ("^=en\\(d\\)\\_>" 1 "!")
-    ;; Percent literal.
-    ("\\(^\\|[[ \t\n<+(,=]\\)\\(%[xrqQwW]?\\([^<[{(a-zA-Z0-9 \n]\\)[^\n\\\\]*\\(\\\\.[^\n\\\\]*\\)*\\(\\3\\)\\)"
-     (3 "\"")
-     (5 "\""))
-    ("^\\(=\\)begin\\_>" 1 (ruby-comment-beg-syntax))
-    ;; Currently, the following case is highlighted incorrectly:
-    ;;
-    ;;   <<FOO
-    ;;   FOO
-    ;;   <<BAR
-    ;;   <<BAZ
-    ;;   BAZ
-    ;;   BAR
-    ;;
-    ;; This is because all here-doc beginnings are highlighted before any endings,
-    ;; so although <<BAR is properly marked as a beginning, when we get to <<BAZ
-    ;; it thinks <<BAR is part of a string so it's marked as well.
-    ;;
-    ;; This may be fixable by modifying ruby-in-here-doc-p to use
-    ;; ruby-in-non-here-doc-string-p rather than syntax-ppss-context,
-    ;; but I don't want to try that until we've got unit tests set up
-    ;; to make sure I don't break anything else.
-    (,(concat ruby-here-doc-beg-re ".*\\(\n\\)")
-     ,(+ 1 (regexp-opt-depth ruby-here-doc-beg-re))
-     (ruby-here-doc-beg-syntax))
-    (,ruby-here-doc-end-re 3 (ruby-here-doc-end-syntax)))
-  "Syntactic keywords for Ruby mode.  See `font-lock-syntactic-keywords'.")
-
-  (defun ruby-comment-beg-syntax ()
-  "Return the syntax cell for a the first character of a =begin.
-See the definition of `ruby-font-lock-syntactic-keywords'.
-
-This returns a comment-delimiter cell as long as the =begin
-isn't in a string or another comment."
-    (when (not (nth 3 (syntax-ppss)))
-      (string-to-syntax "!")))
-
-  (defun ruby-in-here-doc-p ()
-    "Return whether or not the point is in a heredoc."
-    (save-excursion
-      (let ((old-point (point)) (case-fold-search nil))
+  (defvar ruby-syntax-before-regexp-re
+    (concat
+     ;; Special tokens that can't be followed by a division operator.
+     "\\(^\\|[[=(,~;<>]"
+     ;; Distinguish ternary operator tokens.
+     ;; FIXME: They don't really have to be separated with spaces.
+     "\\|[?:] "
+     ;; Control flow keywords and operators following bol or whitespace.
+     "\\|\\(?:^\\|\\s \\)"
+     (regexp-opt '("if" "elsif" "unless" "while" "until" "when" "and"
+                   "or" "not" "&&" "||"))
+     ;; Method name from the list.
+     "\\|\\_<"
+     (regexp-opt ruby-syntax-methods-before-regexp)
+     "\\)\\s *")
+    "Regexp to match text that can be followed by a regular expression."))
+
+(defun ruby-syntax-propertize-function (start end)
+  "Syntactic keywords for Ruby mode.  See `syntax-propertize-function'."
+  (let (case-fold-search)
+    (goto-char start)
+    (remove-text-properties start end '(ruby-expansion-match-data))
+    (ruby-syntax-propertize-heredoc end)
+    (ruby-syntax-enclosing-percent-literal end)
+    (funcall
+     (syntax-propertize-rules
+      ;; $' $" $` .... are variables.
+      ;; ?' ?" ?` are character literals (one-char strings in 1.9+).
+      ("\\([?$]\\)[#\"'`]"
+       (1 (unless (save-excursion
+                    ;; Not within a string.
+                    (nth 3 (syntax-ppss (match-beginning 0))))
+            (string-to-syntax "\\"))))
+      ;; Regular expressions.  Start with matching unescaped slash.
+      ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)"
+       (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1)))))
+            (when (or
+                   ;; Beginning of a regexp.
+                   (and (null (nth 8 state))
+                        (save-excursion
+                          (forward-char -1)
+                          (looking-back ruby-syntax-before-regexp-re
+                                        (point-at-bol))))
+                   ;; End of regexp.  We don't match the whole
+                   ;; regexp at once because it can have
+                   ;; string interpolation inside, or span
+                   ;; several lines.
+                   (eq ?/ (nth 3 state)))
+              (string-to-syntax "\"/")))))
+      ;; Expression expansions in strings.  We're handling them
+      ;; here, so that the regexp rule never matches inside them.
+      (ruby-expression-expansion-re
+       (0 (ignore (ruby-syntax-propertize-expansion))))
+      ("^=en\\(d\\)\\_>" (1 "!"))
+      ("^\\(=\\)begin\\_>" (1 "!"))
+      ;; Handle here documents.
+      ((concat ruby-here-doc-beg-re ".*\\(\n\\)")
+       (7 (unless (or (nth 8 (save-excursion
+                               (syntax-ppss (match-beginning 0))))
+                      (ruby-singleton-class-p (match-beginning 0)))
+            (put-text-property (match-beginning 7) (match-end 7)
+                               'syntax-table (string-to-syntax "\""))
+            (ruby-syntax-propertize-heredoc end))))
+      ;; Handle percent literals: %w(), %q{}, etc.
+      ((concat "\\(?:^\\|[[ \t\n<+(,=]\\)" ruby-percent-literal-beg-re)
+       (1 (prog1 "|" (ruby-syntax-propertize-percent-literal end)))))
+     (point) end)))
+
+(defun ruby-syntax-propertize-heredoc (limit)
+  (let ((ppss (syntax-ppss))
+        (res '()))
+    (when (eq ?\n (nth 3 ppss))
+      (save-excursion
+        (goto-char (nth 8 ppss))
         (beginning-of-line)
-        (catch 'found-beg
-          (while (and (re-search-backward ruby-here-doc-beg-re nil t)
-                      (not (ruby-singleton-class-p)))
-            (if (not (or (ruby-in-ppss-context-p 'anything)
-                         (ruby-here-doc-find-end old-point)))
-                (throw 'found-beg t)))))))
-
-  (defun ruby-here-doc-find-end (&optional limit)
-    "Expects the point to be on a line with one or more heredoc openers.
-Returns the buffer position at which all heredocs on the line
-are terminated, or nil if they aren't terminated before the
-buffer position `limit' or the end of the buffer."
-    (save-excursion
-      (beginning-of-line)
-      (catch 'done
-        (let ((eol (point-at-eol))
-              (case-fold-search nil)
-              ;; Fake match data such that (match-end 0) is at eol
-              (end-match-data (progn (looking-at ".*$") (match-data)))
-              beg-match-data end-re)
-          (while (re-search-forward ruby-here-doc-beg-re eol t)
-            (setq beg-match-data (match-data))
-            (setq end-re (ruby-here-doc-end-match))
-
-            (set-match-data end-match-data)
-            (goto-char (match-end 0))
-            (unless (re-search-forward end-re limit t) (throw 'done nil))
-            (setq end-match-data (match-data))
-
-            (set-match-data beg-match-data)
-            (goto-char (match-end 0)))
-          (set-match-data end-match-data)
-          (goto-char (match-end 0))
-          (point)))))
-
-  (defun ruby-here-doc-beg-syntax ()
-    "Return the syntax cell for a line that may begin a heredoc.
-See the definition of `ruby-font-lock-syntactic-keywords'.
-
-This sets the syntax cell for the newline ending the line
-containing the heredoc beginning so that cases where multiple
-heredocs are started on one line are handled correctly."
-    (save-excursion
-      (goto-char (match-beginning 0))
-      (unless (or (ruby-in-ppss-context-p 'non-heredoc)
-                  (ruby-in-here-doc-p))
-        (string-to-syntax "\""))))
-
-  (defun ruby-here-doc-end-syntax ()
-    "Return the syntax cell for a line that may end a heredoc.
-See the definition of `ruby-font-lock-syntactic-keywords'."
-    (let ((pss (syntax-ppss)) (case-fold-search nil))
-      ;; If we aren't in a string, we definitely aren't ending a heredoc,
-      ;; so we can just give up.
-      ;; This means we aren't doing a full-document search
-      ;; every time we enter a character.
-      (when (ruby-in-ppss-context-p 'heredoc pss)
+        (while (re-search-forward ruby-here-doc-beg-re
+                                  (line-end-position) t)
+          (unless (ruby-singleton-class-p (match-beginning 0))
+            (push (concat (ruby-here-doc-end-match) "\n") res))))
+      (save-excursion
+        ;; With multiple openers on the same line, we don't know in which
+        ;; part `start' is, so we have to go back to the beginning.
+        (when (cdr res)
+          (goto-char (nth 8 ppss))
+          (setq res (nreverse res)))
+        (while (and res (re-search-forward (pop res) limit 'move))
+          (if (null res)
+              (put-text-property (1- (point)) (point)
+                                 'syntax-table (string-to-syntax "\""))))
+        ;; End up at bol following the heredoc openers.
+        ;; Propertize expression expansions from this point forward.
+        ))))
+
+(defun ruby-syntax-enclosing-percent-literal (limit)
+  (let ((state (syntax-ppss))
+        (start (point)))
+    ;; When already inside percent literal, re-propertize it.
+    (when (eq t (nth 3 state))
+      (goto-char (nth 8 state))
+      (when (looking-at ruby-percent-literal-beg-re)
+        (ruby-syntax-propertize-percent-literal limit))
+      (when (< (point) start) (goto-char start)))))
+
+(defun ruby-syntax-propertize-percent-literal (limit)
+  (goto-char (match-beginning 2))
+  ;; Not inside a simple string or comment.
+  (when (eq t (nth 3 (syntax-ppss)))
+    (let* ((op (char-after))
+           (ops (char-to-string op))
+           (cl (or (cdr (aref (syntax-table) op))
+                   (cdr (assoc op '((?< . ?>))))))
+           parse-sexp-lookup-properties)
+      (save-excursion
+        (condition-case nil
+            (progn
+              (if cl              ; Paired delimiters.
+                  ;; Delimiter pairs of the same kind can be nested
+                  ;; inside the literal, as long as they are balanced.
+                  ;; Create syntax table that ignores other characters.
+                  (with-syntax-table (make-char-table 'syntax-table nil)
+                    (modify-syntax-entry op (concat "(" (char-to-string cl)))
+                    (modify-syntax-entry cl (concat ")" ops))
+                    (modify-syntax-entry ?\\ "\\")
+                    (save-restriction
+                      (narrow-to-region (point) limit)
+                      (forward-list))) ; skip to the paired character
+                ;; Single character delimiter.
+                (re-search-forward (concat "[^\\]\\(?:\\\\\\\\\\)*"
+                                           (regexp-quote ops)) limit nil))
+              ;; Found the closing delimiter.
+              (put-text-property (1- (point)) (point) 'syntax-table
+                                 (string-to-syntax "|")))
+          ;; Unclosed literal, do nothing.
+          ((scan-error search-failed)))))))
+
+(defun ruby-syntax-propertize-expansion ()
+  ;; Save the match data to a text property, for font-locking later.
+  ;; Set the syntax of all double quotes and backticks to punctuation.
+  (let* ((beg (match-beginning 2))
+         (end (match-end 2))
+         (state (and beg (save-excursion (syntax-ppss beg)))))
+    (when (ruby-syntax-expansion-allowed-p state)
+      (put-text-property beg (1+ beg) 'ruby-expansion-match-data
+                         (match-data))
+      (goto-char beg)
+      (while (re-search-forward "[\"`]" end 'move)
+        (put-text-property (match-beginning 0) (match-end 0)
+                           'syntax-table (string-to-syntax "."))))))
+
+(defun ruby-syntax-expansion-allowed-p (parse-state)
+  "Return non-nil if expression expansion is allowed."
+  (let ((term (nth 3 parse-state)))
+    (cond
+     ((memq term '(?\" ?` ?\n ?/)))
+     ((eq term t)
+      (save-match-data
         (save-excursion
-          (goto-char (nth 8 pss))    ; Go to the beginning of heredoc.
-          (let ((eol (point)))
-            (beginning-of-line)
-            (if (and (re-search-forward (ruby-here-doc-beg-match) eol t) ; If there is a heredoc that matches this line...
-                     (not (ruby-in-ppss-context-p 'anything)) ; And that's not inside a heredoc/string/comment...
-                     (progn (goto-char (match-end 0)) ; And it's the last heredoc on its line...
-                            (not (re-search-forward ruby-here-doc-beg-re eol t))))
-                (string-to-syntax "\"")))))))
+          (goto-char (nth 8 parse-state))
+          (looking-at "%\\(?:[QWrxI]\\|\\W\\)")))))))
 
-  (unless (functionp 'syntax-ppss)
-    (defun syntax-ppss (&optional pos)
-      (parse-partial-sexp (point-min) (or pos (point)))))
-  )
+(defun ruby-syntax-propertize-expansions (start end)
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward ruby-expression-expansion-re end 'move)
+      (ruby-syntax-propertize-expansion))))
 
 (defun ruby-in-ppss-context-p (context &optional ppss)
   (let ((ppss (or ppss (syntax-ppss (point)))))
@@ -1832,14 +1800,6 @@ See the definition of `ruby-font-lock-syntactic-keywords'."
                   "context name `" (symbol-name context) "' is unknown"))))
         t)))
 
-(if (featurep 'xemacs)
-    (put 'ruby-mode 'font-lock-defaults
-         '((ruby-font-lock-keywords)
-           nil nil nil
-           beginning-of-line
-           (font-lock-syntactic-keywords
-            . ruby-font-lock-syntactic-keywords))))
-
 (defvar ruby-font-lock-syntax-table
   (let ((tbl (copy-syntax-table ruby-mode-syntax-table)))
     (modify-syntax-entry ?_ "w" tbl)
@@ -1850,153 +1810,155 @@ See `font-lock-syntax-table'.")
 (defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)")
 
 (defconst ruby-font-lock-keywords
-  (list
-   ;; functions
-   '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)"
+  `(;; Functions.
+    ("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)"
      1 font-lock-function-name-face)
-   ;; keywords
-   (list (concat
-          ruby-font-lock-keyword-beg-re
-          (regexp-opt
-           '("alias"
-             "and"
-             "begin"
-             "break"
-             "case"
-             "class"
-             "def"
-             "defined?"
-             "do"
-             "elsif"
-             "else"
-             "fail"
-             "ensure"
-             "for"
-             "end"
-             "if"
-             "in"
-             "module"
-             "next"
-             "not"
-             "or"
-             "redo"
-             "rescue"
-             "retry"
-             "return"
-             "then"
-             "super"
-             "unless"
-             "undef"
-             "until"
-             "when"
-             "while"
-             "yield")
-           'symbols))
-         1 'font-lock-keyword-face)
-   ;; some core methods
-   (list (concat
-          ruby-font-lock-keyword-beg-re
-          (regexp-opt
-           '(;; built-in methods on Kernel
-             "__callee__"
-             "__dir__"
-             "__method__"
-             "abort"
-             "at_exit"
-             "autoload"
-             "autoload?"
-             "binding"
-             "block_given?"
-             "caller"
-             "catch"
-             "eval"
-             "exec"
-             "exit"
-             "exit!"
-             "fail"
-             "fork"
-             "format"
-             "lambda"
-             "load"
-             "loop"
-             "open"
-             "p"
-             "print"
-             "printf"
-             "proc"
-             "putc"
-             "puts"
-             "raise"
-             "rand"
-             "readline"
-             "readlines"
-             "require"
-             "require_relative"
-             "sleep"
-             "spawn"
-             "sprintf"
-             "srand"
-             "syscall"
-             "system"
-             "throw"
-             "trap"
-             "warn"
-             ;; keyword-like private methods on Module
-             "alias_method"
-             "attr"
-             "attr_accessor"
-             "attr_reader"
-             "attr_writer"
-             "define_method"
-             "extend"
-             "include"
-             "module_function"
-             "prepend"
-             "private"
-             "protected"
-             "public"
-             "refine"
-             "using")
-           'symbols))
-         1 'font-lock-builtin-face)
-   ;; here-doc beginnings
-   `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0))
-                               'font-lock-string-face))
-   ;; Perl-ish keywords
-   "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
-   ;; variables
-   `(,(concat ruby-font-lock-keyword-beg-re
-              "\\_<\\(nil\\|self\\|true\\|false\\)\\>")
+    ;; Keywords.
+    (,(concat
+       ruby-font-lock-keyword-beg-re
+       (regexp-opt
+        '("alias"
+          "and"
+          "begin"
+          "break"
+          "case"
+          "class"
+          "def"
+          "defined?"
+          "do"
+          "elsif"
+          "else"
+          "fail"
+          "ensure"
+          "for"
+          "end"
+          "if"
+          "in"
+          "module"
+          "next"
+          "not"
+          "or"
+          "redo"
+          "rescue"
+          "retry"
+          "return"
+          "then"
+          "super"
+          "unless"
+          "undef"
+          "until"
+          "when"
+          "while"
+          "yield")
+        'symbols))
+     (1 font-lock-keyword-face))
+    ;; Some core methods.
+    (,(concat
+       ruby-font-lock-keyword-beg-re
+       (regexp-opt
+        '( ;; built-in methods on Kernel
+          "__callee__"
+          "__dir__"
+          "__method__"
+          "abort"
+          "at_exit"
+          "autoload"
+          "autoload?"
+          "binding"
+          "block_given?"
+          "caller"
+          "catch"
+          "eval"
+          "exec"
+          "exit"
+          "exit!"
+          "fail"
+          "fork"
+          "format"
+          "lambda"
+          "load"
+          "loop"
+          "open"
+          "p"
+          "print"
+          "printf"
+          "proc"
+          "putc"
+          "puts"
+          "raise"
+          "rand"
+          "readline"
+          "readlines"
+          "require"
+          "require_relative"
+          "sleep"
+          "spawn"
+          "sprintf"
+          "srand"
+          "syscall"
+          "system"
+          "throw"
+          "trap"
+          "warn"
+          ;; keyword-like private methods on Module
+          "alias_method"
+          "attr"
+          "attr_accessor"
+          "attr_reader"
+          "attr_writer"
+          "define_method"
+          "extend"
+          "include"
+          "module_function"
+          "prepend"
+          "private"
+          "protected"
+          "public"
+          "refine"
+          "using")
+        'symbols))
+     (1 font-lock-builtin-face))
+    ;; Here-doc beginnings.
+    (,ruby-here-doc-beg-re
+     (0 (unless (ruby-singleton-class-p (match-beginning 0))
+          'font-lock-string-face)))
+    ;; Perl-ish keywords.
+    "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$"
+    ;; Variables.
+    (,(concat ruby-font-lock-keyword-beg-re
+              "\\_<\\(nil\\|self\\|true\\|false\\)\\_>")
      1 font-lock-variable-name-face)
-   ;; keywords that evaluate to certain values
-   '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face)
-   ;; symbols
-   '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
+    ;; Keywords that evaluate to certain values.
+    ("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>"
+     (0 font-lock-variable-name-face))
+    ;; Symbols.
+    ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
      2 font-lock-constant-face)
-   ;; variables
-   '("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
+    ;; Variables.
+    ("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
      1 font-lock-variable-name-face)
-   '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
+    ("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
      0 font-lock-variable-name-face)
-   ;; constants
-   '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)"
+    ;; Constants.
+    ("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)"
      1 (unless (eq ?\( (char-after)) font-lock-type-face))
-   '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face)
-   ;; conversion methods on Kernel
-   (list (concat ruby-font-lock-keyword-beg-re
-                 (regexp-opt '("Array" "Complex" "Float" "Hash"
-                               "Integer" "Rational" "String") 'symbols))
-         1 font-lock-builtin-face)
-   ;; expression expansion
-   '(ruby-match-expression-expansion
+    ("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]"
+     (2 font-lock-constant-face))
+    ;; Conversion methods on Kernel.
+    (,(concat ruby-font-lock-keyword-beg-re
+              (regexp-opt '("Array" "Complex" "Float" "Hash"
+                            "Integer" "Rational" "String") 'symbols))
+     (1 font-lock-builtin-face))
+    ;; Expression expansion.
+    (ruby-match-expression-expansion
      2 font-lock-variable-name-face t)
-   ;; negation char
-   '("[^[:alnum:]_]\\(!\\)[^=]"
+    ;; Negation char.
+    ("[^[:alnum:]_]\\(!\\)[^=]"
      1 font-lock-negation-char-face)
-   ;; character literals
-   ;; FIXME: Support longer escape sequences.
-   '("\\_<\\?\\\\?\\S " 0 font-lock-string-face)
-   )
+    ;; Character literals.
+    ;; FIXME: Support longer escape sequences.
+    ("\\_<\\?\\\\?\\S " 0 font-lock-string-face)
+    )
   "Additional expressions to highlight in Ruby mode.")
 
 (defun ruby-match-expression-expansion (limit)
@@ -2011,42 +1973,25 @@ See `font-lock-syntax-table'.")
 
 ;;;###autoload
 (define-derived-mode ruby-mode prog-mode "Ruby"
-  "Major mode for editing Ruby scripts.
-\\[ruby-indent-line] properly indents subexpressions of multi-line
-class, module, def, if, while, for, do, and case statements, taking
-nesting into account.
-
-The variable `ruby-indent-level' controls the amount of indentation.
+  "Major mode for editing Ruby code.
 
 \\{ruby-mode-map}"
   (ruby-mode-variables)
 
-  (set (make-local-variable 'imenu-create-index-function)
-       'ruby-imenu-create-index)
-  (set (make-local-variable 'add-log-current-defun-function)
-       'ruby-add-log-current-method)
-  (set (make-local-variable 'beginning-of-defun-function)
-       'ruby-beginning-of-defun)
-  (set (make-local-variable 'end-of-defun-function)
-       'ruby-end-of-defun)
+  (setq-local imenu-create-index-function 'ruby-imenu-create-index)
+  (setq-local add-log-current-defun-function 'ruby-add-log-current-method)
+  (setq-local beginning-of-defun-function 'ruby-beginning-of-defun)
+  (setq-local end-of-defun-function 'ruby-end-of-defun)
 
   (add-hook 'after-save-hook 'ruby-mode-set-encoding nil 'local)
 
-  (set (make-local-variable 'electric-indent-chars)
-       (append '(?\{ ?\}) electric-indent-chars))
-
-  (set (make-local-variable 'font-lock-defaults)
-       '((ruby-font-lock-keywords) nil nil))
-  (set (make-local-variable 'font-lock-keywords)
-       ruby-font-lock-keywords)
-  (set (make-local-variable 'font-lock-syntax-table)
-       ruby-font-lock-syntax-table)
-
-  (if (eval-when-compile (fboundp 'syntax-propertize-rules))
-      (set (make-local-variable 'syntax-propertize-function)
-           #'ruby-syntax-propertize-function)
-    (set (make-local-variable 'font-lock-syntactic-keywords)
-         ruby-font-lock-syntactic-keywords)))
+  (setq-local electric-indent-chars (append '(?\{ ?\}) electric-indent-chars))
+
+  (setq-local font-lock-defaults '((ruby-font-lock-keywords) nil nil))
+  (setq-local font-lock-keywords ruby-font-lock-keywords)
+  (setq-local font-lock-syntax-table ruby-font-lock-syntax-table)
+
+  (setq-local syntax-propertize-function #'ruby-syntax-propertize-function))
 
 ;;; Invoke ruby-mode when appropriate
 
index fda7d6b6852673af48befb5ff7dd6ba12ad53d1c..eabb222a84bb1544e241c2fb0cb0a18317ac6bb3 100644 (file)
@@ -210,9 +210,7 @@ start an inferior Scheme using the more general `cmuscheme' package.
 Commands:
 Delete converts tabs to spaces as it moves back.
 Blank lines separate paragraphs.  Semicolons start comments.
-\\{scheme-mode-map}
-Entry to this mode calls the value of `scheme-mode-hook'
-if that value is non-nil."
+\\{scheme-mode-map}"
   (scheme-mode-variables))
 
 (defgroup scheme nil
index f834d7f32177890972b5c6721fc6def9247148f3..3ac0868414bf3f74129e37a3f164445949c5cadc 100644 (file)
@@ -942,6 +942,7 @@ See `sh-feature'.")
     (rpm sh-append rpm2
         ("%{?\\(\\sw+\\)"  1 font-lock-keyword-face))
     (rpm2 sh-append shell
+         ("^Summary:\\(.*\\)$" (1 font-lock-doc-face t))
          ("^\\(\\sw+\\):"  1 font-lock-variable-name-face)))
   "Default expressions to highlight in Shell Script modes.  See `sh-feature'.")
 
@@ -1721,7 +1722,7 @@ This adds rules for comments and assignments."
 ;; the various indentation custom-vars, and it misses some important features
 ;; of the old code, mostly: sh-learn-line/buffer-indent, sh-show-indent,
 ;; sh-name/save/load-style.
-(defvar sh-use-smie nil
+(defvar sh-use-smie t
   "Whether to use the SMIE code for navigation and indentation.")
 
 (defun sh-smie--keyword-p ()
@@ -1730,7 +1731,7 @@ A keyword position is one where if we're looking at something that looks
 like a keyword, then it is a keyword."
   (let ((prev (funcall smie-backward-token-function)))
     (if (zerop (length prev))
-        (looking-back "\\s(" (1- (point)))
+        (looking-back "\\`\\|\\s(" (1- (point)))
       (assoc prev smie-grammar))))
 
 (defun sh-smie--newline-semi-p (&optional tok)
@@ -1804,12 +1805,14 @@ Does not preserve point."
       (setq prev (funcall smie-backward-token-function))
       (cond
        ((zerop (length prev))
-        (if newline
-            (progn (cl-assert words) (setq res 'word))
+       (cond
+        (newline (cl-assert words) (setq res 'word))
+        ((bobp) (setq res 'word))
+        (t
           (setq words t)
           (condition-case nil
               (forward-sexp -1)
-            (scan-error (setq res 'unknown)))))
+            (scan-error (setq res 'unknown))))))
        ((equal prev ";")
         (if words (setq newline t)
           (setq res 'keyword)))
@@ -1926,7 +1929,8 @@ May return nil if the line should not be treated as continued."
 (defun sh-smie-sh-rules (kind token)
   (pcase (cons kind token)
     (`(:elem . basic) sh-indentation)
-    (`(:after . "case-)") (or sh-indentation smie-indent-basic))
+    (`(:after . "case-)") (- (sh-var-value 'sh-indent-for-case-alt)
+                             (sh-var-value 'sh-indent-for-case-label)))
     ((and `(:before . ,_)
           (guard (when sh-indent-after-continuation
                    (save-excursion
@@ -1960,6 +1964,21 @@ May return nil if the line should not be treated as continued."
                  (current-column)
                (smie-indent-calculate)))))
     (`(:after . "|") (if (smie-rule-parent-p "|") nil 4))
+    ;; Attempt at backward compatibility with the old config variables.
+    (`(:before . "fi") (sh-var-value 'sh-indent-for-fi))
+    (`(:before . "done") (sh-var-value 'sh-indent-for-done))
+    (`(:after . "else") (sh-var-value 'sh-indent-after-else))
+    (`(:after . "if") (sh-var-value 'sh-indent-after-if))
+    (`(:before . "then") (sh-var-value 'sh-indent-for-then))
+    (`(:before . "do") (sh-var-value 'sh-indent-for-do))
+    (`(:after . "do")
+     (sh-var-value (if (smie-rule-hanging-p)
+                       'sh-indent-after-loop-construct 'sh-indent-after-do)))
+    ;; sh-indent-after-done: aligned completely differently.
+    (`(:after . "in") (sh-var-value 'sh-indent-for-case-label))
+    ;; sh-indent-for-continuation: Line continuations are handled differently.
+    (`(:after . ,(or `"(" `"{" `"[")) (sh-var-value 'sh-indent-after-open))
+    ;; sh-indent-after-function: we don't handle it differently.
     ))
 
 ;; (defconst sh-smie-csh-grammar
@@ -2119,8 +2138,9 @@ Point should be before the newline."
   (pcase (cons kind token)
     (`(:elem . basic) sh-indentation)
     ;; (`(:after . "case") (or sh-indentation smie-indent-basic))
-    (`(:after . ";") (if (smie-rule-parent-p "case")
-                         (smie-rule-parent sh-indentation)))
+    (`(:after . ";")
+     (if (smie-rule-parent-p "case")
+         (smie-rule-parent (sh-var-value 'sh-indent-after-case))))
     (`(:before . "{")
      (save-excursion
        (when (sh-smie--rc-after-special-arg-p)
@@ -2135,6 +2155,7 @@ Point should be before the newline."
     ;; with "(exp)", which is rarely the right thing to do, but is better
     ;; than nothing.
     (`(:list-intro . ,(or `"for" `"if" `"while")) t)
+    ;; sh-indent-after-switch: handled implicitly by the default { rule.
     ))
 
 ;;; End of SMIE code.
@@ -3154,12 +3175,9 @@ IGNORE-ERROR is non-nil."
      ((eq val '/)
       (/ (- sh-basic-offset) 2))
      (t
-      (if ignore-error
-      (progn
-       (message "Don't know how to handle %s's value of %s" var val)
-       0)
-      (error "Don't know how to handle %s's value of %s" var val))
-      ))))
+      (funcall (if ignore-error #'message #'error)
+               "Don't know how to handle %s's value of %s" var val)
+      0))))
 
 (defun sh-set-var-value (var value &optional no-symbol)
   "Set variable VAR to VALUE.
@@ -3284,33 +3302,35 @@ If variable `sh-blink' is non-nil then momentarily go to the line
 we are indenting relative to, if applicable."
   (interactive "P")
   (sh-must-support-indent)
-  (let* ((info (sh-get-indent-info))
-        (var (sh-get-indent-var-for-line info))
-        (curr-indent (current-indentation))
-        val msg)
-    (if (stringp var)
-       (message "%s" (setq msg var))
-      (setq val (sh-calculate-indent info))
-
-      (if (eq curr-indent val)
-         (setq msg (format "%s is %s" var (symbol-value var)))
-       (setq msg
-             (if val
-                 (format "%s (%s) would change indent from %d to: %d"
-                         var (symbol-value var) curr-indent val)
-               (format "%s (%s) would leave line as is"
-                       var (symbol-value var)))
-             ))
-      (if (and arg var)
-         (describe-variable var)))
-    (if sh-blink
-       (let ((info (sh-get-indent-info)))
-         (if (and info (listp (car info))
-                  (eq (car (car info)) t))
-             (sh-blink (nth 1 (car info))  msg)
-           (message "%s" msg)))
-      (message "%s" msg))
-    ))
+  (if sh-use-smie
+      (smie-config-show-indent)
+    (let* ((info (sh-get-indent-info))
+           (var (sh-get-indent-var-for-line info))
+           (curr-indent (current-indentation))
+           val msg)
+      (if (stringp var)
+          (message "%s" (setq msg var))
+        (setq val (sh-calculate-indent info))
+
+        (if (eq curr-indent val)
+            (setq msg (format "%s is %s" var (symbol-value var)))
+          (setq msg
+                (if val
+                    (format "%s (%s) would change indent from %d to: %d"
+                            var (symbol-value var) curr-indent val)
+                  (format "%s (%s) would leave line as is"
+                          var (symbol-value var)))
+                ))
+        (if (and arg var)
+            (describe-variable var)))
+      (if sh-blink
+          (let ((info (sh-get-indent-info)))
+            (if (and info (listp (car info))
+                     (eq (car (car info)) t))
+                (sh-blink (nth 1 (car info))  msg)
+              (message "%s" msg)))
+        (message "%s" msg))
+      )))
 
 (defun sh-set-indent ()
   "Set the indentation for the current line.
@@ -3318,34 +3338,36 @@ If the current line is controlled by an indentation variable, prompt
 for a new value for it."
   (interactive)
   (sh-must-support-indent)
-  (let* ((info (sh-get-indent-info))
-        (var (sh-get-indent-var-for-line info))
-        val old-val indent-val)
-    (if (stringp var)
-       (message "Cannot set indent - %s" var)
-      (setq old-val (symbol-value var))
-      (setq val (sh-read-variable var))
-      (condition-case nil
-         (progn
-           (set var val)
-           (setq indent-val (sh-calculate-indent info))
-           (if indent-val
-               (message "Variable: %s  Value: %s  would indent to: %d"
-                        var (symbol-value var) indent-val)
-             (message "Variable: %s  Value: %s  would leave line as is."
-                      var (symbol-value var)))
-           ;; I'm not sure about this, indenting it now?
-           ;; No.  Because it would give the impression that an undo would
-           ;; restore thing, but the value has been altered.
-           ;; (sh-indent-line)
-           )
-       (error
-        (set var old-val)
-        (message "Bad value for %s, restoring to previous value %s"
-                 var old-val)
-        (sit-for 1)
-        nil))
-      )))
+  (if sh-use-smie
+      (smie-config-set-indent)
+    (let* ((info (sh-get-indent-info))
+           (var (sh-get-indent-var-for-line info))
+           val old-val indent-val)
+      (if (stringp var)
+          (message "Cannot set indent - %s" var)
+        (setq old-val (symbol-value var))
+        (setq val (sh-read-variable var))
+        (condition-case nil
+            (progn
+              (set var val)
+              (setq indent-val (sh-calculate-indent info))
+              (if indent-val
+                  (message "Variable: %s  Value: %s  would indent to: %d"
+                           var (symbol-value var) indent-val)
+                (message "Variable: %s  Value: %s  would leave line as is."
+                         var (symbol-value var)))
+              ;; I'm not sure about this, indenting it now?
+              ;; No.  Because it would give the impression that an undo would
+              ;; restore thing, but the value has been altered.
+              ;; (sh-indent-line)
+              )
+          (error
+           (set var old-val)
+           (message "Bad value for %s, restoring to previous value %s"
+                    var old-val)
+           (sit-for 1)
+           nil))
+        ))))
 
 
 (defun sh-learn-line-indent (arg)
@@ -3359,55 +3381,57 @@ If the value can be represented by one of the symbols then do so
 unless optional argument ARG (the prefix when interactive) is non-nil."
   (interactive "*P")
   (sh-must-support-indent)
-  ;; I'm not sure if we show allow learning on an empty line.
-  ;; Though it might occasionally be useful I think it usually
-  ;; would just be confusing.
-  (if (save-excursion
-       (beginning-of-line)
-       (looking-at "\\s-*$"))
-      (message "sh-learn-line-indent ignores empty lines.")
-    (let* ((info (sh-get-indent-info))
-          (var (sh-get-indent-var-for-line info))
-          ival sval diff new-val
-          (no-symbol arg)
-          (curr-indent (current-indentation)))
-      (cond
-       ((stringp var)
-       (message "Cannot learn line - %s" var))
-       ((eq var 'sh-indent-comment)
-       ;; This is arbitrary...
-       ;; - if curr-indent is 0, set to curr-indent
-       ;; - else if it has the indentation of a "normal" line,
-       ;;   then set to t
-       ;; - else set to curr-indent.
-       (setq sh-indent-comment
-             (if (= curr-indent 0)
-                 0
-               (let* ((sh-indent-comment t)
-                      (val2 (sh-calculate-indent info)))
-                 (if (= val2 curr-indent)
-                     t
-                   curr-indent))))
-       (message "%s set to %s" var (symbol-value var))
-       )
-       ((numberp (setq sval (sh-var-value var)))
-       (setq ival (sh-calculate-indent info))
-       (setq diff (- curr-indent ival))
-
-       (sh-debug "curr-indent: %d   ival: %d  diff: %d  var:%s  sval %s"
-                 curr-indent ival diff  var sval)
-       (setq new-val (+ sval diff))
-;;;      I commented out this because someone might want to replace
-;;;      a value of `+' with the current value of sh-basic-offset
-;;;      or vice-versa.
-;;;      (if (= 0 diff)
-;;;          (message "No change needed!")
-       (sh-set-var-value var new-val no-symbol)
-       (message "%s set to %s" var (symbol-value var))
-       )
-       (t
-       (debug)
-       (message "Cannot change %s" var))))))
+  (if sh-use-smie
+      (smie-config-set-indent)
+    ;; I'm not sure if we show allow learning on an empty line.
+    ;; Though it might occasionally be useful I think it usually
+    ;; would just be confusing.
+    (if (save-excursion
+          (beginning-of-line)
+          (looking-at "\\s-*$"))
+        (message "sh-learn-line-indent ignores empty lines.")
+      (let* ((info (sh-get-indent-info))
+             (var (sh-get-indent-var-for-line info))
+             ival sval diff new-val
+             (no-symbol arg)
+             (curr-indent (current-indentation)))
+        (cond
+         ((stringp var)
+          (message "Cannot learn line - %s" var))
+         ((eq var 'sh-indent-comment)
+          ;; This is arbitrary...
+          ;; - if curr-indent is 0, set to curr-indent
+          ;; - else if it has the indentation of a "normal" line,
+          ;;   then set to t
+          ;; - else set to curr-indent.
+          (setq sh-indent-comment
+                (if (= curr-indent 0)
+                    0
+                  (let* ((sh-indent-comment t)
+                         (val2 (sh-calculate-indent info)))
+                    (if (= val2 curr-indent)
+                        t
+                      curr-indent))))
+          (message "%s set to %s" var (symbol-value var))
+          )
+         ((numberp (setq sval (sh-var-value var)))
+          (setq ival (sh-calculate-indent info))
+          (setq diff (- curr-indent ival))
+
+          (sh-debug "curr-indent: %d   ival: %d  diff: %d  var:%s  sval %s"
+                    curr-indent ival diff  var sval)
+          (setq new-val (+ sval diff))
+          ;; I commented out this because someone might want to replace
+          ;; a value of `+' with the current value of sh-basic-offset
+          ;; or vice-versa.
+          ;;(if (= 0 diff)
+          ;;     (message "No change needed!")
+          (sh-set-var-value var new-val no-symbol)
+          (message "%s set to %s" var (symbol-value var))
+          )
+         (t
+          (debug)
+          (message "Cannot change %s" var)))))))
 
 
 
@@ -3505,202 +3529,204 @@ removed in the future.
 This command can often take a long time to run."
   (interactive "P")
   (sh-must-support-indent)
-  (save-excursion
-    (goto-char (point-min))
-    (let ((learned-var-list nil)
-         (out-buffer "*indent*")
-         (num-diffs 0)
-         previous-set-info
-         (max 17)
-         vec
-         msg
-         (comment-col nil) ;; number if all same, t if seen diff values
-         (comments-always-default t) ;; nil if we see one not default
-         initial-msg
-         (specified-basic-offset (and arg (numberp arg)
-                                      (> arg 0)))
-         (linenum 0)
-         suggested)
-      (setq vec (make-vector max 0))
-      (sh-mark-init out-buffer)
-
-      (if specified-basic-offset
-         (progn
-           (setq sh-basic-offset arg)
-           (setq initial-msg
-                 (format "Using specified sh-basic-offset of %d"
-                         sh-basic-offset)))
-       (setq initial-msg
-             (format "Initial value of sh-basic-offset: %s"
-                     sh-basic-offset)))
-
-      (while (< (point) (point-max))
-       (setq linenum (1+ linenum))
-       ;; (if (zerop (% linenum 10))
-       (message "line %d" linenum)
-       ;; )
-       (unless (looking-at "\\s-*$") ;; ignore empty lines!
-         (let* ((sh-indent-comment t) ;; info must return default indent
-                (info (sh-get-indent-info))
-                (var (sh-get-indent-var-for-line info))
-                sval ival diff new-val
-                (curr-indent (current-indentation)))
-           (cond
-            ((null var)
-             nil)
-            ((stringp var)
-             nil)
-            ((numberp (setq sval (sh-var-value var 'no-error)))
-             ;; the numberp excludes comments since sval will be t.
-             (setq ival (sh-calculate-indent))
-             (setq diff (- curr-indent ival))
-             (setq new-val (+ sval diff))
-             (sh-set-var-value var new-val 'no-symbol)
-             (unless (looking-at "\\s-*#") ;; don't learn from comments
-               (if (setq previous-set-info (assoc var learned-var-list))
-                   (progn
-                     ;; it was already there, is it same value ?
-                     (unless (eq (symbol-value var)
-                                 (nth 1 previous-set-info))
-                       (sh-mark-line
-                        (format "Variable %s was set to %s"
-                                var (symbol-value var))
-                        (point) out-buffer t t)
-                       (sh-mark-line
-                        (format "  but was previously set to %s"
-                                (nth 1 previous-set-info))
-                        (nth 2 previous-set-info) out-buffer t)
-                       (setq num-diffs (1+ num-diffs))
-                       ;; (delete previous-set-info  learned-var-list)
-                       (setcdr previous-set-info
-                               (list (symbol-value var) (point)))
-                       )
-                     )
-                 (setq learned-var-list
-                       (append (list (list var (symbol-value var)
-                                           (point)))
-                               learned-var-list)))
-               (if (numberp new-val)
-                   (progn
-                     (sh-debug
-                      "This line's indent value: %d"  new-val)
-                     (if (< new-val 0)
-                         (setq new-val (- new-val)))
-                     (if (< new-val max)
-                         (aset vec new-val (1+ (aref vec new-val))))))
-               ))
-            ((eq var 'sh-indent-comment)
-             (unless (= curr-indent (sh-calculate-indent info))
-               ;; this is not the default indentation
-               (setq comments-always-default nil)
-               (if comment-col ;; then we have see one before
-                   (or (eq comment-col curr-indent)
-                       (setq comment-col t)) ;; seen a different one
-                 (setq comment-col curr-indent))
-               ))
-            (t
-             (sh-debug "Cannot learn this line!!!")
-             ))
-           (sh-debug
-            "at %s learned-var-list is %s" (point) learned-var-list)
-           ))
-       (forward-line 1)
-       ) ;; while
-      (if sh-debug
-         (progn
-           (setq msg (format
-                      "comment-col = %s  comments-always-default = %s"
-                      comment-col comments-always-default))
-           ;; (message msg)
-           (sh-mark-line  msg nil out-buffer)))
-      (cond
-       ((eq comment-col 0)
-       (setq msg  "\nComments are all in 1st column.\n"))
-       (comments-always-default
-       (setq msg  "\nComments follow default indentation.\n")
-       (setq comment-col t))
-       ((numberp comment-col)
-       (setq msg  (format "\nComments are in col %d." comment-col)))
-       (t
-       (setq msg  "\nComments seem to be mixed, leaving them as is.\n")
-       (setq comment-col nil)
-       ))
-      (sh-debug msg)
-      (sh-mark-line  msg nil out-buffer)
-
-      (sh-mark-line initial-msg nil out-buffer t t)
-
-      (setq suggested (sh-guess-basic-offset vec))
-
-      (if (and suggested (not specified-basic-offset))
-         (let ((new-value
-                (cond
-                 ;; t => set it if we have a single value as a number
-                 ((and (eq sh-learn-basic-offset t) (numberp suggested))
-                  suggested)
-                 ;; other non-nil => set it if only one value was found
-                 (sh-learn-basic-offset
-                  (if (numberp suggested)
-                      suggested
-                    (if (= (length suggested) 1)
-                        (car suggested))))
-                 (t
-                  nil))))
-           (if new-value
-               (progn
-                 (setq learned-var-list
-                       (append (list (list 'sh-basic-offset
-                                           (setq sh-basic-offset new-value)
-                                           (point-max)))
-                               learned-var-list))
-                 ;; Not sure if we need to put this line in, since
-                 ;; it will appear in the "Learned variable settings".
-                 (sh-mark-line
-                  (format "Changed sh-basic-offset to: %d" sh-basic-offset)
-                  nil out-buffer))
-             (sh-mark-line
-              (if (listp suggested)
-                  (format "Possible value(s) for sh-basic-offset:  %s"
-                          (mapconcat 'int-to-string suggested " "))
-                (format "Suggested sh-basic-offset:  %d" suggested))
-              nil out-buffer))))
-
-
-      (setq learned-var-list
-           (append (list (list 'sh-indent-comment comment-col (point-max)))
-                   learned-var-list))
-      (setq sh-indent-comment comment-col)
-      (let ((name (buffer-name)))
-       (sh-mark-line  "\nLearned variable settings:" nil out-buffer)
-       (if arg
-           ;; Set learned variables to symbolic rather than numeric
-           ;; values where possible.
-           (dolist (learned-var (reverse learned-var-list))
-             (let ((var (car learned-var))
-                   (val (nth 1 learned-var)))
-               (when (and (not (eq var 'sh-basic-offset))
-                          (numberp val))
-                 (sh-set-var-value var val)))))
-       (dolist (learned-var (reverse learned-var-list))
-         (let ((var (car learned-var)))
-           (sh-mark-line (format "  %s %s" var (symbol-value var))
-                         (nth 2 learned-var) out-buffer)))
-       (with-current-buffer out-buffer
-         (goto-char (point-min))
-          (let ((inhibit-read-only t))
-            (insert
-             (format "Indentation values for buffer %s.\n" name)
-             (format "%d indentation variable%s different values%s\n\n"
-                     num-diffs
-                     (if (= num-diffs 1)
-                         " has"   "s have")
-                     (if (zerop num-diffs)
-                         "." ":"))))))
-      ;; Are abnormal hooks considered bad form?
-      (run-hook-with-args 'sh-learned-buffer-hook learned-var-list)
-      (and (called-interactively-p 'any)
-          (or sh-popup-occur-buffer (> num-diffs 0))
-          (pop-to-buffer out-buffer)))))
+  (if sh-use-smie
+      (smie-config-guess)
+    (save-excursion
+      (goto-char (point-min))
+      (let ((learned-var-list nil)
+            (out-buffer "*indent*")
+            (num-diffs 0)
+            previous-set-info
+            (max 17)
+            vec
+            msg
+            (comment-col nil) ;; number if all same, t if seen diff values
+            (comments-always-default t) ;; nil if we see one not default
+            initial-msg
+            (specified-basic-offset (and arg (numberp arg)
+                                         (> arg 0)))
+            (linenum 0)
+            suggested)
+        (setq vec (make-vector max 0))
+        (sh-mark-init out-buffer)
+
+        (if specified-basic-offset
+            (progn
+              (setq sh-basic-offset arg)
+              (setq initial-msg
+                    (format "Using specified sh-basic-offset of %d"
+                            sh-basic-offset)))
+          (setq initial-msg
+                (format "Initial value of sh-basic-offset: %s"
+                        sh-basic-offset)))
+
+        (while (< (point) (point-max))
+          (setq linenum (1+ linenum))
+          ;; (if (zerop (% linenum 10))
+          (message "line %d" linenum)
+          ;; )
+          (unless (looking-at "\\s-*$") ;; ignore empty lines!
+            (let* ((sh-indent-comment t) ;; info must return default indent
+                   (info (sh-get-indent-info))
+                   (var (sh-get-indent-var-for-line info))
+                   sval ival diff new-val
+                   (curr-indent (current-indentation)))
+              (cond
+               ((null var)
+                nil)
+               ((stringp var)
+                nil)
+               ((numberp (setq sval (sh-var-value var 'no-error)))
+                ;; the numberp excludes comments since sval will be t.
+                (setq ival (sh-calculate-indent))
+                (setq diff (- curr-indent ival))
+                (setq new-val (+ sval diff))
+                (sh-set-var-value var new-val 'no-symbol)
+                (unless (looking-at "\\s-*#") ;; don't learn from comments
+                  (if (setq previous-set-info (assoc var learned-var-list))
+                      (progn
+                        ;; it was already there, is it same value ?
+                        (unless (eq (symbol-value var)
+                                    (nth 1 previous-set-info))
+                          (sh-mark-line
+                           (format "Variable %s was set to %s"
+                                   var (symbol-value var))
+                           (point) out-buffer t t)
+                          (sh-mark-line
+                           (format "  but was previously set to %s"
+                                   (nth 1 previous-set-info))
+                           (nth 2 previous-set-info) out-buffer t)
+                          (setq num-diffs (1+ num-diffs))
+                          ;; (delete previous-set-info  learned-var-list)
+                          (setcdr previous-set-info
+                                  (list (symbol-value var) (point)))
+                          )
+                        )
+                    (setq learned-var-list
+                          (append (list (list var (symbol-value var)
+                                              (point)))
+                                  learned-var-list)))
+                  (if (numberp new-val)
+                      (progn
+                        (sh-debug
+                         "This line's indent value: %d"  new-val)
+                        (if (< new-val 0)
+                            (setq new-val (- new-val)))
+                        (if (< new-val max)
+                            (aset vec new-val (1+ (aref vec new-val))))))
+                  ))
+               ((eq var 'sh-indent-comment)
+                (unless (= curr-indent (sh-calculate-indent info))
+                  ;; this is not the default indentation
+                  (setq comments-always-default nil)
+                  (if comment-col ;; then we have see one before
+                      (or (eq comment-col curr-indent)
+                          (setq comment-col t)) ;; seen a different one
+                    (setq comment-col curr-indent))
+                  ))
+               (t
+                (sh-debug "Cannot learn this line!!!")
+                ))
+              (sh-debug
+               "at %s learned-var-list is %s" (point) learned-var-list)
+              ))
+          (forward-line 1)
+          ) ;; while
+        (if sh-debug
+            (progn
+              (setq msg (format
+                         "comment-col = %s  comments-always-default = %s"
+                         comment-col comments-always-default))
+              ;; (message msg)
+              (sh-mark-line  msg nil out-buffer)))
+        (cond
+         ((eq comment-col 0)
+          (setq msg  "\nComments are all in 1st column.\n"))
+         (comments-always-default
+          (setq msg  "\nComments follow default indentation.\n")
+          (setq comment-col t))
+         ((numberp comment-col)
+          (setq msg  (format "\nComments are in col %d." comment-col)))
+         (t
+          (setq msg  "\nComments seem to be mixed, leaving them as is.\n")
+          (setq comment-col nil)
+          ))
+        (sh-debug msg)
+        (sh-mark-line  msg nil out-buffer)
+
+        (sh-mark-line initial-msg nil out-buffer t t)
+
+        (setq suggested (sh-guess-basic-offset vec))
+
+        (if (and suggested (not specified-basic-offset))
+            (let ((new-value
+                   (cond
+                    ;; t => set it if we have a single value as a number
+                    ((and (eq sh-learn-basic-offset t) (numberp suggested))
+                     suggested)
+                    ;; other non-nil => set it if only one value was found
+                    (sh-learn-basic-offset
+                     (if (numberp suggested)
+                         suggested
+                       (if (= (length suggested) 1)
+                           (car suggested))))
+                    (t
+                     nil))))
+              (if new-value
+                  (progn
+                    (setq learned-var-list
+                          (append (list (list 'sh-basic-offset
+                                              (setq sh-basic-offset new-value)
+                                              (point-max)))
+                                  learned-var-list))
+                    ;; Not sure if we need to put this line in, since
+                    ;; it will appear in the "Learned variable settings".
+                    (sh-mark-line
+                     (format "Changed sh-basic-offset to: %d" sh-basic-offset)
+                     nil out-buffer))
+                (sh-mark-line
+                 (if (listp suggested)
+                     (format "Possible value(s) for sh-basic-offset:  %s"
+                             (mapconcat 'int-to-string suggested " "))
+                   (format "Suggested sh-basic-offset:  %d" suggested))
+                 nil out-buffer))))
+
+
+        (setq learned-var-list
+              (append (list (list 'sh-indent-comment comment-col (point-max)))
+                      learned-var-list))
+        (setq sh-indent-comment comment-col)
+        (let ((name (buffer-name)))
+          (sh-mark-line  "\nLearned variable settings:" nil out-buffer)
+          (if arg
+              ;; Set learned variables to symbolic rather than numeric
+              ;; values where possible.
+              (dolist (learned-var (reverse learned-var-list))
+                (let ((var (car learned-var))
+                      (val (nth 1 learned-var)))
+                  (when (and (not (eq var 'sh-basic-offset))
+                             (numberp val))
+                    (sh-set-var-value var val)))))
+          (dolist (learned-var (reverse learned-var-list))
+            (let ((var (car learned-var)))
+              (sh-mark-line (format "  %s %s" var (symbol-value var))
+                            (nth 2 learned-var) out-buffer)))
+          (with-current-buffer out-buffer
+            (goto-char (point-min))
+            (let ((inhibit-read-only t))
+              (insert
+               (format "Indentation values for buffer %s.\n" name)
+               (format "%d indentation variable%s different values%s\n\n"
+                       num-diffs
+                       (if (= num-diffs 1)
+                           " has"   "s have")
+                       (if (zerop num-diffs)
+                           "." ":"))))))
+        ;; Are abnormal hooks considered bad form?
+        (run-hook-with-args 'sh-learned-buffer-hook learned-var-list)
+        (and (called-interactively-p 'any)
+             (or sh-popup-occur-buffer (> num-diffs 0))
+             (pop-to-buffer out-buffer))))))
 
 (defun sh-guess-basic-offset (vec)
   "See if we can determine a reasonable value for `sh-basic-offset'.
@@ -3716,11 +3742,11 @@ Return values:
         (i 1)
         (totals (make-vector max 0)))
     (while (< i max)
-      (aset totals i (+ (aref totals i) (* 4 (aref vec i))))
+      (cl-incf (aref totals i) (* 4 (aref vec i)))
       (if (zerop (% i 2))
-         (aset totals i (+ (aref totals i) (aref vec (/ i 2)))))
+         (cl-incf (aref totals i) (aref vec (/ i 2))))
       (if (< (* i 2) max)
-         (aset totals i (+ (aref totals i) (aref vec (* i 2)))))
+         (cl-incf (aref totals i) (aref vec (* i 2))))
       (setq i (1+ i)))
 
     (let ((x nil)
@@ -3729,10 +3755,10 @@ Return values:
       (setq i 1)
       (while (< i max)
        (if (/= (aref totals i) 0)
-           (setq x (append x (list (cons i (aref totals i))))))
+           (push (cons i (aref totals i)) x))
        (setq i (1+ i)))
 
-      (setq x (sort x (lambda (a b) (> (cdr a) (cdr b)))))
+      (setq x (sort (nreverse x) (lambda (a b) (> (cdr a) (cdr b)))))
       (setq tot (apply '+ (append totals nil)))
       (sh-debug (format "vec: %s\ntotals: %s\ntot: %d"
                        vec totals tot))
index 174e4f7862cf7f2278d3b2df9dbeb3ed1fb18181..3765f8afacaf9df1c4e47b9e542b874b5c5d80d4 100644 (file)
 ;;; Code:
 
 ;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "2013-10-09-1a6ecec-vpo"
+(defconst verilog-mode-version "2013-11-05-78e66ba-vpo"
   "Version of this Verilog mode.")
 (defconst verilog-mode-release-emacs t
   "If non-nil, this version of Verilog mode was released with Emacs itself.")
     (condition-case nil
         (if (fboundp 'store-match-data)
             nil ;; fab
-          (defmacro store-match-data (&rest args) nil))
+          (defmacro store-match-data (&rest _args) nil))
       (error nil))
     (condition-case nil
         (if (fboundp 'char-before)
             nil ;; great
-          (defmacro char-before (&rest body)
+          (defmacro char-before (&rest _body)
             (char-after (1- (point)))))
       (error nil))
     (condition-case nil
@@ -210,23 +210,23 @@ STRING should be given if the last search was by `string-match' on STRING."
     (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
         nil ;; We've got what we needed
       ;; We have the old custom-library, hack around it!
-      (defmacro defgroup (&rest args)  nil)
-      (defmacro customize (&rest args)
+      (defmacro defgroup (&rest _args)  nil)
+      (defmacro customize (&rest _args)
         (message
         "Sorry, Customize is not available with this version of Emacs"))
-      (defmacro defcustom (var value doc &rest args)
+      (defmacro defcustom (var value doc &rest _args)
         `(defvar ,var ,value ,doc))
       )
     (if (fboundp 'defface)
         nil                            ; great!
-      (defmacro defface (var values doc &rest args)
+      (defmacro defface (var values doc &rest _args)
         `(make-face ,var))
       )
 
     (if (and (featurep 'custom) (fboundp 'customize-group))
         nil ;; We've got what we needed
       ;; We have an intermediate custom-library, hack around it!
-      (defmacro customize-group (var &rest args)
+      (defmacro customize-group (var &rest _args)
         `(customize ,var))
       )
 
@@ -259,23 +259,23 @@ STRING should be given if the last search was by `string-match' on STRING."
                                        ;with just a two input regexp
                       (defun verilog-regexp-opt (a b)
                         "Deal with differing number of required arguments for  `regexp-opt'.
-         Call 'regexp-opt' on A and B."
-                        (regexp-opt a b 't))
+         Call `regexp-opt' on A and B."
+                        (regexp-opt a b t))
                     (error nil))
                   )
                  ((eq args 2) ;; It takes 2
                   (defun verilog-regexp-opt (a b)
-                    "Call 'regexp-opt' on A and B."
+                    "Call `regexp-opt' on A and B."
                     (regexp-opt a b))
                   )
                  (t nil)))
             ;; We can't tell; assume it takes 2
             (defun verilog-regexp-opt (a b)
-              "Call 'regexp-opt' on A and B."
+              "Call `regexp-opt' on A and B."
               (regexp-opt a b))
             )
         ;; There is no regexp-opt, provide our own
-        (defun verilog-regexp-opt (strings &optional paren shy)
+        (defun verilog-regexp-opt (strings &optional paren _shy)
           (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
             (concat open (mapconcat 'regexp-quote strings "\\|") close)))
         )
@@ -3657,7 +3657,7 @@ Key bindings specific to `verilog-mode-map' are:
   (set-syntax-table verilog-mode-syntax-table)
   (set (make-local-variable 'indent-line-function)
        #'verilog-indent-line-relative)
-  (setq comment-indent-function 'verilog-comment-indent)
+  (set (make-local-variable 'comment-indent-function) 'verilog-comment-indent)
   (set (make-local-variable 'parse-sexp-ignore-comments) nil)
   (set (make-local-variable 'comment-start) "// ")
   (set (make-local-variable 'comment-end) "")
@@ -4081,14 +4081,7 @@ Uses `verilog-scan' cache."
   (interactive)
   (verilog-re-search-forward verilog-end-defun-re nil 'move))
 
-(defun verilog-get-beg-of-defun (&optional warn)
-  (save-excursion
-    (cond ((verilog-re-search-forward-quick verilog-defun-re nil t)
-          (point))
-         (t
-          (error "%s: Can't find module beginning" (verilog-point-text))
-          (point-max)))))
-(defun verilog-get-end-of-defun (&optional warn)
+(defun verilog-get-end-of-defun ()
   (save-excursion
     (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t)
           (point))
@@ -5460,7 +5453,7 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
        (catch 'continue
          (cond
           ((equal (char-after) ?\{)
-            ;; block type returned based on outer contraint { or inner
+            ;; block type returned based on outer constraint { or inner
            (if (verilog-at-constraint-p)
                 (cond (inconstraint (throw 'nesting 'constraint))
                       (t            (throw 'nesting 'statement)))))
@@ -6486,9 +6479,9 @@ Do not count named blocks or case-statements."
                 (looking-at "\*")))
          (insert "* ")))))
 
-(defun verilog-comment-indent (&optional arg)
+(defun verilog-comment-indent (&optional _arg)
   "Return the column number the line should be indented to.
-ARG is ignored, for `comment-indent-function' compatibility."
+_ARG is ignored, for `comment-indent-function' compatibility."
   (cond
    ((verilog-in-star-comment-p)
     (save-excursion
@@ -6650,8 +6643,8 @@ Be verbose about progress unless optional QUIET set."
              (forward-line 1))
            (unless quiet (message "")))))))
 
-(defun verilog-pretty-expr (&optional quiet myre)
-  "Line up expressions around point, optionally QUIET with regexp MYRE ignored."
+(defun verilog-pretty-expr (&optional quiet _myre)
+  "Line up expressions around point, optionally QUIET with regexp _MYRE ignored."
   (interactive)
   (if (not (verilog-in-comment-or-string-p))
       (save-excursion
@@ -6888,8 +6881,7 @@ Region is defined by B and EDPOS."
        ((b (prog2
                (beginning-of-line)
                (point-marker)
-             (end-of-line)))
-        (e (point-marker)))
+             (end-of-line))))
       (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t)
          (progn
            (replace-match " /* -#  ## */")
@@ -7081,24 +7073,6 @@ for matches of `str' and adding the occurrence tp `all' through point END."
       (forward-line 1)))
   verilog-all)
 
-(defun verilog-type-completion ()
-  "Calculate all possible completions for types."
-  (let ((start (point))
-       goon)
-    ;; Search for all reachable type declarations
-    (while (or (verilog-beg-of-defun)
-              (setq goon (not goon)))
-      (save-excursion
-       (if (and (< start (prog1 (save-excursion (verilog-end-of-defun)
-                                                (point))
-                           (forward-char 1)))
-                (verilog-re-search-forward
-                 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>"
-                 start t)
-                (not (match-end 1)))
-           ;; Check current type declaration
-           (verilog-get-completion-decl start))))))
-
 (defun verilog-var-completion ()
   "Calculate all possible completions for variables (or constants)."
   (let ((start (point)))
@@ -7182,6 +7156,7 @@ exact match, nil otherwise."
             ;; Return nil if there was no matching label
             nil
           ;; Get longest string common in the labels
+           ;; FIXME: Why not use `try-completion'?
           (let* ((elm (cdr verilog-all))
                  (match (car verilog-all))
                  (min (length match))
@@ -7218,6 +7193,7 @@ exact match, nil otherwise."
   "Complete word at current point.
 \(See also `verilog-toggle-completions', `verilog-type-keywords',
 and `verilog-separator-keywords'.)"
+  ;; FIXME: Provide completion-at-point-function.
   (interactive)
   (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
         (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
@@ -7789,6 +7765,7 @@ Signals must be in standard (base vector) form."
   "Return list of signals in IN-LIST that aren't parameters or numeric constants."
   (let (out-list)
     (while in-list
+      ;; Namespace intentionally short for AUTOs and compatibility
       (unless (boundp (intern (concat "vh-" (verilog-sig-name (car in-list)))))
        (setq out-list (cons (car in-list) out-list)))
       (setq in-list (cdr in-list)))
@@ -8086,7 +8063,7 @@ Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters."
 (defun verilog-read-decls ()
   "Compute signal declaration information for the current module at point.
 Return an array of [outputs inouts inputs wire reg assign const]."
-  (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max)))
+  (let ((end-mod-point (or (verilog-get-end-of-defun) (point-max)))
        (functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t)
        in-modport in-clocking ptype ign-prop
        sigs-in sigs-out sigs-inout sigs-var sigs-assign sigs-const
@@ -8592,7 +8569,7 @@ Outputs comments above subcell signals, for example:
            // Inputs
            .in  (in));"
   (save-excursion
-    (let ((end-mod-point (verilog-get-end-of-defun t))
+    (let ((end-mod-point (verilog-get-end-of-defun))
          st-point end-inst-point
          ;; below 3 modified by verilog-read-sub-decls-line
          sigs-out sigs-inout sigs-in sigs-intf sigs-intfd)
@@ -8887,7 +8864,7 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement."
 (defun verilog-read-instants ()
   "Parse module at point and return list of ( ( file instance ) ... )."
   (verilog-beg-of-defun-quick)
-  (let* ((end-mod-point (verilog-get-end-of-defun t))
+  (let* ((end-mod-point (verilog-get-end-of-defun))
         (state nil)
         (instants-list nil))
     (save-excursion
@@ -9034,12 +9011,14 @@ If found returns `verilog-read-auto-template-inside' structure."
   "Set the definition DEFNAME to the DEFVALUE in the given BUFFER.
 Optionally associate it with the specified enumeration ENUMNAME."
   (with-current-buffer (or buffer (current-buffer))
+    ;; Namespace intentionally short for AUTOs and compatibility
     (let ((mac (intern (concat "vh-" defname))))
       ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
       ;; Need to define to a constant if no value given
       (set (make-local-variable mac)
           (if (equal defvalue "") "1" defvalue)))
     (if enumname
+       ;; Namespace intentionally short for AUTOs and compatibility
        (let ((enumvar (intern (concat "venum-" enumname))))
          ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
          (unless (boundp enumvar) (set enumvar nil))
@@ -9424,10 +9403,12 @@ If undefined, and WING-IT, return just SYMBOL without the tick, else nil."
   (while (and symbol (string-match "^`" symbol))
     (setq symbol (substring symbol 1))
     (setq symbol
+         ;; Namespace intentionally short for AUTOs and compatibility
          (if (boundp (intern (concat "vh-" symbol)))
              ;; Emacs has a bug where boundp on a buffer-local
              ;; variable in only one buffer returns t in another.
              ;; This can confuse, so check for nil.
+             ;; Namespace intentionally short for AUTOs and compatibility
              (let ((val (eval (intern (concat "vh-" symbol)))))
                (if (eq val nil)
                    (if wing-it symbol nil)
@@ -9460,10 +9441,12 @@ If the variable vh-{symbol} is defined, substitute that value."
       (setq symbol (match-string 1 text))
       ;;(message symbol)
       (cond ((and
+             ;; Namespace intentionally short for AUTOs and compatibility
              (boundp (intern (concat "vh-" symbol)))
              ;; Emacs has a bug where boundp on a buffer-local
              ;; variable in only one buffer returns t in another.
              ;; This can confuse, so check for nil.
+             ;; Namespace intentionally short for AUTOs and compatibility
              (setq val (eval (intern (concat "vh-" symbol)))))
             (setq text (replace-match val nil nil text)))
            (t (setq ok nil)))))
@@ -9807,6 +9790,7 @@ those clocking block's signals."
          (setq out-list (cons (car in-list) out-list)))
       (setq in-list (cdr in-list)))
     ;; New scheme
+    ;; Namespace intentionally short for AUTOs and compatibility
     (let* ((enumvar (intern (concat "venum-" enum)))
           (enumlist (and (boundp enumvar) (eval enumvar))))
       (while enumlist
@@ -10033,19 +10017,6 @@ This repairs those mis-inserted by an AUTOARG."
     (when (looking-at ",")
       (delete-char 1))))
 
-(defun verilog-get-list (start end)
-  "Return the elements of a comma separated list between START and END."
-  (interactive)
-  (let ((my-list (list))
-       my-string)
-    (save-excursion
-      (while (< (point) end)
-       (when (re-search-forward "\\([^,{]+\\)" end t)
-         (setq my-string (verilog-string-remove-spaces (match-string 1)))
-         (setq my-list (nconc my-list (list my-string) ))
-         (goto-char (match-end 0))))
-      my-list)))
-
 (defun verilog-make-width-expression (range-exp)
   "Return an expression calculating the length of a range [x:y] in RANGE-EXP."
   ;; strip off the []
@@ -10799,7 +10770,7 @@ See the example in `verilog-auto-inout-modport'."
                (setq sigs (cdr sigs))))
            (verilog-insert-indent "// End of automatics\n")))))))
 
-(defun verilog-auto-inst-port-map (port-st)
+(defun verilog-auto-inst-port-map (_port-st)
   nil)
 
 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning
@@ -10887,7 +10858,7 @@ If PAR-VALUES replace final strings with these parameter values."
                             (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr))
                             (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr))
                             (prin1 (eval (car (read-from-string expr)))
-                                   (lambda (ch) ())))))
+                                   (lambda (_ch) ())))))
                     (if (numberp value) (setq value (number-to-string value)))
                     value))
                 (substring tpl-net (match-end 0))))))
@@ -11101,7 +11072,7 @@ Templates:
   it is a good idea to do this for all connections in a template,
   as then they will work for any width signal, and with AUTOWIRE.
   See PTL_BUS becoming PTL_BUSNEW below.
+
   Inside a template, a [] in a connection name (with nothing else inside
   the brackets) will be replaced by the same bus subscript as it is being
   connected to, or the [] will be removed if it is a single bit signal.
@@ -12303,7 +12274,7 @@ Limitations:
   Interface names must be resolvable to filenames.  See `verilog-auto-inst'.
 
 As with other autos, any inputs/outputs declared in the module
-will suppress the AUTO from redeclaring an input/output by
+will suppress the AUTO from redeclaring an inputs/outputs by
 the same name.
 
 An example:
@@ -13766,7 +13737,7 @@ and the case items."
   "Map containing mouse bindings for `verilog-mode'.")
 
 
-(defun verilog-highlight-region (beg end old-len)
+(defun verilog-highlight-region (beg end _old-len)
   "Colorize included files and modules in the (changed?) region.
 Clicking on the middle-mouse button loads them in a buffer (as in dired)."
   (when (or verilog-highlight-includes
index 8369afcbbc7e510f9a149f17f2a38e3ab187c5ee..7c28ecc78e02989ac6b2f907693cbc8e0c70635d 100644 (file)
@@ -1771,7 +1771,7 @@ See `ps-lpr-command'."
 
 (defcustom ps-print-region-function
   (if (memq system-type '(ms-dos windows-nt))
-      #'direct-ps-print-region-function
+      #'w32-direct-ps-print-region-function
     #'call-process-region)
   "Specify a function to print the region on a PostScript printer.
 See definition of `call-process-region' for calling conventions.  The fourth
@@ -6293,6 +6293,10 @@ If FACE is not a valid face name, use default face."
    ;; only background color, not a `real' face
    ((ps-face-background-color-p (car face-or-list))
     (vector 0 nil (ps-face-extract-color face-or-list)))
+   ;; Anonymous face.
+   ((keywordp (car face-or-list))
+    (vector 0 (plist-get face-or-list :foreground)
+           (plist-get face-or-list :background)))
    ;; list of faces
    (t
     (let ((effects 0)
index ec234b6514f5d46bfd9c04a9bd2a0164c0d27d2f..ad94663fc9679b53eb9e0249ea38bdfddc25fdb7 100644 (file)
@@ -1,4 +1,4 @@
-;;; rect.el --- rectangle functions for GNU Emacs
+;;; rect.el --- rectangle functions for GNU Emacs  -*- lexical-binding:t -*-
 
 ;; Copyright (C) 1985, 1999-2013 Free Software Foundation, Inc.
 
@@ -412,6 +412,162 @@ with a prefix argument, prompt for START-AT and FORMAT."
     (apply-on-rectangle 'rectangle-number-line-callback
                        start end format)))
 
+;;; New rectangle integration with kill-ring.
+
+;; FIXME: known problems with the new rectangle support:
+;; - lots of commands handle the region without paying attention to its
+;;   rectangular shape.
+
+(add-hook 'deactivate-mark-hook
+          (lambda () (rectangle-mark-mode -1)))
+
+(add-function :around redisplay-highlight-region-function
+              #'rectangle--highlight-for-redisplay)
+(add-function :around redisplay-unhighlight-region-function
+              #'rectangle--unhighlight-for-redisplay)
+(add-function :around region-extract-function
+              #'rectangle--extract-region)
+
+(defvar rectangle-mark-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [?\C-o] 'open-rectangle)
+    (define-key map [?\C-t] 'string-rectangle)
+    ;; (define-key map [remap open-line] 'open-rectangle)
+    ;; (define-key map [remap transpose-chars] 'string-rectangle)
+    map)
+  "Keymap used while marking a rectangular region.")
+
+;;;###autoload
+(define-minor-mode rectangle-mark-mode
+  "Toggle the region as rectangular.
+Activates the region if needed.  Only lasts until the region is deactivated."
+  nil nil nil
+  (when rectangle-mark-mode
+    (unless (region-active-p) (push-mark-command t))))
+
+(defun rectangle--extract-region (orig &optional delete)
+  (if (not rectangle-mark-mode)
+      (funcall orig delete)
+    (let* ((strs (funcall (if delete
+                              #'delete-extract-rectangle
+                            #'extract-rectangle)
+                          (region-beginning) (region-end)))
+           (str (mapconcat #'identity strs "\n")))
+      (when (eq last-command 'kill-region)
+        ;; Try to prevent kill-region from appending this to some
+        ;; earlier element.
+        (setq last-command 'kill-region-dont-append))
+      (when strs
+        (put-text-property 0 (length str) 'yank-handler
+                           `(rectangle--insert-for-yank ,strs t)
+                           str)
+        str))))
+
+(defun rectangle--insert-for-yank (strs)
+  (push (point) buffer-undo-list)
+  (let ((undo-at-start buffer-undo-list))
+    (insert-rectangle strs)
+    (setq yank-undo-function
+          (lambda (_start _end)
+            (undo-start)
+            (setcar undo-at-start nil)  ;Turn it into a boundary.
+            (while (not (eq pending-undo-list (cdr undo-at-start)))
+              (undo-more 1))))))
+
+(defun rectangle--highlight-for-redisplay (orig start end window rol)
+  (cond
+   ((not rectangle-mark-mode)
+    (funcall orig start end window rol))
+   ((and (eq 'rectangle (car-safe rol))
+         (eq (nth 1 rol) (buffer-chars-modified-tick))
+         (eq start (nth 2 rol))
+         (eq end (nth 3 rol)))
+    rol)
+   (t
+    (save-excursion
+      (let* ((nrol nil)
+             (old (if (eq 'rectangle (car-safe rol))
+                      (nthcdr 4 rol)
+                    (funcall redisplay-unhighlight-region-function rol)
+                    nil))
+             (ptcol (progn (goto-char start) (current-column)))
+             (markcol (progn (goto-char end) (current-column)))
+             (leftcol  (min ptcol markcol))
+             (rightcol (max ptcol markcol)))
+        (goto-char start)
+        (while (< (point) end)
+          (let* ((mleft (move-to-column leftcol))
+                 (left (point))
+                 (mright (move-to-column rightcol))
+                 (right (point))
+                 (ol
+                  (if (not old)
+                      (let ((ol (make-overlay left right)))
+                        (overlay-put ol 'window window)
+                        (overlay-put ol 'face 'region)
+                        ol)
+                    (let ((ol (pop old)))
+                      (move-overlay ol left right (current-buffer))
+                      ol))))
+            ;; `move-to-column' may stop before the column (if bumping into
+            ;; EOL) or overshoot it a little, when column is in the middle
+            ;; of a char.
+            (cond
+             ((< mleft leftcol)         ;`leftcol' is past EOL.
+              (overlay-put ol 'before-string
+                           (spaces-string (- leftcol mleft)))
+              (setq mright (max mright leftcol)))
+             ((and (> mleft leftcol)    ;`leftcol' is in the middle of a char.
+                   (eq (char-before left) ?\t))
+              (setq left (1- left))
+              (move-overlay ol left right)
+              (goto-char left)
+              (overlay-put ol 'before-string
+                           (spaces-string (- leftcol (current-column)))))
+             ((overlay-get ol 'before-string)
+              (overlay-put ol 'before-string nil)))
+            (cond
+             ((< mright rightcol)       ;`rightcol' is past EOL.
+              (let ((str (make-string (- rightcol mright) ?\s)))
+                (put-text-property 0 (length str) 'face 'region str)
+                ;; If cursor happens to be here, draw it *before* rather than
+                ;; after this highlighted pseudo-text.
+                (put-text-property 0 1 'cursor t str)
+                (overlay-put ol 'after-string str)))
+             ((and (> mright rightcol)  ;`rightcol' is in the middle of a char.
+                   (eq (char-before right) ?\t))
+              (setq right (1- right))
+              (move-overlay ol left right)
+             (if (= rightcol leftcol)
+                 (overlay-put ol 'after-string nil)
+               (goto-char right)
+               (let ((str (make-string
+                           (- rightcol (max leftcol (current-column))) ?\s)))
+                 (put-text-property 0 (length str) 'face 'region str)
+                 (when (= left right)
+                   ;; If cursor happens to be here, draw it *before* rather
+                   ;; than after this highlighted pseudo-text.
+                   (put-text-property 0 1 'cursor 1 str))
+                 (overlay-put ol 'after-string str))))
+             ((overlay-get ol 'after-string)
+              (overlay-put ol 'after-string nil)))
+            (when (= leftcol rightcol)
+              ;; Make zero-width rectangles visible!
+              (overlay-put ol 'after-string
+                           (concat (propertize " "
+                                               'face '(region (:height 0.2)))
+                                   (overlay-get ol 'after-string))))
+            (push ol nrol))
+          (forward-line 1))
+        (mapc #'delete-overlay old)
+        `(rectangle ,(buffer-chars-modified-tick) ,start ,end ,@nrol))))))
+
+(defun rectangle--unhighlight-for-redisplay (orig rol)
+  (if (not (eq 'rectangle (car-safe rol)))
+      (funcall orig rol)
+    (mapc #'delete-overlay (nthcdr 4 rol))
+    (setcar (cdr rol) nil)))
+
 (provide 'rect)
 
 ;;; rect.el ends here
index d92fb6809efcc8aa98ac51a6e62690beeaf5d1e1..9d7aba333c45a75f4f84268e6c4e0c2db78bbe00 100644 (file)
@@ -1,7 +1,7 @@
 ;;; replace.el --- replace commands for Emacs
 
-;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2013 Free
-;; Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2013
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Package: emacs
@@ -1793,7 +1793,12 @@ type them using Lisp syntax."
 
 (defun replace-eval-replacement (expression count)
   (let* ((replace-count count)
-         (replacement (eval expression)))
+         err
+         (replacement
+          (condition-case err
+              (eval expression)
+            (error
+             (error "Error evaluating replacement expression: %S" err)))))
     (if (stringp replacement)
         replacement
       (prin1-to-string replacement t))))
index d259851dc8524ed515df0085866e90c91fc95dd7..ca2088eeb24a66f5decd5fd05511dd465a5fa573 100644 (file)
@@ -377,14 +377,15 @@ Other major modes are defined by comparison with this one."
 (defvar hard-newline (propertize "\n" 'hard t 'rear-nonsticky '(hard))
   "Propertized string representing a hard newline character.")
 
-(defun newline (&optional arg)
+(defun newline (&optional arg interactive)
   "Insert a newline, and move to left margin of the new line if it's blank.
 If option `use-hard-newlines' is non-nil, the newline is marked with the
 text-property `hard'.
 With ARG, insert that many newlines.
 Call `auto-fill-function' if the current column number is greater
-than the value of `fill-column' and ARG is nil."
-  (interactive "*P")
+than the value of `fill-column' and ARG is nil.
+A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'."
+  (interactive "*P\np")
   (barf-if-buffer-read-only)
   ;; Call self-insert so that auto-fill, abbrev expansion etc. happens.
   ;; Set last-command-event to tell self-insert what to insert.
@@ -415,14 +416,20 @@ than the value of `fill-column' and ARG is nil."
             ;; starts a page.
             (or was-page-start
                 (move-to-left-margin nil t)))))
-    (unwind-protect
-        (progn
-          (add-hook 'post-self-insert-hook postproc)
+    (if (not interactive)
+        ;; FIXME: For non-interactive uses, many calls actually just want
+        ;; (insert "\n"), so maybe we should do just that, so as to avoid
+        ;; the risk of filling or running abbrevs unexpectedly.
+        (let ((post-self-insert-hook (list postproc)))
           (self-insert-command (prefix-numeric-value arg)))
-      ;; We first used let-binding to protect the hook, but that was naive
-      ;; since add-hook affects the symbol-default value of the variable,
-      ;; whereas the let-binding might only protect the buffer-local value.
-      (remove-hook 'post-self-insert-hook postproc)))
+      (unwind-protect
+          (progn
+            (add-hook 'post-self-insert-hook postproc)
+            (self-insert-command (prefix-numeric-value arg)))
+        ;; We first used let-binding to protect the hook, but that was naive
+        ;; since add-hook affects the symbol-default value of the variable,
+        ;; whereas the let-binding might only protect the buffer-local value.
+        (remove-hook 'post-self-insert-hook postproc))))
   nil)
 
 (defun set-hard-newline-properties (from to)
@@ -629,6 +636,67 @@ column specified by the function `current-left-margin'."
       (delete-horizontal-space t))
     (indent-according-to-mode)))
 
+(defcustom read-quoted-char-radix 8
+ "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'.
+Legitimate radix values are 8, 10 and 16."
+ :type '(choice (const 8) (const 10) (const 16))
+ :group 'editing-basics)
+
+(defun read-quoted-char (&optional prompt)
+  "Like `read-char', but do not allow quitting.
+Also, if the first character read is an octal digit,
+we read any number of octal digits and return the
+specified character code.  Any nondigit terminates the sequence.
+If the terminator is RET, it is discarded;
+any other terminator is used itself as input.
+
+The optional argument PROMPT specifies a string to use to prompt the user.
+The variable `read-quoted-char-radix' controls which radix to use
+for numeric input."
+  (let ((message-log-max nil) done (first t) (code 0) translated)
+    (while (not done)
+      (let ((inhibit-quit first)
+           ;; Don't let C-h get the help message--only help function keys.
+           (help-char nil)
+           (help-form
+            "Type the special character you want to use,
+or the octal character code.
+RET terminates the character code and is discarded;
+any other non-digit terminates the character code and is then used as input."))
+       (setq translated (read-key (and prompt (format "%s-" prompt))))
+       (if inhibit-quit (setq quit-flag nil)))
+      (if (integerp translated)
+         (setq translated (char-resolve-modifiers translated)))
+      (cond ((null translated))
+           ((not (integerp translated))
+            (setq unread-command-events
+                   (listify-key-sequence (this-single-command-raw-keys))
+                  done t))
+           ((/= (logand translated ?\M-\^@) 0)
+            ;; Turn a meta-character into a character with the 0200 bit set.
+            (setq code (logior (logand translated (lognot ?\M-\^@)) 128)
+                  done t))
+           ((and (<= ?0 translated)
+                  (< translated (+ ?0 (min 10 read-quoted-char-radix))))
+            (setq code (+ (* code read-quoted-char-radix) (- translated ?0)))
+            (and prompt (setq prompt (message "%s %c" prompt translated))))
+           ((and (<= ?a (downcase translated))
+                 (< (downcase translated)
+                     (+ ?a -10 (min 36 read-quoted-char-radix))))
+            (setq code (+ (* code read-quoted-char-radix)
+                          (+ 10 (- (downcase translated) ?a))))
+            (and prompt (setq prompt (message "%s %c" prompt translated))))
+           ((and (not first) (eq translated ?\C-m))
+            (setq done t))
+           ((not first)
+            (setq unread-command-events
+                   (listify-key-sequence (this-single-command-raw-keys))
+                  done t))
+           (t (setq code translated
+                    done t)))
+      (setq first nil))
+    code))
+
 (defun quoted-insert (arg)
   "Read next input character and insert it.
 This is useful for inserting control characters.
@@ -867,6 +935,18 @@ instead of deleted."
   :group 'killing
   :version "24.1")
 
+(defvar region-extract-function
+  (lambda (delete)
+    (when (region-beginning)
+      (if (eq delete 'delete-only)
+          (delete-region (region-beginning) (region-end))
+        (filter-buffer-substring (region-beginning) (region-end) delete))))
+  "Function to get the region's content.
+Called with one argument DELETE.
+If DELETE is `delete-only', then only delete the region and the return value
+is undefined.  If DELETE is nil, just return the content as a string.
+If anything else, delete the region and return its content as a string.")
+
 (defun delete-backward-char (n &optional killflag)
   "Delete the previous N characters (following if N is negative).
 If Transient Mark mode is enabled, the mark is active, and N is 1,
@@ -888,8 +968,8 @@ the end of the line."
              (= n 1))
         ;; If a region is active, kill or delete it.
         (if (eq delete-active-region 'kill)
-            (kill-region (region-beginning) (region-end))
-          (delete-region (region-beginning) (region-end))))
+            (kill-region (region-beginning) (region-end) 'region)
+           (funcall region-extract-function 'delete-only)))
        ;; In Overwrite mode, maybe untabify while deleting
        ((null (or (null overwrite-mode)
                   (<= n 0)
@@ -920,8 +1000,9 @@ KILLFLAG is set if N was explicitly specified."
              (= n 1))
         ;; If a region is active, kill or delete it.
         (if (eq delete-active-region 'kill)
-            (kill-region (region-beginning) (region-end))
-          (delete-region (region-beginning) (region-end))))
+            (kill-region (region-beginning) (region-end) 'region)
+          (funcall region-extract-function 'delete-only)))
+
        ;; Otherwise, do simple deletion.
        (t (delete-char n killflag))))
 
@@ -3410,7 +3491,7 @@ The comparison is done using `equal-including-properties'."
   :group 'killing
   :version "23.2")
 
-(defun kill-new (string &optional replace yank-handler)
+(defun kill-new (string &optional replace)
   "Make STRING the latest kill in the kill ring.
 Set `kill-ring-yank-pointer' to point to it.
 If `interprogram-cut-function' is non-nil, apply it to STRING.
@@ -3425,13 +3506,6 @@ When the yank handler has a non-nil PARAM element, the original STRING
 argument is not used by `insert-for-yank'.  However, since Lisp code
 may access and use elements from the kill ring directly, the STRING
 argument should still be a \"useful\" string for such uses."
-  (if (> (length string) 0)
-      (if yank-handler
-         (put-text-property 0 (length string)
-                            'yank-handler yank-handler string))
-    (if yank-handler
-       (signal 'args-out-of-range
-               (list string "yank-handler specified for empty string"))))
   (unless (and kill-do-not-save-duplicates
               ;; Due to text properties such as 'yank-handler that
               ;; can alter the contents to yank, comparison using
@@ -3459,19 +3533,15 @@ argument should still be a \"useful\" string for such uses."
   (setq kill-ring-yank-pointer kill-ring)
   (if interprogram-cut-function
       (funcall interprogram-cut-function string)))
-(set-advertised-calling-convention
- 'kill-new '(string &optional replace) "23.3")
 
-(defun kill-append (string before-p &optional yank-handler)
+(defun kill-append (string before-p)
   "Append STRING to the end of the latest kill in the kill ring.
 If BEFORE-P is non-nil, prepend STRING to the kill.
 If `interprogram-cut-function' is set, pass the resulting kill to it."
   (let* ((cur (car kill-ring)))
     (kill-new (if before-p (concat string cur) (concat cur string))
              (or (= (length cur) 0)
-                 (equal yank-handler (get-text-property 0 'yank-handler cur)))
-             yank-handler)))
-(set-advertised-calling-convention 'kill-append '(string before-p) "23.3")
+                 (equal nil (get-text-property 0 'yank-handler cur))))))
 
 (defcustom yank-pop-change-selection nil
   "Whether rotating the kill ring changes the window system selection.
@@ -3532,7 +3602,7 @@ move the yanking point; just return the Nth kill forward."
   :type 'boolean
   :group 'killing)
 
-(defun kill-region (beg end &optional yank-handler)
+(defun kill-region (beg end &optional region)
   "Kill (\"cut\") text between point and mark.
 This deletes the text from the buffer and saves it in the kill ring.
 The command \\[yank] can retrieve it from there.
@@ -3552,19 +3622,24 @@ Supply two arguments, character positions indicating the stretch of text
 Any command that calls this function is a \"kill command\".
 If the previous command was also a kill command,
 the text killed this time appends to the text killed last time
-to make one entry in the kill ring."
+to make one entry in the kill ring.
+
+The optional argument REGION if non-nil, indicates that we're not just killing
+some text between BEG and END, but we're killing the region."
   ;; Pass point first, then mark, because the order matters
   ;; when calling kill-append.
-  (interactive (list (point) (mark)))
+  (interactive (list (point) (mark) 'region))
   (unless (and beg end)
     (error "The mark is not set now, so there is no region"))
   (condition-case nil
-      (let ((string (filter-buffer-substring beg end t)))
+      (let ((string (if region
+                        (funcall region-extract-function 'delete)
+                      (filter-buffer-substring beg end 'delete))))
        (when string                    ;STRING is nil if BEG = END
          ;; Add that string to the kill ring, one way or another.
          (if (eq last-command 'kill-region)
-             (kill-append string (< end beg) yank-handler)
-           (kill-new string nil yank-handler)))
+             (kill-append string (< end beg))
+           (kill-new string nil)))
        (when (or string (eq last-command 'kill-region))
          (setq this-command 'kill-region))
        (setq deactivate-mark t)
@@ -3575,7 +3650,7 @@ to make one entry in the kill ring."
      ;; We should beep, in case the user just isn't aware of this.
      ;; However, there's no harm in putting
      ;; the region's text in the kill ring, anyway.
-     (copy-region-as-kill beg end)
+     (copy-region-as-kill beg end region)
      ;; Set this-command now, so it will be set even if we get an error.
      (setq this-command 'kill-region)
      ;; This should barf, if appropriate, and give us the correct error.
@@ -3585,26 +3660,31 @@ to make one entry in the kill ring."
        (barf-if-buffer-read-only)
        ;; If the buffer isn't read-only, the text is.
        (signal 'text-read-only (list (current-buffer)))))))
-(set-advertised-calling-convention 'kill-region '(beg end) "23.3")
 
 ;; copy-region-as-kill no longer sets this-command, because it's confusing
 ;; to get two copies of the text when the user accidentally types M-w and
 ;; then corrects it with the intended C-w.
-(defun copy-region-as-kill (beg end)
+(defun copy-region-as-kill (beg end &optional region)
   "Save the region as if killed, but don't kill it.
 In Transient Mark mode, deactivate the mark.
 If `interprogram-cut-function' is non-nil, also save the text for a window
 system cut and paste.
 
+The optional argument REGION if non-nil, indicates that we're not just copying
+some text between BEG and END, but we're copying the region.
+
 This command's old key binding has been given to `kill-ring-save'."
-  (interactive "r")
+  (interactive "r\np")
+  (let ((str (if region
+                 (funcall region-extract-function nil)
+               (filter-buffer-substring beg end))))
   (if (eq last-command 'kill-region)
-      (kill-append (filter-buffer-substring beg end) (< end beg))
-    (kill-new (filter-buffer-substring beg end)))
+        (kill-append str (< end beg))
+      (kill-new str)))
   (setq deactivate-mark t)
   nil)
 
-(defun kill-ring-save (beg end)
+(defun kill-ring-save (beg end &optional region)
   "Save the region as if killed, but don't kill it.
 In Transient Mark mode, deactivate the mark.
 If `interprogram-cut-function' is non-nil, also save the text for a window
@@ -3613,10 +3693,13 @@ system cut and paste.
 If you want to append the killed line to the last killed text,
 use \\[append-next-kill] before \\[kill-ring-save].
 
+The optional argument REGION if non-nil, indicates that we're not just copying
+some text between BEG and END, but we're copying the region.
+
 This command is similar to `copy-region-as-kill', except that it gives
 visual feedback indicating the extent of the region being copied."
-  (interactive "r")
-  (copy-region-as-kill beg end)
+  (interactive "r\np")
+  (copy-region-as-kill beg end region)
   ;; This use of called-interactively-p is correct because the code it
   ;; controls just gives the user visual feedback.
   (if (called-interactively-p 'interactive)
@@ -4196,8 +4279,7 @@ run `deactivate-mark-hook'."
                  (or (x-selection-owner-p 'PRIMARY)
                      (null (x-selection-exists-p 'PRIMARY))))
             (x-set-selection 'PRIMARY
-                             (buffer-substring (region-beginning)
-                                               (region-end))))))
+                              (funcall region-extract-function nil)))))
     (if (and (null force)
             (or (eq transient-mark-mode 'lambda)
                 (and (eq (car-safe transient-mark-mode) 'only)
@@ -4282,9 +4364,60 @@ mode is enabled.  Usually, such commands should use
 also checks the value of `use-empty-active-region'."
   (and transient-mark-mode mark-active))
 
-(defvar mark-ring nil
+
+(defvar redisplay-unhighlight-region-function
+  (lambda (rol) (when (overlayp rol) (delete-overlay rol))))
+
+(defvar redisplay-highlight-region-function
+  (lambda (start end window rol)
+    (if (not (overlayp rol))
+        (let ((nrol (make-overlay start end)))
+          (funcall redisplay-unhighlight-region-function rol)
+          (overlay-put nrol 'window window)
+          (overlay-put nrol 'face 'region)
+          nrol)
+      (unless (and (eq (overlay-buffer rol) (current-buffer))
+                   (eq (overlay-start rol) start)
+                   (eq (overlay-end rol) end))
+        (move-overlay rol start end (current-buffer)))
+      rol)))
+
+(defun redisplay--update-region-highlight (window)
+  (with-current-buffer (window-buffer window)
+    (let ((rol (window-parameter window 'internal-region-overlay)))
+      (if (not (region-active-p))
+          (funcall redisplay-unhighlight-region-function rol)
+        (let* ((pt (window-point window))
+               (mark (mark))
+               (start (min pt mark))
+               (end   (max pt mark))
+               (new
+                (funcall redisplay-highlight-region-function
+                         start end window rol)))
+          (unless (equal new rol)
+            (set-window-parameter window 'internal-region-overlay
+                                  new)))))))
+
+(defun redisplay--update-region-highlights (windows)
+  (with-demoted-errors "redisplay--update-region-highlights: %S"
+    (if (null windows)
+        (redisplay--update-region-highlight (selected-window))
+      (unless (listp windows) (setq windows (window-list-1 nil nil t)))
+      (if highlight-nonselected-windows
+          (mapc #'redisplay--update-region-highlight windows)
+        (let ((msw (and (window-minibuffer-p) (minibuffer-selected-window))))
+          (dolist (w windows)
+            (if (or (eq w (selected-window)) (eq w msw))
+                (redisplay--update-region-highlight w)
+              (funcall redisplay-unhighlight-region-function
+                       (window-parameter w 'internal-region-overlay)))))))))
+
+(add-function :before pre-redisplay-function
+              #'redisplay--update-region-highlights)
+
+
+(defvar-local mark-ring nil
   "The list of former marks of the current buffer, most recent first.")
-(make-variable-buffer-local 'mark-ring)
 (put 'mark-ring 'permanent-local t)
 
 (defcustom mark-ring-max 16
@@ -4459,7 +4592,6 @@ mode temporarily."
        (temp-highlight (eq (car-safe transient-mark-mode) 'only)))
     (if (null omark)
         (error "No mark set in this buffer"))
-    (deactivate-mark)
     (set-mark (point))
     (goto-char omark)
     (cond (temp-highlight
@@ -4901,7 +5033,16 @@ The value is a floating-point number."
               ;; When the text in the window is scrolled to the left,
               ;; display-based motion doesn't make sense (because each
               ;; logical line occupies exactly one screen line).
-              (not (> (window-hscroll) 0)))
+              (not (> (window-hscroll) 0))
+              ;; Likewise when the text _was_ scrolled to the left
+              ;; when the current run of vertical motion commands
+              ;; started.
+              (not (and (memq last-command
+                              `(next-line previous-line ,this-command))
+                        auto-hscroll-mode
+                        (numberp temporary-goal-column)
+                        (>= temporary-goal-column
+                           (- (window-width) hscroll-margin)))))
          (prog1 (line-move-visual arg noerror)
            ;; If we moved into a tall line, set vscroll to make
            ;; scrolling through tall images more smooth.
index 059d771032099c4122fd267d9ff0f800a8c42d5b..2394c73b879cdc08861ead5400651c5a159eb947 100644 (file)
@@ -397,8 +397,6 @@ from being initialized."
 
 (defvar no-blinking-cursor nil)
 
-(defvar default-frame-background-mode)
-
 (defvar pure-space-overflow nil
   "Non-nil if building Emacs overflowed pure space.")
 
@@ -443,8 +441,8 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
       (let* ((this-dir (car dirs))
             (contents (directory-files this-dir))
             (default-directory this-dir)
-            (canonicalized (if (fboundp 'untranslated-canonical-name)
-                               (untranslated-canonical-name this-dir))))
+            (canonicalized (if (fboundp 'w32-untranslated-canonical-name)
+                               (w32-untranslated-canonical-name this-dir))))
        ;; The Windows version doesn't report meaningful inode numbers, so
        ;; use the canonicalized absolute file name of the directory instead.
        (setq attrs (or canonicalized
@@ -491,20 +489,12 @@ It is the default value of the variable `top-level'."
   (if command-line-processed
       (message "Back to top level.")
     (setq command-line-processed t)
-    (let ((dir default-directory))
-      (with-current-buffer "*Messages*"
-        (messages-buffer-mode)
-        ;; Make it easy to do like "tail -f".
-        (set (make-local-variable 'window-point-insertion-type) t)
-        ;; Give *Messages* the same default-directory as *scratch*,
-        ;; just to keep things predictable.
-       (setq default-directory dir)))
-    ;; `user-full-name' is now known; reset its standard-value here.
-    (put 'user-full-name 'standard-value
-        (list (default-value 'user-full-name)))
-    ;; Look in each dir in load-path for a subdirs.el file.
-    ;; If we find one, load it, which will add the appropriate subdirs
-    ;; of that dir into load-path,
+
+    ;; Look in each dir in load-path for a subdirs.el file.  If we
+    ;; find one, load it, which will add the appropriate subdirs of
+    ;; that dir into load-path.  This needs to be done before setting
+    ;; the locale environment, because the latter might need to load
+    ;; some support files.
     ;; Look for a leim-list.el file too.  Loading it will register
     ;; available input methods.
     (let ((tail load-path)
@@ -525,6 +515,74 @@ It is the default value of the variable `top-level'."
         ;; the end, because the subdirs.el files may add elements to the end
         ;; of load-path and we want to take it into account.
         (setq tail (cdr tail))))
+
+    ;; Set the default strings to display in mode line for end-of-line
+    ;; formats that aren't native to this platform.  This should be
+    ;; done before calling set-locale-environment, as the latter might
+    ;; use these mnemonics.
+    (cond
+     ((memq system-type '(ms-dos windows-nt))
+      (setq eol-mnemonic-unix "(Unix)"
+           eol-mnemonic-mac  "(Mac)"))
+     (t                                   ; this is for Unix/GNU/Linux systems
+      (setq eol-mnemonic-dos  "(DOS)"
+           eol-mnemonic-mac  "(Mac)")))
+
+    (set-locale-environment nil)
+    ;; Decode all default-directory's (probably, only *scratch* exists
+    ;; at this point).  default-directory of *scratch* is the basis
+    ;; for many other file-name variables and directory lists, so it
+    ;; is important to decode it ASAP.
+    (when locale-coding-system
+      (save-excursion
+       (dolist (elt (buffer-list))
+         (set-buffer elt)
+         (if default-directory
+             (setq default-directory
+                   (decode-coding-string default-directory
+                                         locale-coding-system t)))))
+
+      ;; Decode all the important variables and directory lists, now
+      ;; that we know the locale's encoding.  This is because the
+      ;; values of these variables are until here unibyte undecoded
+      ;; strings created by build_unibyte_string.  data-directory in
+      ;; particular is used to construct many other standard directory
+      ;; names, so it must be decoded ASAP.
+      ;; Note that charset-map-path cannot be decoded here, since we
+      ;; could then be trapped in infinite recursion below, when we
+      ;; load subdirs.el, because encoding a directory name might need
+      ;; to load a charset map, which will want to encode
+      ;; charset-map-path, which will want to load the same charset
+      ;; map...  So decoding of charset-map-path is delayed until
+      ;; further down below.
+      (dolist (pathsym '(load-path exec-path))
+       (let ((path (symbol-value pathsym)))
+         (if (listp path)
+             (set pathsym (mapcar (lambda (dir)
+                                    (decode-coding-string
+                                     dir
+                                     locale-coding-system t))
+                               path)))))
+      (dolist (filesym '(data-directory doc-directory exec-directory
+                                       installation-directory
+                                       invocation-directory invocation-name
+                                       source-directory
+                                       shared-game-score-directory))
+       (let ((file (symbol-value filesym)))
+         (if (stringp file)
+             (set filesym (decode-coding-string file locale-coding-system t))))))
+
+    (let ((dir default-directory))
+      (with-current-buffer "*Messages*"
+        (messages-buffer-mode)
+        ;; Make it easy to do like "tail -f".
+        (set (make-local-variable 'window-point-insertion-type) t)
+        ;; Give *Messages* the same default-directory as *scratch*,
+        ;; just to keep things predictable.
+       (setq default-directory dir)))
+    ;; `user-full-name' is now known; reset its standard-value here.
+    (put 'user-full-name 'standard-value
+        (list (default-value 'user-full-name)))
     ;; If the PWD environment variable isn't accurate, delete it.
     (let ((pwd (getenv "PWD")))
       (and (stringp pwd)
@@ -538,6 +596,16 @@ It is the default value of the variable `top-level'."
               (setq process-environment
                     (delete (concat "PWD=" pwd)
                             process-environment)))))
+    ;; Now, that other directories were searched, and any charsets we
+    ;; need for encoding them are already loaded, we are ready to
+    ;; decode charset-map-path.
+    (if (listp charset-map-path)
+       (setq charset-map-path
+             (mapcar (lambda (dir)
+                       (decode-coding-string
+                        dir
+                        locale-coding-system t))
+                     charset-map-path)))
     (setq default-directory (abbreviate-file-name default-directory))
     (let ((old-face-font-rescale-alist face-font-rescale-alist))
       (unwind-protect
@@ -758,18 +826,6 @@ Amongst another things, it parses the command-line arguments."
   ;;! ;; Choose a good default value for split-window-keep-point.
   ;;! (setq split-window-keep-point (> baud-rate 2400))
 
-  ;; Set the default strings to display in mode line for
-  ;; end-of-line formats that aren't native to this platform.
-  (cond
-   ((memq system-type '(ms-dos windows-nt))
-    (setq eol-mnemonic-unix "(Unix)"
-          eol-mnemonic-mac  "(Mac)"))
-   (t                                   ; this is for Unix/GNU/Linux systems
-    (setq eol-mnemonic-dos  "(DOS)"
-          eol-mnemonic-mac  "(Mac)")))
-
-  (set-locale-environment nil)
-
   ;; Convert preloaded file names in load-history to absolute.
   (let ((simple-file-name
         ;; Look for simple.el or simple.elc and use their directory
@@ -803,7 +859,7 @@ please check its value")
                    load-history))))
 
   ;; Convert the arguments to Emacs internal representation.
-  (let ((args (cdr command-line-args)))
+  (let ((args command-line-args))
     (while args
       (setcar args
              (decode-coding-string (car args) locale-coding-system t))
@@ -1213,19 +1269,6 @@ the `--debug-init' option to view a complete error backtrace."
   (setq after-init-time (current-time))
   (run-hooks 'after-init-hook)
 
-  ;; Decode all default-directory.
-  (if (and (default-value 'enable-multibyte-characters) locale-coding-system)
-      (save-excursion
-       (dolist (elt (buffer-list))
-         (set-buffer elt)
-         (if default-directory
-             (setq default-directory
-                   (decode-coding-string default-directory
-                                         locale-coding-system t))))
-       (setq command-line-default-directory
-             (decode-coding-string command-line-default-directory
-                                   locale-coding-system t))))
-
   ;; If *scratch* exists and init file didn't change its mode, initialize it.
   (if (get-buffer "*scratch*")
       (with-current-buffer "*scratch*"
@@ -2089,12 +2132,11 @@ A fancy display is used on graphic displays, normal otherwise."
            ;; This approach loses for "-batch -L DIR --eval "(require foo)",
            ;; if foo is intended to be found in DIR.
            ;;
-           ;; ;; The directories listed in --directory/-L options will *appear*
-           ;; ;; at the front of `load-path' in the order they appear on the
-           ;; ;; command-line.  We cannot do this by *placing* them at the front
-           ;; ;; in the order they appear, so we need this variable to hold them,
-           ;; ;; temporarily.
-           ;; extra-load-path
+           ;; The directories listed in --directory/-L options will *appear*
+           ;; at the front of `load-path' in the order they appear on the
+           ;; command-line.  We cannot do this by *placing* them at the front
+           ;; in the order they appear, so we need this variable to hold them,
+           ;; temporarily.
            ;;
            ;; To DTRT we keep track of the splice point and modify `load-path'
            ;; straight away upon any --directory/-L option.
@@ -2174,13 +2216,22 @@ A fancy display is used on graphic displays, normal otherwise."
                   (eval (read (or argval (pop command-line-args-left)))))
 
                  ((member argi '("-L" "-directory"))
-                  (setq tem (expand-file-name
-                             (command-line-normalize-file-name
-                              (or argval (pop command-line-args-left)))))
-                  (cond (splice (setcdr splice (cons tem (cdr splice)))
-                                (setq splice (cdr splice)))
-                        (t (setq load-path (cons tem load-path)
-                                 splice load-path))))
+                  ;; -L :/foo adds /foo to the _end_ of load-path.
+                  (let (append)
+                    (if (string-match-p
+                         "\\`:"
+                         (setq tem (or argval (pop command-line-args-left))))
+                        (setq tem (substring tem 1)
+                              append t))
+                    (setq tem (expand-file-name
+                               (command-line-normalize-file-name tem)))
+                    (cond (append (setq load-path
+                                        (append load-path (list tem)))
+                                  (if splice (setq splice load-path)))
+                          (splice (setcdr splice (cons tem (cdr splice)))
+                                  (setq splice (cdr splice)))
+                          (t (setq load-path (cons tem load-path)
+                                   splice load-path)))))
 
                  ((member argi '("-l" "-load"))
                   (let* ((file (command-line-normalize-file-name
index 952b9b601dc27b58193eb24ec3f5a3b691df762e..31798b4484949758ec2d7085a8fb5aa01c22d48e 100644 (file)
 ;; Beware: while this file has tag `utf-8', before it's compiled, it gets
 ;; loaded as "raw-text", so non-ASCII chars won't work right during bootstrap.
 
-(defvar custom-declare-variable-list nil
-  "Record `defcustom' calls made before `custom.el' is loaded to handle them.
-Each element of this list holds the arguments to one call to `defcustom'.")
-
-;; Use this, rather than defcustom, in subr.el and other files loaded
-;; before custom.el.
-(defun custom-declare-variable-early (&rest arguments)
-  (setq custom-declare-variable-list
-       (cons arguments custom-declare-variable-list)))
-
 (defmacro declare-function (_fn _file &optional _arglist _fileonly)
   "Tell the byte-compiler that function FN is defined, in FILE.
 Optional ARGLIST is the argument list used by the function.
@@ -302,8 +292,7 @@ In Emacs, the convention is that error messages start with a capital
 letter but *do not* end with a period.  Please follow this convention
 for the sake of consistency."
   (declare (advertised-calling-convention (string &rest args) "23.1"))
-  (while t
-    (signal 'error (list (apply 'format args)))))
+  (signal 'error (list (apply 'format args))))
 
 (defun user-error (format &rest args)
   "Signal a pilot error, making error message by passing all args to `format'.
@@ -313,8 +302,7 @@ for the sake of consistency.
 This is just like `error' except that `user-error's are expected to be the
 result of an incorrect manipulation on the part of the user, rather than the
 result of an actual problem."
-  (while t
-    (signal 'user-error (list (apply #'format format args)))))
+  (signal 'user-error (list (apply #'format format args))))
 
 (defun define-error (name message &optional parent)
   "Define NAME as a new error signal.
@@ -586,7 +574,15 @@ saving keyboard macros (see `edmacro-mode')."
 (defun undefined ()
   "Beep to tell the user this binding is undefined."
   (interactive)
-  (ding))
+  (ding)
+  (message "%s is undefined" (key-description (this-single-command-keys)))
+  (setq defining-kbd-macro nil)
+  (force-mode-line-update)
+  ;; If this is a down-mouse event, don't reset prefix-arg;
+  ;; pass it to the command run by the up event.
+  (setq prefix-arg
+        (when (memq 'down (event-modifiers last-command-event))
+          current-prefix-arg)))
 
 ;; Prevent the \{...} documentation construct
 ;; from mentioning keys that run this command.
@@ -1541,13 +1537,14 @@ other hooks, such as major mode hooks, can do the job."
                             (byte-compile-log-warning msg t :error))))
                (code
                 (macroexp-let2 macroexp-copyable-p x element
-                  `(unless ,(if compare-fn
-                                (progn
-                                  (require 'cl-lib)
-                                  `(cl-member ,x ,sym :test ,compare-fn))
-                              ;; For bootstrapping reasons, don't rely on
-                              ;; cl--compiler-macro-member for the base case.
-                              `(member ,x ,sym))
+                  `(if ,(if compare-fn
+                            (progn
+                              (require 'cl-lib)
+                              `(cl-member ,x ,sym :test ,compare-fn))
+                          ;; For bootstrapping reasons, don't rely on
+                          ;; cl--compiler-macro-member for the base case.
+                          `(member ,x ,sym))
+                       ,sym
                      ,(if append
                           `(setq ,sym (append ,sym (list ,x)))
                         `(push ,x ,sym))))))
@@ -1934,17 +1931,6 @@ It can be retrieved with `(process-get PROCESS PROPNAME)'."
 \f
 ;;;; Input and display facilities.
 
-(defvar read-quoted-char-radix 8
-  "Radix for \\[quoted-insert] and other uses of `read-quoted-char'.
-Legitimate radix values are 8, 10 and 16.")
-
-(custom-declare-variable-early
- 'read-quoted-char-radix 8
- "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'.
-Legitimate radix values are 8, 10 and 16."
- :type '(choice (const 8) (const 10) (const 16))
- :group 'editing-basics)
-
 (defconst read-key-empty-map (make-sparse-keymap))
 
 (defvar read-key-delay 0.01) ;Fast enough for 100Hz repeat rate, hopefully.
@@ -2000,61 +1986,6 @@ some sort of escape sequence, the ambiguity is resolved via `read-key-delay'."
       (cancel-timer timer)
       (use-global-map old-global-map))))
 
-(defun read-quoted-char (&optional prompt)
-  "Like `read-char', but do not allow quitting.
-Also, if the first character read is an octal digit,
-we read any number of octal digits and return the
-specified character code.  Any nondigit terminates the sequence.
-If the terminator is RET, it is discarded;
-any other terminator is used itself as input.
-
-The optional argument PROMPT specifies a string to use to prompt the user.
-The variable `read-quoted-char-radix' controls which radix to use
-for numeric input."
-  (let ((message-log-max nil) done (first t) (code 0) translated)
-    (while (not done)
-      (let ((inhibit-quit first)
-           ;; Don't let C-h get the help message--only help function keys.
-           (help-char nil)
-           (help-form
-            "Type the special character you want to use,
-or the octal character code.
-RET terminates the character code and is discarded;
-any other non-digit terminates the character code and is then used as input."))
-       (setq translated (read-key (and prompt (format "%s-" prompt))))
-       (if inhibit-quit (setq quit-flag nil)))
-      (if (integerp translated)
-         (setq translated (char-resolve-modifiers translated)))
-      (cond ((null translated))
-           ((not (integerp translated))
-            (setq unread-command-events
-                   (listify-key-sequence (this-single-command-raw-keys))
-                  done t))
-           ((/= (logand translated ?\M-\^@) 0)
-            ;; Turn a meta-character into a character with the 0200 bit set.
-            (setq code (logior (logand translated (lognot ?\M-\^@)) 128)
-                  done t))
-           ((and (<= ?0 translated)
-                  (< translated (+ ?0 (min 10 read-quoted-char-radix))))
-            (setq code (+ (* code read-quoted-char-radix) (- translated ?0)))
-            (and prompt (setq prompt (message "%s %c" prompt translated))))
-           ((and (<= ?a (downcase translated))
-                 (< (downcase translated)
-                     (+ ?a -10 (min 36 read-quoted-char-radix))))
-            (setq code (+ (* code read-quoted-char-radix)
-                          (+ 10 (- (downcase translated) ?a))))
-            (and prompt (setq prompt (message "%s %c" prompt translated))))
-           ((and (not first) (eq translated ?\C-m))
-            (setq done t))
-           ((not first)
-            (setq unread-command-events
-                   (listify-key-sequence (this-single-command-raw-keys))
-                  done t))
-           (t (setq code translated
-                    done t)))
-      (setq first nil))
-    code))
-
 (defvar read-passwd-map
   ;; BEWARE: `defconst' would purecopy it, breaking the sharing with
   ;; minibuffer-local-map along the way!
@@ -2451,14 +2382,6 @@ This finishes the change group by reverting all of its changes."
 (define-obsolete-function-alias 'redraw-modeline
   'force-mode-line-update "24.3")
 
-(defun force-mode-line-update (&optional all)
-  "Force redisplay of the current buffer's mode line and header line.
-With optional non-nil ALL, force redisplay of all mode lines and
-header lines.  This function also forces recomputation of the
-menu bar menus and the frame title."
-  (if all (with-current-buffer (other-buffer)))
-  (set-buffer-modified-p (buffer-modified-p)))
-
 (defun momentary-string-display (string pos &optional exit-char message)
   "Momentarily display STRING in the buffer at POS.
 Display remains until next event is input.
@@ -2565,57 +2488,6 @@ mode.")
 Various programs in Emacs store information in this directory.
 Note that this should end with a directory separator.
 See also `locate-user-emacs-file'.")
-
-(custom-declare-variable-early 'user-emacs-directory-warning t
-  "Non-nil means warn if cannot access `user-emacs-directory'.
-Set this to nil at your own risk..."
-  :type 'boolean
-  :group 'initialization
-  :version "24.4")
-
-(defun locate-user-emacs-file (new-name &optional old-name)
-  "Return an absolute per-user Emacs-specific file name.
-If NEW-NAME exists in `user-emacs-directory', return it.
-Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
-Else return NEW-NAME in `user-emacs-directory', creating the
-directory if it does not exist."
-  (convert-standard-filename
-   (let* ((home (concat "~" (or init-file-user "")))
-         (at-home (and old-name (expand-file-name old-name home)))
-          (bestname (abbreviate-file-name
-                     (expand-file-name new-name user-emacs-directory))))
-     (if (and at-home (not (file-readable-p bestname))
-              (file-readable-p at-home))
-        at-home
-       ;; Make sure `user-emacs-directory' exists,
-       ;; unless we're in batch mode or dumping Emacs.
-       (or noninteractive
-          purify-flag
-          (let (errtype)
-            (if (file-directory-p user-emacs-directory)
-                (or (file-accessible-directory-p user-emacs-directory)
-                    (setq errtype "access"))
-              (let ((umask (default-file-modes)))
-                (unwind-protect
-                    (progn
-                      (set-default-file-modes ?\700)
-                      (condition-case nil
-                          (make-directory user-emacs-directory)
-                        (error (setq errtype "create"))))
-                  (set-default-file-modes umask))))
-            (when (and errtype
-                       user-emacs-directory-warning
-                       (not (get 'user-emacs-directory-warning 'this-session)))
-              ;; Only warn once per Emacs session.
-              (put 'user-emacs-directory-warning 'this-session t)
-              (display-warning 'initialization
-                               (format "\
-Unable to %s `user-emacs-directory' (%s).
-Any data that would normally be written there may be lost!
-If you never want to see this message again,
-customize the variable `user-emacs-directory-warning'."
-                                       errtype user-emacs-directory)))))
-       bestname))))
 \f
 ;;;; Misc. useful functions.
 
@@ -2817,6 +2689,7 @@ if it's an autoloaded macro."
     val))
 \f
 ;;;; Support for yanking and text properties.
+;; Why here in subr.el rather than in simple.el?  --Stef
 
 (defvar yank-handled-properties)
 (defvar yank-excluded-properties)
@@ -4597,11 +4470,14 @@ Usually the separator is \".\", but it can be any other string.")
 
 
 (defconst version-regexp-alist
-  '(("^[-_+ ]?alpha$"           . -3)
-    ("^[-_+]$"                  . -3) ; treat "1.2.3-20050920" and "1.2-3" as alpha releases
-    ("^[-_+ ]cvs$"              . -3) ; treat "1.2.3-CVS" as alpha release
-    ("^[-_+ ]?beta$"            . -2)
-    ("^[-_+ ]?\\(pre\\|rcc\\)$" . -1))
+  '(("^[-_+ ]?snapshot$"                                 . -4)
+    ;; treat "1.2.3-20050920" and "1.2-3" as snapshot releases
+    ("^[-_+]$"                                           . -4)
+    ;; treat "1.2.3-CVS" as snapshot release
+    ("^[-_+ ]?\\(cvs\\|git\\|bzr\\|svn\\|hg\\|darcs\\)$" . -4)
+    ("^[-_+ ]?alpha$"                                    . -3)
+    ("^[-_+ ]?beta$"                                     . -2)
+    ("^[-_+ ]?\\(pre\\|rc\\)$"                           . -1))
   "Specify association between non-numeric version and its priority.
 
 This association is used to handle version string like \"1.0pre2\",
@@ -4609,6 +4485,8 @@ This association is used to handle version string like \"1.0pre2\",
 non-numeric part of a version string to an integer.  For example:
 
    String Version    Integer List Version
+   \"0.9snapshot\"     (0  9 -4)
+   \"1.0-git\"         (1  0 -4)
    \"1.0pre2\"         (1  0 -1 2)
    \"1.0PRE2\"         (1  0 -1 2)
    \"22.8beta3\"       (22 8 -2 3)
@@ -4665,6 +4543,8 @@ Examples of version conversion:
    \"0.9alpha1\"       (0  9 -3 1)
    \"0.9AlphA1\"       (0  9 -3 1)
    \"0.9alpha\"        (0  9 -3)
+   \"0.9snapshot\"     (0  9 -4)
+   \"1.0-git\"         (1  0 -4)
 
 See documentation for `version-separator' and `version-regexp-alist'."
   (or (and (stringp ver) (> (length ver) 0))
@@ -4786,19 +4666,18 @@ If all LST elements are zeros or LST is nil, return zero."
 Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\",
 etc.  That is, the trailing \".0\"s are insignificant.  Also, version
 string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
-which is higher than \"1alpha\".  Also, \"-CVS\" and \"-NNN\" are treated
-as alpha versions."
+which is higher than \"1alpha\", which is higher than \"1snapshot\".
+Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
   (version-list-< (version-to-list v1) (version-to-list v2)))
 
-
 (defun version<= (v1 v2)
   "Return t if version V1 is lower (older) than or equal to V2.
 
 Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\",
 etc.  That is, the trailing \".0\"s are insignificant.  Also, version
 string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
-which is higher than \"1alpha\".  Also, \"-CVS\" and \"-NNN\" are treated
-as alpha versions."
+which is higher than \"1alpha\", which is higher than \"1snapshot\".
+Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
   (version-list-<= (version-to-list v1) (version-to-list v2)))
 
 (defun version= (v1 v2)
@@ -4807,8 +4686,8 @@ as alpha versions."
 Note that version string \"1\" is equal to \"1.0\", \"1.0.0\", \"1.0.0.0\",
 etc.  That is, the trailing \".0\"s are insignificant.  Also, version
 string \"1\" is higher (newer) than \"1pre\", which is higher than \"1beta\",
-which is higher than \"1alpha\".  Also, \"-CVS\" and \"-NNN\" are treated
-as alpha versions."
+which is higher than \"1alpha\", which is higher than \"1snapshot\".
+Also, \"-GIT\", \"-CVS\" and \"-NNN\" are treated as snapshot versions."
   (version-list-= (version-to-list v1) (version-to-list v2)))
 
 \f
index bc9cab375bf5e521850b101b67e3295f23d9b089..03244aaeb8aaf2f354335600b10609bce3935d91 100644 (file)
@@ -899,6 +899,25 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
 
   (x-open-connection (system-name) nil t)
 
+  ;; Add GNUStep menu items Services, Hide and Quit.  Rename Help to Info
+  ;; and put it first (i.e. omit from menu-bar-final-items.
+  (if (featurep 'gnustep)
+      (progn
+       (setq menu-bar-final-items '(buffer services hide-app quit))
+
+       ;; If running under GNUstep, "Help" is moved and renamed "Info".
+       (bindings--define-key global-map [menu-bar help-menu]
+         (cons "Info" menu-bar-help-menu))
+       (bindings--define-key global-map [menu-bar quit]
+         '(menu-item "Quit" save-buffers-kill-emacs
+                     :help "Save unsaved buffers, then exit"))
+       (bindings--define-key global-map [menu-bar hide-app]
+         '(menu-item "Hide" ns-do-hide-emacs
+                     :help "Hide Emacs"))
+       (bindings--define-key global-map [menu-bar services]
+         (cons "Services" (make-sparse-keymap "Services")))))
+
+
   (dolist (service (ns-list-services))
       (if (eq (car service) 'undefined)
          (ns-define-service (cdr service))
index 9690a5a7d75b7d5dc13bda77da4bafa24781a24d..513a99d4914e3b674dd8cbd80962ed8867a707ec 100644 (file)
@@ -216,13 +216,29 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
        ;; the version we were compiled against.  (If we were compiled
        ;; without PNG support, libpng-version's value is -1.)
        (if (>= libpng-version 10400)
-          ;; libpng14-14.dll is libpng 1.4.3 from GTK+
-          '(png "libpng14-14.dll" "libpng14.dll")
+          (let ((major (/ libpng-version 10000))
+                (minor (mod (/ libpng-version 100) 10)))
+            (list 'png
+                  ;; libpngXY.dll is the default name when building
+                  ;; with CMake or from a lpngXYY tarball on w32,
+                  ;; libpngXY-XY.dll is the DLL name when building
+                  ;; with libtool / autotools
+                  (format "libpng%d%d.dll" major minor)
+                  (format "libpng%d%d-%d%d.dll" major minor major minor)))
         '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll"
               ;; these are libpng 1.2.8 from GTK+
               "libpng13d.dll" "libpng13.dll"))
-       '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
-       '(tiff "libtiff3.dll" "libtiff.dll")
+       '(tiff "libtiff-5.dll" "libtiff3.dll" "libtiff.dll")
+       (if (> libjpeg-version 62)
+          ;; Versions of libjpeg after 6b are incompatible with
+          ;; earlier versions, and each of versions 7, 8, and 9 is
+          ;; also incompatible with the preceding ones (the core data
+          ;; structures used for communications with the library
+          ;; gained additional members with each new version).  So we
+          ;; must use only the version of the library which Emacs was
+          ;; compiled against.
+          (list 'jpeg (format "libjpeg-%d.dll" (/ libjpeg-version 10)))
+        '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll"))
        ;; Versions of giflib 5.0.0 and later changed signatures of
        ;; several functions used by Emacs, which makes those versions
        ;; incompatible with previous ones.  We select the correct
index 119b4b0459389a89b1bf88c8d8535c271258bcf8..73b9362da760e17574f695c618c9d17d6723e94a 100644 (file)
@@ -329,13 +329,24 @@ places."
              (and (memq (preceding-char) '(?\t ?\s))
                   (eq (char-syntax (following-char)) ?w)))))))
 
+(defun fill-single-char-nobreak-p ()
+  "Return t if point is placed just after a 1-letter word.
+This is used in `fill-nobreak-predicate' to prevent breaking line just
+after a 1-letter word (usually conjunction or preposition) which is
+considered composition error in Polish and Czech typography."
+  (save-excursion
+    (skip-chars-backward " \t")
+    (backward-char 2)
+    (looking-at "[[:space:]][[:alpha:]]")))
+
 (defcustom fill-nobreak-predicate nil
   "List of predicates for recognizing places not to break a line.
 The predicates are called with no arguments, with point at the place to
 be tested.  If it returns t, fill commands do not break the line there."
   :group 'fill
   :type 'hook
-  :options '(fill-french-nobreak-p fill-single-word-nobreak-p))
+  :options '(fill-french-nobreak-p fill-single-word-nobreak-p
+             fill-single-char-nobreak-p))
 
 (defcustom fill-nobreak-invisible nil
   "Non-nil means that fill commands do not break lines in invisible text."
index a361bdae64bde37e5e767d8d40a325d58f2f8385..651aaa2668845faa782465fe9fea96f47a14d81d 100644 (file)
@@ -2649,8 +2649,12 @@ if defined."
       (message "Starting \"%s\" process..." (file-name-nondirectory prog))
       (if look-p
           nil
+        (insert "^" word)
+        ;; When there are no wildcards, append one, for consistency
+        ;; with `look' behavior.
+        (unless wild-p (insert "*"))
+        (insert "$")
         ;; Convert * to .*
-        (insert "^" word "$")
         (while (search-backward "*" nil t) (insert "."))
         (setq word (buffer-string))
         (erase-buffer))
@@ -3785,8 +3789,7 @@ Standard ispell choices are then available."
          (or (string= word "")         ; Will give you every word
              (ispell-lookup-words
               (concat (and interior-frag "*") word
-                      (if (or interior-frag (null ispell-look-p))
-                          "*"))
+                      (and interior-frag "*"))
               (or ispell-complete-word-dict
                   ispell-alternate-dictionary))))
     (cond ((eq possibilities t)
index a99791e5427c1dafeaaad99917a44380cb23656c..ffabb134c83a4f78aa3c9db777551ddd8e530bf3 100644 (file)
@@ -350,20 +350,38 @@ of master file."
     ;; Return the list
     docstruct))
 
+(defun reftex-using-biblatex-p ()
+  "Return non-nil iff we are using biblatex rather than bibtex."
+  (if (boundp 'TeX-active-styles)
+      ;; the sophisticated AUCTeX way
+      (member "biblatex" TeX-active-styles)
+    ;; poor-man's check...
+    (save-excursion
+      (re-search-forward "^[^%]*\\\\usepackage.*{biblatex}" nil t))))
+
 (defun reftex-locate-bibliography-files (master-dir &optional files)
-  "Scan buffer for bibliography macro and return file list."
+  "Scan buffer for bibliography macros and return file list."
   (unless files
     (save-excursion
       (goto-char (point-min))
-      (if (re-search-forward
-           (concat
-;           "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
-            "\\(^\\)[^%\n\r]*\\\\\\("
-            (mapconcat 'identity reftex-bibliography-commands "\\|")
-            "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t)
-          (setq files
-                (split-string (reftex-match-string 4)
-                              "[ \t\n\r]*,[ \t\n\r]*")))))
+      ;; when biblatex is used, multiple \bibliography or
+      ;; \addbibresource macros are allowed.  With plain bibtex, only
+      ;; the first is used.
+      (let ((using-biblatex (reftex-using-biblatex-p))
+           (again t))
+       (while (and again
+                   (re-search-forward
+                    (concat
+                     ;;           "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+                     "\\(^\\)[^%\n\r]*\\\\\\("
+                     (mapconcat 'identity reftex-bibliography-commands "\\|")
+                     "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t))
+         (setq files
+               (append files
+                       (split-string (reftex-match-string 4)
+                                     "[ \t\n\r]*,[ \t\n\r]*")))
+         (unless using-biblatex
+           (setq again nil))))))
   (when files
     (setq files
           (mapcar
index e44f12d1db8e1b39fe59f73572f7fe971e95c701..891912c0a91c48c9f8990224b6772500f42b185b 100644 (file)
@@ -535,7 +535,7 @@ If this is nil, then `diary-file' will be used instead."
     (goto-char (point-min))
     (let (list)
       (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
-        (add-to-list 'list (remember-diary-convert-entry (match-string 1))))
+        (push (remember-diary-convert-entry (match-string 1)) list))
       (when list
         (diary-make-entry (mapconcat 'identity list "\n")
                           nil remember-diary-file))
index a045af8522fd645c1027e2e33f154fa5f86506f2..6c97ce6372bcf79fad0ed98a27fdad2bfdb789ff 100644 (file)
@@ -121,9 +121,10 @@ Turning on Paragraph-Indent minor mode runs the normal hook
                (concat ps-re paragraph-start)))))
   ;; Change the indentation function.
   (if paragraph-indent-minor-mode
-      (set (make-local-variable 'indent-line-function) 'indent-to-left-margin)
-    (if (eq indent-line-function 'indent-to-left-margin)
-        (set (make-local-variable 'indent-line-function) 'indent-region))))
+      (add-function :override (local 'indent-line-function)
+                    #'indent-to-left-margin)
+    (remove-function (local 'indent-line-function)
+                     #'indent-to-left-margin)))
 
 (defalias 'indented-text-mode 'text-mode)
 
index b67a32a24f72043f0c9268facd74f91682ec5b5c..0887c7f1fe49b625a251b2edf6e5b514ffb921f7 100644 (file)
@@ -476,19 +476,22 @@ looks like an email address, \"ftp://\" if it starts with
 ;; matches that straddle the start position so we search forwards once
 ;; and then back repeatedly and then back up a char at a time.
 
-(defun thing-at-point-looking-at (regexp)
+(defun thing-at-point-looking-at (regexp &optional distance)
   "Return non-nil if point is in or just after a match for REGEXP.
 Set the match data from the earliest such match ending at or after
 point."
   (save-excursion
-    (let ((old-point (point)) match)
+    (let ((old-point (point))
+         (forward-bound (and distance (+ (point) distance)))
+         (backward-bound (and distance (- (point) distance)))
+         match)
       (and (looking-at regexp)
           (>= (match-end 0) old-point)
           (setq match (point)))
       ;; Search back repeatedly from end of next match.
       ;; This may fail if next match ends before this match does.
-      (re-search-forward regexp nil 'limit)
-      (while (and (re-search-backward regexp nil t)
+      (re-search-forward regexp forward-bound 'limit)
+      (while (and (re-search-backward regexp backward-bound t)
                  (or (> (match-beginning 0) old-point)
                      (and (looking-at regexp)  ; Extend match-end past search start
                           (>= (match-end 0) old-point)
@@ -518,7 +521,8 @@ with angle brackets.")
 
 (put 'email 'bounds-of-thing-at-point
      (lambda ()
-       (let ((thing (thing-at-point-looking-at thing-at-point-email-regexp)))
+       (let ((thing (thing-at-point-looking-at
+                    thing-at-point-email-regexp 500)))
          (if thing
              (let ((beginning (match-beginning 0))
                    (end (match-end 0)))
index 1aab1fa665b4428a4f91b7dd12ab8495c2e254ca..79a1934f21ae1684236997423d547f6680c7e42c 100644 (file)
@@ -1924,6 +1924,8 @@ With prefix argument, prompt for cvs flags."
                              (lambda () (with-current-buffer buf
                                      (cvs-mode-remove-handled)))))))
 
+(autoload 'cvs-status-cvstrees "cvs-status")
+
 (defun-cvs-mode (cvs-mode-tree . SIMPLE) (flags)
   "Call cvstree using the file under the point as a keyfile."
   (interactive (list (cvs-flags-query 'cvs-status-flags "cvs status flags")))
index 618250dedabbe7c47bd7eda7f692463a7df31787..8935ed82a2ac40ae442386d29af1af26714b2a2c 100644 (file)
@@ -294,7 +294,7 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
                                 nil ".*,v$" t))
           (yes-or-no-p "Create RCS subdirectory? ")
           (make-directory subdir))
-      (apply 'vc-do-command "*vc*" 0 "ci" file
+      (apply #'vc-do-command "*vc*" 0 "ci" file
             ;; if available, use the secure registering option
             (and (vc-rcs-release-p "5.6.4") "-i")
             (concat (if vc-keep-workfiles "-u" "-r") rev)
@@ -375,7 +375,7 @@ whether to remove it."
             (setq switches (cons "-f" switches)))
        (if (and (not rev) old-version)
            (setq rev (vc-branch-part old-version)))
-       (apply 'vc-do-command "*vc*" 0 "ci" (vc-name file)
+       (apply #'vc-do-command "*vc*" 0 "ci" (vc-name file)
               ;; if available, use the secure check-in option
               (and (vc-rcs-release-p "5.6.4") "-j")
               (concat (if vc-keep-workfiles "-u" "-r") rev)
@@ -411,7 +411,7 @@ whether to remove it."
                             (concat "-u" old-version)))))))))
 
 (defun vc-rcs-find-revision (file rev buffer)
-  (apply 'vc-do-command
+  (apply #'vc-do-command
         (or buffer "*vc*") 0 "co" (vc-name file)
         "-q" ;; suppress diagnostic output
         (concat "-p" rev)
@@ -443,7 +443,7 @@ attempt the checkout for all registered files beneath it."
              (and rev (string= rev "")
                   (vc-rcs-set-default-branch file nil))
              ;; now do the checkout
-             (apply 'vc-do-command
+             (apply #'vc-do-command
                     "*vc*" 0 "co" (vc-name file)
                     ;; If locking is not strict, force to overwrite
                     ;; the writable workfile.
@@ -585,7 +585,7 @@ files beneath it."
 
 (defun vc-rcs-diff (files &optional oldvers newvers buffer)
   "Get a difference report using RCS between two sets of files."
-  (apply 'vc-do-command (or buffer "*vc-diff*")
+  (apply #'vc-do-command (or buffer "*vc-diff*")
         1              ;; Always go synchronous, the repo is local
         "rcsdiff" (vc-expand-dirs files)
          (append (list "-q"
@@ -787,7 +787,7 @@ Optional arg REVISION is a revision to annotate from."
       (cl-flet ((pad (w) (substring-no-properties padding w))
                 (render (rda &rest ls)
                         (propertize
-                         (apply 'concat
+                         (apply #'concat
                                 (format-time-string "%Y-%m-%d" (aref rda 1))
                                 "  "
                                 (aref rda 0)
@@ -811,7 +811,7 @@ Optional arg REVISION is a revision to annotate from."
   "Return the current time, based at midnight of the current day, and
 encoded as fractional days."
   (vc-annotate-convert-time
-   (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time))))))
+   (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time))))))
 
 (defun vc-rcs-annotate-time ()
   "Return the time of the next annotation (as fraction of days)
@@ -935,7 +935,7 @@ Uses `rcs2log' which only works for RCS and CVS."
             (unwind-protect
                 (progn
                   (setq default-directory odefault)
-                  (if (eq 0 (apply 'call-process vc-rcs-rcs2log-program
+                  (if (eq 0 (apply #'call-process vc-rcs-rcs2log-program
                                     nil (list t tempfile) nil
                                     "-c" changelog
                                     "-u" (concat login-name
@@ -1340,11 +1340,10 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
          (to-one@ () (setq @-holes nil
                            b (progn (search-forward "@") (point))
                            e (progn (while (and (search-forward "@")
-                                                (= ?@ (char-after))
-                                                (progn
-                                                  (push (point) @-holes)
-                                                  (forward-char 1)
-                                                  (push (point) @-holes))))
+                                                (= ?@ (char-after)))
+                                      (push (point) @-holes)
+                                      (forward-char 1)
+                                      (push (point) @-holes))
                                     (1- (point)))))
          (tok+val (set-b+e name &optional proc)
                   (unless (eq name (setq tok (read buffer)))
@@ -1355,18 +1354,18 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
                                 (funcall proc)
                               (buffer-substring-no-properties b e))))
          (k-semi (name &optional proc) (tok+val #'to-semi name proc))
-         (gather () (let ((pairs `(,e ,@@-holes ,b))
-                          acc)
-                      (while pairs
-                        (push (buffer-substring-no-properties
-                               (cadr pairs) (car pairs))
-                              acc)
-                        (setq pairs (cddr pairs)))
-                      (apply 'concat acc)))
-         (k-one@ (name &optional later) (tok+val #'to-one@ name
-                                                 (if later
-                                                     (lambda () t)
-                                                   #'gather))))
+         (gather (b e @-holes)
+                 (let ((pairs `(,e ,@@-holes ,b))
+                       acc)
+                   (while pairs
+                     (push (buffer-substring-no-properties
+                            (cadr pairs) (car pairs))
+                           acc)
+                     (setq pairs (cddr pairs)))
+                   (apply #'concat acc)))
+         (gather1 () (gather b e @-holes))
+         (k-one@ (name &optional later)
+                 (tok+val #'to-one@ name (if later (lambda () t) #'gather1))))
       (save-excursion
         (goto-char (point-min))
         ;; headers
@@ -1413,7 +1412,7 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
                                ;; same algorithm used in RCS 5.7.
                                (when (< (car ls) 100)
                                  (setcar ls (+ 1900 (car ls))))
-                               (apply 'encode-time (nreverse ls)))))
+                               (apply #'encode-time (nreverse ls)))))
                   ,@(mapcar #'k-semi '(author state))
                   ,(k-semi 'branches
                            (lambda ()
@@ -1444,9 +1443,10 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
               ;; only the former since it behaves identically to the
               ;; latter in the absence of "@@".)
               sub)
-          (cl-flet ((incg (_beg end)
-                          (let ((e end) @-holes)
+          (cl-flet ((incg (beg end)
+                          (let ((b beg) (e end) @-holes)
                             (while (and asc (< (car asc) e))
+                              (push (pop asc) @-holes)
                               (push (pop asc) @-holes))
                             ;; Self-deprecate when work is done.
                             ;; Folding many dimensions into one.
@@ -1454,7 +1454,7 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
                             ;; O beauteous math! --the Unvexed Bum
                             (unless asc
                               (setq sub #'buffer-substring-no-properties))
-                            (gather))))
+                            (gather b e @-holes))))
             (while (and (sw)
                         (not (eobp))
                         (setq context (to-eol)
@@ -1470,7 +1470,7 @@ The `:insn' key is a keyword to distinguish it as a vc-rcs.el extension."
               ;; other revisions, replace the `text' tag+value with `:insn'
               ;; plus value, always scanning in-place.
               (if (string= context (cdr (assq 'head headers)))
-                  (setcdr (cadr rev) (gather))
+                  (setcdr (cadr rev) (gather b e @-holes))
                 (if @-holes
                     (setq asc (nreverse @-holes)
                           sub #'incg)
index 585b6d48d45f627123b580c219879a88fc8ed0a8..bf69a1ccecccb4ed56af0a4b535c68cb62ed4c4c 100644 (file)
@@ -755,13 +755,6 @@ not specific to any particular backend."
   :group 'vc
   :version "21.1")
 
-(defcustom vc-diff-knows-L nil
-  "Indicates whether diff understands the -L option.
-The value is either `yes', `no', or nil.  If it is nil, VC tries
-to use -L and sets this variable to remember whether it worked."
-  :type '(choice (const :tag "Work out" nil) (const yes) (const no))
-  :group 'vc)
-
 (defcustom vc-log-show-limit 2000
   "Limit the number of items shown by the VC log commands.
 Zero means unlimited.
@@ -2302,7 +2295,8 @@ WORKING-REVISION and LIMIT."
   (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: Why t? --Stef
         (backend (car vc-fileset))
         (files (cadr vc-fileset))
-        (working-revision (or working-revision (vc-working-revision (car files)))))
+;;      (working-revision (or working-revision (vc-working-revision (car files))))
+         )
     (vc-print-log-internal backend files working-revision nil limit)))
 
 ;;;###autoload
@@ -2330,10 +2324,10 @@ When called interactively with a prefix argument, prompt for LIMIT."
        (setq rootdir (vc-call-backend backend 'root default-directory))
       (setq rootdir (read-directory-name "Directory for VC root-log: "))
       (setq backend (vc-responsible-backend rootdir))
-      (if backend
-         (setq default-directory rootdir)
-       (error "Directory is not version controlled")))
-    (setq working-revision (vc-working-revision rootdir))
+      (unless backend
+        (error "Directory is not version controlled")))
+    (setq working-revision (vc-working-revision rootdir)
+          default-directory rootdir)
     (vc-print-log-internal backend (list rootdir) working-revision nil limit)))
 
 ;;;###autoload
index 917dde618727fe8c40788e8361d79e5cd86ef954..e648a575a3532a82f98b7b3352ede941d2960af7 100644 (file)
@@ -4,7 +4,6 @@
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: help, extensions, faces, hypermedia
-;; Version: 1.9920
 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
 ;; Package: emacs
 
index 3f409a6f26a8a49a4264ef8802c4ffe045d96145..07741c74a84822d691db255bc756dd5546111a89 100644 (file)
@@ -5545,7 +5545,7 @@ argument, ACTION is t."
        window))))
 
 (defun display-buffer-other-frame (buffer)
-  "Display buffer BUFFER in another frame.
+  "Display buffer BUFFER preferably in another frame.
 This uses the function `display-buffer' as a subroutine; see
 its documentation for additional customization information."
   (interactive "BDisplay buffer in other frame: ")
index 5a1018f85e5f9c7cad8417a2a564a783e83b33f6..e4ab1a91cac2b153e2f3e7d39c2f48ccbd60656e 100644 (file)
@@ -1,3 +1,21 @@
+2013-11-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lwlib.c (safe_strdup): Prefer tail calls.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       Use relative filenames in TAGS files.
+       * Makefile.in (abs_srcdir): Remove it again.
+       (ctagsfiles, TAGS): Use relative filenames.
+
+       * Makefile.in (abs_srcdir): New, set by configure.
+       (ETAGS, ctagsfiles): New variables.
+       (TAGS): Use ETAGS, ctagsfiles.  Use absolute filenames again.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
 2013-09-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        Makefile improvements.
index 40f4a405e97027cd16faf4989f050588c66239ea..8bb23bb11bdfbb79d9c1a7c213fcca9993870a46 100644 (file)
@@ -23,6 +23,8 @@
 # and set up to be configured by ../configure.
 
 srcdir=@srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 VPATH=@srcdir@
 @SET_MAKE@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
@@ -98,7 +100,15 @@ distclean: clean
 maintainer-clean: distclean
        rm -f TAGS
 
-TAGS:
-       ../lib-src/etags $(srcdir)/*.[ch]
+
+ETAGS = ../lib-src/etags
+
+ctagsfiles= $(srcdir)/*.[ch]
+
+TAGS: $(ctagsfiles)
+       "$(ETAGS)" $(ctagsfiles)
 tags: TAGS
 .PHONY: tags
+
+
+### Makefile.in ends here
index 7d9920e8bce3e24de0ad862b0306e700151b523b..c8eba9cf35e3cba801c40aeba5d90b3a8a99c765 100644 (file)
@@ -103,11 +103,7 @@ static void show_one_widget_busy (Widget, Boolean);
 char *
 safe_strdup (const char *s)
 {
-  char *result;
-  if (! s) return 0;
-  result = (char *) xmalloc (strlen (s) + 1);
-  strcpy (result, s);
-  return result;
+  return s ? xstrdup (s) : 0;
 }
 
 static void
index 5b1fb65e6e65ac297e570e7b2837cf3edf0e45f9..24b6e4969d10aca36a4712bf94c914323bea186e 100644 (file)
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
 # acl.m4 - check for access control list (ACL) primitives
-# serial 15
+# serial 16
 
 # Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -141,12 +141,14 @@ int type = ACL_TYPE_EXTENDED;]])],
 # -------------------------------------
 # If 'acl_get_file' works (does not have a particular bug),
 # run IF-WORKS, otherwise, IF-NOT.
-# This tests for a Darwin 8.7.0 bug, whereby acl_get_file returns NULL,
-# but sets errno = ENOENT for an existing file or directory.
+# When building natively, test for a Darwin 8.7.0 bug, whereby acl_get_file
+# returns NULL, but sets errno = ENOENT for an existing file or directory.
+# When cross-compiling, assume that this old bug no longer applies.
 AC_DEFUN([gl_ACL_GET_FILE],
 [
   AC_CACHE_CHECK([for working acl_get_file], [gl_cv_func_working_acl_get_file],
-    [AC_RUN_IFELSE(
+    [gl_cv_func_working_acl_get_file=no
+     AC_LINK_IFELSE(
        [AC_LANG_PROGRAM(
           [[#include <sys/types.h>
            #include <sys/acl.h>
@@ -156,9 +158,10 @@ AC_DEFUN([gl_ACL_GET_FILE],
               return 1;
             return 0;
           ]])],
-       [gl_cv_func_working_acl_get_file=yes],
-       [gl_cv_func_working_acl_get_file=no],
-       [gl_cv_func_working_acl_get_file=cross-compiling])])
-
-  AS_IF([test $gl_cv_func_working_acl_get_file = yes], [$1], [$2])
+       [if test $cross_compiling = yes; then
+          gl_cv_func_working_acl_get_file="guessing yes"
+        elif ./conftest$ac_exeext; then
+          gl_cv_func_working_acl_get_file=yes
+        fi])])
+  AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2])
 ])
index 4862d60d8e7416d109c9e5428225015ffefeac4d..9f93c29e4d42592cacb957cd28f653992d2b07f5 100644 (file)
@@ -19,15 +19,20 @@ AC_DEFUN([gl_EXTERN_INLINE],
    'reference to static identifier "f" in extern inline function'.
    This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
 
-   Suppress the use of extern inline on problematic Apple configurations, as
-   Libc at least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
+   Suppress the use of extern inline on problematic Apple configurations.
+   OS X 10.8 and earlier mishandle it; see, e.g.,
    <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+   OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
+   for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
    Perhaps Apple will fix this some day.  */
 #if (defined __APPLE__ \
-     && ((! defined _DONT_USE_CTYPE_INLINE_ \
-          && (defined __GNUC__ || defined __cplusplus)) \
-         || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
-             && defined __GNUC__ && ! defined __cplusplus)))
+     && (defined __header_inline \
+         ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
+            && ! defined __clang__) \
+         : ((! defined _DONT_USE_CTYPE_INLINE_ \
+             && (defined __GNUC__ || defined __cplusplus)) \
+            || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
+                && defined __GNUC__ && ! defined __cplusplus))))
 # define _GL_EXTERN_INLINE_APPLE_BUG
 #endif
 #if ((__GNUC__ \
@@ -41,7 +46,7 @@ AC_DEFUN([gl_EXTERN_INLINE],
 # define _GL_EXTERN_INLINE_IN_USE
 #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
        && !defined _GL_EXTERN_INLINE_APPLE_BUG)
-# if __GNUC_GNU_INLINE__
+# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
    /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
 #  define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
 # else
index c8d9e8b7ba80abb1aafa4770a60cd7bd92d02453..669105b9b536d9ec4a5d1c84c388f7a7977f112b 100644 (file)
@@ -1,4 +1,4 @@
-# serial 20
+# serial 21
 
 # Copyright (C) 2000-2001, 2004-2013 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -16,19 +16,23 @@ dnl we have to grub around in the FILE struct.
 AC_DEFUN([gl_FUNC_FPENDING],
 [
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
+  fp_headers='
+    #include <stdio.h>
+    #if HAVE_STDIO_EXT_H
+    # include <stdio_ext.h>
+    #endif
+  '
   AC_CACHE_CHECK([for __fpending], [gl_cv_func___fpending],
     [
       AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM(
-           [[#include <stdio.h>
-             #if HAVE_STDIO_EXT_H
-             # include <stdio_ext.h>
-             #endif
-           ]],
+        [AC_LANG_PROGRAM([$fp_headers],
            [[return ! __fpending (stdin);]])],
         [gl_cv_func___fpending=yes],
         [gl_cv_func___fpending=no])
     ])
+  if test $gl_cv_func___fpending = yes; then
+    AC_CHECK_DECLS([__fpending], [], [], [$fp_headers])
+  fi
 ])
 
 AC_DEFUN([gl_PREREQ_FPENDING],
index 95e4984a6bdf16f158e029748c758c3bb1a00018..fe4f5ccbdf3cb08f72c8d40e52b3ae5bae2b1c73 100755 (executable)
--- a/make-dist
+++ b/make-dist
@@ -404,7 +404,7 @@ echo "Making links to \`nt'"
  ln config.nt emacsclient.rc emacs-src.tags ../${tempdir}/nt
  ln nmake.defs gmake.defs subdirs.el [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
  ln Makefile.in gnulib.mk ../${tempdir}/nt
- ln msysconfig.sh mingw-cfg.site epaths.nt INSTALL.OLD ../${tempdir}/nt
+ ln mingw-cfg.site epaths.nt INSTALL.OLD ../${tempdir}/nt
  ln ChangeLog INSTALL README README.W32 makefile.w32-in ../${tempdir}/nt)
 
 echo "Making links to \`nt/inc' and its subdirectories"
@@ -453,6 +453,8 @@ echo "Making links to \`lwlib'"
  ln *.[ch] *.in ../${tempdir}/lwlib
  ln README ChangeLog ../${tempdir}/lwlib)
 
+## It is important to distribute admin/ because it contains sources
+## for generated lisp/international/uni-*.el files.
 echo "Making links to \`admin' and its subdirectories"
 for f in `find admin -type f`; do
   case $f in
index 0214b6bc98bd35386ed96bd52acbd6d3844bb48e..96a5e79b13a0402c28436ea892518cabcef54ab5 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-05  Glenn Morris  <rgm@gnu.org>
+
+       * autogen/config.in:
+       * autogen/Makefile.in: Move here from ../autogen.
+       * mainmake.v2: Use msdos/autogen rather than autogen.
+
 2013-05-15  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * sed1x.inp: Don't rewrite DOC any more.
similarity index 99%
rename from autogen/config.in
rename to msdos/autogen/config.in
index d57d1575119184a614673d4c98c7d9a5084c2e33..dedb1888e20cf9ecf3f8562e686b2d3bd9c79598 100644 (file)
@@ -1689,7 +1689,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 # define _GL_EXTERN_INLINE_IN_USE
 #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
        && !defined _GL_EXTERN_INLINE_APPLE_BUG)
-# if __GNUC_GNU_INLINE__
+# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
    /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
 #  define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
 # else
index e6c1567deabb36925a78e18ab9a6e76717e2ab34..81e85a07165abc178cb78a2fd5c3e1d11c20920d 100644 (file)
@@ -64,13 +64,13 @@ MAKESHELL=/xyzzy/command
 top_srcdir := $(subst \,/,$(shell cd))
 
 # Q: Do we need to bootstrap?
-# A: Only if we find autogen/README, i.e. we are building out of
+# A: Only if we find msdos/autogen/Makefile.in, i.e. we are building out of
 #    a VCS-checkout (not a release), and src/b-emacs.exe does not exist.
 #    This avoids building a bootstrap-emacs and recompiling Lisp files
 #    when building a pretest/release tarball.  Recompiling Lisp files
 #    is BAD because lisp/Makefile.in requires a Unixy shell.
 boot :=
-ifneq ($(wildcard autogen/README),)
+ifneq ($(wildcard msdos/autogen/Makefile.in),)
 ifeq ($(wildcard src/b-emacs.exe),)
 boot := b-emacs.exe
 endif
index 42086ec10075ca2746e4debc425171463aa0826b..7d3cceba205df8cdb77c9b134204e0bcb37caac3 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (${ns_check_file} ${ns_appdir}):
+       Quote entities that might contain whitespace.
+
 2013-09-02  Jan Djärv  <jan.h.d@swipnet.se>
 
        * Makefile.in (${ns_check_file}): Add so Emacs.app gets properly
index 3d80ddb7ad2598782fff5d431b86155c2046c773..b5377232e313c06cbdae3a9f4f034fb319fb18ee 100644 (file)
@@ -38,7 +38,7 @@ ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc}
        ${MKDIR_P} ${ns_appdir}
        ( cd ${srcdir}/${ns_appsrc} ; tar cfh - . ) | \
          ( cd ${ns_appdir} ; umask 022; tar xf - )
-       [ `cd ${srcdir} && /bin/pwd` = `/bin/pwd` ] || \
+       [ "`cd ${srcdir} && /bin/pwd`" = "`/bin/pwd`" ] || \
          ( cd ${ns_appsrc} ; tar cfh - . ) | \
            ( cd ${ns_appdir} ; umask 022; tar xf - )
        touch ${ns_appdir}
index b8bbddda6e5da2f1bc914cbff6e819ce3950e1af..1b766f0f34970a39102b60f12ae02c48c31a4ebd 100644 (file)
@@ -1,3 +1,24 @@
+2013-11-12  Dani Moncayo  <dmoncayo@gmail.com>
+
+       * msysconfig.sh: Remove.
+       * INSTALL: Update for this.
+
+2013-11-09  Glenn Morris  <rgm@gnu.org>
+
+       * mingw-cfg.site: No need for this to be executable.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in ($(DESTDIR)${archlibdir}):
+       Avoid non-portable "`\" nesting.
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in ($(DESTDIR)${archlibdir}, install, uninstall):
+       Quote entities that might contain whitespace.
+
 2013-10-14  Eli Zaretskii  <eliz@gnu.org>
 
        * inc/mingw_time.h: New file.
index 8f08c078a61866a7efb443385cc79f12fd8729a3..434327b66cc7aa5dcac7142132e528682fba9a89 100644 (file)
@@ -31,15 +31,15 @@ Windows 9X as well).
   1. If you want to build Emacs outside of the source tree
      (recommended), create the build directory and chdir there.
 
-  2. Invoke the MSYS-specific configure script:
+  2. Invoke the configure script:
 
       - If you are building outside the source tree:
 
-        /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
+        /PATH/TO/EMACS/SOURCE/TREE/configure --prefix=PREFIX ...
 
       - If you are building in-place, i.e. inside the source tree:
 
-        ./nt/msysconfig.sh --prefix=PREFIX ...
+        ./configure --prefix=PREFIX ...
 
      It is always preferable to use --prefix to configure Emacs for
      some specific location of its installed tree; the default
@@ -49,7 +49,7 @@ Windows 9X as well).
      You can pass other options to the configure script.  Here's a
      typical example (for an in-place debug build):
 
-       CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=/d/usr/emacs --enable-checking
+       CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./configure --prefix=/d/usr/emacs --enable-checking
 
   3. After the configure script finishes, it should display the
      resulting configuration.  After that, type
@@ -281,12 +281,7 @@ Windows 9X as well).
 
   To build a development snapshot from the Emacs Bazaar repository,
   you will first need to generate the configure script and a few other
-  auto-generated files.  (If this step, described below, somehow
-  fails, you can use the files in the autogen/ directory instead, but
-  they might be outdated, and, most importantly, you are well advised
-  not to disregard any failures in your local build procedures, as
-  these are likely to be symptoms of incorrect installation that will
-  bite you down the road.)
+  auto-generated files.
 
   To generate the configure script, type this at the MSYS Bash prompt
   from the top-level directory of the Emacs tree:
@@ -318,11 +313,11 @@ Windows 9X as well).
 
   You invoke the configure script like this:
 
-     /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
+     /PATH/TO/EMACS/SOURCE/TREE/configure --prefix=PREFIX ...
 
   or, if you are building in-place, i.e. inside the source tree:
 
-     ./nt/msysconfig.sh --prefix=PREFIX ...
+     ./configure --prefix=PREFIX ...
 
   Here PREFIX is the place where you eventually want to install Emacs
   once built, e.g. /d/usr.  We recommend to always use --prefix when
@@ -342,12 +337,12 @@ Windows 9X as well).
   Windows-style file names was reported to cause subtle and hard to
   figure out problems during the build.  This applies both to the
   command switches, such as --prefix=, and to the absolute file name
-  of msysconfig.sh, if you are building outside of the source tree.
+  of 'configure', if you are building outside of the source tree.
 
   You can pass additional options to the configure script, for the
   full list type
 
-     ./nt/msysconfig.sh --help
+     ./configure --help
 
   As explained in the help text, you may need to tell the script what
   are the optional flags to invoke the compiler.  This is needed if
@@ -360,7 +355,7 @@ Windows 9X as well).
   headers in C:\emacs\libs\jpeg-6b-4-lib\include, you will need to say
   something like this:
 
-    CPPFLAGS='-I/c/emacs/libs/libpng-1.2.37-lib/include -I/c/emacs/libs/jpeg-6b-4-lib/include' ./nt/msysconfig.sh --prefix=PREFIX
+    CPPFLAGS='-I/c/emacs/libs/libpng-1.2.37-lib/include -I/c/emacs/libs/jpeg-6b-4-lib/include' ./configure --prefix=PREFIX
 
   which is quite a mouth-full, especially if you have more directories
   to specify...  Perhaps you may wish to revisit your installation
@@ -368,9 +363,9 @@ Windows 9X as well).
 
   If you have a global site-lisp directory from previous Emacs
   installation, and you want Emacs to continue using it, specify it
-  via the --enable-locallisppath switch to msysconfig.sh, like this:
+  via the --enable-locallisppath switch to 'configure', like this:
 
-   ./nt/msysconfig.sh --prefix=PREFIX --enable-locallisppath="/d/usr/share/emacs/VERSION/site-lisp:/d/wherever/site-lisp"
+   ./configure --prefix=PREFIX --enable-locallisppath="/d/usr/share/emacs/VERSION/site-lisp:/d/wherever/site-lisp"
 
   Use the normal MSYS /d/foo/bar style to specify directories by their
   absolute file names.
@@ -378,7 +373,7 @@ Windows 9X as well).
   A few frequently used options are needed when you want to produce an
   unoptimized binary with runtime checks enabled:
 
-     CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=PREFIX --enable-checking
+     CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./configure --prefix=PREFIX --enable-checking
 
   Once invoked, the configure script will run for some time, and, if
   successful, will eventually produce a summary of the configuration
index 0b7318c9b49090a3b9fbe8302f1de080d8acae7a..17fef43e26d81f7df55c437c0fbcf41c7c36db69 100644 (file)
@@ -76,6 +76,8 @@ VPATH=@srcdir@
 
 # The top-level source directory, also set by configure.
 top_srcdir=@top_srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 
 # ==================== Emacs-specific directories ====================
 
@@ -141,10 +143,11 @@ all: ${EXE_FILES}
 $(DESTDIR)${archlibdir}: all
        @echo
        @echo "Installing utilities run internally by Emacs."
-       umask 022; ${MKDIR_P} $(DESTDIR)${archlibdir}
-       if [ `cd $(DESTDIR)${archlibdir} && /bin/pwd` != `/bin/pwd` ]; then \
+       umask 022; ${MKDIR_P} "$(DESTDIR)${archlibdir}"
+       exp_archlibdir=`cd "$(DESTDIR)${archlibdir}" && /bin/pwd`; \
+       if [ "$$exp_archlibdir" != "`/bin/pwd`" ]; then \
          for file in ${UTILITIES}; do \
-           $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \
+           $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file "$(DESTDIR)${archlibdir}/$$file" ; \
          done ; \
         fi
 
@@ -154,17 +157,17 @@ $(DESTDIR)${archlibdir}: all
 install: $(DESTDIR)${archlibdir}
        @echo
        @echo "Installing utilities for users to run."
-       umask 022; ${MKDIR_P} $(DESTDIR)${bindir}
+       umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
        for file in ${INSTALLABLES} ; do \
-         $(INSTALL_PROGRAM) $(INSTALL_STRIP) $${file} $(DESTDIR)${bindir}/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
+         $(INSTALL_PROGRAM) $(INSTALL_STRIP) $${file} "$(DESTDIR)${bindir}"/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
        done
 
 uninstall:
        for file in ${INSTALLABLES}; do \
-         rm -f $(DESTDIR)${bindir}/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
+         rm -f "$(DESTDIR)${bindir}"/`echo $${file} | sed -e 's/${EXEEXT}$$//' -e '$(TRANSFORM)'`${EXEEXT} ; \
        done
-       if [ -d $(DESTDIR)${archlibdir} ]; then \
-         (cd $(DESTDIR)${archlibdir} && rm -f ${UTILITIES}) \
+       if [ -d "$(DESTDIR)${archlibdir}" ]; then \
+         (cd "$(DESTDIR)${archlibdir}" && rm -f ${UTILITIES}) \
        fi
 
 mostlyclean:
index 3ba60a85752d61be1d10c75f1625de2724cd0382..90713e595cd9a0388dea1657e1fa4739e772a6d9 100644 (file)
@@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* NOTE:
-   This file is intentionally kept in sync with autogen/config.in to
-   ease maintenance.  Please do not remove non-Windows related stuff
+   *** WARNING This file is no longer being updated ***
+   Please do not remove non-Windows related stuff
    unless strictly necessary.  Also, before adding anything here
    consider whether inc/ms-w32.h would be a better place; this is
    particularly true for gcc vs. MSVC conditional defines, MinGW or
index a217cbc8c701e66569f7874cbbf249a311c0fc82..0be24dde12f3f9a0782c427fc1fdf6af8a1f2a57 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/sh
+# -*- sh -*-
 # Site defaults for the MinGW configuration of GNU Emacs.
 #
 # This file's purpose is to short-circuit configure-time tests for
 # value of a shell variable ac_cv_header_foo_h.  The value should be
 # yes if the header is deemed to exist, no otherwise.  Or it could be
 # something else, if the value computed by 'configure' requires that.
-# In general, since nt/msysconfig.sh instructs GCC to use header files
-# in nt/inc, you should not need to futz with header file tests.  But
-# there are exceptions, like with getopt.h below (which is a MinGW
-# system header, but we do not want to use it).
+# In general, since configure (when invoked from an MSYS environment)
+# instructs GCC to use header files in nt/inc, you should not need to
+# futz with header file tests.  But there are exceptions, like with
+# getopt.h below (which is a MinGW system header, but we do not want
+# to use it).
 #
 # For each library function foo you want to supply test results, set
 # the value of a shell variable ac_cv_func_foo.  Again, the value is
diff --git a/nt/msysconfig.sh b/nt/msysconfig.sh
deleted file mode 100644 (file)
index 45bbf13..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/sh
-### msysconfig.sh - Run the top-level 'configure' script as appropriate
-### for the MinGW/MSYS build of a native MS-Windows port of Emacs.
-
-## Copyright (C) 2013 Free Software Foundation, Inc.
-
-## Author: Eli Zaretskii <eliz@gnu.org>
-
-## This file is part of GNU Emacs.
-
-## GNU Emacs is free software: you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation, either version 3 of the License, or
-## (at your option) any later version.
-
-## GNU Emacs is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-
-### Commentary:
-
-## The Posix 'configure' script needs a few tweaks to produce desired
-## results when running under MSYS with the purpose of configuring
-## Emacs for the MinGW MS-Windows build.  Rather than asking users to
-## type these tweaks every time they configure the package, we provide
-## this helper script which takes care of the mundane things.
-
-### Code:
-
-srcdir=`dirname "$0"`
-parent=`dirname "$srcdir"`
-
-## The nt/mingw-cfg.site file provides various autoconf variables that
-## are needed for a successful MinGW build.
-CONFIG_SITE="$srcdir/mingw-cfg.site" $parent/configure "$@"
index 21acbe830530a010c448988398208b42335324d0..a8f19210561159fdbeebb1e276f831bdd41b75c4 100644 (file)
@@ -1,3 +1,7 @@
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
 2013-09-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        Makefile improvements.
index 394bfb3ab500498f547a5b5d0a80653f0bb9c511..8b0e8391278c359134d45f804ce73d5d7be38527 100644 (file)
@@ -43,6 +43,8 @@
 ### Code:
 
 srcdir=@srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 VPATH=@srcdir@
 C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
 C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
index b973b5b8d04b97b6b473a1ffa79331efa4d87527..a2dfa5bf613f33373275371b8b5bfa4aaf61e809 100644 (file)
@@ -1,3 +1,706 @@
+2013-11-18  Eli Zaretskii  <eliz@gnu.org>
+
+       * insdel.c (invalidate_buffer_caches): New function, consolidated
+       from part of prepare_to_modify_buffer.
+       (insert_from_gap, prepare_to_modify_buffer):
+       * coding.c (code_convert_region, code_convert_string): Call
+       invalidate_buffer_caches.  (Bug#15841)
+
+       * lisp.h (invalidate_buffer_caches): Add prototype.
+
+2013-11-17  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32term.c (x_update_window_end): Don't invalidate the entire
+       mouse-highlight info, just signal frame_up_to_date_hook that mouse
+       highlight needs to be redisplayed.  (Bug#15913)
+
+2013-11-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lisp.h (DEBUGGER_SEES_C_MACROS): Remove.
+
+2013-11-16  Eli Zaretskii  <eliz@gnu.org>
+
+       * doc.c (Fsubstitute_command_keys): Inhibit modification hooks
+       while we are using Vprin1_to_string_buffer.
+
+       * keymap.c (describe_map): Don't crash if PT is 1 both before and
+       after inserting the description string.  (Bug#15907)
+
+2013-11-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * data.c: Work around bogus GCC diagnostic about shift count.
+       Reported by Eli Zaretskii in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00489.html>.
+       (pre_value): New function.
+       (count_trailing_zero_bits): Use it.
+
+2013-11-15  Eli Zaretskii  <eliz@gnu.org>
+
+       * lisp.h (DEBUGGER_SEES_C_MACROS) [GCC < v3.5]: Pessimistically
+       assume C macros are not supported even under -g3 in these old GCC
+       versions.
+
+2013-11-15  Leo Liu  <sdl.web@gmail.com>
+
+       * minibuf.c (Ftry_completion, Fall_completions)
+       (Ftest_completion): Use FUNCTIONP.  (Bug#15889)
+
+2013-11-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lisp.h (DEFINE_GDB_SYMBOL_BEGIN, DEFINE_GDB_SYMBOL_END):
+       Define to empty if DEBUGGER_SEES_C_MACROS is defined.
+       This avoids placing unnecessary constants into the Emacs code.
+
+2013-11-14  Kazuhiro Ito  <kzhr@d1.dion.ne.jp>  (tiny change)
+
+       * keyboard.c (make_ctrl_char) [HAVE_NTGUI]: Now externally visible
+       for Cygwin w32 build.
+
+       * xdisp.c (erase_phys_cursor) [HAVE_NTGUI]: Now externally visible
+       for Cygwin w32 build.  (Bug#15892)
+
+2013-11-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify, port and tune bool vector implementation.
+       * alloc.c (bool_vector_exact_payload_bytes)
+       (bool_vector_payload_bytes): Remove.
+       (bool_vector_fill): Return its argument.
+       * alloc.c (bool_vector_fill):
+       * lread.c (read1):
+       * print.c (print_object):
+       Simplify by using bool_vector_bytes.
+       * alloc.c (make_uninit_bool_vector):
+       New function, broken out from Fmake_bool_vector.
+       (Fmake_bool_vector): Use it.  Use tail call.
+       (make_uninit_bool_vector, vector_nbytes): Simplify size calculations.
+       * data.c (BITS_PER_ULL): New constant.
+       (ULLONG_MAX, count_one_bits_ll): Fall back on long counterparts
+       if long long versions don't exist.
+       (shift_right_ull): New function.
+       (count_one_bits_word): New function, replacing popcount_bits_word
+       macro.  Don't assume that bits_word is no wider than long long.
+       (count_one_bits_word, count_trailing_zero_bits):
+       Don't assume that bits_word is no wider than long long.
+       * data.c (bool_vector_binop_driver, bool_vector_not):
+       * fns.c (Fcopy_sequence):
+       * lread.c (read1):
+       Create an uninitialized destination, to avoid needless work.
+       (internal_equal): Simplify.
+       (Ffillarray): Prefer tail call.
+       * data.c (bool_vector_binop_driver): Don't assume bit vectors always
+       contain at least one word.
+       (bits_word_to_host_endian): Prefer if to #if.  Don't assume
+       chars are narrower than ints.
+       * data.c (Fbool_vector_count_matches, Fbool_vector_count_matches_at):
+       * fns.c (Fcopy_sequence):
+       Simplify and tune.
+       * lisp.h (bits_word, BITS_WORD_MAX, BITS_PER_BITS_WORD):
+       Don't try to port to hosts where bits_word values have holes; the
+       code wouldn't work there anyway.  Verify this assumption, though.
+       (bool_vector_bytes): New function.
+       (make_uninit_bool_vector): New decl.
+       (bool_vector_fill): Now returns Lisp_Object.
+
+       * xfns.c (xic_create_fontsetname):
+       * xrdb.c (gethomedir): Prefer tail calls.
+
+2013-11-12  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * xterm.c (syms_of_xterm): staticpro Qmodifier_value, Qalt, Qhyper,
+       Qmeta, and Qsuper.  This is safer, and it's what w32fns.c does.
+
+       * buffer.c (Fforce_mode_line_update): Don't fall off end of function
+       that requires a return value.
+       (Fset_buffer_modified_p): Take advantage of this change to do
+       a tail call.
+
+2013-11-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * buffer.c (Frestore_buffer_modified_p): Sync it with
+       Fset_buffer_modified_p.
+       (Fforce_mode_line_update): New function, moved from subr.el.
+       (Fset_buffer_modified_p): Use them.
+       (syms_of_buffer): Defsubr Fforce_mode_line_update.
+
+2013-11-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * search.c (find_newline): Rewrite to prefer offsets to pointers.
+       This avoids undefined behavior when subtracting pointers into
+       different aways.  On my platform it also makes the code a tad
+       smaller and presumably faster.
+
+2013-11-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * keyboard.c (command_loop_1): Use region-extract-function.
+       * insdel.c (Qregion_extract_function): Not static any more (can we
+       stop pretending that these vars can benefit from being marked static?).
+
+2013-11-09  Eli Zaretskii  <eliz@gnu.org>
+
+       * search.c (find_newline): If buffer text is relocated during the
+       "dumb loop", adjust C pointers into buffer text to follow suit.
+       (Bug#15841)
+
+2013-11-09  Łukasz Stelmach <stlman@poczta.fm> (tiny change)
+
+       * gtkutil.c (xg_check_special_colors): Use rgb: instead of rgbi:
+       for conversion (Bug#15837).
+
+2013-11-09  Eli Zaretskii  <eliz@gnu.org>
+
+       * fileio.c (Finsert_file_contents): Invalidate the newline cache
+       for the entire range of inserted characters.  (Bug#15841)
+
+2013-11-08  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * xfaces.c (lface_fully_specified_p): Let distant-foreground be
+       unspecified.
+       (realize_default_face): Remove assignment to distant-foreground if
+       unspecified (Bug#15815).
+
+2013-11-08  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (message_dolog): Make sure the *Messages* buffer has its
+       cache-long-scans disabled, since we don't want to call
+       prepare_to_modify_buffer (in insert_1_both) for each message we
+       display.
+
+       * buffer.h (bset_cache_long_scans): New INLINE function, moved
+       from buffer.c.  Improve commentary to the buffer field setter
+       functions.
+
+       * buffer.c (bset_cache_long_scans): Static function deleted.
+       Improve commentary to the buffer field setter functions.
+       (init_buffer_once): Default for cache-long-scans changed to t.
+       (Bug#15797)
+
+2013-11-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * gmalloc.c (special_realloc, calloc, mallochook): Use tail calls.
+
+       * chartab.c (make_sub_char_table): Fix size typo (Bug#15825).
+       This bug was introduced in my 2013-06-21 change, and caused
+       struct Lisp_Sub_Char_Table objects to be given too many slots,
+       which broke 'make -C admin/unidata'.
+
+2013-11-07  Jan Djärv  <jan.h.d@swipnet.se>
+
+       Import changes from mac-port 4.5.
+       * macfont.m (mac_font_copy_default_descriptors_for_language)
+       (mac_font_copy_default_name_for_charset_and_languages): Declare.
+       (cf_charset_table): big-5-0 has uniquifier 0x4EDC.
+       (macfont_language_default_font_names): New.
+       (macfont_list): Rearrange language/charset code.
+       (macfont_close): Don't check for macfont_info->cache.
+       (mac_ctfont_create_preferred_family_for_attributes): New font
+       selection code, call
+       mac_font_copy_default_name_for_charset_and_languages.
+       (mac_font_copy_default_descriptors_for_language)
+       (mac_font_copy_default_name_for_charset_and_languages): New functions.
+
+       * macfont.h (kCTVersionNumber10_9): Define if not defined.
+
+2013-11-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to C11 aligned_alloc, and fix some integer overflows.
+       * alloc.c (USE_ALIGNED_ALLOC): New symbol.
+       (USE_POSIX_MEMALIGN): Remove.  All uses replaced with USE_ALIGNED_ALLOC,
+       and use of posix_memalign replaced with aligned_alloc.
+       (aligned_alloc): New function, defined or declared as needed.
+       * conf_post.h (HAVE_POSIX_MEMALIGN) [DARWIN_OS]:
+       Don't undef; configure.ac now does this.
+       * gmalloc.c (aligned_alloc) [MSDOS]: New decl.
+       (calloc, aligned_alloc): Check for integer overflow.
+       (aligned_alloc): Rename from memalign.  All uses changed.
+       (memalign): New function, an alias for aligned_alloc.
+
+2013-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * xdisp.c (redisplay_internal): Fix typo in last change.
+
+2013-11-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * regex.c: Fix --enable-gcc-warning glitch with GCC 4.5.2.
+
+2013-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * xdisp.c (syms_of_xdisp): New vars redisplay--all-windows-cause and
+       redisplay--mode-lines-cause.
+       (redisplay_internal): Keep them uptodate.  Remove redundant check of
+       buffer_shared_and_changed.
+       * *.[chm]: Number every assignment to update_mode_lines so we
+       can track why it is set.
+
+2013-11-06  Eli Zaretskii  <eliz@gnu.org>
+
+       * editfns.c (Fformat_time_string): Doc fix.  (Bug#15816)
+
+2013-11-06  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * *.[chm]: Number every assignment to windows_or_buffers_changed so we
+       can track why it is set.
+
+2013-11-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Integer-related fixes for term.c etc.
+       * dispextern.h (face_tty_specified_color): New function.
+       * term.c (turn_on_face): Don't rely on undefined behavior when
+       assigning an out-of-range value to 'long'.
+       Simplify test for toggling highlight.
+       (tty_capable_p): Omit last two (unused) args.  All callers changed.
+       * term.c (tty_capable_p, tty_menu_display, tty_menu_add_selection)
+       (read_menu_input, tty_menu_activate, tty_menu_show):
+       * xfaces.c (x_supports_face_attributes_p)
+       (tty_supports_face_attributes_p):
+       Use bool for boolean.  All callers changed.
+       (tty_supports_face_attributes_p): Omit defaults for color indices;
+       no longer needed.  Simplify tail call.
+
+2013-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * xdisp.c (prepare_menu_bars): Mark static.
+       * lisp.h (prepare_menu_bars): Don't declare.
+       * xselect.c (x_handle_selection_clear):
+       * callproc.c (call_process): Remove redundant call to prepare_menu_bars.
+
+2013-11-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * keyboard.c (Fcommand_error_default_function): Fix pointer signedness
+       glitch.  Eliminate 'sz' prefix; Hungarian notation is not helpful here.
+
+2013-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * keyboard.c (Fcommand_error_default_function): Rename from
+       Fdefault_error_output.
+
+2013-11-05  Jarek Czekalski  <jarekczek@poczta.onet.pl>  (tiny change)
+
+       * keyboard.c (Fdefault_error_output): New function, extracted from
+       cmd_error_internal.
+       (syms_of_keyboard): Use it for Vcommand_error_function.
+
+2013-11-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * eval.c (handlerlist_sentinel): New variable (bug#15802).
+       (init_eval): Use it to ensure handlerlist is non-NULL.
+       (unwind_to_catch): Make sure we never set handlerlist to NULL.
+       (Fsignal): Adjust NULLness test of handlerlist.
+       * lisp.h (PUSH_HANDLER): Assume handlerlist is non-NULL.
+
+2013-11-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * callproc.c (call_process): Call prepare_to_modify_buffer before
+       decoding text read from the sub-process, as the decoded stuff will
+       be inserted into the buffer.  This will invalidate the various
+       caches maintained for the buffer.  (Bug#15148)
+
+2013-11-05  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * xdisp.c (syms_of_xdisp): Mention the active display table in doc
+       string of glyphless-char-display.
+
+2013-11-05  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * nsfns.m (ns_get_name_from_ioreg): New function.
+       (ns_screen_name): Don't use deprecated CGDisplayIOServicePort on
+       OSX >= 10.9.  Use ns_get_name_from_ioreg.
+
+2013-11-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify and port recent bool vector changes.
+       * alloc.c (ROUNDUP): Move here from lisp.h, since it's now used
+       only in this file.  Use a more-efficient implementation if the
+       second argument is a power of 2.
+       (ALIGN): Rewrite in terms of ROUNDUP.  Make it a function.
+       Remove no-longer-necessary compile-time checks.
+       (bool_vector_exact_payload_bytes): New function.
+       (bool_vector_payload_bytes): Remove 2nd arg; callers that need
+       exact payload changed to call the new function.  Do not assume
+       that the arg or result fits in ptrdiff_t.
+       (bool_vector_fill): New function.
+       (Fmake_bool_vector): Use it.  Don't assume bit counts fit
+       in ptrdiff_t.
+       (vroundup_ct): Don't assume arg fits in size_t.
+       * category.c (SET_CATEGORY_SET): Remove.  All callers now just
+       invoke set_category_set.
+       (set_category_set): 2nd arg is now EMACS_INT and 3rd is now bool.
+       All callers changed.  Use bool_vector_set.
+       * category.h (XCATEGORY_SET): Remove; no longer needed.
+       (CATEGORY_MEMBER): Now a function.  Rewrite in terms of
+       bool_vector_bitref.
+       * data.c (Faref): Use bool_vector_ref.
+       (Faset): Use bool_vector_set.
+       (bits_word_to_host_endian): Don't assume you can shift by CHAR_BIT.
+       (Fbool_vector_not, Fbool_vector_count_matches)
+       (Fbool_vector_count_matches_at): Don't assume CHAR_BIT == 8.
+       * fns.c (concat): Use bool_vector_ref.
+       (Ffillarray): Use bool_vector_fill.
+       (mapcar1): Use bool_vector_ref.
+       (sxhash_bool_vector): Hash words, not bytes.
+       * lisp.h (BOOL_VECTOR_BITS_PER_CHAR): Now a macro as well as
+       a constant, since it's now used in #if.
+       (bits_word, BITS_WORD_MAX, BITS_PER_BITS_WORD): Fall back on
+       unsigned char on unusual architectures, so that we no longer
+       assume that the number of bits per bits_word is a power of two or
+       is a multiple of 8 or of CHAR_BIT.
+       (Qt): Add forward decl.
+       (struct Lisp_Bool_Vector): Don't assume EMACS_INT is aligned
+       at least as strictly as bits_word.
+       (bool_vector_data, bool_vector_uchar_data): New accessors.
+       All data structure accesses changed to use them.
+       (bool_vector_words, bool_vector_bitref, bool_vector_ref)
+       (bool_vector_set): New functions.
+       (bool_vector_fill): New decl.
+       (ROUNDUP): Move to alloc.c as described above.
+
+       Fix recent gnutls changes.
+       * gnutls.c (Fgnutls_boot): Don't assume C99.
+       * process.c (wait_reading_process_output): Fix typo in recent change.
+
+2013-11-05  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * process.c (wait_reading_process_output, read_process_output)
+       (send_process): Check gnutls_state is not NULL.
+
+       * gnutls.c (emacs_gnutls_handle_error): Adjust log level for EAGAIN.
+       (Fgnutls_boot): Set process gnutls_p later, after initialization.
+
+2013-11-04  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * nsterm.m (init, run, stop:): New methods in EmacsApp for
+       OSX >= 10.9 to prevent memory leak of GCD dispatch source.
+
+       * nsterm.h (EmacsApp): Add shouldKeepRunning and isFirst for
+       OSX >= 10.9.
+
+       * nsfns.m (Fx_create_frame): Fix memory leak.
+
+       * macfont.m (CG_SET_FILL_COLOR_WITH_GC_FOREGROUND)
+       (CG_SET_FILL_COLOR_WITH_GC_BACKGROUND)
+       (CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND): Fix memory leak.
+
+2013-11-04  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (message3_nolog, message_with_string): Encode the string
+       before writing it to the terminal in a non-interactive session.
+
+       * lread.c (openp): If both FILENAME and SUFFIX are unibyte, make
+       sure we concatenate them into a unibyte string.
+
+       * fileio.c (make_temp_name): Encode PREFIX, and decode the
+       resulting temporary name before returning it to the caller.
+       (Fexpand_file_name): If NAME is pure-ASCII and DEFAULT_DIRECTORY
+       is a unibyte string, convert NAME to a unibyte string to ensure
+       that the result is also a unibyte string.
+
+       * emacs.c (init_cmdargs): Use build_unibyte_string to make sure we
+       create unibyte strings from default paths and directory/file
+       names.
+
+       * coding.h (ENCODE_FILE): Do not attempt to encode a unibyte
+       string.
+
+       * callproc.c (init_callproc): Use build_unibyte_string to make
+       sure we create unibyte strings from default paths and
+       directory/file names.
+
+       * buffer.c (init_buffer): Don't store default-directory of
+       *scratch* in multibyte form.  The original problem which led to
+       that is described in
+       http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-11/msg00532.html,
+       but it was solved long ago.  (Bug#15260)
+
+2013-11-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to stricter C99 platforms.
+       Especially, C99 prohibits nesting a struct X inside struct Y if
+       struct X has a flexible array member.
+       * alloc.c (struct sdata): New type.
+       (sdata): Implement in terms of struct sdata.
+       Remove u member; all uses replaced by next_vector, set_next_vector.
+       (SDATA_SELECTOR, SDATA_DATA, SDATA_DATA_OFFSET): Adjust to sdata change.
+       (SDATA_DATA_OFFSET): Now a constant, not a macro.
+       (struct sblock): Rename first_data member to data, which is now
+       a flexible array member.  All uses changed.
+       (next_vector, set_next_vector, large_vector_vec): New functions.
+       (vector_alignment): New constant.
+       (roundup_size): Make it a multiple of ALIGNOF_STRUCT_LISP_VECTOR, too.
+       (struct large-vector): Now merely a NEXT member, since the old approach
+       ran afoul of stricter C99.  All uses changed to use
+       large_vector_vec or large_vector_offset.
+       (large_vector_offset): New constant.
+       * dispnew.c: Include tparam.h, for tgetent.
+       Do not include term.h; no longer needed.
+       * gnutls.c (Fgnutls_boot): Don't continue after calling a _Noreturn.
+       * lisp.h (ENUM_BF) [__SUNPRO_C && __STDC__]: Use unsigned int.
+       (struct Lisp_Vector): Use a flexible array member for contents,
+       instead of a union with a member that is an array of size 1.
+       All uses changed.
+       (ALIGNOF_STRUCT_LISP_VECTOR): New constant, to make up for the
+       fact that the struct no longer contains a union.
+       (struct Lisp_Misc_Any, struct Lisp_Marker, struct Lisp_Overlay)
+       (struct Lisp_Save_Value, struct Lisp_Free):
+       Use unsigned, not int, for spacers, to avoid c99 warning.
+       (union specbinding): Use unsigned, not bool, for bitfield, as
+       bool is not portable to pre-C99 hosts.
+
+2013-11-04  Glenn Morris  <rgm@gnu.org>
+
+       * emacs.c (usage_message): Mention that `-L :...' appends.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_builddir): Remove.
+       (bootstrap_exe): Use relative filename.
+
+       Use relative filenames in TAGS files.
+       * Makefile.in (abs_srcdir): Remove it again.
+       (.PHONY): Remove frc.
+       (maintainer-clean): No more TAGS-LISP file.
+       (TAGS): Pass relative file names to etags.
+       (../lisp/TAGS): Rename from TAGS-LISP.  Work in ../lisp.
+
+       * Makefile.in (abs_srcdir): New, set by configure.
+       (lispdir): Remove.
+       (maintainer-clean): Remove pointless echo.  That should be in the
+       top-level Makefile, if anywhere.  Delete TAGS-LISP.
+       (extraclean): No s/ and m/ directories for some time.
+       (TAGS): Also depend on ctagsfiles3.
+       Remove no-longer-defined S_FILE.
+       Pass absolute filenames to etags once more.
+       (TAGS-LISP): Replace lispdir with its expansion.
+       (TAGS-LISP, $(lwlibdir)/TAGS): Correctly pass ETAGS to sub-makes.
+       ($(lwlibdir)/TAGS): Remove useless subshell, check cd return value.
+
+2013-11-02  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * xfaces.c (check_lface_attrs, realize_default_face):
+       Add LFACE_DISTANT_FOREGROUND_INDEX (Bug#15788).
+       (realize_default_face): Set DISTANT_FOREGROUND to unspecified_fg.
+
+2013-11-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * emacs.c (original_pwd): Remove global var by making it local.
+       (init_cmdargs): New arg ORIGINAL_PWD; caller changed.
+
+2013-11-01  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * xfaces.c: Declare color_distance.
+       (QCdistant_foreground): New variable.
+       (NEAR_SAME_COLOR_THRESHOLD): New define.
+       (load_color2): New function.
+       (load_color): Call load_color2.
+       (load_face_colors): Call load_color2 and if distant-color is specified
+       calculate distant and use distant-color if colors are near.
+       (LFACE_DISTANT_FOREGROUND): New define.
+       (merge_face_ref, Finternal_set_lisp_face_attribute)
+       (Finternal_get_lisp_face_attribute)
+       (x_supports_face_attributes_p): Handle distant-foreground similar to
+       foreground.
+       (syms_of_xfaces): DEFSYM QCdistant_foreground.
+
+       * dispextern.h (lface_attribute_index):
+       Add LFACE_DISTANT_FOREGROUND_INDEX.
+
+2013-11-01  Claudio Bley  <claudio.bley@googlemail.com>
+
+       * image.c (pbm_next_char): New function.
+       See http://netpbm.sourceforge.net/doc/pbm.html for the details.
+       (pbm_scan_number): Use it.
+       (Qlibjpeg_version): New variable.
+       (syms_of_image): DEFSYM and initialize it.
+
+2013-10-31  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * emacs.c (main): Skip -psn args on OSX even if ! isatty (0).
+
+2013-10-31  Glenn Morris  <rgm@gnu.org>
+
+       * emacs.c (original_pwd): New char.
+       (main): If using --chdir, store original_pwd.
+       (init_cmdargs): When setting Vinvocation_directory based on a
+       relative argv[0], use original_pwd if set.  (Bug#15768)
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * keyboard.c (command_loop_1): If command is nil, call `undefined'.
+
+2013-10-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * insdel.c: Fix minor problems found by static checking.
+       (Qregion_extract_function): Now static.
+       (prepare_to_modify_buffer_1): Remove unused locals.
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * xdisp.c (prepare_menu_bars): Call Vpre_redisplay_function.
+       (syms_of_xdisp): Declare pre-redisplay-function.
+       (markpos_of_region): Remove function.
+       (init_iterator, compute_stop_pos, handle_face_prop)
+       (face_before_or_after_it_pos, reseat_to_string)
+       (get_next_display_element, window_buffer_changed)
+       (redisplay_internal, try_cursor_movement, redisplay_window)
+       (try_window_reusing_current_matrix, try_window_id, display_line)
+       (note_mode_line_or_margin_highlight, note_mouse_highlight)
+       (display_string, mouse_face_from_buffer_pos): Remove region handling.
+       * window.h (struct window): Remove field `region_showing'.
+       * dispextern.h (struct it): Remove region_beg/end_charpos.
+       (face_at_buffer_position, face_for_overlay_string)
+       (face_at_string_position): Update prototypes.
+       * xfaces.c (face_at_buffer_position, face_for_overlay_string)
+       (face_at_string_position): Remove `region_beg' and `region_end' args.
+       * fontset.c (Finternal_char_font):
+       * font.c (font_at, font_range): Adjust calls accordingly.
+       * insdel.c (Qregion_extract_function): New var.
+       (syms_of_insdel): Initialize it.
+       (prepare_to_modify_buffer_1): Use it.
+
+2013-10-29  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Prefer 'unsigned long' to 'long unsigned int' and 'unsigned long int'.
+       * ftxfont.c (ftxfont_get_gcs):
+       * gtkutil.c (xg_set_widget_bg, xg_set_background_color):
+       * xfaces.c (x_free_colors, x_free_dpy_colors)
+       (x_create_gc, unload_color):
+       * xselect.c (x_property_data_to_lisp):
+       * xsettings.c (parse_settings):
+       * xterm.c (x_copy_color, x_alloc_lighter_color, x_setup_relief_color)
+       (get_bits_and_offset): Adjust definition.
+       * frame.c (XParseGeometry): Adjust locals.
+       * lisp.h (toplevel): Adjust EMACS_UINT type definition.
+       * regex.h (toplevel): Likewise for reg_syntax_t.
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * eval.c (run_hook_with_args): Use FUNCTIONP.
+
+2013-10-29  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * xterm.h (struct x_output): For 'black_relief' and 'white_relief'
+       fields, drop 'allocated_p' member and use -1 for uninitialized value.
+       * w32term.h (struct w32_output): Similarly but do not use -1 because...
+       * xfaces.c (unload_color) [HAVE_X_WINDOWS]: ...this function is a no-op
+       on MS-Windows anyway.
+       (free_face_colors): Define only if HAVE_X_WINDOWS and...
+       (free_realized_face): ...adjust user.
+       * xfns.c (Fx_create_frame, x_create_tip_frame): Initialize black and
+       white relief pixels to -1.
+       * xterm.c (x_setup_relief_color, x_free_frame_resources): Adjust users.
+       * w32term.c (w32_setup_relief_color, x_free_frame_resources): Likewise.
+       * dispextern.h (unload_color): Move prototype under HAVE_X_WINDOWS.
+
+2013-10-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * dispextern.h, image.c (x_bitmap_height, x_bitmap_width): Now static.
+       * xfaces.c (load_pixmap): Omit last two args, which are always NULL
+       in practice now.  All callers changed.
+
+2013-10-28  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * dispextern.h (struct face): Use bitfields for 'underline_type'
+       and 'box' members.  Remove set-but-unused members 'pixmap_w' and
+       'pixmap_h'.  If not HAVE_WINDOW_SYSTEM, also remove dummy
+       'stipple' member.  Move 'lface' member up to help...
+       * xfaces.c (make_realized_face): ...this function to find and
+       clear just the members that need clearing.
+       (load_face_colors, realize_x_face):
+       * xdisp.c (extend_face_to_end_of_line): Adjust user.
+
+2013-10-27  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * xftfont.c (struct xftfont_info): Remove set-but-unused
+       'screen' member.
+       (xftfont_open): Adjust user.
+       (xftfont_get_colors): Remove useless prototype.
+
+2013-10-26  Eli Zaretskii  <eliz@gnu.org>
+
+       * emacs.c (Fdump_emacs): Encode FILENAME and SYMFILE arguments
+       before passing them to 'unexec'.  (Bug#15260)
+
+2013-10-26  Xue Fuqiao  <xfq.free@gmail.com>
+
+       * fringe.c (set_fringe_bitmap_face): Add usage note from lispref.
+
+2013-10-25  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32uniscribe.c (uniscribe_close): Adjust the argument list to
+       the changed signature of the font driver's 'close' method.
+
+       * w32font.h (w32font_close): Adjust the prototype to the change in
+       function definition.
+
+       * w32font.c (w32font_close): Reintroduce deleted declaration of i.
+
+       * w32uniscribe.c (uniscribe_close): Adapt the call to
+       w32font_close to its new prototype.
+
+2013-10-25  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Omit unused frame argument of font API's close function.
+       * font.h (struct font): Drop frame argument.  Adjust comment.
+       * font.c (font_clear_cache, font_close_object): Adjust users.
+       * ftfont.c (ftfont_close):
+       * ftxfont.c (ftxfont_close):
+       * macfont.m (macfont_close):
+       * nsfont.m (nsfont_close):
+       * w32font.c (w32font_close):
+       * xfont.c (xfont_close):
+       * xftfont.c (xftfont_close): Adjust driver-specific close functions,
+       tweak comments and make functions safe if called more than once for
+       the same font object.
+
+       Perform font-specific cleanup when font object is swept by GC.  See
+       http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00740.html.
+       * alloc.c (cleanup_vector): New function.
+       (sweep_vector): Call it for each reclaimed vector object.
+       * font.h (struct font): Adjust comment.
+
+2013-10-24  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (abs_top_srcdir): New, set by configure.
+
+2013-10-23  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Adjust recent font-related changes to fix bug#15686.
+       * alloc.c (mark_object) [HAVE_WINDOW_SYSTEM]: If marked frame
+       is a live window system frame, mark its default font too.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (RUN_TEMACS): Make relative (again).
+       ($(leimdir)/leim-list.el, .el.elc, $(lispsource)/loaddefs.el)
+       (bootstrap-emacs$(EXEEXT)):
+       Quote entities that might contain whitespace.
+
+2013-10-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to Solaris 10 and its bundled GCC.
+       Problem reported by Timothy C. Burt.
+       * floatfns.c (isfinite, isnan): Redefine unconditionally.
+
+2013-10-21  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Do not allow font caches to grow too large.
+       * alloc.c (compact_font_cache_entry, compact_font_caches):
+       New functions or stub if not HAVE_WINDOW_SYSTEM.
+       (compact_undo_list): Factor out from Fgarbage_collect.
+       Add comment.
+       (mark_face_cache): Mark face font.  Move down to avoid
+       extra prototypes.
+       (mark_terminals): Do not mark font cache here.
+       (Fgarbage_collect): Call compaction functions described
+       above.  Adjust comment.
+
+2013-10-20  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * emacs.c (main): On Cocoa, if GUI session and 0 is not a tty,
+       chdir to HOME (bug#15607).
+
+       * nsterm.m (Qcocoa, Qgnustep): New variables.
+       (syms_of_nsterm): Defsym Qcocoa, Qgnustep.  Fprovide appropriate one.
+       (ns_get_color): Make selection color work for GNUStep also.
+
 2013-10-18  Eli Zaretskii  <eliz@gnu.org>
 
        * keyboard.c (make_lispy_event): Remove GPM-specific code that
        (get_adapters_info): New wrapper function.
        (globals_of_w32): Initialize g_b_init_get_adapters_info.
 
-       * process.h (network_interface_list, network_interface_info): New
-       prototypes.
+       * process.h (network_interface_list, network_interface_info):
+       New prototypes.
 
        * process.c (conv_sockaddr_to_lisp): Now externally-visible.
        (Fnetwork_interface_list, Fnetwork_interface_info): Define for
        (xw_popup_dialog): New function, with X-specific bits of popup
        dialogs.
 
-       * xdisp.c (deep_copy_glyph_row, display_tty_menu_item): New
-       functions.
+       * xdisp.c (deep_copy_glyph_row, display_tty_menu_item):
+       New functions.
 
        * window.c (Fset_window_configuration): Use run-time tests of the
        frame type instead of compile-time conditionals, when menu-bar
        of, or in addition to, compile-time conditionals.
        (menu_item_width, Fmenu_bar_menu_at_x_y): New functions.
        (Fx_popup_menu): Detect when the function is called from keyboard
-       on a TTY.  Don't barf when invoked on a text-mode frame.  Check
-       frame type at run time, instead of compile-time conditionals for
-       invoking terminal-specific menu-show functions.  Call
-       tty_menu_show on text-mode frames.
-       (Fx_popup_dialog): Moved here from xmenu.c.  Test frame types at
+       on a TTY.  Don't barf when invoked on a text-mode frame.
+       Check frame type at run time, instead of compile-time conditionals for
+       invoking terminal-specific menu-show functions.
+       Call tty_menu_show on text-mode frames.
+       (Fx_popup_dialog): Move here from xmenu.c.  Test frame types at
        run time to determine which alternative to invoke; support dialogs
        on TTYs.
 
 
        * keyboard.c (read_decoded_char): Don't decode under w32 (bug#14403).
 
-2013-05-22  Barry OReilly  <gundaetiapo@gmail.com>  (tiny change)
+2013-05-22  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * casetab.c (init_casetab_once): Fix last change (bug#14424).
 
        character numbers counted by detect_coding_utf_8.  Fix detection
        of BOM for utf-8.
 
-2013-05-21  Barry OReilly  <gundaetiapo@gmail.com>  (tiny change)
+2013-05-21  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * search.c (looking_at_1): Only set last_thing_searched if the match
        changed the match-data (bug#14281).
index 053baa3d48797ac9b11e79e5695cf69bef883a0e..b14ce20ede31566e8b561feffc4780018d6e3454 100644 (file)
        is undefined.  See Stefan Monnier in
        <http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00762.html>.
 
-2012-08-26  Barry OReilly  <gundaetiapo@gmail.com>  (tiny change)
+2012-08-26  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * lisp.h (functionp): New function (extracted from Ffunctionp).
        (FUNCTIONP): Use it.
        * editfns.c (Fformat): Doc fix (Bug#12059).
        (Fsave_current_buffer): Doc fix (Bug#11542).
 
-2012-08-14  Barry OReilly  <gundaetiapo@gmail.com>  (tiny change)
+2012-08-14  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * keyboard.c (access_keymap_keyremap): Accept anonymous functions
        (bug#12022).
index 254aa175d49860f9de37dedcc237d1cfe9ca3009..ca0b25a2f690960593790ddcb672332090f10f84 100644 (file)
@@ -1,7 +1,7 @@
 ### @configure_input@
 
-# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013 Free Software
-# Foundation, Inc.
+# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013
+#   Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -28,8 +28,9 @@ SHELL = @SHELL@
 # Here are the things that we expect ../configure to edit.
 # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
 srcdir = @srcdir@
+# MinGW CPPFLAGS may use this.
+abs_top_srcdir=@abs_top_srcdir@
 ntsource = $(srcdir)/../nt
-abs_builddir = @abs_builddir@
 VPATH = $(srcdir)
 CC = @CC@
 WINDRES = @WINDRES@
@@ -54,12 +55,11 @@ etc = ../etc
 leimdir = ../leim
 oldXMenudir = ../oldXMenu
 lwlibdir = ../lwlib
-lispdir = ../lisp
 
 # Configuration files for .o files to depend on.
 config_h = config.h $(srcdir)/conf_post.h
 
-bootstrap_exe = $(abs_builddir)/bootstrap-emacs$(EXEEXT)
+bootstrap_exe = ../src/bootstrap-emacs$(EXEEXT)
 
 ## ns-app if HAVE_NS, else empty.
 OTHER_FILES = @OTHER_FILES@
@@ -313,7 +313,7 @@ INTERVALS_H = dispextern.h intervals.h composite.h
 
 GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
 
-RUN_TEMACS = `/bin/pwd`/temacs
+RUN_TEMACS = ./temacs
 
 ## Invoke ../nt/addsection for MinGW, ":" elsewhere.
 TEMACS_POST_LINK = @TEMACS_POST_LINK@
@@ -437,7 +437,7 @@ all: emacs$(EXEEXT) $(OTHER_FILES)
 .PHONY: all
 
 $(leimdir)/leim-list.el: bootstrap-emacs$(EXEEXT)
-       cd $(leimdir) && $(MAKE) $(MFLAGS) leim-list.el EMACS=$(bootstrap_exe)
+       cd $(leimdir) && $(MAKE) $(MFLAGS) leim-list.el EMACS="$(bootstrap_exe)"
 
 ## The dumped Emacs is as functional and more efficient than
 ## bootstrap-emacs, so we replace the latter with the former.
@@ -555,7 +555,7 @@ ns-app: emacs$(EXEEXT)
        cd ../nextstep && $(MAKE) $(MFLAGS) all
 
 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
-.PHONY: versionclean extraclean frc
+.PHONY: versionclean extraclean
 
 mostlyclean:
        rm -f temacs$(EXEEXT) core *.core \#* *.o libXMenu11.a liblw.a
@@ -578,40 +578,45 @@ bootstrap-clean: clean
          if test -f "$(srcdir)/.gdbinit"; then rm -f ./.gdbinit.save; \
          else mv ./.gdbinit.save ./.gdbinit; fi; \
        fi
-## This is used in making a distribution.
-## Do not use it on development directories!
+
 distclean: bootstrap-clean
        rm -f Makefile
+
 maintainer-clean: distclean
-       @echo "This command is intended for maintainers to use;"
-       @echo "it deletes files that may require special tools to rebuild."
        rm -f TAGS
 versionclean:
        -rm -f emacs$(EXEEXT) emacs-*.*.*$(EXEEXT) ../etc/DOC*
 extraclean: distclean
-       -rm -f *~ \#* m/?*~ s/?*~
+       -rm -f *~ \#*
+
 
-## Arrange to make a tags table TAGS-LISP for ../lisp,
-## plus TAGS for the C files, which includes ../lisp/TAGS by reference.
+ETAGS = ../lib-src/etags
 
 ctagsfiles1 = [xyzXYZ]*.[hc]
 ctagsfiles2 = [a-wA-W]*.[hc]
 ctagsfiles3 = [a-zA-Z]*.m
 
-TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(S_FILE)
-       ../lib-src/etags --include=TAGS-LISP --include=$(lwlibdir)/TAGS \
+## FIXME? In out-of-tree builds, should TAGS be generated in srcdir?
+
+## This does not need to depend on ../lisp and ../lwlib TAGS files,
+## because etags "--include" only includes a pointer to the file,
+## rather than the file contents.
+TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(srcdir)/$(ctagsfiles3)
+       "$(ETAGS)" --include=../lisp/TAGS --include=$(lwlibdir)/TAGS \
          --regex='{c}/[        ]*DEFVAR_[A-Z_  (]+"\([^"]+\)"/' \
-         $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) $(S_FILE) \
+         $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2) \
          --regex='{objc}/[     ]*DEFVAR_[A-Z_  (]+"\([^"]+\)"/' \
          $(srcdir)/$(ctagsfiles3)
-frc:
-TAGS-LISP: frc
-       $(MAKE) -f $(lispdir)/Makefile TAGS-LISP ETAGS=../lib-src/etags
+
+## Arrange to make tags tables for ../lisp and ../lwlib,
+## which the above TAGS file for the C files includes by reference.
+../lisp/TAGS:
+       cd ../lisp && $(MAKE) TAGS ETAGS="$(ETAGS)"
 
 $(lwlibdir)/TAGS:
-       (cd $(lwlibdir); $(MAKE) -f $(lwlibdir)/Makefile tags ETAGS=../lib-src/etags)
+       cd $(lwlibdir) && $(MAKE) TAGS ETAGS="$(ETAGS)"
 
-tags: TAGS TAGS-LISP $(lwlibdir)/TAGS
+tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
 .PHONY: tags
 
 
@@ -646,7 +651,7 @@ tags: TAGS TAGS-LISP $(lwlibdir)/TAGS
 ## With GNU Make, we would just say "%.el : %.elc $(BOOTSTRAPEMACS)"
 .el.elc:
        @cd ../lisp; $(MAKE) $(MFLAGS) compile-onefile \
-                            THEFILE=$< EMACS=$(bootstrap_exe)
+                            THEFILE=$< EMACS="$(bootstrap_exe)"
 
 ## Since the .el.elc rule cannot specify an extra dependency, we do it here.
 $(lisp): $(BOOTSTRAPEMACS)
@@ -657,7 +662,7 @@ $(lisp): $(BOOTSTRAPEMACS)
 VCSWITNESS =
 
 $(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS)
-       cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=$(bootstrap_exe)
+       cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS="$(bootstrap_exe)"
 
 ## Dump an Emacs executable named bootstrap-emacs containing the
 ## files from loadup.el in source form.
@@ -672,7 +677,7 @@ bootstrap-emacs$(EXEEXT): temacs$(EXEEXT)
          mv -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT); \
        fi
        @: Compile some files earlier to speed up further compilation.
-       cd ../lisp; $(MAKE) $(MFLAGS) compile-first EMACS=$(bootstrap_exe)
+       cd ../lisp; $(MAKE) $(MFLAGS) compile-first EMACS="$(bootstrap_exe)"
 
 ## Insert either autodeps.mk (if AUTO_DEPEND), else deps.mk.
 @deps_frag@
index 02deaa94af128bcc63f10c63099609bb25c2335b..f12fdc5c861efc78b9b2c4e0f40ba1005ba76d53 100644 (file)
@@ -361,13 +361,21 @@ static int staticidx;
 
 static void *pure_alloc (size_t, int);
 
+/* Return X rounded to the next multiple of Y.  Arguments should not
+   have side effects, as they are evaluated more than once.  Assume X
+   + Y - 1 does not overflow.  Tune for Y being a power of 2.  */
 
-/* Value is SZ rounded up to the next multiple of ALIGNMENT.
-   ALIGNMENT must be a power of 2.  */
+#define ROUNDUP(x, y) ((y) & ((y) - 1)                                 \
+                      ? ((x) + (y) - 1) - ((x) + (y) - 1) % (y)        \
+                      : ((x) + (y) - 1) & ~ ((y) - 1))
 
-#define ALIGN(ptr, ALIGNMENT) \
-  ((void *) (((uintptr_t) (ptr) + (ALIGNMENT) - 1) \
-            & ~ ((ALIGNMENT) - 1)))
+/* Return PTR rounded up to the next multiple of ALIGNMENT.  */
+
+static void *
+ALIGN (void *ptr, int alignment)
+{
+  return (void *) ROUNDUP ((uintptr_t) ptr, alignment);
+}
 
 static void
 XFLOAT_INIT (Lisp_Object f, double n)
@@ -912,8 +920,20 @@ lisp_free (void *block)
 /* The entry point is lisp_align_malloc which returns blocks of at most
    BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary.  */
 
-#if defined (HAVE_POSIX_MEMALIGN) && defined (SYSTEM_MALLOC)
-#define USE_POSIX_MEMALIGN 1
+#if !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC
+# define USE_ALIGNED_ALLOC 1
+/* Defined in gmalloc.c.  */
+void *aligned_alloc (size_t, size_t);
+#elif defined HAVE_ALIGNED_ALLOC
+# define USE_ALIGNED_ALLOC 1
+#elif defined HAVE_POSIX_MEMALIGN
+# define USE_ALIGNED_ALLOC 1
+static void *
+aligned_alloc (size_t alignment, size_t size)
+{
+  void *p;
+  return posix_memalign (&p, alignment, size) == 0 ? p : 0;
+}
 #endif
 
 /* BLOCK_ALIGN has to be a power of 2.  */
@@ -923,7 +943,7 @@ lisp_free (void *block)
    malloc a chance to minimize the amount of memory wasted to alignment.
    It should be tuned to the particular malloc library used.
    On glibc-2.3.2, malloc never tries to align, so a padding of 0 is best.
-   posix_memalign on the other hand would ideally prefer a value of 4
+   aligned_alloc on the other hand would ideally prefer a value of 4
    because otherwise, there's 1020 bytes wasted between each ablocks.
    In Emacs, testing shows that those 1020 can most of the time be
    efficiently used by malloc to place other objects, so a value of 0 can
@@ -968,7 +988,7 @@ struct ablocks
   struct ablock blocks[ABLOCKS_SIZE];
 };
 
-/* Size of the block requested from malloc or posix_memalign.  */
+/* Size of the block requested from malloc or aligned_alloc.  */
 #define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING)
 
 #define ABLOCK_ABASE(block) \
@@ -980,7 +1000,7 @@ struct ablocks
 #define ABLOCKS_BUSY(abase) ((abase)->blocks[0].abase)
 
 /* Pointer to the (not necessarily aligned) malloc block.  */
-#ifdef USE_POSIX_MEMALIGN
+#ifdef USE_ALIGNED_ALLOC
 #define ABLOCKS_BASE(abase) (abase)
 #else
 #define ABLOCKS_BASE(abase) \
@@ -1019,13 +1039,8 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
       mallopt (M_MMAP_MAX, 0);
 #endif
 
-#ifdef USE_POSIX_MEMALIGN
-      {
-       int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES);
-       if (err)
-         base = NULL;
-       abase = base;
-      }
+#ifdef USE_ALIGNED_ALLOC
+      abase = base = aligned_alloc (BLOCK_ALIGN, ABLOCKS_BYTES);
 #else
       base = malloc (ABLOCKS_BYTES);
       abase = ALIGN (base, BLOCK_ALIGN);
@@ -1280,28 +1295,32 @@ mark_interval (register INTERVAL i, Lisp_Object dummy)
 
 #define LARGE_STRING_BYTES 1024
 
-/* Struct or union describing string memory sub-allocated from an sblock.
-   This is where the contents of Lisp strings are stored.  */
-
-#ifdef GC_CHECK_STRING_BYTES
+/* The SDATA typedef is a struct or union describing string memory
+   sub-allocated from an sblock.  This is where the contents of Lisp
+   strings are stored.  */
 
-typedef struct
+struct sdata
 {
   /* Back-pointer to the string this sdata belongs to.  If null, this
-     structure is free, and the NBYTES member of the union below
+     structure is free, and NBYTES (in this structure or in the union below)
      contains the string's byte size (the same value that STRING_BYTES
      would return if STRING were non-null).  If non-null, STRING_BYTES
      (STRING) is the size of the data, and DATA contains the string's
      contents.  */
   struct Lisp_String *string;
 
+#ifdef GC_CHECK_STRING_BYTES
   ptrdiff_t nbytes;
+#endif
+
   unsigned char data[FLEXIBLE_ARRAY_MEMBER];
-} sdata;
+};
 
+#ifdef GC_CHECK_STRING_BYTES
+
+typedef struct sdata sdata;
 #define SDATA_NBYTES(S)        (S)->nbytes
 #define SDATA_DATA(S)  (S)->data
-#define SDATA_SELECTOR(member) member
 
 #else
 
@@ -1309,12 +1328,16 @@ typedef union
 {
   struct Lisp_String *string;
 
-  /* When STRING is non-null.  */
-  struct
-  {
-    struct Lisp_String *string;
-    unsigned char data[FLEXIBLE_ARRAY_MEMBER];
-  } u;
+  /* When STRING is nonnull, this union is actually of type 'struct sdata',
+     which has a flexible array member.  However, if implemented by
+     giving this union a member of type 'struct sdata', the union
+     could not be the last (flexible) member of 'struct sblock',
+     because C99 prohibits a flexible array member from having a type
+     that is itself a flexible array.  So, comment this member out here,
+     but remember that the option's there when using this union.  */
+#if 0
+  struct sdata u;
+#endif
 
   /* When STRING is null.  */
   struct
@@ -1325,13 +1348,11 @@ typedef union
 } sdata;
 
 #define SDATA_NBYTES(S)        (S)->n.nbytes
-#define SDATA_DATA(S)  (S)->u.data
-#define SDATA_SELECTOR(member) u.member
+#define SDATA_DATA(S)  ((struct sdata *) (S))->data
 
 #endif /* not GC_CHECK_STRING_BYTES */
 
-#define SDATA_DATA_OFFSET offsetof (sdata, SDATA_SELECTOR (data))
-
+enum { SDATA_DATA_OFFSET = offsetof (struct sdata, data) };
 
 /* Structure describing a block of memory which is sub-allocated to
    obtain string data memory for strings.  Blocks for small strings
@@ -1347,8 +1368,8 @@ struct sblock
      of the sblock if there isn't any space left in this block.  */
   sdata *next_free;
 
-  /* Start of data.  */
-  sdata first_data;
+  /* String data.  */
+  sdata data[FLEXIBLE_ARRAY_MEMBER];
 };
 
 /* Number of Lisp strings in a string_block structure.  The 1020 is
@@ -1464,7 +1485,7 @@ static ptrdiff_t const STRING_BYTES_MAX =
   min (STRING_BYTES_BOUND,
        ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD
         - GC_STRING_EXTRA
-        - offsetof (struct sblock, first_data)
+        - offsetof (struct sblock, data)
         - SDATA_DATA_OFFSET)
        & ~(sizeof (EMACS_INT) - 1)));
 
@@ -1507,7 +1528,7 @@ check_sblock (struct sblock *b)
 
   end = b->next_free;
 
-  for (from = &b->first_data; from < end; from = from_end)
+  for (from = b->data; from < end; from = from_end)
     {
       /* Compute the next FROM here because copying below may
         overwrite data we need to compute it.  */
@@ -1535,7 +1556,7 @@ check_string_bytes (bool all_p)
 
       for (b = large_sblocks; b; b = b->next)
        {
-         struct Lisp_String *s = b->first_data.string;
+         struct Lisp_String *s = b->data[0].string;
          if (s)
            string_bytes (s);
        }
@@ -1669,7 +1690,7 @@ allocate_string_data (struct Lisp_String *s,
 
   if (nbytes > LARGE_STRING_BYTES)
     {
-      size_t size = offsetof (struct sblock, first_data) + needed;
+      size_t size = offsetof (struct sblock, data) + needed;
 
 #ifdef DOUG_LEA_MALLOC
       /* Prevent mmap'ing the chunk.  Lisp data may not be mmap'ed
@@ -1691,8 +1712,8 @@ allocate_string_data (struct Lisp_String *s,
       mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
 #endif
 
-      b->next_free = &b->first_data;
-      b->first_data.string = NULL;
+      b->next_free = b->data;
+      b->data[0].string = NULL;
       b->next = large_sblocks;
       large_sblocks = b;
     }
@@ -1703,8 +1724,8 @@ allocate_string_data (struct Lisp_String *s,
     {
       /* Not enough room in the current sblock.  */
       b = lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP);
-      b->next_free = &b->first_data;
-      b->first_data.string = NULL;
+      b->next_free = b->data;
+      b->data[0].string = NULL;
       b->next = NULL;
 
       if (current_sblock)
@@ -1858,7 +1879,7 @@ free_large_strings (void)
     {
       next = b->next;
 
-      if (b->first_data.string == NULL)
+      if (b->data[0].string == NULL)
        lisp_free (b);
       else
        {
@@ -1885,7 +1906,7 @@ compact_small_strings (void)
      to, and TB_END is the end of TB.  */
   tb = oldest_sblock;
   tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
-  to = &tb->first_data;
+  to = tb->data;
 
   /* Step through the blocks from the oldest to the youngest.  We
      expect that old blocks will stabilize over time, so that less
@@ -1895,7 +1916,7 @@ compact_small_strings (void)
       end = b->next_free;
       eassert ((char *) end <= (char *) b + SBLOCK_SIZE);
 
-      for (from = &b->first_data; from < end; from = from_end)
+      for (from = b->data; from < end; from = from_end)
        {
          /* Compute the next FROM here because copying below may
             overwrite data we need to compute it.  */
@@ -1932,7 +1953,7 @@ compact_small_strings (void)
                  tb->next_free = to;
                  tb = tb->next;
                  tb_end = (sdata *) ((char *) tb + SBLOCK_SIZE);
-                 to = &tb->first_data;
+                 to = tb->data;
                  to_end = (sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
                }
 
@@ -2020,82 +2041,61 @@ INIT must be an integer that represents a character.  */)
   return val;
 }
 
-verify (sizeof (size_t) * CHAR_BIT == BITS_PER_BITS_WORD);
-verify ((BITS_PER_BITS_WORD & (BITS_PER_BITS_WORD - 1)) == 0);
+/* Fill A with 1 bits if INIT is non-nil, and with 0 bits otherwise.
+   Return A.  */
 
-static ptrdiff_t
-bool_vector_payload_bytes (ptrdiff_t nr_bits,
-                           ptrdiff_t *exact_needed_bytes_out)
+Lisp_Object
+bool_vector_fill (Lisp_Object a, Lisp_Object init)
 {
-  ptrdiff_t exact_needed_bytes;
-  ptrdiff_t needed_bytes;
-
-  eassume (nr_bits >= 0);
-
-  exact_needed_bytes = ROUNDUP ((size_t) nr_bits, CHAR_BIT) / CHAR_BIT;
-  needed_bytes = ROUNDUP ((size_t) nr_bits, BITS_PER_BITS_WORD) / CHAR_BIT;
-
-  if (needed_bytes == 0)
+  EMACS_INT nbits = bool_vector_size (a);
+  if (0 < nbits)
     {
-      /* Always allocate at least one machine word of payload so that
-         bool-vector operations in data.c don't need a special case
-         for empty vectors.  */
-      needed_bytes = sizeof (bits_word);
+      unsigned char *data = bool_vector_uchar_data (a);
+      int pattern = NILP (init) ? 0 : (1 << BOOL_VECTOR_BITS_PER_CHAR) - 1;
+      ptrdiff_t nbytes = bool_vector_bytes (nbits);
+      int last_mask = ~ (~0 << ((nbits - 1) % BOOL_VECTOR_BITS_PER_CHAR + 1));
+      memset (data, pattern, nbytes - 1);
+      data[nbytes - 1] = pattern & last_mask;
     }
-
-  if (exact_needed_bytes_out != NULL)
-    *exact_needed_bytes_out = exact_needed_bytes;
-
-  return needed_bytes;
+  return a;
 }
 
-DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0,
-       doc: /* Return a new bool-vector of length LENGTH, using INIT for each element.
-LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
-  (Lisp_Object length, Lisp_Object init)
+/* Return a newly allocated, uninitialized bool vector of size NBITS.  */
+
+Lisp_Object
+make_uninit_bool_vector (EMACS_INT nbits)
 {
-  register Lisp_Object val;
+  Lisp_Object val;
   struct Lisp_Bool_Vector *p;
-  ptrdiff_t exact_payload_bytes;
-  ptrdiff_t total_payload_bytes;
-  ptrdiff_t needed_elements;
-
-  CHECK_NATNUM (length);
-  if (PTRDIFF_MAX < XFASTINT (length))
-    memory_full (SIZE_MAX);
-
-  total_payload_bytes = bool_vector_payload_bytes
-    (XFASTINT (length), &exact_payload_bytes);
-
-  eassume (exact_payload_bytes <= total_payload_bytes);
-  eassume (0 <= exact_payload_bytes);
-
-  needed_elements = ROUNDUP ((size_t) ((bool_header_size - header_size)
-                                       + total_payload_bytes),
-                             word_size) / word_size;
-
+  EMACS_INT word_bytes, needed_elements;
+  word_bytes = bool_vector_words (nbits) * sizeof (bits_word);
+  needed_elements = ((bool_header_size - header_size + word_bytes
+                     + word_size - 1)
+                    / word_size);
   p = (struct Lisp_Bool_Vector *) allocate_vector (needed_elements);
   XSETVECTOR (val, p);
   XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0);
-
-  p->size = XFASTINT (length);
-  if (exact_payload_bytes)
-    {
-      memset (p->data, ! NILP (init) ? -1 : 0, exact_payload_bytes);
-
-      /* Clear any extraneous bits in the last byte.  */
-      p->data[exact_payload_bytes - 1]
-       &= (1 << ((XFASTINT (length) - 1) % BOOL_VECTOR_BITS_PER_CHAR + 1)) - 1;
-    }
+  p->size = nbits;
 
   /* Clear padding at the end.  */
-  memset (p->data + exact_payload_bytes,
-          0,
-          total_payload_bytes - exact_payload_bytes);
+  if (nbits)
+    p->data[bool_vector_words (nbits) - 1] = 0;
 
   return val;
 }
 
+DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0,
+       doc: /* Return a new bool-vector of length LENGTH, using INIT for each element.
+LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
+  (Lisp_Object length, Lisp_Object init)
+{
+  Lisp_Object val;
+
+  CHECK_NATNUM (length);
+  val = make_uninit_bool_vector (XFASTINT (length));
+  return bool_vector_fill (val, init);
+}
+
 
 /* Make a string from NBYTES bytes at CONTENTS, and compute the number
    of characters from the contents.  This string may be unibyte or
@@ -2606,16 +2606,35 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
                           Vector Allocation
  ***********************************************************************/
 
+/* Sometimes a vector's contents are merely a pointer internally used
+   in vector allocation code.  Usually you don't want to touch this.  */
+
+static struct Lisp_Vector *
+next_vector (struct Lisp_Vector *v)
+{
+  return XUNTAG (v->contents[0], 0);
+}
+
+static void
+set_next_vector (struct Lisp_Vector *v, struct Lisp_Vector *p)
+{
+  v->contents[0] = make_lisp_ptr (p, 0);
+}
+
 /* This value is balanced well enough to avoid too much internal overhead
    for the most common cases; it's not required to be a power of two, but
    it's expected to be a mult-of-ROUNDUP_SIZE (see below).  */
 
 #define VECTOR_BLOCK_SIZE 4096
 
-/* Align allocation request sizes to be a multiple of ROUNDUP_SIZE.  */
 enum
   {
-    roundup_size = COMMON_MULTIPLE (word_size, USE_LSB_TAG ? GCALIGNMENT : 1)
+    /* Alignment of struct Lisp_Vector objects.  */
+    vector_alignment = COMMON_MULTIPLE (ALIGNOF_STRUCT_LISP_VECTOR,
+                                       USE_LSB_TAG ? GCALIGNMENT : 1),
+
+    /* Vector size requests are a multiple of this.  */
+    roundup_size = COMMON_MULTIPLE (vector_alignment, word_size)
   };
 
 /* Verify assumptions described above.  */
@@ -2623,7 +2642,7 @@ verify ((VECTOR_BLOCK_SIZE % roundup_size) == 0);
 verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
 
 /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time.  */
-#define vroundup_ct(x) ROUNDUP ((size_t) (x), roundup_size)
+#define vroundup_ct(x) ROUNDUP (x, roundup_size)
 /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at runtime.  */
 #define vroundup(x) (eassume ((x) >= 0), vroundup_ct (x))
 
@@ -2663,26 +2682,37 @@ verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
     eassert ((nbytes) % roundup_size == 0);            \
     (tmp) = VINDEX (nbytes);                           \
     eassert ((tmp) < VECTOR_MAX_FREE_LIST_INDEX);      \
-    v->u.next = vector_free_lists[tmp];                        \
+    set_next_vector (v, vector_free_lists[tmp]);       \
     vector_free_lists[tmp] = (v);                      \
     total_free_vector_slots += (nbytes) / word_size;   \
   } while (0)
 
 /* This internal type is used to maintain the list of large vectors
-   which are allocated at their own, e.g. outside of vector blocks.  */
+   which are allocated at their own, e.g. outside of vector blocks.
+
+   struct large_vector itself cannot contain a struct Lisp_Vector, as
+   the latter contains a flexible array member and C99 does not allow
+   such structs to be nested.  Instead, each struct large_vector
+   object LV is followed by a struct Lisp_Vector, which is at offset
+   large_vector_offset from LV, and whose address is therefore
+   large_vector_vec (&LV).  */
 
 struct large_vector
 {
-  union {
-    struct large_vector *vector;
-#if USE_LSB_TAG
-    /* We need to maintain ROUNDUP_SIZE alignment for the vector member.  */
-    unsigned char c[vroundup_ct (sizeof (struct large_vector *))];
-#endif
-  } next;
-  struct Lisp_Vector v;
+  struct large_vector *next;
 };
 
+enum
+{
+  large_vector_offset = ROUNDUP (sizeof (struct large_vector), vector_alignment)
+};
+
+static struct Lisp_Vector *
+large_vector_vec (struct large_vector *p)
+{
+  return (struct Lisp_Vector *) ((char *) p + large_vector_offset);
+}
+
 /* This internal type is used to maintain an underlying storage
    for small vectors.  */
 
@@ -2760,7 +2790,7 @@ allocate_vector_from_block (size_t nbytes)
   if (vector_free_lists[index])
     {
       vector = vector_free_lists[index];
-      vector_free_lists[index] = vector->u.next;
+      vector_free_lists[index] = next_vector (vector);
       total_free_vector_slots -= nbytes / word_size;
       return vector;
     }
@@ -2774,7 +2804,7 @@ allocate_vector_from_block (size_t nbytes)
       {
        /* This vector is larger than requested.  */
        vector = vector_free_lists[index];
-       vector_free_lists[index] = vector->u.next;
+       vector_free_lists[index] = next_vector (vector);
        total_free_vector_slots -= nbytes / word_size;
 
        /* Excess bytes are used for the smaller vector,
@@ -2814,27 +2844,40 @@ static ptrdiff_t
 vector_nbytes (struct Lisp_Vector *v)
 {
   ptrdiff_t size = v->header.size & ~ARRAY_MARK_FLAG;
+  ptrdiff_t nwords;
 
   if (size & PSEUDOVECTOR_FLAG)
     {
       if (PSEUDOVECTOR_TYPEP (&v->header, PVEC_BOOL_VECTOR))
         {
           struct Lisp_Bool_Vector *bv = (struct Lisp_Bool_Vector *) v;
-          ptrdiff_t payload_bytes =
-              bool_vector_payload_bytes (bv->size, NULL);
-
-          eassume (payload_bytes >= 0);
-          size = bool_header_size + ROUNDUP (payload_bytes, word_size);
+         ptrdiff_t word_bytes = (bool_vector_words (bv->size)
+                                 * sizeof (bits_word));
+         ptrdiff_t boolvec_bytes = bool_header_size + word_bytes;
+         verify (header_size <= bool_header_size);
+         nwords = (boolvec_bytes - header_size + word_size - 1) / word_size;
         }
       else
-       size = (header_size
-               + ((size & PSEUDOVECTOR_SIZE_MASK)
-                  + ((size & PSEUDOVECTOR_REST_MASK)
-                     >> PSEUDOVECTOR_SIZE_BITS)) * word_size);
+       nwords = ((size & PSEUDOVECTOR_SIZE_MASK)
+                 + ((size & PSEUDOVECTOR_REST_MASK)
+                    >> PSEUDOVECTOR_SIZE_BITS));
     }
   else
-    size = header_size + size * word_size;
-  return vroundup (size);
+    nwords = size;
+  return vroundup (header_size + word_size * nwords);
+}
+
+/* Release extra resources still in use by VECTOR, which may be any
+   vector-like object.  For now, this is used just to free data in
+   font objects.  */
+
+static void
+cleanup_vector (struct Lisp_Vector *vector)
+{
+  if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT)
+      && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
+         == FONT_OBJECT_MAX))
+    ((struct font *) vector)->driver->close ((struct font *) vector);
 }
 
 /* Reclaim space used by unmarked vectors.  */
@@ -2871,6 +2914,7 @@ sweep_vectors (void)
            {
              ptrdiff_t total_bytes;
 
+             cleanup_vector (vector);
              nbytes = vector_nbytes (vector);
              total_bytes = nbytes;
              next = ADVANCE (vector, nbytes);
@@ -2882,6 +2926,7 @@ sweep_vectors (void)
                {
                  if (VECTOR_MARKED_P (next))
                    break;
+                 cleanup_vector (next);
                  nbytes = vector_nbytes (next);
                  total_bytes += nbytes;
                  next = ADVANCE (next, nbytes);
@@ -2918,7 +2963,7 @@ sweep_vectors (void)
 
   for (lv = large_vectors; lv; lv = *lvprev)
     {
-      vector = &lv->v;
+      vector = large_vector_vec (lv);
       if (VECTOR_MARKED_P (vector))
        {
          VECTOR_UNMARK (vector);
@@ -2934,11 +2979,11 @@ sweep_vectors (void)
          else
            total_vector_slots
              += header_size / word_size + vector->header.size;
-         lvprev = &lv->next.vector;
+         lvprev = &lv->next;
        }
       else
        {
-         *lvprev = lv->next.vector;
+         *lvprev = lv->next;
          lisp_free (lv);
        }
     }
@@ -2972,12 +3017,12 @@ allocate_vectorlike (ptrdiff_t len)
       else
        {
          struct large_vector *lv
-           = lisp_malloc ((offsetof (struct large_vector, v.u.contents)
+           = lisp_malloc ((large_vector_offset + header_size
                            + len * word_size),
                           MEM_TYPE_VECTORLIKE);
-         lv->next.vector = large_vectors;
+         lv->next = large_vectors;
          large_vectors = lv;
-         p = &lv->v;
+         p = large_vector_vec (lv);
        }
 
 #ifdef DOUG_LEA_MALLOC
@@ -3026,7 +3071,7 @@ allocate_pseudovector (int memlen, int lisplen, enum pvec_type tag)
 
   /* Only the first lisplen slots will be traced normally by the GC.  */
   for (i = 0; i < lisplen; ++i)
-    v->u.contents[i] = Qnil;
+    v->contents[i] = Qnil;
 
   XSETPVECTYPESIZE (v, tag, lisplen, memlen - lisplen);
   return v;
@@ -3114,7 +3159,7 @@ See also the function `vector'.  */)
   p = allocate_vector (XFASTINT (length));
   sizei = XFASTINT (length);
   for (i = 0; i < sizei; i++)
-    p->u.contents[i] = init;
+    p->contents[i] = init;
 
   XSETVECTOR (vector, p);
   return vector;
@@ -3132,7 +3177,7 @@ usage: (vector &rest OBJECTS)  */)
   register struct Lisp_Vector *p = XVECTOR (val);
 
   for (i = 0; i < nargs; i++)
-    p->u.contents[i] = args[i];
+    p->contents[i] = args[i];
   return val;
 }
 
@@ -3141,14 +3186,14 @@ make_byte_code (struct Lisp_Vector *v)
 {
   /* Don't allow the global zero_vector to become a byte code object. */
   eassert(0 < v->header.size);
-  if (v->header.size > 1 && STRINGP (v->u.contents[1])
-      && STRING_MULTIBYTE (v->u.contents[1]))
+  if (v->header.size > 1 && STRINGP (v->contents[1])
+      && STRING_MULTIBYTE (v->contents[1]))
     /* BYTECODE-STRING must have been produced by Emacs 20.2 or the
        earlier because they produced a raw 8-bit string for byte-code
        and now such a byte-code string is loaded as multibyte while
        raw 8-bit characters converted to multibyte form.  Thus, now we
        must convert them back to the original unibyte form.  */
-    v->u.contents[1] = Fstring_as_unibyte (v->u.contents[1]);
+    v->contents[1] = Fstring_as_unibyte (v->contents[1]);
   XSETPVECTYPE (v, PVEC_COMPILED);
 }
 
@@ -3183,7 +3228,7 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
      to be setcar'd).  */
 
   for (i = 0; i < nargs; i++)
-    p->u.contents[i] = args[i];
+    p->contents[i] = args[i];
   make_byte_code (p);
   XSETCOMPILED (val, p);
   return val;
@@ -4241,9 +4286,7 @@ live_vector_p (struct mem_node *m, void *p)
            vector = ADVANCE (vector, vector_nbytes (vector));
        }
     }
-  else if (m->type == MEM_TYPE_VECTORLIKE
-          && (char *) p == ((char *) m->start
-                            + offsetof (struct large_vector, v)))
+  else if (m->type == MEM_TYPE_VECTORLIKE && p == large_vector_vec (m->start))
     /* This memory node corresponds to a large vector.  */
     return 1;
   return 0;
@@ -5174,7 +5217,7 @@ Does not copy symbols.  Copies strings without text properties.  */)
        size &= PSEUDOVECTOR_SIZE_MASK;
       vec = XVECTOR (make_pure_vector (size));
       for (i = 0; i < size; i++)
-       vec->u.contents[i] = Fpurecopy (AREF (obj, i));
+       vec->contents[i] = Fpurecopy (AREF (obj, i));
       if (COMPILEDP (obj))
        {
          XSETPVECTYPE (vec, PVEC_COMPILED);
@@ -5254,6 +5297,95 @@ total_bytes_of_live_objects (void)
   return tot;
 }
 
+#ifdef HAVE_WINDOW_SYSTEM
+
+/* Remove unmarked font-spec and font-entity objects from ENTRY, which is
+   (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...), and return changed entry.  */
+
+static Lisp_Object
+compact_font_cache_entry (Lisp_Object entry)
+{
+  Lisp_Object tail, *prev = &entry;
+
+  for (tail = entry; CONSP (tail); tail = XCDR (tail))
+    {
+      bool drop = 0;
+      Lisp_Object obj = XCAR (tail);
+
+      /* Consider OBJ if it is (font-spec . [font-entity font-entity ...]).  */
+      if (CONSP (obj) && FONT_SPEC_P (XCAR (obj))
+         && !VECTOR_MARKED_P (XFONT_SPEC (XCAR (obj)))
+         && VECTORP (XCDR (obj)))
+       {
+         ptrdiff_t i, size = ASIZE (XCDR (obj)) & ~ARRAY_MARK_FLAG;
+
+         /* If font-spec is not marked, most likely all font-entities
+            are not marked too.  But we must be sure that nothing is
+            marked within OBJ before we really drop it.  */
+         for (i = 0; i < size; i++)
+           if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
+             break;
+
+         if (i == size)
+           drop = 1;
+       }
+      if (drop)
+       *prev = XCDR (tail);
+      else
+       prev = xcdr_addr (tail);
+    }
+  return entry;
+}
+
+/* Compact font caches on all terminals and mark
+   everything which is still here after compaction.  */
+
+static void
+compact_font_caches (void)
+{
+  struct terminal *t;
+
+  for (t = terminal_list; t; t = t->next_terminal)
+    {
+      Lisp_Object cache = TERMINAL_FONT_CACHE (t);
+
+      if (CONSP (cache))
+       {
+         Lisp_Object entry;
+
+         for (entry = XCDR (cache); CONSP (entry); entry = XCDR (entry))
+           XSETCAR (entry, compact_font_cache_entry (XCAR (entry)));
+       }
+      mark_object (cache);
+    }
+}
+
+#else /* not HAVE_WINDOW_SYSTEM */
+
+#define compact_font_caches() (void)(0)
+
+#endif /* HAVE_WINDOW_SYSTEM */
+
+/* Remove (MARKER . DATA) entries with unmarked MARKER
+   from buffer undo LIST and return changed list.  */
+
+static Lisp_Object
+compact_undo_list (Lisp_Object list)
+{
+  Lisp_Object tail, *prev = &list;
+
+  for (tail = list; CONSP (tail); tail = XCDR (tail))
+    {
+      if (CONSP (XCAR (tail))
+         && MARKERP (XCAR (XCAR (tail)))
+         && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit)
+       *prev = XCDR (tail);
+      else
+       prev = xcdr_addr (tail);
+    }
+  return list;
+}
+
 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
        doc: /* Reclaim storage for Lisp objects no longer needed.
 Garbage collection happens automatically if you cons more than
@@ -5392,46 +5524,19 @@ See Info node `(elisp)Garbage Collection'.  */)
   mark_stack ();
 #endif
 
-  /* Everything is now marked, except for the things that require special
-     finalization, i.e. the undo_list.
-     Look thru every buffer's undo list
-     for elements that update markers that were not marked,
-     and delete them.  */
+  /* Everything is now marked, except for the data in font caches
+     and undo lists.  They're compacted by removing an items which
+     aren't reachable otherwise.  */
+
+  compact_font_caches ();
+
   FOR_EACH_BUFFER (nextb)
     {
-      /* If a buffer's undo list is Qt, that means that undo is
-        turned off in that buffer.  Calling truncate_undo_list on
-        Qt tends to return NULL, which effectively turns undo back on.
-        So don't call truncate_undo_list if undo_list is Qt.  */
-      if (! EQ (nextb->INTERNAL_FIELD (undo_list), Qt))
-       {
-         Lisp_Object tail, prev;
-         tail = nextb->INTERNAL_FIELD (undo_list);
-         prev = Qnil;
-         while (CONSP (tail))
-           {
-             if (CONSP (XCAR (tail))
-                 && MARKERP (XCAR (XCAR (tail)))
-                 && !XMARKER (XCAR (XCAR (tail)))->gcmarkbit)
-               {
-                 if (NILP (prev))
-                   nextb->INTERNAL_FIELD (undo_list) = tail = XCDR (tail);
-                 else
-                   {
-                     tail = XCDR (tail);
-                     XSETCDR (prev, tail);
-                   }
-               }
-             else
-               {
-                 prev = tail;
-                 tail = XCDR (tail);
-               }
-           }
-       }
-      /* Now that we have stripped the elements that need not be in the
-        undo_list any more, we can finally mark the list.  */
-      mark_object (nextb->INTERNAL_FIELD (undo_list));
+      if (!EQ (BVAR (nextb, undo_list), Qt))
+       bset_undo_list (nextb, compact_undo_list (BVAR (nextb, undo_list)));
+      /* Now that we have stripped the elements that need not be
+        in the undo_list any more, we can finally mark the list.  */
+      mark_object (BVAR (nextb, undo_list));
     }
 
   gc_sweep ();
@@ -5603,30 +5708,6 @@ mark_glyph_matrix (struct glyph_matrix *matrix)
       }
 }
 
-
-/* Mark Lisp faces in the face cache C.  */
-
-static void
-mark_face_cache (struct face_cache *c)
-{
-  if (c)
-    {
-      int i, j;
-      for (i = 0; i < c->used; ++i)
-       {
-         struct face *face = FACE_FROM_ID (c->f, i);
-
-         if (face)
-           {
-             for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
-               mark_object (face->lface[j]);
-           }
-       }
-    }
-}
-
-
-\f
 /* Mark reference to a Lisp_Object.
    If the object referred to has not been seen yet, recursively mark
    all the references contained in it.  */
@@ -5657,7 +5738,7 @@ mark_vectorlike (struct Lisp_Vector *ptr)
      The distinction is used e.g. by Lisp_Process which places extra
      non-Lisp_Object fields at the end of the structure...  */
   for (i = 0; i < size; i++) /* ...and then mark its elements.  */
-    mark_object (ptr->u.contents[i]);
+    mark_object (ptr->contents[i]);
 }
 
 /* Like mark_vectorlike but optimized for char-tables (and
@@ -5674,7 +5755,7 @@ mark_char_table (struct Lisp_Vector *ptr)
   VECTOR_MARK (ptr);
   for (i = 0; i < size; i++)
     {
-      Lisp_Object val = ptr->u.contents[i];
+      Lisp_Object val = ptr->contents[i];
 
       if (INTEGERP (val) || (SYMBOLP (val) && XSYMBOL (val)->gcmarkbit))
        continue;
@@ -5726,6 +5807,30 @@ mark_buffer (struct buffer *buffer)
     mark_buffer (buffer->base_buffer);
 }
 
+/* Mark Lisp faces in the face cache C.  */
+
+static void
+mark_face_cache (struct face_cache *c)
+{
+  if (c)
+    {
+      int i, j;
+      for (i = 0; i < c->used; ++i)
+       {
+         struct face *face = FACE_FROM_ID (c->f, i);
+
+         if (face)
+           {
+             if (face->font && !VECTOR_MARKED_P (face->font))
+               mark_vectorlike ((struct Lisp_Vector *) face->font);
+
+             for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
+               mark_object (face->lface[j]);
+           }
+       }
+    }
+}
+
 /* Remove killed buffers or items whose car is a killed buffer from
    LIST, and mark other items.  Return changed LIST, which is marked.  */
 
@@ -5879,18 +5984,31 @@ mark_object (Lisp_Object arg)
              VECTOR_MARK (ptr);
              for (i = 0; i < size; i++)
                if (i != COMPILED_CONSTANTS)
-                 mark_object (ptr->u.contents[i]);
+                 mark_object (ptr->contents[i]);
              if (size > COMPILED_CONSTANTS)
                {
-                 obj = ptr->u.contents[COMPILED_CONSTANTS];
+                 obj = ptr->contents[COMPILED_CONSTANTS];
                  goto loop;
                }
            }
            break;
 
          case PVEC_FRAME:
-           mark_vectorlike (ptr);
-           mark_face_cache (((struct frame *) ptr)->face_cache);
+           {
+             struct frame *f = (struct frame *) ptr;
+
+             mark_vectorlike (ptr);
+             mark_face_cache (f->face_cache);
+#ifdef HAVE_WINDOW_SYSTEM
+             if (FRAME_WINDOW_P (f) && FRAME_X_OUTPUT (f))
+               {
+                 struct font *font = FRAME_FONT (f);
+
+                 if (font && !VECTOR_MARKED_P (font))
+                   mark_vectorlike ((struct Lisp_Vector *) font);
+               }
+#endif
+           }
            break;
 
          case PVEC_WINDOW:
@@ -6118,9 +6236,6 @@ mark_terminals (void)
         it might have been marked already.  Make sure the image cache
         gets marked.  */
       mark_image_cache (t->image_cache);
-      /* FIXME: currently font cache may grow too large
-        and probably needs special finalization.  */
-      mark_object (TERMINAL_FONT_CACHE (t));
 #endif /* HAVE_WINDOW_SYSTEM */
       if (!VECTOR_MARKED_P (t))
        mark_vectorlike ((struct Lisp_Vector *)t);
index ef04ca7018dab39a86a36f6720fb40ddcfc0ada1..61b685ea5c5f7f534a4ce845ce5c654b46ac7113 100644 (file)
@@ -154,7 +154,8 @@ CHECK_OVERLAY (Lisp_Object x)
   CHECK_TYPE (OVERLAYP (x), Qoverlayp, x);
 }
 
-/* These setters are used only in this file, so they can be private.  */
+/* These setters are used only in this file, so they can be private.
+   The public setters are inline functions defined in buffer.h.  */
 static void
 bset_abbrev_mode (struct buffer *b, Lisp_Object val)
 {
@@ -201,11 +202,6 @@ bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val)
   b->INTERNAL_FIELD (buffer_file_coding_system) = val;
 }
 static void
-bset_cache_long_scans (struct buffer *b, Lisp_Object val)
-{
-  b->INTERNAL_FIELD (cache_long_scans) = val;
-}
-static void
 bset_case_fold_search (struct buffer *b, Lisp_Object val)
 {
   b->INTERNAL_FIELD (case_fold_search) = val;
@@ -1332,15 +1328,54 @@ No argument or nil as argument means use current buffer as BUFFER.  */)
   return BUF_SAVE_MODIFF (buf) < BUF_MODIFF (buf) ? Qt : Qnil;
 }
 
+DEFUN ("force-mode-line-update", Fforce_mode_line_update,
+       Sforce_mode_line_update, 0, 1, 0,
+       doc: /* Force redisplay of the current buffer's mode line and header line.
+With optional non-nil ALL, force redisplay of all mode lines and
+header lines.  This function also forces recomputation of the
+menu bar menus and the frame title.  */)
+     (Lisp_Object all)
+{
+  if (!NILP (all) || buffer_window_count (current_buffer))
+    {
+      update_mode_lines = 10;
+      current_buffer->prevent_redisplay_optimizations_p = 1;
+    }
+  return all;
+}
+
 DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
        1, 1, 0,
        doc: /* Mark current buffer as modified or unmodified according to FLAG.
 A non-nil FLAG means mark the buffer modified.  */)
   (Lisp_Object flag)
 {
-  Lisp_Object fn;
+  Frestore_buffer_modified_p (flag);
+
+  /* Set update_mode_lines only if buffer is displayed in some window.
+     Packages like jit-lock or lazy-lock preserve a buffer's modified
+     state by recording/restoring the state around blocks of code.
+     Setting update_mode_lines makes redisplay consider all windows
+     (on all frames).  Stealth fontification of buffers not displayed
+     would incur additional redisplay costs if we'd set
+     update_modes_lines unconditionally.
+
+     Ideally, I think there should be another mechanism for fontifying
+     buffers without "modifying" buffers, or redisplay should be
+     smarter about updating the `*' in mode lines.  --gerd  */
+  return Fforce_mode_line_update (Qnil);
+}
 
+DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p,
+       Srestore_buffer_modified_p, 1, 1, 0,
+       doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay.
+It is not ensured that mode lines will be updated to show the modified
+state of the current buffer.  Use with care.  */)
+  (Lisp_Object flag)
+{
 #ifdef CLASH_DETECTION
+  Lisp_Object fn;
+
   /* If buffer becoming modified, lock the file.
      If buffer becoming unmodified, unlock the file.  */
 
@@ -1380,52 +1415,6 @@ A non-nil FLAG means mark the buffer modified.  */)
                    or increase MODIFF.  */
                 : MODIFF++);
 
-  /* Set update_mode_lines only if buffer is displayed in some window.
-     Packages like jit-lock or lazy-lock preserve a buffer's modified
-     state by recording/restoring the state around blocks of code.
-     Setting update_mode_lines makes redisplay consider all windows
-     (on all frames).  Stealth fontification of buffers not displayed
-     would incur additional redisplay costs if we'd set
-     update_modes_lines unconditionally.
-
-     Ideally, I think there should be another mechanism for fontifying
-     buffers without "modifying" buffers, or redisplay should be
-     smarter about updating the `*' in mode lines.  --gerd  */
-  if (buffer_window_count (current_buffer))
-    {
-      ++update_mode_lines;
-      current_buffer->prevent_redisplay_optimizations_p = 1;
-    }
-
-  return flag;
-}
-
-DEFUN ("restore-buffer-modified-p", Frestore_buffer_modified_p,
-       Srestore_buffer_modified_p, 1, 1, 0,
-       doc: /* Like `set-buffer-modified-p', with a difference concerning redisplay.
-It is not ensured that mode lines will be updated to show the modified
-state of the current buffer.  Use with care.  */)
-  (Lisp_Object flag)
-{
-#ifdef CLASH_DETECTION
-  Lisp_Object fn;
-
-  /* If buffer becoming modified, lock the file.
-     If buffer becoming unmodified, unlock the file.  */
-
-  fn = BVAR (current_buffer, file_truename);
-  /* Test buffer-file-name so that binding it to nil is effective.  */
-  if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
-    {
-      bool already = SAVE_MODIFF < MODIFF;
-      if (!already && !NILP (flag))
-       lock_file (fn);
-      else if (already && NILP (flag))
-       unlock_file (fn);
-    }
-#endif /* CLASH_DETECTION */
-
-  SAVE_MODIFF = NILP (flag) ? MODIFF : 0;
   return flag;
 }
 
@@ -1513,7 +1502,7 @@ This does not change the name of the visited file (if any).  */)
 
   /* Catch redisplay's attention.  Unless we do this, the mode lines for
      any windows displaying current_buffer will stay unchanged.  */
-  update_mode_lines++;
+  update_mode_lines = 11;
 
   XSETBUFFER (buf, current_buffer);
   Fsetcar (Frassq (buf, Vbuffer_alist), newname);
@@ -1798,7 +1787,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
   /* Run replace_buffer_in_windows before making another buffer current
      since set-window-buffer-start-and-point will refuse to make another
      buffer current if the selected window does not show the current
-     buffer.  (Bug#10114) */
+     buffer (bug#10114).  */
   replace_buffer_in_windows (buffer);
 
   /* Exit if replacing the buffer in windows has killed our buffer.  */
@@ -2074,7 +2063,7 @@ the current buffer's major mode.  */)
   count = SPECPDL_INDEX ();
 
   /* To select a nonfundamental mode,
-     select the buffer temporarily and then call the mode function. */
+     select the buffer temporarily and then call the mode function.  */
 
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
 
@@ -2114,7 +2103,7 @@ set_buffer_internal_1 (register struct buffer *b)
 
   old_buf = current_buffer;
   current_buffer = b;
-  last_known_column_point = -1;   /* invalidate indentation cache */
+  last_known_column_point = -1;   /* Invalidate indentation cache.  */
 
   if (old_buf)
     {
@@ -2138,7 +2127,7 @@ set_buffer_internal_1 (register struct buffer *b)
   fetch_buffer_markers (b);
 
   /* Look down buffer's list of local Lisp variables
-     to find and update any that forward into C variables. */
+     to find and update any that forward into C variables.  */
 
   do
     {
@@ -2705,7 +2694,7 @@ current buffer is cleared.  */)
 
   /* If buffer is shown in a window, let redisplay consider other windows.  */
   if (buffer_window_count (current_buffer))
-    ++windows_or_buffers_changed;
+    windows_or_buffers_changed = 10;
 
   /* Copy this buffer's new multibyte status
      into all of its indirect buffers.  */
@@ -2765,7 +2754,7 @@ the normal hook `change-major-mode-hook'.  */)
 
   /* Force mode-line redisplay.  Useful here because all major mode
      commands call this function.  */
-  update_mode_lines++;
+  update_mode_lines = 12;
 
   return Qnil;
 }
@@ -3911,11 +3900,11 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
     {
       /* ... it's visible in other window than selected,  */
       if (buf != XBUFFER (XWINDOW (selected_window)->contents))
-       windows_or_buffers_changed = 1;
+       windows_or_buffers_changed = 11;
       /* ... or if we modify an overlay at the end of the buffer
         and so we cannot be sure that window end is still valid.  */
       else if (end >= ZV && start <= ZV)
-       windows_or_buffers_changed = 1;
+       windows_or_buffers_changed = 12;
     }
 
   ++BUF_OVERLAY_MODIFF (buf);
@@ -4534,7 +4523,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after,
     Lisp_Object *copy = alloca (size * sizeof *copy);
     ptrdiff_t i;
 
-    memcpy (copy, XVECTOR (last_overlay_modification_hooks)->u.contents,
+    memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
            size * word_size);
     gcpro1.var = copy;
     gcpro1.nvars = size;
@@ -5185,7 +5174,7 @@ init_buffer_once (void)
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
   XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
-  bset_cache_long_scans (&buffer_defaults, Qnil);
+  bset_cache_long_scans (&buffer_defaults, Qt);
   bset_file_truename (&buffer_defaults, Qnil);
   XSETFASTINT (BVAR (&buffer_defaults, display_count), 0);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
@@ -5349,13 +5338,10 @@ init_buffer (void)
       len++;
     }
 
+  /* At this moment, we still don't know how to decode the directory
+     name.  So, we keep the bytes in unibyte form so that file I/O
+     routines correctly get the original bytes.  */
   bset_directory (current_buffer, make_unibyte_string (pwd, len));
-  if (! NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
-    /* At this moment, we still don't know how to decode the
-       directory name.  So, we keep the bytes in multibyte form so
-       that ENCODE_FILE correctly gets the original bytes.  */
-    bset_directory
-      (current_buffer, string_to_multibyte (BVAR (current_buffer, directory)));
 
   /* Add /: to the front of the name
      if it would otherwise be treated as magic.  */
@@ -5410,12 +5396,12 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
 
   if (PER_BUFFER_IDX (offset) == 0)
     /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
-       slot of buffer_local_flags */
+       slot of buffer_local_flags */
     emacs_abort ();
 }
 
 
-/* initialize the buffer routines */
+/* Initialize the buffer routines.  */
 void
 syms_of_buffer (void)
 {
@@ -5805,7 +5791,8 @@ its value may not be a list of functions.  */);
 
   DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename),
                     Qstringp,
-                    doc: /* Name of file visited in current buffer, or nil if not visiting a file.  */);
+                    doc: /* Name of file visited in current buffer, or nil if not visiting a file.
+This should be an absolute file name.  */);
 
   DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename),
                     Qstringp,
@@ -6305,6 +6292,7 @@ and `bury-buffer-internal'.  */);
   defsubr (&Sbuffer_local_value);
   defsubr (&Sbuffer_local_variables);
   defsubr (&Sbuffer_modified_p);
+  defsubr (&Sforce_mode_line_update);
   defsubr (&Sset_buffer_modified_p);
   defsubr (&Sbuffer_modified_tick);
   defsubr (&Sbuffer_chars_modified_tick);
index a36c0d13c9e3aadc761d0616a7cb55374297268a..d1a3e50d7cf41afb0ce23e4394a73f82b7f747ea 100644 (file)
@@ -871,13 +871,19 @@ struct buffer
 };
 
 /* Most code should use these functions to set Lisp fields in struct
-   buffer.  */
+   buffer.  (Some setters that are private to a single .c file are
+   defined as static in those files.)  */
 INLINE void
 bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
 {
   b->INTERNAL_FIELD (bidi_paragraph_direction) = val;
 }
 INLINE void
+bset_cache_long_scans (struct buffer *b, Lisp_Object val)
+{
+  b->INTERNAL_FIELD (cache_long_scans) = val;
+}
+INLINE void
 bset_case_canon_table (struct buffer *b, Lisp_Object val)
 {
   b->INTERNAL_FIELD (case_canon_table) = val;
index b9cb36c871f9a1fe8e63444ab894cb3320d640b0..f34e702c71dd7a899153f79025cf3ff37566fe94 100644 (file)
@@ -550,7 +550,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
 #ifdef BYTE_CODE_SAFE
   bytestr_length = SBYTES (bytestr);
 #endif
-  vectorp = XVECTOR (vector)->u.contents;
+  vectorp = XVECTOR (vector)->contents;
 
   stack.byte_string = bytestr;
   stack.pc = stack.byte_string_start = SDATA (bytestr);
index d4b4a26ec3ae3f16bc1b0113be2e0a4c74caa952..3317c1203bc5dddd60ebd1e165adebd7df7b0c12 100644 (file)
@@ -777,7 +777,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
       char buf[CALLPROC_BUFFER_SIZE_MAX];
       int bufsize = CALLPROC_BUFFER_SIZE_MIN;
       int nread;
-      bool first = 1;
       EMACS_INT total_read = 0;
       int carryover = 0;
       bool display_on_the_fly = display_p;
@@ -822,6 +821,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
              ptrdiff_t count1 = SPECPDL_INDEX ();
 
              XSETBUFFER (curbuf, current_buffer);
+             prepare_to_modify_buffer (PT, PT, NULL);
              /* We cannot allow after-change-functions be run
                 during decoding, because that might modify the
                 buffer, while we rely on process_coding.produced to
@@ -874,9 +874,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
 
          if (display_p)
            {
-             if (first)
-               prepare_menu_bars ();
-             first = 0;
              redisplay_preserve_echo_area (1);
              /* This variable might have been set to 0 for code
                 detection.  In that case, set it back to 1 because
@@ -1612,14 +1609,14 @@ init_callproc (void)
       Lisp_Object tem, tem1, srcdir;
 
       srcdir = Fexpand_file_name (build_string ("../src/"),
-                                 build_string (PATH_DUMPLOADSEARCH));
+                                 build_unibyte_string (PATH_DUMPLOADSEARCH));
       tem = Fexpand_file_name (build_string ("GNU"), Vdata_directory);
       tem1 = Ffile_exists_p (tem);
       if (!NILP (Fequal (srcdir, Vinvocation_directory)) || NILP (tem1))
        {
          Lisp_Object newdir;
          newdir = Fexpand_file_name (build_string ("../etc/"),
-                                     build_string (PATH_DUMPLOADSEARCH));
+                                     build_unibyte_string (PATH_DUMPLOADSEARCH));
          tem = Fexpand_file_name (build_string ("GNU"), newdir);
          tem1 = Ffile_exists_p (tem);
          if (!NILP (tem1))
@@ -1646,7 +1643,7 @@ init_callproc (void)
 #ifdef DOS_NT
   Vshared_game_score_directory = Qnil;
 #else
-  Vshared_game_score_directory = build_string (PATH_GAME);
+  Vshared_game_score_directory = build_unibyte_string (PATH_GAME);
   if (NILP (Ffile_accessible_directory_p (Vshared_game_score_directory)))
     Vshared_game_score_directory = Qnil;
 #endif
index 5a40790f87f7f84a8381d24eb6d868d0a5c91968..9b213bb3cf2f10204ba9297e7566d248f3b95c94 100644 (file)
@@ -102,7 +102,7 @@ casify_object (enum case_action flag, Lisp_Object obj)
            inword = (SYNTAX (c) == Sword);
          if (c != c1)
            {
-                 MAKE_CHAR_UNIBYTE (c);
+             MAKE_CHAR_UNIBYTE (c);
              /* If the char can't be converted to a valid byte, just don't
                 change it.  */
              if (c >= 0 && c < 256)
index da5e81e4709cf3a1e21a48c8c34fa3abbc9c7f94..80d8b1ca1a2ca9c9452582547ed1c27940e17de5 100644 (file)
@@ -55,17 +55,9 @@ bset_category_table (struct buffer *b, Lisp_Object val)
 static int category_table_version;
 
 static Lisp_Object Qcategory_table, Qcategoryp, Qcategorysetp, Qcategory_table_p;
-
-/* Make CATEGORY_SET includes (if VAL is t) or excludes (if VAL is
-   nil) CATEGORY.  */
-#define SET_CATEGORY_SET(category_set, category, val) \
-  set_category_set (category_set, category, val)
-static void set_category_set (Lisp_Object, Lisp_Object, Lisp_Object);
 \f
 /* Category set staff.  */
 
-static Lisp_Object hash_get_category_set (Lisp_Object, Lisp_Object);
-
 static Lisp_Object
 hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
 {
@@ -88,6 +80,13 @@ hash_get_category_set (Lisp_Object table, Lisp_Object category_set)
   return category_set;
 }
 
+/* Make CATEGORY_SET include (if VAL) or exclude (if !VAL) CATEGORY.  */
+
+static void
+set_category_set (Lisp_Object category_set, EMACS_INT category, bool val)
+{
+  bool_vector_set (category_set, category, val);
+}
 
 DEFUN ("make-category-set", Fmake_category_set, Smake_category_set, 1, 1, 0,
        doc: /* Return a newly created category-set which contains CATEGORIES.
@@ -108,11 +107,11 @@ those categories.  */)
   len = SCHARS (categories);
   while (--len >= 0)
     {
-      Lisp_Object category;
+      unsigned char cat = SREF (categories, len);
+      Lisp_Object category = make_number (cat);
 
-      XSETFASTINT (category, SREF (categories, len));
       CHECK_CATEGORY (category);
-      SET_CATEGORY_SET (val, category, Qt);
+      set_category_set (val, cat, 1);
     }
   return val;
 }
@@ -334,20 +333,6 @@ The return value is a string containing those same categories.  */)
   return build_string (str);
 }
 
-static void
-set_category_set (Lisp_Object category_set, Lisp_Object category, Lisp_Object val)
-{
-  do {
-    int idx = XINT (category) / 8;
-    unsigned char bits = 1 << (XINT (category) % 8);
-
-    if (NILP (val))
-      XCATEGORY_SET (category_set)->data[idx] &= ~bits;
-    else
-      XCATEGORY_SET (category_set)->data[idx] |= bits;
-  } while (0);
-}
-
 DEFUN ("modify-category-entry", Fmodify_category_entry,
        Smodify_category_entry, 2, 4, 0,
        doc: /* Modify the category set of CHARACTER by adding CATEGORY to it.
@@ -359,7 +344,7 @@ If optional fourth argument RESET is non-nil,
 then delete CATEGORY from the category set instead of adding it.  */)
   (Lisp_Object character, Lisp_Object category, Lisp_Object table, Lisp_Object reset)
 {
-  Lisp_Object set_value;       /* Actual value to be set in category sets.  */
+  bool set_value;      /* Actual value to be set in category sets.  */
   Lisp_Object category_set;
   int start, end;
   int from, to;
@@ -384,7 +369,7 @@ then delete CATEGORY from the category set instead of adding it.  */)
   if (NILP (CATEGORY_DOCSTRING (table, XFASTINT (category))))
     error ("Undefined category: %c", (int) XFASTINT (category));
 
-  set_value = NILP (reset) ? Qt : Qnil;
+  set_value = NILP (reset);
 
   while (start <= end)
     {
@@ -393,7 +378,7 @@ then delete CATEGORY from the category set instead of adding it.  */)
       if (CATEGORY_MEMBER (XFASTINT (category), category_set) != NILP (reset))
        {
          category_set = Fcopy_sequence (category_set);
-         SET_CATEGORY_SET (category_set, category, set_value);
+         set_category_set (category_set, XFASTINT (category), set_value);
          category_set = hash_get_category_set (table, category_set);
          char_table_set_range (table, start, to, category_set);
        }
index a2eaf01013235dfd951d4972e300cf9311ac53aa..ef784c8cbf5469ee8fb91a6c6b7c476b7d483bff 100644 (file)
@@ -60,8 +60,6 @@ INLINE_HEADER_BEGIN
 #define CHECK_CATEGORY(x) \
   CHECK_TYPE (CATEGORYP (x), Qcategoryp, x)
 
-#define XCATEGORY_SET XBOOL_VECTOR
-
 #define CATEGORY_SET_P(x) \
   (BOOL_VECTOR_P (x) && bool_vector_size (x) == 128)
 
@@ -75,10 +73,12 @@ INLINE_HEADER_BEGIN
 #define CATEGORY_SET(c) char_category_set (c)
 
 /* Return true if CATEGORY_SET contains CATEGORY.
-   The faster version of `!NILP (Faref (category_set, category))'.  */
-#define CATEGORY_MEMBER(category, category_set)                                \
-  ((XCATEGORY_SET (category_set)->data[(category) / 8]                 \
-    >> ((category) % 8)) & 1)
+   Faster than '!NILP (Faref (category_set, make_number (category)))'.  */
+INLINE bool
+CATEGORY_MEMBER (EMACS_INT category, Lisp_Object category_set)
+{
+  return bool_vector_bitref (category_set, category);
+}
 
 /* Return true if category set of CH contains CATEGORY.  */
 INLINE bool
index d1783c25718bd4fd4d2df318af757fb247f80526..8fec18296a66f27c68bf43c8c280755ef029da9b 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1094,7 +1094,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
            ccl_prog_stack_struct[stack_idx].ic = ic;
            ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic;
            stack_idx++;
-           ccl_prog = XVECTOR (AREF (slot, 1))->u.contents;
+           ccl_prog = XVECTOR (AREF (slot, 1))->contents;
            ic = CCL_HEADER_MAIN;
            eof_ic = XFASTINT (ccl_prog[CCL_HEADER_EOF]);
          }
@@ -1936,9 +1936,9 @@ setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
        return -1;
       vp = XVECTOR (ccl_prog);
       ccl->size = vp->header.size;
-      ccl->prog = vp->u.contents;
-      ccl->eof_ic = XINT (vp->u.contents[CCL_HEADER_EOF]);
-      ccl->buf_magnification = XINT (vp->u.contents[CCL_HEADER_BUF_MAG]);
+      ccl->prog = vp->contents;
+      ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]);
+      ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]);
       if (ccl->idx >= 0)
        {
          Lisp_Object slot;
index d1b781caa53b693b8fe416ae46053204fc54be6b..e944b5775edb967a508b5c4a3461332a882c88dc 100644 (file)
@@ -677,7 +677,7 @@ extern Lisp_Object string_escape_byte8 (Lisp_Object);
 
 /* Return a translation table of id number ID.  */
 #define GET_TRANSLATION_TABLE(id) \
-  (XCDR (XVECTOR (Vtranslation_table_vector)->u.contents[(id)]))
+  (XCDR (XVECTOR (Vtranslation_table_vector)->contents[(id)]))
 
 INLINE_HEADER_END
 
index 089c4254da63b8c22f5ab51b84542c6488ac1f01..16dd85c12c00431e16be176dbdd6c5c61c3cf706 100644 (file)
@@ -141,7 +141,8 @@ static Lisp_Object
 make_sub_char_table (int depth, int min_char, Lisp_Object defalt)
 {
   Lisp_Object table;
-  int size = CHAR_TABLE_STANDARD_SLOTS + chartab_size[depth];
+  int size = (PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents)
+             + chartab_size[depth]);
 
   table = Fmake_vector (make_number (size), defalt);
   XSETPVECTYPE (XVECTOR (table), PVEC_SUB_CHAR_TABLE);
@@ -1258,7 +1259,7 @@ uniprop_encode_value_character (Lisp_Object table, Lisp_Object value)
 static Lisp_Object
 uniprop_encode_value_run_length (Lisp_Object table, Lisp_Object value)
 {
-  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->u.contents;
+  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->contents;
   int i, size = ASIZE (XCHAR_TABLE (table)->extras[4]);
 
   for (i = 0; i < size; i++)
@@ -1276,7 +1277,7 @@ uniprop_encode_value_run_length (Lisp_Object table, Lisp_Object value)
 static Lisp_Object
 uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value)
 {
-  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->u.contents;
+  Lisp_Object *value_table = XVECTOR (XCHAR_TABLE (table)->extras[4])->contents;
   int i, size = ASIZE (XCHAR_TABLE (table)->extras[4]);
 
   CHECK_NUMBER (value);
index 69b01553e7f128c6f59afb837230b7e99fd6baad..4ee55f7c8e6d06d00d1f3f1806c85ac00fc3e79b 100644 (file)
@@ -9358,6 +9358,14 @@ code_convert_region (Lisp_Object start, Lisp_Object end,
   setup_coding_system (coding_system, &coding);
   coding.mode |= CODING_MODE_LAST_BLOCK;
 
+  if (BUFFERP (dst_object) && !EQ (dst_object, src_object))
+    {
+      struct buffer *buf = XBUFFER (dst_object);
+      ptrdiff_t buf_pt = BUF_PT (buf);
+
+      invalidate_buffer_caches (buf, buf_pt, buf_pt);
+    }
+
   if (encodep)
     encode_coding_object (&coding, src_object, from, from_byte, to, to_byte,
                          dst_object);
@@ -9447,6 +9455,15 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
   coding.mode |= CODING_MODE_LAST_BLOCK;
   chars = SCHARS (string);
   bytes = SBYTES (string);
+
+  if (BUFFERP (dst_object))
+    {
+      struct buffer *buf = XBUFFER (dst_object);
+      ptrdiff_t buf_pt = BUF_PT (buf);
+
+      invalidate_buffer_caches (buf, buf_pt, buf_pt);
+    }
+
   if (encodep)
     encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object);
   else
@@ -9499,6 +9516,12 @@ decode_file_name (Lisp_Object fname)
 Lisp_Object
 encode_file_name (Lisp_Object fname)
 {
+  /* This is especially important during bootstrap and dumping, when
+     file-name encoding is not yet known, and therefore any non-ASCII
+     file names are unibyte strings, and could only be thrashed if we
+     try to encode them.  */
+  if (!STRING_MULTIBYTE (fname))
+    return fname;
 #ifdef WINDOWSNT
   /* The w32 build pretends to use UTF-8 for file-name encoding, and
      converts the file names either to UTF-16LE or to the system ANSI
index 35c2c05fe722226301c5e67930ff6b9ee7f71df3..b7f0049515dc2b33b1163d378fd88a3ca486ae0e 100644 (file)
@@ -36,10 +36,10 @@ extern Lisp_Object control_x_map;
    events until a non-ASCII event is acceptable as input.  */
 extern Lisp_Object unread_switch_frame;
 
-/* Nonzero if input is coming from the keyboard */
+/* Nonzero if input is coming from the keyboard */
 
 #define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive)
 
-/* Set this nonzero to force reconsideration of mode line. */
+/* Set this nonzero to force reconsideration of mode line.  */
 
 extern int update_mode_lines;
index 689ae95fa172b45373daaaadc452dbc996942aa6..2ab5dbc91331967c528a9cd34ffd845ad1dfbe69 100644 (file)
@@ -266,7 +266,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
     composition_table = xpalloc (composition_table, &composition_table_size,
                                 1, -1, sizeof *composition_table);
 
-  key_contents = XVECTOR (key)->u.contents;
+  key_contents = XVECTOR (key)->contents;
 
   /* Check if the contents of COMPONENTS are valid if COMPONENTS is a
      vector or a list.  It should be a sequence of:
index b3ea5cd1ed83d85661004a88f9683d3aaf9ac833..9026d03f7b6d6db2caf3ad176e0fc2f1e67c4ea8 100644 (file)
@@ -88,8 +88,8 @@ composition_registered_p (Lisp_Object prop)
 #define COMPOSITION_GLYPH(cmp, n)                                      \
   XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table)         \
                          ->key_and_value)                              \
-                ->u.contents[cmp->hash_index * 2])                     \
-       ->u.contents[cmp->method == COMPOSITION_WITH_RULE_ALTCHARS      \
+                ->contents[cmp->hash_index * 2])                       \
+       ->contents[cmp->method == COMPOSITION_WITH_RULE_ALTCHARS        \
                  ? (n) * 2 : (n)])
 
 /* Return the encoded composition rule to compose the Nth glyph of
@@ -98,8 +98,8 @@ composition_registered_p (Lisp_Object prop)
 #define COMPOSITION_RULE(cmp, n)                               \
   XINT (XVECTOR (XVECTOR (XHASH_TABLE (composition_hash_table) \
                          ->key_and_value)                      \
-                ->u.contents[cmp->hash_index * 2])             \
-       ->u.contents[(n) * 2 - 1])
+                ->contents[cmp->hash_index * 2])               \
+       ->contents[(n) * 2 - 1])
 
 /* Decode encoded composition rule RULE_CODE into GREF (global
    reference point code), NREF (new ref. point code).  Don't check RULE_CODE;
index 786105864f29b23cbf7a473de59524c282d482c9..2d967c0fefc4b42e8b1fa71870b8c9b4a5a1d793 100644 (file)
@@ -49,8 +49,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #define malloc unexec_malloc
 #define realloc unexec_realloc
 #define free unexec_free
-/* Don't use posix_memalign because it is not compatible with unexmacosx.c.  */
-#undef HAVE_POSIX_MEMALIGN
 #endif
 /* The following solves the problem that Emacs hangs when evaluating
    (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile
index 22d051ef932235c6f4ea271ebc41ca25e9a4c632..d0171b5d758434d55f17dfab833291414172e420 100644 (file)
@@ -2141,13 +2141,9 @@ or a byte-code object.  IDX starts at 0.  */)
     }
   else if (BOOL_VECTOR_P (array))
     {
-      int val;
-
       if (idxval < 0 || idxval >= bool_vector_size (array))
        args_out_of_range (array, idx);
-
-      val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
-      return (val & (1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR)) ? Qt : Qnil);
+      return bool_vector_ref (array, idxval);
     }
   else if (CHAR_TABLE_P (array))
     {
@@ -2191,18 +2187,9 @@ bool-vector.  IDX starts at 0.  */)
     }
   else if (BOOL_VECTOR_P (array))
     {
-      int val;
-
       if (idxval < 0 || idxval >= bool_vector_size (array))
        args_out_of_range (array, idx);
-
-      val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
-
-      if (! NILP (newelt))
-       val |= 1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR);
-      else
-       val &= ~(1 << (idxval % BOOL_VECTOR_BITS_PER_CHAR));
-      XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR] = val;
+      bool_vector_set (array, idxval, !NILP (newelt));
     }
   else if (CHAR_TABLE_P (array))
     {
@@ -2975,9 +2962,7 @@ lowercase l) for small endian machines.  */)
 
 /* Because we round up the bool vector allocate size to word_size
    units, we can safely read past the "end" of the vector in the
-   operations below.  These extra bits are always zero.  Also, we
-   always allocate bool vectors with at least one bits_word of storage so
-   that we don't have to special-case empty bit vectors.  */
+   operations below.  These extra bits are always zero.  */
 
 static bits_word
 bool_vector_spare_mask (EMACS_INT nr_bits)
@@ -2985,16 +2970,47 @@ bool_vector_spare_mask (EMACS_INT nr_bits)
   return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1;
 }
 
-#if BITS_WORD_MAX <= UINT_MAX
-# define popcount_bits_word count_one_bits
-#elif BITS_WORD_MAX <= ULONG_MAX
-# define popcount_bits_word count_one_bits_l
-#elif BITS_WORD_MAX <= ULLONG_MAX
-# define popcount_bits_word count_one_bits_ll
+/* Info about unsigned long long, falling back on unsigned long
+   if unsigned long long is not available.  */
+
+#if HAVE_UNSIGNED_LONG_LONG_INT
+enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) };
 #else
-# error "bits_word wider than long long? Please file a bug report."
+enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long) };
+# define ULLONG_MAX ULONG_MAX
+# define count_one_bits_ll count_one_bits_l
 #endif
 
+/* Shift VAL right by the width of an unsigned long long.
+   BITS_PER_ULL must be less than BITS_PER_BITS_WORD.  */
+
+static bits_word
+shift_right_ull (bits_word w)
+{
+  /* Pacify bogus GCC warning about shift count exceeding type width.  */
+  int shift = BITS_PER_ULL - BITS_PER_BITS_WORD < 0 ? BITS_PER_ULL : 0;
+  return w >> shift;
+}
+
+/* Return the number of 1 bits in W.  */
+
+static int
+count_one_bits_word (bits_word w)
+{
+  if (BITS_WORD_MAX <= UINT_MAX)
+    return count_one_bits (w);
+  else if (BITS_WORD_MAX <= ULONG_MAX)
+    return count_one_bits_l (w);
+  else
+    {
+      int i = 0, count = 0;
+      while (count += count_one_bits_ll (w),
+            BITS_PER_BITS_WORD <= (i += BITS_PER_ULL))
+       w = shift_right_ull (w);
+      return count;
+    }
+}
+
 enum bool_vector_op { bool_vector_exclusive_or,
                       bool_vector_union,
                       bool_vector_intersection,
@@ -3010,7 +3026,7 @@ bool_vector_binop_driver (Lisp_Object op1,
   EMACS_INT nr_bits;
   bits_word *adata, *bdata, *cdata;
   ptrdiff_t i;
-  bits_word changed = 0;
+  bool changed = 0;
   bits_word mword;
   ptrdiff_t nr_words;
 
@@ -3023,7 +3039,7 @@ bool_vector_binop_driver (Lisp_Object op1,
 
   if (NILP (dest))
     {
-      dest = Fmake_bool_vector (make_number (nr_bits), Qnil);
+      dest = make_uninit_bool_vector (nr_bits);
       changed = 1;
     }
   else
@@ -3033,13 +3049,13 @@ bool_vector_binop_driver (Lisp_Object op1,
        wrong_length_argument (op1, op2, dest);
     }
 
-  nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD;
+  nr_words = bool_vector_words (nr_bits);
+
+  adata = bool_vector_data (dest);
+  bdata = bool_vector_data (op1);
+  cdata = bool_vector_data (op2);
 
-  adata = (bits_word *) XBOOL_VECTOR (dest)->data;
-  bdata = (bits_word *) XBOOL_VECTOR (op1)->data;
-  cdata = (bits_word *) XBOOL_VECTOR (op2)->data;
-  i = 0;
-  do
+  for (i = 0; i < nr_words; i++)
     {
       if (op == bool_vector_exclusive_or)
         mword = bdata[i] ^ cdata[i];
@@ -3052,18 +3068,26 @@ bool_vector_binop_driver (Lisp_Object op1,
       else
         abort ();
 
-      changed |= adata[i] ^ mword;
+      if (! changed)
+       changed = adata[i] != mword;
 
       if (op != bool_vector_subsetp)
         adata[i] = mword;
-
-      i++;
     }
-  while (i < nr_words);
 
   return changed ? dest : Qnil;
 }
 
+/* PRECONDITION must be true.  Return VALUE.  This odd construction
+   works around a bogus GCC diagnostic "shift count >= width of type".  */
+
+static int
+pre_value (bool precondition, int value)
+{
+  eassume (precondition);
+  return precondition ? value : 0;
+}
+
 /* Compute the number of trailing zero bits in val.  If val is zero,
    return the number of bits in val.  */
 static int
@@ -3073,27 +3097,34 @@ count_trailing_zero_bits (bits_word val)
     return count_trailing_zeros (val);
   if (BITS_WORD_MAX == ULONG_MAX)
     return count_trailing_zeros_l (val);
-# if HAVE_UNSIGNED_LONG_LONG_INT
   if (BITS_WORD_MAX == ULLONG_MAX)
     return count_trailing_zeros_ll (val);
-# endif
 
   /* The rest of this code is for the unlikely platform where bits_word differs
      in width from unsigned int, unsigned long, and unsigned long long.  */
-  if (val == 0)
-    return CHAR_BIT * sizeof (val);
+  val |= ~ BITS_WORD_MAX;
   if (BITS_WORD_MAX <= UINT_MAX)
     return count_trailing_zeros (val);
   if (BITS_WORD_MAX <= ULONG_MAX)
     return count_trailing_zeros_l (val);
-  {
-# if HAVE_UNSIGNED_LONG_LONG_INT
-    verify (BITS_WORD_MAX <= ULLONG_MAX);
-    return count_trailing_zeros_ll (val);
-# else
-    verify (BITS_WORD_MAX <= ULONG_MAX);
-# endif
-  }
+  else
+    {
+      int count;
+      for (count = 0;
+          count < BITS_PER_BITS_WORD - BITS_PER_ULL;
+          count += BITS_PER_ULL)
+       {
+         if (val & ULLONG_MAX)
+           return count + count_trailing_zeros_ll (val);
+         val = shift_right_ull (val);
+       }
+
+      if (BITS_PER_BITS_WORD % BITS_PER_ULL != 0
+         && BITS_WORD_MAX == (bits_word) -1)
+       val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
+                                          BITS_PER_BITS_WORD % BITS_PER_ULL);
+      return count + count_trailing_zeros_ll (val);
+    }
 }
 
 static bits_word
@@ -3101,19 +3132,24 @@ bits_word_to_host_endian (bits_word val)
 {
 #ifndef WORDS_BIGENDIAN
   return val;
-#elif BITS_WORD_MAX >> 31 == 1
-  return bswap_32 (val);
-#elif BITS_WORD_MAX >> 31 >> 31 >> 1 == 1
-  return bswap_64 (val);
 #else
-  int i;
-  bits_word r = 0;
-  for (i = 0; i < sizeof val; i++)
-    {
-      r = (r << CHAR_BIT) | (val & ((1u << CHAR_BIT) - 1));
-      val >>= CHAR_BIT;
-    }
-  return r;
+  if (BITS_WORD_MAX >> 31 == 1)
+    return bswap_32 (val);
+# if HAVE_UNSIGNED_LONG_LONG
+  if (BITS_WORD_MAX >> 31 >> 31 >> 1 == 1)
+    return bswap_64 (val);
+# endif
+  {
+    int i;
+    bits_word r = 0;
+    for (i = 0; i < sizeof val; i++)
+      {
+       r = ((r << 1 << (CHAR_BIT - 1))
+            | (val & ((1u << 1 << (CHAR_BIT - 1)) - 1)));
+       val = val >> 1 >> (CHAR_BIT - 1);
+      }
+    return r;
+  }
 #endif
 }
 
@@ -3181,13 +3217,12 @@ Return the destination vector.  */)
   EMACS_INT nr_bits;
   bits_word *bdata, *adata;
   ptrdiff_t i;
-  bits_word mword;
 
   CHECK_BOOL_VECTOR (a);
   nr_bits = bool_vector_size (a);
 
   if (NILP (b))
-    b = Fmake_bool_vector (make_number (nr_bits), Qnil);
+    b = make_uninit_bool_vector (nr_bits);
   else
     {
       CHECK_BOOL_VECTOR (b);
@@ -3195,15 +3230,15 @@ Return the destination vector.  */)
        wrong_length_argument (a, b, Qnil);
     }
 
-  bdata = (bits_word *) XBOOL_VECTOR (b)->data;
-  adata = (bits_word *) XBOOL_VECTOR (a)->data;
+  bdata = bool_vector_data (b);
+  adata = bool_vector_data (a);
 
   for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; i++)
-    bdata[i] = ~adata[i];
+    bdata[i] = BITS_WORD_MAX & ~adata[i];
 
   if (nr_bits % BITS_PER_BITS_WORD)
     {
-      mword = bits_word_to_host_endian (adata[i]);
+      bits_word mword = bits_word_to_host_endian (adata[i]);
       mword = ~mword;
       mword &= bool_vector_spare_mask (nr_bits);
       bdata[i] = bits_word_to_host_endian (mword);
@@ -3221,27 +3256,20 @@ A must be a bool vector.  B is a generalized bool.  */)
   EMACS_INT count;
   EMACS_INT nr_bits;
   bits_word *adata;
-  bits_word match;
-  ptrdiff_t i;
+  ptrdiff_t i, nwords;
 
   CHECK_BOOL_VECTOR (a);
 
   nr_bits = bool_vector_size (a);
+  nwords = bool_vector_words (nr_bits);
   count = 0;
-  match = NILP (b) ? -1 : 0;
-  adata = (bits_word *) XBOOL_VECTOR (a)->data;
-
-  for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; ++i)
-    count += popcount_bits_word (adata[i] ^ match);
+  adata = bool_vector_data (a);
 
-  /* Mask out trailing parts of final mword.  */
-  if (nr_bits % BITS_PER_BITS_WORD)
-    {
-      bits_word mword = adata[i] ^ match;
-      mword = bits_word_to_host_endian (mword);
-      count += popcount_bits_word (mword & bool_vector_spare_mask (nr_bits));
-    }
+  for (i = 0; i < nwords; i++)
+    count += count_one_bits_word (adata[i]);
 
+  if (NILP (b))
+    count = nr_bits - count;
   return make_number (count);
 }
 
@@ -3259,7 +3287,7 @@ index into the vector.  */)
   bits_word *adata;
   bits_word twiddle;
   bits_word mword; /* Machine word.  */
-  ptrdiff_t pos;
+  ptrdiff_t pos, pos0;
   ptrdiff_t nr_words;
 
   CHECK_BOOL_VECTOR (a);
@@ -3269,10 +3297,8 @@ index into the vector.  */)
   if (XFASTINT (i) > nr_bits) /* Allow one past the end for convenience */
     args_out_of_range (a, i);
 
-  adata = (bits_word *) XBOOL_VECTOR (a)->data;
-
-  nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD;
-
+  adata = bool_vector_data (a);
+  nr_words = bool_vector_words (nr_bits);
   pos = XFASTINT (i) / BITS_PER_BITS_WORD;
   offset = XFASTINT (i) % BITS_PER_BITS_WORD;
   count = 0;
@@ -3280,7 +3306,7 @@ index into the vector.  */)
   /* By XORing with twiddle, we transform the problem of "count
      consecutive equal values" into "count the zero bits".  The latter
      operation usually has hardware support.  */
-  twiddle = NILP (b) ? 0 : -1;
+  twiddle = NILP (b) ? 0 : BITS_WORD_MAX;
 
   /* Scan the remainder of the mword at the current offset.  */
   if (pos < nr_words && offset != 0)
@@ -3288,8 +3314,8 @@ index into the vector.  */)
       mword = bits_word_to_host_endian (adata[pos]);
       mword ^= twiddle;
       mword >>= offset;
+      mword |= (bits_word) 1 << (BITS_PER_BITS_WORD - offset);
       count = count_trailing_zero_bits (mword);
-      count = min (count, BITS_PER_BITS_WORD - offset);
       pos++;
       if (count + offset < BITS_PER_BITS_WORD)
         return make_number (count);
@@ -3298,11 +3324,10 @@ index into the vector.  */)
   /* Scan whole words until we either reach the end of the vector or
      find an mword that doesn't completely match.  twiddle is
      endian-independent.  */
+  pos0 = pos;
   while (pos < nr_words && adata[pos] == twiddle)
-    {
-      count += BITS_PER_BITS_WORD;
-      ++pos;
-    }
+    pos++;
+  count += (pos - pos0) * BITS_PER_BITS_WORD;
 
   if (pos < nr_words)
     {
index 681eba25cb3d399e8ad18708ef28de5f34ad2b5f..d40febd207abd03889a7e5d3b287292968a12cdf 100644 (file)
@@ -33,7 +33,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #else /* !HAVE_X_WINDOWS */
 
-/* X-related stuff used by non-X gui code. */
+/* X-related stuff used by non-X gui code.  */
 
 typedef struct {
   unsigned long pixel;
@@ -1543,6 +1543,7 @@ enum lface_attribute_index
   LFACE_FONT_INDEX,
   LFACE_INHERIT_INDEX,
   LFACE_FONTSET_INDEX,
+  LFACE_DISTANT_FOREGROUND_INDEX,
   LFACE_VECTOR_SIZE
 };
 
@@ -1581,6 +1582,10 @@ enum face_underline_type
 
 struct face
 {
+  /* The Lisp face attributes this face realizes.  All attributes
+     in this vector are non-nil.  */
+  Lisp_Object lface[LFACE_VECTOR_SIZE];
+
   /* The id of this face.  The id equals the index of this face in the
      vector faces_by_id of its face cache.  */
   int id;
@@ -1595,11 +1600,6 @@ struct face
      an id as returned from load_pixmap.  */
   ptrdiff_t stipple;
 
-#else /* not HAVE_WINDOW_SYSTEM */
-
-  /* Dummy.  */
-  ptrdiff_t stipple;
-
 #endif /* not HAVE_WINDOW_SYSTEM */
 
   /* Pixel value of foreground color for X frames.  Color index
@@ -1624,9 +1624,6 @@ struct face
      from the same ASCII face have the same fontset.  */
   int fontset;
 
-  /* Pixmap width and height.  */
-  unsigned int pixmap_w, pixmap_h;
-
   /* Non-zero means characters in this face have a box of that
      thickness around them.  If this value is negative, its absolute
      value indicates the thickness, and the horizontal (top and
@@ -1640,10 +1637,10 @@ struct face
      of width box_line_width is drawn in color box_color.  A value of
      FACE_RAISED_BOX or FACE_SUNKEN_BOX means a 3D box is drawn with
      shadow colors derived from the background color of the face.  */
-  enum face_box_type box;
+  ENUM_BF (face_box_type) box : 2;
 
   /* Style of underlining. */
-  enum face_underline_type underline_type;
+  ENUM_BF (face_underline_type) underline_type : 1;
 
   /* If `box' above specifies a 3D type, 1 means use box_color for
      drawing shadows.  */
@@ -1695,10 +1692,6 @@ struct face
   unsigned synth_ital : 1;
 #endif
 
-  /* The Lisp face attributes this face realizes.  All attributes
-     in this vector are non-nil.  */
-  Lisp_Object lface[LFACE_VECTOR_SIZE];
-
   /* The hash value of this face.  */
   unsigned hash;
 
@@ -1727,6 +1720,15 @@ struct face
 
 #define FACE_TTY_DEFAULT_BG_COLOR ((unsigned long) -3)
 
+/* True if COLOR is a specified (i.e., nondefault) foreground or
+   background color for a tty face.  */
+
+INLINE bool
+face_tty_specified_color (unsigned long color)
+{
+  return color < FACE_TTY_DEFAULT_BG_COLOR;
+}
+
 /* Non-zero if FACE was realized for unibyte use.  */
 
 #define FACE_UNIBYTE_P(FACE) ((FACE)->charset < 0)
@@ -2222,10 +2224,6 @@ struct it
      used for overlay strings and strings from display properties.  */
   ptrdiff_t string_nchars;
 
-  /* Start and end of a visible region; -1 if the region is not
-     visible in the window.  */
-  ptrdiff_t region_beg_charpos, region_end_charpos;
-
   /* Position at which redisplay end trigger functions should be run.  */
   ptrdiff_t redisplay_end_trigger_charpos;
 
@@ -2359,7 +2357,7 @@ struct it
       } stretch;
     } u;
 
-    /* current text and display positions.  */
+    /* Current text and display positions.  */
     struct text_pos position;
     struct display_pos current;
     Lisp_Object from_overlay;
@@ -2371,11 +2369,12 @@ struct it
     unsigned string_from_prefix_prop_p : 1;
     unsigned display_ellipsis_p : 1;
     unsigned avoid_cursor_p : 1;
-    unsigned bidi_p:1;
+    unsigned bidi_p : 1;
     unsigned from_disp_prop_p : 1;
     enum line_wrap_method line_wrap;
 
-    /* properties from display property that are reset by another display property. */
+    /* Properties from display property that are reset by another display
+       property.  */
     short voffset;
     Lisp_Object space_width;
     Lisp_Object font_height;
@@ -3282,8 +3281,6 @@ extern unsigned row_hash (struct glyph_row *);
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern int x_bitmap_height (struct frame *, ptrdiff_t);
-extern int x_bitmap_width (struct frame *, ptrdiff_t);
 extern ptrdiff_t x_bitmap_pixmap (struct frame *, ptrdiff_t);
 extern void x_reference_bitmap (struct frame *, ptrdiff_t);
 extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *,
@@ -3335,9 +3332,10 @@ void init_baud_rate (int);
 void init_sigio (int);
 void ignore_sigio (void);
 
-/* Defined in xfaces.c */
+/* Defined in xfaces.c */
 
 #ifdef HAVE_X_WINDOWS
+void unload_color (struct frame *, unsigned long);
 void x_free_colors (struct frame *, unsigned long *, int);
 #endif
 
@@ -3349,7 +3347,6 @@ void clear_face_cache (int);
 unsigned long load_color (struct frame *, struct face *, Lisp_Object,
                           enum lface_attribute_index);
 #endif
-void unload_color (struct frame *, unsigned long);
 char *choose_face_font (struct frame *, Lisp_Object *, Lisp_Object,
                         int *);
 void prepare_face_for_display (struct frame *, struct face *);
@@ -3362,16 +3359,13 @@ void init_frame_faces (struct frame *);
 void free_frame_faces (struct frame *);
 void recompute_basic_faces (struct frame *);
 int face_at_buffer_position (struct window *w, ptrdiff_t pos,
-                             ptrdiff_t region_beg, ptrdiff_t region_end,
                              ptrdiff_t *endptr, ptrdiff_t limit,
                              int mouse, int base_face_id);
 int face_for_overlay_string (struct window *w, ptrdiff_t pos,
-                             ptrdiff_t region_beg, ptrdiff_t region_end,
                              ptrdiff_t *endptr, ptrdiff_t limit,
                              int mouse, Lisp_Object overlay);
 int face_at_string_position (struct window *w, Lisp_Object string,
                              ptrdiff_t pos, ptrdiff_t bufpos,
-                             ptrdiff_t region_beg, ptrdiff_t region_end,
                              ptrdiff_t *endptr, enum face_id, int mouse);
 int merge_faces (struct frame *, Lisp_Object, int, int);
 int compute_char_face (struct frame *, int, Lisp_Object);
@@ -3379,7 +3373,7 @@ void free_all_realized_faces (Lisp_Object);
 extern Lisp_Object Qforeground_color, Qbackground_color;
 extern char unspecified_fg[], unspecified_bg[];
 
-/* Defined in xfns.c  */
+/* Defined in xfns.c.  */
 
 #ifdef HAVE_X_WINDOWS
 void gamma_correct (struct frame *, XColor *);
@@ -3504,8 +3498,7 @@ extern int string_cost (const char *);
 extern int per_line_cost (const char *);
 extern void calculate_costs (struct frame *);
 extern void produce_glyphs (struct it *);
-extern bool tty_capable_p (struct tty_display_info *, unsigned,
-                          unsigned long, unsigned long);
+extern bool tty_capable_p (struct tty_display_info *, unsigned);
 extern void set_tty_color_mode (struct tty_display_info *, struct frame *);
 extern struct terminal *get_named_tty (const char *);
 extern void create_tty_output (struct frame *);
index 25acdd725dd7c071de32353600448a69c3240c8c..3207f4a00182b1f469ce34675184eee84579555f 100644 (file)
@@ -42,6 +42,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "process.h"
 
 #include "syssignal.h"
+#include "tparam.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -52,10 +53,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <fpending.h>
 #include <timespec.h>
 
-#if defined (HAVE_TERM_H) && defined (GNU_LINUX)
-#include <term.h>              /* for tgetent */
-#endif
-
 #ifdef WINDOWSNT
 #include "w32.h"
 #endif
@@ -2943,7 +2940,7 @@ redraw_frame (struct frame *f)
   clear_frame (f);
   clear_current_matrices (f);
   update_end (f);
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 13;
   /* Mark all windows as inaccurate, so that every window will have
      its redisplay done.  */
   mark_window_display_accurate (FRAME_ROOT_WINDOW (f), 0);
index 87dc5a22a68345ff019c8eb234626762c70a59fb..e02bab04bbc9108a3c5f5c0accb77dedc1663ba9 100644 (file)
@@ -59,7 +59,7 @@ extern Lisp_Object Qdisplay_table;
 /* Return the current base (for indexing) of the GLYPH table,
    or 0 if the table isn't currently valid.  */
 #define GLYPH_TABLE_BASE  \
-  ((VECTORP (Vglyph_table)) ? XVECTOR (Vglyph_table)->u.contents : 0)
+  ((VECTORP (Vglyph_table)) ? XVECTOR (Vglyph_table)->contents : 0)
 
 /* Given BASE and LEN returned by the two previous macros,
    return nonzero if the GLYPH code G should be output as a single
index d3f8fde08f6b9770fa262f61363728cc7fb3dc39..b6f1569c2d830c87a97df60c42b4b422ec9a504c 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -850,6 +850,7 @@ Otherwise, return a new string, without any text properties.  */)
          /* This is for computing the SHADOWS arg for describe_map_tree.  */
          Lisp_Object active_maps = Fcurrent_active_maps (Qnil, Qnil);
          Lisp_Object earlier_maps;
+         ptrdiff_t count = SPECPDL_INDEX ();
 
          changed = 1;
          strp += 2;            /* skip \{ or \< */
@@ -886,6 +887,10 @@ Otherwise, return a new string, without any text properties.  */)
          /* Now switch to a temp buffer.  */
          oldbuf = current_buffer;
          set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
+         /* This is for an unusual case where some after-change
+            function uses 'format' or 'prin1' or something else that
+            will thrash Vprin1_to_string_buffer we are using.  */
+         specbind (Qinhibit_modification_hooks, Qt);
 
          if (NILP (tem))
            {
@@ -910,6 +915,7 @@ Otherwise, return a new string, without any text properties.  */)
          tem = Fbuffer_string ();
          Ferase_buffer ();
          set_buffer_internal (oldbuf);
+         unbind_to (count, Qnil);
 
        subst_string:
          start = SDATA (tem);
index 37d3998b5ee1a88be86f0220d0d4638bd119f546..426da1fb41a8d8699b1c2318fcd1a4a6b47ee08b 100644 (file)
@@ -472,7 +472,7 @@ x_set_title (struct frame *f, Lisp_Object name)
   if (EQ (name, f->title))
     return;
 
-  update_mode_lines = 1;
+  update_mode_lines = 13;
 
   fset_title (f, name);
 
index d4c1f995d61d261c644a1d1adae5dc8e39fb6196..277e5b60704dbfc940245ea294a407485bdd5de3 100644 (file)
@@ -1702,6 +1702,7 @@ by text that describes the specified date and time in TIME:
 %G is the year corresponding to the ISO week, %g within the century.
 %m is the numeric month.
 %b and %h are the locale's abbreviated month name, %B the full name.
+ (%h is not supported on MS-Windows.)
 %d is the day of the month, zero-padded, %e is blank-padded.
 %u is the numeric day of week from 1 (Monday) to 7, %w from 0 (Sunday) to 6.
 %a is the locale's abbreviated name of the day of week, %A the full name.
index a58829e891841cbbdd0c26fad175e57aa83fbcaf..3e9635fd229c26f561cc526e81a790a5b0883835 100644 (file)
@@ -254,7 +254,7 @@ Action options:\n\
 FILE                    visit FILE using find-file\n\
 +LINE                   go to line LINE in next FILE\n\
 +LINE:COLUMN            go to line LINE, column COLUMN, in next FILE\n\
---directory, -L DIR     add DIR to variable load-path\n\
+--directory, -L DIR     prepend DIR to load-path (with :DIR, append DIR)\n\
 --eval EXPR             evaluate Emacs Lisp expression EXPR\n\
 --execute EXPR          evaluate Emacs Lisp expression EXPR\n\
 ",
@@ -383,7 +383,7 @@ terminate_due_to_signal (int sig, int backtrace_limit)
 /* Code for dealing with Lisp access to the Unix command line.  */
 
 static void
-init_cmdargs (int argc, char **argv, int skip_args)
+init_cmdargs (int argc, char **argv, int skip_args, char *original_pwd)
 {
   register int i;
   Lisp_Object name, dir, handler;
@@ -393,7 +393,7 @@ init_cmdargs (int argc, char **argv, int skip_args)
   initial_argv = argv;
   initial_argc = argc;
 
-  raw_name = build_string (argv[0]);
+  raw_name = build_unibyte_string (argv[0]);
 
   /* Add /: to the front of the name
      if it would otherwise be treated as magic.  */
@@ -426,7 +426,12 @@ init_cmdargs (int argc, char **argv, int skip_args)
       && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
     /* Emacs was started with relative path, like ./emacs.
        Make it absolute.  */
-    Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
+    {
+      Lisp_Object odir =
+       original_pwd ? build_unibyte_string (original_pwd) : Qnil;
+
+      Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, odir);
+    }
 
   Vinstallation_directory = Qnil;
 
@@ -699,6 +704,9 @@ main (int argc, char **argv)
 #endif
   char *ch_to_dir;
 
+  /* If we use --chdir, this records the original directory.  */
+  char *original_pwd = 0;
+
 #if GC_MARK_STACK
   stack_base = &dummy;
 #endif
@@ -786,12 +794,15 @@ main (int argc, char **argv)
     }
 
   if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args))
-    if (chdir (ch_to_dir) == -1)
-      {
-       fprintf (stderr, "%s: Can't chdir to %s: %s\n",
-                argv[0], ch_to_dir, strerror (errno));
-       exit (1);
-      }
+    {
+      original_pwd = get_current_dir_name ();
+      if (chdir (ch_to_dir) != 0)
+        {
+          fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+                   argv[0], ch_to_dir, strerror (errno));
+          exit (1);
+        }
+    }
 
   dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
                             || strcmp (argv[argc - 1], "bootstrap") == 0);
@@ -1187,10 +1198,13 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
   if (!noninteractive)
     {
 #ifdef NS_IMPL_COCOA
+      /* Started from GUI? */
+      /* FIXME: Do the right thing if getenv returns NULL, or if
+         chdir fails.  */
+      if (! inhibit_window_system && ! isatty (0))
+        chdir (getenv ("HOME"));
       if (skip_args < argc)
         {
-         /* FIXME: Do the right thing if getenv returns NULL, or if
-            chdir fails.  */
           if (!strncmp (argv[skip_args], "-psn", 4))
             {
               skip_args += 1;
@@ -1318,7 +1332,9 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
   init_buffer ();      /* Init default directory of main buffer.  */
 
   init_callproc_1 ();  /* Must precede init_cmdargs and init_sys_modes.  */
-  init_cmdargs (argc, argv, skip_args);        /* Must precede init_lread.  */
+
+  /* Must precede init_lread.  */
+  init_cmdargs (argc, argv, skip_args, original_pwd);
 
   if (initialized)
     {
@@ -2041,11 +2057,15 @@ You must run Emacs in batch mode in order to dump it.  */)
 
   CHECK_STRING (filename);
   filename = Fexpand_file_name (filename, Qnil);
+  filename = ENCODE_FILE (filename);
   if (!NILP (symfile))
     {
       CHECK_STRING (symfile);
       if (SCHARS (symfile))
-       symfile = Fexpand_file_name (symfile, Qnil);
+       {
+         symfile = Fexpand_file_name (symfile, Qnil);
+         symfile = ENCODE_FILE (symfile);
+       }
     }
 
   tem = Vpurify_flag;
@@ -2201,7 +2221,7 @@ decode_env_path (const char *evarname, const char *defalt)
       p = strchr (path, SEPCHAR);
       if (!p)
        p = path + strlen (path);
-      element = (p - path ? make_string (path, p - path)
+      element = (p - path ? make_unibyte_string (path, p - path)
                 : build_string ("."));
 #ifdef WINDOWSNT
       /* Relative file names in the default path are interpreted as
@@ -2211,7 +2231,7 @@ decode_env_path (const char *evarname, const char *defalt)
        element = Fexpand_file_name (Fsubstring (element,
                                                 make_number (emacs_dir_len),
                                                 Qnil),
-                                    build_string (emacs_dir));
+                                    build_unibyte_string (emacs_dir));
 #endif
 
       /* Add /: to the front of the name
index 1e0a63a0eceb54e5e04522ee8eae180bd1249132..d3fcec5aef43c430a0524ad3678199f2eaf1dfd8 100644 (file)
@@ -237,11 +237,22 @@ init_eval_once (void)
   Vrun_hooks = Qnil;
 }
 
+static struct handler handlerlist_sentinel;
+
 void
 init_eval (void)
 {
   specpdl_ptr = specpdl;
-  handlerlist = NULL;
+  { /* Put a dummy catcher at top-level so that handlerlist is never NULL.
+       This is important since handlerlist->nextfree holds the freelist
+       which would otherwise leak every time we unwind back to top-level.   */
+    struct handler *c;
+    handlerlist = handlerlist_sentinel.nextfree = &handlerlist_sentinel;
+    PUSH_HANDLER (c, Qunbound, CATCHER);
+    eassert (c == &handlerlist_sentinel);
+    handlerlist_sentinel.nextfree = NULL;
+    handlerlist_sentinel.next = NULL;
+  }
   Vquit_flag = Qnil;
   debug_on_next_call = 0;
   lisp_eval_depth = 0;
@@ -1129,6 +1140,8 @@ unwind_to_catch (struct handler *catch, Lisp_Object value)
 {
   bool last_time;
 
+  eassert (catch->next);
+
   /* Save the value in the tag.  */
   catch->val = value;
 
@@ -1542,7 +1555,10 @@ See also the function `condition-case'.  */)
     }
   else
     {
-      if (handlerlist != 0)
+      if (handlerlist != &handlerlist_sentinel)
+       /* FIXME: This will come right back here if there's no `top-level'
+          catcher.  A better solution would be to abort here, and instead
+          add a catch-all condition handler so we never come here.  */
        Fthrow (Qtop_level, Qt);
     }
 
@@ -2479,7 +2495,7 @@ run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args,
 
   if (EQ (val, Qunbound) || NILP (val))
     return ret;
-  else if (!CONSP (val) || EQ (XCAR (val), Qlambda))
+  else if (!CONSP (val) || FUNCTIONP (val))
     {
       args[0] = val;
       return funcall (nargs, args);
index eeaa736290ceeec3eadd971aa2712f5e3183aae6..fbf896e91c34fa87e4ae1926da72365bb2cf21ba 100644 (file)
@@ -49,6 +49,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "window.h"
 #include "blockinput.h"
+#include "region-cache.h"
 #include "frame.h"
 #include "dispextern.h"
 
@@ -733,8 +734,8 @@ static unsigned make_temp_name_count, make_temp_name_count_initialized_p;
 Lisp_Object
 make_temp_name (Lisp_Object prefix, bool base64_p)
 {
-  Lisp_Object val;
-  int len, clen;
+  Lisp_Object val, encoded_prefix;
+  int len;
   printmax_t pid;
   char *p, *data;
   char pidbuf[INT_BUFSIZE_BOUND (printmax_t)];
@@ -768,12 +769,11 @@ make_temp_name (Lisp_Object prefix, bool base64_p)
 #endif
     }
 
-  len = SBYTES (prefix); clen = SCHARS (prefix);
-  val = make_uninit_multibyte_string (clen + 3 + pidlen, len + 3 + pidlen);
-  if (!STRING_MULTIBYTE (prefix))
-    STRING_SET_UNIBYTE (val);
+  encoded_prefix = ENCODE_FILE (prefix);
+  len = SBYTES (encoded_prefix);
+  val = make_uninit_string (len + 3 + pidlen);
   data = SSDATA (val);
-  memcpy (data, SSDATA (prefix), len);
+  memcpy (data, SSDATA (encoded_prefix), len);
   p = data + len;
 
   memcpy (p, pidbuf, pidlen);
@@ -811,7 +811,7 @@ make_temp_name (Lisp_Object prefix, bool base64_p)
        {
          /* We want to return only if errno is ENOENT.  */
          if (errno == ENOENT)
-           return val;
+           return DECODE_FILE (val);
          else
            /* The error here is dubious, but there is little else we
               can do.  The alternatives are to return nil, which is
@@ -988,7 +988,26 @@ filesystem tree, not (expand-file-name ".."  dirname).  */)
   if (multibyte != STRING_MULTIBYTE (default_directory))
     {
       if (multibyte)
-       default_directory = string_to_multibyte (default_directory);
+       {
+         unsigned char *p = SDATA (name);
+
+         while (*p && ASCII_BYTE_P (*p))
+           p++;
+         if (*p == '\0')
+           {
+             /* NAME is a pure ASCII string, and DEFAULT_DIRECTORY is
+                unibyte.  Do not convert DEFAULT_DIRECTORY to
+                multibyte; instead, convert NAME to a unibyte string,
+                so that the result of this function is also a unibyte
+                string.  This is needed during bootstrapping and
+                dumping, when Emacs cannot decode file names, because
+                the locale environment is not set up.  */
+             name = make_unibyte_string (SSDATA (name), SBYTES (name));
+             multibyte = 0;
+           }
+         else
+           default_directory = string_to_multibyte (default_directory);
+       }
       else
        {
          name = string_to_multibyte (name);
@@ -4467,6 +4486,14 @@ by calling `format-decode', which see.  */)
       report_file_errno ("Opening input file", orig_filename, save_errno);
     }
 
+  /* We made a lot of deletions and insertions above, so invalidate
+     the newline cache for the entire region of the inserted
+     characters.  */
+  if (current_buffer->newline_cache)
+    invalidate_region_cache (current_buffer,
+                             current_buffer->newline_cache,
+                             PT - BEG, Z - PT - inserted);
+
   if (read_quit)
     Fsignal (Qquit, Qnil);
 
@@ -4988,7 +5015,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
       SAVE_MODIFF = MODIFF;
       XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
       bset_filename (current_buffer, visit_file);
-      update_mode_lines++;
+      update_mode_lines = 14;
     }
   else if (quietly)
     {
index f3d0936f88866c52bbc4135134cd7bea5772fbff..9f0bab2a452e25f9d8ec915a93ffeafdc54dfa08 100644 (file)
@@ -46,12 +46,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
 
-#ifndef isfinite
-# define isfinite(x) ((x) - (x) == 0)
-#endif
-#ifndef isnan
-# define isnan(x) ((x) != (x))
-#endif
+/* 'isfinite' and 'isnan' cause build failures on Solaris 10 with the
+   bundled GCC in c99 mode.  Work around the bugs with simple
+   implementations that are good enough.  */
+#undef isfinite
+#define isfinite(x) ((x) - (x) == 0)
+#undef isnan
+#define isnan(x) ((x) != (x))
 
 /* Check that X is a floating point number.  */
 
index 7a7ddc8b89ce3c0ec76b6151a642cbf847bed725..93829fb1d624009931488ea514130d972cce2804 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -435,14 +435,10 @@ with the original.  */)
 
   if (BOOL_VECTOR_P (arg))
     {
-      Lisp_Object val;
-      ptrdiff_t size_in_chars
-       = ((bool_vector_size (arg) + BOOL_VECTOR_BITS_PER_CHAR - 1)
-          / BOOL_VECTOR_BITS_PER_CHAR);
-
-      val = Fmake_bool_vector (Flength (arg), Qnil);
-      memcpy (XBOOL_VECTOR (val)->data, XBOOL_VECTOR (arg)->data,
-             size_in_chars);
+      EMACS_INT nbits = bool_vector_size (arg);
+      ptrdiff_t nbytes = bool_vector_bytes (nbits);
+      Lisp_Object val = make_uninit_bool_vector (nbits);
+      memcpy (bool_vector_data (val), bool_vector_data (arg), nbytes);
       return val;
     }
 
@@ -674,12 +670,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
              }
            else if (BOOL_VECTOR_P (this))
              {
-               int byte;
-               byte = XBOOL_VECTOR (this)->data[thisindex / BOOL_VECTOR_BITS_PER_CHAR];
-               if (byte & (1 << (thisindex % BOOL_VECTOR_BITS_PER_CHAR)))
-                 elt = Qt;
-               else
-                 elt = Qnil;
+               elt = bool_vector_ref (this, thisindex);
                thisindex++;
              }
            else
@@ -1602,7 +1593,7 @@ changing the value of a sequence `foo'.  */)
 
          for (i = n = 0; i < ASIZE (seq); ++i)
            if (NILP (Fequal (AREF (seq, i), elt)))
-             p->u.contents[n++] = AREF (seq, i);
+             p->contents[n++] = AREF (seq, i);
 
          XSETVECTOR (seq, p);
        }
@@ -2071,9 +2062,8 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
            EMACS_INT size = bool_vector_size (o1);
            if (size != bool_vector_size (o2))
              return 0;
-           if (memcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data,
-                       ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
-                        / BOOL_VECTOR_BITS_PER_CHAR)))
+           if (memcmp (bool_vector_data (o1), bool_vector_data (o2),
+                       bool_vector_bytes (size)))
              return 0;
            return 1;
          }
@@ -2163,19 +2153,7 @@ ARRAY is a vector, string, char-table, or bool-vector.  */)
          p[idx] = charval;
     }
   else if (BOOL_VECTOR_P (array))
-    {
-      unsigned char *p = XBOOL_VECTOR (array)->data;
-      size = ((bool_vector_size (array) + BOOL_VECTOR_BITS_PER_CHAR - 1)
-             / BOOL_VECTOR_BITS_PER_CHAR);
-
-      if (size)
-       {
-         memset (p, ! NILP (item) ? -1 : 0, size);
-
-         /* Clear any extraneous bits in the last byte.  */
-         p[size - 1] &= (1 << (size % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
-       }
-    }
+    return bool_vector_fill (array, item);
   else
     wrong_type_argument (Qarrayp, array);
   return array;
@@ -2287,10 +2265,7 @@ mapcar1 (EMACS_INT leni, Lisp_Object *vals, Lisp_Object fn, Lisp_Object seq)
     {
       for (i = 0; i < leni; i++)
        {
-         unsigned char byte;
-         byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR];
-         dummy = (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) ? Qt : Qnil;
-         dummy = call1 (fn, dummy);
+         dummy = call1 (fn, bool_vector_ref (seq, i));
          if (vals)
            vals[i] = dummy;
        }
@@ -3446,7 +3421,7 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
 {
   struct Lisp_Vector *v;
   ptrdiff_t i, incr, incr_max, old_size, new_size;
-  ptrdiff_t C_language_max = min (PTRDIFF_MAX, SIZE_MAX) / sizeof *v->u.contents;
+  ptrdiff_t C_language_max = min (PTRDIFF_MAX, SIZE_MAX) / sizeof *v->contents;
   ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max
                     ? nitems_max : C_language_max);
   eassert (VECTORP (vec));
@@ -3458,9 +3433,9 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
     memory_full (SIZE_MAX);
   new_size = old_size + incr;
   v = allocate_vector (new_size);
-  memcpy (v->u.contents, XVECTOR (vec)->u.contents, old_size * sizeof *v->u.contents);
+  memcpy (v->contents, XVECTOR (vec)->contents, old_size * sizeof *v->contents);
   for (i = old_size; i < new_size; ++i)
-    v->u.contents[i] = Qnil;
+    v->contents[i] = Qnil;
   XSETVECTOR (vec, v);
   return vec;
 }
@@ -4189,11 +4164,9 @@ sxhash_bool_vector (Lisp_Object vec)
   EMACS_UINT hash = size;
   int i, n;
 
-  n = min (SXHASH_MAX_LEN,
-          ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
-           / BOOL_VECTOR_BITS_PER_CHAR));
+  n = min (SXHASH_MAX_LEN, bool_vector_words (size));
   for (i = 0; i < n; ++i)
-    hash = sxhash_combine (hash, XBOOL_VECTOR (vec)->data[i]);
+    hash = sxhash_combine (hash, bool_vector_data (vec)[i]);
 
   return SXHASH_REDUCE (hash);
 }
index 68db9f2ef2dbdac1c47167042477066e95d80b92..1e1670b21afb5f72e82803f5bd58871167cdebd8 100644 (file)
@@ -2591,7 +2591,7 @@ font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver
                      if (! NILP (AREF (val, FONT_TYPE_INDEX)))
                        {
                          eassert (font && driver == font->driver);
-                         driver->close (f, font);
+                         driver->close (font);
                        }
                    }
                  if (driver->free_entity)
@@ -2892,7 +2892,7 @@ font_close_object (struct frame *f, Lisp_Object font_object)
     /* Already closed.  */
     return;
   FONT_ADD_LOG ("close", font_object, Qnil);
-  font->driver->close (f, font);
+  font->driver->close (font);
 #ifdef HAVE_WINDOW_SYSTEM
   eassert (FRAME_DISPLAY_INFO (f)->n_fonts);
   FRAME_DISPLAY_INFO (f)->n_fonts--;
@@ -3669,10 +3669,10 @@ font_at (int c, ptrdiff_t pos, struct face *face, struct window *w,
       ptrdiff_t endptr;
 
       if (STRINGP (string))
-       face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr,
+       face_id = face_at_string_position (w, string, pos, 0, &endptr,
                                           DEFAULT_FACE_ID, 0);
       else
-       face_id = face_at_buffer_position (w, pos, -1, -1, &endptr,
+       face_id = face_at_buffer_position (w, pos, &endptr,
                                           pos + 100, 0, -1);
       face = FACE_FROM_ID (f, face_id);
     }
@@ -3716,7 +3716,7 @@ font_range (ptrdiff_t pos, ptrdiff_t pos_byte, ptrdiff_t *limit,
        {
          int face_id;
 
-         face_id = face_at_buffer_position (w, pos, 0, 0, &ignore,
+         face_id = face_at_buffer_position (w, pos, &ignore,
                                             *limit, 0, -1);
          face = FACE_FROM_ID (XFRAME (w->frame), face_id);
        }
index 0ec56590916a590730dfb32fe01b0139ce3afffc..2db8d35af486ae83a1c47e93a4ea59755cdf722e 100644 (file)
@@ -545,8 +545,8 @@ struct font_driver
   Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity,
                        int pixel_size);
 
-  /* Close FONT on frame F.  */
-  void (*close) (struct frame *f, struct font *font);
+  /* Close FONT.  NOTE: this can be called by GC.  */
+  void (*close) (struct font *font);
 
   /* Optional (if FACE->extra is not used).
      Prepare FACE for displaying characters by FONT on frame F by
index 15fdf9f41a071771c62336c05003ad306d5cebae..a3634f0b08dca1769614b2dcd12cf5fd4ef87fe3 100644 (file)
@@ -453,7 +453,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
     }
 
   if (score_changed)
-    qsort (XVECTOR (vec)->u.contents, size, word_size,
+    qsort (XVECTOR (vec)->contents, size, word_size,
           fontset_compare_rfontdef);
   XSETCAR (font_group, make_number (charset_ordered_list_tick));
 }
@@ -1875,7 +1875,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
        return Qnil;
       w = XWINDOW (window);
       f = XFRAME (w->frame);
-      face_id = face_at_buffer_position (w, pos, -1, -1, &dummy,
+      face_id = face_at_buffer_position (w, pos, &dummy,
                                         pos + 100, 0, -1);
     }
   if (! CHAR_VALID_P (c))
index f2218b7bcb7574823c434171bdbf2ecaee2ef3d4..4494edda5d7756c02888d219b0ca648a345f50d9 100644 (file)
@@ -231,7 +231,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 
   if (nlines != olines)
     {
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 14;
       FRAME_WINDOW_SIZES_CHANGED (f) = 1;
       FRAME_MENU_BAR_LINES (f) = nlines;
       set_menu_bar_lines_1 (f->root_window, nlines - olines);
@@ -1489,7 +1489,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
 
   /* Cause frame titles to update--necessary if we now have just one frame.  */
   if (!is_tooltip_frame)
-    update_mode_lines = 1;
+    update_mode_lines = 15;
 
   return Qnil;
 }
@@ -1699,7 +1699,7 @@ If omitted, FRAME defaults to the currently selected frame.  */)
   make_frame_visible_1 (f->root_window);
 
   /* Make menu bar update for the Buffers and Frames menus.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 15;
 
   XSETFRAME (frame, f);
   return frame;
@@ -1753,7 +1753,7 @@ displayed in the terminal.  */)
 #endif
 
   /* Make menu bar update for the Buffers and Frames menus.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 16;
 
   return Qnil;
 }
@@ -1776,7 +1776,7 @@ If omitted, FRAME defaults to the currently selected frame.  */)
 #endif
 
   /* Make menu bar update for the Buffers and Frames menus.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 17;
 
   return Qnil;
 }
@@ -2025,7 +2025,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name)
     }
 
   fset_name (f, name);
-  update_mode_lines = 1;
+  update_mode_lines = 16;
 }
 
 void
@@ -3245,7 +3245,7 @@ x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
       XSETFRAME (frame, f);
       x_set_font (f, Fframe_parameter (frame, Qfont), Qnil);
       ++face_change_count;
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 18;
     }
 }
 
@@ -3844,7 +3844,7 @@ XParseGeometry (char *string,
 {
   int mask = NoValue;
   char *strind;
-  unsigned long int tempWidth, tempHeight;
+  unsigned long tempWidth, tempHeight;
   long int tempX, tempY;
   char *nextCharacter;
 
index 3537027f1ddbc6ce3ce7c0a4d8f643a9cbffd8c6..9c77e6557f4a8d1892652a13211a66e86c477c8d 100644 (file)
@@ -1690,6 +1690,8 @@ If BITMAP already exists, the existing definition is replaced.  */)
 DEFUN ("set-fringe-bitmap-face", Fset_fringe_bitmap_face, Sset_fringe_bitmap_face,
        1, 2, 0,
        doc: /* Set face for fringe bitmap BITMAP to FACE.
+FACE is merged with the `fringe' face, so normally FACE should specify
+only the foreground color.
 If FACE is nil, reset face to default fringe face.  */)
   (Lisp_Object bitmap, Lisp_Object face)
 {
index eeee56891ecc7b54e438a5feeae19be0926a9da7..224b8e82500be21e116093bc51be346e4138cd9e 100644 (file)
@@ -498,7 +498,7 @@ static Lisp_Object ftfont_list (struct frame *, Lisp_Object);
 static Lisp_Object ftfont_match (struct frame *, Lisp_Object);
 static Lisp_Object ftfont_list_family (struct frame *);
 static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
-static void ftfont_close (struct frame *, struct font *);
+static void ftfont_close (struct font *);
 static int ftfont_has_char (Lisp_Object, int);
 static unsigned ftfont_encode_char (struct font *, int);
 static int ftfont_text_extents (struct font *, unsigned *, int,
@@ -1317,7 +1317,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 }
 
 static void
-ftfont_close (struct frame *f, struct font *font)
+ftfont_close (struct font *font)
 {
   struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
   Lisp_Object val, cache;
index 63d03b0e2440fa7918045098b402353c5dee9c62..d1aa3e404037c9d5602054a5e22a60d38794913c 100644 (file)
@@ -57,7 +57,7 @@ struct ftxfont_frame_data
 /* Return an array of 6 GCs for antialiasing.  */
 
 static GC *
-ftxfont_get_gcs (struct frame *f, long unsigned int foreground, long unsigned int background)
+ftxfont_get_gcs (struct frame *f, unsigned long foreground, unsigned long background)
 {
   XColor color;
   XGCValues xgcv;
@@ -260,9 +260,9 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 }
 
 static void
-ftxfont_close (struct frame *f, struct font *font)
+ftxfont_close (struct font *font)
 {
-  ftfont_driver.close (f, font);
+  ftfont_driver.close (font);
 }
 
 static int
index bc1d85ac5fbb0ac1ae34f1b3f606d394f9d81388..c50df25cd41148f0097223ec8b320411d3baf86c 100644 (file)
@@ -58,6 +58,7 @@ extern void free (void *ptr);
 
 /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
 #ifdef MSDOS
+extern void *aligned_alloc (size_t, size_t);
 extern void *memalign (size_t, size_t);
 extern int posix_memalign (void **, size_t, size_t);
 #endif
@@ -143,11 +144,11 @@ struct list
 /* Free list headers for each fragment size.  */
 extern struct list _fraghead[];
 
-/* List of blocks allocated with `memalign' (or `valloc').  */
+/* List of blocks allocated with aligned_alloc and friends.  */
 struct alignlist
   {
     struct alignlist *next;
-    void *aligned;             /* The address that memaligned returned.  */
+    void *aligned;             /* The address that aligned_alloc returned.  */
     void *exact;               /* The address that malloc returned.  */
   };
 extern struct alignlist *_aligned_blocks;
@@ -977,7 +978,7 @@ License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 /* Debugging hook for free.  */
 void (*__free_hook) (void *__ptr);
 
-/* List of blocks allocated by memalign.  */
+/* List of blocks allocated by aligned_alloc.  */
 struct alignlist *_aligned_blocks = NULL;
 
 /* Return memory to the heap.
@@ -1306,8 +1307,8 @@ special_realloc (void *ptr, size_t size)
     type == 0 ? bss_sbrk_heapinfo[block].busy.info.size * BLOCKSIZE
     : (size_t) 1 << type;
   result = _malloc_internal_nolock (size);
-  if (result != NULL)
-    memcpy (result, ptr, min (oldsize, size));
+  if (result)
+    return memcpy (result, ptr, min (oldsize, size));
   return result;
 }
 #endif
@@ -1487,13 +1488,20 @@ License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 /* Allocate an array of NMEMB elements each SIZE bytes long.
    The entire array is initialized to zeros.  */
 void *
-calloc (register size_t nmemb, register size_t size)
+calloc (size_t nmemb, size_t size)
 {
-  register void *result = malloc (nmemb * size);
+  void *result;
+  size_t bytes = nmemb * size;
 
-  if (result != NULL)
-    (void) memset (result, 0, nmemb * size);
+  if (size != 0 && bytes / size != nmemb)
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
 
+  result = malloc (bytes);
+  if (result)
+    return memset (result, 0, bytes);
   return result;
 }
 /* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
@@ -1559,7 +1567,7 @@ License along with this library.  If not, see <http://www.gnu.org/licenses/>.  *
 void *(*__memalign_hook) (size_t size, size_t alignment);
 
 void *
-memalign (size_t alignment, size_t size)
+aligned_alloc (size_t alignment, size_t size)
 {
   void *result;
   size_t adj, lastadj;
@@ -1570,6 +1578,11 @@ memalign (size_t alignment, size_t size)
 
   /* Allocate a block with enough extra space to pad the block with up to
      (ALIGNMENT - 1) bytes if necessary.  */
+  if (- size < alignment)
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
   result = malloc (size + alignment - 1);
   if (result == NULL)
     return NULL;
@@ -1631,6 +1644,15 @@ memalign (size_t alignment, size_t size)
   return result;
 }
 
+/* An obsolete alias for aligned_alloc, for any old libraries that use
+   this alias.  */
+
+void *
+memalign (size_t alignment, size_t size)
+{
+  return aligned_alloc (alignment, size);
+}
+
 int
 posix_memalign (void **memptr, size_t alignment, size_t size)
 {
@@ -1641,7 +1663,7 @@ posix_memalign (void **memptr, size_t alignment, size_t size)
       || (alignment & (alignment - 1)) != 0)
     return EINVAL;
 
-  mem = memalign (alignment, size);
+  mem = aligned_alloc (alignment, size);
   if (mem == NULL)
     return ENOMEM;
 
@@ -1686,7 +1708,7 @@ valloc (size_t size)
   if (pagesize == 0)
     pagesize = getpagesize ();
 
-  return memalign (pagesize, size);
+  return aligned_alloc (pagesize, size);
 }
 
 #ifdef GC_MCHECK
@@ -1792,8 +1814,7 @@ mallochook (size_t size)
   hdr->size = size;
   hdr->magic = MAGICWORD;
   ((char *) &hdr[1])[size] = MAGICBYTE;
-  memset (hdr + 1, MALLOCFLOOD, size);
-  return hdr + 1;
+  return memset (hdr + 1, MALLOCFLOOD, size);
 }
 
 static void *
index f9e86d1a6975a605cb5e4e08935b4baceab823db..82b2fc8baa4b5a8210e8d6be43afe42dd201878c 100644 (file)
@@ -488,8 +488,20 @@ emacs_gnutls_handle_error (gnutls_session_t session, int err)
   else
     {
       ret = 1;
-      GNUTLS_LOG2 (1, max_log_level, "non-fatal error:", str);
-      /* TODO: EAGAIN AKA Qgnutls_e_again should be level 2.  */
+
+      switch (err)
+        {
+        case GNUTLS_E_AGAIN:
+          GNUTLS_LOG2 (3,
+                       max_log_level,
+                       "retry:",
+                       str);
+        default:
+          GNUTLS_LOG2 (1,
+                       max_log_level,
+                       "non-fatal error:",
+                       str);
+        }
     }
 
   if (err == GNUTLS_E_WARNING_ALERT_RECEIVED
@@ -791,16 +803,10 @@ one trustfile (usually a CA bundle).  */)
   CHECK_LIST (proplist);
 
   if (NILP (Fgnutls_available_p ()))
-    {
-      error ("GnuTLS not available");
-      return gnutls_make_error (GNUTLS_EMACS_ERROR_NOT_LOADED);
-    }
+    error ("GnuTLS not available");
 
   if (!EQ (type, Qgnutls_x509pki) && !EQ (type, Qgnutls_anon))
-    {
-      error ("Invalid GnuTLS credential type");
-      return gnutls_make_error (GNUTLS_EMACS_ERROR_INVALID_TYPE);
-    }
+    error ("Invalid GnuTLS credential type");
 
   hostname              = Fplist_get (proplist, QCgnutls_bootprop_hostname);
   priority_string       = Fplist_get (proplist, QCgnutls_bootprop_priority);
@@ -816,7 +822,6 @@ one trustfile (usually a CA bundle).  */)
   c_hostname = SSDATA (hostname);
 
   state = XPROCESS (proc)->gnutls_state;
-  XPROCESS (proc)->gnutls_p = 1;
 
   if (TYPE_RANGED_INTEGERP (int, loglevel))
     {
@@ -839,7 +844,6 @@ one trustfile (usually a CA bundle).  */)
   emacs_gnutls_deinit (proc);
 
   /* Mark PROC as a GnuTLS process.  */
-  XPROCESS (proc)->gnutls_p = 1;
   XPROCESS (proc)->gnutls_state = NULL;
   XPROCESS (proc)->gnutls_x509_cred = NULL;
   XPROCESS (proc)->gnutls_anon_cred = NULL;
@@ -1099,6 +1103,9 @@ one trustfile (usually a CA bundle).  */)
       fn_gnutls_x509_crt_deinit (gnutls_verify_cert);
     }
 
+  /* Set this flag only if the whole initialization succeeded.  */
+  XPROCESS (proc)->gnutls_p = 1;
+
   return gnutls_make_error (ret);
 }
 
index e20d01521f08ac9a244ee3ee1be2b2f80cbe490d..192b64a7e6242a065d293274dea556b0867aa653 100644 (file)
@@ -598,14 +598,17 @@ xg_check_special_colors (struct frame *f,
     GtkStyleContext *gsty
       = gtk_widget_get_style_context (FRAME_GTK_OUTER_WIDGET (f));
     GdkRGBA col;
-    char buf[sizeof "rgbi://" + 3 * (DBL_MAX_10_EXP + sizeof "-1.000000" - 1)];
+    char buf[sizeof "rgb://rrrr/gggg/bbbb"];
     int state = GTK_STATE_FLAG_SELECTED|GTK_STATE_FLAG_FOCUSED;
     if (get_fg)
       gtk_style_context_get_color (gsty, state, &col);
     else
       gtk_style_context_get_background_color (gsty, state, &col);
 
-    sprintf (buf, "rgbi:%lf/%lf/%lf", col.red, col.green, col.blue);
+    sprintf (buf, "rgb:%04x/%04x/%04x",
+             (int)(col.red * 65535),
+             (int)(col.green * 65535),
+             (int)(col.blue * 65535));
     success_p = (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
                              buf, color)
                 != 0);
@@ -1038,7 +1041,7 @@ xg_win_to_widget (Display *dpy, Window wdesc)
 /* Set the background of widget W to PIXEL.  */
 
 static void
-xg_set_widget_bg (struct frame *f, GtkWidget *w, long unsigned int pixel)
+xg_set_widget_bg (struct frame *f, GtkWidget *w, unsigned long pixel)
 {
 #ifdef HAVE_GTK3
   GdkRGBA bg;
@@ -1439,7 +1442,7 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
    BG is the pixel value to change to.  */
 
 void
-xg_set_background_color (struct frame *f, long unsigned int bg)
+xg_set_background_color (struct frame *f, unsigned long bg)
 {
   if (FRAME_GTK_WIDGET (f))
     {
index 2b07b83b816c9fd10674d752eff45b555b485203..37a19e4f5a59975bef3457ebc86c1847822500a5 100644 (file)
@@ -87,11 +87,12 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define x_defined_color w32_defined_color
 #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
 
-/* Versions of libpng and libgif that we were compiled with, or -1 if
-   no PNG/GIF support was compiled in.  This is tested by w32-win.el
-   to correctly set up the alist used to search for the respective
-   image libraries.  */
-Lisp_Object Qlibpng_version, Qlibgif_version;
+/* Versions of libpng, libgif, and libjpeg that we were compiled with,
+   or -1 if no PNG/GIF support was compiled in.  This is tested by
+   w32-win.el to correctly set up the alist used to search for the
+   respective image libraries.  */
+Lisp_Object Qlibpng_version, Qlibgif_version, Qlibjpeg_version;
+
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -159,13 +160,13 @@ XPutPixel (XImagePtr ximage, int x, int y, unsigned long pixel)
 
 /* Functions to access the contents of a bitmap, given an id.  */
 
-int
+static int
 x_bitmap_height (struct frame *f, ptrdiff_t id)
 {
   return FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].height;
 }
 
-int
+static int
 x_bitmap_width (struct frame *f, ptrdiff_t id)
 {
   return FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].width;
@@ -1520,7 +1521,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter)
                clear_current_matrices (fr);
            }
 
-         ++windows_or_buffers_changed;
+         windows_or_buffers_changed = 19;
        }
 
       unblock_input ();
@@ -3025,13 +3026,13 @@ xbm_load (struct frame *f, struct image *img)
                  if (STRINGP (line))
                    memcpy (p, SDATA (line), nbytes);
                  else
-                   memcpy (p, XBOOL_VECTOR (line)->data, nbytes);
+                   memcpy (p, bool_vector_data (line), nbytes);
                }
            }
          else if (STRINGP (data))
            bits = SSDATA (data);
          else
-           bits = (char *) XBOOL_VECTOR (data)->data;
+           bits = (char *) bool_vector_data (data);
 
 #ifdef HAVE_NTGUI
           {
@@ -5105,6 +5106,27 @@ pbm_image_p (Lisp_Object object)
 }
 
 
+/* Get next char skipping comments in Netpbm header.  Returns -1 at
+   end of input.  */
+
+static int
+pbm_next_char (unsigned char **s, unsigned char *end)
+{
+  int c = -1;
+
+  while (*s < end && (c = *(*s)++, c == '#'))
+    {
+      /* Skip to the next line break.  */
+      while (*s < end && (c = *(*s)++, c != '\n' && c != '\r'))
+        ;
+
+      c = -1;
+    }
+
+  return c;
+}
+
+
 /* Scan a decimal number from *S and return it.  Advance *S while
    reading the number.  END is the end of the string.  Value is -1 at
    end of input.  */
@@ -5114,28 +5136,16 @@ pbm_scan_number (unsigned char **s, unsigned char *end)
 {
   int c = 0, val = -1;
 
-  while (*s < end)
-    {
-      /* Skip white-space.  */
-      while (*s < end && (c = *(*s)++, c_isspace (c)))
-       ;
+  /* Skip white-space.  */
+  while ((c = pbm_next_char (s, end)) != -1 && c_isspace (c))
+    ;
 
-      if (c == '#')
-       {
-         /* Skip comment to end of line.  */
-         while (*s < end && (c = *(*s)++, c != '\n'))
-           ;
-       }
-      else if (c_isdigit (c))
-       {
-         /* Read decimal number.  */
-         val = c - '0';
-         while (*s < end && (c = *(*s)++, c_isdigit (c)))
-           val = 10 * val + c - '0';
-         break;
-       }
-      else
-       break;
+  if (c_isdigit (c))
+    {
+      /* Read decimal number.  */
+      val = c - '0';
+      while ((c = pbm_next_char (s, end)) != -1 && c_isdigit (c))
+        val = 10 * val + c - '0';
     }
 
   return val;
@@ -9410,6 +9420,14 @@ non-numeric, there is no explicit limit on the size of images.  */);
                     + GIFLIB_RELEASE)
 #else
        make_number (-1)
+#endif
+        );
+  DEFSYM (Qlibjpeg_version, "libjpeg-version");
+  Fset (Qlibjpeg_version,
+#if HAVE_JPEG
+       make_number (JPEG_LIB_VERSION)
+#else
+       make_number (-1)
 #endif
        );
 #endif
index d956e627ba94323fe7cd98a06a53f93739df1591..891b42788ed80ec4c5f6c41348ccd68f590b0574 100644 (file)
@@ -118,7 +118,7 @@ disptab_matches_widthtab (struct Lisp_Char_Table *disptab, struct Lisp_Vector *w
 
   for (i = 0; i < 256; i++)
     if (character_width (i, disptab)
-        != XFASTINT (widthtab->u.contents[i]))
+        != XFASTINT (widthtab->contents[i]))
       return 0;
 
   return 1;
@@ -138,7 +138,7 @@ recompute_width_table (struct buffer *buf, struct Lisp_Char_Table *disptab)
   eassert (widthtab->header.size == 256);
 
   for (i = 0; i < 256; i++)
-    XSETFASTINT (widthtab->u.contents[i], character_width (i, disptab));
+    XSETFASTINT (widthtab->contents[i], character_width (i, disptab));
 }
 
 /* Allocate or free the width run cache, as requested by the
@@ -1136,7 +1136,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
   width_run_cache_on_off ();
   if (dp == buffer_display_table ())
     width_table = (VECTORP (BVAR (current_buffer, width_table))
-                   ? XVECTOR (BVAR (current_buffer, width_table))->u.contents
+                   ? XVECTOR (BVAR (current_buffer, width_table))->contents
                    : 0);
   else
     /* If the window has its own display table, we can't use the width
index 0eb80c04d990758499cb675151fb3c503cd6d571..8de4f095396a9fa5548b5e15322368b6846c9b9e 100644 (file)
@@ -827,7 +827,7 @@ insert_1_both (const char *string,
 
   eassert (GPT <= GPT_BYTE);
 
-  /* The insert may have been in the unchanged region, so check again. */
+  /* The insert may have been in the unchanged region, so check again.  */
   if (Z - GPT < END_UNCHANGED)
     END_UNCHANGED = Z - GPT;
 
@@ -956,7 +956,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
 
   eassert (GPT <= GPT_BYTE);
 
-  /* The insert may have been in the unchanged region, so check again. */
+  /* The insert may have been in the unchanged region, so check again.  */
   if (Z - GPT < END_UNCHANGED)
     END_UNCHANGED = Z - GPT;
 
@@ -993,6 +993,11 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
   if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
     nchars = nbytes;
 
+  /* No need to call prepare_to_modify_buffer, since this is called
+     from places that replace some region with a different text, so
+     prepare_to_modify_buffer was already called by the deletion part
+     of this dance.  */
+  invalidate_buffer_caches (current_buffer, GPT, GPT);
   record_insert (GPT, nchars);
   MODIFF++;
 
@@ -1148,7 +1153,7 @@ insert_from_buffer_1 (struct buffer *buf,
 
   eassert (GPT <= GPT_BYTE);
 
-  /* The insert may have been in the unchanged region, so check again. */
+  /* The insert may have been in the unchanged region, so check again.  */
   if (Z - GPT < END_UNCHANGED)
     END_UNCHANGED = Z - GPT;
 
@@ -1778,6 +1783,8 @@ modify_text (ptrdiff_t start, ptrdiff_t end)
   bset_point_before_scroll (current_buffer, Qnil);
 }
 
+Lisp_Object Qregion_extract_function;
+
 /* Check that it is okay to modify the buffer between START and END,
    which are char positions.
 
@@ -1801,7 +1808,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
      let redisplay consider other windows if this buffer is visible.  */
   if (XBUFFER (XWINDOW (selected_window)->contents) != current_buffer
       && buffer_window_count (current_buffer))
-    ++windows_or_buffers_changed;
+    windows_or_buffers_changed = 20;
 
   if (buffer_intervals (current_buffer))
     {
@@ -1843,6 +1850,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
 #endif /* not CLASH_DETECTION */
 
   /* If `select-active-regions' is non-nil, save the region text.  */
+  /* FIXME: Move this to Elisp (via before-change-functions).  */
   if (!NILP (BVAR (current_buffer, mark_active))
       && !inhibit_modification_hooks
       && XMARKER (BVAR (current_buffer, mark))->buffer
@@ -1851,14 +1859,8 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
          ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
          : (!NILP (Vselect_active_regions)
             && !NILP (Vtransient_mark_mode))))
-    {
-      ptrdiff_t b = marker_position (BVAR (current_buffer, mark));
-      ptrdiff_t e = PT;
-      if (b < e)
-       Vsaved_region_selection = make_buffer_string (b, e, 0);
-      else if (b > e)
-       Vsaved_region_selection = make_buffer_string (e, b, 0);
-    }
+    Vsaved_region_selection
+      = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
 
   signal_before_change (start, end, preserve_ptr);
   Vdeactivate_mark = Qt;
@@ -1872,19 +1874,26 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
                          ptrdiff_t *preserve_ptr)
 {
   prepare_to_modify_buffer_1 (start, end, preserve_ptr);
+  invalidate_buffer_caches (current_buffer, start, end);
+}
 
-  if (current_buffer->newline_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->newline_cache,
-                             start - BEG, Z - end);
-  if (current_buffer->width_run_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->width_run_cache,
-                             start - BEG, Z - end);
-  if (current_buffer->bidi_paragraph_cache)
-    invalidate_region_cache (current_buffer,
-                             current_buffer->bidi_paragraph_cache,
-                             start - BEG, Z - end);
+/* Invalidate the caches maintained by the buffer BUF, if any, for the
+   region between buffer positions START and END.  */
+void
+invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
+{
+  if (buf->newline_cache)
+    invalidate_region_cache (buf,
+                             buf->newline_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  if (buf->width_run_cache)
+    invalidate_region_cache (buf,
+                             buf->width_run_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
+  if (buf->bidi_paragraph_cache)
+    invalidate_region_cache (buf,
+                             buf->bidi_paragraph_cache,
+                             start - BUF_BEG (buf), BUF_Z (buf) - end);
 }
 
 /* These macros work with an argument named `preserve_ptr'
@@ -2202,5 +2211,7 @@ as well as hooks attached to text properties and overlays.  */);
   inhibit_modification_hooks = 0;
   DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks");
 
+  DEFSYM (Qregion_extract_function, "region-extract-function");
+
   defsubr (&Scombine_after_change_execute);
 }
index 0ff4cda034ac6e0a1e52f76df24f0b95e05e71ea..450592a07b697fd8fc5a307ba182d9f37779bfdd 100644 (file)
@@ -821,7 +821,7 @@ This function is called by the editor initialization to begin editing.  */)
     return Qnil;
 
   command_loop_level++;
-  update_mode_lines = 1;
+  update_mode_lines = 17;
 
   if (command_loop_level
       && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
@@ -848,7 +848,7 @@ recursive_edit_unwind (Lisp_Object buffer)
     Fset_buffer (buffer);
 
   command_loop_level--;
-  update_mode_lines = 1;
+  update_mode_lines = 18;
 }
 
 \f
@@ -1064,8 +1064,6 @@ cmd_error (Lisp_Object data)
 void
 cmd_error_internal (Lisp_Object data, const char *context)
 {
-  struct frame *sf = SELECTED_FRAME ();
-
   /* The immediate context is not interesting for Quits,
      since they are asynchronous.  */
   if (EQ (XCAR (data), Qquit))
@@ -1079,9 +1077,23 @@ cmd_error_internal (Lisp_Object data, const char *context)
     call3 (Vcommand_error_function, data,
           context ? build_string (context) : empty_unibyte_string,
           Vsignaling_function);
+
+  Vsignaling_function = Qnil;
+}
+
+DEFUN ("command-error-default-function", Fcommand_error_default_function,
+       Scommand_error_default_function, 3, 3, 0,
+       doc: /* Produce default output for unhandled error message.
+Default value of `command-error-function'.  */)
+  (Lisp_Object data, Lisp_Object context, Lisp_Object signal)
+{
+  struct frame *sf = SELECTED_FRAME ();
+
+  CHECK_STRING (context);
+
   /* If the window system or terminal frame hasn't been initialized
      yet, or we're not interactive, write the message to stderr and exit.  */
-  else if (!sf->glyphs_initialized_p
+  if (!sf->glyphs_initialized_p
           /* The initial frame is a special non-displaying frame. It
              will be current in daemon mode when there are no frames
              to display, and in non-daemon mode before the real frame
@@ -1096,7 +1108,7 @@ cmd_error_internal (Lisp_Object data, const char *context)
           || noninteractive)
     {
       print_error_message (data, Qexternal_debugging_output,
-                          context, Vsignaling_function);
+                          SSDATA (context), signal);
       Fterpri (Qexternal_debugging_output);
       Fkill_emacs (make_number (-1));
     }
@@ -1107,10 +1119,9 @@ cmd_error_internal (Lisp_Object data, const char *context)
       message_log_maybe_newline ();
       bitch_at_user ();
 
-      print_error_message (data, Qt, context, Vsignaling_function);
+      print_error_message (data, Qt, SSDATA (context), signal);
     }
-
-  Vsignaling_function = Qnil;
+  return Qnil;
 }
 
 static Lisp_Object command_loop_2 (Lisp_Object);
@@ -1310,6 +1321,8 @@ static void adjust_point_for_property (ptrdiff_t, bool);
 /* The last boundary auto-added to buffer-undo-list.  */
 Lisp_Object last_undo_boundary;
 
+extern Lisp_Object Qregion_extract_function;
+
 /* FIXME: This is wrong rather than test window-system, we should call
    a new set-selection, which will then dispatch to x-set-selection, or
    tty-set-selection, or w32-set-selection, ...  */
@@ -1510,27 +1523,8 @@ command_loop_1 (void)
       already_adjusted = 0;
 
       if (NILP (Vthis_command))
-       {
-         /* nil means key is undefined.  */
-         Lisp_Object keys = Fvector (i, keybuf);
-         keys = Fkey_description (keys, Qnil);
-         bitch_at_user ();
-         message_with_string ("%s is undefined", keys, 0);
-         kset_defining_kbd_macro (current_kboard, Qnil);
-         update_mode_lines = 1;
-         /* If this is a down-mouse event, don't reset prefix-arg;
-            pass it to the command run by the up event.  */
-         if (EVENT_HAS_PARAMETERS (last_command_event))
-           {
-             Lisp_Object breakdown
-               = parse_modifiers (EVENT_HEAD (last_command_event));
-             int modifiers = XINT (XCAR (XCDR (breakdown)));
-             if (!(modifiers & down_modifier))
-               kset_prefix_arg (current_kboard, Qnil);
-           }
-         else
-           kset_prefix_arg (current_kboard, Qnil);
-       }
+       /* nil means key is undefined.  */
+       call0 (Qundefined);
       else
        {
          /* Here for a command that isn't executed directly.  */
@@ -1637,16 +1631,11 @@ command_loop_1 (void)
                  && NILP (Fmemq (Vthis_command,
                                  Vselection_inhibit_update_commands)))
                {
-                 ptrdiff_t beg =
-                   XINT (Fmarker_position (BVAR (current_buffer, mark)));
-                 ptrdiff_t end = PT;
-                 if (beg < end)
-                   call2 (Qx_set_selection, QPRIMARY,
-                          make_buffer_string (beg, end, 0));
-                 else if (beg > end)
-                   call2 (Qx_set_selection, QPRIMARY,
-                          make_buffer_string (end, beg, 0));
-                 /* Don't set empty selections.  */
+                 Lisp_Object txt
+                   = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
+                 if (XINT (Flength (txt)) > 0)
+                   /* Don't set empty selections.  */
+                   call2 (Qx_set_selection, QPRIMARY, txt);
                }
 
              if (current_buffer != prev_buffer || MODIFF != prev_modiff)
@@ -1675,7 +1664,7 @@ command_loop_1 (void)
               cluster to prevent automatic composition.  To recover
               the automatic composition, we must update the
               display.  */
-           windows_or_buffers_changed++;
+           windows_or_buffers_changed = 21;
          if (!already_adjusted)
            adjust_point_for_property (last_point_position,
                                       MODIFF != prev_modiff);
@@ -2097,7 +2086,7 @@ bind_polling_period (int n)
 \f
 /* Apply the control modifier to CHARACTER.  */
 
-#ifndef WINDOWSNT
+#ifndef HAVE_NTGUI
 static
 #endif
 int
@@ -4376,7 +4365,7 @@ decode_timer (Lisp_Object timer, struct timespec *result)
 
   if (! (VECTORP (timer) && ASIZE (timer) == 9))
     return 0;
-  vector = XVECTOR (timer)->u.contents;
+  vector = XVECTOR (timer)->contents;
   if (! NILP (vector[0]))
     return 0;
 
@@ -8006,7 +7995,7 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
         discard any previously made item.  */
       for (i = 0; i < ntool_bar_items; i += TOOL_BAR_ITEM_NSLOTS)
        {
-         Lisp_Object *v = XVECTOR (tool_bar_items_vector)->u.contents + i;
+         Lisp_Object *v = XVECTOR (tool_bar_items_vector)->contents + i;
 
          if (EQ (key, v[TOOL_BAR_ITEM_KEY]))
            {
@@ -8330,7 +8319,7 @@ append_tool_bar_item (void)
   /* Append entries from tool_bar_item_properties to the end of
      tool_bar_items_vector.  */
   vcopy (tool_bar_items_vector, ntool_bar_items,
-        XVECTOR (tool_bar_item_properties)->u.contents, TOOL_BAR_ITEM_NSLOTS);
+        XVECTOR (tool_bar_item_properties)->contents, TOOL_BAR_ITEM_NSLOTS);
   ntool_bar_items += TOOL_BAR_ITEM_NSLOTS;
 }
 
@@ -9934,7 +9923,7 @@ DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0,
        doc: /* Return vector of last 300 events, not counting those from keyboard macros.  */)
   (void)
 {
-  Lisp_Object *keys = XVECTOR (recent_keys)->u.contents;
+  Lisp_Object *keys = XVECTOR (recent_keys)->contents;
   Lisp_Object val;
 
   if (total_keys < NUM_RECENT_KEYS)
@@ -9960,7 +9949,7 @@ See also `this-command-keys-vector'.  */)
   (void)
 {
   return make_event_array (this_command_key_count,
-                          XVECTOR (this_command_keys)->u.contents);
+                          XVECTOR (this_command_keys)->contents);
 }
 
 DEFUN ("this-command-keys-vector", Fthis_command_keys_vector, Sthis_command_keys_vector, 0, 0, 0,
@@ -9972,7 +9961,7 @@ See also `this-command-keys'.  */)
   (void)
 {
   return Fvector (this_command_key_count,
-                 XVECTOR (this_command_keys)->u.contents);
+                 XVECTOR (this_command_keys)->contents);
 }
 
 DEFUN ("this-single-command-keys", Fthis_single_command_keys,
@@ -9987,7 +9976,7 @@ The value is always a vector.  */)
 {
   return Fvector (this_command_key_count
                  - this_single_command_key_start,
-                 (XVECTOR (this_command_keys)->u.contents
+                 (XVECTOR (this_command_keys)->contents
                   + this_single_command_key_start));
 }
 
@@ -10001,7 +9990,7 @@ shows the events before all translations (except for input methods).
 The value is always a vector.  */)
   (void)
 {
-  return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->u.contents);
+  return Fvector (raw_keybuf_count, XVECTOR (raw_keybuf)->contents);
 }
 
 DEFUN ("reset-this-command-lengths", Freset_this_command_lengths,
@@ -11127,6 +11116,7 @@ syms_of_keyboard (void)
   defsubr (&Sabort_recursive_edit);
   defsubr (&Sexit_recursive_edit);
   defsubr (&Srecursion_depth);
+  defsubr (&Scommand_error_default_function);
   defsubr (&Stop_level);
   defsubr (&Sdiscard_input);
   defsubr (&Sopen_dribble_file);
@@ -11606,13 +11596,13 @@ peculiar kind of quitting.  */);
   Vthrow_on_input = Qnil;
 
   DEFVAR_LISP ("command-error-function", Vcommand_error_function,
-              doc: /* If non-nil, function to output error messages.
-The arguments are the error data, a list of the form
- (SIGNALED-CONDITIONS . SIGNAL-DATA)
-such as just as `condition-case' would bind its variable to,
-the context (a string which normally goes at the start of the message),
-and the Lisp function within which the error was signaled.  */);
-  Vcommand_error_function = Qnil;
+              doc: /* Function to output error messages.
+Called with three arguments:
+- the error data, a list of the form (SIGNALED-CONDITION . SIGNAL-DATA)
+  such as what `condition-case' would bind its variable to,
+the context (a string which normally goes at the start of the message),
+- the Lisp function within which the error was signaled.  */);
+  Vcommand_error_function = intern ("command-error-default-function");
 
   DEFVAR_LISP ("enable-disabled-menus-and-buttons",
               Venable_disabled_menus_and_buttons,
index 7a18cd5d98386e07a80c05034b33122b9ef177e3..562787ee8a59ae09d50c54ef43c4cadc077ae44f 100644 (file)
@@ -3383,9 +3383,12 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
 
       if (vect[i].shadowed)
        {
-         SET_PT (PT - 1);
+         ptrdiff_t pt = max (PT - 1, BEG);
+
+         SET_PT (pt);
          insert_string ("\n  (that binding is currently shadowed by another mode)");
-         SET_PT (PT + 1);
+         pt = min (PT + 1, Z);
+         SET_PT (pt);
        }
     }
 
index e1a6fc7c91a01dd0bfcb51c260554ddb6471b9e2..a5aec41be387943e51da889f6f9a584a4c03111a 100644 (file)
@@ -45,7 +45,7 @@ INLINE_HEADER_BEGIN
    definitions visible to the debugger.  It's used for symbols that
    .gdbinit needs, symbols whose values may not fit in 'int' (where an
    enum would suffice).  */
-#ifdef MAIN_PROGRAM
+#if defined MAIN_PROGRAM
 # define DEFINE_GDB_SYMBOL_BEGIN(type, id) type const id EXTERNALLY_VISIBLE
 # define DEFINE_GDB_SYMBOL_END(id) = id;
 #else
@@ -71,7 +71,7 @@ typedef unsigned long long int EMACS_UINT;
 #  define pI "ll"
 # elif INT_MAX < LONG_MAX
 typedef long int EMACS_INT;
-typedef unsigned long int EMACS_UINT;
+typedef unsigned long EMACS_UINT;
 #  define EMACS_INT_MAX LONG_MAX
 #  define pI "l"
 # else
@@ -82,10 +82,26 @@ typedef unsigned int EMACS_UINT;
 # endif
 #endif
 
+/* Number of bits to put in each character in the internal representation
+   of bool vectors.  This should not vary across implementations.  */
+enum {  BOOL_VECTOR_BITS_PER_CHAR =
+#define BOOL_VECTOR_BITS_PER_CHAR 8
+        BOOL_VECTOR_BITS_PER_CHAR
+};
+
 /* An unsigned integer type representing a fixed-length bit sequence,
-   suitable for words in a Lisp bool vector.  */
+   suitable for words in a Lisp bool vector.  Normally it is size_t
+   for speed, but it is unsigned char on weird platforms.  */
+#if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT
 typedef size_t bits_word;
-#define BITS_WORD_MAX SIZE_MAX
+# define BITS_WORD_MAX SIZE_MAX
+enum { BITS_PER_BITS_WORD = CHAR_BIT * sizeof (bits_word) };
+#else
+typedef unsigned char bits_word;
+# define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1)
+enum { BITS_PER_BITS_WORD = BOOL_VECTOR_BITS_PER_CHAR };
+#endif
+verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1);
 
 /* Number of bits in some machine integer types.  */
 enum
@@ -94,7 +110,6 @@ enum
     BITS_PER_SHORT     = CHAR_BIT * sizeof (short),
     BITS_PER_INT       = CHAR_BIT * sizeof (int),
     BITS_PER_LONG      = CHAR_BIT * sizeof (long int),
-    BITS_PER_BITS_WORD = CHAR_BIT * sizeof (bits_word),
     BITS_PER_EMACS_INT = CHAR_BIT * sizeof (EMACS_INT)
   };
 
@@ -406,8 +421,10 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
 #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
 
 /* Idea stolen from GDB.  Pedantic GCC complains about enum bitfields,
-   MSVC doesn't support them, and xlc complains vociferously about them.  */
-#if defined __STRICT_ANSI__ || defined _MSC_VER || defined __IBMC__
+   MSVC doesn't support them, and xlc and Oracle Studio c99 complain
+   vociferously about them.  */
+#if (defined __STRICT_ANSI__ || defined _MSC_VER || defined __IBMC__ \
+     || (defined __SUNPRO_C && __STDC__))
 #define ENUM_BF(TYPE) unsigned int
 #else
 #define ENUM_BF(TYPE) enum TYPE
@@ -614,10 +631,6 @@ enum More_Lisp_Bits
     /* Used to extract pseudovector subtype information.  */
     PSEUDOVECTOR_AREA_BITS = PSEUDOVECTOR_SIZE_BITS + PSEUDOVECTOR_REST_BITS,
     PVEC_TYPE_MASK = 0x3f << PSEUDOVECTOR_AREA_BITS,
-
-    /* Number of bits to put in each character in the internal representation
-       of bool vectors.  This should not vary across implementations.  */
-    BOOL_VECTOR_BITS_PER_CHAR = 8
   };
 \f
 /* These functions extract various sorts of values from a Lisp_Object.
@@ -775,7 +788,7 @@ extern int char_table_translate (Lisp_Object, int);
 /* Defined in data.c.  */
 extern Lisp_Object Qarrayp, Qbufferp, Qbuffer_or_string_p, Qchar_table_p;
 extern Lisp_Object Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp, Qnil;
-extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qvectorp;
+extern Lisp_Object Qnumberp, Qstringp, Qsymbolp, Qt, Qvectorp;
 extern Lisp_Object Qbool_vector_p;
 extern Lisp_Object Qvector_or_char_table_p, Qwholenump;
 extern Lisp_Object Qwindow;
@@ -1150,7 +1163,7 @@ STRING_COPYIN (Lisp_Object string, ptrdiff_t index, char const *new,
    and PSEUDOVECTORP cast their pointers to struct vectorlike_header *,
    because when two such pointers potentially alias, a compiler won't
    incorrectly reorder loads and stores to their size fields.  See
-   <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8546>.  */
+   Bug#8546.  */
 struct vectorlike_header
   {
     /* The only field contains various pieces of information:
@@ -1175,22 +1188,22 @@ struct vectorlike_header
     ptrdiff_t size;
   };
 
-/* Regular vector is just a header plus array of Lisp_Objects...  */
+/* A regular vector is just a header plus an array of Lisp_Objects.  */
 
 struct Lisp_Vector
   {
     struct vectorlike_header header;
-    union {
-      /* ...but sometimes there is also a pointer internally used in
-        vector allocation code.  Usually you don't want to touch this.  */
-      struct Lisp_Vector *next;
+    Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
+  };
 
-      /* We can't use FLEXIBLE_ARRAY_MEMBER here.  */
-      Lisp_Object contents[1];
-    } u;
+/* C11 prohibits alignof (struct Lisp_Vector), so compute it manually.  */
+enum
+  {
+    ALIGNOF_STRUCT_LISP_VECTOR
+      = alignof (union { struct vectorlike_header a; Lisp_Object b; })
   };
 
-/* A boolvector is a kind of vectorlike, with contents are like a string.  */
+/* A boolvector is a kind of vectorlike, with contents like a string.  */
 
 struct Lisp_Bool_Vector
   {
@@ -1199,8 +1212,10 @@ struct Lisp_Bool_Vector
     struct vectorlike_header header;
     /* This is the size in bits.  */
     EMACS_INT size;
-    /* This contains the actual bits, packed into bytes.  */
-    unsigned char data[FLEXIBLE_ARRAY_MEMBER];
+    /* The actual bits, packed into bytes.
+       The bits are in little-endian order in the bytes, and
+       the bytes are in little-endian order in the words.  */
+    bits_word data[FLEXIBLE_ARRAY_MEMBER];
   };
 
 INLINE EMACS_INT
@@ -1211,12 +1226,72 @@ bool_vector_size (Lisp_Object a)
   return size;
 }
 
+INLINE bits_word *
+bool_vector_data (Lisp_Object a)
+{
+  return XBOOL_VECTOR (a)->data;
+}
+
+INLINE unsigned char *
+bool_vector_uchar_data (Lisp_Object a)
+{
+  return (unsigned char *) bool_vector_data (a);
+}
+
+/* The number of data words and bytes in a bool vector with SIZE bits.  */
+
+INLINE EMACS_INT
+bool_vector_words (EMACS_INT size)
+{
+  eassume (0 <= size && size <= EMACS_INT_MAX - (BITS_PER_BITS_WORD - 1));
+  return (size + BITS_PER_BITS_WORD - 1) / BITS_PER_BITS_WORD;
+}
+
+INLINE EMACS_INT
+bool_vector_bytes (EMACS_INT size)
+{
+  eassume (0 <= size && size <= EMACS_INT_MAX - (BITS_PER_BITS_WORD - 1));
+  return (size + BOOL_VECTOR_BITS_PER_CHAR - 1) / BOOL_VECTOR_BITS_PER_CHAR;
+}
+
+/* True if A's Ith bit is set.  */
+
+INLINE bool
+bool_vector_bitref (Lisp_Object a, EMACS_INT i)
+{
+  eassume (0 <= i && i < bool_vector_size (a));
+  return !! (bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR]
+            & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR)));
+}
+
+INLINE Lisp_Object
+bool_vector_ref (Lisp_Object a, EMACS_INT i)
+{
+  return bool_vector_bitref (a, i) ? Qt : Qnil;
+}
+
+/* Set A's Ith bit to B.  */
+
+INLINE void
+bool_vector_set (Lisp_Object a, EMACS_INT i, bool b)
+{
+  unsigned char *addr;
+
+  eassume (0 <= i && i < bool_vector_size (a));
+  addr = &bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR];
+
+  if (b)
+    *addr |= 1 << (i % BOOL_VECTOR_BITS_PER_CHAR);
+  else
+    *addr &= ~ (1 << (i % BOOL_VECTOR_BITS_PER_CHAR));
+}
+
 /* Some handy constants for calculating sizes
    and offsets, mostly of vectorlike objects.   */
 
 enum
   {
-    header_size = offsetof (struct Lisp_Vector, u.contents),
+    header_size = offsetof (struct Lisp_Vector, contents),
     bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
     word_size = sizeof (Lisp_Object)
   };
@@ -1226,13 +1301,13 @@ enum
 INLINE Lisp_Object
 AREF (Lisp_Object array, ptrdiff_t idx)
 {
-  return XVECTOR (array)->u.contents[idx];
+  return XVECTOR (array)->contents[idx];
 }
 
 INLINE Lisp_Object *
 aref_addr (Lisp_Object array, ptrdiff_t idx)
 {
-  return & XVECTOR (array)->u.contents[idx];
+  return & XVECTOR (array)->contents[idx];
 }
 
 INLINE ptrdiff_t
@@ -1245,7 +1320,7 @@ INLINE void
 ASET (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
 {
   eassert (0 <= idx && idx < ASIZE (array));
-  XVECTOR (array)->u.contents[idx] = val;
+  XVECTOR (array)->contents[idx] = val;
 }
 
 INLINE void
@@ -1254,7 +1329,7 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
   /* Like ASET, but also can be used in the garbage collector:
      sweep_weak_table calls set_hash_key etc. while the table is marked.  */
   eassert (0 <= idx && idx < (ASIZE (array) & ~ARRAY_MARK_FLAG));
-  XVECTOR (array)->u.contents[idx] = val;
+  XVECTOR (array)->contents[idx] = val;
 }
 
 /* If a struct is made to look like a vector, this macro returns the length
@@ -1758,14 +1833,14 @@ struct Lisp_Misc_Any            /* Supertype of all Misc types.  */
 {
   ENUM_BF (Lisp_Misc_Type) type : 16;          /* = Lisp_Misc_??? */
   unsigned gcmarkbit : 1;
-  int spacer : 15;
+  unsigned spacer : 15;
 };
 
 struct Lisp_Marker
 {
   ENUM_BF (Lisp_Misc_Type) type : 16;          /* = Lisp_Misc_Marker */
   unsigned gcmarkbit : 1;
-  int spacer : 13;
+  unsigned spacer : 13;
   /* This flag is temporarily used in the functions
      decode/encode_coding_object to record that the marker position
      must be adjusted after the conversion.  */
@@ -1819,7 +1894,7 @@ struct Lisp_Overlay
   {
     ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Overlay */
     unsigned gcmarkbit : 1;
-    int spacer : 15;
+    unsigned spacer : 15;
     struct Lisp_Overlay *next;
     Lisp_Object start;
     Lisp_Object end;
@@ -1897,7 +1972,7 @@ struct Lisp_Save_Value
   {
     ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Save_Value */
     unsigned gcmarkbit : 1;
-    int spacer : 32 - (16 + 1 + SAVE_TYPE_BITS);
+    unsigned spacer : 32 - (16 + 1 + SAVE_TYPE_BITS);
 
     /* V->data may hold up to SAVE_VALUE_SLOTS entries.  The type of
        V's data entries are determined by V->save_type.  E.g., if
@@ -1973,7 +2048,7 @@ struct Lisp_Free
   {
     ENUM_BF (Lisp_Misc_Type) type : 16;        /* = Lisp_Misc_Free */
     unsigned gcmarkbit : 1;
-    int spacer : 15;
+    unsigned spacer : 15;
     union Lisp_Misc *chain;
   };
 
@@ -2737,7 +2812,7 @@ union specbinding
     } let;
     struct {
       ENUM_BF (specbind_tag) kind : CHAR_BIT;
-      bool debug_on_exit : 1;
+      unsigned debug_on_exit : 1;
       Lisp_Object function;
       Lisp_Object *args;
       ptrdiff_t nargs;
@@ -2807,14 +2882,13 @@ struct handler
 
 /* Fill in the components of c, and put it on the list.  */
 #define PUSH_HANDLER(c, tag_ch_val, handlertype)       \
-  if (handlerlist && handlerlist->nextfree)            \
+  if (handlerlist->nextfree)                           \
     (c) = handlerlist->nextfree;                       \
   else                                                 \
     {                                                  \
       (c) = xmalloc (sizeof (struct handler));         \
       (c)->nextfree = NULL;                            \
-      if (handlerlist)                                 \
-       handlerlist->nextfree = (c);                    \
+      handlerlist->nextfree = (c);                     \
     }                                                  \
   (c)->type = (handlertype);                           \
   (c)->tag_or_ch = (tag_ch_val);                       \
@@ -3089,7 +3163,7 @@ INLINE void
 vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count)
 {
   eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
-  memcpy (XVECTOR (v)->u.contents + offset, args, count * sizeof *args);
+  memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
 }
 
 /* Functions to modify hash tables.  */
@@ -3405,6 +3479,7 @@ extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t,
 extern void modify_text (ptrdiff_t, ptrdiff_t);
 extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
 extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
+extern void invalidate_buffer_caches (struct buffer *, ptrdiff_t, ptrdiff_t);
 extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
 extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
                                 ptrdiff_t, ptrdiff_t);
@@ -3461,7 +3536,6 @@ extern void update_echo_area (void);
 extern void truncate_echo_area (ptrdiff_t);
 extern void redisplay (void);
 extern void redisplay_preserve_echo_area (int);
-extern void prepare_menu_bars (void);
 
 void set_frame_cursor_types (struct frame *, Lisp_Object);
 extern void syms_of_xdisp (void);
@@ -3524,6 +3598,8 @@ list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, EMACS_INT h)
                make_number (w), make_number (h));
 }
 
+extern Lisp_Object make_uninit_bool_vector (EMACS_INT);
+extern Lisp_Object bool_vector_fill (Lisp_Object, Lisp_Object);
 extern _Noreturn void string_overflow (void);
 extern Lisp_Object make_string (const char *, ptrdiff_t);
 extern Lisp_Object make_formatted_string (char *, const char *, ...)
@@ -4417,10 +4493,6 @@ functionp (Lisp_Object object)
     return 0;
 }
 
-/* Round x to the next multiple of y.  Does not overflow.  Evaluates
-   arguments repeatedly.  */
-#define ROUNDUP(x,y) ((y)*((x)/(y) + ((x)%(y)!=0)))
-
 INLINE_HEADER_END
 
 #endif /* EMACS_LISP_H */
index fe2b92a34b3407fd93d83b4aa9360c33cc367111..6c1b17f62b738f4f0e6cf726aa4b11de0ed38712 100644 (file)
@@ -1500,7 +1500,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
       for (tail = NILP (suffixes) ? list1 (empty_unibyte_string) : suffixes;
           CONSP (tail); tail = XCDR (tail))
        {
-         ptrdiff_t fnlen, lsuffix = SBYTES (XCAR (tail));
+         Lisp_Object suffix = XCAR (tail);
+         ptrdiff_t fnlen, lsuffix = SBYTES (suffix);
          Lisp_Object handler;
 
          /* Concatenate path element/specified name with the suffix.
@@ -1511,7 +1512,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
                           ? 2 : 0);
          fnlen = SBYTES (filename) - prefixlen;
          memcpy (fn, SDATA (filename) + prefixlen, fnlen);
-         memcpy (fn + fnlen, SDATA (XCAR (tail)), lsuffix + 1);
+         memcpy (fn + fnlen, SDATA (suffix), lsuffix + 1);
          fnlen += lsuffix;
          /* Check that the file exists and is not a directory.  */
          /* We used to only check for handlers on non-absolute file names:
@@ -1521,7 +1522,18 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes,
                  handler = Ffind_file_name_handler (filename, Qfile_exists_p);
             It's not clear why that was the case and it breaks things like
             (load "/bar.el") where the file is actually "/bar.el.gz".  */
-         string = make_string (fn, fnlen);
+         /* make_string has its own ideas on when to return a unibyte
+            string and when a multibyte string, but we know better.
+            We must have a unibyte string when dumping, since
+            file-name encoding is shaky at best at that time, and in
+            particular default-file-name-coding-system is reset
+            several times during loadup.  We therefore don't want to
+            encode the file before passing it to file I/O library
+            functions.  */
+         if (!STRING_MULTIBYTE (filename) && !STRING_MULTIBYTE (suffix))
+           string = make_unibyte_string (fn, fnlen);
+         else
+           string = make_string (fn, fnlen);
          handler = Ffind_file_name_handler (string, Qfile_exists_p);
          if ((!NILP (handler) || !NILP (predicate)) && !NATNUMP (predicate))
             {
@@ -2565,9 +2577,8 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
          if (c == '"')
            {
              Lisp_Object tmp, val;
-             EMACS_INT size_in_chars
-               = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1)
-                  / BOOL_VECTOR_BITS_PER_CHAR);
+             EMACS_INT size_in_chars = bool_vector_bytes (XFASTINT (length));
+             unsigned char *data;
 
              UNREAD (c);
              tmp = read1 (readcharfun, pch, first_in_list);
@@ -2581,11 +2592,12 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
                            == (SCHARS (tmp) - 1) * BOOL_VECTOR_BITS_PER_CHAR)))
                invalid_syntax ("#&...");
 
-             val = Fmake_bool_vector (length, Qnil);
-             memcpy (XBOOL_VECTOR (val)->data, SDATA (tmp), size_in_chars);
+             val = make_uninit_bool_vector (XFASTINT (length));
+             data = bool_vector_uchar_data (val);
+             memcpy (data, SDATA (tmp), size_in_chars);
              /* Clear the extraneous bits in the last byte.  */
              if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR)
-               XBOOL_VECTOR (val)->data[size_in_chars - 1]
+               data[size_in_chars - 1]
                  &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1;
              return val;
            }
@@ -3462,7 +3474,7 @@ read_vector (Lisp_Object readcharfun, bool bytecodeflag)
   vector = Fmake_vector (len, Qnil);
 
   size = ASIZE (vector);
-  ptr = XVECTOR (vector)->u.contents;
+  ptr = XVECTOR (vector)->contents;
   for (i = 0; i < size; i++)
     {
       item = Fcar (tem);
index 141d60bfb0a94d0ba1cc02725c9ff6eeefc2ad24..4b57c18692e64cf2df1a25ee3b5834ee9fcb0773 100644 (file)
@@ -134,6 +134,9 @@ enum {
 
 #define mac_nsctfont_copy_font_descriptor CTFontCopyFontDescriptor
 
+#ifndef kCTVersionNumber10_9
+#define kCTVersionNumber10_9 0x00060000
+#endif
 #define MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE \
   (CFSTR ("MAC_FONT_CHARACTER_SET_STRING_ATTRIBUTE"))
 
index b3bf96d8c4e0e864e0afec3248f5bc2a7b2e6629..10623eb12fea4772ce766f4e7a7bba9103d418d4 100644 (file)
@@ -57,6 +57,13 @@ static Boolean mac_ctfont_descriptor_supports_languages (CTFontDescriptorRef,
 static CFStringRef mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef);
 static CFIndex mac_ctfont_shape (CTFontRef, CFStringRef,
                                 struct mac_glyph_layout *, CFIndex);
+static CFArrayRef
+mac_font_copy_default_descriptors_for_language (CFStringRef language);
+
+static CFStringRef
+mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef charset,
+                                                     CFArrayRef languages);
+
 #if USE_CT_GLYPH_INFO
 static CGGlyph mac_ctfont_get_glyph_for_cid (CTFontRef,
                                             CTCharacterCollection,
@@ -64,7 +71,7 @@ static CGGlyph mac_ctfont_get_glyph_for_cid (CTFontRef,
 #endif
 
 /* The font property key specifying the font design destination.  The
-   value is an unsigned integer code: 0 for WYSIWIG, and 1 for Video
+   value is an unsigned integer code: 0 for WYSIWYG, and 1 for Video
    text.  (See the documentation of X Logical Font Description
    Conventions.)  In the Mac font driver, 1 means the screen font is
    used for calculating some glyph metrics.  You can see the
@@ -366,7 +373,7 @@ mac_font_shape_1 (NSFont *font, NSString *string,
   if (!(textStorage && layoutManager && textContainer))
     {
       [textStorage release];
-      
+
       return 0;
     }
 
@@ -624,19 +631,26 @@ get_cgcolor(unsigned long idx, struct frame *f)
 }
 
 #define CG_SET_FILL_COLOR_WITH_GC_FOREGROUND(context, s)                \
-  CGContextSetFillColorWithColor (context,                              \
-                                  get_cgcolor (NS_FACE_FOREGROUND (s->face), \
-                                               s->f))
-
+  do {                                                                  \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face),     \
+                                      s->f);                            \
+    CGContextSetFillColorWithColor (context, refcol_) ;                 \
+    CGColorRelease (refcol_);                                           \
+  } while (0)
 #define CG_SET_FILL_COLOR_WITH_GC_BACKGROUND(context, s)                \
-  CGContextSetFillColorWithColor (context,                              \
-                                  get_cgcolor (NS_FACE_BACKGROUND (s->face), \
-                                               s->f))
-
+  do {                                                                  \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (s->face),\
+                                      s->f);                            \
+    CGContextSetFillColorWithColor (context, refcol_);                  \
+    CGColorRelease (refcol_);                                           \
+  } while (0)
 #define CG_SET_STROKE_COLOR_WITH_GC_FOREGROUND(context, s)              \
-  CGContextSetStrokeColorWithColor (context,                            \
-                                    get_cgcolor (NS_FACE_FOREGROUND (s->face),\
-                                                 s->f))
+  do {                                                                  \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (s->face),\
+                                      s->f);                            \
+    CGContextSetStrokeColorWithColor (context, refcol_);                \
+    CGColorRelease (refcol_);                                           \
+  } while (0)
 
 \f
 /* Mac font driver.  */
@@ -669,7 +683,7 @@ static struct
     { "iso8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }},
     { "iso8859-16", { 0x00A0, 0x0218}},
     { "gb2312.1980-0", { 0x4E13 }, CFSTR ("zh-Hans")},
-    { "big5-0", { /* 0xF6B1 in ftfont.c */ 0xF7E5 }, CFSTR ("zh-Hant") },
+    { "big5-0", { /* 0xF6B1 in ftfont.c */ 0x4EDC }, CFSTR ("zh-Hant") },
     { "jisx0208.1983-0", { 0x4E55 }, CFSTR ("ja")},
     { "ksc5601.1987-0", { 0xAC00 }, CFSTR ("ko")},
     { "cns11643.1992-1", { 0xFE32 }, CFSTR ("zh-Hant")},
@@ -693,9 +707,31 @@ static struct
     { NULL }
   };
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+static const struct
+{
+  CFStringRef language;
+  CFStringRef font_names[3];
+} macfont_language_default_font_names[] = {
+  { CFSTR ("ja"), { CFSTR ("HiraKakuProN-W3"), /* 10.5 - 10.9 */
+                   CFSTR ("HiraKakuPro-W3"),  /* 10.4 */
+                   NULL }},
+  { CFSTR ("ko"), { CFSTR ("AppleSDGothicNeo-Regular"), /* 10.8 - 10.9 */
+                   CFSTR ("AppleGothic"), /* 10.4 - 10.7 */
+                   NULL }},
+  { CFSTR ("zh-Hans"), { CFSTR ("STHeitiSC-Light"), /* 10.6 - 10.9 */
+                        CFSTR ("STXihei"),         /* 10.4 - 10.5 */
+                        NULL }},
+  { CFSTR ("zh-Hant"), { CFSTR ("STHeitiTC-Light"), /* 10.6 - 10.9 */
+                        CFSTR ("LiHeiPro"),        /* 10.4 - 10.5 */
+                        NULL }},
+  { NULL }
+};
+#endif
+
 static CGFloat macfont_antialias_threshold;
 
-void
+static void
 macfont_update_antialias_threshold (void)
 {
   int threshold;
@@ -1159,7 +1195,7 @@ struct macfont_cache
 
     /* The cached glyph for a character c is stored as the (c %
        NGLYPHS_IN_VALUE)-th CGGlyph block of a value for the key (c /
-       NGLYPHS_IN_VALUE).  However, the glyph for a BMP characrer c is
+       NGLYPHS_IN_VALUE).  However, the glyph for a BMP character c is
        not stored here if row_nkeys_or_perm[c / 256] >=
        ROW_PERM_OFFSET.  */
     CFMutableDictionaryRef dictionary;
@@ -1518,7 +1554,7 @@ static Lisp_Object macfont_match (struct frame *, Lisp_Object);
 static Lisp_Object macfont_list_family (struct frame *);
 static void macfont_free_entity (Lisp_Object);
 static Lisp_Object macfont_open (struct frame *, Lisp_Object, int);
-static void macfont_close (struct frame *, struct font *);
+static void macfont_close (struct font *);
 static int macfont_has_char (Lisp_Object, int);
 static unsigned macfont_encode_char (struct font *, int);
 static int macfont_text_extents (struct font *, unsigned int *, int,
@@ -2045,33 +2081,7 @@ macfont_list (struct frame *f, Lisp_Object spec)
   if (! attributes)
     goto finish;
 
-  charset = ((CFCharacterSetRef)
-            CFDictionaryGetValue (attributes,
-                                  MAC_FONT_CHARACTER_SET_ATTRIBUTE));
-  if (charset)
-    {
-      CFRetain (charset);
-      CFDictionaryRemoveValue (attributes, MAC_FONT_CHARACTER_SET_ATTRIBUTE);
-    }
-  else
-    {
-      val = assq_no_quit (QCscript, AREF (spec, FONT_EXTRA_INDEX));
-      if (! NILP (val))
-       {
-         val = assq_no_quit (XCDR (val), Vscript_representative_chars);
-         if (CONSP (val) && VECTORP (XCDR (val)))
-           chars = XCDR (val);
-       }
-      val = Qnil;
-    }
-
-  languages = ((CFArrayRef)
-              CFDictionaryGetValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE));
-  if (languages)
-    {
-      CFRetain (languages);
-      CFDictionaryRemoveValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE);
-    }
+  languages = CFDictionaryGetValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE);
 
   if (INTEGERP (AREF (spec, FONT_SPACING_INDEX)))
     spacing = XINT (AREF (spec, FONT_SPACING_INDEX));
@@ -2155,6 +2165,31 @@ macfont_list (struct frame *f, Lisp_Object spec)
        }
     }
 
+  charset = CFDictionaryGetValue (attributes,
+                                 MAC_FONT_CHARACTER_SET_ATTRIBUTE);
+  if (charset)
+    {
+      CFRetain (charset);
+      CFDictionaryRemoveValue (attributes, MAC_FONT_CHARACTER_SET_ATTRIBUTE);
+    }
+  else
+    {
+      val = assq_no_quit (QCscript, AREF (spec, FONT_EXTRA_INDEX));
+      if (! NILP (val))
+       {
+         val = assq_no_quit (XCDR (val), Vscript_representative_chars);
+         if (CONSP (val) && VECTORP (XCDR (val)))
+           chars = XCDR (val);
+       }
+      val = Qnil;
+    }
+
+  if (languages)
+    {
+      CFRetain (languages);
+      CFDictionaryRemoveValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE);
+    }
+
   val = Qnil;
   extra = AREF (spec, FONT_EXTRA_INDEX);
   families_count = CFArrayGetCount (families);
@@ -2465,7 +2500,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
   macfont_info = (struct macfont_info *) font;
   macfont_info->macfont = macfont;
   macfont_info->cgfont = mac_font_copy_graphics_font (macfont);
-  
+
   val = assq_no_quit (QCdestination, AREF (entity, FONT_EXTRA_INDEX));
   if (CONSP (val) && EQ (XCDR (val), make_number (1)))
     macfont_info->screen_font = mac_screen_font_create_with_name (font_name,
@@ -2580,7 +2615,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
 }
 
 static void
-macfont_close (struct frame * f, struct font *font)
+macfont_close (struct font *font)
 {
   struct macfont_info *macfont_info = (struct macfont_info *) font;
   int i;
@@ -2667,7 +2702,7 @@ macfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
     }
   unblock_input ();
 
-  if (metrics) 
+  if (metrics)
     metrics->width = width;
 
   return width;
@@ -2729,7 +2764,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
       for (i = 0; i < len; i++)
        {
          int width;
+
          glyphs[i] = *(s->char2b + s->cmp_from + i);
          width = (s->padding_p ? 1
                   : macfont_glyph_extents (s->font, glyphs[i],
@@ -2786,7 +2821,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
   return len;
 }
 
-Lisp_Object
+static Lisp_Object
 macfont_shape (Lisp_Object lgstring)
 {
   struct font *font;
@@ -2989,7 +3024,7 @@ struct non_default_uvs_table
 #define BUINT32_VALUE(lval)    OSReadBigInt32 (&(lval), 0)
 
 /* Return UVS subtable for the specified FONT.  If the subtable is not
-   found or ill-formated, then return NULL.  */
+   found or ill-formatted, then return NULL.  */
 
 static CFDataRef
 mac_font_copy_uvs_table (FontRef font)
@@ -3323,49 +3358,80 @@ mac_ctfont_create_preferred_family_for_attributes (CFDictionaryRef attributes)
 
   if (charset_string && CFStringGetLength (charset_string) > 0)
     {
-      CFAttributedStringRef attr_string = NULL;
-      CTLineRef ctline = NULL;
-      CFDictionaryRef attrs =
-       CFDictionaryCreate (NULL, NULL, NULL, 0,
-                           &kCFTypeDictionaryKeyCallBacks,
-                           &kCFTypeDictionaryValueCallBacks);
+      CFStringRef keys[] = {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+       kCTLanguageAttributeName
+#else
+       CFSTR ("NSLanguage")
+#endif
+      };
+      CFTypeRef values[] = {NULL};
+      CFIndex num_values = 0;
+      CFArrayRef languages
+       = CFDictionaryGetValue (attributes, MAC_FONT_LANGUAGES_ATTRIBUTE);
 
-      if (attrs)
-       {
-         attr_string = CFAttributedStringCreate (NULL, charset_string, attrs);
-         CFRelease (attrs);
-       }
-      if (attr_string)
+      if (languages && CFArrayGetCount (languages) > 0)
        {
-         ctline = CTLineCreateWithAttributedString (attr_string);
-         CFRelease (attr_string);
+         if (CTGetCoreTextVersion () >= kCTVersionNumber10_9)
+           values[num_values++] = CFArrayGetValueAtIndex (languages, 0);
+         else
+           {
+             CFCharacterSetRef charset =
+               CFDictionaryGetValue (attributes,
+                                     MAC_FONT_CHARACTER_SET_ATTRIBUTE);
+
+             result = mac_font_copy_default_name_for_charset_and_languages (charset, languages);
+           }
        }
-      if (ctline)
+      if (result == NULL)
        {
-         CFArrayRef runs = CTLineGetGlyphRuns (ctline);
-         CFIndex i, nruns = CFArrayGetCount (runs);
-         CTFontRef font;
-
-         for (i = 0; i < nruns; i++)
+         CFAttributedStringRef attr_string = NULL;
+         CTLineRef ctline = NULL;
+         CFDictionaryRef attrs
+           = CFDictionaryCreate (NULL, (const void **) keys,
+                                 (const void **) values, num_values,
+                                 &kCFTypeDictionaryKeyCallBacks,
+                                 &kCFTypeDictionaryValueCallBacks);
+
+         if (attrs)
            {
-             CTRunRef run = CFArrayGetValueAtIndex (runs, i);
-             CFDictionaryRef attributes = CTRunGetAttributes (run);
-             CTFontRef font_in_run;
+             attr_string = CFAttributedStringCreate (NULL, charset_string,
+                                                     attrs);
+             CFRelease (attrs);
+           }
+         if (attr_string)
+           {
+             ctline = CTLineCreateWithAttributedString (attr_string);
+             CFRelease (attr_string);
+           }
+         if (ctline)
+           {
+             CFArrayRef runs = CTLineGetGlyphRuns (ctline);
+             CFIndex i, nruns = CFArrayGetCount (runs);
+             CTFontRef font;
 
-             if (attributes == NULL)
-               break;
-             font_in_run =
-               CFDictionaryGetValue (attributes, kCTFontAttributeName);
-             if (font_in_run == NULL)
-               break;
-             if (i == 0)
-               font = font_in_run;
-             else if (!mac_ctfont_equal_in_postscript_name (font, font_in_run))
-               break;
+             for (i = 0; i < nruns; i++)
+               {
+                 CTRunRef run = CFArrayGetValueAtIndex (runs, i);
+                 CFDictionaryRef attributes = CTRunGetAttributes (run);
+                 CTFontRef font_in_run;
+
+                 if (attributes == NULL)
+                   break;
+                 font_in_run =
+                   CFDictionaryGetValue (attributes, kCTFontAttributeName);
+                 if (font_in_run == NULL)
+                   break;
+                 if (i == 0)
+                   font = font_in_run;
+                 else if (!mac_ctfont_equal_in_postscript_name (font,
+                                                                font_in_run))
+                   break;
+               }
+             if (nruns > 0 && i == nruns)
+               result = CTFontCopyAttribute (font, kCTFontFamilyNameAttribute);
+             CFRelease (ctline);
            }
-         if (nruns > 0 && i == nruns)
-           result = CTFontCopyAttribute (font, kCTFontFamilyNameAttribute);
-         CFRelease (ctline);
        }
     }
 
@@ -3559,7 +3625,7 @@ mac_ctfont_create_line_with_string_and_font (CFStringRef string,
   return ctline;
 }
 
-CFIndex
+static CFIndex
 mac_ctfont_shape (CTFontRef font, CFStringRef string,
                  struct mac_glyph_layout *glyph_layouts, CFIndex glyph_len)
 {
@@ -3712,7 +3778,7 @@ mac_ctfont_shape (CTFontRef font, CFStringRef string,
    created by CFStringCreateWithCharacters as of Mac OS X 10.5.8 and
    10.6.3.  For now, we use the NSGlyphInfo version instead.  */
 #if USE_CT_GLYPH_INFO
-CGGlyph
+static CGGlyph
 mac_ctfont_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection,
                              CGFontIndex cid)
 {
@@ -3805,7 +3871,7 @@ mac_font_family_group (CFStringRef family)
     }
 }
 
-CFComparisonResult
+static CFComparisonResult
 mac_font_family_compare (const void *val1, const void *val2, void *context)
 {
   CFStringRef family1 = (CFStringRef) val1, family2 = (CFStringRef) val2;
@@ -3821,6 +3887,142 @@ mac_font_family_compare (const void *val1, const void *val2, void *context)
 }
 #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
 
+static CFArrayRef
+mac_font_copy_default_descriptors_for_language (CFStringRef language)
+{
+  CFArrayRef result = NULL;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+  if (CTFontCopyDefaultCascadeListForLanguages != NULL)
+#endif
+    {
+      CTFontRef user_font =
+       CTFontCreateUIFontForLanguage (kCTFontUserFontType, 0, language);
+
+      if (user_font)
+       {
+         CFArrayRef languages =
+           CFArrayCreate (NULL, (const void **) &language, 1,
+                          &kCFTypeArrayCallBacks);
+
+         if (languages)
+           {
+             result = CTFontCopyDefaultCascadeListForLanguages (user_font,
+                                                                languages);
+             CFRelease (languages);
+           }
+         CFRelease (user_font);
+       }
+    }
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+  else         /* CTFontCopyDefaultCascadeListForLanguages == NULL */
+#endif
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 */
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+    {
+      CFIndex i;
+
+      for (i = 0; macfont_language_default_font_names[i].language; i++)
+       {
+         if (CFStringCompare (macfont_language_default_font_names[i].language,
+                              language, 0) == kCFCompareEqualTo)
+           {
+             CFMutableArrayRef descriptors =
+               CFArrayCreateMutable (NULL, 0, &kCFTypeArrayCallBacks);
+
+             if (descriptors)
+               {
+                 CFIndex j;
+
+                 for (j = 0;
+                      macfont_language_default_font_names[i].font_names[j];
+                      j++)
+                   {
+                     CFDictionaryRef attributes =
+                       CFDictionaryCreate (NULL,
+                                           ((const void **)
+                                            &MAC_FONT_NAME_ATTRIBUTE),
+                                           ((const void **)
+                                            &macfont_language_default_font_names[i].font_names[j]),
+                                           1, &kCFTypeDictionaryKeyCallBacks,
+                                           &kCFTypeDictionaryValueCallBacks);
+
+                     if (attributes)
+                       {
+                         FontDescriptorRef pat_desc =
+                           mac_font_descriptor_create_with_attributes (attributes);
+
+                         if (pat_desc)
+                           {
+                             FontDescriptorRef descriptor =
+                               mac_font_descriptor_create_matching_font_descriptor (pat_desc, NULL);
+
+                             if (descriptor)
+                               {
+                                 CFArrayAppendValue (descriptors, descriptor);
+                                 CFRelease (descriptor);
+                               }
+                             CFRelease (pat_desc);
+                           }
+                         CFRelease (attributes);
+                       }
+                   }
+                 result = descriptors;
+               }
+             break;
+           }
+       }
+    }
+#endif
+
+  return result;
+}
+
+static CFStringRef
+mac_font_copy_default_name_for_charset_and_languages (CFCharacterSetRef charset,
+                                                     CFArrayRef languages)
+{
+  CFStringRef result = NULL;
+  CFStringRef language = CFArrayGetValueAtIndex (languages, 0);
+  CFArrayRef descriptors =
+    mac_font_copy_default_descriptors_for_language (language);
+
+  if (descriptors)
+    {
+      CFIndex i, count = CFArrayGetCount (descriptors);
+
+      for (i = 0; i < count; i++)
+       {
+         FontDescriptorRef descriptor =
+           CFArrayGetValueAtIndex (descriptors, i);
+
+         if (macfont_supports_charset_and_languages_p (descriptor, charset,
+                                                       Qnil, languages))
+           {
+             CFStringRef family =
+               mac_font_descriptor_copy_attribute (descriptor,
+                                                   MAC_FONT_FAMILY_NAME_ATTRIBUTE);
+             if (family)
+               {
+                 if (!CFStringHasPrefix (family, CFSTR ("."))
+                     && (CFStringCompare (family, CFSTR ("LastResort"), 0)
+                         != kCFCompareEqualTo))
+                   {
+                     result = family;
+                     break;
+                   }
+                 else
+                   CFRelease (family);
+               }
+           }
+       }
+      CFRelease (descriptors);
+    }
+
+  return result;
+}
+
 void *
 macfont_get_nsctfont (struct font *font)
 {
index 0c11efcdc9a2b6db5f32838763531c978588fd58..232188a408b93b508f7b122dd158a73770ec1325 100644 (file)
@@ -55,7 +55,7 @@ Use \\[name-last-kbd-macro] to give it a permanent name.
 Non-nil arg (prefix arg) means append to last macro defined;
 this begins by re-executing that macro as if you typed it again.
 If optional second arg, NO-EXEC, is non-nil, do not re-execute last
-macro before appending to it. */)
+macro before appending to it.  */)
   (Lisp_Object append, Lisp_Object no_exec)
 {
   if (!NILP (KVAR (current_kboard, defining_kbd_macro)))
@@ -66,7 +66,7 @@ macro before appending to it. */)
       current_kboard->kbd_macro_buffer = xmalloc (30 * word_size);
       current_kboard->kbd_macro_bufsize = 30;
     }
-  update_mode_lines++;
+  update_mode_lines = 19;
   if (NILP (append))
     {
       if (current_kboard->kbd_macro_bufsize > 200)
@@ -138,7 +138,7 @@ void
 end_kbd_macro (void)
 {
   kset_defining_kbd_macro (current_kboard, Qnil);
-  update_mode_lines++;
+  update_mode_lines = 20;
   kset_last_kbd_macro
     (current_kboard,
      make_event_array ((current_kboard->kbd_macro_end
index 17d6629064722f5f77ab0f4e463c5e178e698230..cd89f5eecea42b73adcc25f0da931573e5dc5113 100644 (file)
@@ -51,7 +51,7 @@ extern Lisp_Object ns_menu_show (struct frame *, int, int, bool, bool,
                                 Lisp_Object, const char **);
 extern Lisp_Object xmenu_show (struct frame *, int, int, bool, bool,
                               Lisp_Object, const char **);
-extern Lisp_Object tty_menu_show (struct frame *, int, int, int, int,
-                                 Lisp_Object, int, const char **);
+extern Lisp_Object tty_menu_show (struct frame *, int, int, bool, bool,
+                                 Lisp_Object, bool, const char **);
 extern ptrdiff_t menu_item_width (const unsigned char *);
 #endif /* MENU_H */
index cc6f234f7dafa6729b4bf5795dc647bdf6d3a900..8eb1a2890e0015f9eed531596f1789167a924e07 100644 (file)
@@ -866,7 +866,7 @@ read_minibuf_unwind (void)
     resize_mini_window (XWINDOW (window), 0);
 
   /* Enforce full redisplay.  FIXME: make it more selective.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 22;
 
   /* In case the previous minibuffer displayed in this miniwindow is
      dead, we may keep displaying this buffer (tho it's inactive), so reset it,
@@ -1199,9 +1199,7 @@ is used to further constrain the set of candidates.  */)
     type = (HASH_TABLE_P (collection) ? hash_table
            : VECTORP (collection) ? obarray_table
            : ((NILP (collection)
-               || (CONSP (collection)
-                   && (!SYMBOLP (XCAR (collection))
-                       || NILP (XCAR (collection)))))
+               || (CONSP (collection) && !FUNCTIONP (collection)))
               ? list_table : function_table));
   ptrdiff_t idx = 0, obsize = 0;
   int matchcount = 0;
@@ -1460,9 +1458,7 @@ with a space are ignored unless STRING itself starts with a space.  */)
   Lisp_Object allmatches;
   int type = HASH_TABLE_P (collection) ? 3
     : VECTORP (collection) ? 2
-    : NILP (collection) || (CONSP (collection)
-                           && (!SYMBOLP (XCAR (collection))
-                               || NILP (XCAR (collection))));
+    : NILP (collection) || (CONSP (collection) && !FUNCTIONP (collection));
   ptrdiff_t idx = 0, obsize = 0;
   ptrdiff_t bindcount = -1;
   Lisp_Object bucket, tem, zero;
@@ -1691,9 +1687,7 @@ the values STRING, PREDICATE and `lambda'.  */)
 
   CHECK_STRING (string);
 
-  if ((CONSP (collection)
-       && (!SYMBOLP (XCAR (collection)) || NILP (XCAR (collection))))
-      || NILP (collection))
+  if (NILP (collection) || (CONSP (collection) && !FUNCTIONP (collection)))
     {
       tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil);
       if (NILP (tem))
index cb4f8c3df89feaf152670eb8ef012ad5eaccef1d..b778245a7be363a9923b55ad26ff37cc67cb8431 100644 (file)
@@ -2387,7 +2387,7 @@ Each input key receives two values in this vector: first the ASCII code,
 and then the scan code.  */)
   (void)
 {
-  Lisp_Object val, *keys = XVECTOR (recent_doskeys)->u.contents;
+  Lisp_Object val, *keys = XVECTOR (recent_doskeys)->contents;
 
   if (total_doskeys < NUM_RECENT_DOSKEYS)
     return Fvector (total_doskeys, keys);
index 011edf38cef117e180dd396b3e10ee6d291183eb..ee6020f2b436e354afc03db6d1f45896833a82ca 100644 (file)
@@ -403,23 +403,23 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
       if (!NILP (f->title))
         arg = f->title;
       else
-        /* explicit name and no icon-name -> explicit_name */
+        /* Explicit name and no icon-name -> explicit_name.  */
         if (f->explicit_name)
           arg = f->name;
         else
           {
-            /* no explicit name and no icon-name ->
-               name has to be rebuild from icon_title_format */
-            windows_or_buffers_changed++;
+            /* No explicit name and no icon-name ->
+               name has to be rebuild from icon_title_format */
+            windows_or_buffers_changed = 62;
             return;
           }
     }
 
   /* Don't change the name if it's already NAME.  */
-  if ([[view window] miniwindowTitle] &&
-      ([[[view window] miniwindowTitle]
+  if ([[view window] miniwindowTitle]
+      && ([[[view window] miniwindowTitle]
              isEqualToString: [NSString stringWithUTF8String:
-                                           SSDATA (arg)]]))
+                                         SSDATA (arg)]]))
     return;
 
   [[view window] setMiniwindowTitle:
@@ -451,8 +451,8 @@ ns_set_name_internal (struct frame *f, Lisp_Object name)
 
   str = [NSString stringWithUTF8String: SSDATA (encoded_icon_name)];
 
-  if ([[view window] miniwindowTitle] &&
-      ! [[[view window] miniwindowTitle] isEqualToString: str])
+  if ([[view window] miniwindowTitle]
+      && ! [[[view window] miniwindowTitle] isEqualToString: str])
     [[view window] setMiniwindowTitle: str];
 
 }
@@ -469,7 +469,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit)
       /* If we're switching from explicit to implicit, we had better
          update the mode lines and thereby update the title.  */
       if (f->explicit_name && NILP (name))
-        update_mode_lines = 1;
+        update_mode_lines = 21;
 
       f->explicit_name = ! NILP (name);
     }
@@ -477,7 +477,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit)
     return;
 
   if (NILP (name))
-    name = build_string([ns_app_name UTF8String]);
+    name = build_string ([ns_app_name UTF8String]);
   else
     CHECK_STRING (name);
 
@@ -487,7 +487,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit)
 
   fset_name (f, name);
 
-  /* title overrides explicit name */
+  /* Title overrides explicit name.  */
   if (! NILP (f->title))
     name = f->title;
 
@@ -534,7 +534,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
   if (EQ (name, f->title))
     return;
 
-  update_mode_lines = 1;
+  update_mode_lines = 22;
 
   fset_title (f, name);
 
@@ -1194,6 +1194,7 @@ This function is an internal primitive--use `make-frame' instead.  */)
     x_default_parameter (f, parms, Qfont,
                                  build_string (fontname),
                                  "font", "Font", RES_TYPE_STRING);
+    xfree (fontname);
   }
   unblock_input ();
 
@@ -2357,28 +2358,86 @@ each physical monitor, use `display-monitor-attributes-list'.  */)
 }
 
 #ifdef NS_IMPL_COCOA
-/* Returns the name for the screen that DICT came from, or NULL.
+
+/* Returns the name for the screen that OBJ represents, or NULL.
    Caller must free return value.
 */
 
 static char *
-ns_screen_name (CGDirectDisplayID did)
+ns_get_name_from_ioreg (io_object_t obj)
 {
   char *name = NULL;
+
   NSDictionary *info = (NSDictionary *)
-    IODisplayCreateInfoDictionary (CGDisplayIOServicePort (did),
-                                   kIODisplayOnlyPreferredName);
-  NSDictionary *names
-    = [info objectForKey:
-              [NSString stringWithUTF8String:kDisplayProductName]];
-
-  if ([names count] > 0) {
-    NSString *n = [names objectForKey: [[names allKeys] objectAtIndex:0]];
-    if (n != nil)
-      name = xstrdup ([n UTF8String]);
-  }
+    IODisplayCreateInfoDictionary (obj, kIODisplayOnlyPreferredName);
+  NSDictionary *names = [info objectForKey:
+                                [NSString stringWithUTF8String:
+                                            kDisplayProductName]];
+
+  if ([names count] > 0)
+    {
+      NSString *n = [names objectForKey: [[names allKeys]
+                                                 objectAtIndex:0]];
+      if (n != nil) name = xstrdup ([n UTF8String]);
+    }
 
   [info release];
+
+  return name;
+}
+
+/* Returns the name for the screen that DID came from, or NULL.
+   Caller must free return value.
+*/
+
+static char *
+ns_screen_name (CGDirectDisplayID did)
+{
+  char *name = NULL;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+  mach_port_t masterPort;
+  io_iterator_t it;
+  io_object_t obj;
+
+  // CGDisplayIOServicePort is deprecated.  Do it another (harder) way.
+
+  if (IOMasterPort (MACH_PORT_NULL, &masterPort) != kIOReturnSuccess
+      || IOServiceGetMatchingServices (masterPort,
+                                       IOServiceMatching ("IONDRVDevice"),
+                                       &it) != kIOReturnSuccess)
+    return name;
+
+  /* Must loop until we find a name.  Many devices can have the same unit
+     number (represents different GPU parts), but only one has a name.  */
+  while (! name && (obj = IOIteratorNext (it)))
+    {
+      CFMutableDictionaryRef props;
+      const void *val;
+
+      if (IORegistryEntryCreateCFProperties (obj,
+                                             &props,
+                                             kCFAllocatorDefault,
+                                             kNilOptions) == kIOReturnSuccess
+          && props != nil
+          && (val = CFDictionaryGetValue(props, @"IOFBDependentIndex")))
+        {
+          unsigned nr = [(NSNumber *)val unsignedIntegerValue];
+          if (nr == CGDisplayUnitNumber (did))
+            name = ns_get_name_from_ioreg (obj);
+        }
+
+      CFRelease (props);
+      IOObjectRelease (obj);
+    }
+
+  IOObjectRelease (it);
+
+#else
+
+  name = ns_get_name_from_ioreg (CGDisplayIOServicePort (did));
+
+#endif
   return name;
 }
 #endif
index bd9a2acc983eac2881dbd4c872be2115056c28db..58663804a2fe6a8aed58bfaf9ff08865e9adb8ac 100644 (file)
@@ -624,7 +624,7 @@ static Lisp_Object nsfont_match (struct frame *, Lisp_Object);
 static Lisp_Object nsfont_list_family (struct frame *);
 static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
                                  int pixel_size);
-static void nsfont_close (struct frame *f, struct font *font);
+static void nsfont_close (struct font *font);
 static int nsfont_has_char (Lisp_Object entity, int c);
 static unsigned int nsfont_encode_char (struct font *font, int c);
 static int nsfont_text_extents (struct font *font, unsigned int *code,
@@ -929,29 +929,30 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
 }
 
 
-/* Close FONT on frame F. */
+/* Close FONT. */
 static void
-nsfont_close (struct frame *f, struct font *font)
+nsfont_close (struct font *font)
 {
-  struct nsfont_info *font_info = (struct nsfont_info *)font;
-  int i;
-
-  /* FIXME: this occurs apparently due to same failure to detect same font
-            that causes need for cache in nsfont_open () */
-  if (!font_info)
-      return;
+  struct nsfont_info *font_info = (struct nsfont_info *) font;
 
-  for (i =0; i<0x100; i++)
+  /* FIXME: font_info may be NULL due to same failure to detect
+     same font that causes need for cache in nsfont_open.  */
+  if (font_info && font_info->name)
     {
-      xfree (font_info->glyphs[i]);
-      xfree (font_info->metrics[i]);
-    }
-  [font_info->nsfont release];
+      int i;
+
+      for (i = 0; i < 0x100; i++)
+       {
+         xfree (font_info->glyphs[i]);
+         xfree (font_info->metrics[i]);
+       }
+      [font_info->nsfont release];
 #ifdef NS_IMPL_COCOA
-  CGFontRelease (font_info->cgfont);
+      CGFontRelease (font_info->cgfont);
 #endif
-  xfree (font_info->name);
-  xfree (font_info);
+      xfree (font_info->name);
+      font_info->name = NULL;
+    }
 }
 
 
index 71faa075f325e074c2125c8020ef12f2ffb73b8a..22a8aec943669da4968670b481a2438593a75553 100644 (file)
@@ -85,6 +85,10 @@ typedef float EmacsCGFloat;
 /* We override sendEvent: as a means to stop/start the event loop */
 @interface EmacsApp : NSApplication
 {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+  BOOL shouldKeepRunning;
+  BOOL isFirst;
+#endif
 #ifdef NS_IMPL_GNUSTEP
 @public
   int nextappdefined;
index 5b2c6a3f6865cc2bfe34236baa574036d7141574..0e7667b6dc653c5b1083ac5d217bee2b76c9b82e 100644 (file)
@@ -173,6 +173,7 @@ Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
 extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft;
 
 static Lisp_Object QUTF8_STRING;
+static Lisp_Object Qcocoa, Qgnustep;
 
 /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold,
    the maximum font size to NOT antialias.  On GNUstep there is currently
@@ -1460,15 +1461,16 @@ ns_get_color (const char *name, NSColor **col)
 /*fprintf (stderr, "ns_get_color: '%s'\n", name); */
   block_input ();
 
-#ifdef NS_IMPL_COCOA
   if ([nsname isEqualToString: @"ns_selection_bg_color"])
     {
+#ifdef NS_IMPL_COCOA
       NSString *defname = [[NSUserDefaults standardUserDefaults]
                             stringForKey: @"AppleHighlightColor"];
-
       if (defname != nil)
         nsname = defname;
-      else if ((new = [NSColor selectedTextBackgroundColor]) != nil)
+      else
+#endif
+      if ((new = [NSColor selectedTextBackgroundColor]) != nil)
         {
           *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
           unblock_input ();
@@ -1494,7 +1496,6 @@ ns_get_color (const char *name, NSColor **col)
       nsname = NS_SELECTION_FG_COLOR_DEFAULT;
       name = [nsname UTF8String];
     }
-#endif // NS_IMPL_COCOA
 
   /* First, check for some sort of numeric specification. */
   hex[0] = '\0';
@@ -4366,6 +4367,46 @@ ns_term_shutdown (int sig)
 
 @implementation EmacsApp
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+- (id)init
+{
+  if (self = [super init])
+    self->isFirst = YES;
+
+  return self;
+}
+
+- (void)run
+{
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    if (isFirst) [self finishLaunching];
+    isFirst = NO;
+
+    shouldKeepRunning = YES;
+    do
+    {
+        [pool release];
+        pool = [[NSAutoreleasePool alloc] init];
+
+        NSEvent *event =
+          [self nextEventMatchingMask:NSAnyEventMask
+                            untilDate:[NSDate distantFuture]
+                               inMode:NSDefaultRunLoopMode
+                              dequeue:YES];
+        [self sendEvent:event];
+        [self updateWindows];
+    } while (shouldKeepRunning);
+
+    [pool release];
+}
+
+- (void)stop: (id)sender
+{
+    shouldKeepRunning = NO;
+}
+#endif
+
 - (void)logNotification: (NSNotification *)notification
 {
   const char *name = [[notification name] UTF8String];
@@ -6048,7 +6089,7 @@ if (cols > 0 && rows > 0)
 
   SET_FRAME_ICONIFIED (emacsframe, 0);
   SET_FRAME_VISIBLE (emacsframe, 1);
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 63;
 
   if (emacs_event)
     {
@@ -7501,11 +7542,17 @@ baseline level.  The default value is nil.  */);
   /* Tell Emacs about this window system.  */
   Fprovide (Qns, Qnil);
 
+  DEFSYM (Qcocoa, "cocoa");
+  DEFSYM (Qgnustep, "gnustep");
+
   syms_of_nsfont ();
 #ifdef NS_IMPL_COCOA
+  Fprovide (Qcocoa, Qnil);
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
   syms_of_macfont ();
 #endif
+#else
+  Fprovide (Qgnustep, Qnil);
 #endif
   
 }
index 965d719f852c022a62c8feb7bc0111366e3c9c5e..e3c56a6de62f466d5056b7385fc8d20eb21922c2 100644 (file)
@@ -1705,8 +1705,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
          unsigned char c;
          struct gcpro gcpro1;
          EMACS_INT size = bool_vector_size (obj);
-         ptrdiff_t size_in_chars = ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
-                                    / BOOL_VECTOR_BITS_PER_CHAR);
+         ptrdiff_t size_in_chars = bool_vector_bytes (size);
          ptrdiff_t real_size_in_chars = size_in_chars;
          GCPRO1 (obj);
 
@@ -1726,7 +1725,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
          for (i = 0; i < size_in_chars; i++)
            {
              QUIT;
-             c = XBOOL_VECTOR (obj)->data[i];
+             c = bool_vector_uchar_data (obj)[i];
              if (c == '\n' && print_escape_newlines)
                {
                  PRINTCHAR ('\\');
index 91bc090e76ee491dea9a07888bbff945ead4c3f1..307eab3ab3030500f9607de21685ff4a0c31b877 100644 (file)
@@ -1333,15 +1333,15 @@ Returns nil if format of ADDRESS is invalid.  */)
 
       for (i = 0; i < nargs; i++)
        {
-         if (! RANGED_INTEGERP (0, p->u.contents[i], 65535))
+         if (! RANGED_INTEGERP (0, p->contents[i], 65535))
            return Qnil;
 
          if (nargs <= 5         /* IPv4 */
              && i < 4           /* host, not port */
-             && XINT (p->u.contents[i]) > 255)
+             && XINT (p->contents[i]) > 255)
            return Qnil;
 
-         args[i+1] = p->u.contents[i];
+         args[i+1] = p->contents[i];
        }
 
       return Fformat (nargs+1, args);
@@ -1983,7 +1983,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
        len = sizeof (sin->sin_addr) + 1;
        address = Fmake_vector (make_number (len), Qnil);
        p = XVECTOR (address);
-       p->u.contents[--len] = make_number (ntohs (sin->sin_port));
+       p->contents[--len] = make_number (ntohs (sin->sin_port));
        cp = (unsigned char *) &sin->sin_addr;
        break;
       }
@@ -1995,9 +1995,9 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
        len = sizeof (sin6->sin6_addr)/2 + 1;
        address = Fmake_vector (make_number (len), Qnil);
        p = XVECTOR (address);
-       p->u.contents[--len] = make_number (ntohs (sin6->sin6_port));
+       p->contents[--len] = make_number (ntohs (sin6->sin6_port));
        for (i = 0; i < len; i++)
-         p->u.contents[i] = make_number (ntohs (ip6[i]));
+         p->contents[i] = make_number (ntohs (ip6[i]));
        return address;
       }
 #endif
@@ -2022,7 +2022,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
 
   i = 0;
   while (i < len)
-    p->u.contents[i++] = make_number (*cp++);
+    p->contents[i++] = make_number (*cp++);
 
   return address;
 }
@@ -2093,7 +2093,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
        {
          struct sockaddr_in *sin = (struct sockaddr_in *) sa;
          len = sizeof (sin->sin_addr) + 1;
-         hostport = XINT (p->u.contents[--len]);
+         hostport = XINT (p->contents[--len]);
          sin->sin_port = htons (hostport);
          cp = (unsigned char *)&sin->sin_addr;
          sa->sa_family = family;
@@ -2104,12 +2104,12 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
          struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa;
          uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr;
          len = sizeof (sin6->sin6_addr) + 1;
-         hostport = XINT (p->u.contents[--len]);
+         hostport = XINT (p->contents[--len]);
          sin6->sin6_port = htons (hostport);
          for (i = 0; i < len; i++)
-           if (INTEGERP (p->u.contents[i]))
+           if (INTEGERP (p->contents[i]))
              {
-               int j = XFASTINT (p->u.contents[i]) & 0xffff;
+               int j = XFASTINT (p->contents[i]) & 0xffff;
                ip6[i] = ntohs (j);
              }
          sa->sa_family = family;
@@ -2140,8 +2140,8 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int
     }
 
   for (i = 0; i < len; i++)
-    if (INTEGERP (p->u.contents[i]))
-      *cp++ = XFASTINT (p->u.contents[i]) & 0xff;
+    if (INTEGERP (p->contents[i]))
+      *cp++ = XFASTINT (p->contents[i]) & 0xff;
 }
 
 #ifdef DATAGRAM_SOCKETS
@@ -3723,7 +3723,9 @@ network_interface_info (Lisp_Object ifname)
 
       any = 1;
       for (n = 0; n < 6; n++)
-       p->u.contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]);
+       p->contents[n] = make_number (((unsigned char *)
+                                      &rq.ifr_hwaddr.sa_data[0])
+                                     [n]);
       elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr);
     }
 #elif defined (HAVE_GETIFADDRS) && defined (LLADDR)
@@ -3746,7 +3748,7 @@ network_interface_info (Lisp_Object ifname)
 
           memcpy (linkaddr, LLADDR (sdl), sdl->sdl_alen);
           for (n = 0; n < 6; n++)
-            p->u.contents[n] = make_number (linkaddr[n]);
+            p->contents[n] = make_number (linkaddr[n]);
 
           elt = Fcons (make_number (it->ifa_addr->sa_family), hwaddr);
           break;
@@ -4607,7 +4609,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                      {
                        struct Lisp_Process *p =
                          XPROCESS (chan_process[channel]);
-                       if (p && p->gnutls_p && p->infd
+                       if (p && p->gnutls_p && p->gnutls_state && p->infd
                            && ((emacs_gnutls_record_check_pending
                                 (p->gnutls_state))
                                > 0))
@@ -4621,6 +4623,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
                {
                  /* Check this specific channel. */
                  if (wait_proc->gnutls_p /* Check for valid process.  */
+                     && wait_proc->gnutls_state
                      /* Do we have pending data?  */
                      && ((emacs_gnutls_record_check_pending
                           (wait_proc->gnutls_state))
@@ -5002,7 +5005,7 @@ read_process_output (Lisp_Object proc, register int channel)
          proc_buffered_char[channel] = -1;
        }
 #ifdef HAVE_GNUTLS
-      if (p->gnutls_p)
+      if (p->gnutls_p && p->gnutls_state)
        nbytes = emacs_gnutls_read (p, chars + carryover + buffered,
                                    readmax - buffered);
       else
@@ -5243,7 +5246,7 @@ DEFUN ("internal-default-process-filter", Finternal_default_process_filter,
       else
        set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
 
-      update_mode_lines++;
+      update_mode_lines = 23;
 
       /* Make sure opoint and the old restrictions
         float ahead of any new text just as point would.  */
@@ -5496,7 +5499,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
 #endif
            {
 #ifdef HAVE_GNUTLS
-             if (p->gnutls_p)
+             if (p->gnutls_p && p->gnutls_state)
                written = emacs_gnutls_write (p, cur_buf, cur_len);
              else
 #endif
@@ -6387,7 +6390,7 @@ status_notify (struct Lisp_Process *deleting_process)
        }
     } /* end for */
 
-  update_mode_lines++;  /* In case buffers use %s in mode-line-format.  */
+  update_mode_lines = 24;  /* In case buffers use %s in mode-line-format.  */
   UNGCPRO;
 }
 
index 4ab98bbf0984435adba01eda7c21a25addb13792..615fb3fdf3484035117071767bcffcac4bb06550 100644 (file)
@@ -43,7 +43,7 @@
 # endif
 #endif
 
-#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__) && ! defined __clang__
+#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) && ! defined __clang__
 # pragma GCC diagnostic ignored "-Wunused-but-set-variable"
 #endif
 
index bb737df52394ba01557b944d79d48d556a40d708..8f5bb56fbd143e628d96aca5bfd8506974c25388 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
    The bits are given in alphabetical order, and
    the definitions shifted by one from the previous bit; thus, when we
    add or remove a bit, only one other definition need change.  */
-typedef unsigned long int reg_syntax_t;
+typedef unsigned long reg_syntax_t;
 
 /* If this bit is not set, then \ inside a bracket expression is literal.
    If set, then such a \ quotes the following character.  */
index 99e8d2501feb8bf50154bda4a3e1b731eb1ca926..c9e27627cd173690aadbcf3fc869084267d35cee 100644 (file)
@@ -720,42 +720,45 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
 
         {
           /* The termination address of the dumb loop.  */
-          register unsigned char *ceiling_addr
-           = BYTE_POS_ADDR (ceiling_byte) + 1;
-          register unsigned char *cursor
-           = BYTE_POS_ADDR (start_byte);
-          unsigned char *base = cursor;
+         unsigned char *lim_addr = BYTE_POS_ADDR (ceiling_byte) + 1;
+         ptrdiff_t lim_byte = ceiling_byte + 1;
 
-          while (cursor < ceiling_addr)
-            {
+         /* Nonpositive offsets (relative to LIM_ADDR and LIM_BYTE)
+            of the base, the cursor, and the next line.  */
+         ptrdiff_t base = start_byte - lim_byte;
+         ptrdiff_t cursor, next;
+
+         for (cursor = base; cursor < 0; cursor = next)
+           {
               /* The dumb loop.  */
-             unsigned char *nl = memchr (cursor, '\n', ceiling_addr - cursor);
+             unsigned char *nl = memchr (lim_addr + cursor, '\n', - cursor);
+             next = nl ? nl - lim_addr : 0;
 
               /* If we're looking for newlines, cache the fact that
-                 the region from start to cursor is free of them. */
+                 this line's region is free of them. */
               if (newline_cache)
                {
-                 unsigned char *low = cursor;
-                 unsigned char *lim = nl ? nl : ceiling_addr;
                  know_region_cache (current_buffer, newline_cache,
-                                    BYTE_TO_CHAR (low - base + start_byte),
-                                    BYTE_TO_CHAR (lim - base + start_byte));
+                                    BYTE_TO_CHAR (lim_byte + cursor),
+                                    BYTE_TO_CHAR (lim_byte + next));
+                 /* know_region_cache can relocate buffer text.  */
+                 lim_addr = BYTE_POS_ADDR (ceiling_byte) + 1;
                }
 
               if (! nl)
                break;
+             next++;
 
              if (--count == 0)
                {
                  immediate_quit = 0;
                  if (bytepos)
-                   *bytepos = nl + 1 - base + start_byte;
-                 return BYTE_TO_CHAR (nl + 1 - base + start_byte);
+                   *bytepos = lim_byte + next;
+                 return BYTE_TO_CHAR (lim_byte + next);
                }
-             cursor = nl + 1;
             }
 
-         start_byte += ceiling_addr - base;
+         start_byte = lim_byte;
          start = BYTE_TO_CHAR (start_byte);
         }
       }
@@ -794,24 +797,28 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
 
         {
           /* The termination address of the dumb loop.  */
-          register unsigned char *ceiling_addr = BYTE_POS_ADDR (ceiling_byte);
-          register unsigned char *cursor = BYTE_POS_ADDR (start_byte - 1);
-          unsigned char *base = cursor;
+         unsigned char *ceiling_addr = BYTE_POS_ADDR (ceiling_byte);
+
+         /* Offsets (relative to CEILING_ADDR and CEILING_BYTE) of
+            the base, the cursor, and the previous line.  These
+            offsets are at least -1.  */
+         ptrdiff_t base = start_byte - ceiling_byte;
+         ptrdiff_t cursor, prev;
 
-          while (cursor >= ceiling_addr)
+         for (cursor = base; 0 < cursor; cursor = prev)
             {
-             unsigned char *nl = memrchr (ceiling_addr, '\n',
-                                          cursor + 1 - ceiling_addr);
+             unsigned char *nl = memrchr (ceiling_addr, '\n', cursor);
+             prev = nl ? nl - ceiling_addr : -1;
 
               /* If we're looking for newlines, cache the fact that
-                 the region from after the cursor to start is free of them.  */
+                 this line's region is free of them. */
               if (newline_cache)
                {
-                 unsigned char *low = nl ? nl : ceiling_addr - 1;
-                 unsigned char *lim = cursor;
                  know_region_cache (current_buffer, newline_cache,
-                                    BYTE_TO_CHAR (low - base + start_byte),
-                                    BYTE_TO_CHAR (lim - base + start_byte));
+                                    BYTE_TO_CHAR (ceiling_byte + prev + 1),
+                                    BYTE_TO_CHAR (ceiling_byte + cursor));
+                 /* know_region_cache can relocate buffer text.  */
+                 ceiling_addr = BYTE_POS_ADDR (ceiling_byte);
                }
 
               if (! nl)
@@ -821,13 +828,12 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
                {
                  immediate_quit = 0;
                  if (bytepos)
-                   *bytepos = nl - base + start_byte;
-                 return BYTE_TO_CHAR (nl - base + start_byte);
+                   *bytepos = ceiling_byte + prev + 1;
+                 return BYTE_TO_CHAR (ceiling_byte + prev + 1);
                }
-             cursor = nl - 1;
             }
 
-         start_byte += ceiling_addr - 1 - base;
+         start_byte = ceiling_byte;
          start = BYTE_TO_CHAR (start_byte);
         }
       }
index b4c2e2560cc73f1a48493b446fa206d24e6f937c..f86d71ac2f4e1081d03f98e6e99003e189cbf6b8 100644 (file)
@@ -1892,55 +1892,18 @@ static void
 turn_on_face (struct frame *f, int face_id)
 {
   struct face *face = FACE_FROM_ID (f, face_id);
-  long fg = face->foreground;
-  long bg = face->background;
+  unsigned long fg = face->foreground;
+  unsigned long bg = face->background;
   struct tty_display_info *tty = FRAME_TTY (f);
 
-  /* Do this first because TS_end_standout_mode may be the same
+  /* Use reverse video if the face specifies that.
+     Do this first because TS_end_standout_mode may be the same
      as TS_exit_attribute_mode, which turns all appearances off. */
-  if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE))
-    {
-      if (tty->TN_max_colors > 0)
-       {
-         if (fg >= 0 && bg >= 0)
-           {
-             /* If the terminal supports colors, we can set them
-                below without using reverse video.  The face's fg
-                and bg colors are set as they should appear on
-                the screen, i.e. they take the inverse-video'ness
-                of the face already into account.  */
-           }
-         else if (inverse_video)
-           {
-             if (fg == FACE_TTY_DEFAULT_FG_COLOR
-                 || bg == FACE_TTY_DEFAULT_BG_COLOR)
-               tty_toggle_highlight (tty);
-           }
-         else
-           {
-             if (fg == FACE_TTY_DEFAULT_BG_COLOR
-                 || bg == FACE_TTY_DEFAULT_FG_COLOR)
-               tty_toggle_highlight (tty);
-           }
-       }
-      else
-       {
-         /* If we can't display colors, use reverse video
-            if the face specifies that.  */
-         if (inverse_video)
-           {
-             if (fg == FACE_TTY_DEFAULT_FG_COLOR
-                 || bg == FACE_TTY_DEFAULT_BG_COLOR)
-               tty_toggle_highlight (tty);
-           }
-         else
-           {
-             if (fg == FACE_TTY_DEFAULT_BG_COLOR
-                 || bg == FACE_TTY_DEFAULT_FG_COLOR)
-               tty_toggle_highlight (tty);
-           }
-       }
-    }
+  if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE)
+      && (inverse_video
+         ? fg == FACE_TTY_DEFAULT_FG_COLOR || bg == FACE_TTY_DEFAULT_BG_COLOR
+         : fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR))
+    tty_toggle_highlight (tty);
 
   if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
     OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
@@ -1965,7 +1928,7 @@ turn_on_face (struct frame *f, int face_id)
       char *p;
 
       ts = tty->standout_mode ? tty->TS_set_background : tty->TS_set_foreground;
-      if (fg >= 0 && ts)
+      if (face_tty_specified_color (fg) && ts)
        {
           p = tparam (ts, NULL, 0, fg, 0, 0, 0);
          OUTPUT (tty, p);
@@ -1973,7 +1936,7 @@ turn_on_face (struct frame *f, int face_id)
        }
 
       ts = tty->standout_mode ? tty->TS_set_foreground : tty->TS_set_background;
-      if (bg >= 0 && ts)
+      if (face_tty_specified_color (bg) && ts)
        {
           p = tparam (ts, NULL, 0, bg, 0, 0, 0);
          OUTPUT (tty, p);
@@ -2027,12 +1990,10 @@ turn_off_face (struct frame *f, int face_id)
 
 
 /* Return true if the terminal on frame F supports all of the
-   capabilities in CAPS simultaneously, with foreground and background
-   colors FG and BG.  */
+   capabilities in CAPS simultaneously.  */
 
 bool
-tty_capable_p (struct tty_display_info *tty, unsigned int caps,
-              unsigned long fg, unsigned long bg)
+tty_capable_p (struct tty_display_info *tty, unsigned int caps)
 {
 #define TTY_CAPABLE_P_TRY(tty, cap, TS, NC_bit)                                \
   if ((caps & (cap)) && (!(TS) || !MAY_USE_WITH_COLORS_P(tty, NC_bit)))        \
@@ -2867,7 +2828,8 @@ tty_menu_search_pane (tty_menu *menu, int pane)
       {
        if (pane == menu->panenumber[i])
          return menu->submenu[i];
-       if ((try = tty_menu_search_pane (menu->submenu[i], pane)))
+       try = tty_menu_search_pane (menu->submenu[i], pane);
+       if (try)
          return try;
       }
   return (tty_menu *) 0;
@@ -2920,7 +2882,7 @@ mouse_get_xy (int *x, int *y)
 
 static void
 tty_menu_display (tty_menu *menu, int x, int y, int pn, int *faces,
-                 int mx, int my, int first_item, int disp_help)
+                 int mx, int my, int first_item, bool disp_help)
 {
   int i, face, width, enabled, mousehere, row, col;
   struct frame *sf = SELECTED_FRAME ();
@@ -2997,16 +2959,19 @@ tty_menu_add_pane (tty_menu *menu, const char *txt)
 
 /* Create a new item in a menu pane.  */
 
-static int
+static bool
 tty_menu_add_selection (tty_menu *menu, int pane,
-                       char *txt, int enable, char const *help_text)
+                       char *txt, bool enable, char const *help_text)
 {
   int len;
   unsigned char *p;
 
   if (pane)
-    if (!(menu = tty_menu_search_pane (menu, pane)))
-      return TTYM_FAILURE;
+    {
+      menu = tty_menu_search_pane (menu, pane);
+      if (! menu)
+       return 0;
+    }
   tty_menu_make_room (menu);
   menu->submenu[menu->count] = (tty_menu *) 0;
   menu->text[menu->count] = txt;
@@ -3027,7 +2992,7 @@ tty_menu_add_selection (tty_menu *menu, int pane,
   if (len > menu->width)
     menu->width = len;
 
-  return TTYM_SUCCESS;
+  return 1;
 }
 
 /* Decide where the menu would be placed if requested at (X,Y).  */
@@ -3155,7 +3120,7 @@ read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y,
   else
     {
       Lisp_Object cmd;
-      int usable_input = 1;
+      bool usable_input = 1;
       mi_result st = MI_CONTINUE;
       struct tty_display_info *tty = FRAME_TTY (sf);
       Lisp_Object saved_mouse_tracking = do_mouse_tracking;
@@ -3215,10 +3180,11 @@ static int
 tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
                   int x0, int y0, char **txt,
                   void (*help_callback)(char const *, int, int),
-                  int kbd_navigation)
+                  bool kbd_navigation)
 {
   struct tty_menu_state *state;
-  int statecount, x, y, i, leave, onepane;
+  int statecount, x, y, i;
+  bool leave, onepane;
   int result IF_LINT (= 0);
   int title_faces[4];          /* face to display the menu title */
   int faces[4], buffers_num_deleted = 0;
@@ -3285,7 +3251,8 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx,
   tty_hide_cursor (tty);
   if (buffers_num_deleted)
     menu->text[0][7] = ' ';
-  if ((onepane = menu->count == 1 && menu->submenu[0]))
+  onepane = menu->count == 1 && menu->submenu[0];
+  if (onepane)
     {
       menu->width = menu->submenu[0]->width;
       state[0].menu = menu->submenu[0];
@@ -3478,7 +3445,7 @@ tty_menu_help_callback (char const *help_string, int pane, int item)
   Lisp_Object pane_name;
   Lisp_Object menu_object;
 
-  first_item = XVECTOR (menu_items)->u.contents;
+  first_item = XVECTOR (menu_items)->contents;
   if (EQ (first_item[0], Qt))
     pane_name = first_item[MENU_ITEMS_PANE_NAME];
   else if (EQ (first_item[0], Qquote))
@@ -3585,8 +3552,8 @@ tty_menu_new_item_coords (struct frame *f, int which, int *x, int *y)
 }
 
 Lisp_Object
-tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
-              Lisp_Object title, int kbd_navigation, const char **error_name)
+tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps,
+              Lisp_Object title, bool kbd_navigation, const char **error_name)
 {
   tty_menu *menu;
   int pane, selidx, lpane, status;
@@ -3709,9 +3676,8 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps,
            item_data = SSDATA (item_name);
 
          if (lpane == TTYM_FAILURE
-             || (tty_menu_add_selection (menu, lpane, item_data,
-                                         !NILP (enable), help_string)
-                 == TTYM_FAILURE))
+             || (! tty_menu_add_selection (menu, lpane, item_data,
+                                           !NILP (enable), help_string)))
            {
              tty_menu_destroy (menu);
              *error_name = "Can't add selection to menu";
index 8968147ac0646cac4f295c2eff2d2c84df66f209..64fdd47a86a54d89d70cd2bc8bf8c8e68e03f11d 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -8049,7 +8049,7 @@ network_interface_get_info (Lisp_Object ifname)
 
              /* Hardware address and its family.  */
              for (n = 0; n < adapter->AddressLength; n++)
-               p->u.contents[n] = make_number ((int) adapter->Address[n]);
+               p->contents[n] = make_number ((int) adapter->Address[n]);
              /* Windows does not support AF_LINK or AF_PACKET family
                 of addresses.  Use an arbitrary family number that is
                 identical to what GNU/Linux returns.  */
index 3e60d68023bfe3ba6e9c299fb2c06bfc535fb4a3..eb77980af79491e1c3ca53c1438d9d9f8e8af3bc 100644 (file)
@@ -1664,7 +1664,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
     nlines = 0;
 
   /* Make sure we redisplay all windows in this frame.  */
-  ++windows_or_buffers_changed;
+  windows_or_buffers_changed = 23;
 
   delta = nlines - FRAME_TOOL_BAR_LINES (f);
 
@@ -1740,7 +1740,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
       /* If we're switching from explicit to implicit, we had better
         update the mode lines and thereby update the title.  */
       if (f->explicit_name && NILP (name))
-       update_mode_lines = 1;
+       update_mode_lines = 25;
 
       f->explicit_name = ! NILP (name);
     }
@@ -1808,7 +1808,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
   if (EQ (name, f->title))
     return;
 
-  update_mode_lines = 1;
+  update_mode_lines = 26;
 
   fset_title (f, name);
 
index 845df68f09db34612e859229097c79ecac512535..effedfc04e12b774e1b18725406b2bbc9bb5059c 100644 (file)
@@ -376,26 +376,28 @@ w32font_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
   return font_object;
 }
 
-/* w32 implementation of close for font_backend.
-   Close FONT on frame F.  */
+/* w32 implementation of close for font_backend.  */
 void
-w32font_close (struct frame *f, struct font *font)
+w32font_close (struct font *font)
 {
-  int i;
   struct w32font_info *w32_font = (struct w32font_info *) font;
 
-  /* Delete the GDI font object.  */
-  DeleteObject (w32_font->hfont);
-
-  /* Free all the cached metrics.  */
-  if (w32_font->cached_metrics)
+  if (w32_font->hfont)
     {
-      for (i = 0; i < w32_font->n_cache_blocks; i++)
-        {
-          xfree (w32_font->cached_metrics[i]);
-        }
-      xfree (w32_font->cached_metrics);
-      w32_font->cached_metrics = NULL;
+      /* Delete the GDI font object.  */
+      DeleteObject (w32_font->hfont);
+      w32_font->hfont = NULL;
+
+      /* Free all the cached metrics.  */
+      if (w32_font->cached_metrics)
+       {
+         int i;
+
+         for (i = 0; i < w32_font->n_cache_blocks; i++)
+             xfree (w32_font->cached_metrics[i]);
+         xfree (w32_font->cached_metrics);
+         w32_font->cached_metrics = NULL;
+       }
     }
 }
 
index 5622086086395056dfc58e4ff03540ac0236da96..1991492628c0475bf043a7e31b4f5028ea5761b0 100644 (file)
@@ -72,7 +72,7 @@ Lisp_Object w32font_match_internal (struct frame *f,
                                     int opentype_only);
 int w32font_open_internal (struct frame *f, Lisp_Object font_entity,
                            int pixel_size, Lisp_Object font_object);
-void w32font_close (struct frame *f, struct font *font);
+void w32font_close (struct font *font);
 int w32font_has_char (Lisp_Object entity, int c);
 int w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
                           struct font_metrics *metrics);
index c5d3fa3ad7df38dd3fa2a02b078131057a2dcfb7..dc587de11832cf67e96b468fa830e32532728a1b 100644 (file)
@@ -518,7 +518,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
                              help_echo_window, help_echo_object,
                              help_echo_pos);
          }
-       /* We alread called kbd_buffer_store_event, so indicate the
+       /* We already called kbd_buffer_store_event, so indicate the
           the caller it shouldn't.  */
        return 0;
       }
index 6ac02d95a634bcf33687a3133b108f14901c2471..b25652017cdff0c7ba25253c333a1bdf53017ed8 100644 (file)
@@ -326,7 +326,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
 
       /* Save the frame's previous menu bar contents data.  */
       if (previous_menu_items_used)
-       memcpy (previous_items, XVECTOR (f->menu_bar_vector)->u.contents,
+       memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
                previous_menu_items_used * word_size);
 
       /* Fill in menu_items with the current menu bar contents.
index 6c94090f3b7096521df14fcb93c5d0fb0f62c5c1..0741761febe7e0e0078a8de95b762826cf7b75c8 100644 (file)
@@ -656,7 +656,13 @@ x_update_window_end (struct window *w, bool cursor_on_p,
   /* If a row with mouse-face was overwritten, arrange for
      XTframe_up_to_date to redisplay the mouse highlight.  */
   if (mouse_face_overwritten_p)
-    reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame)));
+    {
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
+
+      hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
+      hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
+      hlinfo->mouse_face_window = Qnil;
+    }
 
   /* Unhide the caret.  This won't actually show the cursor, unless it
      was visible before the corresponding call to HideCaret in
@@ -1596,10 +1602,7 @@ w32_setup_relief_color (struct frame *f, struct relief *relief, double factor,
   xgcv.foreground = default_pixel;
   pixel = background;
   if (w32_alloc_lighter_color (f, &pixel, factor, delta))
-    {
-      relief->allocated_p = 1;
-      xgcv.foreground = relief->pixel = pixel;
-    }
+    xgcv.foreground = relief->pixel = pixel;
 
   if (relief->gc == 0)
     {
@@ -6001,17 +6004,6 @@ x_free_frame_resources (struct frame *f)
 
   free_frame_menubar (f);
 
-  unload_color (f, FRAME_FOREGROUND_PIXEL (f));
-  unload_color (f, FRAME_BACKGROUND_PIXEL (f));
-  unload_color (f, f->output_data.w32->cursor_pixel);
-  unload_color (f, f->output_data.w32->cursor_foreground_pixel);
-  unload_color (f, f->output_data.w32->border_pixel);
-  unload_color (f, f->output_data.w32->mouse_pixel);
-  if (f->output_data.w32->white_relief.allocated_p)
-    unload_color (f, f->output_data.w32->white_relief.pixel);
-  if (f->output_data.w32->black_relief.allocated_p)
-    unload_color (f, f->output_data.w32->black_relief.pixel);
-
   if (FRAME_FACE_CACHE (f))
     free_frame_faces (f);
 
index 956e03d336c3668e809961c6dee8a32384515ac1..b3c0cf56c7b8001b6ee60e58d6fcf95669d3b699 100644 (file)
@@ -376,7 +376,6 @@ struct w32_output
   {
     XGCValues *gc;
     unsigned long pixel;
-    int allocated_p;
   }
   black_relief, white_relief;
 
index b31baa0e65cf0e8370bd66af7c3cbe151a8727ab..fb3fbd0d607452358805fbd1a095326d0ba9fc4c 100644 (file)
@@ -135,7 +135,7 @@ uniscribe_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
 }
 
 static void
-uniscribe_close (struct frame *f, struct font *font)
+uniscribe_close (struct font *font)
 {
   struct uniscribe_font_info *uniscribe_font
     = (struct uniscribe_font_info *) font;
@@ -143,7 +143,7 @@ uniscribe_close (struct frame *f, struct font *font)
   if (uniscribe_font->cache)
     ScriptFreeCache (&(uniscribe_font->cache));
 
-  w32font_close (f, font);
+  w32font_close (font);
 }
 
 /* Return a list describing which scripts/languages FONT supports by
index ecbe5fa5365dd263e4d8ee52bf650c22a67331be..bc0adaf459fa7f012f753572e1277002f2f8a951 100644 (file)
@@ -500,7 +500,7 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap)
 
   select_window_1 (window, inhibit_point_swap);
   bset_last_selected_window (XBUFFER (w->contents), window);
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 24;
 
  record_and_return:
   /* record_buffer can run QUIT, so make sure it is run only after we have
@@ -1553,7 +1553,7 @@ Return POS.  */)
       set_marker_restricted (w->pointm, pos, w->contents);
       /* We have to make sure that redisplay updates the window to show
         the new value of point.  */
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 25;
     }
 
   return pos;
@@ -1576,7 +1576,7 @@ overriding motion of point in order to display at this exact start.  */)
   w->update_mode_line = 1;
   if (w != XWINDOW (selected_window))
     /* Enforce full redisplay.  FIXME: make it more selective.  */
-    windows_or_buffers_changed++;
+    windows_or_buffers_changed = 26;
 
   return pos;
 }
@@ -2639,7 +2639,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame
                mark_window_display_accurate (window, 0);
                w->update_mode_line = 1;
                XBUFFER (obj)->prevent_redisplay_optimizations_p = 1;
-               ++update_mode_lines;
+               update_mode_lines = 27;
                best_window = window;
              }
            break;
@@ -2837,7 +2837,7 @@ window-start value is reasonable when this function is called.  */)
     }
   free_window_matrices (r);
 
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 27;
   Vwindow_list = Qnil;
   FRAME_WINDOW_SIZES_CHANGED (f) = 1;
   resize_failed = 0;
@@ -3171,7 +3171,7 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
     }
   /* Maybe we could move this into the `if' but it's not obviously safe and
      I doubt it's worth the trouble.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 28;
 
   /* We must select BUFFER for running the window-scroll-functions.  */
   /* We can't check ! NILP (Vwindow_scroll_functions) here
@@ -3278,8 +3278,8 @@ displaying that buffer.  */)
 {
   if (NILP (object))
     {
-      windows_or_buffers_changed++;
-      update_mode_lines++;
+      windows_or_buffers_changed = 29;
+      update_mode_lines = 28;
       return Qt;
     }
 
@@ -3290,7 +3290,7 @@ displaying that buffer.  */)
       w->update_mode_line = 1;
       if (BUFFERP (w->contents))
        XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
-      ++update_mode_lines;
+      update_mode_lines = 29;
       return Qt;
     }
 
@@ -3646,7 +3646,7 @@ be applied on the Elisp level.  */)
   block_input ();
   window_resize_apply (r, horflag);
 
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 30;
   FRAME_WINDOW_SIZES_CHANGED (f) = 1;
 
   adjust_frame_glyphs (f);
@@ -3741,7 +3741,7 @@ resize_frame_windows (struct frame *f, int size, bool horflag)
        }
     }
 
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 31;
 }
 
 
@@ -3862,7 +3862,7 @@ set correctly.  See the code of `split-window' for how this is done.  */)
   else
     p = XWINDOW (o->parent);
 
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 32;
   FRAME_WINDOW_SIZES_CHANGED (f) = 1;
   new = make_window ();
   n = XWINDOW (new);
@@ -4012,7 +4012,7 @@ Signal an error when WINDOW is the only window on its frame.  */)
            hlinfo->mouse_face_window = Qnil;
        }
 
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 33;
       Vwindow_list = Qnil;
       FRAME_WINDOW_SIZES_CHANGED (f) = 1;
 
@@ -4134,7 +4134,7 @@ grow_mini_window (struct window *w, int delta)
       w->top_line = r->top_line + r->total_lines;
       w->total_lines -= XINT (value);
       /* Enforce full redisplay.  FIXME: make it more selective.  */
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 34;
       adjust_frame_glyphs (f);
       unblock_input ();
     }
@@ -4168,7 +4168,7 @@ shrink_mini_window (struct window *w)
          w->top_line = r->top_line + r->total_lines;
          w->total_lines = 1;
          /* Enforce full redisplay.  FIXME: make it more selective.  */
-         windows_or_buffers_changed++;
+         windows_or_buffers_changed = 35;
          adjust_frame_glyphs (f);
          unblock_input ();
        }
@@ -4208,7 +4208,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
       w->total_lines = XFASTINT (w->new_total);
       w->top_line = r->top_line + r->total_lines;
 
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 36;
       FRAME_WINDOW_SIZES_CHANGED (f) = 1;
       adjust_frame_glyphs (f);
       unblock_input ();
@@ -4830,7 +4830,7 @@ scroll_command (Lisp_Object n, int direction)
       Fset_buffer (XWINDOW (selected_window)->contents);
 
       /* Make redisplay consider other windows than just selected_window.  */
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 37;
     }
 
   if (NILP (n))
@@ -4940,7 +4940,7 @@ specifies the window to scroll.  This takes precedence over
 
   /* Don't screw up if window_scroll gets an error.  */
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
-  ++windows_or_buffers_changed;
+  windows_or_buffers_changed = 38;
 
   Fset_buffer (w->contents);
   SET_PT_BOTH (marker_position (w->pointm), marker_byte_position (w->pointm));
@@ -5405,7 +5405,7 @@ struct saved_window
 };
 
 #define SAVED_WINDOW_N(swv,n) \
-  ((struct saved_window *) (XVECTOR ((swv)->u.contents[(n)])))
+  ((struct saved_window *) (XVECTOR ((swv)->contents[(n)])))
 
 DEFUN ("window-configuration-p", Fwindow_configuration_p, Swindow_configuration_p, 1, 1, 0,
        doc: /* Return t if OBJECT is a window-configuration object.  */)
@@ -5575,7 +5575,7 @@ the return value is nil.  Otherwise the value is t.  */)
                           BUF_PT_BYTE (XBUFFER (w->contents)));
        }
 
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 39;
       FRAME_WINDOW_SIZES_CHANGED (f) = 1;
 
       /* Problem: Freeing all matrices and later allocating them again
@@ -6103,7 +6103,7 @@ apply_window_adjustment (struct window *w)
   adjust_window_margins (w);
   clear_glyph_matrix (w->current_matrix);
   w->window_end_valid = 0;
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 40;
   adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w)));
 }
 
index cc4332ccf7f5d7763e81726a920c19f11b0f1236..f619b82e8a3d9705325363e5509c190ec38ee01e 100644 (file)
@@ -341,10 +341,6 @@ struct window
        y-direction (smooth scrolling).  */
     int vscroll;
 
-    /* If we have highlighted the region (or any part of it), the mark
-       (region start) position; otherwise zero.  */
-    ptrdiff_t region_showing;
-
     /* Z_BYTE - buffer position of the last glyph in the current matrix of W.
        Should be nonnegative, and only valid if window_end_valid is nonzero.  */
     ptrdiff_t window_end_bytepos;
index 395a74e4122a52c4411ed82cfb000b1892396ba7..47855a1de3c6d3109c50b81396a7a431a8b763e7 100644 (file)
@@ -737,7 +737,7 @@ ptrdiff_t help_echo_pos;
 
 Lisp_Object previous_help_echo_string;
 
-/* Platform-independent portion of hourglass implementation. */
+/* Platform-independent portion of hourglass implementation.  */
 
 #ifdef HAVE_WINDOW_SYSTEM
 
@@ -2601,24 +2601,6 @@ check_window_end (struct window *w)
 
 #endif /* GLYPH_DEBUG and ENABLE_CHECKING */
 
-/* Return mark position if current buffer has the region of non-zero length,
-   or -1 otherwise.  */
-
-static ptrdiff_t
-markpos_of_region (void)
-{
-  if (!NILP (Vtransient_mark_mode)
-      && !NILP (BVAR (current_buffer, mark_active))
-      && XMARKER (BVAR (current_buffer, mark))->buffer != NULL)
-    {
-      ptrdiff_t markpos = XMARKER (BVAR (current_buffer, mark))->charpos;
-
-      if (markpos != PT)
-       return markpos;
-    }
-  return -1;
-}
-
 /***********************************************************************
                       Iterator initialization
  ***********************************************************************/
@@ -2647,7 +2629,6 @@ init_iterator (struct it *it, struct window *w,
               ptrdiff_t charpos, ptrdiff_t bytepos,
               struct glyph_row *row, enum face_id base_face_id)
 {
-  ptrdiff_t markpos;
   enum face_id remapped_base_face_id = base_face_id;
 
   /* Some precondition checks.  */
@@ -2751,28 +2732,6 @@ init_iterator (struct it *it, struct window *w,
   /* Are multibyte characters enabled in current_buffer?  */
   it->multibyte_p = !NILP (BVAR (current_buffer, enable_multibyte_characters));
 
-  /* If visible region is of non-zero length, set IT->region_beg_charpos
-     and IT->region_end_charpos to the start and end of a visible region
-     in window IT->w.  Set both to -1 to indicate no region.  */
-  markpos = markpos_of_region ();
-  if (markpos >= 0
-      /* Maybe highlight only in selected window.  */
-      && (/* Either show region everywhere.  */
-         highlight_nonselected_windows
-         /* Or show region in the selected window.  */
-         || w == XWINDOW (selected_window)
-         /* Or show the region if we are in the mini-buffer and W is
-            the window the mini-buffer refers to.  */
-         || (MINI_WINDOW_P (XWINDOW (selected_window))
-             && WINDOWP (minibuf_selected_window)
-             && w == XWINDOW (minibuf_selected_window))))
-    {
-      it->region_beg_charpos = min (PT, markpos);
-      it->region_end_charpos = max (PT, markpos);
-    }
-  else
-    it->region_beg_charpos = it->region_end_charpos = -1;
-
   /* Get the position at which the redisplay_end_trigger hook should
      be run, if it is to be run at all.  */
   if (MARKERP (w->redisplay_end_trigger)
@@ -3406,16 +3365,6 @@ compute_stop_pos (struct it *it)
       if (pos < it->stop_charpos)
        it->stop_charpos = pos;
 
-      /* If showing the region, we have to stop at the region
-        start or end because the face might change there.  */
-      if (it->region_beg_charpos > 0)
-       {
-         if (IT_CHARPOS (*it) < it->region_beg_charpos)
-           it->stop_charpos = min (it->stop_charpos, it->region_beg_charpos);
-         else if (IT_CHARPOS (*it) < it->region_end_charpos)
-           it->stop_charpos = min (it->stop_charpos, it->region_end_charpos);
-       }
-
       /* Set up variables for computing the stop position from text
          property changes.  */
       XSETBUFFER (object, current_buffer);
@@ -3799,8 +3748,6 @@ handle_face_prop (struct it *it)
       new_face_id
        = face_at_buffer_position (it->w,
                                   IT_CHARPOS (*it),
-                                  it->region_beg_charpos,
-                                  it->region_end_charpos,
                                   &next_stop,
                                   (IT_CHARPOS (*it)
                                    + TEXT_PROP_DISTANCE_LIMIT),
@@ -3877,8 +3824,6 @@ handle_face_prop (struct it *it)
          base_face_id
            = face_for_overlay_string (it->w,
                                       IT_CHARPOS (*it),
-                                      it->region_beg_charpos,
-                                      it->region_end_charpos,
                                       &next_stop,
                                       (IT_CHARPOS (*it)
                                        + TEXT_PROP_DISTANCE_LIMIT),
@@ -3907,8 +3852,6 @@ handle_face_prop (struct it *it)
                                             it->string,
                                             IT_STRING_CHARPOS (*it),
                                             bufpos,
-                                            it->region_beg_charpos,
-                                            it->region_end_charpos,
                                             &next_stop,
                                             base_face_id, 0);
 
@@ -4051,8 +3994,6 @@ face_before_or_after_it_pos (struct it *it, int before_p)
                                         it->string,
                                         charpos,
                                         bufpos,
-                                        it->region_beg_charpos,
-                                        it->region_end_charpos,
                                         &next_check_charpos,
                                         base_face_id, 0);
 
@@ -4142,8 +4083,6 @@ face_before_or_after_it_pos (struct it *it, int before_p)
       /* Determine face for CHARSET_ASCII, or unibyte.  */
       face_id = face_at_buffer_position (it->w,
                                         CHARPOS (pos),
-                                        it->region_beg_charpos,
-                                        it->region_end_charpos,
                                         &next_check_charpos,
                                         limit, 0, -1);
 
@@ -4473,8 +4412,8 @@ setup_for_ellipsis (struct it *it, int len)
   if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
     {
       struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
-      it->dpvec = v->u.contents;
-      it->dpend = v->u.contents + v->header.size;
+      it->dpvec = v->contents;
+      it->dpend = v->contents + v->header.size;
     }
   else
     {
@@ -6441,9 +6380,6 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
                  ptrdiff_t charpos, ptrdiff_t precision, int field_width,
                  int multibyte)
 {
-  /* No region in strings.  */
-  it->region_beg_charpos = it->region_end_charpos = -1;
-
   /* No text property checks performed by default, but see below.  */
   it->stop_charpos = -1;
 
@@ -6618,8 +6554,8 @@ lookup_glyphless_char_display (int c, struct it *it)
       if (c >= 0)
        {
          glyphless_method = CHAR_TABLE_REF (Vglyphless_char_display, c);
-         if (CONSP (glyphless_method))
-           glyphless_method = FRAME_WINDOW_P (it->f)
+      if (CONSP (glyphless_method))
+       glyphless_method = FRAME_WINDOW_P (it->f)
              ? XCAR (glyphless_method)
              : XCDR (glyphless_method);
        }
@@ -6778,8 +6714,8 @@ get_next_display_element (struct it *it)
              if (v->header.size)
                {
                  it->dpvec_char_len = it->len;
-                 it->dpvec = v->u.contents;
-                 it->dpend = v->u.contents + v->header.size;
+                 it->dpvec = v->contents;
+                 it->dpend = v->contents + v->header.size;
                  it->current.dpvec_index = 0;
                  it->dpvec_face_id = -1;
                  it->saved_face_id = it->face_id;
@@ -6823,7 +6759,7 @@ get_next_display_element (struct it *it)
 
             Non-printable characters and raw-byte characters are also
             translated to octal form.  */
-         if (((c < ' ' || c == 127) /* ASCII control chars */
+         if (((c < ' ' || c == 127) /* ASCII control chars */
               ? (it->area != TEXT_AREA
                  /* In mode line, treat \n, \t like other crl chars.  */
                  || (c != '\t'
@@ -7033,8 +6969,7 @@ get_next_display_element (struct it *it)
                  INC_TEXT_POS (pos, it->multibyte_p);
 
                  next_face_id = face_at_buffer_position
-                   (it->w, CHARPOS (pos), it->region_beg_charpos,
-                    it->region_end_charpos, &ignore,
+                   (it->w, CHARPOS (pos), &ignore,
                     (IT_CHARPOS (*it) + TEXT_PROP_DISTANCE_LIMIT), 0,
                     -1);
                  it->end_of_box_run_p
@@ -9337,7 +9272,7 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos)
 
   /* The commented-out optimization uses vmotion on terminals.  This
      gives bad results, because elements like it->what, on which
-     callers such as pos_visible_p rely, aren't updated. */
+     callers such as pos_visible_p rely, aren't updated.  */
   /* struct position pos;
     if (!FRAME_WINDOW_P (it->f))
     {
@@ -9355,7 +9290,7 @@ move_it_by_lines (struct it *it, ptrdiff_t dvpos)
     {
       /* DVPOS == 0 means move to the start of the screen line.  */
       move_it_vertically_backward (it, 0);
-      /* Let next call to line_bottom_y calculate real line height */
+      /* Let next call to line_bottom_y calculate real line height */
       last_height = 0;
     }
   else if (dvpos > 0)
@@ -9553,6 +9488,7 @@ message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte)
       }
 
       bset_undo_list (current_buffer, Qt);
+      bset_cache_long_scans (current_buffer, Qnil);
 
       oldpoint = message_dolog_marker1;
       set_marker_restricted_both (oldpoint, Qnil, PT, PT_BYTE);
@@ -9698,7 +9634,7 @@ message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte)
         shown in some window.  So we must manually incrementing
         windows_or_buffers_changed here to make up for that.  */
       if (shown)
-       windows_or_buffers_changed++;
+       windows_or_buffers_changed = 41;
       else
        windows_or_buffers_changed = old_windows_or_buffers_changed;
       message_log_need_newline = !nlflag;
@@ -9793,7 +9729,11 @@ message3_nolog (Lisp_Object m)
        putc ('\n', stderr);
       noninteractive_need_newline = 0;
       if (STRINGP (m))
-       fwrite (SDATA (m), SBYTES (m), 1, stderr);
+       {
+         Lisp_Object s = ENCODE_SYSTEM (m);
+
+         fwrite (SDATA (s), SBYTES (s), 1, stderr);
+       }
       if (cursor_in_echo_area == 0)
        fprintf (stderr, "\n");
       fflush (stderr);
@@ -9868,13 +9808,19 @@ message_with_string (const char *m, Lisp_Object string, int log)
     {
       if (m)
        {
+         /* ENCODE_SYSTEM below can GC and/or relocate the Lisp
+            String whose data pointer might be passed to us in M.  So
+            we use a local copy.  */
+         char *fmt = xstrdup (m);
+
          if (noninteractive_need_newline)
            putc ('\n', stderr);
          noninteractive_need_newline = 0;
-         fprintf (stderr, m, SDATA (string));
+         fprintf (stderr, fmt, SDATA (ENCODE_SYSTEM (string)));
          if (!cursor_in_echo_area)
            fprintf (stderr, "\n");
          fflush (stderr);
+         xfree (fmt);
        }
     }
   else if (INTERACTIVE)
@@ -10391,8 +10337,8 @@ resize_echo_area_exactly (void)
                                         (intptr_t) w, resize_exactly);
       if (resized_p)
        {
-         ++windows_or_buffers_changed;
-         ++update_mode_lines;
+         windows_or_buffers_changed = 42;
+         update_mode_lines = 30;
          redisplay_internal ();
        }
     }
@@ -10788,7 +10734,7 @@ clear_garbaged_frames (void)
 
       frame_garbaged = 0;
       if (changed_count)
-       ++windows_or_buffers_changed;
+       windows_or_buffers_changed = 43;
     }
 }
 
@@ -10857,7 +10803,7 @@ echo_area_display (int update_frame_p)
                 pending input.  */
              ptrdiff_t count = SPECPDL_INDEX ();
              specbind (Qredisplay_dont_pause, Qt);
-             windows_or_buffers_changed = 1;
+             windows_or_buffers_changed = 44;
              redisplay_internal ();
              unbind_to (count, Qnil);
            }
@@ -10876,11 +10822,11 @@ echo_area_display (int update_frame_p)
             redisplay displays the minibuffer, so that the cursor will
             be replaced with what the minibuffer wants.  */
          if (cursor_in_echo_area)
-           ++windows_or_buffers_changed;
+           windows_or_buffers_changed = 45;
        }
     }
   else if (!EQ (mini_window, selected_window))
-    windows_or_buffers_changed++;
+    windows_or_buffers_changed = 46;
 
   /* Last displayed message is now the current message.  */
   echo_area_buffer[1] = echo_area_buffer[0];
@@ -10906,8 +10852,7 @@ buffer_shared_and_changed (void)
          && UNCHANGED_MODIFIED < MODIFF);
 }
 
-/* Nonzero if W's buffer was changed but not saved or Transient Mark mode
-   is enabled and mark of W's buffer was changed since last W's update.  */
+/* Nonzero if W's buffer was changed but not saved.  */
 
 static int
 window_buffer_changed (struct window *w)
@@ -10916,9 +10861,7 @@ window_buffer_changed (struct window *w)
 
   eassert (BUFFER_LIVE_P (b));
 
-  return (((BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star)
-         || ((!NILP (Vtransient_mark_mode) && !NILP (BVAR (b, mark_active)))
-             != (w->region_showing != 0)));
+  return (((BUF_SAVE_MODIFF (b) < BUF_MODIFF (b)) != w->last_had_star));
 }
 
 /* Nonzero if W has %c in its mode line and mode line should be updated.  */
@@ -11225,7 +11168,7 @@ x_consider_frame_title (Lisp_Object frame)
 /* Prepare for redisplay by updating menu-bar item lists when
    appropriate.  This can call eval.  */
 
-void
+static void
 prepare_menu_bars (void)
 {
   int all_windows;
@@ -11273,6 +11216,10 @@ prepare_menu_bars (void)
   all_windows = (update_mode_lines
                 || buffer_shared_and_changed ()
                 || windows_or_buffers_changed);
+
+  if (FUNCTIONP (Vpre_redisplay_function))
+    safe_call1 (Vpre_redisplay_function, all_windows ? Qt : Qnil);
+
   if (all_windows)
     {
       Lisp_Object tail, frame;
@@ -12940,12 +12887,12 @@ redisplay_internal (void)
   int polling_stopped_here = 0;
   Lisp_Object tail, frame;
 
-  /* Non-zero means redisplay has to consider all windows on all
-     frames.  Zero means, only selected_window is considered.  */
-  int consider_all_windows_p;
+  /* True means redisplay has to consider all windows on all
+     frames.  False, only selected_window is considered.  */
+  bool consider_all_windows_p;
 
-  /* Non-zero means redisplay has to redisplay the miniwindow.  */
-  int update_miniwindow_p = 0;
+  /* True means redisplay has to redisplay the miniwindow.  */
+  bool update_miniwindow_p = false;
 
   TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p));
 
@@ -13001,7 +12948,7 @@ redisplay_internal (void)
      realized faces, which includes the faces referenced from current
      matrices.  So, we can't reuse current matrices in this case.  */
   if (face_change_count)
-    ++windows_or_buffers_changed;
+    windows_or_buffers_changed = 47;
 
   if ((FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf))
       && FRAME_TTY (sf)->previous_frame != sf)
@@ -13009,7 +12956,7 @@ redisplay_internal (void)
       /* Since frames on a single ASCII terminal share the same
         display area, displaying a different frame means redisplay
         the whole thing.  */
-      windows_or_buffers_changed++;
+      windows_or_buffers_changed = 48;
       SET_FRAME_GARBAGED (sf);
 #ifndef DOS_NT
       set_tty_color_mode (FRAME_TTY (sf), sf);
@@ -13038,7 +12985,7 @@ redisplay_internal (void)
          /* If cursor type has been changed on the frame
             other than selected, consider all frames.  */
          if (f != sf && f->cursor_type_changed)
-           update_mode_lines++;
+           update_mode_lines = 31;
        }
       clear_desired_matrices (f);
     }
@@ -13058,8 +13005,8 @@ redisplay_internal (void)
   if (NILP (Vmemory_full))
     prepare_menu_bars ();
 
-  if (windows_or_buffers_changed)
-    update_mode_lines++;
+  if (windows_or_buffers_changed && !update_mode_lines)
+    update_mode_lines = 32;
 
   reconsider_clip_changes (w);
 
@@ -13072,7 +13019,7 @@ redisplay_internal (void)
        {
          w->update_mode_line = 1;
          if (buffer_shared_and_changed ())
-           update_mode_lines++;
+           update_mode_lines = 33;
        }
 
       if (mode_line_update_needed (w))
@@ -13085,7 +13032,10 @@ redisplay_internal (void)
   /* If specs for an arrow have changed, do thorough redisplay
      to ensure we remove any arrow that should no longer exist.  */
   if (overlay_arrows_changed_p ())
-    consider_all_windows_p = windows_or_buffers_changed = 1;
+    {
+      consider_all_windows_p = true;
+      windows_or_buffers_changed = 49;
+    }
 
   /* Normally the message* functions will have already displayed and
      updated the echo area, but the frame may have been trashed, or
@@ -13103,7 +13053,7 @@ redisplay_internal (void)
       int window_height_changed_p = echo_area_display (0);
 
       if (message_cleared_p)
-       update_miniwindow_p = 1;
+       update_miniwindow_p = true;
 
       must_finish = 1;
 
@@ -13116,9 +13066,9 @@ redisplay_internal (void)
 
       if (window_height_changed_p)
        {
-         consider_all_windows_p = 1;
-         ++update_mode_lines;
-         ++windows_or_buffers_changed;
+         consider_all_windows_p = true;
+         update_mode_lines = 34;
+         windows_or_buffers_changed = 50;
 
          /* If window configuration was changed, frames may have been
             marked garbaged.  Clear them or we will experience
@@ -13137,9 +13087,9 @@ redisplay_internal (void)
         since only the current frame needs to be considered.  This function
         needs to be rewritten with two variables, consider_all_windows and
         consider_all_frames.  */
-      consider_all_windows_p = 1;
-      ++windows_or_buffers_changed;
-      ++update_mode_lines;
+      consider_all_windows_p = true;
+      windows_or_buffers_changed = 51;
+      update_mode_lines = 35;
 
       /* If window configuration was changed, frames may have been
         marked garbaged.  Clear them or we will experience
@@ -13147,16 +13097,23 @@ redisplay_internal (void)
       clear_garbaged_frames ();
     }
 
-  /* If showing the region, and mark has changed, we must redisplay
-     the whole window.  The assignment to this_line_start_pos prevents
-     the optimization directly below this if-statement.  */
-  if (((!NILP (Vtransient_mark_mode)
-       && !NILP (BVAR (XBUFFER (w->contents), mark_active)))
-       != (w->region_showing > 0))
-      || (w->region_showing
-         && w->region_showing
-         != XINT (Fmarker_position (BVAR (XBUFFER (w->contents), mark)))))
-    CHARPOS (this_line_start_pos) = 0;
+  if (VECTORP (Vredisplay__all_windows_cause)
+      && windows_or_buffers_changed >= 0
+      && windows_or_buffers_changed < ASIZE (Vredisplay__all_windows_cause)
+      && INTEGERP (AREF (Vredisplay__all_windows_cause,
+                        windows_or_buffers_changed)))
+    ASET (Vredisplay__all_windows_cause, windows_or_buffers_changed,
+         make_number (1 + XINT (AREF (Vredisplay__all_windows_cause,
+                                      windows_or_buffers_changed))));
+
+  if (VECTORP (Vredisplay__mode_lines_cause)
+      && update_mode_lines >= 0
+      && update_mode_lines < ASIZE (Vredisplay__mode_lines_cause)
+      && INTEGERP (AREF (Vredisplay__mode_lines_cause,
+                        update_mode_lines)))
+    ASET (Vredisplay__mode_lines_cause, update_mode_lines,
+         make_number (1 + XINT (AREF (Vredisplay__mode_lines_cause,
+                                      update_mode_lines))));
 
   /* Optimize the case that only the line containing the cursor in the
      selected window has changed.  Variables starting with this_ are
@@ -13317,13 +13274,7 @@ redisplay_internal (void)
        }
       /* If highlighting the region, or if the cursor is in the echo area,
         then we can't just move the cursor.  */
-      else if (! (!NILP (Vtransient_mark_mode)
-                 && !NILP (BVAR (current_buffer, mark_active)))
-              && (EQ (selected_window,
-                      BVAR (current_buffer, last_selected_window))
-                  || highlight_nonselected_windows)
-              && !w->region_showing
-              && NILP (Vshow_trailing_whitespace)
+      else if (NILP (Vshow_trailing_whitespace)
               && !cursor_in_echo_area)
        {
          struct it it;
@@ -13365,7 +13316,6 @@ redisplay_internal (void)
     }
 
   CHARPOS (this_line_start_pos) = 0;
-  consider_all_windows_p |= buffer_shared_and_changed ();
   ++clear_face_cache_count;
 #ifdef HAVE_WINDOW_SYSTEM
   ++clear_image_cache_count;
@@ -13544,7 +13494,7 @@ redisplay_internal (void)
         matrices of some windows are not valid.  */
       if (!WINDOW_FULL_WIDTH_P (w)
          && !FRAME_WINDOW_P (XFRAME (w->frame)))
-       update_mode_lines = 1;
+       update_mode_lines = 36;
     }
   else
     {
@@ -13595,7 +13545,7 @@ redisplay_internal (void)
        }
 
       if (new_count != number_of_visible_frames)
-       windows_or_buffers_changed++;
+       windows_or_buffers_changed = 52;
     }
 
   /* Change frame size now if a change is pending.  */
@@ -15003,11 +14953,6 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
       && !update_mode_lines
       && !windows_or_buffers_changed
       && !f->cursor_type_changed
-      /* Can't use this case if highlighting a region.  When a
-         region exists, cursor movement has to do more than just
-         set the cursor.  */
-      && markpos_of_region () < 0
-      && !w->region_showing
       && NILP (Vshow_trailing_whitespace)
       /* This code is not used for mini-buffer for the sake of the case
         of redisplaying to replace an echo area message; since in
@@ -15413,7 +15358,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
        }
       else if ((w != XWINDOW (minibuf_window)
                || minibuf_level == 0)
-              /* When buffer is nonempty, redisplay window normally. */
+              /* When buffer is nonempty, redisplay window normally.  */
               && BUF_Z (XBUFFER (w->contents)) == BUF_BEG (XBUFFER (w->contents))
               /* Quail displays non-mini buffers in minibuffer window.
                  In that case, redisplay the window normally.  */
@@ -15622,7 +15567,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
             Move it back to a fully-visible line.  */
          new_vpos = window_box_height (w);
        }
-      else if (w->cursor.vpos >=0)
+      else if (w->cursor.vpos >= 0)
        {
          /* Some people insist on not letting point enter the scroll
             margin, even though this part handles windows that didn't
@@ -15680,12 +15625,14 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
 
          /* If we are highlighting the region, then we just changed
             the region, so redisplay to show it.  */
-         if (markpos_of_region () >= 0)
+         /* FIXME: We need to (re)run pre-redisplay-function!  */
+         /* if (markpos_of_region () >= 0)
            {
              clear_glyph_matrix (w->desired_matrix);
              if (!try_window (window, startp, 0))
                goto need_larger_matrices;
            }
+         */
        }
 
 #ifdef GLYPH_DEBUG
@@ -16380,10 +16327,8 @@ try_window_reusing_current_matrix (struct window *w)
       || f->cursor_type_changed)
     return 0;
 
-  /* Can't do this if region may have changed.  */
-  if (markpos_of_region () >= 0
-      || w->region_showing
-      || !NILP (Vshow_trailing_whitespace))
+  /* Can't do this if showing trailing whitespace.  */
+  if (!NILP (Vshow_trailing_whitespace))
     return 0;
 
   /* If top-line visibility has changed, give up.  */
@@ -17181,19 +17126,10 @@ try_window_id (struct window *w)
   if (!w->window_end_valid)
     GIVE_UP (8);
 
-  /* Can't use this if highlighting a region because a cursor movement
-     will do more than just set the cursor.  */
-  if (markpos_of_region () >= 0)
-    GIVE_UP (9);
-
   /* Likewise if highlighting trailing whitespace.  */
   if (!NILP (Vshow_trailing_whitespace))
     GIVE_UP (11);
 
-  /* Likewise if showing a region.  */
-  if (w->region_showing)
-    GIVE_UP (10);
-
   /* Can't use this if overlay arrow position and/or string have
      changed.  */
   if (overlay_arrows_changed_p ())
@@ -18537,7 +18473,7 @@ append_space_for_newline (struct it *it, int default_face_p)
          it->len = 1;
 
          /* If the default face was remapped, be sure to use the
-            remapped face for the appended newline. */
+            remapped face for the appended newline.  */
          if (default_face_p)
            it->face_id = lookup_basic_face (it->f, DEFAULT_FACE_ID);
          else if (it->face_before_selective_p)
@@ -18615,7 +18551,9 @@ extend_face_to_end_of_line (struct it *it)
       && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
       && face->box == FACE_NO_BOX
       && face->background == FRAME_BACKGROUND_PIXEL (f)
+#ifdef HAVE_WINDOW_SYSTEM
       && !face->stipple
+#endif
       && !it->glyph_row->reversed_p)
     return;
 
@@ -19275,9 +19213,6 @@ display_line (struct it *it)
       return 0;
     }
 
-  /* Is IT->w showing the region?  */
-  it->w->region_showing = it->region_beg_charpos > 0 ? it->region_beg_charpos : 0;
-
   /* Clear the result glyph row and enable it.  */
   prepare_desired_row (row);
 
@@ -22411,9 +22346,7 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st
 
       it->face_id
        = face_at_string_position (it->w, face_string, face_string_pos,
-                                  0, it->region_beg_charpos,
-                                  it->region_end_charpos,
-                                  &endptr, it->base_face_id, 0);
+                                  0, &endptr, it->base_face_id, 0);
       face = FACE_FROM_ID (it->f, it->face_id);
       it->face_box_p = face->box != FACE_NO_BOX;
     }
@@ -25140,7 +25073,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
       lower_yoff = descent - 2 - metrics_lower.descent;
       upper_yoff = (lower_yoff - metrics_lower.ascent - 1
                    - metrics_upper.descent);
-      /* Don't make the height shorter than the base height. */
+      /* Don't make the height shorter than the base height.  */
       if (height > base_height)
        {
          it->ascent = ascent;
@@ -25177,16 +25110,16 @@ x_produce_glyphs (struct it *it)
       struct face *face = FACE_FROM_ID (it->f, it->face_id);
       struct font *font = face->font;
       struct font_metrics *pcm = NULL;
-      int boff;                        /* baseline offset */
+      int boff;                        /* Baseline offset.  */
 
       if (font == NULL)
        {
          /* When no suitable font is found, display this character by
             the method specified in the first extra slot of
             Vglyphless_char_display.  */
-         Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
+             Lisp_Object acronym = lookup_glyphless_char_display (-1, it);
 
-         eassert (it->what == IT_GLYPHLESS);
+             eassert (it->what == IT_GLYPHLESS);
          produce_glyphless_glyph (it, 1, STRINGP (acronym) ? acronym : Qnil);
          goto done;
        }
@@ -25324,7 +25257,7 @@ x_produce_glyphs (struct it *it)
        {
          /* A newline has no width, but we need the height of the
             line.  But if previous part of the line sets a height,
-            don't increase that height */
+            don't increase that height */
 
          Lisp_Object height;
          Lisp_Object total_height = Qnil;
@@ -25334,7 +25267,7 @@ x_produce_glyphs (struct it *it)
          it->nglyphs = 0;
 
          height = get_it_property (it, Qline_height);
-         /* Split (line-height total-height) list */
+         /* Split (line-height total-height) list */
          if (CONSP (height)
              && CONSP (XCDR (height))
              && NILP (XCDR (XCDR (height))))
@@ -26412,7 +26345,7 @@ draw_phys_cursor_glyph (struct window *w, struct glyph_row *row,
 
 /* Erase the image of a cursor of window W from the screen.  */
 
-#ifndef WINDOWSNT
+#ifndef HAVE_NTGUI
 static
 #endif
 void
@@ -27417,7 +27350,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
 
   hlinfo->mouse_face_window = window;
   hlinfo->mouse_face_face_id
-    = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore,
+    = face_at_buffer_position (w, mouse_charpos, &ignore,
                               mouse_charpos + 1,
                               !hlinfo->mouse_face_hidden, -1);
   show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
@@ -27683,7 +27616,7 @@ on_hot_spot_p (Lisp_Object hot_spot, int x, int y)
       if (VECTORP (XCDR (hot_spot)))
        {
          struct Lisp_Vector *v = XVECTOR (XCDR (hot_spot));
-         Lisp_Object *poly = v->u.contents;
+         Lisp_Object *poly = v->contents;
          ptrdiff_t n = v->header.size;
          ptrdiff_t i;
          int inside = 0;
@@ -28098,8 +28031,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
 
          hlinfo->mouse_face_face_id = face_at_string_position (w, string,
                                                                charpos,
-                                                               0, 0, 0,
-                                                               &ignore,
+                                                               0, &ignore,
                                                                glyph->face_id,
                                                                1);
          show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
@@ -28400,7 +28332,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
              hlinfo->mouse_face_past_end = 0;
              hlinfo->mouse_face_window = window;
              hlinfo->mouse_face_face_id
-               = face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
+               = face_at_string_position (w, object, pos, 0, &ignore,
                                           glyph->face_id, 1);
              show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
              cursor = No_Cursor;
@@ -28447,13 +28379,14 @@ note_mouse_highlight (struct frame *f, int x, int y)
                     the first row visible in a window does not
                     necessarily display the character whose position
                     is the smallest.  */
-                 Lisp_Object lim1 =
-                   NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+                 Lisp_Object lim1
+                   NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
                    ? Fmarker_position (w->start)
                    : Qnil;
-                 Lisp_Object lim2 =
-                   NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
-                   ? make_number (BUF_Z (XBUFFER (buffer)) - w->window_end_pos)
+                 Lisp_Object lim2
+                   = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+                   ? make_number (BUF_Z (XBUFFER (buffer))
+                                  - w->window_end_pos)
                    : Qnil;
 
                  if (NILP (overlay))
@@ -29786,6 +29719,13 @@ cursor shapes.  */);
   DEFSYM (Qthin_space, "thin-space");
   DEFSYM (Qzero_width, "zero-width");
 
+  DEFVAR_LISP ("pre-redisplay-function", Vpre_redisplay_function,
+              doc: /* Function run just before redisplay.
+It is called with one argument, which is the set of windows that are to
+be redisplayed.  This set can be nil (meaning, only the selected window),
+or t (meaning all windows).  */);
+  Vpre_redisplay_function = intern ("ignore");
+
   DEFSYM (Qglyphless_char_display, "glyphless-char-display");
   Fput (Qglyphless_char_display, Qchar_table_extra_slots, make_number (1));
 
@@ -29804,7 +29744,11 @@ GRAPHICAL and TEXT should each have one of the values listed above.
 The char-table has one extra slot to control the display of a character for
 which no font is found.  This slot only takes effect on graphical terminals.
 Its value should be an ASCII acronym string, `hex-code', `empty-box', or
-`thin-space'.  The default is `empty-box'.  */);
+`thin-space'.  The default is `empty-box'.
+
+If a character has a non-nil entry in an active display table, the
+display table takes effect; in this case, Emacs does not consult
+`glyphless-char-display' at all.  */);
   Vglyphless_char_display = Fmake_char_table (Qglyphless_char_display, Qnil);
   Fset_char_table_extra_slot (Vglyphless_char_display, make_number (0),
                              Qempty_box);
@@ -29812,6 +29756,16 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
   DEFVAR_LISP ("debug-on-message", Vdebug_on_message,
               doc: /* If non-nil, debug if a message matching this regexp is displayed.  */);
   Vdebug_on_message = Qnil;
+
+  DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause,
+              doc: /*  */);
+  Vredisplay__all_windows_cause
+    = Fmake_vector (make_number (100), make_number (0));
+
+  DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause,
+              doc: /*  */);
+  Vredisplay__mode_lines_cause
+    = Fmake_vector (make_number (100), make_number (0));
 }
 
 
index 363d3bb0784e44dac19957c6fdbdc1f934430a9a..b9ddddfd9e2fce7d6d66d14e8445f596f0a231ed 100644 (file)
@@ -292,7 +292,7 @@ Lisp_Object QCwidth;
 static Lisp_Object QCfont, QCbold, QCitalic;
 static Lisp_Object QCreverse_video;
 static Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit;
-static Lisp_Object QCfontset;
+static Lisp_Object QCfontset, QCdistant_foreground;
 
 /* Symbols used for attribute values.  */
 
@@ -440,6 +440,7 @@ static struct face_cache *make_face_cache (struct frame *);
 static void free_face_cache (struct face_cache *);
 static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *,
                           int, struct named_merge_point *);
+static int color_distance (XColor *x, XColor *y);
 
 #ifdef HAVE_WINDOW_SYSTEM
 static void set_font_frame_param (Lisp_Object, Lisp_Object);
@@ -535,7 +536,7 @@ DEFUN ("dump-colors", Fdump_colors, Sdump_colors, 0, 0, 0,
    is called.  */
 
 void
-x_free_colors (struct frame *f, long unsigned int *pixels, int npixels)
+x_free_colors (struct frame *f, unsigned long *pixels, int npixels)
 {
   int class = FRAME_DISPLAY_INFO (f)->visual->class;
 
@@ -560,7 +561,7 @@ x_free_colors (struct frame *f, long unsigned int *pixels, int npixels)
 
 void
 x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
-                  long unsigned int *pixels, int npixels)
+                  unsigned long *pixels, int npixels)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
   int class = dpyinfo->visual->class;
@@ -581,7 +582,7 @@ x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
    are given by XGCV and MASK.  */
 
 static GC
-x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv)
+x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
 {
   GC gc;
   block_input ();
@@ -787,7 +788,7 @@ Optional THOROUGHLY non-nil means try to free unused fonts, too.  */)
 {
   clear_face_cache (!NILP (thoroughly));
   ++face_change_count;
-  ++windows_or_buffers_changed;
+  windows_or_buffers_changed = 53;
   return Qnil;
 }
 
@@ -853,12 +854,10 @@ the pixmap.  Bits are stored row by row, each row occupies
    pixmap spec) for use on frame F.  Value is the bitmap_id (see
    xfns.c).  If NAME is nil, return with a bitmap id of zero.  If
    bitmap cannot be loaded, display a message saying so, and return
-   zero.  Store the bitmap width in *W_PTR and its height in *H_PTR,
-   if these pointers are not null.  */
+   zero.  */
 
 static ptrdiff_t
-load_pixmap (struct frame *f, Lisp_Object name, unsigned int *w_ptr,
-            unsigned int *h_ptr)
+load_pixmap (struct frame *f, Lisp_Object name)
 {
   ptrdiff_t bitmap_id;
 
@@ -893,22 +892,12 @@ load_pixmap (struct frame *f, Lisp_Object name, unsigned int *w_ptr,
     {
       add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil);
       bitmap_id = 0;
-
-      if (w_ptr)
-       *w_ptr = 0;
-      if (h_ptr)
-       *h_ptr = 0;
     }
   else
     {
 #ifdef GLYPH_DEBUG
       ++npixmaps_allocated;
 #endif
-      if (w_ptr)
-       *w_ptr = x_bitmap_width (f, bitmap_id);
-
-      if (h_ptr)
-       *h_ptr = x_bitmap_height (f, bitmap_id);
     }
 
   return bitmap_id;
@@ -922,6 +911,8 @@ load_pixmap (struct frame *f, Lisp_Object name, unsigned int *w_ptr,
                                X Colors
  ***********************************************************************/
 
+#define NEAR_SAME_COLOR_THRESHOLD 30000
+
 /* Parse RGB_LIST, and fill in the RGB fields of COLOR.
    RGB_LIST should contain (at least) 3 lisp integers.
    Return 0 if there's a problem with RGB_LIST, otherwise return 1.  */
@@ -1188,24 +1179,10 @@ COLOR must be a valid color name.  */)
 }
 
 
-/* Load color with name NAME for use by face FACE on frame F.
-   TARGET_INDEX must be one of LFACE_FOREGROUND_INDEX,
-   LFACE_BACKGROUND_INDEX, LFACE_UNDERLINE_INDEX, LFACE_OVERLINE_INDEX,
-   LFACE_STRIKE_THROUGH_INDEX, or LFACE_BOX_INDEX.  Value is the
-   pixel color.  If color cannot be loaded, display a message, and
-   return the foreground, background or underline color of F, but
-   record that fact in flags of the face so that we don't try to free
-   these colors.  */
-
-#ifndef MSDOS
-static
-#endif
-unsigned long
-load_color (struct frame *f, struct face *face, Lisp_Object name,
-           enum lface_attribute_index target_index)
+static unsigned long
+load_color2 (struct frame *f, struct face *face, Lisp_Object name,
+             enum lface_attribute_index target_index, XColor *color)
 {
-  XColor color;
-
   eassert (STRINGP (name));
   eassert (target_index == LFACE_FOREGROUND_INDEX
           || target_index == LFACE_BACKGROUND_INDEX
@@ -1216,7 +1193,7 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
 
   /* if the color map is full, defined_color will return a best match
      to the values in an existing cell. */
-  if (!defined_color (f, SSDATA (name), &color, 1))
+  if (!defined_color (f, SSDATA (name), color, 1))
     {
       add_to_log ("Unable to load color \"%s\"", name, Qnil);
 
@@ -1224,32 +1201,32 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
        {
        case LFACE_FOREGROUND_INDEX:
          face->foreground_defaulted_p = 1;
-         color.pixel = FRAME_FOREGROUND_PIXEL (f);
+         color->pixel = FRAME_FOREGROUND_PIXEL (f);
          break;
 
        case LFACE_BACKGROUND_INDEX:
          face->background_defaulted_p = 1;
-         color.pixel = FRAME_BACKGROUND_PIXEL (f);
+         color->pixel = FRAME_BACKGROUND_PIXEL (f);
          break;
 
        case LFACE_UNDERLINE_INDEX:
          face->underline_defaulted_p = 1;
-         color.pixel = FRAME_FOREGROUND_PIXEL (f);
+         color->pixel = FRAME_FOREGROUND_PIXEL (f);
          break;
 
        case LFACE_OVERLINE_INDEX:
          face->overline_color_defaulted_p = 1;
-         color.pixel = FRAME_FOREGROUND_PIXEL (f);
+         color->pixel = FRAME_FOREGROUND_PIXEL (f);
          break;
 
        case LFACE_STRIKE_THROUGH_INDEX:
          face->strike_through_color_defaulted_p = 1;
-         color.pixel = FRAME_FOREGROUND_PIXEL (f);
+         color->pixel = FRAME_FOREGROUND_PIXEL (f);
          break;
 
        case LFACE_BOX_INDEX:
          face->box_color_defaulted_p = 1;
-         color.pixel = FRAME_FOREGROUND_PIXEL (f);
+         color->pixel = FRAME_FOREGROUND_PIXEL (f);
          break;
 
        default:
@@ -1261,7 +1238,27 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
     ++ncolors_allocated;
 #endif
 
-  return color.pixel;
+  return color->pixel;
+}
+
+/* Load color with name NAME for use by face FACE on frame F.
+   TARGET_INDEX must be one of LFACE_FOREGROUND_INDEX,
+   LFACE_BACKGROUND_INDEX, LFACE_UNDERLINE_INDEX, LFACE_OVERLINE_INDEX,
+   LFACE_STRIKE_THROUGH_INDEX, or LFACE_BOX_INDEX.  Value is the
+   pixel color.  If color cannot be loaded, display a message, and
+   return the foreground, background or underline color of F, but
+   record that fact in flags of the face so that we don't try to free
+   these colors.  */
+
+#ifndef MSDOS
+static
+#endif
+unsigned long
+load_color (struct frame *f, struct face *face, Lisp_Object name,
+           enum lface_attribute_index target_index)
+{
+  XColor color;
+  return load_color2 (f, face, name, target_index, &color);
 }
 
 
@@ -1276,7 +1273,8 @@ static void
 load_face_colors (struct frame *f, struct face *face,
                  Lisp_Object attrs[LFACE_VECTOR_SIZE])
 {
-  Lisp_Object fg, bg;
+  Lisp_Object fg, bg, dfg;
+  XColor xfg, xbg;
 
   bg = attrs[LFACE_BACKGROUND_INDEX];
   fg = attrs[LFACE_FOREGROUND_INDEX];
@@ -1298,38 +1296,45 @@ load_face_colors (struct frame *f, struct face *face,
       && !NILP (Fbitmap_spec_p (Vface_default_stipple)))
     {
       x_destroy_bitmap (f, face->stipple);
-      face->stipple = load_pixmap (f, Vface_default_stipple,
-                                  &face->pixmap_w, &face->pixmap_h);
+      face->stipple = load_pixmap (f, Vface_default_stipple);
     }
 
-  face->background = load_color (f, face, bg, LFACE_BACKGROUND_INDEX);
-  face->foreground = load_color (f, face, fg, LFACE_FOREGROUND_INDEX);
+  face->background = load_color2 (f, face, bg, LFACE_BACKGROUND_INDEX, &xbg);
+  face->foreground = load_color2 (f, face, fg, LFACE_FOREGROUND_INDEX, &xfg);
+
+  dfg = attrs[LFACE_DISTANT_FOREGROUND_INDEX];
+  if (!NILP (dfg) && !UNSPECIFIEDP (dfg)
+      && color_distance (&xbg, &xfg) < NEAR_SAME_COLOR_THRESHOLD)
+    {
+      if (EQ (attrs[LFACE_INVERSE_INDEX], Qt))
+        face->background = load_color (f, face, dfg, LFACE_BACKGROUND_INDEX);
+      else
+        face->foreground = load_color (f, face, dfg, LFACE_FOREGROUND_INDEX);
+    }
 }
 
+#ifdef HAVE_X_WINDOWS
 
 /* Free color PIXEL on frame F.  */
 
 void
-unload_color (struct frame *f, long unsigned int pixel)
+unload_color (struct frame *f, unsigned long pixel)
 {
-#ifdef HAVE_X_WINDOWS
   if (pixel != -1)
     {
       block_input ();
       x_free_colors (f, &pixel, 1);
       unblock_input ();
     }
-#endif
 }
 
-
 /* Free colors allocated for FACE.  */
 
 static void
 free_face_colors (struct frame *f, struct face *face)
 {
-/* PENDING(NS): need to do something here? */
-#ifdef HAVE_X_WINDOWS
+  /* PENDING(NS): need to do something here? */
+
   if (face->colors_copied_bitwise_p)
     return;
 
@@ -1376,9 +1381,10 @@ free_face_colors (struct frame *f, struct face *face)
     }
 
   unblock_input ();
-#endif /* HAVE_X_WINDOWS */
 }
 
+#endif /* HAVE_X_WINDOWS */
+
 #endif /* HAVE_WINDOW_SYSTEM */
 
 
@@ -1563,7 +1569,7 @@ the face font sort order.  */)
   vec = Fvconcat (ndrivers, drivers);
   nfonts = ASIZE (vec);
 
-  qsort (XVECTOR (vec)->u.contents, nfonts, word_size,
+  qsort (XVECTOR (vec)->contents, nfonts, word_size,
         compare_fonts_by_sort_order);
 
   result = Qnil;
@@ -1735,6 +1741,8 @@ the WIDTH times as wide as FACE on FRAME.  */)
 #define LFACE_FONT(LFACE)          AREF ((LFACE), LFACE_FONT_INDEX)
 #define LFACE_INHERIT(LFACE)       AREF ((LFACE), LFACE_INHERIT_INDEX)
 #define LFACE_FONTSET(LFACE)       AREF ((LFACE), LFACE_FONTSET_INDEX)
+#define LFACE_DISTANT_FOREGROUND(LFACE) \
+  AREF ((LFACE), LFACE_DISTANT_FOREGROUND_INDEX)
 
 /* Non-zero if LFACE is a Lisp face.  A Lisp face is a vector of size
    LFACE_VECTOR_SIZE which has the symbol `face' in slot 0.  */
@@ -1797,6 +1805,9 @@ check_lface_attrs (Lisp_Object attrs[LFACE_VECTOR_SIZE])
   eassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_FOREGROUND_INDEX])
           || STRINGP (attrs[LFACE_FOREGROUND_INDEX]));
+  eassert (UNSPECIFIEDP (attrs[LFACE_DISTANT_FOREGROUND_INDEX])
+          || IGNORE_DEFFACE_P (attrs[LFACE_DISTANT_FOREGROUND_INDEX])
+          || STRINGP (attrs[LFACE_DISTANT_FOREGROUND_INDEX]));
   eassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_BACKGROUND_INDEX])
           || STRINGP (attrs[LFACE_BACKGROUND_INDEX]));
@@ -1828,7 +1839,7 @@ check_lface (Lisp_Object lface)
   if (!NILP (lface))
     {
       eassert (LFACEP (lface));
-      check_lface_attrs (XVECTOR (lface)->u.contents);
+      check_lface_attrs (XVECTOR (lface)->contents);
     }
 }
 
@@ -2005,7 +2016,7 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
   lface = lface_from_face_name_no_resolve (f, face_name, signal_p);
 
   if (! NILP (lface))
-    memcpy (attrs, XVECTOR (lface)->u.contents,
+    memcpy (attrs, XVECTOR (lface)->contents,
            LFACE_VECTOR_SIZE * sizeof *attrs);
 
   return !NILP (lface);
@@ -2062,7 +2073,8 @@ lface_fully_specified_p (Lisp_Object attrs[LFACE_VECTOR_SIZE])
   int i;
 
   for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
-    if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX)
+    if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX
+        && i != LFACE_DISTANT_FOREGROUND_INDEX)
       if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i])))
        break;
 
@@ -2463,6 +2475,13 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
                  else
                    err = 1;
                }
+             else if (EQ (keyword, QCdistant_foreground))
+               {
+                 if (STRINGP (value))
+                   to[LFACE_DISTANT_FOREGROUND_INDEX] = value;
+                 else
+                   err = 1;
+               }
              else if (EQ (keyword, QCbackground))
                {
                  if (STRINGP (value))
@@ -2619,7 +2638,7 @@ Value is a vector of face attributes.  */)
   if (NILP (Fget (face, Qface_no_inherit)))
     {
       ++face_change_count;
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 54;
     }
 
   eassert (LFACEP (lface));
@@ -2688,7 +2707,7 @@ The value is TO.  */)
       copy = Finternal_make_lisp_face (to, new_frame);
     }
 
-  vcopy (copy, 0, XVECTOR (lface)->u.contents, LFACE_VECTOR_SIZE);
+  vcopy (copy, 0, XVECTOR (lface)->contents, LFACE_VECTOR_SIZE);
 
   /* Changing a named face means that all realized faces depending on
      that face are invalid.  Since we cannot tell which realized faces
@@ -2698,7 +2717,7 @@ The value is TO.  */)
   if (NILP (Fget (to, Qface_no_inherit)))
     {
       ++face_change_count;
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 55;
     }
 
   return to;
@@ -3019,6 +3038,23 @@ FRAME 0 means change the face on all frames, and change the default
       old_value = LFACE_FOREGROUND (lface);
       ASET (lface, LFACE_FOREGROUND_INDEX, value);
     }
+  else if (EQ (attr, QCdistant_foreground))
+    {
+      /* Compatibility with 20.x.  */
+      if (NILP (value))
+       value = Qunspecified;
+      if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value))
+       {
+         /* Don't check for valid color names here because it depends
+            on the frame (display) whether the color will be valid
+            when the face is realized.  */
+         CHECK_STRING (value);
+         if (SCHARS (value) == 0)
+           signal_error ("Empty distant-foreground color value", value);
+       }
+      old_value = LFACE_DISTANT_FOREGROUND (lface);
+      ASET (lface, LFACE_DISTANT_FOREGROUND_INDEX, value);
+    }
   else if (EQ (attr, QCbackground))
     {
       /* Compatibility with 20.x.  */
@@ -3091,7 +3127,7 @@ FRAME 0 means change the face on all frames, and change the default
                f = XFRAME (frame);
              if (! FONT_OBJECT_P (value))
                {
-                 Lisp_Object *attrs = XVECTOR (lface)->u.contents;
+                 Lisp_Object *attrs = XVECTOR (lface)->contents;
                  Lisp_Object font_object;
 
                  font_object = font_load_for_lface (f, attrs, value);
@@ -3159,7 +3195,7 @@ FRAME 0 means change the face on all frames, and change the default
         the font to nil so that the font selector doesn't think that
         the attribute is mandatory.  Also, clear the average
         width.  */
-      font_clear_prop (XVECTOR (lface)->u.contents, prop_index);
+      font_clear_prop (XVECTOR (lface)->contents, prop_index);
     }
 
   /* Changing a named face means that all realized faces depending on
@@ -3172,7 +3208,7 @@ FRAME 0 means change the face on all frames, and change the default
       && NILP (Fequal (old_value, value)))
     {
       ++face_change_count;
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 56;
     }
 
   if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)
@@ -3186,10 +3222,10 @@ FRAME 0 means change the face on all frames, and change the default
        {
 #ifdef HAVE_WINDOW_SYSTEM
          /* Changed font-related attributes of the `default' face are
-            reflected in changed `font' frame parameters. */
+            reflected in changed `font' frame parameters.  */
          if (FRAMEP (frame)
              && (prop_index || EQ (attr, QCfont))
-             && lface_fully_specified_p (XVECTOR (lface)->u.contents))
+             && lface_fully_specified_p (XVECTOR (lface)->contents))
            set_font_frame_param (frame, lface);
          else
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -3345,7 +3381,7 @@ update_face_from_frame_parameter (struct frame *f, Lisp_Object param,
       && NILP (Fget (face, Qface_no_inherit)))
     {
       ++face_change_count;
-      ++windows_or_buffers_changed;
+      windows_or_buffers_changed = 57;
     }
 }
 
@@ -3369,7 +3405,7 @@ set_font_frame_param (Lisp_Object frame, Lisp_Object lface)
     {
       if (FONT_SPEC_P (font))
        {
-         font = font_load_for_lface (f, XVECTOR (lface)->u.contents, font);
+         font = font_load_for_lface (f, XVECTOR (lface)->contents, font);
          if (NILP (font))
            return;
          ASET (lface, LFACE_FONT_INDEX, font);
@@ -3663,6 +3699,8 @@ frames).  If FRAME is omitted or nil, use the selected frame.  */)
     value = LFACE_INVERSE (lface);
   else if (EQ (keyword, QCforeground))
     value = LFACE_FOREGROUND (lface);
+  else if (EQ (keyword, QCdistant_foreground))
+    value = LFACE_DISTANT_FOREGROUND (lface);
   else if (EQ (keyword, QCbackground))
     value = LFACE_BACKGROUND (lface);
   else if (EQ (keyword, QCstipple))
@@ -3726,8 +3764,8 @@ Default face attributes override any local face attributes.  */)
      the local frame is defined from default specs in `face-defface-spec'
      and those should be overridden by global settings.  Hence the strange
      "global before local" priority.  */
-  lvec = XVECTOR (local_lface)->u.contents;
-  gvec = XVECTOR (global_lface)->u.contents;
+  lvec = XVECTOR (local_lface)->contents;
+  gvec = XVECTOR (global_lface)->contents;
   for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
     if (IGNORE_DEFFACE_P (gvec[i]))
       ASET (local_lface, i, Qunspecified);
@@ -3911,8 +3949,8 @@ If FRAME is omitted or nil, use the selected frame.  */)
 
   lface1 = lface_from_face_name (f, face1, 1);
   lface2 = lface_from_face_name (f, face2, 1);
-  equal_p = lface_equal_p (XVECTOR (lface1)->u.contents,
-                          XVECTOR (lface2)->u.contents);
+  equal_p = lface_equal_p (XVECTOR (lface1)->contents,
+                          XVECTOR (lface2)->contents);
   return equal_p ? Qt : Qnil;
 }
 
@@ -4018,9 +4056,13 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
 static struct face *
 make_realized_face (Lisp_Object *attr)
 {
-  struct face *face = xzalloc (sizeof *face);
-  face->ascii_face = face;
+  enum { off = offsetof (struct face, id) };
+  struct face *face = xmalloc (sizeof *face);
+
   memcpy (face->lface, attr, sizeof face->lface);
+  memset (&face->id, 0, sizeof *face - off);
+  face->ascii_face = face;
+
   return face;
 }
 
@@ -4048,8 +4090,9 @@ free_realized_face (struct frame *f, struct face *face)
              face->gc = 0;
              unblock_input ();
            }
-
+#ifdef HAVE_X_WINDOWS
          free_face_colors (f, face);
+#endif /* HAVE_X_WINDOWS */
          x_destroy_bitmap (f, face->stipple);
        }
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -4231,7 +4274,7 @@ free_realized_faces (struct face_cache *c)
       if (WINDOWP (f->root_window))
        {
          clear_current_matrices (f);
-         ++windows_or_buffers_changed;
+         windows_or_buffers_changed = 58;
        }
 
       unblock_input ();
@@ -4649,7 +4692,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
   Lisp_Object lface;
   lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE),
                        Qunspecified);
-  merge_face_ref (XFRAME (selected_frame), plist, XVECTOR (lface)->u.contents,
+  merge_face_ref (XFRAME (selected_frame), plist, XVECTOR (lface)->contents,
                  1, 0);
   return lface;
 }
@@ -4669,7 +4712,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-/* Return non-zero if all the face attributes in ATTRS are supported
+/* Return true if all the face attributes in ATTRS are supported
    on the window-system frame F.
 
    The definition of `supported' is somewhat heuristic, but basically means
@@ -4679,7 +4722,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
     \(1) different in appearance than the default face, and
     \(2) `close in spirit' to what the attributes specify, if not exact.  */
 
-static int
+static bool
 x_supports_face_attributes_p (struct frame *f,
                              Lisp_Object attrs[LFACE_VECTOR_SIZE],
                              struct face *def_face)
@@ -4697,6 +4740,9 @@ x_supports_face_attributes_p (struct frame *f,
       || (!UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
          && face_attr_equal_p (attrs[LFACE_FOREGROUND_INDEX],
                                def_attrs[LFACE_FOREGROUND_INDEX]))
+      || (!UNSPECIFIEDP (attrs[LFACE_DISTANT_FOREGROUND_INDEX])
+         && face_attr_equal_p (attrs[LFACE_DISTANT_FOREGROUND_INDEX],
+                               def_attrs[LFACE_DISTANT_FOREGROUND_INDEX]))
       || (!UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
          && face_attr_equal_p (attrs[LFACE_BACKGROUND_INDEX],
                                def_attrs[LFACE_BACKGROUND_INDEX]))
@@ -4766,7 +4812,7 @@ x_supports_face_attributes_p (struct frame *f,
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
-/* Return non-zero if all the face attributes in ATTRS are supported
+/* Return true if all the face attributes in ATTRS are supported
    on the tty frame F.
 
    The definition of `supported' is somewhat heuristic, but basically means
@@ -4782,7 +4828,7 @@ x_supports_face_attributes_p (struct frame *f,
    will _not_ be satisfied by the tty display code's automatic
    substitution of a `dim' face for italic.  */
 
-static int
+static bool
 tty_supports_face_attributes_p (struct frame *f,
                                Lisp_Object attrs[LFACE_VECTOR_SIZE],
                                struct face *def_face)
@@ -4876,12 +4922,6 @@ tty_supports_face_attributes_p (struct frame *f,
 
   /* Color testing.  */
 
-  /* Default the color indices in FG_TTY_COLOR and BG_TTY_COLOR, since
-     we use them when calling `tty_capable_p' below, even if the face
-     specifies no colors.  */
-  fg_tty_color.pixel = FACE_TTY_DEFAULT_FG_COLOR;
-  bg_tty_color.pixel = FACE_TTY_DEFAULT_BG_COLOR;
-
   /* Check if foreground color is close enough.  */
   fg = attrs[LFACE_FOREGROUND_INDEX];
   if (STRINGP (fg))
@@ -4947,14 +4987,7 @@ tty_supports_face_attributes_p (struct frame *f,
 
   /* See if the capabilities we selected above are supported, with the
      given colors.  */
-  if (test_caps != 0 &&
-      ! tty_capable_p (FRAME_TTY (f), test_caps, fg_tty_color.pixel,
-                      bg_tty_color.pixel))
-    return 0;
-
-
-  /* Hmmm, everything checks out, this terminal must support this face.  */
-  return 1;
+  return tty_capable_p (FRAME_TTY (f), test_caps);
 }
 
 
@@ -4979,7 +5012,8 @@ satisfied by the tty display code's automatic substitution of a `dim'
 face for italic.  */)
   (Lisp_Object attributes, Lisp_Object display)
 {
-  int supports = 0, i;
+  bool supports = 0;
+  int i;
   Lisp_Object frame;
   struct frame *f;
   struct face *def_face;
@@ -5329,9 +5363,9 @@ realize_default_face (struct frame *f)
     ASET (lface, LFACE_STIPPLE_INDEX, Qnil);
 
   /* Realize the face; it must be fully-specified now.  */
-  eassert (lface_fully_specified_p (XVECTOR (lface)->u.contents));
+  eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
   check_lface (lface);
-  memcpy (attrs, XVECTOR (lface)->u.contents, sizeof attrs);
+  memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
   face = realize_face (c, attrs, DEFAULT_FACE_ID);
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -5716,7 +5750,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
 
   stipple = attrs[LFACE_STIPPLE_INDEX];
   if (!NILP (stipple))
-    face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h);
+    face->stipple = load_pixmap (f, stipple);
 #endif /* HAVE_WINDOW_SYSTEM */
 
   return face;
@@ -5925,7 +5959,6 @@ compute_char_face (struct frame *f, int ch, Lisp_Object prop)
 
 int
 face_at_buffer_position (struct window *w, ptrdiff_t pos,
-                        ptrdiff_t region_beg, ptrdiff_t region_end,
                         ptrdiff_t *endptr, ptrdiff_t limit,
                         int mouse, int base_face_id)
 {
@@ -5946,8 +5979,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
   XSETFASTINT (position, pos);
 
   endpos = ZV;
-  if (pos < region_beg && region_beg < endpos)
-    endpos = region_beg;
 
   /* Get the `face' or `mouse_face' text property at POS, and
      determine the next position at which the property changes.  */
@@ -5983,8 +6014,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
 
   /* Optimize common cases where we can use the default face.  */
   if (noverlays == 0
-      && NILP (prop)
-      && !(pos >= region_beg && pos < region_end))
+      && NILP (prop))
     return default_face->id;
 
   /* Begin with attributes from the default face.  */
@@ -6011,15 +6041,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
        endpos = oendpos;
     }
 
-  /* If in the region, merge in the region face.  */
-  if (pos >= region_beg && pos < region_end)
-    {
-      merge_named_face (f, Qregion, attrs, 0);
-
-      if (region_end < endpos)
-       endpos = region_end;
-    }
-
   *endptr = endpos;
 
   /* Look up a realized face with the given face attributes,
@@ -6035,7 +6056,6 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
 
 int
 face_for_overlay_string (struct window *w, ptrdiff_t pos,
-                        ptrdiff_t region_beg, ptrdiff_t region_end,
                         ptrdiff_t *endptr, ptrdiff_t limit,
                         int mouse, Lisp_Object overlay)
 {
@@ -6054,8 +6074,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
   XSETFASTINT (position, pos);
 
   endpos = ZV;
-  if (pos < region_beg && region_beg < endpos)
-    endpos = region_beg;
 
   /* Get the `face' or `mouse_face' text property at POS, and
      determine the next position at which the property changes.  */
@@ -6069,7 +6087,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
 
   /* Optimize common case where we can use the default face.  */
   if (NILP (prop)
-      && !(pos >= region_beg && pos < region_end)
       && NILP (Vface_remapping_alist))
     return DEFAULT_FACE_ID;
 
@@ -6081,15 +6098,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
   if (!NILP (prop))
     merge_face_ref (f, prop, attrs, 1, 0);
 
-  /* If in the region, merge in the region face.  */
-  if (pos >= region_beg && pos < region_end)
-    {
-      merge_named_face (f, Qregion, attrs, 0);
-
-      if (region_end < endpos)
-       endpos = region_end;
-    }
-
   *endptr = endpos;
 
   /* Look up a realized face with the given face attributes,
@@ -6122,7 +6130,6 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
 int
 face_at_string_position (struct window *w, Lisp_Object string,
                         ptrdiff_t pos, ptrdiff_t bufpos,
-                        ptrdiff_t region_beg, ptrdiff_t region_end,
                         ptrdiff_t *endptr, enum face_id base_face_id,
                         int mouse_p)
 {
@@ -6154,15 +6161,8 @@ face_at_string_position (struct window *w, Lisp_Object string,
   base_face = FACE_FROM_ID (f, base_face_id);
   eassert (base_face);
 
-  /* Optimize the default case that there is no face property and we
-     are not in the region.  */
+  /* Optimize the default case that there is no face property.  */
   if (NILP (prop)
-      && (base_face_id != DEFAULT_FACE_ID
-         /* BUFPOS <= 0 means STRING is not an overlay string, so
-            that the region doesn't have to be taken into account.  */
-         || bufpos <= 0
-         || bufpos < region_beg
-         || bufpos >= region_end)
       && (multibyte_p
          /* We can't realize faces for different charsets differently
             if we don't have fonts, so we can stop here if not working
@@ -6178,12 +6178,6 @@ face_at_string_position (struct window *w, Lisp_Object string,
   if (!NILP (prop))
     merge_face_ref (f, prop, attrs, 1, 0);
 
-  /* If in the region, merge in the region face.  */
-  if (bufpos
-      && bufpos >= region_beg
-      && bufpos < region_end)
-    merge_named_face (f, Qregion, attrs, 0);
-
   /* Look up a realized face with the given face attributes,
      or realize a new one for ASCII characters.  */
   return lookup_face (f, attrs);
@@ -6410,6 +6404,7 @@ syms_of_xfaces (void)
   DEFSYM (QCwidth, ":width");
   DEFSYM (QCfont, ":font");
   DEFSYM (QCfontset, ":fontset");
+  DEFSYM (QCdistant_foreground, ":distant-foreground");
   DEFSYM (QCbold, ":bold");
   DEFSYM (QCitalic, ":italic");
   DEFSYM (QCoverline, ":overline");
index 9cd7d3e6627ef2149c8654955103bd4defac0b18..46f377042f6ee2799d8a632183bbc134b19dbd2d 100644 (file)
@@ -959,7 +959,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
     nlines = 0;
 
   /* Make sure we redisplay all windows in this frame.  */
-  windows_or_buffers_changed++;
+  windows_or_buffers_changed = 59;
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   FRAME_MENU_BAR_LINES (f) = 0;
@@ -1068,8 +1068,8 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 
 #else /* !USE_GTK */
 
-     /* Make sure we redisplay all windows in this frame.  */
-  ++windows_or_buffers_changed;
+  /* Make sure we redisplay all windows in this frame.  */
+  windows_or_buffers_changed = 60;
 
   delta = nlines - FRAME_TOOL_BAR_LINES (f);
 
@@ -1383,7 +1383,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
       /* If we're switching from explicit to implicit, we had better
         update the mode lines and thereby update the title.  */
       if (f->explicit_name && NILP (name))
-       update_mode_lines = 1;
+       update_mode_lines = 37;
 
       f->explicit_name = ! NILP (name);
     }
@@ -1445,7 +1445,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
   if (EQ (name, f->title))
     return;
 
-  update_mode_lines = 1;
+  update_mode_lines = 38;
 
   fset_title (f, name);
 
@@ -1750,7 +1750,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
        }
     }
   if (motif)
-    strcat (fontsetname, ":");
+    return strcat (fontsetname, ":");
   return fontsetname;
 }
 #endif /* HAVE_X_WINDOWS && USE_X_TOOLKIT */
@@ -2880,6 +2880,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
   f->output_data.x->scroll_bar_top_shadow_pixel = -1;
   f->output_data.x->scroll_bar_bottom_shadow_pixel = -1;
 #endif /* USE_TOOLKIT_SCROLL_BARS */
+  f->output_data.x->white_relief.pixel = -1;
+  f->output_data.x->black_relief.pixel = -1;
 
   fset_icon_name (f,
                  x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
@@ -4824,6 +4826,9 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
   f->output_data.x->scroll_bar_top_shadow_pixel = -1;
   f->output_data.x->scroll_bar_bottom_shadow_pixel = -1;
 #endif /* USE_TOOLKIT_SCROLL_BARS */
+  f->output_data.x->white_relief.pixel = -1;
+  f->output_data.x->black_relief.pixel = -1;
+
   fset_icon_name (f, Qnil);
   FRAME_DISPLAY_INFO (f) = dpyinfo;
   f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
index c5b8db3830ccf88f46cfe0cf8a02e0ed79c23f47..d4d6ee7c10fe1dd10079a5615dd6432a9d7694f8 100644 (file)
@@ -119,7 +119,7 @@ static Lisp_Object xfont_list (struct frame *, Lisp_Object);
 static Lisp_Object xfont_match (struct frame *, Lisp_Object);
 static Lisp_Object xfont_list_family (struct frame *);
 static Lisp_Object xfont_open (struct frame *, Lisp_Object, int);
-static void xfont_close (struct frame *, struct font *);
+static void xfont_close (struct font *);
 static int xfont_prepare_face (struct frame *, struct face *);
 static int xfont_has_char (Lisp_Object, int);
 static unsigned xfont_encode_char (struct font *, int);
@@ -384,7 +384,7 @@ xfont_list_pattern (Display *display, const char *pattern,
   if (num_fonts > 0)
     {
       char **indices = alloca (sizeof (char *) * num_fonts);
-      Lisp_Object *props = XVECTOR (xfont_scratch_props)->u.contents;
+      Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents;
       Lisp_Object scripts = Qnil;
 
       for (i = 0; i < ASIZE (xfont_scratch_props); i++)
@@ -890,11 +890,17 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 }
 
 static void
-xfont_close (struct frame *f, struct font *font)
+xfont_close (struct font *font)
 {
-  block_input ();
-  XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont);
-  unblock_input ();
+  struct xfont_info *xfi = (struct xfont_info *) font;
+
+  if (xfi->xfont)
+    {
+      block_input ();
+      XFreeFont (xfi->display, xfi->xfont);
+      unblock_input ();
+      xfi->xfont = NULL;
+    }
 }
 
 static int
index f2b4c2abe2bcdfd511fa83a14aa0f6356f60a25a..37b33b3ead8cf9d39a7f97b25617a5a9b513f60c 100644 (file)
@@ -58,7 +58,6 @@ struct xftfont_info
   int index;
   FT_Matrix matrix;
   Display *display;
-  int screen;
   XftFont *xftfont;
 };
 
@@ -70,11 +69,6 @@ struct xftface_info
   XftColor xft_bg;             /* color for face->background */
 };
 
-static void xftfont_get_colors (struct frame *, struct face *, GC gc,
-                                struct xftface_info *,
-                                XftColor *fg, XftColor *bg);
-
-
 /* Setup foreground and background colors of GC into FG and BG.  If
    XFTFACE_INFO is not NULL, reuse the colors in it if possible.  BG
    may be NULL.  */
@@ -377,7 +371,6 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 
   xftfont_info = (struct xftfont_info *) font;
   xftfont_info->display = display;
-  xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f);
   xftfont_info->xftfont = xftfont;
   /* This means that there's no need of transformation.  */
   xftfont_info->matrix.xx = 0;
@@ -486,18 +479,26 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 }
 
 static void
-xftfont_close (struct frame *f, struct font *font)
+xftfont_close (struct font *font)
 {
   struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
 
 #ifdef HAVE_LIBOTF
   if (xftfont_info->otf)
-    OTF_close (xftfont_info->otf);
+    {
+      OTF_close (xftfont_info->otf);
+      xftfont_info->otf = NULL;
+    }
 #endif
-  block_input ();
-  XftUnlockFace (xftfont_info->xftfont);
-  XftFontClose (xftfont_info->display, xftfont_info->xftfont);
-  unblock_input ();
+
+  if (xftfont_info->xftfont)
+    {
+      block_input ();
+      XftUnlockFace (xftfont_info->xftfont);
+      XftFontClose (xftfont_info->display, xftfont_info->xftfont);
+      unblock_input ();
+      xftfont_info->xftfont = NULL;
+    }
 }
 
 static int
index d910100f77f6824e23ba58f9f6d3a43bd1120512..b2c7fb5f0734bbf0cb74d49297ee01ae28ac4495 100644 (file)
@@ -847,7 +847,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
 
       /* Save the frame's previous menu bar contents data.  */
       if (previous_menu_items_used)
-       memcpy (previous_items, XVECTOR (f->menu_bar_vector)->u.contents,
+       memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
                previous_menu_items_used * word_size);
 
       /* Fill in menu_items with the current menu bar contents.
@@ -2086,7 +2086,7 @@ menu_help_callback (char const *help_string, int pane, int item)
   Lisp_Object pane_name;
   Lisp_Object menu_object;
 
-  first_item = XVECTOR (menu_items)->u.contents;
+  first_item = XVECTOR (menu_items)->contents;
   if (EQ (first_item[0], Qt))
     pane_name = first_item[MENU_ITEMS_PANE_NAME];
   else if (EQ (first_item[0], Qquote))
index 52988f0818a601f2018d1f3cfb852658085841ee..ea823b2b3135f3da0be177a7e9eeb8ced027fbf4 100644 (file)
@@ -234,9 +234,7 @@ gethomedir (void)
 
   copy = xmalloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
-  strcat (copy, "/");
-
-  return copy;
+  return strcat (copy, "/");
 }
 
 
index b4f4f9d43b60cadf8e9081dcf31f672254268caa..6dbeb539f778a4c5e8fb320325037c9715764aa1 100644 (file)
@@ -972,7 +972,6 @@ x_handle_selection_clear (struct input_event *event)
     Frun_hook_with_args (2, args);
   }
 
-  prepare_menu_bars ();
   redisplay_preserve_echo_area (20);
 }
 
@@ -2365,7 +2364,7 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
 
 Lisp_Object
 x_property_data_to_lisp (struct frame *f, const unsigned char *data,
-                        Atom type, int format, long unsigned int size)
+                        Atom type, int format, unsigned long size)
 {
   ptrdiff_t format_bytes = format >> 3;
   if (PTRDIFF_MAX / format_bytes < size)
index e5a66c4cf0a7a91eaaee82e957c676699b40fdfc..cff0c99548dc5dfed290adbd1fb30b87eb54bc3f 100644 (file)
@@ -393,7 +393,7 @@ get_prop_window (struct x_display_info *dpyinfo)
 
 static int
 parse_settings (unsigned char *prop,
-                long unsigned int bytes,
+                unsigned long bytes,
                 struct xsettings *settings)
 {
   Lisp_Object byteorder = Fbyteorder ();
index 26ad526762558c57058a63f0c719c9ea269a80a7..446b2cf1e45171182fda306b07dcabd0d5ae2977 100644 (file)
@@ -1643,7 +1643,7 @@ x_alloc_nearest_color (struct frame *f, Colormap cmap, XColor *color)
    get color reference counts right.  */
 
 unsigned long
-x_copy_color (struct frame *f, long unsigned int pixel)
+x_copy_color (struct frame *f, unsigned long pixel)
 {
   XColor color;
 
@@ -1681,7 +1681,8 @@ x_copy_color (struct frame *f, long unsigned int pixel)
    Value is non-zero if successful.  */
 
 static bool
-x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long unsigned int *pixel, double factor, int delta)
+x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap,
+                      unsigned long *pixel, double factor, int delta)
 {
   XColor color, new;
   long bright;
@@ -1757,7 +1758,8 @@ x_alloc_lighter_color (struct frame *f, Display *display, Colormap cmap, long un
    be allocated, use DEFAULT_PIXEL, instead.  */
 
 static void
-x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int delta, long unsigned int default_pixel)
+x_setup_relief_color (struct frame *f, struct relief *relief, double factor,
+                     int delta, unsigned long default_pixel)
 {
   XGCValues xgcv;
   struct x_output *di = f->output_data.x;
@@ -1774,11 +1776,10 @@ x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int
   /* Free previously allocated color.  The color cell will be reused
      when it has been freed as many times as it was allocated, so this
      doesn't affect faces using the same colors.  */
-  if (relief->gc
-      && relief->allocated_p)
+  if (relief->gc && relief->pixel != -1)
     {
       x_free_colors (f, &relief->pixel, 1);
-      relief->allocated_p = 0;
+      relief->pixel = -1;
     }
 
   /* Allocate new color.  */
@@ -1786,10 +1787,7 @@ x_setup_relief_color (struct frame *f, struct relief *relief, double factor, int
   pixel = background;
   if (dpyinfo->n_planes != 1
       && x_alloc_lighter_color (f, dpy, cmap, &pixel, factor, delta))
-    {
-      relief->allocated_p = 1;
-      xgcv.foreground = relief->pixel = pixel;
-    }
+    xgcv.foreground = relief->pixel = pixel;
 
   if (relief->gc == 0)
     {
@@ -9338,9 +9336,9 @@ x_free_frame_resources (struct frame *f)
       if (f->output_data.x->scroll_bar_bottom_shadow_pixel != -1)
        unload_color (f, f->output_data.x->scroll_bar_bottom_shadow_pixel);
 #endif /* USE_TOOLKIT_SCROLL_BARS */
-      if (f->output_data.x->white_relief.allocated_p)
+      if (f->output_data.x->white_relief.pixel != -1)
        unload_color (f, f->output_data.x->white_relief.pixel);
-      if (f->output_data.x->black_relief.allocated_p)
+      if (f->output_data.x->black_relief.pixel != -1)
        unload_color (f, f->output_data.x->black_relief.pixel);
 
       x_free_gcs (f);
@@ -9690,7 +9688,7 @@ same_x_server (const char *name1, const char *name2)
    get to the first bit.  With MASK 0x7e0, *BITS is set to 6, and *OFFSET
    to 5.  */
 static void
-get_bits_and_offset (long unsigned int mask, int *bits, int *offset)
+get_bits_and_offset (unsigned long mask, int *bits, int *offset)
 {
   int nr = 0;
   int off = 0;
@@ -10589,14 +10587,14 @@ With MS Windows or Nextstep, the value is t.  */);
   Vx_toolkit_scroll_bars = Qnil;
 #endif
 
-  Qmodifier_value = intern_c_string ("modifier-value");
-  Qalt = intern_c_string ("alt");
+  DEFSYM (Qmodifier_value, "modifier-value");
+  DEFSYM (Qalt, "alt");
   Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
-  Qhyper = intern_c_string ("hyper");
+  DEFSYM (Qhyper, "hyper");
   Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
-  Qmeta = intern_c_string ("meta");
+  DEFSYM (Qmeta, "meta");
   Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
-  Qsuper = intern_c_string ("super");
+  DEFSYM (Qsuper, "super");
   Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
 
   DEFVAR_LISP ("x-alt-keysym", Vx_alt_keysym,
index 06c0d4882b8a317de2a0b2cad57378a2a8a3d3d6..753debff1bb0b05b2ae6cb283afbb80ea0107799 100644 (file)
@@ -605,7 +605,6 @@ struct x_output
   {
     GC gc;
     unsigned long pixel;
-    int allocated_p;
   }
   black_relief, white_relief;
 
index 9a8a61eb062623ce6b87ce536efcfb3a947fd022..79d9ab544e0bd31f9b83183edaade53ba69871fb 100644 (file)
@@ -1,3 +1,211 @@
+2013-11-16  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp-test07-file-exists-p)
+       (tramp-test08-file-local-copy)
+       (tramp-test09-insert-file-contents, tramp-test10-write-region)
+       (tramp-test11-copy-file, tramp-test12-rename-file)
+       (tramp-test13-make-directory, tramp-test14-delete-directory)
+       (tramp-test15-copy-directory, tramp-test16-directory-files)
+       (tramp-test17-insert-directory, tramp-test18-file-attributes)
+       (tramp-test19-directory-files-and-attributes)
+       (tramp-test20-file-modes, tramp-test21-file-links)
+       (tramp-test22-file-times, tramp-test23-visited-file-modtime)
+       (tramp-test24-file-name-completion, tramp-test25-load)
+       (tramp-test26-process-file, tramp-test27-start-file-process)
+       (tramp-test28-shell-command): Cleanup connection initially.
+
+2013-11-15  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp-test29-utf8): Cleanup the
+       connection before running the test.
+
+2013-11-15  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp-test15-copy-directory)
+       (tramp-test16-directory-files, tramp-test17-insert-directory)
+       (tramp-test18-file-attributes)
+       (tramp-test19-directory-files-and-attributes)
+       (tramp-test20-file-modes, tramp-test21-file-links)
+       (tramp-test22-file-times, tramp-test23-visited-file-modtime)
+       (tramp-test24-file-name-completion, tramp-test25-load)
+       (tramp-test26-process-file, tramp-test27-start-file-process):
+       (tramp-test28-shell-command): Protect unwindforms with
+       `ignore-errors'.
+       (tramp-test29-utf8): New test.
+
+2013-11-13  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/file-notify-tests.el (file-notify-test02-events)
+       (file-notify-test03-autorevert): Suppress messages in `write-region'.
+
+       * automated/tramp-tests.el (tramp-test02-file-name-dissect)
+       (tramp-test03-file-name-defaults, tramp-test21-file-links): Add tests.
+       (tramp-test26-process-file, tramp-test28-shell-command):
+       Ensure, that the directory is not empty when calling "ls".
+
+2013-11-11  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp-test-temporary-file-directory):
+       Check $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY.
+       (tramp-read-passwd): Check $TRAMP_TEST_ALLOW_PASSWORD.
+       (tramp-test09-insert-file-contents, tramp-test10-write-region):
+       (tramp-test26-process-file): Add tests.
+       (tramp-test11-copy-file): Remove debug message.
+       (tramp-test20-file-modes): Special case, if user is "root".
+
+2013-11-08  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/file-notify-tests.el:
+       * automated/tramp-tests.el: Add `tramp-own-remote-path' to
+       `tramp-remote-path' when running on hydra.
+       (tramp-test07-file-exists-p): Remove instrumentation code.
+       (tramp-test26-process-file): Don't use "/bin/true" and
+       "/bin/false", these paths do not exist on hydra.
+
+2013-11-08  Helmut Eller  <eller.helmut@gmail.com>
+
+       * automated/process-tests.el: New file.
+
+2013-11-08  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: New examples.
+
+2013-11-06  Glenn Morris  <rgm@gnu.org>
+
+       * automated/Makefile.in (setwins): Avoid accidental matches.
+
+2013-11-06  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el (tramp-test07-file-exists-p):
+       Fix docstring.  Instrument, in order to hunt failure on hydra.
+
+2013-11-06  Glenn Morris  <rgm@gnu.org>
+
+       * automated/flymake-tests.el (warning-predicate-rx-gcc)
+       (warning-predicate-function-gcc, warning-predicate-rx-perl)
+       (warning-predicate-function-perl):
+       * automated/info-xref.el (info-xref-test-makeinfo):
+       * automated/vc-bzr.el (vc-bzr-test-bug9726, vc-bzr-test-bug9781)
+       (vc-bzr-test-faulty-bzr-autoloads): Skip rather than expect failure.
+
+2013-11-05  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/tramp-tests.el: New file.
+
+2013-11-05  Glenn Morris  <rgm@gnu.org>
+
+       Get rid of --chdir usage.
+       * automated/Makefile.in (EMACSOPT): Move -L here.
+       (emacs): Set EMACS_TEST_DIRECTORY in the environment.
+       (setwins): Don't assume called from srcdir.  Remove legacy stuff.
+       (.el.elc): No more need to pass -L here.
+       (compile-main): Get rid of sub-shell and cd.
+       (compile-clean, check): Get rid of cd.
+
+       Make it possible to run tests with a different working directory.
+       * automated/flymake-tests.el (flymake-tests-data-directory): New.
+       (flymake-tests--current-face): Use flymake-tests-data-directory.
+       (warning-predicate-function-gcc, warning-predicate-rx-perl)
+       (warning-predicate-function-perl): Adapt for above change.
+       * automated/zlib-tests.el (zlib-tests-data-directory): New.
+       (zlib--decompress): Use zlib-tests-data-directory.
+
+       * automated/eieio-tests.el (eieio-test-37-persistent-classes):
+       Remove test that makes no sense.
+
+       * automated/files.el (files-test-local-variable-data):
+       Fix result typo presumably caused by interference from dir-locals.
+       (file-test--do-local-variables-test): Prevent dir-locals interfering.
+
+2013-11-04  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: Add a statement on the line after heredoc.
+       Move a now-successful example.
+
+       * automated/ruby-mode-tests.el: Remove outdated comment.
+
+2013-11-04  Glenn Morris  <rgm@gnu.org>
+
+       * automated/Makefile.in (abs_srcdir): Remove.
+       (emacs): Unset EMACSLOADPATH.
+       (.el.elc, check): Use -L to append srcdir to load-path.
+
+2013-11-02  Glenn Morris  <rgm@gnu.org>
+
+       * automated/Makefile.in (top_builddir, abs_test, abs_lispsrc, lisp)
+       (test, abs_top_srcdir, abs_top_builddir): Remove variables.
+       (abs_srcdir): New, set by configure.
+       (EMACS): Use a relative file name.
+       (emacs): Use abs_srcdir rather than abs_lispsrc, abs_test.
+       (lisp-compile): Remove (assume it's up-to-date).
+       (compile-main): Do not run lisp-compile.
+       (compile-main, compile-clean, compile-always, bootstrap-clean)
+       (check): Use srcdir rather than $test.  Check cd return value.
+       Use --chdir.
+       (doit, compile, compile-always): Remove stuff copied from lisp/.
+       (all, check, bootstrap-clean, distclean, maintainer-clean): PHONY.
+
+2013-10-31  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/ert-tests.el (ert-test-stats-set-test-and-result):
+       Add a skipping test.
+
+2013-10-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * indent/prolog.prolog: Test alignment of ->; with operator at bol.
+
+       * indent/css-mode.css (.x2): Test alignement inside braces.
+
+2013-10-26  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: New failing example.
+
+       * automated/ruby-mode-tests.el (ruby-toggle-block-to-brace):
+       Fix the test, in respect to adding the space after the curly.
+
+2013-10-24  Michael Albinus  <michael.albinus@gmx.de>
+
+       * automated/ert-tests.el (ert-test-skip-unless): New test case.
+       (ert-test-deftest): Adapt test for changed macro expansion.
+       (ert-test-run-tests-interactively):
+       * automated/ert-x-tests.el (ert-test-run-tests-interactively-2):
+       Add a skipping test.
+
+       * automated/file-notify-tests.el (top): Do not require tramp-sh.el.
+       (file-notify--test-local-enabled): Make it a function.  Check also
+       for `file-remote-p' of `temporary-file-directory'.
+       (file-notify--test-remote-enabled-checked): New defvar.
+       (file-notify--test-remote-enabled): Rewrite.  Do not use Tramp
+       internal functions.  Cache result.
+       (file-notify--deftest-remote, file-notify-test00-availability)
+       (file-notify-test01-add-watch, file-notify-test02-events)
+       (file-notify-test03-autorevert): Add checks with `skip_unless'.
+       (file-notify-test-all): Do not check `file-notify--test-local-enabled'.
+
+2013-10-24  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: Fix syntax error in the latest example.
+
+2013-10-23  Glenn Morris  <rgm@gnu.org>
+
+       * automated/Makefile.in (abs_top_srcdir, top_builddir):
+       New, set by configure.
+       (top_srcdir): Remove.
+       (abs_test, abs_lispsrc): New.
+       (lisp): No longer absolute.
+       (emacs, lisp-compile, compile, compile-always):
+       Quote entities that might contain whitespace.
+
+2013-10-22  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: Move two examples to "working" section, add one
+       more.
+
+2013-10-21  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * indent/ruby.rb: New examples for indentation of blocks.
+       Example of hash inside parens that inflooped before the present commit.
+
 2013-10-17  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * test/automated/timer-tests.el: New file.  Tests that (sit-for 0)
index bf8e62f77cda777a010910303b4e30fae7e651aa..617768995f1694417ee6eabf250c154a4c9eff0d 100644 (file)
 SHELL = @SHELL@
 
 srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-abs_top_builddir = @abs_top_builddir@
-test = $(srcdir)
 VPATH = $(srcdir)
-lispsrc = $(top_srcdir)/lisp
-lisp = ${abs_top_builddir}/lisp
 
-# You can specify a different executable on the make command line,
-# e.g. "make EMACS=../src/emacs ...".
-
-# We sometimes change directory before running Emacs (typically when
-# building out-of-tree, we chdir to the source directory), so we need
-# to use an absolute file name.
-EMACS = ${abs_top_builddir}/src/emacs
+# We never change directory before running Emacs, so a relative file
+# name is fine, and makes life easier.  If we need to change
+# directory, we can use emacs --chdir.
+EMACS = ../../src/emacs
 
 # Command line flags for Emacs.
+EMACSOPT = -batch --no-site-file --no-site-lisp -L :$(srcdir)
 
-EMACSOPT = -batch --no-site-file --no-site-lisp
-
-# Extra flags to pass to the byte compiler
+# Extra flags to pass to the byte compiler.
 BYTE_COMPILE_EXTRA_FLAGS =
-# For example to not display the undefined function warnings you can use this:
-# BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
-# The example above is just for developers, it should not be used by default.
 
 # The actual Emacs command run in the targets below.
-emacs = EMACSLOADPATH=$(lispsrc):$(test) LC_ALL=C $(EMACS) $(EMACSOPT)
+# Prevent any setting of EMACSLOADPATH in user environment causing problems.
+emacs = unset EMACSLOADPATH; \
+       LC_ALL=C EMACS_TEST_DIRECTORY=$(srcdir) "$(EMACS)" $(EMACSOPT)
 
 # Common command to find subdirectories
-setwins=subdirs=`find . -type d -print`; \
-       for file in $$subdirs; do \
-          case $$file in */.* | */.*/* | */=* | ./data* ) ;; \
+setwins=for file in `find $(srcdir) -type d -print`; do \
+          case $$file in $(srcdir)*/data* | $(srcdir)*/flymake* ) ;; \
                *) wins="$$wins$${wins:+ }$$file" ;; \
           esac; \
         done
 
-all: check
-
-doit:
+.PHONY: all check
 
+all: check
 
-# Files MUST be compiled one by one. If we compile several files in a
-# row (i.e., in the same instance of Emacs) we can't make sure that
-# the compilation environment is clean.  We also set the load-path of
-# the Emacs used for compilation to the current directory and its
-# subdirectories, to make sure require's and load's in the files being
-# compiled find the right files.
+# The compilation stuff is copied from lisp/Makefile - see comments there.
 
 .SUFFIXES: .elc .el
 
-# An old-fashioned suffix rule, which, according to the GNU Make manual,
-# cannot have prerequisites.
 .el.elc:
        @echo Compiling $<
        @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
 
-.PHONY: lisp-compile compile-main compile compile-always
 
-lisp-compile:
-       cd $(lisp); $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
+.PHONY: compile-targets compile-main compile-clean
 
-# In `compile-main' we could directly do
-#    ... | xargs $(MAKE) $(MFLAGS) EMACS="$(EMACS)"
-# and it works, but it generates a lot of messages like
-#    make[2]: « gnus/gnus-mlspl.elc » is up to date.
-# so instead, we use "xargs echo" to split the list of file into manageable
-# chunks and then use an intermediate `compile-targets' target so the
-# actual targets (the .elc files) are not mentioned as targets on the
-# make command line.
-
-
-.PHONY: compile-targets
 # TARGETS is set dynamically in the recursive call from `compile-main'.
 compile-targets: $(TARGETS)
 
 # Compile all the Elisp files that need it.  Beware: it approximates
 # `no-byte-compile', so watch out for false-positives!
-compile-main: compile-clean lisp-compile
-       @(cd $(test); $(setwins); \
+compile-main: compile-clean
+       @$(setwins); \
        els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
        for el in $$els; do \
          test -f $$el || continue; \
          test ! -f $${el}c && GREP_OPTIONS= grep '^;.*no-byte-compile: t' $$el > /dev/null && continue; \
          echo "$${el}c"; \
-       done | xargs echo) | \
+       done | xargs echo | \
        while read chunk; do \
          $(MAKE) $(MFLAGS) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \
        done
 
-.PHONY: compile-clean
 # Erase left-over .elc files that do not have a corresponding .el file.
 compile-clean:
-       @cd $(test); $(setwins); \
+       @$(setwins); \
        elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
        for el in $$(echo $$elcs | sed -e 's/\.elc/\.el/g'); do \
          if test -f "$$el" -o \! -f "$${el}c"; then :; else \
@@ -121,32 +88,20 @@ compile-clean:
          fi \
        done
 
-# Compile all Lisp files, but don't recompile those that are up to
-# date.  Some .el files don't get compiled because they set the
-# local variable no-byte-compile.
-# Calling make recursively because suffix rule cannot have prerequisites.
-# Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
-# sub-makes that run rules that use it, for the sake of some non-GNU makes.
-compile: $(LOADDEFS) autoloads compile-first
-       $(MAKE) $(MFLAGS) compile-main EMACS=$(EMACS)
-
-# Compile all Lisp files.  This is like `compile' but compiles files
-# unconditionally.  Some files don't actually get compiled because they
-# set the local variable no-byte-compile.
-compile-always: doit
-       cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
-       $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
+
+.PHONY: bootstrap-clean distclean maintainer-clean
 
 bootstrap-clean:
-       cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
+       -cd $(srcdir) && rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
 
 distclean:
-       -rm -f ./Makefile
+       rm -f Makefile
 
 maintainer-clean: distclean bootstrap-clean
 
+
 check: compile-main
-       @(cd $(test); $(setwins); \
+       @$(setwins); \
        pattern=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
        for el in $$pattern; do \
          test -f $$el || continue; \
@@ -154,6 +109,6 @@ check: compile-main
          els="$$els $$el"; \
        done; \
        echo Testing $$els; \
-       $(emacs) $$args -f ert-run-tests-batch-and-exit)
+       $(emacs) $$args -f ert-run-tests-batch-and-exit
 
 # Makefile ends here.
index 144f0bc919dc171c12700f1b2db521d2c10376db..52a3eb0c529b80805b26bcf1e0d5e824c817bac4 100644 (file)
@@ -885,9 +885,6 @@ Subclasses to override slot attributes.")
   (should (= (length (eieio-build-class-alist opt-test1 nil)) 2))
   (should (= (length (eieio-build-class-alist opt-test1 t)) 1)))
 
-(ert-deftest eieio-test-37-persistent-classes ()
-  (load-file "eieio-test-persist.el"))
-
 (provide 'eieio-tests)
 
 ;;; eieio-tests.el ends here
index a2be534c25cbf1bb45ec2fb71a08a5ae2425023b..2561942b83dbeb49e5f86661957d4ec4258e09d3 100644 (file)
@@ -294,6 +294,20 @@ failed or if there was a problem."
                   "the error signaled was a subtype of the expected type")))))
     ))
 
+(ert-deftest ert-test-skip-unless ()
+  ;; Don't skip.
+  (let ((test (make-ert-test :body (lambda () (skip-unless t)))))
+    (let ((result (ert-run-test test)))
+      (should (ert-test-passed-p result))))
+  ;; Skip.
+  (let ((test (make-ert-test :body (lambda () (skip-unless nil)))))
+    (let ((result (ert-run-test test)))
+      (should (ert-test-skipped-p result))))
+  ;; Skip in case of error.
+  (let ((test (make-ert-test :body (lambda () (skip-unless (error "Foo"))))))
+    (let ((result (ert-run-test test)))
+      (should (ert-test-skipped-p result)))))
+
 (defmacro ert--test-my-list (&rest args)
   "Don't use this.  Instead, call `list' with ARGS, it does the same thing.
 
@@ -332,23 +346,31 @@ This macro is used to test if macroexpansion in `should' works."
 
 (ert-deftest ert-test-deftest ()
   (should (equal (macroexpand '(ert-deftest abc () "foo" :tags '(bar)))
-                 '(progn
-                    (ert-set-test 'abc
-                                  (make-ert-test :name 'abc
-                                                 :documentation "foo"
-                                                 :tags '(bar)
-                                                 :body (lambda ())))
-                    (push '(ert-deftest . abc) current-load-list)
-                    'abc)))
+                '(progn
+                   (ert-set-test 'abc
+                                 (progn
+                                   (vector 'cl-struct-ert-test 'abc "foo"
+                                           #'(lambda nil)
+                                           nil ':passed
+                                           '(bar))))
+                   (setq current-load-list
+                         (cons
+                          '(ert-deftest . abc)
+                          current-load-list))
+                   'abc)))
   (should (equal (macroexpand '(ert-deftest def ()
                                  :expected-result ':passed))
-                 '(progn
-                    (ert-set-test 'def
-                                  (make-ert-test :name 'def
-                                                 :expected-result-type ':passed
-                                                 :body (lambda ())))
-                    (push '(ert-deftest . def) current-load-list)
-                    'def)))
+                '(progn
+                   (ert-set-test 'def
+                                 (progn
+                                   (vector 'cl-struct-ert-test 'def nil
+                                           #'(lambda nil)
+                                           nil ':passed 'nil)))
+                   (setq current-load-list
+                         (cons
+                          '(ert-deftest . def)
+                          current-load-list))
+                   'def)))
   ;; :documentation keyword is forbidden
   (should-error (macroexpand '(ert-deftest ghi ()
                                 :documentation "foo"))))
@@ -543,7 +565,10 @@ This macro is used to test if macroexpansion in `should' works."
                                      :body (lambda () (ert-pass))))
         (failing-test (make-ert-test :name 'failing-test
                                      :body (lambda () (ert-fail
-                                                       "failure message")))))
+                                                       "failure message"))))
+        (skipped-test (make-ert-test :name 'skipped-test
+                                     :body (lambda () (ert-skip
+                                                       "skip message")))))
     (let ((ert-debug-on-error nil))
       (let* ((buffer-name (generate-new-buffer-name " *ert-test-run-tests*"))
              (messages nil)
@@ -554,23 +579,26 @@ This macro is used to test if macroexpansion in `should' works."
           (unwind-protect
               (let ((case-fold-search nil))
                 (ert-run-tests-interactively
-                 `(member ,passing-test ,failing-test) buffer-name
+                 `(member ,passing-test ,failing-test, skipped-test) buffer-name
                  mock-message-fn)
                 (should (equal messages `(,(concat
-                                            "Ran 2 tests, 1 results were "
-                                            "as expected, 1 unexpected"))))
+                                            "Ran 3 tests, 1 results were "
+                                            "as expected, 1 unexpected, "
+                                           "1 skipped"))))
                 (with-current-buffer buffer-name
                   (goto-char (point-min))
                   (should (equal
                            (buffer-substring (point-min)
                                              (save-excursion
-                                               (forward-line 4)
+                                               (forward-line 5)
                                                (point)))
                            (concat
-                            "Selector: (member <passing-test> <failing-test>)\n"
-                            "Passed: 1\n"
-                            "Failed: 1 (1 unexpected)\n"
-                            "Total:  2/2\n")))))
+                            "Selector: (member <passing-test> <failing-test> "
+                           "<skipped-test>)\n"
+                            "Passed:  1\n"
+                            "Failed:  1 (1 unexpected)\n"
+                           "Skipped: 1\n"
+                            "Total:   3/3\n")))))
             (when (get-buffer buffer-name)
               (kill-buffer buffer-name))))))))
 
@@ -749,41 +777,57 @@ This macro is used to test if macroexpansion in `should' works."
          (stats (ert--make-stats (list test-1 test-2) 't))
          (failed (make-ert-test-failed :condition nil
                                        :backtrace nil
-                                       :infos nil)))
+                                       :infos nil))
+         (skipped (make-ert-test-skipped :condition nil
+                                        :backtrace nil
+                                        :infos nil)))
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 0 (ert-stats-completed stats)))
     (should (eql 0 (ert-stats-completed-expected stats)))
     (should (eql 0 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 0 test-1 (make-ert-test-passed))
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 1 (ert-stats-completed stats)))
     (should (eql 1 (ert-stats-completed-expected stats)))
     (should (eql 0 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 0 test-1 failed)
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 1 (ert-stats-completed stats)))
     (should (eql 0 (ert-stats-completed-expected stats)))
     (should (eql 1 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 0 test-1 nil)
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 0 (ert-stats-completed stats)))
     (should (eql 0 (ert-stats-completed-expected stats)))
     (should (eql 0 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 0 test-3 failed)
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 1 (ert-stats-completed stats)))
     (should (eql 0 (ert-stats-completed-expected stats)))
     (should (eql 1 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 1 test-2 (make-ert-test-passed))
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 2 (ert-stats-completed stats)))
     (should (eql 1 (ert-stats-completed-expected stats)))
     (should (eql 1 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
     (ert--stats-set-test-and-result stats 0 test-1 (make-ert-test-passed))
     (should (eql 2 (ert-stats-total stats)))
     (should (eql 2 (ert-stats-completed stats)))
     (should (eql 2 (ert-stats-completed-expected stats)))
-    (should (eql 0 (ert-stats-completed-unexpected stats)))))
+    (should (eql 0 (ert-stats-completed-unexpected stats)))
+    (should (eql 0 (ert-stats-skipped stats)))
+    (ert--stats-set-test-and-result stats 0 test-1 skipped)
+    (should (eql 2 (ert-stats-total stats)))
+    (should (eql 2 (ert-stats-completed stats)))
+    (should (eql 1 (ert-stats-completed-expected stats)))
+    (should (eql 0 (ert-stats-completed-unexpected stats)))
+    (should (eql 1 (ert-stats-skipped stats)))))
 
 
 (provide 'ert-tests)
index dc67fe34833cfe744edecb81879061039fcf5832..0a657fd4a848a0c5b1f5d54247d8239b9e7532f2 100644 (file)
                                                                      'a 'b))
                                                 (ert-fail
                                                  "failure message")))))
+         (skipped-test (make-ert-test :name 'skipped-test
+                                      :body (lambda () (ert-skip
+                                                       "skip message"))))
          (ert-debug-on-error nil)
          (buffer-name (generate-new-buffer-name "*ert-test-run-tests*"))
          (messages nil)
             (push (apply #'format format-string args) messages))))
     (cl-flet ((expected-string (with-font-lock-p)
                 (ert-propertized-string
-                 "Selector: (member <passing-test> <failing-test>)\n"
-                 "Passed: 1\n"
-                 "Failed: 1 (1 unexpected)\n"
-                 "Total:  2/2\n\n"
+                 "Selector: (member <passing-test> <failing-test> "
+                "<skipped-test>)\n"
+                 "Passed:  1\n"
+                 "Failed:  1 (1 unexpected)\n"
+                 "Skipped: 1\n"
+                 "Total:   3/3\n\n"
                  "Started at:\n"
                  "Finished.\n"
                  "Finished at:\n\n"
                             face ,(if with-font-lock-p
                                       'ert-test-result-unexpected
                                     'button))
-                 ".F" nil "\n\n"
+                 ".Fs" nil "\n\n"
                  `(category ,(button-category-symbol
                               'ert--results-expand-collapse-button)
                             button (t)
         (unwind-protect
             (let ((case-fold-search nil))
               (ert-run-tests-interactively
-               `(member ,passing-test ,failing-test) buffer-name
+               `(member ,passing-test ,failing-test ,skipped-test) buffer-name
                mock-message-fn)
               (should (equal messages `(,(concat
-                                          "Ran 2 tests, 1 results were "
-                                          "as expected, 1 unexpected"))))
+                                          "Ran 3 tests, 1 results were "
+                                          "as expected, 1 unexpected, "
+                                         "1 skipped"))))
               (with-current-buffer buffer-name
                 (font-lock-mode 0)
                 (should (ert-equal-including-properties
index 9f552ee7ab1f0f6304fc7cffd0f1bebe3a590834..e0852fb5705eab13ac491d56c1aa07db801b526d 100644 (file)
 (defvar file-notify--test-event nil)
 
 (require 'tramp)
-(require 'tramp-sh)
 (setq tramp-verbose 0
       tramp-message-show-message nil)
 (when noninteractive (defalias 'tramp-read-passwd 'ignore))
+;; This shall happen on hydra only.
+(when (getenv "NIX_STORE")
+  (add-to-list 'tramp-remote-path 'tramp-own-remote-path))
 
 ;; We do not want to try and fail `file-notify-add-watch'.
-(defconst file-notify--test-local-enabled file-notify--library
-  "Whether local file notification is enabled.")
+(defun file-notify--test-local-enabled ()
+  "Whether local file notification is enabled.
+This is needed for local `temporary-file-directory' only, in the
+remote case we return always `t'."
+  (or file-notify--library
+      (not (file-remote-p temporary-file-directory))))
+
+(defvar file-notify--test-remote-enabled-checked nil
+  "Cached result of `file-notify--test-remote-enabled'.
+If the function did run, the value is a cons cell, the `cdr'
+being the result.")
 
-;; We need also a check on the remote side, w/o adding a file monitor.
 (defun file-notify--test-remote-enabled ()
   "Whether remote file notification is enabled."
-  (ignore-errors
-    (and (file-remote-p file-notify-test-remote-temporary-file-directory)
-        (file-directory-p file-notify-test-remote-temporary-file-directory)
-        (file-writable-p file-notify-test-remote-temporary-file-directory)
-        ;; Extracted from tramp-sh-handle-file-notify-add-watch.
-        ;; Even though the "remote" system is just ssh@localhost,
-        ;; the PATH might not be the same as the "local" PATH.
-        ;; Eg this seems to be the case on hydra.nixos.org.
-        ;; Without this, tests fail with:
-        ;; "No file notification program found on /ssh:localhost:"
-        ;; Try to fix PATH instead?
-        (with-parsed-tramp-file-name
-            file-notify-test-remote-temporary-file-directory nil
-            (or (tramp-get-remote-gvfs-monitor-dir v)
-                (tramp-get-remote-inotifywait v))))))
+  (unless (consp file-notify--test-remote-enabled-checked)
+    (let (desc)
+      (unwind-protect
+         (ignore-errors
+           (and
+            (file-remote-p file-notify-test-remote-temporary-file-directory)
+            (file-directory-p file-notify-test-remote-temporary-file-directory)
+            (file-writable-p file-notify-test-remote-temporary-file-directory)
+            (setq desc
+                  (file-notify-add-watch
+                   file-notify-test-remote-temporary-file-directory
+                   '(change) 'ignore))))
+       ;; Unwind forms.
+       (setq file-notify--test-remote-enabled-checked (cons t desc))
+       (when desc (file-notify-rm-watch desc)))))
+  ;; Return result.
+  (cdr file-notify--test-remote-enabled-checked))
 
 (defmacro file-notify--deftest-remote (test docstring)
   "Define ert `TEST-remote' for remote files."
-  `(when (and (file-notify--test-remote-enabled) (ert-get-test ',test))
-     ;; Define the test.
-     (ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
-       ,docstring
-       (let* ((temporary-file-directory
-              file-notify-test-remote-temporary-file-directory)
-             (ert-test (ert-get-test ',test))
-             (most-recent-result (ert-test-most-recent-result ert-test))
-             result)
-        (unwind-protect
-            (progn
-              (setq result
-                    (condition-case err
-                        (ert-run-test ert-test)
-                      ((error quit)
-                       (ert-fail err))))
-              (when (ert-test-failed-p result)
-                (ert-fail
-                 (cadr (ert-test-result-with-condition-condition result)))))
-          ;; Reset status of TEST.
-          (setf (ert-test-most-recent-result ert-test) most-recent-result))))))
+  `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
+     ,docstring
+     (let* ((temporary-file-directory
+            file-notify-test-remote-temporary-file-directory)
+           (ert-test (ert-get-test ',test)))
+       (skip-unless (file-notify--test-remote-enabled))
+       ;; The local test could have passed, skipped, or quit.  All of
+       ;; these results should not prevent us to run the remote test.
+       ;; That's why we skip only for failed local tests.
+       (skip-unless
+       (not (ert-test-failed-p (ert-test-most-recent-result ert-test))))
+       (funcall (ert-test-body ert-test)))))
 
 (ert-deftest file-notify-test00-availability ()
   "Test availability of `file-notify'."
+  (skip-unless (file-notify--test-local-enabled))
   (let (desc)
     ;; Check, that different valid parameters are accepted.
     (should (setq desc (file-notify-add-watch
 (file-notify--deftest-remote file-notify-test00-availability
   "Test availability of `file-notify' for remote files.")
 
-(when file-notify--test-local-enabled
+(ert-deftest file-notify-test01-add-watch ()
+  "Check `file-notify-add-watch'."
+  (skip-unless (file-notify--test-local-enabled))
+  (let (desc)
+    ;; Check, that different valid parameters are accepted.
+    (should (setq desc (file-notify-add-watch
+                       temporary-file-directory '(change) 'ignore)))
+    (file-notify-rm-watch desc)
+    (should (setq desc (file-notify-add-watch
+                       temporary-file-directory
+                       '(attribute-change) 'ignore)))
+    (file-notify-rm-watch desc)
+    (should (setq desc (file-notify-add-watch
+                       temporary-file-directory
+                       '(change attribute-change) 'ignore)))
+    (file-notify-rm-watch desc)
 
-  (ert-deftest file-notify-test01-add-watch ()
-    "Check `file-notify-add-watch'."
-    (let (desc)
-      ;; Check, that different valid parameters are accepted.
-      (should (setq desc (file-notify-add-watch
-                         temporary-file-directory '(change) 'ignore)))
-      (file-notify-rm-watch desc)
-      (should (setq desc (file-notify-add-watch
-                         temporary-file-directory
-                         '(attribute-change) 'ignore)))
-      (file-notify-rm-watch desc)
-      (should (setq desc (file-notify-add-watch
-                         temporary-file-directory
-                         '(change attribute-change) 'ignore)))
-      (file-notify-rm-watch desc)
+    ;; Check error handling.
+    (should-error (file-notify-add-watch 1 2 3 4)
+                 :type 'wrong-number-of-arguments)
+    (should
+     (equal (should-error (file-notify-add-watch 1 2 3))
+           '(wrong-type-argument 1)))
+    (should
+     (equal (should-error (file-notify-add-watch
+                          temporary-file-directory 2 3))
+           '(wrong-type-argument 2)))
+    (should
+     (equal (should-error (file-notify-add-watch
+                          temporary-file-directory '(change) 3))
+           '(wrong-type-argument 3)))))
 
-      ;; Check error handling.
-      (should-error (file-notify-add-watch 1 2 3 4)
-                   :type 'wrong-number-of-arguments)
-      (should
-       (equal (should-error (file-notify-add-watch 1 2 3))
-             '(wrong-type-argument 1)))
-      (should
-       (equal (should-error (file-notify-add-watch
-                            temporary-file-directory 2 3))
-             '(wrong-type-argument 2)))
-      (should
-       (equal (should-error (file-notify-add-watch
-                            temporary-file-directory '(change) 3))
-             '(wrong-type-argument 3)))))
-
-  (file-notify--deftest-remote file-notify-test01-add-watch
-    "Check `file-notify-add-watch' for remote files.")
-  ) ;; file-notify--test-local-enabled
+(file-notify--deftest-remote file-notify-test01-add-watch
+  "Check `file-notify-add-watch' for remote files.")
 
 (defun file-notify--test-event-test ()
   "Ert test function to be called by `file-notify--test-event-handler'.
@@ -172,117 +174,118 @@ Save the result in `file-notify--test-results', for later analysis."
   (expand-file-name
    (make-temp-name "file-notify-test") temporary-file-directory))
 
-(when file-notify--test-local-enabled
+(ert-deftest file-notify-test02-events ()
+  "Check file creation/removal notifications."
+  (skip-unless (file-notify--test-local-enabled))
+  (let (desc)
+    (unwind-protect
+       (progn
+         (setq file-notify--test-results nil
+               file-notify--test-tmpfile (file-notify--test-make-temp-name)
+               file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
+               desc
+               (file-notify-add-watch
+                file-notify--test-tmpfile
+                '(change) 'file-notify--test-event-handler))
+
+         ;; Check creation and removal.
+         (write-region
+          "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (delete-file file-notify--test-tmpfile)
+
+         ;; Check copy and rename.
+         (write-region
+          "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+         (delete-file file-notify--test-tmpfile)
+         (delete-file file-notify--test-tmpfile1)
+
+         (write-region
+          "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
+         (delete-file file-notify--test-tmpfile1))
+
+      ;; Wait for events, and exit.
+      (sit-for 5 'nodisplay)
+      (file-notify-rm-watch desc)
+      (ignore-errors (delete-file file-notify--test-tmpfile))
+      (ignore-errors (delete-file file-notify--test-tmpfile1))))
 
-  (ert-deftest file-notify-test02-events ()
-    "Check file creation/removal notifications."
-    (let (desc)
-      (unwind-protect
-         (progn
-           (setq file-notify--test-results nil
-                 file-notify--test-tmpfile (file-notify--test-make-temp-name)
-                 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)
-                 desc
-                 (file-notify-add-watch
-                  file-notify--test-tmpfile
-                  '(change) 'file-notify--test-event-handler))
-
-           ;; Check creation and removal.
-           (write-region "any text" nil file-notify--test-tmpfile)
-           (delete-file file-notify--test-tmpfile)
-
-           ;; Check copy and rename.
-           (write-region "any text" nil file-notify--test-tmpfile)
-           (copy-file file-notify--test-tmpfile file-notify--test-tmpfile1)
-           (delete-file file-notify--test-tmpfile)
-           (delete-file file-notify--test-tmpfile1)
-
-           (write-region "any text" nil file-notify--test-tmpfile)
-           (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
-           (delete-file file-notify--test-tmpfile1))
-
-       ;; Wait for events, and exit.
-       (sit-for 5 'nodisplay)
-       (file-notify-rm-watch desc)
-       (ignore-errors (delete-file file-notify--test-tmpfile))
-       (ignore-errors (delete-file file-notify--test-tmpfile1))))
-
-    (dolist (result file-notify--test-results)
-      ;(message "%s" (ert-test-result-messages result))
-      (when (ert-test-failed-p result)
-       (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
-
-  (file-notify--deftest-remote file-notify-test02-events
-    "Check file creation/removal notifications for remote files.")
-  ) ;; file-notify--test-local-enabled
+  (dolist (result file-notify--test-results)
+    ;(message "%s" (ert-test-result-messages result))
+    (when (ert-test-failed-p result)
+      (ert-fail (cadr (ert-test-result-with-condition-condition result))))))
+
+(file-notify--deftest-remote file-notify-test02-events
+  "Check file creation/removal notifications for remote files.")
 
 ;; autorevert runs only in interactive mode.
 (defvar auto-revert-remote-files)
 (setq auto-revert-remote-files t)
 (require 'autorevert)
-(when (and file-notify--test-local-enabled (null noninteractive))
 
-  (ert-deftest file-notify-test03-autorevert ()
-    "Check autorevert via file notification.
+(ert-deftest file-notify-test03-autorevert ()
+  "Check autorevert via file notification.
 This test is skipped in batch mode."
-    ;; `auto-revert-buffers' runs every 5".  And we must wait, until
-    ;; the file has been reverted.
-    (let ((timeout 10)
-         buf)
-      (unwind-protect
-         (progn
-           (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
-
-           (write-region "any text" nil file-notify--test-tmpfile)
-           (setq buf (find-file-noselect file-notify--test-tmpfile))
-           (with-current-buffer buf
-             (should (string-equal (buffer-string) "any text"))
-             (auto-revert-mode 1)
-
-             ;; `auto-revert-buffers' runs every 5".
+  (skip-unless (file-notify--test-local-enabled))
+  (skip-unless (not noninteractive))
+  ;; `auto-revert-buffers' runs every 5".  And we must wait, until the
+  ;; file has been reverted.
+  (let ((timeout 10)
+       buf)
+    (unwind-protect
+       (progn
+         (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+
+         (write-region
+          "any text" nil file-notify--test-tmpfile nil 'no-message)
+         (setq buf (find-file-noselect file-notify--test-tmpfile))
+         (with-current-buffer buf
+           (should (string-equal (buffer-string) "any text"))
+           (auto-revert-mode 1)
+
+           ;; `auto-revert-buffers' runs every 5".
+           (with-timeout (timeout (ignore))
+             (while (null auto-revert-notify-watch-descriptor)
+               (sit-for 0.1 'nodisplay)))
+
+           ;; Check, that file notification has been used.
+           (should auto-revert-mode)
+           (should auto-revert-use-notify)
+           (should auto-revert-notify-watch-descriptor)
+
+           ;; Modify file.  We wait for a second, in order to
+           ;; have another timestamp.
+           (sit-for 1)
+           (shell-command
+            (format "echo -n 'another text' >%s"
+                    (or (file-remote-p file-notify--test-tmpfile 'localname)
+                        file-notify--test-tmpfile)))
+
+           ;; Check, that the buffer has been reverted.
+           (with-current-buffer (get-buffer-create "*Messages*")
              (with-timeout (timeout (ignore))
-               (while (null auto-revert-notify-watch-descriptor)
-                 (sit-for 0.1 'nodisplay)))
-
-             ;; Check, that file notification has been used.
-             (should auto-revert-mode)
-             (should auto-revert-use-notify)
-             (should auto-revert-notify-watch-descriptor)
-
-             ;; Modify file.  We wait for a second, in order to
-             ;; have another timestamp.
-             (sit-for 1)
-             (shell-command
-              (format "echo -n 'another text' >%s"
-                      (or (file-remote-p file-notify--test-tmpfile 'localname)
-                          file-notify--test-tmpfile)))
-
-             ;; Check, that the buffer has been reverted.
-             (with-current-buffer (get-buffer-create "*Messages*")
-               (with-timeout (timeout (ignore))
-                 (while
-                     (null (string-match
-                            (format "Reverting buffer `%s'." (buffer-name buf))
-                            (buffer-string)))
-                   (sit-for 0.1 'nodisplay))))
-             (should (string-equal (buffer-string) "another text"))))
-
-       ;; Exit.
-       (ignore-errors (kill-buffer buf))
-       (ignore-errors (delete-file file-notify--test-tmpfile)))))
-
-  (file-notify--deftest-remote file-notify-test03-autorevert
-    "Check autorevert via file notification for remote files.
+               (while
+                   (null (string-match
+                          (format "Reverting buffer `%s'." (buffer-name buf))
+                          (buffer-string)))
+                 (sit-for 0.1 'nodisplay))))
+           (should (string-equal (buffer-string) "another text"))))
+
+      ;; Exit.
+      (ignore-errors (kill-buffer buf))
+      (ignore-errors (delete-file file-notify--test-tmpfile)))))
+
+(file-notify--deftest-remote file-notify-test03-autorevert
+  "Check autorevert via file notification for remote files.
 This test is skipped in batch mode.")
-  ) ;; (and file-notify--test-local-enabled (null noninteractive))
 
 (defun file-notify-test-all (&optional interactive)
   "Run all tests for \\[file-notify]."
   (interactive "p")
-  (when file-notify--test-local-enabled
-    (if interactive
-       (ert-run-tests-interactively "^file-notify-")
-      (ert-run-tests-batch "^file-notify-"))))
+  (if interactive
+      (ert-run-tests-interactively "^file-notify-")
+    (ert-run-tests-batch "^file-notify-")))
 
 (provide 'file-notify-tests)
 ;;; file-notify-tests.el ends here
index 8ce2ed7230c30a4cce5043434ff695584e31fd23..6ce1cbc24575a94de8beaa38657d9436700a008e 100644 (file)
@@ -51,7 +51,7 @@
      (:all nil    (eq files-test-result nil))
      (:all maybe  (eq files-test-result t)) ; This combination is ambiguous.
      (maybe t     (eq files-test-result 'query))
-     (maybe nil   (eq files-test-result 'query))
+     (maybe nil   (eq files-test-result nil))
      (maybe maybe (eq files-test-result 'query)))
     ;; Unsafe local variable value
     (("files-test-result: t")
@@ -127,6 +127,8 @@ form.")
          files-test-safe-result nil)
     (let ((enable-local-variables (nth 0 test-settings))
          (enable-local-eval      (nth 1 test-settings))
+         ;; Prevent any dir-locals file interfering with the tests.
+         (enable-dir-local-variables nil)
          (files-test-queried nil))
       (hack-local-variables)
       (eval (nth 2 test-settings)))))
index 03a8fb08bc590ab49b6c3ebf1b4ac066eaa07603..34a7b4f369634801b26091ae48bd3ff9c1332023 100644 (file)
 (require 'ert)
 (require 'flymake)
 
+(defvar flymake-tests-data-directory
+  (expand-file-name "flymake/warnpred" (getenv "EMACS_TEST_DIRECTORY"))
+  "Directory containing flymake test data.")
+
 \f
 ;; Warning predicate
 (defun flymake-tests--current-face (file predicate)
-  (let ((buffer (find-file-noselect file)))
+  (let ((buffer (find-file-noselect
+                 (expand-file-name file flymake-tests-data-directory))))
     (unwind-protect
-        (with-current-buffer (find-file-noselect file)
+        (with-current-buffer buffer
           (setq-local flymake-warning-predicate predicate)
           (goto-char (point-min))
           (flymake-mode 1)
 
 (ert-deftest warning-predicate-rx-gcc ()
   "Test GCC warning via regexp predicate."
-  :expected-result (if (executable-find "gcc") :passed :failed)
+  (skip-unless (executable-find "gcc"))
   (should (eq 'flymake-warnline
-              (flymake-tests--current-face
-               "flymake/warnpred/test.c"
-               "^[Ww]arning"))))
+              (flymake-tests--current-face "test.c" "^[Ww]arning"))))
 
 (ert-deftest warning-predicate-function-gcc ()
   "Test GCC warning via function predicate."
-  :expected-result (if (and (executable-find "gcc") (executable-find "make"))
-                       :passed
-                     :failed)
+  (skip-unless (and (executable-find "gcc") (executable-find "make")))
   (should (eq 'flymake-warnline
-              (flymake-tests--current-face
-               "flymake/warnpred/test.c"
+              (flymake-tests--current-face "test.c"
                (lambda (msg) (string-match "^[Ww]arning" msg))))))
 
 (ert-deftest warning-predicate-rx-perl ()
   "Test perl warning via regular expression predicate."
-  :expected-result (if (executable-find "perl") :passed :failed)
+  (skip-unless (executable-find "perl"))
   (should (eq 'flymake-warnline
-              (flymake-tests--current-face
-               "flymake/warnpred/test.pl"
-               "^Scalar value"))))
+              (flymake-tests--current-face "test.pl" "^Scalar value"))))
 
 (ert-deftest warning-predicate-function-perl ()
   "Test perl warning via function predicate."
-  :expected-result (if (executable-find "perl") :passed :failed)
+  (skip-unless (executable-find "perl"))
   (should (eq 'flymake-warnline
               (flymake-tests--current-face
-               "flymake/warnpred/test.pl"
+               "test.pl"
                (lambda (msg) (string-match "^Scalar value" msg))))))
 
 (provide 'flymake-tests)
index 973af0d46c7508e1e790d3213835cade5233ffb8..54cd534e8ce35892fd8c582e19f04f71bfdc8114 100644 (file)
@@ -95,8 +95,7 @@ text.
 
 (ert-deftest info-xref-test-makeinfo ()
   "Test that info-xref can parse basic makeinfo output."
-  :expected-result (if (executable-find "makeinfo") :passed :failed)
-  (should (executable-find "makeinfo"))
+  (skip-unless (executable-find "makeinfo"))
   (let ((tempfile (make-temp-file "info-xref-test" nil ".texi"))
         (tempfile2 (make-temp-file "info-xref-test2" nil ".texi"))
         (errflag t))
diff --git a/test/automated/process-tests.el b/test/automated/process-tests.el
new file mode 100644 (file)
index 0000000..f694a34
--- /dev/null
@@ -0,0 +1,53 @@
+;;; process-tests.el --- Testing the process facilities
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+
+;; Timeout in seconds; the test fails if the timeout is reached.
+(defvar process-test-sentinel-wait-timeout 2.0)
+
+;; Start a process that exits immediately.  Call WAIT-FUNCTION,
+;; possibly multiple times, to wait for the process to complete.
+(defun process-test-sentinel-wait-function-working-p (wait-function)
+  (let ((proc (start-process "test" nil "bash" "-c" "exit 20"))
+       (sentinel-called nil)
+       (start-time (float-time)))
+    (set-process-sentinel proc (lambda (proc msg)
+                                (setq sentinel-called t)))
+    (while (not (or sentinel-called
+                   (> (- (float-time) start-time)
+                      process-test-sentinel-wait-timeout)))
+      (funcall wait-function))
+    (cl-assert (eq (process-status proc) 'exit))
+    (cl-assert (= (process-exit-status proc) 20))
+    sentinel-called))
+
+(ert-deftest process-test-sentinel-accept-process-output ()
+  (should (process-test-sentinel-wait-function-working-p
+           #'accept-process-output)))
+
+(ert-deftest process-test-sentinel-sit-for ()
+  (should
+   (process-test-sentinel-wait-function-working-p (lambda () (sit-for 0.01 t)))))
+
+(provide 'process-tests)
index dafe393377bee8d925c1a32ed59b6c15de68b3e5..e84f55be93df9c383729bfab4045d04374f772c1 100644 (file)
@@ -292,8 +292,8 @@ VALUES-PLIST is a list with alternating index and value elements."
     (should (string= "foo do |b|\nend" (buffer-string)))))
 
 (ert-deftest ruby-toggle-block-to-brace ()
-  (let ((pairs '((16 . "foo {|b| b + 2 }")
-                 (15 . "foo {|b|\n  b + 2\n}"))))
+  (let ((pairs '((17 . "foo { |b| b + 2 }")
+                 (16 . "foo { |b|\n  b + 2\n}"))))
     (dolist (pair pairs)
       (with-temp-buffer
         (let ((fill-column (car pair)))
@@ -309,6 +309,12 @@ VALUES-PLIST is a list with alternating index and value elements."
     (ruby-toggle-block)
     (should (string= "foo do |b|\n  b + 1\nend" (buffer-string)))))
 
+(ert-deftest ruby-toggle-block-with-interpolation ()
+  (ruby-with-temp-buffer "foo do\n  \"#{bar}\"\nend"
+    (beginning-of-line)
+    (ruby-toggle-block)
+    (should (string= "foo { \"#{bar}\" }" (buffer-string)))))
+
 (ert-deftest ruby-recognize-symbols-starting-with-at-character ()
   (ruby-assert-face ":@abc" 3 font-lock-constant-face))
 
@@ -585,8 +591,6 @@ VALUES-PLIST is a list with alternating index and value elements."
     (end-of-defun)
     (should (= 5 (line-number-at-pos)))))
 
-;; Tests below fail when using SMIE.
-
 (defvar ruby-sexp-test-example
   (ruby-test-string
    "class C
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el
new file mode 100644 (file)
index 0000000..2bb815b
--- /dev/null
@@ -0,0 +1,1203 @@
+;;; tramp-tests.el --- Tests of remote file access
+
+;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; Author: Michael Albinus <michael.albinus@gmx.de>
+
+;; This program is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see `http://www.gnu.org/licenses/'.
+
+;;; Commentary:
+
+;; The tests require a recent ert.el from Emacs 24.4.
+
+;; Some of the tests require access to a remote host files.  Set
+;; $TRAMP_TEST_TEMPORARY_FILE_DIRECTORY to a suitable value in order
+;; to overwrite the default value.  If you want to skip tests
+;; accessing a remote host, set this environment variable to
+;; "/dev/null" or whatever is appropriate on your system.
+
+;; When running the tests in batch mode, it must NOT require an
+;; interactive password prompt unless the environment variable
+;; $TRAMP_TEST_ALLOW_PASSWORD is set.
+
+;; A whole test run can be performed calling the command `tramp-test-all'.
+
+;;; Code:
+
+(require 'ert)
+(require 'tramp)
+
+;; There is no default value on w32 systems, which could work out of the box.
+(defconst tramp-test-temporary-file-directory
+  (cond
+   ((getenv "TRAMP_TEST_TEMPORARY_FILE_DIRECTORY"))
+   ((eq system-type 'windows-nt) null-device)
+   (t (format "/ssh::%s" temporary-file-directory)))
+  "Temporary directory for Tramp tests.")
+
+(setq tramp-verbose 0
+      tramp-message-show-message nil)
+
+;; Disable interactive passwords in batch mode.
+(when (and noninteractive (not (getenv "TRAMP_TEST_ALLOW_PASSWORD")))
+  (defalias 'tramp-read-passwd 'ignore))
+
+;; This shall happen on hydra only.
+(when (getenv "NIX_STORE")
+  (add-to-list 'tramp-remote-path 'tramp-own-remote-path))
+
+(defvar tramp--test-enabled-checked nil
+  "Cached result of `tramp--test-enabled'.
+If the function did run, the value is a cons cell, the `cdr'
+being the result.")
+
+(defun tramp--test-enabled ()
+  "Whether remote file access is enabled."
+  (unless (consp tramp--test-enabled-checked)
+    (setq
+     tramp--test-enabled-checked
+     (cons
+      t (ignore-errors
+         (and
+          (file-remote-p tramp-test-temporary-file-directory)
+          (file-directory-p tramp-test-temporary-file-directory)
+          (file-writable-p tramp-test-temporary-file-directory))))))
+  ;; Return result.
+  (cdr tramp--test-enabled-checked))
+
+(defun tramp--test-make-temp-name ()
+  "Create a temporary file name for test."
+  (expand-file-name
+   (make-temp-name "tramp-test") tramp-test-temporary-file-directory))
+
+(ert-deftest tramp-test00-availability ()
+  "Test availability of Tramp functions."
+  :expected-result (if (tramp--test-enabled) :passed :failed)
+  (should (ignore-errors
+           (and
+            (file-remote-p tramp-test-temporary-file-directory)
+            (file-directory-p tramp-test-temporary-file-directory)
+            (file-writable-p tramp-test-temporary-file-directory)))))
+
+(ert-deftest tramp-test01-file-name-syntax ()
+  "Check remote file name syntax."
+  ;; Simple cases.
+  (should (tramp-tramp-file-p "/method::"))
+  (should (tramp-tramp-file-p "/host:"))
+  (should (tramp-tramp-file-p "/user@:"))
+  (should (tramp-tramp-file-p "/user@host:"))
+  (should (tramp-tramp-file-p "/method:host:"))
+  (should (tramp-tramp-file-p "/method:user@:"))
+  (should (tramp-tramp-file-p "/method:user@host:"))
+  (should (tramp-tramp-file-p "/method:user@email@host:"))
+
+  ;; Using a port.
+  (should (tramp-tramp-file-p "/host#1234:"))
+  (should (tramp-tramp-file-p "/user@host#1234:"))
+  (should (tramp-tramp-file-p "/method:host#1234:"))
+  (should (tramp-tramp-file-p "/method:user@host#1234:"))
+
+  ;; Using an IPv4 address.
+  (should (tramp-tramp-file-p "/1.2.3.4:"))
+  (should (tramp-tramp-file-p "/user@1.2.3.4:"))
+  (should (tramp-tramp-file-p "/method:1.2.3.4:"))
+  (should (tramp-tramp-file-p "/method:user@1.2.3.4:"))
+
+  ;; Using an IPv6 address.
+  (should (tramp-tramp-file-p "/[]:"))
+  (should (tramp-tramp-file-p "/[::1]:"))
+  (should (tramp-tramp-file-p "/user@[::1]:"))
+  (should (tramp-tramp-file-p "/method:[::1]:"))
+  (should (tramp-tramp-file-p "/method:user@[::1]:"))
+
+  ;; Local file name part.
+  (should (tramp-tramp-file-p "/host:/:"))
+  (should (tramp-tramp-file-p "/method:::"))
+  (should (tramp-tramp-file-p "/method::/path/to/file"))
+  (should (tramp-tramp-file-p "/method::file"))
+
+  ;; Multihop.
+  (should (tramp-tramp-file-p "/method1:|method2::"))
+  (should (tramp-tramp-file-p "/method1:host1|host2:"))
+  (should (tramp-tramp-file-p "/method1:host1|method2:host2:"))
+  (should (tramp-tramp-file-p "/method1:user1@host1|method2:user2@host2:"))
+  (should (tramp-tramp-file-p
+          "/method1:user1@host1|method2:user2@host2|method3:user3@host3:"))
+
+  ;; No strings.
+  (should-not (tramp-tramp-file-p nil))
+  (should-not (tramp-tramp-file-p 'symbol))
+  ;; "/:" suppresses file name handlers.
+  (should-not (tramp-tramp-file-p "/::"))
+  (should-not (tramp-tramp-file-p "/:@:"))
+  (should-not (tramp-tramp-file-p "/:[]:"))
+  ;; Multihops require a method.
+  (should-not (tramp-tramp-file-p "/host1|host2:"))
+  ;; Methods or hostnames shall be at least two characters on MS Windows.
+  (when (memq system-type '(cygwin windows-nt))
+      (should-not (tramp-tramp-file-p "/c:/path/to/file"))
+      (should-not (tramp-tramp-file-p "/c::/path/to/file"))))
+
+(ert-deftest tramp-test02-file-name-dissect ()
+  "Check remote file name components."
+  (let ((tramp-default-method "default-method")
+       (tramp-default-user "default-user")
+       (tramp-default-host "default-host"))
+    ;; Expand `tramp-default-user' and `tramp-default-host'.
+    (should (string-equal
+            (file-remote-p "/method::")
+            (format "/%s:%s@%s:" "method" "default-user" "default-host")))
+    (should (string-equal (file-remote-p "/method::" 'method) "method"))
+    (should (string-equal (file-remote-p "/method::" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/method::" 'host) "default-host"))
+    (should (string-equal (file-remote-p "/method::" 'localname) ""))
+
+    ;; Expand `tramp-default-method' and `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/host:")
+            (format "/%s:%s@%s:" "default-method" "default-user" "host")))
+    (should (string-equal (file-remote-p "/host:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/host:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/host:" 'host) "host"))
+    (should (string-equal (file-remote-p "/host:" 'localname) ""))
+
+    ;; Expand `tramp-default-method' and `tramp-default-host'.
+    (should (string-equal
+            (file-remote-p "/user@:")
+            (format "/%s:%s@%s:" "default-method""user" "default-host")))
+    (should (string-equal (file-remote-p "/user@:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/user@:" 'user) "user"))
+    (should (string-equal (file-remote-p "/user@:" 'host) "default-host"))
+    (should (string-equal (file-remote-p "/user@:" 'localname) ""))
+
+    ;; Expand `tramp-default-method'.
+    (should (string-equal
+            (file-remote-p "/user@host:")
+            (format "/%s:%s@%s:" "default-method" "user" "host")))
+    (should (string-equal
+            (file-remote-p "/user@host:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/user@host:" 'user) "user"))
+    (should (string-equal (file-remote-p "/user@host:" 'host) "host"))
+    (should (string-equal (file-remote-p "/user@host:" 'localname) ""))
+
+    ;; Expand `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/method:host:")
+            (format "/%s:%s@%s:" "method" "default-user" "host")))
+    (should (string-equal (file-remote-p "/method:host:" 'method) "method"))
+    (should (string-equal (file-remote-p "/method:host:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/method:host:" 'host) "host"))
+    (should (string-equal (file-remote-p "/method:host:" 'localname) ""))
+
+    ;; Expand `tramp-default-host'.
+    (should (string-equal
+            (file-remote-p "/method:user@:")
+            (format "/%s:%s@%s:" "method" "user" "default-host")))
+    (should (string-equal (file-remote-p "/method:user@:" 'method) "method"))
+    (should (string-equal (file-remote-p "/method:user@:" 'user) "user"))
+    (should (string-equal (file-remote-p "/method:user@:" 'host)
+                         "default-host"))
+    (should (string-equal (file-remote-p "/method:user@:" 'localname) ""))
+
+    ;; No expansion.
+    (should (string-equal
+            (file-remote-p "/method:user@host:")
+            (format "/%s:%s@%s:" "method" "user" "host")))
+    (should (string-equal
+            (file-remote-p "/method:user@host:" 'method) "method"))
+    (should (string-equal (file-remote-p "/method:user@host:" 'user) "user"))
+    (should (string-equal (file-remote-p "/method:user@host:" 'host) "host"))
+    (should (string-equal (file-remote-p "/method:user@host:" 'localname) ""))
+
+    ;; No expansion.
+    (should (string-equal
+            (file-remote-p "/method:user@email@host:")
+            (format "/%s:%s@%s:" "method" "user@email" "host")))
+    (should (string-equal
+            (file-remote-p "/method:user@email@host:" 'method) "method"))
+    (should (string-equal
+            (file-remote-p "/method:user@email@host:" 'user) "user@email"))
+    (should (string-equal
+            (file-remote-p "/method:user@email@host:" 'host) "host"))
+    (should (string-equal
+            (file-remote-p "/method:user@email@host:" 'localname) ""))
+
+    ;; Expand `tramp-default-method' and `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/host#1234:")
+            (format "/%s:%s@%s:" "default-method" "default-user" "host#1234")))
+    (should (string-equal
+            (file-remote-p "/host#1234:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/host#1234:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/host#1234:" 'host) "host#1234"))
+    (should (string-equal (file-remote-p "/host#1234:" 'localname) ""))
+
+    ;; Expand `tramp-default-method'.
+    (should (string-equal
+            (file-remote-p "/user@host#1234:")
+            (format "/%s:%s@%s:" "default-method" "user" "host#1234")))
+    (should (string-equal
+            (file-remote-p "/user@host#1234:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/user@host#1234:" 'user) "user"))
+    (should (string-equal (file-remote-p "/user@host#1234:" 'host) "host#1234"))
+    (should (string-equal (file-remote-p "/user@host#1234:" 'localname) ""))
+
+    ;; Expand `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/method:host#1234:")
+            (format "/%s:%s@%s:" "method" "default-user" "host#1234")))
+    (should (string-equal
+            (file-remote-p "/method:host#1234:" 'method) "method"))
+    (should (string-equal
+            (file-remote-p "/method:host#1234:" 'user) "default-user"))
+    (should (string-equal
+            (file-remote-p "/method:host#1234:" 'host) "host#1234"))
+    (should (string-equal (file-remote-p "/method:host#1234:" 'localname) ""))
+
+    ;; No expansion.
+    (should (string-equal
+            (file-remote-p "/method:user@host#1234:")
+            (format "/%s:%s@%s:" "method" "user" "host#1234")))
+    (should (string-equal
+            (file-remote-p "/method:user@host#1234:" 'method) "method"))
+    (should (string-equal
+            (file-remote-p "/method:user@host#1234:" 'user) "user"))
+    (should (string-equal
+            (file-remote-p "/method:user@host#1234:" 'host) "host#1234"))
+    (should (string-equal
+            (file-remote-p "/method:user@host#1234:" 'localname) ""))
+
+    ;; Expand `tramp-default-method' and `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/1.2.3.4:")
+            (format "/%s:%s@%s:" "default-method" "default-user" "1.2.3.4")))
+    (should (string-equal (file-remote-p "/1.2.3.4:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/1.2.3.4:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4"))
+    (should (string-equal (file-remote-p "/1.2.3.4:" 'localname) ""))
+
+    ;; Expand `tramp-default-method'.
+    (should (string-equal
+            (file-remote-p "/user@1.2.3.4:")
+            (format "/%s:%s@%s:" "default-method" "user" "1.2.3.4")))
+    (should (string-equal
+            (file-remote-p "/user@1.2.3.4:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user"))
+    (should (string-equal (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4"))
+    (should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) ""))
+
+    ;; Expand `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/method:1.2.3.4:")
+            (format "/%s:%s@%s:" "method" "default-user" "1.2.3.4")))
+    (should (string-equal (file-remote-p "/method:1.2.3.4:" 'method) "method"))
+    (should (string-equal
+            (file-remote-p "/method:1.2.3.4:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4"))
+    (should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) ""))
+
+    ;; No expansion.
+    (should (string-equal
+            (file-remote-p "/method:user@1.2.3.4:")
+            (format "/%s:%s@%s:" "method" "user" "1.2.3.4")))
+    (should (string-equal
+            (file-remote-p "/method:user@1.2.3.4:" 'method) "method"))
+    (should (string-equal (file-remote-p "/method:user@1.2.3.4:" 'user) "user"))
+    (should (string-equal
+            (file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4"))
+    (should (string-equal
+            (file-remote-p "/method:user@1.2.3.4:" 'localname) ""))
+
+    ;; Expand `tramp-default-method', `tramp-default-user' and
+    ;; `tramp-default-host'.
+    (should (string-equal
+            (file-remote-p "/[]:")
+            (format
+             "/%s:%s@%s:" "default-method" "default-user" "default-host")))
+    (should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/[]:" 'host) "default-host"))
+    (should (string-equal (file-remote-p "/[]:" 'localname) ""))
+
+    ;; Expand `tramp-default-method' and `tramp-default-user'.
+    (let ((tramp-default-host "::1"))
+      (should (string-equal
+              (file-remote-p "/[]:")
+              (format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
+      (should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
+      (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
+      (should (string-equal (file-remote-p "/[]:" 'host) "::1"))
+      (should (string-equal (file-remote-p "/[]:" 'localname) "")))
+
+    ;; Expand `tramp-default-method' and `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/[::1]:")
+            (format "/%s:%s@%s:" "default-method" "default-user" "[::1]")))
+    (should (string-equal (file-remote-p "/[::1]:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/[::1]:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/[::1]:" 'host) "::1"))
+    (should (string-equal (file-remote-p "/[::1]:" 'localname) ""))
+
+    ;; Expand `tramp-default-method'.
+    (should (string-equal
+            (file-remote-p "/user@[::1]:")
+            (format "/%s:%s@%s:" "default-method" "user" "[::1]")))
+    (should (string-equal
+            (file-remote-p "/user@[::1]:" 'method) "default-method"))
+    (should (string-equal (file-remote-p "/user@[::1]:" 'user) "user"))
+    (should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1"))
+    (should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
+
+    ;; Expand `tramp-default-user'.
+    (should (string-equal
+            (file-remote-p "/method:[::1]:")
+            (format "/%s:%s@%s:" "method" "default-user" "[::1]")))
+    (should (string-equal (file-remote-p "/method:[::1]:" 'method) "method"))
+    (should (string-equal
+            (file-remote-p "/method:[::1]:" 'user) "default-user"))
+    (should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1"))
+    (should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
+
+    ;; No expansion.
+    (should (string-equal
+            (file-remote-p "/method:user@[::1]:")
+            (format "/%s:%s@%s:" "method" "user" "[::1]")))
+    (should (string-equal
+            (file-remote-p "/method:user@[::1]:" 'method) "method"))
+    (should (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user"))
+    (should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
+    (should (string-equal
+            (file-remote-p "/method:user@[::1]:" 'localname) ""))
+
+    ;; Local file name part.
+    (should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
+    (should (string-equal (file-remote-p "/method:::" 'localname) ":"))
+    (should (string-equal (file-remote-p "/method:: " 'localname) " "))
+    (should (string-equal (file-remote-p "/method::file" 'localname) "file"))
+    (should (string-equal
+            (file-remote-p "/method::/path/to/file" 'localname)
+            "/path/to/file"))
+
+    ;; Multihop.
+    (should
+     (string-equal
+      (file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file")
+      (format "/%s:%s@%s:" "method2" "user2" "host2")))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2:/path/to/file" 'method)
+      "method2"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2:/path/to/file" 'user)
+      "user2"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2:/path/to/file" 'host)
+      "host2"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname)
+      "/path/to/file"))
+
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file")
+      (format "/%s:%s@%s:" "method3" "user3" "host3")))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
+       'method)
+      "method3"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
+       'user)
+      "user3"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
+       'host)
+      "host3"))
+    (should
+     (string-equal
+      (file-remote-p
+       "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
+       'localname)
+      "/path/to/file"))))
+
+(ert-deftest tramp-test03-file-name-defaults ()
+  "Check default values for some methods."
+  ;; Default values in tramp-adb.el.
+  (should (string-equal (file-remote-p "/adb::" 'host) ""))
+  ;; Default values in tramp-ftp.el.
+  (should (string-equal (file-remote-p "/ftp.host:" 'method) "ftp"))
+  (dolist (u '("ftp" "anonymous"))
+    (should (string-equal (file-remote-p (format "/%s@:" u) 'method) "ftp")))
+  ;; Default values in tramp-gvfs.el.
+  (when (and (load "tramp-gvfs" 'noerror 'nomessage)
+            (symbol-value 'tramp-gvfs-enabled))
+    (should (string-equal (file-remote-p "/synce::" 'user) nil)))
+  ;; Default values in tramp-gw.el.
+  (dolist (m '("tunnel" "socks"))
+    (should
+     (string-equal (file-remote-p (format "/%s::" m) 'user) (user-login-name))))
+  ;; Default values in tramp-sh.el.
+  (dolist (h `("127.0.0.1" "[::1]" "localhost" "localhost6" ,(system-name)))
+    (should (string-equal (file-remote-p (format "/root@%s:" h) 'method) "su")))
+  (dolist (m '("su" "sudo" "ksu"))
+    (should (string-equal (file-remote-p (format "/%s::" m) 'user) "root")))
+  (dolist (m '("rcp" "remcp" "rsh" "telnet" "krlogin" "fcp"))
+    (should
+     (string-equal (file-remote-p (format "/%s::" m) 'user) (user-login-name))))
+  ;; Default values in tramp-smb.el.
+  (should (string-equal (file-remote-p "/user%domain@host:" 'method) "smb"))
+  (should (string-equal (file-remote-p "/smb::" 'user) nil)))
+
+(ert-deftest tramp-test04-substitute-in-file-name ()
+  "Check `substitute-in-file-name'."
+  (should (string-equal (substitute-in-file-name "/method:host://foo") "/foo"))
+  (should
+   (string-equal
+    (substitute-in-file-name "/method:host:/path//foo") "/method:host:/foo"))
+  (should
+   (string-equal (substitute-in-file-name "/method:host:/path///foo")  "/foo"))
+  (should
+   (string-equal
+    (substitute-in-file-name "/method:host:/path/~/foo") "/method:host:~/foo"))
+  (should
+   (string-equal (substitute-in-file-name "/method:host:/path//~/foo") "~/foo"))
+  (let (process-environment)
+    (should
+     (string-equal
+      (substitute-in-file-name "/method:host:/path/$FOO")
+      "/method:host:/path/$FOO"))
+    (setenv "FOO" "bla")
+    (should
+     (string-equal
+      (substitute-in-file-name "/method:host:/path/$FOO")
+      "/method:host:/path/bla"))
+    (should
+     (string-equal
+      (substitute-in-file-name "/method:host:/path/$$FOO")
+      "/method:host:/path/$FOO"))))
+
+(ert-deftest tramp-test05-expand-file-name ()
+  "Check `expand-file-name'."
+  (should
+   (string-equal
+    (expand-file-name "/method:host:/path/./file") "/method:host:/path/file"))
+  (should
+   (string-equal
+    (expand-file-name "/method:host:/path/../file") "/method:host:/file")))
+
+(ert-deftest tramp-test06-directory-file-name ()
+  "Check `directory-file-name'.
+This checks also `file-name-as-directory', `file-name-directory'
+and `file-name-nondirectory'."
+  (should
+   (string-equal
+    (directory-file-name "/method:host:/path/to/file")
+    "/method:host:/path/to/file"))
+  (should
+   (string-equal
+    (directory-file-name "/method:host:/path/to/file/")
+    "/method:host:/path/to/file"))
+  (should
+   (string-equal
+    (file-name-as-directory "/method:host:/path/to/file")
+    "/method:host:/path/to/file/"))
+  (should
+   (string-equal
+    (file-name-as-directory "/method:host:/path/to/file/")
+    "/method:host:/path/to/file/"))
+  (should
+   (string-equal
+    (file-name-directory "/method:host:/path/to/file")
+    "/method:host:/path/to/"))
+  (should
+   (string-equal
+    (file-name-directory "/method:host:/path/to/file/")
+    "/method:host:/path/to/file/"))
+  (should
+   (string-equal (file-name-nondirectory "/method:host:/path/to/file") "file"))
+  (should
+   (string-equal (file-name-nondirectory "/method:host:/path/to/file/") ""))
+  (should-not
+   (file-remote-p
+    (unhandled-file-name-directory "/method:host:/path/to/file"))))
+
+(ert-deftest tramp-test07-file-exists-p ()
+  "Check `file-exist-p', `write-region' and `delete-file'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (should-not (file-exists-p tmp-name))
+    (write-region "foo" nil tmp-name)
+    (should (file-exists-p tmp-name))
+    (delete-file tmp-name)
+    (should-not (file-exists-p tmp-name))))
+
+(ert-deftest tramp-test08-file-local-copy ()
+  "Check `file-local-copy'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name1 (tramp--test-make-temp-name))
+       tmp-name2)
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (should (setq tmp-name2 (file-local-copy tmp-name1)))
+         (with-temp-buffer
+           (insert-file-contents tmp-name2)
+           (should (string-equal (buffer-string) "foo"))))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))))
+
+(ert-deftest tramp-test09-insert-file-contents ()
+  "Check `insert-file-contents'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name)
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "foo"))
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "foofoo"))
+           ;; Insert partly.
+           (insert-file-contents tmp-name nil 1 3)
+           (should (string-equal (buffer-string) "oofoofoo"))
+           ;; Replace.
+           (insert-file-contents tmp-name nil nil nil 'replace)
+           (should (string-equal (buffer-string) "foo"))))
+      (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test10-write-region ()
+  "Check `write-region'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (with-temp-buffer
+           (insert "foo")
+           (write-region nil nil tmp-name))
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "foo")))
+         ;; Append.
+         (with-temp-buffer
+           (insert "bla")
+           (write-region nil nil tmp-name 'append))
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "foobla")))
+         ;; Write string.
+         (write-region "foo" nil tmp-name)
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "foo")))
+         ;; Write partly.
+         (with-temp-buffer
+           (insert "123456789")
+           (write-region 3 5 tmp-name))
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (string-equal (buffer-string) "34"))))
+     (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test11-copy-file ()
+  "Check `copy-file'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name1 (tramp--test-make-temp-name))
+       (tmp-name2 (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (copy-file tmp-name1 tmp-name2)
+         (should (file-exists-p tmp-name2))
+         (with-temp-buffer
+           (insert-file-contents tmp-name2)
+           (should (string-equal (buffer-string) "foo"))))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))))
+
+(ert-deftest tramp-test12-rename-file ()
+  "Check `rename-file'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name1 (tramp--test-make-temp-name))
+       (tmp-name2 (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (rename-file tmp-name1 tmp-name2)
+         (should-not (file-exists-p tmp-name1))
+         (should (file-exists-p tmp-name2))
+         (with-temp-buffer
+           (insert-file-contents tmp-name2)
+           (should (string-equal (buffer-string) "foo"))))
+      (ignore-errors (delete-file tmp-name2)))))
+
+(ert-deftest tramp-test13-make-directory ()
+  "Check `make-directory'.
+This tests also `file-directory-p' and `file-accessible-directory-p'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (make-directory tmp-name)
+         (should (file-directory-p tmp-name))
+         (should (file-accessible-directory-p tmp-name)))
+      (ignore-errors (delete-directory tmp-name)))))
+
+(ert-deftest tramp-test14-delete-directory ()
+  "Check `delete-directory'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    ;; Delete empty directory.
+    (make-directory tmp-name)
+    (should (file-directory-p tmp-name))
+    (delete-directory tmp-name)
+    (should-not (file-directory-p tmp-name))
+    ;; Delete non-empty directory.
+    (make-directory tmp-name)
+    (write-region "foo" nil (expand-file-name "bla" tmp-name))
+    (should-error (delete-directory tmp-name))
+    (delete-directory tmp-name 'recursive)
+    (should-not (file-directory-p tmp-name))))
+
+(ert-deftest tramp-test15-copy-directory ()
+  "Check `copy-directory'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let* ((tmp-name1 (tramp--test-make-temp-name))
+        (tmp-name2 (tramp--test-make-temp-name))
+        (tmp-name3 (expand-file-name
+                    (file-name-nondirectory tmp-name1) tmp-name2))
+        (tmp-name4 (expand-file-name "foo" tmp-name1))
+        (tmp-name5 (expand-file-name "foo" tmp-name2))
+        (tmp-name6 (expand-file-name "foo" tmp-name3)))
+    (unwind-protect
+       (progn
+         ;; Copy empty directory.
+         (make-directory tmp-name1)
+         (write-region "foo" nil tmp-name4)
+         (should (file-directory-p tmp-name1))
+         (should (file-exists-p tmp-name4))
+         (copy-directory tmp-name1 tmp-name2)
+         (should (file-directory-p tmp-name2))
+         (should (file-exists-p tmp-name5))
+         ;; Target directory does exist already.
+         (copy-directory tmp-name1 tmp-name2)
+         (should (file-directory-p tmp-name3))
+         (should (file-exists-p tmp-name6)))
+      (ignore-errors
+       (delete-directory tmp-name1 'recursive)
+       (delete-directory tmp-name2 'recursive)))))
+
+(ert-deftest tramp-test16-directory-files ()
+  "Check `directory-files'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let* ((tmp-name1 (tramp--test-make-temp-name))
+        (tmp-name2 (expand-file-name "bla" tmp-name1))
+        (tmp-name3 (expand-file-name "foo" tmp-name1)))
+    (unwind-protect
+       (progn
+         (make-directory tmp-name1)
+         (write-region "foo" nil tmp-name2)
+         (write-region "bla" nil tmp-name3)
+         (should (file-directory-p tmp-name1))
+         (should (file-exists-p tmp-name2))
+         (should (file-exists-p tmp-name3))
+         (should (equal (directory-files tmp-name1) '("." ".." "bla" "foo")))
+         (should (equal (directory-files tmp-name1 'full)
+                        `(,(concat tmp-name1 "/.")
+                          ,(concat tmp-name1 "/..")
+                          ,tmp-name2 ,tmp-name3)))
+         (should (equal (directory-files
+                         tmp-name1 nil directory-files-no-dot-files-regexp)
+                        '("bla" "foo")))
+         (should (equal (directory-files
+                         tmp-name1 'full directory-files-no-dot-files-regexp)
+                        `(,tmp-name2 ,tmp-name3))))
+      (ignore-errors (delete-directory tmp-name1 'recursive)))))
+
+(ert-deftest tramp-test17-insert-directory ()
+  "Check `insert-directory'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let* ((tmp-name1 (tramp--test-make-temp-name))
+        (tmp-name2 (expand-file-name "foo" tmp-name1)))
+    (unwind-protect
+       (progn
+         (make-directory tmp-name1)
+         (write-region "foo" nil tmp-name2)
+         (should (file-directory-p tmp-name1))
+         (should (file-exists-p tmp-name2))
+         (with-temp-buffer
+           (insert-directory tmp-name1 nil)
+           (goto-char (point-min))
+           (should (looking-at-p (regexp-quote tmp-name1))))
+         (with-temp-buffer
+           (insert-directory tmp-name1 "-al")
+           (goto-char (point-min))
+           (should (looking-at-p (format "^.+ %s$" (regexp-quote tmp-name1)))))
+         (with-temp-buffer
+           (insert-directory (file-name-as-directory tmp-name1) "-al")
+           (goto-char (point-min))
+           (should
+            (looking-at-p (format "^.+ %s/$" (regexp-quote tmp-name1)))))
+         (with-temp-buffer
+           (insert-directory
+            (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
+           (goto-char (point-min))
+           (should
+            (looking-at-p "total +[[:digit:]]+\n.+ \\.\n.+ \\.\\.\n.+ foo$"))))
+      (ignore-errors (delete-directory tmp-name1 'recursive)))))
+
+(ert-deftest tramp-test18-file-attributes ()
+  "Check `file-attributes'.
+This tests also `file-readable-p' and `file-regular-p'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name))
+       attr)
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name)
+         (should (file-exists-p tmp-name))
+         (setq attr (file-attributes tmp-name))
+         (should (consp attr))
+         (should (file-exists-p tmp-name))
+         (should (file-readable-p tmp-name))
+         (should (file-regular-p tmp-name))
+         ;; We do not test inodes and device numbers.
+         (should (null (car attr)))
+          (should (numberp (nth 1 attr))) ;; Link.
+          (should (numberp (nth 2 attr))) ;; Uid.
+          (should (numberp (nth 3 attr))) ;; Gid.
+         ;; Last access time.
+          (should (stringp (current-time-string (nth 4 attr))))
+         ;; Last modification time.
+          (should (stringp (current-time-string (nth 5 attr))))
+         ;; Last status change time.
+          (should (stringp (current-time-string (nth 6 attr))))
+          (should (numberp (nth 7 attr))) ;; Size.
+          (should (stringp (nth 8 attr))) ;; Modes.
+
+         (setq attr (file-attributes tmp-name 'string))
+          (should (stringp (nth 2 attr))) ;; Uid.
+          (should (stringp (nth 3 attr))) ;; Gid.
+         (delete-file tmp-name)
+
+         (make-directory tmp-name)
+         (should (file-exists-p tmp-name))
+         (should (file-readable-p tmp-name))
+         (should-not (file-regular-p tmp-name))
+         (setq attr (file-attributes tmp-name))
+         (should (eq (car attr) t)))
+      (ignore-errors (delete-directory tmp-name)))))
+
+(ert-deftest tramp-test19-directory-files-and-attributes ()
+  "Check `directory-files-and-attributes'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name))
+       attr)
+    (unwind-protect
+       (progn
+         (make-directory tmp-name)
+         (should (file-directory-p tmp-name))
+         (write-region "foo" nil (expand-file-name "foo" tmp-name))
+         (write-region "bar" nil (expand-file-name "bar" tmp-name))
+         (write-region "boz" nil (expand-file-name "boz" tmp-name))
+         (setq attr (directory-files-and-attributes tmp-name))
+         (should (consp attr))
+         (dolist (elt attr)
+           (should
+            (equal (file-attributes (expand-file-name (car elt) tmp-name))
+                   (cdr elt))))
+         (setq attr (directory-files-and-attributes tmp-name 'full))
+         (dolist (elt attr)
+           (should
+            (equal (file-attributes (car elt)) (cdr elt))))
+         (setq attr (directory-files-and-attributes tmp-name nil "^b"))
+         (should (equal (mapcar 'car attr) '("bar" "boz"))))
+      (ignore-errors (delete-directory tmp-name 'recursive)))))
+
+(ert-deftest tramp-test20-file-modes ()
+  "Check `file-modes'.
+This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name)
+         (should (file-exists-p tmp-name))
+         (set-file-modes tmp-name #o777)
+         (should (= (file-modes tmp-name) #o777))
+         (should (file-executable-p tmp-name))
+         (should (file-writable-p tmp-name))
+         (set-file-modes tmp-name #o444)
+         (should (= (file-modes tmp-name) #o444))
+         (should-not (file-executable-p tmp-name))
+         ;; A file is always writable for user "root".
+         (unless (string-equal (file-remote-p tmp-name 'user) "root")
+           (should-not (file-writable-p tmp-name))))
+      (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test21-file-links ()
+  "Check `file-symlink-p'.
+This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name1 (tramp--test-make-temp-name))
+       (tmp-name2 (tramp--test-make-temp-name))
+       (tmp-name3 (make-temp-name "tramp-")))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (should (file-exists-p tmp-name1))
+         (make-symbolic-link tmp-name1 tmp-name2)
+         (should (file-symlink-p tmp-name2))
+         (should-error (make-symbolic-link tmp-name1 tmp-name2))
+         (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists)
+         (should (file-symlink-p tmp-name2))
+         ;; `tmp-name3' is a local file name.
+         (should-error (make-symbolic-link tmp-name1 tmp-name3)))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))
+
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (should (file-exists-p tmp-name1))
+         (add-name-to-file tmp-name1 tmp-name2)
+         (should-not (file-symlink-p tmp-name2))
+         (should-error (add-name-to-file tmp-name1 tmp-name2))
+         (add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists)
+         (should-not (file-symlink-p tmp-name2))
+         ;; `tmp-name3' is a local file name.
+         (should-error (add-name-to-file tmp-name1 tmp-name3)))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))
+
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (should (file-exists-p tmp-name1))
+         (make-symbolic-link tmp-name1 tmp-name2)
+         (should (file-symlink-p tmp-name2))
+         (should-not (string-equal tmp-name2 (file-truename tmp-name2)))
+         (should
+          (string-equal (file-truename tmp-name1) (file-truename tmp-name2))))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))))
+
+(ert-deftest tramp-test22-file-times ()
+  "Check `set-file-times' and `file-newer-than-file-p'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name1 (tramp--test-make-temp-name))
+       (tmp-name2 (tramp--test-make-temp-name))
+       (tmp-name3 (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name1)
+         (should (file-exists-p tmp-name1))
+         (should (consp (nth 5 (file-attributes tmp-name1))))
+         ;; '(0 0) means don't know, and will be replaced by `current-time'.
+         (set-file-times tmp-name1 '(0 1))
+         (should (equal (nth 5 (file-attributes tmp-name1)) '(0 1)))
+         (write-region "bla" nil tmp-name2)
+         (should (file-exists-p tmp-name2))
+         (should (file-newer-than-file-p tmp-name2 tmp-name1))
+         ;; `tmp-name3' does not exist.
+         (should (file-newer-than-file-p tmp-name2 tmp-name3))
+         (should-not (file-newer-than-file-p tmp-name3 tmp-name1)))
+      (ignore-errors
+       (delete-file tmp-name1)
+       (delete-file tmp-name2)))))
+
+(ert-deftest tramp-test23-visited-file-modtime ()
+  "Check `set-visited-file-modtime' and `verify-visited-file-modtime'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (write-region "foo" nil tmp-name)
+         (should (file-exists-p tmp-name))
+         (with-temp-buffer
+           (insert-file-contents tmp-name)
+           (should (verify-visited-file-modtime))
+           (set-visited-file-modtime '(0 1))
+           (should (verify-visited-file-modtime))
+           (should (equal (visited-file-modtime) '(0 1 0 0)))))
+      (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test24-file-name-completion ()
+  "Check `file-name-completion' and `file-name-all-completions'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (make-directory tmp-name)
+         (should (file-directory-p tmp-name))
+         (write-region "foo" nil (expand-file-name "foo" tmp-name))
+         (write-region "bar" nil (expand-file-name "bold" tmp-name))
+         (make-directory (expand-file-name "boz" tmp-name))
+         (should (equal (file-name-completion "fo" tmp-name) "foo"))
+         (should (equal (file-name-completion "b" tmp-name) "bo"))
+         (should
+          (equal (file-name-completion "b" tmp-name 'file-directory-p) "boz/"))
+         (should (equal (file-name-all-completions "fo" tmp-name) '("foo")))
+         (should
+          (equal (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
+                 '("bold" "boz/"))))
+      (ignore-errors (delete-directory tmp-name 'recursive)))))
+
+(ert-deftest tramp-test25-load ()
+  "Check `load'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name)))
+    (unwind-protect
+       (progn
+         (load tmp-name 'noerror 'nomessage)
+         (should-not (featurep 'tramp-test-load))
+         (write-region "(provide 'tramp-test-load)" nil tmp-name)
+         ;; `load' in lread.c does not pass `must-suffix'.  Why?
+         ;(should-error (load tmp-name nil 'nomessage 'nosuffix 'must-suffix))
+         (load tmp-name nil 'nomessage 'nosuffix)
+         (should (featurep 'tramp-test-load)))
+      (ignore-errors
+       (and (featurep 'tramp-test-load) (unload-feature 'tramp-test-load))
+       (delete-file tmp-name)))))
+
+(ert-deftest tramp-test26-process-file ()
+  "Check `process-file'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name))
+       (default-directory tramp-test-temporary-file-directory))
+    (unwind-protect
+       (progn
+         ;; We cannot use "/bin/true" and "/bin/false"; those paths
+         ;; do not exist on hydra.
+         (should (zerop (process-file "true")))
+         (should-not (zerop (process-file "false")))
+         (should-not (zerop (process-file "binary-does-not-exist")))
+         (with-temp-buffer
+           (write-region "foo" nil tmp-name)
+           (should (zerop (process-file "ls" nil t)))
+           (should (> (point-max) (point-min)))))
+      (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test27-start-file-process ()
+  "Check `start-file-process'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((default-directory tramp-test-temporary-file-directory)
+       (tmp-name (tramp--test-make-temp-name))
+       kill-buffer-query-functions proc)
+    (unwind-protect
+       (with-temp-buffer
+         (setq proc (start-file-process "test1" (current-buffer) "cat"))
+         (should (processp proc))
+         (should (equal (process-status proc) 'run))
+         (process-send-string proc "foo")
+         (process-send-eof proc)
+         (accept-process-output proc 1)
+         (should (string-equal (buffer-string) "foo")))
+      (ignore-errors (delete-process proc)))
+
+    (unwind-protect
+       (with-temp-buffer
+         (write-region "foo" nil tmp-name)
+         (should (file-exists-p tmp-name))
+         (setq proc
+               (start-file-process
+                "test2" (current-buffer)
+                "cat" (file-name-nondirectory tmp-name)))
+         (should (processp proc))
+         (accept-process-output proc 1)
+         (should (string-equal (buffer-string) "foo")))
+      (ignore-errors
+       (delete-process proc)
+       (delete-file tmp-name)))
+
+    (unwind-protect
+       (progn
+         (setq proc (start-file-process "test3" nil "cat"))
+         (should (processp proc))
+         (should (equal (process-status proc) 'run))
+         (set-process-filter
+          proc (lambda (p s) (should (string-equal s "foo"))))
+         (process-send-string proc "foo")
+         (process-send-eof proc)
+         (accept-process-output proc 1))
+      (ignore-errors (delete-process proc)))))
+
+(ert-deftest tramp-test28-shell-command ()
+  "Check `shell-command'."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name))
+       (default-directory tramp-test-temporary-file-directory))
+    (unwind-protect
+       (with-temp-buffer
+         (write-region "foo" nil tmp-name)
+         (shell-command "ls" (current-buffer))
+         (should (> (point-max) (point-min))))
+      (ignore-errors (delete-file tmp-name)))))
+
+(ert-deftest tramp-test29-utf8 ()
+  "Check UTF8 encoding in file names and file contents."
+  (skip-unless (tramp--test-enabled))
+  (tramp-cleanup-connection
+   (tramp-dissect-file-name tramp-test-temporary-file-directory)
+   nil 'keep-password)
+
+  (let ((tmp-name (tramp--test-make-temp-name))
+       (arabic "أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
+       (chinese "银河系漫游指南系列")
+       (russian "Автостопом по гала́ктике"))
+    (unwind-protect
+       (progn
+         (make-directory tmp-name)
+         (dolist (lang `(,arabic ,chinese ,russian))
+           (let ((file (expand-file-name lang tmp-name)))
+             (write-region lang nil file)
+             (should (file-exists-p file))
+             ;; Check file contents.
+             (with-temp-buffer
+               (insert-file-contents file)
+               (should (string-equal (buffer-string) lang)))))
+         ;; Check file names.
+         (should (equal (directory-files
+                         tmp-name nil directory-files-no-dot-files-regexp)
+                        (sort `(,arabic ,chinese ,russian) 'string-lessp))))
+      (ignore-errors (delete-directory tmp-name 'recursive)))))
+
+;; TODO:
+
+;; * dired-compress-file
+;; * dired-uncache
+;; * file-acl
+;; * file-ownership-preserved-p
+;; * file-selinux-context
+;; * find-backup-file-name
+;; * make-auto-save-file-name
+;; * set-file-acl
+;; * set-file-selinux-context
+;; * vc-registered
+
+(defun tramp-test-all (&optional interactive)
+  "Run all tests for \\[tramp]."
+  (interactive "p")
+  (funcall
+   (if interactive 'ert-run-tests-interactively 'ert-run-tests-batch) "^tramp"))
+
+(provide 'tramp-tests)
+;;; tramp-tests.el ends here
index 2776435be82c4ad0526103d84378b088f7d539e7..18918607c27c44a0b50ca0f73e052bac8e551442 100644 (file)
 (require 'vc-bzr)
 (require 'vc-dir)
 
-;; FIXME it would be better to skip all these tests if there is no
-;; bzr installed.  We could just put everything inside an IF
-;; statement, but it would be nice if ERT had a "skipped" facility (?).
-
 (ert-deftest vc-bzr-test-bug9726 ()
   "Test for http://debbugs.gnu.org/9726 ."
-  :expected-result (if (executable-find vc-bzr-program) :passed :failed)
-  (should (executable-find vc-bzr-program))
+  (skip-unless (executable-find vc-bzr-program))
   (let* ((tempdir (make-temp-file "vc-bzr-test" t))
          (ignored-dir (expand-file-name "ignored-dir" tempdir))
          (default-directory (file-name-as-directory tempdir)))
@@ -64,8 +59,7 @@
 ;; Not specific to bzr.
 (ert-deftest vc-bzr-test-bug9781 ()
   "Test for http://debbugs.gnu.org/9781 ."
-  :expected-result (if (executable-find vc-bzr-program) :passed :failed)
-  (should (executable-find vc-bzr-program))
+  (skip-unless (executable-find vc-bzr-program))
   (let* ((tempdir (make-temp-file "vc-bzr-test" t))
          (subdir (expand-file-name "subdir" tempdir))
          (file (expand-file-name "file" tempdir))
 ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
 (ert-deftest vc-bzr-test-faulty-bzr-autoloads ()
   "Test we can generate autoloads in a bzr directory when bzr is faulty."
-  :expected-result (if (executable-find vc-bzr-program) :passed :failed)
-  (should (executable-find vc-bzr-program))
+  (skip-unless (executable-find vc-bzr-program))
   (let* ((tempdir (make-temp-file "vc-bzr-test" t))
          (file (expand-file-name "foo.el" tempdir))
          (default-directory (file-name-as-directory tempdir))
index d03d4c981b8f49f4a845e421adaef105ef54f714..57823a2e2dbb202e05ef57ef96dbb1bfe53d6c92 100644 (file)
 
 (require 'ert)
 
+(defvar zlib-tests-data-directory
+  (expand-file-name "data/decompress" (getenv "EMACS_TEST_DIRECTORY"))
+  "Directory containing zlib test data.")
+
 (ert-deftest zlib--decompress ()
   "Test decompressing a gzipped file."
   (when (and (fboundp 'zlib-available-p)
@@ -30,7 +34,8 @@
     (should (string=
             (with-temp-buffer
               (set-buffer-multibyte nil)
-              (insert-file-contents-literally "data/decompress/foo-gzipped")
+              (insert-file-contents-literally
+               (expand-file-name "foo-gzipped" zlib-tests-data-directory))
               (zlib-decompress-region (point-min) (point-max))
               (buffer-string))
             "foo\n"))))
index 9a2a15f6ba5429aec83f59bda9deafef5d37909d..4dbab06975c9630f9436f0f39a3eb2c9a7a1806b 100644 (file)
@@ -4,6 +4,8 @@
 
 .x2
 {
+    foo: bar;
+    bar: baz;
 }
 
 div.x3
index 8af21877b595906671768ef98ddd3a9e73ee0acf..5b5d272c579721f2a0d6ab3c1862473d98980d01 100644 (file)
@@ -48,7 +48,19 @@ subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)) :-
           subst(Y, Y1, [], Bi, Bi1);
       Y1 = Y, Bi1 = Bi),
      %% Perform substitution on the body.
-     subst(X, V, FV, Bi1, Bo)).
+     subst(X, V, FV, Bi1, Bo)),
+    (  X = Y
+     %% If X is equal to Y, X is shadowed, so no subst can take place.
+     ->        Y1 = Y, Bo = Bi
+     ; (member((Y, _), FV)
+        %% If Y appears in FV, it can appear in V, so we need to
+        %% rename it to avoid name capture.
+        -> new_atom(Y, Y1),
+           subst(Y, Y1, [], Bi, Bi1)
+        ; Y1 = Y, Bi1 = Bi),
+       %% Perform substitution on the body.
+       subst(X, V, FV, Bi1, Bo)
+    ).
 subst(X, V, FV, pi(Y, Ti, Bi), pi(Y1, To, Bo)) :-
     subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)).
 subst(X, V, FV, forall(Y, Ti, Bi), forall(Y1, To, Bo)) :-
index ef89ebc1aa767d7d9b7c61f7fb72793ac11cc8a1..a3ab73bcfb5973a994d16f0ca967f5771a96cb66 100644 (file)
@@ -3,6 +3,7 @@ if something_wrong?             # ruby-move-to-block-skips-heredoc
   boo hoo
   end
   eowarn
+  foo
 end
 
 # Percent literals.
@@ -40,6 +41,15 @@ foo = {                         # ruby-deep-indent-disabled
   a: b
 }
 
+foo = { a: b,
+        a1: b1
+      }
+
+foo({
+     a: b,
+     c: d
+   })
+
 foo = [                         # ruby-deep-indent-disabled
   1
 ]
@@ -107,6 +117,9 @@ d = 4 + 5 +      # no '\' needed
 e = 8 + 9   \
     + 10         # '\' needed
 
+foo = obj.bar { |m| tee(m) } +
+      obj.qux { |m| hum(m) }
+
 begin
   foo
 ensure
@@ -165,38 +178,124 @@ method? arg1,
 method! arg1,
         arg2
 
-# Examples below still fail with `ruby-use-smie' on:
+method !arg1,
+       arg2
+
+method [],
+       arg2
+
+method :foo,
+       :bar
+
+method (a + b),
+       c, :d => :e,
+       f: g
+
+it "is a method call with block" do |asd|
+  foo
+end
+
+it("is too!") {
+  bar
+}
+
+and_this_one(has) { |block, parameters|
+  tee
+}
+
+if foo &&
+   bar
+end
 
 foo +
   bar
 
-foo = [1, 2, 3].map do |i|
-  i + 1
+foo and
+  bar
+
+foo > bar &&
+  tee < qux
+
+zux do
+  foo == bar and
+    tee == qux
 end
 
+foo ^
+  bar
+
 foo_bar_tee(1, 2, 3)
   .qux
+  .bar
 
-if foo &&
-    bar
+foo do
+  bar
+    .tee
 end
 
-method !arg1,
-       arg2
+def bar
+  foo
+    .baz
+end
 
-method [],
-       arg2
+# http://stackoverflow.com/questions/17786563/emacs-ruby-mode-if-expressions-indentation
+tee = if foo
+        bar
+      end
 
-method :foo,
-       :bar
+a = b {
+  c
+}
 
-method (a + b),
-       c
+aa = bb do
+  cc
+end
 
-it "is a method call with block" do
-  foo
+foo :bar do
+  qux
 end
 
-it("is too!") {
+foo do |*args|
+  tee
+end
+
+bar do |&block|
+  tee
+end
+
+foo = [1, 2, 3].map do |i|
+  i + 1
+end
+
+bar.foo do
+  bar
+end
+
+bar.foo(tee) do
+  bar
+end
+
+bar.foo(tee) {
   bar
 }
+
+bar 1 do
+  foo 2 do
+    tee
+  end
+end
+
+foo |
+  bar
+
+foo ||
+  begin
+    bar
+  end
+
+def qux
+  foo ||= begin
+    bar
+    tee
+  end
+end
index e402398b99628759288f168d222fdbab28008163..fdf736e06bec1892622a2bb849192be3b09c1191 100755 (executable)
@@ -35,7 +35,7 @@ echo $[1<<8]                    # bug#11263
 declare -a VERSION
 for i in $(ls "$PREFIX/sbin") ; do
     echo -e $N')' $i
-    VERSION[${#VERSION[*]}]=$i         #bug#11946.
+    VERSION[${#VERSION[*]}]=$i  bug#11946.
     N=$(($N + 1))
 done